]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.8.8-201304172116.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.8.8-201304172116.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 7684f95..12f2f86 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 7361e47..16dc226 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 @@ -714,6 +726,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 @@ -930,7 +957,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 @@ -1005,6 +1032,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 b3b0ec1..b1cd3eb 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 @@ -98,7 +98,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 @@ -192,7 +192,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 @@ -223,7 +223,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 @@ -313,6 +313,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 @@ -324,6 +325,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 @@ -334,7 +341,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/uaccess.h b/arch/x86/include/asm/uaccess.h
15918 index 1709801..0a60f2f 100644
15919 --- a/arch/x86/include/asm/uaccess.h
15920 +++ b/arch/x86/include/asm/uaccess.h
15921 @@ -7,6 +7,7 @@
15922 #include <linux/compiler.h>
15923 #include <linux/thread_info.h>
15924 #include <linux/string.h>
15925 +#include <linux/sched.h>
15926 #include <asm/asm.h>
15927 #include <asm/page.h>
15928 #include <asm/smap.h>
15929 @@ -29,7 +30,12 @@
15930
15931 #define get_ds() (KERNEL_DS)
15932 #define get_fs() (current_thread_info()->addr_limit)
15933 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15934 +void __set_fs(mm_segment_t x);
15935 +void set_fs(mm_segment_t x);
15936 +#else
15937 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15938 +#endif
15939
15940 #define segment_eq(a, b) ((a).seg == (b).seg)
15941
15942 @@ -77,8 +83,33 @@
15943 * checks that the pointer is in the user space range - after calling
15944 * this function, memory access functions may still return -EFAULT.
15945 */
15946 -#define access_ok(type, addr, size) \
15947 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15948 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15949 +#define access_ok(type, addr, size) \
15950 +({ \
15951 + long __size = size; \
15952 + unsigned long __addr = (unsigned long)addr; \
15953 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15954 + unsigned long __end_ao = __addr + __size - 1; \
15955 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15956 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15957 + while(__addr_ao <= __end_ao) { \
15958 + char __c_ao; \
15959 + __addr_ao += PAGE_SIZE; \
15960 + if (__size > PAGE_SIZE) \
15961 + cond_resched(); \
15962 + if (__get_user(__c_ao, (char __user *)__addr)) \
15963 + break; \
15964 + if (type != VERIFY_WRITE) { \
15965 + __addr = __addr_ao; \
15966 + continue; \
15967 + } \
15968 + if (__put_user(__c_ao, (char __user *)__addr)) \
15969 + break; \
15970 + __addr = __addr_ao; \
15971 + } \
15972 + } \
15973 + __ret_ao; \
15974 +})
15975
15976 /*
15977 * The exception table consists of pairs of addresses relative to the
15978 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
15979 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15980 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15981
15982 -
15983 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15984 +#define __copyuser_seg "gs;"
15985 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15986 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15987 +#else
15988 +#define __copyuser_seg
15989 +#define __COPYUSER_SET_ES
15990 +#define __COPYUSER_RESTORE_ES
15991 +#endif
15992
15993 #ifdef CONFIG_X86_32
15994 #define __put_user_asm_u64(x, addr, err, errret) \
15995 asm volatile(ASM_STAC "\n" \
15996 - "1: movl %%eax,0(%2)\n" \
15997 - "2: movl %%edx,4(%2)\n" \
15998 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15999 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
16000 "3: " ASM_CLAC "\n" \
16001 ".section .fixup,\"ax\"\n" \
16002 "4: movl %3,%0\n" \
16003 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
16004
16005 #define __put_user_asm_ex_u64(x, addr) \
16006 asm volatile(ASM_STAC "\n" \
16007 - "1: movl %%eax,0(%1)\n" \
16008 - "2: movl %%edx,4(%1)\n" \
16009 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
16010 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
16011 "3: " ASM_CLAC "\n" \
16012 _ASM_EXTABLE_EX(1b, 2b) \
16013 _ASM_EXTABLE_EX(2b, 3b) \
16014 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
16015 __typeof__(*(ptr)) __pu_val; \
16016 __chk_user_ptr(ptr); \
16017 might_fault(); \
16018 - __pu_val = x; \
16019 + __pu_val = (x); \
16020 switch (sizeof(*(ptr))) { \
16021 case 1: \
16022 __put_user_x(1, __pu_val, ptr, __ret_pu); \
16023 @@ -358,7 +397,7 @@ do { \
16024
16025 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16026 asm volatile(ASM_STAC "\n" \
16027 - "1: mov"itype" %2,%"rtype"1\n" \
16028 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
16029 "2: " ASM_CLAC "\n" \
16030 ".section .fixup,\"ax\"\n" \
16031 "3: mov %3,%0\n" \
16032 @@ -366,7 +405,7 @@ do { \
16033 " jmp 2b\n" \
16034 ".previous\n" \
16035 _ASM_EXTABLE(1b, 3b) \
16036 - : "=r" (err), ltype(x) \
16037 + : "=r" (err), ltype (x) \
16038 : "m" (__m(addr)), "i" (errret), "0" (err))
16039
16040 #define __get_user_size_ex(x, ptr, size) \
16041 @@ -391,7 +430,7 @@ do { \
16042 } while (0)
16043
16044 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
16045 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
16046 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
16047 "2:\n" \
16048 _ASM_EXTABLE_EX(1b, 2b) \
16049 : ltype(x) : "m" (__m(addr)))
16050 @@ -408,13 +447,24 @@ do { \
16051 int __gu_err; \
16052 unsigned long __gu_val; \
16053 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
16054 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
16055 + (x) = (__typeof__(*(ptr)))__gu_val; \
16056 __gu_err; \
16057 })
16058
16059 /* FIXME: this hack is definitely wrong -AK */
16060 struct __large_struct { unsigned long buf[100]; };
16061 -#define __m(x) (*(struct __large_struct __user *)(x))
16062 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16063 +#define ____m(x) \
16064 +({ \
16065 + unsigned long ____x = (unsigned long)(x); \
16066 + if (____x < PAX_USER_SHADOW_BASE) \
16067 + ____x += PAX_USER_SHADOW_BASE; \
16068 + (void __user *)____x; \
16069 +})
16070 +#else
16071 +#define ____m(x) (x)
16072 +#endif
16073 +#define __m(x) (*(struct __large_struct __user *)____m(x))
16074
16075 /*
16076 * Tell gcc we read from memory instead of writing: this is because
16077 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
16078 */
16079 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16080 asm volatile(ASM_STAC "\n" \
16081 - "1: mov"itype" %"rtype"1,%2\n" \
16082 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
16083 "2: " ASM_CLAC "\n" \
16084 ".section .fixup,\"ax\"\n" \
16085 "3: mov %3,%0\n" \
16086 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
16087 ".previous\n" \
16088 _ASM_EXTABLE(1b, 3b) \
16089 : "=r"(err) \
16090 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
16091 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
16092
16093 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
16094 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
16095 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
16096 "2:\n" \
16097 _ASM_EXTABLE_EX(1b, 2b) \
16098 : : ltype(x), "m" (__m(addr)))
16099 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
16100 * On error, the variable @x is set to zero.
16101 */
16102
16103 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16104 +#define __get_user(x, ptr) get_user((x), (ptr))
16105 +#else
16106 #define __get_user(x, ptr) \
16107 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
16108 +#endif
16109
16110 /**
16111 * __put_user: - Write a simple value into user space, with less checking.
16112 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
16113 * Returns zero on success, or -EFAULT on error.
16114 */
16115
16116 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16117 +#define __put_user(x, ptr) put_user((x), (ptr))
16118 +#else
16119 #define __put_user(x, ptr) \
16120 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
16121 +#endif
16122
16123 #define __get_user_unaligned __get_user
16124 #define __put_user_unaligned __put_user
16125 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
16126 #define get_user_ex(x, ptr) do { \
16127 unsigned long __gue_val; \
16128 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
16129 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
16130 + (x) = (__typeof__(*(ptr)))__gue_val; \
16131 } while (0)
16132
16133 #define put_user_try uaccess_try
16134 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
16135 extern __must_check long strlen_user(const char __user *str);
16136 extern __must_check long strnlen_user(const char __user *str, long n);
16137
16138 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
16139 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
16140 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16141 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16142
16143 /*
16144 * movsl can be slow when source and dest are not both 8-byte aligned
16145 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
16146 index 7f760a9..04b1c65 100644
16147 --- a/arch/x86/include/asm/uaccess_32.h
16148 +++ b/arch/x86/include/asm/uaccess_32.h
16149 @@ -11,15 +11,15 @@
16150 #include <asm/page.h>
16151
16152 unsigned long __must_check __copy_to_user_ll
16153 - (void __user *to, const void *from, unsigned long n);
16154 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
16155 unsigned long __must_check __copy_from_user_ll
16156 - (void *to, const void __user *from, unsigned long n);
16157 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16158 unsigned long __must_check __copy_from_user_ll_nozero
16159 - (void *to, const void __user *from, unsigned long n);
16160 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16161 unsigned long __must_check __copy_from_user_ll_nocache
16162 - (void *to, const void __user *from, unsigned long n);
16163 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16164 unsigned long __must_check __copy_from_user_ll_nocache_nozero
16165 - (void *to, const void __user *from, unsigned long n);
16166 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16167
16168 /**
16169 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
16170 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
16171 static __always_inline unsigned long __must_check
16172 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
16173 {
16174 + if ((long)n < 0)
16175 + return n;
16176 +
16177 + check_object_size(from, n, true);
16178 +
16179 if (__builtin_constant_p(n)) {
16180 unsigned long ret;
16181
16182 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
16183 __copy_to_user(void __user *to, const void *from, unsigned long n)
16184 {
16185 might_fault();
16186 +
16187 return __copy_to_user_inatomic(to, from, n);
16188 }
16189
16190 static __always_inline unsigned long
16191 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
16192 {
16193 + if ((long)n < 0)
16194 + return n;
16195 +
16196 /* Avoid zeroing the tail if the copy fails..
16197 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
16198 * but as the zeroing behaviour is only significant when n is not
16199 @@ -137,6 +146,12 @@ static __always_inline unsigned long
16200 __copy_from_user(void *to, const void __user *from, unsigned long n)
16201 {
16202 might_fault();
16203 +
16204 + if ((long)n < 0)
16205 + return n;
16206 +
16207 + check_object_size(to, n, false);
16208 +
16209 if (__builtin_constant_p(n)) {
16210 unsigned long ret;
16211
16212 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16213 const void __user *from, unsigned long n)
16214 {
16215 might_fault();
16216 +
16217 + if ((long)n < 0)
16218 + return n;
16219 +
16220 if (__builtin_constant_p(n)) {
16221 unsigned long ret;
16222
16223 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16224 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16225 unsigned long n)
16226 {
16227 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16228 + if ((long)n < 0)
16229 + return n;
16230 +
16231 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16232 }
16233
16234 -unsigned long __must_check copy_to_user(void __user *to,
16235 - const void *from, unsigned long n);
16236 -unsigned long __must_check _copy_from_user(void *to,
16237 - const void __user *from,
16238 - unsigned long n);
16239 -
16240 +extern void copy_to_user_overflow(void)
16241 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16242 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16243 +#else
16244 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16245 +#endif
16246 +;
16247
16248 extern void copy_from_user_overflow(void)
16249 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16250 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16251 #endif
16252 ;
16253
16254 -static inline unsigned long __must_check copy_from_user(void *to,
16255 - const void __user *from,
16256 - unsigned long n)
16257 +/**
16258 + * copy_to_user: - Copy a block of data into user space.
16259 + * @to: Destination address, in user space.
16260 + * @from: Source address, in kernel space.
16261 + * @n: Number of bytes to copy.
16262 + *
16263 + * Context: User context only. This function may sleep.
16264 + *
16265 + * Copy data from kernel space to user space.
16266 + *
16267 + * Returns number of bytes that could not be copied.
16268 + * On success, this will be zero.
16269 + */
16270 +static inline unsigned long __must_check
16271 +copy_to_user(void __user *to, const void *from, unsigned long n)
16272 {
16273 - int sz = __compiletime_object_size(to);
16274 + size_t sz = __compiletime_object_size(from);
16275
16276 - if (likely(sz == -1 || sz >= n))
16277 - n = _copy_from_user(to, from, n);
16278 - else
16279 + if (unlikely(sz != (size_t)-1 && sz < n))
16280 + copy_to_user_overflow();
16281 + else if (access_ok(VERIFY_WRITE, to, n))
16282 + n = __copy_to_user(to, from, n);
16283 + return n;
16284 +}
16285 +
16286 +/**
16287 + * copy_from_user: - Copy a block of data from user space.
16288 + * @to: Destination address, in kernel space.
16289 + * @from: Source address, in user space.
16290 + * @n: Number of bytes to copy.
16291 + *
16292 + * Context: User context only. This function may sleep.
16293 + *
16294 + * Copy data from user space to kernel space.
16295 + *
16296 + * Returns number of bytes that could not be copied.
16297 + * On success, this will be zero.
16298 + *
16299 + * If some data could not be copied, this function will pad the copied
16300 + * data to the requested size using zero bytes.
16301 + */
16302 +static inline unsigned long __must_check
16303 +copy_from_user(void *to, const void __user *from, unsigned long n)
16304 +{
16305 + size_t sz = __compiletime_object_size(to);
16306 +
16307 + check_object_size(to, n, false);
16308 +
16309 + if (unlikely(sz != (size_t)-1 && sz < n))
16310 copy_from_user_overflow();
16311 -
16312 + else if (access_ok(VERIFY_READ, from, n))
16313 + n = __copy_from_user(to, from, n);
16314 + else if ((long)n > 0)
16315 + memset(to, 0, n);
16316 return n;
16317 }
16318
16319 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16320 index 142810c..1f2a0a7 100644
16321 --- a/arch/x86/include/asm/uaccess_64.h
16322 +++ b/arch/x86/include/asm/uaccess_64.h
16323 @@ -10,6 +10,9 @@
16324 #include <asm/alternative.h>
16325 #include <asm/cpufeature.h>
16326 #include <asm/page.h>
16327 +#include <asm/pgtable.h>
16328 +
16329 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16330
16331 /*
16332 * Copy To/From Userspace
16333 @@ -17,13 +20,13 @@
16334
16335 /* Handles exceptions in both to and from, but doesn't do access_ok */
16336 __must_check unsigned long
16337 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16338 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16339 __must_check unsigned long
16340 -copy_user_generic_string(void *to, const void *from, unsigned len);
16341 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16342 __must_check unsigned long
16343 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16344 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16345
16346 -static __always_inline __must_check unsigned long
16347 +static __always_inline __must_check __size_overflow(3) unsigned long
16348 copy_user_generic(void *to, const void *from, unsigned len)
16349 {
16350 unsigned ret;
16351 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16352 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16353 "=d" (len)),
16354 "1" (to), "2" (from), "3" (len)
16355 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16356 + : "memory", "rcx", "r8", "r9", "r11");
16357 return ret;
16358 }
16359
16360 +static __always_inline __must_check unsigned long
16361 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16362 +static __always_inline __must_check unsigned long
16363 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16364 __must_check unsigned long
16365 -_copy_to_user(void __user *to, const void *from, unsigned len);
16366 -__must_check unsigned long
16367 -_copy_from_user(void *to, const void __user *from, unsigned len);
16368 -__must_check unsigned long
16369 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16370 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16371 +
16372 +extern void copy_to_user_overflow(void)
16373 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16374 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16375 +#else
16376 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16377 +#endif
16378 +;
16379 +
16380 +extern void copy_from_user_overflow(void)
16381 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16382 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16383 +#else
16384 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16385 +#endif
16386 +;
16387
16388 static inline unsigned long __must_check copy_from_user(void *to,
16389 const void __user *from,
16390 unsigned long n)
16391 {
16392 - int sz = __compiletime_object_size(to);
16393 -
16394 might_fault();
16395 - if (likely(sz == -1 || sz >= n))
16396 - n = _copy_from_user(to, from, n);
16397 -#ifdef CONFIG_DEBUG_VM
16398 - else
16399 - WARN(1, "Buffer overflow detected!\n");
16400 -#endif
16401 +
16402 + check_object_size(to, n, false);
16403 +
16404 + if (access_ok(VERIFY_READ, from, n))
16405 + n = __copy_from_user(to, from, n);
16406 + else if (n < INT_MAX)
16407 + memset(to, 0, n);
16408 return n;
16409 }
16410
16411 static __always_inline __must_check
16412 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16413 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16414 {
16415 might_fault();
16416
16417 - return _copy_to_user(dst, src, size);
16418 + if (access_ok(VERIFY_WRITE, dst, size))
16419 + size = __copy_to_user(dst, src, size);
16420 + return size;
16421 }
16422
16423 static __always_inline __must_check
16424 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16425 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16426 {
16427 - int ret = 0;
16428 + size_t sz = __compiletime_object_size(dst);
16429 + unsigned ret = 0;
16430
16431 might_fault();
16432 +
16433 + if (size > INT_MAX)
16434 + return size;
16435 +
16436 + check_object_size(dst, size, false);
16437 +
16438 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16439 + if (!__access_ok(VERIFY_READ, src, size))
16440 + return size;
16441 +#endif
16442 +
16443 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16444 + copy_from_user_overflow();
16445 + return size;
16446 + }
16447 +
16448 if (!__builtin_constant_p(size))
16449 - return copy_user_generic(dst, (__force void *)src, size);
16450 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16451 switch (size) {
16452 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16453 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16454 ret, "b", "b", "=q", 1);
16455 return ret;
16456 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16457 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16458 ret, "w", "w", "=r", 2);
16459 return ret;
16460 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16461 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16462 ret, "l", "k", "=r", 4);
16463 return ret;
16464 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16465 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16466 ret, "q", "", "=r", 8);
16467 return ret;
16468 case 10:
16469 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16470 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16471 ret, "q", "", "=r", 10);
16472 if (unlikely(ret))
16473 return ret;
16474 __get_user_asm(*(u16 *)(8 + (char *)dst),
16475 - (u16 __user *)(8 + (char __user *)src),
16476 + (const u16 __user *)(8 + (const char __user *)src),
16477 ret, "w", "w", "=r", 2);
16478 return ret;
16479 case 16:
16480 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16481 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16482 ret, "q", "", "=r", 16);
16483 if (unlikely(ret))
16484 return ret;
16485 __get_user_asm(*(u64 *)(8 + (char *)dst),
16486 - (u64 __user *)(8 + (char __user *)src),
16487 + (const u64 __user *)(8 + (const char __user *)src),
16488 ret, "q", "", "=r", 8);
16489 return ret;
16490 default:
16491 - return copy_user_generic(dst, (__force void *)src, size);
16492 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16493 }
16494 }
16495
16496 static __always_inline __must_check
16497 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16498 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16499 {
16500 - int ret = 0;
16501 + size_t sz = __compiletime_object_size(src);
16502 + unsigned ret = 0;
16503
16504 might_fault();
16505 +
16506 + if (size > INT_MAX)
16507 + return size;
16508 +
16509 + check_object_size(src, size, true);
16510 +
16511 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16512 + if (!__access_ok(VERIFY_WRITE, dst, size))
16513 + return size;
16514 +#endif
16515 +
16516 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16517 + copy_to_user_overflow();
16518 + return size;
16519 + }
16520 +
16521 if (!__builtin_constant_p(size))
16522 - return copy_user_generic((__force void *)dst, src, size);
16523 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16524 switch (size) {
16525 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16526 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16527 ret, "b", "b", "iq", 1);
16528 return ret;
16529 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16530 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16531 ret, "w", "w", "ir", 2);
16532 return ret;
16533 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16534 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16535 ret, "l", "k", "ir", 4);
16536 return ret;
16537 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16538 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16539 ret, "q", "", "er", 8);
16540 return ret;
16541 case 10:
16542 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16543 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16544 ret, "q", "", "er", 10);
16545 if (unlikely(ret))
16546 return ret;
16547 asm("":::"memory");
16548 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16549 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16550 ret, "w", "w", "ir", 2);
16551 return ret;
16552 case 16:
16553 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16554 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16555 ret, "q", "", "er", 16);
16556 if (unlikely(ret))
16557 return ret;
16558 asm("":::"memory");
16559 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16560 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16561 ret, "q", "", "er", 8);
16562 return ret;
16563 default:
16564 - return copy_user_generic((__force void *)dst, src, size);
16565 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16566 }
16567 }
16568
16569 static __always_inline __must_check
16570 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16571 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16572 {
16573 - int ret = 0;
16574 + unsigned ret = 0;
16575
16576 might_fault();
16577 +
16578 + if (size > INT_MAX)
16579 + return size;
16580 +
16581 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16582 + if (!__access_ok(VERIFY_READ, src, size))
16583 + return size;
16584 + if (!__access_ok(VERIFY_WRITE, dst, size))
16585 + return size;
16586 +#endif
16587 +
16588 if (!__builtin_constant_p(size))
16589 - return copy_user_generic((__force void *)dst,
16590 - (__force void *)src, size);
16591 + return copy_user_generic((__force_kernel void *)____m(dst),
16592 + (__force_kernel const void *)____m(src), size);
16593 switch (size) {
16594 case 1: {
16595 u8 tmp;
16596 - __get_user_asm(tmp, (u8 __user *)src,
16597 + __get_user_asm(tmp, (const u8 __user *)src,
16598 ret, "b", "b", "=q", 1);
16599 if (likely(!ret))
16600 __put_user_asm(tmp, (u8 __user *)dst,
16601 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16602 }
16603 case 2: {
16604 u16 tmp;
16605 - __get_user_asm(tmp, (u16 __user *)src,
16606 + __get_user_asm(tmp, (const u16 __user *)src,
16607 ret, "w", "w", "=r", 2);
16608 if (likely(!ret))
16609 __put_user_asm(tmp, (u16 __user *)dst,
16610 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16611
16612 case 4: {
16613 u32 tmp;
16614 - __get_user_asm(tmp, (u32 __user *)src,
16615 + __get_user_asm(tmp, (const u32 __user *)src,
16616 ret, "l", "k", "=r", 4);
16617 if (likely(!ret))
16618 __put_user_asm(tmp, (u32 __user *)dst,
16619 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16620 }
16621 case 8: {
16622 u64 tmp;
16623 - __get_user_asm(tmp, (u64 __user *)src,
16624 + __get_user_asm(tmp, (const u64 __user *)src,
16625 ret, "q", "", "=r", 8);
16626 if (likely(!ret))
16627 __put_user_asm(tmp, (u64 __user *)dst,
16628 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16629 return ret;
16630 }
16631 default:
16632 - return copy_user_generic((__force void *)dst,
16633 - (__force void *)src, size);
16634 + return copy_user_generic((__force_kernel void *)____m(dst),
16635 + (__force_kernel const void *)____m(src), size);
16636 }
16637 }
16638
16639 static __must_check __always_inline int
16640 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16641 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16642 {
16643 - return copy_user_generic(dst, (__force const void *)src, size);
16644 + if (size > INT_MAX)
16645 + return size;
16646 +
16647 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16648 + if (!__access_ok(VERIFY_READ, src, size))
16649 + return size;
16650 +#endif
16651 +
16652 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16653 }
16654
16655 -static __must_check __always_inline int
16656 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16657 +static __must_check __always_inline unsigned long
16658 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16659 {
16660 - return copy_user_generic((__force void *)dst, src, size);
16661 + if (size > INT_MAX)
16662 + return size;
16663 +
16664 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16665 + if (!__access_ok(VERIFY_WRITE, dst, size))
16666 + return size;
16667 +#endif
16668 +
16669 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16670 }
16671
16672 -extern long __copy_user_nocache(void *dst, const void __user *src,
16673 - unsigned size, int zerorest);
16674 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16675 + unsigned long size, int zerorest) __size_overflow(3);
16676
16677 -static inline int
16678 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16679 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16680 {
16681 might_sleep();
16682 +
16683 + if (size > INT_MAX)
16684 + return size;
16685 +
16686 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16687 + if (!__access_ok(VERIFY_READ, src, size))
16688 + return size;
16689 +#endif
16690 +
16691 return __copy_user_nocache(dst, src, size, 1);
16692 }
16693
16694 -static inline int
16695 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16696 - unsigned size)
16697 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16698 + unsigned long size)
16699 {
16700 + if (size > INT_MAX)
16701 + return size;
16702 +
16703 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16704 + if (!__access_ok(VERIFY_READ, src, size))
16705 + return size;
16706 +#endif
16707 +
16708 return __copy_user_nocache(dst, src, size, 0);
16709 }
16710
16711 -unsigned long
16712 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16713 +extern unsigned long
16714 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16715
16716 #endif /* _ASM_X86_UACCESS_64_H */
16717 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16718 index 5b238981..77fdd78 100644
16719 --- a/arch/x86/include/asm/word-at-a-time.h
16720 +++ b/arch/x86/include/asm/word-at-a-time.h
16721 @@ -11,7 +11,7 @@
16722 * and shift, for example.
16723 */
16724 struct word_at_a_time {
16725 - const unsigned long one_bits, high_bits;
16726 + unsigned long one_bits, high_bits;
16727 };
16728
16729 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16730 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16731 index 5769349..a3d3e2a 100644
16732 --- a/arch/x86/include/asm/x86_init.h
16733 +++ b/arch/x86/include/asm/x86_init.h
16734 @@ -141,7 +141,7 @@ struct x86_init_ops {
16735 struct x86_init_timers timers;
16736 struct x86_init_iommu iommu;
16737 struct x86_init_pci pci;
16738 -};
16739 +} __no_const;
16740
16741 /**
16742 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16743 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
16744 void (*setup_percpu_clockev)(void);
16745 void (*early_percpu_clock_init)(void);
16746 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16747 -};
16748 +} __no_const;
16749
16750 /**
16751 * struct x86_platform_ops - platform specific runtime functions
16752 @@ -178,7 +178,7 @@ struct x86_platform_ops {
16753 void (*save_sched_clock_state)(void);
16754 void (*restore_sched_clock_state)(void);
16755 void (*apic_post_init)(void);
16756 -};
16757 +} __no_const;
16758
16759 struct pci_dev;
16760
16761 @@ -187,14 +187,14 @@ struct x86_msi_ops {
16762 void (*teardown_msi_irq)(unsigned int irq);
16763 void (*teardown_msi_irqs)(struct pci_dev *dev);
16764 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16765 -};
16766 +} __no_const;
16767
16768 struct x86_io_apic_ops {
16769 void (*init) (void);
16770 unsigned int (*read) (unsigned int apic, unsigned int reg);
16771 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
16772 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
16773 -};
16774 +} __no_const;
16775
16776 extern struct x86_init_ops x86_init;
16777 extern struct x86_cpuinit_ops x86_cpuinit;
16778 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16779 index 0415cda..b43d877 100644
16780 --- a/arch/x86/include/asm/xsave.h
16781 +++ b/arch/x86/include/asm/xsave.h
16782 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16783 return -EFAULT;
16784
16785 __asm__ __volatile__(ASM_STAC "\n"
16786 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16787 + "1:"
16788 + __copyuser_seg
16789 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16790 "2: " ASM_CLAC "\n"
16791 ".section .fixup,\"ax\"\n"
16792 "3: movl $-1,%[err]\n"
16793 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16794 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16795 {
16796 int err;
16797 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16798 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16799 u32 lmask = mask;
16800 u32 hmask = mask >> 32;
16801
16802 __asm__ __volatile__(ASM_STAC "\n"
16803 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16804 + "1:"
16805 + __copyuser_seg
16806 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16807 "2: " ASM_CLAC "\n"
16808 ".section .fixup,\"ax\"\n"
16809 "3: movl $-1,%[err]\n"
16810 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16811 index bbae024..e1528f9 100644
16812 --- a/arch/x86/include/uapi/asm/e820.h
16813 +++ b/arch/x86/include/uapi/asm/e820.h
16814 @@ -63,7 +63,7 @@ struct e820map {
16815 #define ISA_START_ADDRESS 0xa0000
16816 #define ISA_END_ADDRESS 0x100000
16817
16818 -#define BIOS_BEGIN 0x000a0000
16819 +#define BIOS_BEGIN 0x000c0000
16820 #define BIOS_END 0x00100000
16821
16822 #define BIOS_ROM_BASE 0xffe00000
16823 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16824 index 34e923a..0c6bb6e 100644
16825 --- a/arch/x86/kernel/Makefile
16826 +++ b/arch/x86/kernel/Makefile
16827 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16828 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16829 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16830 obj-y += probe_roms.o
16831 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16832 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16833 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16834 obj-y += syscall_$(BITS).o
16835 obj-$(CONFIG_X86_64) += vsyscall_64.o
16836 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16837 index bacf4b0..4ede72e 100644
16838 --- a/arch/x86/kernel/acpi/boot.c
16839 +++ b/arch/x86/kernel/acpi/boot.c
16840 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16841 * If your system is blacklisted here, but you find that acpi=force
16842 * works for you, please contact linux-acpi@vger.kernel.org
16843 */
16844 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16845 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16846 /*
16847 * Boxes that need ACPI disabled
16848 */
16849 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16850 };
16851
16852 /* second table for DMI checks that should run after early-quirks */
16853 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16854 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16855 /*
16856 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16857 * which includes some code which overrides all temperature
16858 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16859 index d5e0d71..6533e08 100644
16860 --- a/arch/x86/kernel/acpi/sleep.c
16861 +++ b/arch/x86/kernel/acpi/sleep.c
16862 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16863 #else /* CONFIG_64BIT */
16864 #ifdef CONFIG_SMP
16865 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16866 +
16867 + pax_open_kernel();
16868 early_gdt_descr.address =
16869 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16870 + pax_close_kernel();
16871 +
16872 initial_gs = per_cpu_offset(smp_processor_id());
16873 #endif
16874 initial_code = (unsigned long)wakeup_long64;
16875 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16876 index 13ab720..95d5442 100644
16877 --- a/arch/x86/kernel/acpi/wakeup_32.S
16878 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16879 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16880 # and restore the stack ... but you need gdt for this to work
16881 movl saved_context_esp, %esp
16882
16883 - movl %cs:saved_magic, %eax
16884 - cmpl $0x12345678, %eax
16885 + cmpl $0x12345678, saved_magic
16886 jne bogus_magic
16887
16888 # jump to place where we left off
16889 - movl saved_eip, %eax
16890 - jmp *%eax
16891 + jmp *(saved_eip)
16892
16893 bogus_magic:
16894 jmp bogus_magic
16895 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16896 index ef5ccca..bd83949 100644
16897 --- a/arch/x86/kernel/alternative.c
16898 +++ b/arch/x86/kernel/alternative.c
16899 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16900 */
16901 for (a = start; a < end; a++) {
16902 instr = (u8 *)&a->instr_offset + a->instr_offset;
16903 +
16904 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16905 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16906 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16907 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16908 +#endif
16909 +
16910 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16911 BUG_ON(a->replacementlen > a->instrlen);
16912 BUG_ON(a->instrlen > sizeof(insnbuf));
16913 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16914 for (poff = start; poff < end; poff++) {
16915 u8 *ptr = (u8 *)poff + *poff;
16916
16917 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16918 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16919 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16920 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16921 +#endif
16922 +
16923 if (!*poff || ptr < text || ptr >= text_end)
16924 continue;
16925 /* turn DS segment override prefix into lock prefix */
16926 - if (*ptr == 0x3e)
16927 + if (*ktla_ktva(ptr) == 0x3e)
16928 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16929 }
16930 mutex_unlock(&text_mutex);
16931 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16932 for (poff = start; poff < end; poff++) {
16933 u8 *ptr = (u8 *)poff + *poff;
16934
16935 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16936 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16937 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16938 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16939 +#endif
16940 +
16941 if (!*poff || ptr < text || ptr >= text_end)
16942 continue;
16943 /* turn lock prefix into DS segment override prefix */
16944 - if (*ptr == 0xf0)
16945 + if (*ktla_ktva(ptr) == 0xf0)
16946 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16947 }
16948 mutex_unlock(&text_mutex);
16949 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16950
16951 BUG_ON(p->len > MAX_PATCH_LEN);
16952 /* prep the buffer with the original instructions */
16953 - memcpy(insnbuf, p->instr, p->len);
16954 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16955 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16956 (unsigned long)p->instr, p->len);
16957
16958 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16959 if (!uniproc_patched || num_possible_cpus() == 1)
16960 free_init_pages("SMP alternatives",
16961 (unsigned long)__smp_locks,
16962 - (unsigned long)__smp_locks_end);
16963 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16964 #endif
16965
16966 apply_paravirt(__parainstructions, __parainstructions_end);
16967 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16968 * instructions. And on the local CPU you need to be protected again NMI or MCE
16969 * handlers seeing an inconsistent instruction while you patch.
16970 */
16971 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16972 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16973 size_t len)
16974 {
16975 unsigned long flags;
16976 local_irq_save(flags);
16977 - memcpy(addr, opcode, len);
16978 +
16979 + pax_open_kernel();
16980 + memcpy(ktla_ktva(addr), opcode, len);
16981 sync_core();
16982 + pax_close_kernel();
16983 +
16984 local_irq_restore(flags);
16985 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16986 that causes hangs on some VIA CPUs. */
16987 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16988 */
16989 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16990 {
16991 - unsigned long flags;
16992 - char *vaddr;
16993 + unsigned char *vaddr = ktla_ktva(addr);
16994 struct page *pages[2];
16995 - int i;
16996 + size_t i;
16997
16998 if (!core_kernel_text((unsigned long)addr)) {
16999 - pages[0] = vmalloc_to_page(addr);
17000 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
17001 + pages[0] = vmalloc_to_page(vaddr);
17002 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
17003 } else {
17004 - pages[0] = virt_to_page(addr);
17005 + pages[0] = virt_to_page(vaddr);
17006 WARN_ON(!PageReserved(pages[0]));
17007 - pages[1] = virt_to_page(addr + PAGE_SIZE);
17008 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
17009 }
17010 BUG_ON(!pages[0]);
17011 - local_irq_save(flags);
17012 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
17013 - if (pages[1])
17014 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
17015 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
17016 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
17017 - clear_fixmap(FIX_TEXT_POKE0);
17018 - if (pages[1])
17019 - clear_fixmap(FIX_TEXT_POKE1);
17020 - local_flush_tlb();
17021 - sync_core();
17022 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
17023 - that causes hangs on some VIA CPUs. */
17024 + text_poke_early(addr, opcode, len);
17025 for (i = 0; i < len; i++)
17026 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
17027 - local_irq_restore(flags);
17028 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
17029 return addr;
17030 }
17031
17032 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
17033 index cbf5121..812b537 100644
17034 --- a/arch/x86/kernel/apic/apic.c
17035 +++ b/arch/x86/kernel/apic/apic.c
17036 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
17037 /*
17038 * Debug level, exported for io_apic.c
17039 */
17040 -unsigned int apic_verbosity;
17041 +int apic_verbosity;
17042
17043 int pic_mode;
17044
17045 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
17046 apic_write(APIC_ESR, 0);
17047 v1 = apic_read(APIC_ESR);
17048 ack_APIC_irq();
17049 - atomic_inc(&irq_err_count);
17050 + atomic_inc_unchecked(&irq_err_count);
17051
17052 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
17053 smp_processor_id(), v0 , v1);
17054 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
17055 index 00c77cf..2dc6a2d 100644
17056 --- a/arch/x86/kernel/apic/apic_flat_64.c
17057 +++ b/arch/x86/kernel/apic/apic_flat_64.c
17058 @@ -157,7 +157,7 @@ static int flat_probe(void)
17059 return 1;
17060 }
17061
17062 -static struct apic apic_flat = {
17063 +static struct apic apic_flat __read_only = {
17064 .name = "flat",
17065 .probe = flat_probe,
17066 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
17067 @@ -271,7 +271,7 @@ static int physflat_probe(void)
17068 return 0;
17069 }
17070
17071 -static struct apic apic_physflat = {
17072 +static struct apic apic_physflat __read_only = {
17073
17074 .name = "physical flat",
17075 .probe = physflat_probe,
17076 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
17077 index e145f28..2752888 100644
17078 --- a/arch/x86/kernel/apic/apic_noop.c
17079 +++ b/arch/x86/kernel/apic/apic_noop.c
17080 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
17081 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
17082 }
17083
17084 -struct apic apic_noop = {
17085 +struct apic apic_noop __read_only = {
17086 .name = "noop",
17087 .probe = noop_probe,
17088 .acpi_madt_oem_check = NULL,
17089 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
17090 index d50e364..543bee3 100644
17091 --- a/arch/x86/kernel/apic/bigsmp_32.c
17092 +++ b/arch/x86/kernel/apic/bigsmp_32.c
17093 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
17094 return dmi_bigsmp;
17095 }
17096
17097 -static struct apic apic_bigsmp = {
17098 +static struct apic apic_bigsmp __read_only = {
17099
17100 .name = "bigsmp",
17101 .probe = probe_bigsmp,
17102 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
17103 index 0874799..a7a7892 100644
17104 --- a/arch/x86/kernel/apic/es7000_32.c
17105 +++ b/arch/x86/kernel/apic/es7000_32.c
17106 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
17107 return ret && es7000_apic_is_cluster();
17108 }
17109
17110 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
17111 -static struct apic __refdata apic_es7000_cluster = {
17112 +static struct apic apic_es7000_cluster __read_only = {
17113
17114 .name = "es7000",
17115 .probe = probe_es7000,
17116 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
17117 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
17118 };
17119
17120 -static struct apic __refdata apic_es7000 = {
17121 +static struct apic apic_es7000 __read_only = {
17122
17123 .name = "es7000",
17124 .probe = probe_es7000,
17125 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
17126 index b739d39..aebc14c 100644
17127 --- a/arch/x86/kernel/apic/io_apic.c
17128 +++ b/arch/x86/kernel/apic/io_apic.c
17129 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
17130 }
17131 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
17132
17133 -void lock_vector_lock(void)
17134 +void lock_vector_lock(void) __acquires(vector_lock)
17135 {
17136 /* Used to the online set of cpus does not change
17137 * during assign_irq_vector.
17138 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
17139 raw_spin_lock(&vector_lock);
17140 }
17141
17142 -void unlock_vector_lock(void)
17143 +void unlock_vector_lock(void) __releases(vector_lock)
17144 {
17145 raw_spin_unlock(&vector_lock);
17146 }
17147 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
17148 ack_APIC_irq();
17149 }
17150
17151 -atomic_t irq_mis_count;
17152 +atomic_unchecked_t irq_mis_count;
17153
17154 #ifdef CONFIG_GENERIC_PENDING_IRQ
17155 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
17156 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
17157 * at the cpu.
17158 */
17159 if (!(v & (1 << (i & 0x1f)))) {
17160 - atomic_inc(&irq_mis_count);
17161 + atomic_inc_unchecked(&irq_mis_count);
17162
17163 eoi_ioapic_irq(irq, cfg);
17164 }
17165 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
17166
17167 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
17168 {
17169 - chip->irq_print_chip = ir_print_prefix;
17170 - chip->irq_ack = ir_ack_apic_edge;
17171 - chip->irq_eoi = ir_ack_apic_level;
17172 + pax_open_kernel();
17173 + *(void **)&chip->irq_print_chip = ir_print_prefix;
17174 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
17175 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
17176
17177 - chip->irq_set_affinity = set_remapped_irq_affinity;
17178 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
17179 + pax_close_kernel();
17180 }
17181 #endif /* CONFIG_IRQ_REMAP */
17182
17183 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
17184 index d661ee9..791fd33 100644
17185 --- a/arch/x86/kernel/apic/numaq_32.c
17186 +++ b/arch/x86/kernel/apic/numaq_32.c
17187 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
17188 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
17189 }
17190
17191 -/* Use __refdata to keep false positive warning calm. */
17192 -static struct apic __refdata apic_numaq = {
17193 +static struct apic apic_numaq __read_only = {
17194
17195 .name = "NUMAQ",
17196 .probe = probe_numaq,
17197 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
17198 index eb35ef9..f184a21 100644
17199 --- a/arch/x86/kernel/apic/probe_32.c
17200 +++ b/arch/x86/kernel/apic/probe_32.c
17201 @@ -72,7 +72,7 @@ static int probe_default(void)
17202 return 1;
17203 }
17204
17205 -static struct apic apic_default = {
17206 +static struct apic apic_default __read_only = {
17207
17208 .name = "default",
17209 .probe = probe_default,
17210 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
17211 index 77c95c0..434f8a4 100644
17212 --- a/arch/x86/kernel/apic/summit_32.c
17213 +++ b/arch/x86/kernel/apic/summit_32.c
17214 @@ -486,7 +486,7 @@ void setup_summit(void)
17215 }
17216 #endif
17217
17218 -static struct apic apic_summit = {
17219 +static struct apic apic_summit __read_only = {
17220
17221 .name = "summit",
17222 .probe = probe_summit,
17223 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
17224 index c88baa4..757aee1 100644
17225 --- a/arch/x86/kernel/apic/x2apic_cluster.c
17226 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
17227 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
17228 return notifier_from_errno(err);
17229 }
17230
17231 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17232 +static struct notifier_block x2apic_cpu_notifier = {
17233 .notifier_call = update_clusterinfo,
17234 };
17235
17236 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17237 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17238 }
17239
17240 -static struct apic apic_x2apic_cluster = {
17241 +static struct apic apic_x2apic_cluster __read_only = {
17242
17243 .name = "cluster x2apic",
17244 .probe = x2apic_cluster_probe,
17245 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17246 index 562a76d..a003c0f 100644
17247 --- a/arch/x86/kernel/apic/x2apic_phys.c
17248 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17249 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17250 return apic == &apic_x2apic_phys;
17251 }
17252
17253 -static struct apic apic_x2apic_phys = {
17254 +static struct apic apic_x2apic_phys __read_only = {
17255
17256 .name = "physical x2apic",
17257 .probe = x2apic_phys_probe,
17258 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17259 index 8cfade9..b9d04fc 100644
17260 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17261 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17262 @@ -333,7 +333,7 @@ static int uv_probe(void)
17263 return apic == &apic_x2apic_uv_x;
17264 }
17265
17266 -static struct apic __refdata apic_x2apic_uv_x = {
17267 +static struct apic apic_x2apic_uv_x __read_only = {
17268
17269 .name = "UV large system",
17270 .probe = uv_probe,
17271 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17272 index d65464e..1035d31 100644
17273 --- a/arch/x86/kernel/apm_32.c
17274 +++ b/arch/x86/kernel/apm_32.c
17275 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
17276 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17277 * even though they are called in protected mode.
17278 */
17279 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17280 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17281 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17282
17283 static const char driver_version[] = "1.16ac"; /* no spaces */
17284 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
17285 BUG_ON(cpu != 0);
17286 gdt = get_cpu_gdt_table(cpu);
17287 save_desc_40 = gdt[0x40 / 8];
17288 +
17289 + pax_open_kernel();
17290 gdt[0x40 / 8] = bad_bios_desc;
17291 + pax_close_kernel();
17292
17293 apm_irq_save(flags);
17294 APM_DO_SAVE_SEGS;
17295 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
17296 &call->esi);
17297 APM_DO_RESTORE_SEGS;
17298 apm_irq_restore(flags);
17299 +
17300 + pax_open_kernel();
17301 gdt[0x40 / 8] = save_desc_40;
17302 + pax_close_kernel();
17303 +
17304 put_cpu();
17305
17306 return call->eax & 0xff;
17307 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
17308 BUG_ON(cpu != 0);
17309 gdt = get_cpu_gdt_table(cpu);
17310 save_desc_40 = gdt[0x40 / 8];
17311 +
17312 + pax_open_kernel();
17313 gdt[0x40 / 8] = bad_bios_desc;
17314 + pax_close_kernel();
17315
17316 apm_irq_save(flags);
17317 APM_DO_SAVE_SEGS;
17318 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
17319 &call->eax);
17320 APM_DO_RESTORE_SEGS;
17321 apm_irq_restore(flags);
17322 +
17323 + pax_open_kernel();
17324 gdt[0x40 / 8] = save_desc_40;
17325 + pax_close_kernel();
17326 +
17327 put_cpu();
17328 return error;
17329 }
17330 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
17331 * code to that CPU.
17332 */
17333 gdt = get_cpu_gdt_table(0);
17334 +
17335 + pax_open_kernel();
17336 set_desc_base(&gdt[APM_CS >> 3],
17337 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17338 set_desc_base(&gdt[APM_CS_16 >> 3],
17339 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17340 set_desc_base(&gdt[APM_DS >> 3],
17341 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17342 + pax_close_kernel();
17343
17344 proc_create("apm", 0, NULL, &apm_file_ops);
17345
17346 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17347 index 2861082..6d4718e 100644
17348 --- a/arch/x86/kernel/asm-offsets.c
17349 +++ b/arch/x86/kernel/asm-offsets.c
17350 @@ -33,6 +33,8 @@ void common(void) {
17351 OFFSET(TI_status, thread_info, status);
17352 OFFSET(TI_addr_limit, thread_info, addr_limit);
17353 OFFSET(TI_preempt_count, thread_info, preempt_count);
17354 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17355 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17356
17357 BLANK();
17358 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17359 @@ -53,8 +55,26 @@ void common(void) {
17360 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17361 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17362 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17363 +
17364 +#ifdef CONFIG_PAX_KERNEXEC
17365 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17366 #endif
17367
17368 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17369 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17370 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17371 +#ifdef CONFIG_X86_64
17372 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17373 +#endif
17374 +#endif
17375 +
17376 +#endif
17377 +
17378 + BLANK();
17379 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17380 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17381 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17382 +
17383 #ifdef CONFIG_XEN
17384 BLANK();
17385 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17386 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17387 index 1b4754f..fbb4227 100644
17388 --- a/arch/x86/kernel/asm-offsets_64.c
17389 +++ b/arch/x86/kernel/asm-offsets_64.c
17390 @@ -76,6 +76,7 @@ int main(void)
17391 BLANK();
17392 #undef ENTRY
17393
17394 + DEFINE(TSS_size, sizeof(struct tss_struct));
17395 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17396 BLANK();
17397
17398 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17399 index a0e067d..9c7db16 100644
17400 --- a/arch/x86/kernel/cpu/Makefile
17401 +++ b/arch/x86/kernel/cpu/Makefile
17402 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17403 CFLAGS_REMOVE_perf_event.o = -pg
17404 endif
17405
17406 -# Make sure load_percpu_segment has no stackprotector
17407 -nostackp := $(call cc-option, -fno-stack-protector)
17408 -CFLAGS_common.o := $(nostackp)
17409 -
17410 obj-y := intel_cacheinfo.o scattered.o topology.o
17411 obj-y += proc.o capflags.o powerflags.o common.o
17412 obj-y += vmware.o hypervisor.o mshyperv.o
17413 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17414 index 15239ff..e23e04e 100644
17415 --- a/arch/x86/kernel/cpu/amd.c
17416 +++ b/arch/x86/kernel/cpu/amd.c
17417 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17418 unsigned int size)
17419 {
17420 /* AMD errata T13 (order #21922) */
17421 - if ((c->x86 == 6)) {
17422 + if (c->x86 == 6) {
17423 /* Duron Rev A0 */
17424 if (c->x86_model == 3 && c->x86_mask == 0)
17425 size = 64;
17426 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17427 index 9c3ab43..51e6366 100644
17428 --- a/arch/x86/kernel/cpu/common.c
17429 +++ b/arch/x86/kernel/cpu/common.c
17430 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17431
17432 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17433
17434 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17435 -#ifdef CONFIG_X86_64
17436 - /*
17437 - * We need valid kernel segments for data and code in long mode too
17438 - * IRET will check the segment types kkeil 2000/10/28
17439 - * Also sysret mandates a special GDT layout
17440 - *
17441 - * TLS descriptors are currently at a different place compared to i386.
17442 - * Hopefully nobody expects them at a fixed place (Wine?)
17443 - */
17444 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17445 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17446 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17447 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17448 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17449 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17450 -#else
17451 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17452 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17453 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17454 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17455 - /*
17456 - * Segments used for calling PnP BIOS have byte granularity.
17457 - * They code segments and data segments have fixed 64k limits,
17458 - * the transfer segment sizes are set at run time.
17459 - */
17460 - /* 32-bit code */
17461 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17462 - /* 16-bit code */
17463 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17464 - /* 16-bit data */
17465 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17466 - /* 16-bit data */
17467 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17468 - /* 16-bit data */
17469 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17470 - /*
17471 - * The APM segments have byte granularity and their bases
17472 - * are set at run time. All have 64k limits.
17473 - */
17474 - /* 32-bit code */
17475 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17476 - /* 16-bit code */
17477 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17478 - /* data */
17479 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17480 -
17481 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17482 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17483 - GDT_STACK_CANARY_INIT
17484 -#endif
17485 -} };
17486 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17487 -
17488 static int __init x86_xsave_setup(char *s)
17489 {
17490 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17491 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
17492 {
17493 struct desc_ptr gdt_descr;
17494
17495 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17496 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17497 gdt_descr.size = GDT_SIZE - 1;
17498 load_gdt(&gdt_descr);
17499 /* Reload the per-cpu base */
17500 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17501 /* Filter out anything that depends on CPUID levels we don't have */
17502 filter_cpuid_features(c, true);
17503
17504 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17505 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17506 +#endif
17507 +
17508 /* If the model name is still unset, do table lookup. */
17509 if (!c->x86_model_id[0]) {
17510 const char *p;
17511 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
17512 }
17513 __setup("clearcpuid=", setup_disablecpuid);
17514
17515 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17516 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17517 +
17518 #ifdef CONFIG_X86_64
17519 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17520 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17521 - (unsigned long) nmi_idt_table };
17522 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17523
17524 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17525 irq_stack_union) __aligned(PAGE_SIZE);
17526 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17527 EXPORT_PER_CPU_SYMBOL(current_task);
17528
17529 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17530 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17531 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17532 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17533
17534 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17535 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
17536 int i;
17537
17538 cpu = stack_smp_processor_id();
17539 - t = &per_cpu(init_tss, cpu);
17540 + t = init_tss + cpu;
17541 oist = &per_cpu(orig_ist, cpu);
17542
17543 #ifdef CONFIG_NUMA
17544 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
17545 switch_to_new_gdt(cpu);
17546 loadsegment(fs, 0);
17547
17548 - load_idt((const struct desc_ptr *)&idt_descr);
17549 + load_idt(&idt_descr);
17550
17551 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17552 syscall_init();
17553 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
17554 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17555 barrier();
17556
17557 - x86_configure_nx();
17558 enable_x2apic();
17559
17560 /*
17561 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
17562 {
17563 int cpu = smp_processor_id();
17564 struct task_struct *curr = current;
17565 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17566 + struct tss_struct *t = init_tss + cpu;
17567 struct thread_struct *thread = &curr->thread;
17568
17569 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
17570 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17571 index fcaabd0..7b55a26 100644
17572 --- a/arch/x86/kernel/cpu/intel.c
17573 +++ b/arch/x86/kernel/cpu/intel.c
17574 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17575 * Update the IDT descriptor and reload the IDT so that
17576 * it uses the read-only mapped virtual address.
17577 */
17578 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17579 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17580 load_idt(&idt_descr);
17581 }
17582 #endif
17583 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17584 index 84c1309..39b7224 100644
17585 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17586 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17587 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17588 };
17589
17590 #ifdef CONFIG_AMD_NB
17591 +static struct attribute *default_attrs_amd_nb[] = {
17592 + &type.attr,
17593 + &level.attr,
17594 + &coherency_line_size.attr,
17595 + &physical_line_partition.attr,
17596 + &ways_of_associativity.attr,
17597 + &number_of_sets.attr,
17598 + &size.attr,
17599 + &shared_cpu_map.attr,
17600 + &shared_cpu_list.attr,
17601 + NULL,
17602 + NULL,
17603 + NULL,
17604 + NULL
17605 +};
17606 +
17607 static struct attribute ** __cpuinit amd_l3_attrs(void)
17608 {
17609 static struct attribute **attrs;
17610 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17611
17612 n = ARRAY_SIZE(default_attrs);
17613
17614 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17615 - n += 2;
17616 -
17617 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17618 - n += 1;
17619 -
17620 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17621 - if (attrs == NULL)
17622 - return attrs = default_attrs;
17623 -
17624 - for (n = 0; default_attrs[n]; n++)
17625 - attrs[n] = default_attrs[n];
17626 + attrs = default_attrs_amd_nb;
17627
17628 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17629 attrs[n++] = &cache_disable_0.attr;
17630 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17631 .default_attrs = default_attrs,
17632 };
17633
17634 +#ifdef CONFIG_AMD_NB
17635 +static struct kobj_type ktype_cache_amd_nb = {
17636 + .sysfs_ops = &sysfs_ops,
17637 + .default_attrs = default_attrs_amd_nb,
17638 +};
17639 +#endif
17640 +
17641 static struct kobj_type ktype_percpu_entry = {
17642 .sysfs_ops = &sysfs_ops,
17643 };
17644 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17645 return retval;
17646 }
17647
17648 +#ifdef CONFIG_AMD_NB
17649 + amd_l3_attrs();
17650 +#endif
17651 +
17652 for (i = 0; i < num_cache_leaves; i++) {
17653 + struct kobj_type *ktype;
17654 +
17655 this_object = INDEX_KOBJECT_PTR(cpu, i);
17656 this_object->cpu = cpu;
17657 this_object->index = i;
17658
17659 this_leaf = CPUID4_INFO_IDX(cpu, i);
17660
17661 - ktype_cache.default_attrs = default_attrs;
17662 + ktype = &ktype_cache;
17663 #ifdef CONFIG_AMD_NB
17664 if (this_leaf->base.nb)
17665 - ktype_cache.default_attrs = amd_l3_attrs();
17666 + ktype = &ktype_cache_amd_nb;
17667 #endif
17668 retval = kobject_init_and_add(&(this_object->kobj),
17669 - &ktype_cache,
17670 + ktype,
17671 per_cpu(ici_cache_kobject, cpu),
17672 "index%1lu", i);
17673 if (unlikely(retval)) {
17674 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17675 return NOTIFY_OK;
17676 }
17677
17678 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17679 +static struct notifier_block cacheinfo_cpu_notifier = {
17680 .notifier_call = cacheinfo_cpu_callback,
17681 };
17682
17683 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17684 index 80dbda8..be16652 100644
17685 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17686 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17687 @@ -45,6 +45,7 @@
17688 #include <asm/processor.h>
17689 #include <asm/mce.h>
17690 #include <asm/msr.h>
17691 +#include <asm/local.h>
17692
17693 #include "mce-internal.h"
17694
17695 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17696 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17697 m->cs, m->ip);
17698
17699 - if (m->cs == __KERNEL_CS)
17700 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17701 print_symbol("{%s}", m->ip);
17702 pr_cont("\n");
17703 }
17704 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17705
17706 #define PANIC_TIMEOUT 5 /* 5 seconds */
17707
17708 -static atomic_t mce_paniced;
17709 +static atomic_unchecked_t mce_paniced;
17710
17711 static int fake_panic;
17712 -static atomic_t mce_fake_paniced;
17713 +static atomic_unchecked_t mce_fake_paniced;
17714
17715 /* Panic in progress. Enable interrupts and wait for final IPI */
17716 static void wait_for_panic(void)
17717 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17718 /*
17719 * Make sure only one CPU runs in machine check panic
17720 */
17721 - if (atomic_inc_return(&mce_paniced) > 1)
17722 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17723 wait_for_panic();
17724 barrier();
17725
17726 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17727 console_verbose();
17728 } else {
17729 /* Don't log too much for fake panic */
17730 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17731 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17732 return;
17733 }
17734 /* First print corrected ones that are still unlogged */
17735 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
17736 * might have been modified by someone else.
17737 */
17738 rmb();
17739 - if (atomic_read(&mce_paniced))
17740 + if (atomic_read_unchecked(&mce_paniced))
17741 wait_for_panic();
17742 if (!mca_cfg.monarch_timeout)
17743 goto out;
17744 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17745 }
17746
17747 /* Call the installed machine check handler for this CPU setup. */
17748 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17749 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17750 unexpected_machine_check;
17751
17752 /*
17753 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17754 return;
17755 }
17756
17757 + pax_open_kernel();
17758 machine_check_vector = do_machine_check;
17759 + pax_close_kernel();
17760
17761 __mcheck_cpu_init_generic();
17762 __mcheck_cpu_init_vendor(c);
17763 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17764 */
17765
17766 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17767 -static int mce_chrdev_open_count; /* #times opened */
17768 +static local_t mce_chrdev_open_count; /* #times opened */
17769 static int mce_chrdev_open_exclu; /* already open exclusive? */
17770
17771 static int mce_chrdev_open(struct inode *inode, struct file *file)
17772 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17773 spin_lock(&mce_chrdev_state_lock);
17774
17775 if (mce_chrdev_open_exclu ||
17776 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17777 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17778 spin_unlock(&mce_chrdev_state_lock);
17779
17780 return -EBUSY;
17781 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17782
17783 if (file->f_flags & O_EXCL)
17784 mce_chrdev_open_exclu = 1;
17785 - mce_chrdev_open_count++;
17786 + local_inc(&mce_chrdev_open_count);
17787
17788 spin_unlock(&mce_chrdev_state_lock);
17789
17790 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17791 {
17792 spin_lock(&mce_chrdev_state_lock);
17793
17794 - mce_chrdev_open_count--;
17795 + local_dec(&mce_chrdev_open_count);
17796 mce_chrdev_open_exclu = 0;
17797
17798 spin_unlock(&mce_chrdev_state_lock);
17799 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17800 return NOTIFY_OK;
17801 }
17802
17803 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17804 +static struct notifier_block mce_cpu_notifier = {
17805 .notifier_call = mce_cpu_callback,
17806 };
17807
17808 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
17809
17810 for (i = 0; i < mca_cfg.banks; i++) {
17811 struct mce_bank *b = &mce_banks[i];
17812 - struct device_attribute *a = &b->attr;
17813 + device_attribute_no_const *a = &b->attr;
17814
17815 sysfs_attr_init(&a->attr);
17816 a->attr.name = b->attrname;
17817 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
17818 static void mce_reset(void)
17819 {
17820 cpu_missing = 0;
17821 - atomic_set(&mce_fake_paniced, 0);
17822 + atomic_set_unchecked(&mce_fake_paniced, 0);
17823 atomic_set(&mce_executing, 0);
17824 atomic_set(&mce_callin, 0);
17825 atomic_set(&global_nwo, 0);
17826 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17827 index 2d5454c..51987eb 100644
17828 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17829 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17830 @@ -11,6 +11,7 @@
17831 #include <asm/processor.h>
17832 #include <asm/mce.h>
17833 #include <asm/msr.h>
17834 +#include <asm/pgtable.h>
17835
17836 /* By default disabled */
17837 int mce_p5_enabled __read_mostly;
17838 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17839 if (!cpu_has(c, X86_FEATURE_MCE))
17840 return;
17841
17842 + pax_open_kernel();
17843 machine_check_vector = pentium_machine_check;
17844 + pax_close_kernel();
17845 /* Make sure the vector pointer is visible before we enable MCEs: */
17846 wmb();
17847
17848 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17849 index 47a1870..8c019a7 100644
17850 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17851 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17852 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17853 return notifier_from_errno(err);
17854 }
17855
17856 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17857 +static struct notifier_block thermal_throttle_cpu_notifier =
17858 {
17859 .notifier_call = thermal_throttle_cpu_callback,
17860 };
17861 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17862 index 2d7998f..17c9de1 100644
17863 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17864 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17865 @@ -10,6 +10,7 @@
17866 #include <asm/processor.h>
17867 #include <asm/mce.h>
17868 #include <asm/msr.h>
17869 +#include <asm/pgtable.h>
17870
17871 /* Machine check handler for WinChip C6: */
17872 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17873 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17874 {
17875 u32 lo, hi;
17876
17877 + pax_open_kernel();
17878 machine_check_vector = winchip_machine_check;
17879 + pax_close_kernel();
17880 /* Make sure the vector pointer is visible before we enable MCEs: */
17881 wmb();
17882
17883 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17884 index 726bf96..81f0526 100644
17885 --- a/arch/x86/kernel/cpu/mtrr/main.c
17886 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17887 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17888 u64 size_or_mask, size_and_mask;
17889 static bool mtrr_aps_delayed_init;
17890
17891 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17892 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17893
17894 const struct mtrr_ops *mtrr_if;
17895
17896 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17897 index df5e41f..816c719 100644
17898 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17899 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17900 @@ -25,7 +25,7 @@ struct mtrr_ops {
17901 int (*validate_add_page)(unsigned long base, unsigned long size,
17902 unsigned int type);
17903 int (*have_wrcomb)(void);
17904 -};
17905 +} __do_const;
17906
17907 extern int generic_get_free_region(unsigned long base, unsigned long size,
17908 int replace_reg);
17909 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17910 index 6774c17..72c1b22 100644
17911 --- a/arch/x86/kernel/cpu/perf_event.c
17912 +++ b/arch/x86/kernel/cpu/perf_event.c
17913 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17914 pr_info("no hardware sampling interrupt available.\n");
17915 }
17916
17917 -static struct attribute_group x86_pmu_format_group = {
17918 +static attribute_group_no_const x86_pmu_format_group = {
17919 .name = "format",
17920 .attrs = NULL,
17921 };
17922 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
17923 struct perf_pmu_events_attr {
17924 struct device_attribute attr;
17925 u64 id;
17926 -};
17927 +} __do_const;
17928
17929 /*
17930 * Remove all undefined events (x86_pmu.event_map(id) == 0)
17931 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
17932 NULL,
17933 };
17934
17935 -static struct attribute_group x86_pmu_events_group = {
17936 +static attribute_group_no_const x86_pmu_events_group = {
17937 .name = "events",
17938 .attrs = events_attr,
17939 };
17940 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
17941 if (idx > GDT_ENTRIES)
17942 return 0;
17943
17944 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17945 + desc = get_cpu_gdt_table(smp_processor_id());
17946 }
17947
17948 return get_desc_base(desc + idx);
17949 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17950 break;
17951
17952 perf_callchain_store(entry, frame.return_address);
17953 - fp = frame.next_frame;
17954 + fp = (const void __force_user *)frame.next_frame;
17955 }
17956 }
17957
17958 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17959 index 4914e94..60b06e3 100644
17960 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17961 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17962 @@ -1958,10 +1958,10 @@ __init int intel_pmu_init(void)
17963 * v2 and above have a perf capabilities MSR
17964 */
17965 if (version > 1) {
17966 - u64 capabilities;
17967 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17968
17969 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17970 - x86_pmu.intel_cap.capabilities = capabilities;
17971 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17972 + x86_pmu.intel_cap.capabilities = capabilities;
17973 }
17974
17975 intel_ds_init();
17976 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17977 index b43200d..d235b3e 100644
17978 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17979 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17980 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17981 static int __init uncore_type_init(struct intel_uncore_type *type)
17982 {
17983 struct intel_uncore_pmu *pmus;
17984 - struct attribute_group *events_group;
17985 + attribute_group_no_const *attr_group;
17986 struct attribute **attrs;
17987 int i, j;
17988
17989 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
17990 while (type->event_descs[i].attr.attr.name)
17991 i++;
17992
17993 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17994 - sizeof(*events_group), GFP_KERNEL);
17995 - if (!events_group)
17996 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17997 + sizeof(*attr_group), GFP_KERNEL);
17998 + if (!attr_group)
17999 goto fail;
18000
18001 - attrs = (struct attribute **)(events_group + 1);
18002 - events_group->name = "events";
18003 - events_group->attrs = attrs;
18004 + attrs = (struct attribute **)(attr_group + 1);
18005 + attr_group->name = "events";
18006 + attr_group->attrs = attrs;
18007
18008 for (j = 0; j < i; j++)
18009 attrs[j] = &type->event_descs[j].attr.attr;
18010
18011 - type->events_group = events_group;
18012 + type->events_group = attr_group;
18013 }
18014
18015 type->pmu_group = &uncore_pmu_attr_group;
18016 @@ -2826,7 +2826,7 @@ static int
18017 return NOTIFY_OK;
18018 }
18019
18020 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
18021 +static struct notifier_block uncore_cpu_nb = {
18022 .notifier_call = uncore_cpu_notifier,
18023 /*
18024 * to migrate uncore events, our notifier should be executed
18025 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18026 index e68a455..975a932 100644
18027 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18028 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18029 @@ -428,7 +428,7 @@ struct intel_uncore_box {
18030 struct uncore_event_desc {
18031 struct kobj_attribute attr;
18032 const char *config;
18033 -};
18034 +} __do_const;
18035
18036 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
18037 { \
18038 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
18039 index 60c7891..9e911d3 100644
18040 --- a/arch/x86/kernel/cpuid.c
18041 +++ b/arch/x86/kernel/cpuid.c
18042 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
18043 return notifier_from_errno(err);
18044 }
18045
18046 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
18047 +static struct notifier_block cpuid_class_cpu_notifier =
18048 {
18049 .notifier_call = cpuid_class_cpu_callback,
18050 };
18051 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
18052 index 74467fe..18793d5 100644
18053 --- a/arch/x86/kernel/crash.c
18054 +++ b/arch/x86/kernel/crash.c
18055 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
18056 {
18057 #ifdef CONFIG_X86_32
18058 struct pt_regs fixed_regs;
18059 -#endif
18060
18061 -#ifdef CONFIG_X86_32
18062 - if (!user_mode_vm(regs)) {
18063 + if (!user_mode(regs)) {
18064 crash_fixup_ss_esp(&fixed_regs, regs);
18065 regs = &fixed_regs;
18066 }
18067 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
18068 index 37250fe..bf2ec74 100644
18069 --- a/arch/x86/kernel/doublefault_32.c
18070 +++ b/arch/x86/kernel/doublefault_32.c
18071 @@ -11,7 +11,7 @@
18072
18073 #define DOUBLEFAULT_STACKSIZE (1024)
18074 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
18075 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
18076 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
18077
18078 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
18079
18080 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
18081 unsigned long gdt, tss;
18082
18083 store_gdt(&gdt_desc);
18084 - gdt = gdt_desc.address;
18085 + gdt = (unsigned long)gdt_desc.address;
18086
18087 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
18088
18089 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
18090 /* 0x2 bit is always set */
18091 .flags = X86_EFLAGS_SF | 0x2,
18092 .sp = STACK_START,
18093 - .es = __USER_DS,
18094 + .es = __KERNEL_DS,
18095 .cs = __KERNEL_CS,
18096 .ss = __KERNEL_DS,
18097 - .ds = __USER_DS,
18098 + .ds = __KERNEL_DS,
18099 .fs = __KERNEL_PERCPU,
18100
18101 .__cr3 = __pa_nodebug(swapper_pg_dir),
18102 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
18103 index ae42418b..787c16b 100644
18104 --- a/arch/x86/kernel/dumpstack.c
18105 +++ b/arch/x86/kernel/dumpstack.c
18106 @@ -2,6 +2,9 @@
18107 * Copyright (C) 1991, 1992 Linus Torvalds
18108 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
18109 */
18110 +#ifdef CONFIG_GRKERNSEC_HIDESYM
18111 +#define __INCLUDED_BY_HIDESYM 1
18112 +#endif
18113 #include <linux/kallsyms.h>
18114 #include <linux/kprobes.h>
18115 #include <linux/uaccess.h>
18116 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
18117 static void
18118 print_ftrace_graph_addr(unsigned long addr, void *data,
18119 const struct stacktrace_ops *ops,
18120 - struct thread_info *tinfo, int *graph)
18121 + struct task_struct *task, int *graph)
18122 {
18123 - struct task_struct *task;
18124 unsigned long ret_addr;
18125 int index;
18126
18127 if (addr != (unsigned long)return_to_handler)
18128 return;
18129
18130 - task = tinfo->task;
18131 index = task->curr_ret_stack;
18132
18133 if (!task->ret_stack || index < *graph)
18134 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18135 static inline void
18136 print_ftrace_graph_addr(unsigned long addr, void *data,
18137 const struct stacktrace_ops *ops,
18138 - struct thread_info *tinfo, int *graph)
18139 + struct task_struct *task, int *graph)
18140 { }
18141 #endif
18142
18143 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18144 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
18145 */
18146
18147 -static inline int valid_stack_ptr(struct thread_info *tinfo,
18148 - void *p, unsigned int size, void *end)
18149 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
18150 {
18151 - void *t = tinfo;
18152 if (end) {
18153 if (p < end && p >= (end-THREAD_SIZE))
18154 return 1;
18155 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
18156 }
18157
18158 unsigned long
18159 -print_context_stack(struct thread_info *tinfo,
18160 +print_context_stack(struct task_struct *task, void *stack_start,
18161 unsigned long *stack, unsigned long bp,
18162 const struct stacktrace_ops *ops, void *data,
18163 unsigned long *end, int *graph)
18164 {
18165 struct stack_frame *frame = (struct stack_frame *)bp;
18166
18167 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
18168 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
18169 unsigned long addr;
18170
18171 addr = *stack;
18172 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
18173 } else {
18174 ops->address(data, addr, 0);
18175 }
18176 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18177 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18178 }
18179 stack++;
18180 }
18181 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
18182 EXPORT_SYMBOL_GPL(print_context_stack);
18183
18184 unsigned long
18185 -print_context_stack_bp(struct thread_info *tinfo,
18186 +print_context_stack_bp(struct task_struct *task, void *stack_start,
18187 unsigned long *stack, unsigned long bp,
18188 const struct stacktrace_ops *ops, void *data,
18189 unsigned long *end, int *graph)
18190 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18191 struct stack_frame *frame = (struct stack_frame *)bp;
18192 unsigned long *ret_addr = &frame->return_address;
18193
18194 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
18195 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
18196 unsigned long addr = *ret_addr;
18197
18198 if (!__kernel_text_address(addr))
18199 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18200 ops->address(data, addr, 1);
18201 frame = frame->next_frame;
18202 ret_addr = &frame->return_address;
18203 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18204 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18205 }
18206
18207 return (unsigned long)frame;
18208 @@ -189,7 +188,7 @@ void dump_stack(void)
18209
18210 bp = stack_frame(current, NULL);
18211 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
18212 - current->pid, current->comm, print_tainted(),
18213 + task_pid_nr(current), current->comm, print_tainted(),
18214 init_utsname()->release,
18215 (int)strcspn(init_utsname()->version, " "),
18216 init_utsname()->version);
18217 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
18218 }
18219 EXPORT_SYMBOL_GPL(oops_begin);
18220
18221 +extern void gr_handle_kernel_exploit(void);
18222 +
18223 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18224 {
18225 if (regs && kexec_should_crash(current))
18226 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18227 panic("Fatal exception in interrupt");
18228 if (panic_on_oops)
18229 panic("Fatal exception");
18230 - do_exit(signr);
18231 +
18232 + gr_handle_kernel_exploit();
18233 +
18234 + do_group_exit(signr);
18235 }
18236
18237 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18238 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18239 print_modules();
18240 show_regs(regs);
18241 #ifdef CONFIG_X86_32
18242 - if (user_mode_vm(regs)) {
18243 + if (user_mode(regs)) {
18244 sp = regs->sp;
18245 ss = regs->ss & 0xffff;
18246 } else {
18247 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
18248 unsigned long flags = oops_begin();
18249 int sig = SIGSEGV;
18250
18251 - if (!user_mode_vm(regs))
18252 + if (!user_mode(regs))
18253 report_bug(regs->ip, regs);
18254
18255 if (__die(str, regs, err))
18256 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18257 index 1038a41..db2c12b 100644
18258 --- a/arch/x86/kernel/dumpstack_32.c
18259 +++ b/arch/x86/kernel/dumpstack_32.c
18260 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18261 bp = stack_frame(task, regs);
18262
18263 for (;;) {
18264 - struct thread_info *context;
18265 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18266
18267 - context = (struct thread_info *)
18268 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18269 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18270 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18271
18272 - stack = (unsigned long *)context->previous_esp;
18273 - if (!stack)
18274 + if (stack_start == task_stack_page(task))
18275 break;
18276 + stack = *(unsigned long **)stack_start;
18277 if (ops->stack(data, "IRQ") < 0)
18278 break;
18279 touch_nmi_watchdog();
18280 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
18281 {
18282 int i;
18283
18284 - __show_regs(regs, !user_mode_vm(regs));
18285 + __show_regs(regs, !user_mode(regs));
18286
18287 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
18288 TASK_COMM_LEN, current->comm, task_pid_nr(current),
18289 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
18290 * When in-kernel, we also print out the stack and code at the
18291 * time of the fault..
18292 */
18293 - if (!user_mode_vm(regs)) {
18294 + if (!user_mode(regs)) {
18295 unsigned int code_prologue = code_bytes * 43 / 64;
18296 unsigned int code_len = code_bytes;
18297 unsigned char c;
18298 u8 *ip;
18299 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18300
18301 pr_emerg("Stack:\n");
18302 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18303
18304 pr_emerg("Code:");
18305
18306 - ip = (u8 *)regs->ip - code_prologue;
18307 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18308 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18309 /* try starting at IP */
18310 - ip = (u8 *)regs->ip;
18311 + ip = (u8 *)regs->ip + cs_base;
18312 code_len = code_len - code_prologue + 1;
18313 }
18314 for (i = 0; i < code_len; i++, ip++) {
18315 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18316 pr_cont(" Bad EIP value.");
18317 break;
18318 }
18319 - if (ip == (u8 *)regs->ip)
18320 + if (ip == (u8 *)regs->ip + cs_base)
18321 pr_cont(" <%02x>", c);
18322 else
18323 pr_cont(" %02x", c);
18324 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18325 {
18326 unsigned short ud2;
18327
18328 + ip = ktla_ktva(ip);
18329 if (ip < PAGE_OFFSET)
18330 return 0;
18331 if (probe_kernel_address((unsigned short *)ip, ud2))
18332 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18333
18334 return ud2 == 0x0b0f;
18335 }
18336 +
18337 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18338 +void pax_check_alloca(unsigned long size)
18339 +{
18340 + unsigned long sp = (unsigned long)&sp, stack_left;
18341 +
18342 + /* all kernel stacks are of the same size */
18343 + stack_left = sp & (THREAD_SIZE - 1);
18344 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18345 +}
18346 +EXPORT_SYMBOL(pax_check_alloca);
18347 +#endif
18348 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18349 index b653675..51cc8c0 100644
18350 --- a/arch/x86/kernel/dumpstack_64.c
18351 +++ b/arch/x86/kernel/dumpstack_64.c
18352 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18353 unsigned long *irq_stack_end =
18354 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18355 unsigned used = 0;
18356 - struct thread_info *tinfo;
18357 int graph = 0;
18358 unsigned long dummy;
18359 + void *stack_start;
18360
18361 if (!task)
18362 task = current;
18363 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18364 * current stack address. If the stacks consist of nested
18365 * exceptions
18366 */
18367 - tinfo = task_thread_info(task);
18368 for (;;) {
18369 char *id;
18370 unsigned long *estack_end;
18371 +
18372 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18373 &used, &id);
18374
18375 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18376 if (ops->stack(data, id) < 0)
18377 break;
18378
18379 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18380 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18381 data, estack_end, &graph);
18382 ops->stack(data, "<EOE>");
18383 /*
18384 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18385 * second-to-last pointer (index -2 to end) in the
18386 * exception stack:
18387 */
18388 + if ((u16)estack_end[-1] != __KERNEL_DS)
18389 + goto out;
18390 stack = (unsigned long *) estack_end[-2];
18391 continue;
18392 }
18393 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18394 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18395 if (ops->stack(data, "IRQ") < 0)
18396 break;
18397 - bp = ops->walk_stack(tinfo, stack, bp,
18398 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18399 ops, data, irq_stack_end, &graph);
18400 /*
18401 * We link to the next stack (which would be
18402 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18403 /*
18404 * This handles the process stack:
18405 */
18406 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18407 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18408 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18409 +out:
18410 put_cpu();
18411 }
18412 EXPORT_SYMBOL(dump_trace);
18413 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18414 {
18415 int i;
18416 unsigned long sp;
18417 - const int cpu = smp_processor_id();
18418 + const int cpu = raw_smp_processor_id();
18419 struct task_struct *cur = current;
18420
18421 sp = regs->sp;
18422 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18423
18424 return ud2 == 0x0b0f;
18425 }
18426 +
18427 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18428 +void pax_check_alloca(unsigned long size)
18429 +{
18430 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18431 + unsigned cpu, used;
18432 + char *id;
18433 +
18434 + /* check the process stack first */
18435 + stack_start = (unsigned long)task_stack_page(current);
18436 + stack_end = stack_start + THREAD_SIZE;
18437 + if (likely(stack_start <= sp && sp < stack_end)) {
18438 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18439 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18440 + return;
18441 + }
18442 +
18443 + cpu = get_cpu();
18444 +
18445 + /* check the irq stacks */
18446 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18447 + stack_start = stack_end - IRQ_STACK_SIZE;
18448 + if (stack_start <= sp && sp < stack_end) {
18449 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18450 + put_cpu();
18451 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18452 + return;
18453 + }
18454 +
18455 + /* check the exception stacks */
18456 + used = 0;
18457 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18458 + stack_start = stack_end - EXCEPTION_STKSZ;
18459 + if (stack_end && stack_start <= sp && sp < stack_end) {
18460 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18461 + put_cpu();
18462 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18463 + return;
18464 + }
18465 +
18466 + put_cpu();
18467 +
18468 + /* unknown stack */
18469 + BUG();
18470 +}
18471 +EXPORT_SYMBOL(pax_check_alloca);
18472 +#endif
18473 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18474 index 9b9f18b..9fcaa04 100644
18475 --- a/arch/x86/kernel/early_printk.c
18476 +++ b/arch/x86/kernel/early_printk.c
18477 @@ -7,6 +7,7 @@
18478 #include <linux/pci_regs.h>
18479 #include <linux/pci_ids.h>
18480 #include <linux/errno.h>
18481 +#include <linux/sched.h>
18482 #include <asm/io.h>
18483 #include <asm/processor.h>
18484 #include <asm/fcntl.h>
18485 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18486 index 6ed91d9..6cc365b 100644
18487 --- a/arch/x86/kernel/entry_32.S
18488 +++ b/arch/x86/kernel/entry_32.S
18489 @@ -177,13 +177,153 @@
18490 /*CFI_REL_OFFSET gs, PT_GS*/
18491 .endm
18492 .macro SET_KERNEL_GS reg
18493 +
18494 +#ifdef CONFIG_CC_STACKPROTECTOR
18495 movl $(__KERNEL_STACK_CANARY), \reg
18496 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18497 + movl $(__USER_DS), \reg
18498 +#else
18499 + xorl \reg, \reg
18500 +#endif
18501 +
18502 movl \reg, %gs
18503 .endm
18504
18505 #endif /* CONFIG_X86_32_LAZY_GS */
18506
18507 -.macro SAVE_ALL
18508 +.macro pax_enter_kernel
18509 +#ifdef CONFIG_PAX_KERNEXEC
18510 + call pax_enter_kernel
18511 +#endif
18512 +.endm
18513 +
18514 +.macro pax_exit_kernel
18515 +#ifdef CONFIG_PAX_KERNEXEC
18516 + call pax_exit_kernel
18517 +#endif
18518 +.endm
18519 +
18520 +#ifdef CONFIG_PAX_KERNEXEC
18521 +ENTRY(pax_enter_kernel)
18522 +#ifdef CONFIG_PARAVIRT
18523 + pushl %eax
18524 + pushl %ecx
18525 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18526 + mov %eax, %esi
18527 +#else
18528 + mov %cr0, %esi
18529 +#endif
18530 + bts $16, %esi
18531 + jnc 1f
18532 + mov %cs, %esi
18533 + cmp $__KERNEL_CS, %esi
18534 + jz 3f
18535 + ljmp $__KERNEL_CS, $3f
18536 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18537 +2:
18538 +#ifdef CONFIG_PARAVIRT
18539 + mov %esi, %eax
18540 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18541 +#else
18542 + mov %esi, %cr0
18543 +#endif
18544 +3:
18545 +#ifdef CONFIG_PARAVIRT
18546 + popl %ecx
18547 + popl %eax
18548 +#endif
18549 + ret
18550 +ENDPROC(pax_enter_kernel)
18551 +
18552 +ENTRY(pax_exit_kernel)
18553 +#ifdef CONFIG_PARAVIRT
18554 + pushl %eax
18555 + pushl %ecx
18556 +#endif
18557 + mov %cs, %esi
18558 + cmp $__KERNEXEC_KERNEL_CS, %esi
18559 + jnz 2f
18560 +#ifdef CONFIG_PARAVIRT
18561 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18562 + mov %eax, %esi
18563 +#else
18564 + mov %cr0, %esi
18565 +#endif
18566 + btr $16, %esi
18567 + ljmp $__KERNEL_CS, $1f
18568 +1:
18569 +#ifdef CONFIG_PARAVIRT
18570 + mov %esi, %eax
18571 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18572 +#else
18573 + mov %esi, %cr0
18574 +#endif
18575 +2:
18576 +#ifdef CONFIG_PARAVIRT
18577 + popl %ecx
18578 + popl %eax
18579 +#endif
18580 + ret
18581 +ENDPROC(pax_exit_kernel)
18582 +#endif
18583 +
18584 +.macro pax_erase_kstack
18585 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18586 + call pax_erase_kstack
18587 +#endif
18588 +.endm
18589 +
18590 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18591 +/*
18592 + * ebp: thread_info
18593 + */
18594 +ENTRY(pax_erase_kstack)
18595 + pushl %edi
18596 + pushl %ecx
18597 + pushl %eax
18598 +
18599 + mov TI_lowest_stack(%ebp), %edi
18600 + mov $-0xBEEF, %eax
18601 + std
18602 +
18603 +1: mov %edi, %ecx
18604 + and $THREAD_SIZE_asm - 1, %ecx
18605 + shr $2, %ecx
18606 + repne scasl
18607 + jecxz 2f
18608 +
18609 + cmp $2*16, %ecx
18610 + jc 2f
18611 +
18612 + mov $2*16, %ecx
18613 + repe scasl
18614 + jecxz 2f
18615 + jne 1b
18616 +
18617 +2: cld
18618 + mov %esp, %ecx
18619 + sub %edi, %ecx
18620 +
18621 + cmp $THREAD_SIZE_asm, %ecx
18622 + jb 3f
18623 + ud2
18624 +3:
18625 +
18626 + shr $2, %ecx
18627 + rep stosl
18628 +
18629 + mov TI_task_thread_sp0(%ebp), %edi
18630 + sub $128, %edi
18631 + mov %edi, TI_lowest_stack(%ebp)
18632 +
18633 + popl %eax
18634 + popl %ecx
18635 + popl %edi
18636 + ret
18637 +ENDPROC(pax_erase_kstack)
18638 +#endif
18639 +
18640 +.macro __SAVE_ALL _DS
18641 cld
18642 PUSH_GS
18643 pushl_cfi %fs
18644 @@ -206,7 +346,7 @@
18645 CFI_REL_OFFSET ecx, 0
18646 pushl_cfi %ebx
18647 CFI_REL_OFFSET ebx, 0
18648 - movl $(__USER_DS), %edx
18649 + movl $\_DS, %edx
18650 movl %edx, %ds
18651 movl %edx, %es
18652 movl $(__KERNEL_PERCPU), %edx
18653 @@ -214,6 +354,15 @@
18654 SET_KERNEL_GS %edx
18655 .endm
18656
18657 +.macro SAVE_ALL
18658 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18659 + __SAVE_ALL __KERNEL_DS
18660 + pax_enter_kernel
18661 +#else
18662 + __SAVE_ALL __USER_DS
18663 +#endif
18664 +.endm
18665 +
18666 .macro RESTORE_INT_REGS
18667 popl_cfi %ebx
18668 CFI_RESTORE ebx
18669 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18670 popfl_cfi
18671 jmp syscall_exit
18672 CFI_ENDPROC
18673 -END(ret_from_fork)
18674 +ENDPROC(ret_from_fork)
18675
18676 ENTRY(ret_from_kernel_thread)
18677 CFI_STARTPROC
18678 @@ -344,7 +493,15 @@ ret_from_intr:
18679 andl $SEGMENT_RPL_MASK, %eax
18680 #endif
18681 cmpl $USER_RPL, %eax
18682 +
18683 +#ifdef CONFIG_PAX_KERNEXEC
18684 + jae resume_userspace
18685 +
18686 + pax_exit_kernel
18687 + jmp resume_kernel
18688 +#else
18689 jb resume_kernel # not returning to v8086 or userspace
18690 +#endif
18691
18692 ENTRY(resume_userspace)
18693 LOCKDEP_SYS_EXIT
18694 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18695 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18696 # int/exception return?
18697 jne work_pending
18698 - jmp restore_all
18699 -END(ret_from_exception)
18700 + jmp restore_all_pax
18701 +ENDPROC(ret_from_exception)
18702
18703 #ifdef CONFIG_PREEMPT
18704 ENTRY(resume_kernel)
18705 @@ -372,7 +529,7 @@ need_resched:
18706 jz restore_all
18707 call preempt_schedule_irq
18708 jmp need_resched
18709 -END(resume_kernel)
18710 +ENDPROC(resume_kernel)
18711 #endif
18712 CFI_ENDPROC
18713 /*
18714 @@ -406,30 +563,45 @@ sysenter_past_esp:
18715 /*CFI_REL_OFFSET cs, 0*/
18716 /*
18717 * Push current_thread_info()->sysenter_return to the stack.
18718 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18719 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18720 */
18721 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18722 + pushl_cfi $0
18723 CFI_REL_OFFSET eip, 0
18724
18725 pushl_cfi %eax
18726 SAVE_ALL
18727 + GET_THREAD_INFO(%ebp)
18728 + movl TI_sysenter_return(%ebp),%ebp
18729 + movl %ebp,PT_EIP(%esp)
18730 ENABLE_INTERRUPTS(CLBR_NONE)
18731
18732 /*
18733 * Load the potential sixth argument from user stack.
18734 * Careful about security.
18735 */
18736 + movl PT_OLDESP(%esp),%ebp
18737 +
18738 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18739 + mov PT_OLDSS(%esp),%ds
18740 +1: movl %ds:(%ebp),%ebp
18741 + push %ss
18742 + pop %ds
18743 +#else
18744 cmpl $__PAGE_OFFSET-3,%ebp
18745 jae syscall_fault
18746 ASM_STAC
18747 1: movl (%ebp),%ebp
18748 ASM_CLAC
18749 +#endif
18750 +
18751 movl %ebp,PT_EBP(%esp)
18752 _ASM_EXTABLE(1b,syscall_fault)
18753
18754 GET_THREAD_INFO(%ebp)
18755
18756 +#ifdef CONFIG_PAX_RANDKSTACK
18757 + pax_erase_kstack
18758 +#endif
18759 +
18760 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18761 jnz sysenter_audit
18762 sysenter_do_call:
18763 @@ -444,12 +616,24 @@ sysenter_do_call:
18764 testl $_TIF_ALLWORK_MASK, %ecx
18765 jne sysexit_audit
18766 sysenter_exit:
18767 +
18768 +#ifdef CONFIG_PAX_RANDKSTACK
18769 + pushl_cfi %eax
18770 + movl %esp, %eax
18771 + call pax_randomize_kstack
18772 + popl_cfi %eax
18773 +#endif
18774 +
18775 + pax_erase_kstack
18776 +
18777 /* if something modifies registers it must also disable sysexit */
18778 movl PT_EIP(%esp), %edx
18779 movl PT_OLDESP(%esp), %ecx
18780 xorl %ebp,%ebp
18781 TRACE_IRQS_ON
18782 1: mov PT_FS(%esp), %fs
18783 +2: mov PT_DS(%esp), %ds
18784 +3: mov PT_ES(%esp), %es
18785 PTGS_TO_GS
18786 ENABLE_INTERRUPTS_SYSEXIT
18787
18788 @@ -466,6 +650,9 @@ sysenter_audit:
18789 movl %eax,%edx /* 2nd arg: syscall number */
18790 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18791 call __audit_syscall_entry
18792 +
18793 + pax_erase_kstack
18794 +
18795 pushl_cfi %ebx
18796 movl PT_EAX(%esp),%eax /* reload syscall number */
18797 jmp sysenter_do_call
18798 @@ -491,10 +678,16 @@ sysexit_audit:
18799
18800 CFI_ENDPROC
18801 .pushsection .fixup,"ax"
18802 -2: movl $0,PT_FS(%esp)
18803 +4: movl $0,PT_FS(%esp)
18804 + jmp 1b
18805 +5: movl $0,PT_DS(%esp)
18806 + jmp 1b
18807 +6: movl $0,PT_ES(%esp)
18808 jmp 1b
18809 .popsection
18810 - _ASM_EXTABLE(1b,2b)
18811 + _ASM_EXTABLE(1b,4b)
18812 + _ASM_EXTABLE(2b,5b)
18813 + _ASM_EXTABLE(3b,6b)
18814 PTGS_TO_GS_EX
18815 ENDPROC(ia32_sysenter_target)
18816
18817 @@ -509,6 +702,11 @@ ENTRY(system_call)
18818 pushl_cfi %eax # save orig_eax
18819 SAVE_ALL
18820 GET_THREAD_INFO(%ebp)
18821 +
18822 +#ifdef CONFIG_PAX_RANDKSTACK
18823 + pax_erase_kstack
18824 +#endif
18825 +
18826 # system call tracing in operation / emulation
18827 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18828 jnz syscall_trace_entry
18829 @@ -527,6 +725,15 @@ syscall_exit:
18830 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18831 jne syscall_exit_work
18832
18833 +restore_all_pax:
18834 +
18835 +#ifdef CONFIG_PAX_RANDKSTACK
18836 + movl %esp, %eax
18837 + call pax_randomize_kstack
18838 +#endif
18839 +
18840 + pax_erase_kstack
18841 +
18842 restore_all:
18843 TRACE_IRQS_IRET
18844 restore_all_notrace:
18845 @@ -583,14 +790,34 @@ ldt_ss:
18846 * compensating for the offset by changing to the ESPFIX segment with
18847 * a base address that matches for the difference.
18848 */
18849 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18850 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18851 mov %esp, %edx /* load kernel esp */
18852 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18853 mov %dx, %ax /* eax: new kernel esp */
18854 sub %eax, %edx /* offset (low word is 0) */
18855 +#ifdef CONFIG_SMP
18856 + movl PER_CPU_VAR(cpu_number), %ebx
18857 + shll $PAGE_SHIFT_asm, %ebx
18858 + addl $cpu_gdt_table, %ebx
18859 +#else
18860 + movl $cpu_gdt_table, %ebx
18861 +#endif
18862 shr $16, %edx
18863 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18864 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18865 +
18866 +#ifdef CONFIG_PAX_KERNEXEC
18867 + mov %cr0, %esi
18868 + btr $16, %esi
18869 + mov %esi, %cr0
18870 +#endif
18871 +
18872 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18873 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18874 +
18875 +#ifdef CONFIG_PAX_KERNEXEC
18876 + bts $16, %esi
18877 + mov %esi, %cr0
18878 +#endif
18879 +
18880 pushl_cfi $__ESPFIX_SS
18881 pushl_cfi %eax /* new kernel esp */
18882 /* Disable interrupts, but do not irqtrace this section: we
18883 @@ -619,20 +846,18 @@ work_resched:
18884 movl TI_flags(%ebp), %ecx
18885 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18886 # than syscall tracing?
18887 - jz restore_all
18888 + jz restore_all_pax
18889 testb $_TIF_NEED_RESCHED, %cl
18890 jnz work_resched
18891
18892 work_notifysig: # deal with pending signals and
18893 # notify-resume requests
18894 + movl %esp, %eax
18895 #ifdef CONFIG_VM86
18896 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18897 - movl %esp, %eax
18898 jne work_notifysig_v86 # returning to kernel-space or
18899 # vm86-space
18900 1:
18901 -#else
18902 - movl %esp, %eax
18903 #endif
18904 TRACE_IRQS_ON
18905 ENABLE_INTERRUPTS(CLBR_NONE)
18906 @@ -653,7 +878,7 @@ work_notifysig_v86:
18907 movl %eax, %esp
18908 jmp 1b
18909 #endif
18910 -END(work_pending)
18911 +ENDPROC(work_pending)
18912
18913 # perform syscall exit tracing
18914 ALIGN
18915 @@ -661,11 +886,14 @@ syscall_trace_entry:
18916 movl $-ENOSYS,PT_EAX(%esp)
18917 movl %esp, %eax
18918 call syscall_trace_enter
18919 +
18920 + pax_erase_kstack
18921 +
18922 /* What it returned is what we'll actually use. */
18923 cmpl $(NR_syscalls), %eax
18924 jnae syscall_call
18925 jmp syscall_exit
18926 -END(syscall_trace_entry)
18927 +ENDPROC(syscall_trace_entry)
18928
18929 # perform syscall exit tracing
18930 ALIGN
18931 @@ -678,21 +906,25 @@ syscall_exit_work:
18932 movl %esp, %eax
18933 call syscall_trace_leave
18934 jmp resume_userspace
18935 -END(syscall_exit_work)
18936 +ENDPROC(syscall_exit_work)
18937 CFI_ENDPROC
18938
18939 RING0_INT_FRAME # can't unwind into user space anyway
18940 syscall_fault:
18941 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18942 + push %ss
18943 + pop %ds
18944 +#endif
18945 ASM_CLAC
18946 GET_THREAD_INFO(%ebp)
18947 movl $-EFAULT,PT_EAX(%esp)
18948 jmp resume_userspace
18949 -END(syscall_fault)
18950 +ENDPROC(syscall_fault)
18951
18952 syscall_badsys:
18953 movl $-ENOSYS,PT_EAX(%esp)
18954 jmp resume_userspace
18955 -END(syscall_badsys)
18956 +ENDPROC(syscall_badsys)
18957 CFI_ENDPROC
18958 /*
18959 * End of kprobes section
18960 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
18961 * normal stack and adjusts ESP with the matching offset.
18962 */
18963 /* fixup the stack */
18964 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18965 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18966 +#ifdef CONFIG_SMP
18967 + movl PER_CPU_VAR(cpu_number), %ebx
18968 + shll $PAGE_SHIFT_asm, %ebx
18969 + addl $cpu_gdt_table, %ebx
18970 +#else
18971 + movl $cpu_gdt_table, %ebx
18972 +#endif
18973 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18974 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18975 shl $16, %eax
18976 addl %esp, %eax /* the adjusted stack pointer */
18977 pushl_cfi $__KERNEL_DS
18978 @@ -807,7 +1046,7 @@ vector=vector+1
18979 .endr
18980 2: jmp common_interrupt
18981 .endr
18982 -END(irq_entries_start)
18983 +ENDPROC(irq_entries_start)
18984
18985 .previous
18986 END(interrupt)
18987 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
18988 pushl_cfi $do_coprocessor_error
18989 jmp error_code
18990 CFI_ENDPROC
18991 -END(coprocessor_error)
18992 +ENDPROC(coprocessor_error)
18993
18994 ENTRY(simd_coprocessor_error)
18995 RING0_INT_FRAME
18996 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
18997 #endif
18998 jmp error_code
18999 CFI_ENDPROC
19000 -END(simd_coprocessor_error)
19001 +ENDPROC(simd_coprocessor_error)
19002
19003 ENTRY(device_not_available)
19004 RING0_INT_FRAME
19005 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
19006 pushl_cfi $do_device_not_available
19007 jmp error_code
19008 CFI_ENDPROC
19009 -END(device_not_available)
19010 +ENDPROC(device_not_available)
19011
19012 #ifdef CONFIG_PARAVIRT
19013 ENTRY(native_iret)
19014 iret
19015 _ASM_EXTABLE(native_iret, iret_exc)
19016 -END(native_iret)
19017 +ENDPROC(native_iret)
19018
19019 ENTRY(native_irq_enable_sysexit)
19020 sti
19021 sysexit
19022 -END(native_irq_enable_sysexit)
19023 +ENDPROC(native_irq_enable_sysexit)
19024 #endif
19025
19026 ENTRY(overflow)
19027 @@ -910,7 +1149,7 @@ ENTRY(overflow)
19028 pushl_cfi $do_overflow
19029 jmp error_code
19030 CFI_ENDPROC
19031 -END(overflow)
19032 +ENDPROC(overflow)
19033
19034 ENTRY(bounds)
19035 RING0_INT_FRAME
19036 @@ -919,7 +1158,7 @@ ENTRY(bounds)
19037 pushl_cfi $do_bounds
19038 jmp error_code
19039 CFI_ENDPROC
19040 -END(bounds)
19041 +ENDPROC(bounds)
19042
19043 ENTRY(invalid_op)
19044 RING0_INT_FRAME
19045 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
19046 pushl_cfi $do_invalid_op
19047 jmp error_code
19048 CFI_ENDPROC
19049 -END(invalid_op)
19050 +ENDPROC(invalid_op)
19051
19052 ENTRY(coprocessor_segment_overrun)
19053 RING0_INT_FRAME
19054 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
19055 pushl_cfi $do_coprocessor_segment_overrun
19056 jmp error_code
19057 CFI_ENDPROC
19058 -END(coprocessor_segment_overrun)
19059 +ENDPROC(coprocessor_segment_overrun)
19060
19061 ENTRY(invalid_TSS)
19062 RING0_EC_FRAME
19063 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
19064 pushl_cfi $do_invalid_TSS
19065 jmp error_code
19066 CFI_ENDPROC
19067 -END(invalid_TSS)
19068 +ENDPROC(invalid_TSS)
19069
19070 ENTRY(segment_not_present)
19071 RING0_EC_FRAME
19072 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
19073 pushl_cfi $do_segment_not_present
19074 jmp error_code
19075 CFI_ENDPROC
19076 -END(segment_not_present)
19077 +ENDPROC(segment_not_present)
19078
19079 ENTRY(stack_segment)
19080 RING0_EC_FRAME
19081 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
19082 pushl_cfi $do_stack_segment
19083 jmp error_code
19084 CFI_ENDPROC
19085 -END(stack_segment)
19086 +ENDPROC(stack_segment)
19087
19088 ENTRY(alignment_check)
19089 RING0_EC_FRAME
19090 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
19091 pushl_cfi $do_alignment_check
19092 jmp error_code
19093 CFI_ENDPROC
19094 -END(alignment_check)
19095 +ENDPROC(alignment_check)
19096
19097 ENTRY(divide_error)
19098 RING0_INT_FRAME
19099 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
19100 pushl_cfi $do_divide_error
19101 jmp error_code
19102 CFI_ENDPROC
19103 -END(divide_error)
19104 +ENDPROC(divide_error)
19105
19106 #ifdef CONFIG_X86_MCE
19107 ENTRY(machine_check)
19108 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
19109 pushl_cfi machine_check_vector
19110 jmp error_code
19111 CFI_ENDPROC
19112 -END(machine_check)
19113 +ENDPROC(machine_check)
19114 #endif
19115
19116 ENTRY(spurious_interrupt_bug)
19117 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
19118 pushl_cfi $do_spurious_interrupt_bug
19119 jmp error_code
19120 CFI_ENDPROC
19121 -END(spurious_interrupt_bug)
19122 +ENDPROC(spurious_interrupt_bug)
19123 /*
19124 * End of kprobes section
19125 */
19126 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
19127
19128 ENTRY(mcount)
19129 ret
19130 -END(mcount)
19131 +ENDPROC(mcount)
19132
19133 ENTRY(ftrace_caller)
19134 cmpl $0, function_trace_stop
19135 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
19136 .globl ftrace_stub
19137 ftrace_stub:
19138 ret
19139 -END(ftrace_caller)
19140 +ENDPROC(ftrace_caller)
19141
19142 ENTRY(ftrace_regs_caller)
19143 pushf /* push flags before compare (in cs location) */
19144 @@ -1235,7 +1474,7 @@ trace:
19145 popl %ecx
19146 popl %eax
19147 jmp ftrace_stub
19148 -END(mcount)
19149 +ENDPROC(mcount)
19150 #endif /* CONFIG_DYNAMIC_FTRACE */
19151 #endif /* CONFIG_FUNCTION_TRACER */
19152
19153 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
19154 popl %ecx
19155 popl %eax
19156 ret
19157 -END(ftrace_graph_caller)
19158 +ENDPROC(ftrace_graph_caller)
19159
19160 .globl return_to_handler
19161 return_to_handler:
19162 @@ -1309,15 +1548,18 @@ error_code:
19163 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
19164 REG_TO_PTGS %ecx
19165 SET_KERNEL_GS %ecx
19166 - movl $(__USER_DS), %ecx
19167 + movl $(__KERNEL_DS), %ecx
19168 movl %ecx, %ds
19169 movl %ecx, %es
19170 +
19171 + pax_enter_kernel
19172 +
19173 TRACE_IRQS_OFF
19174 movl %esp,%eax # pt_regs pointer
19175 call *%edi
19176 jmp ret_from_exception
19177 CFI_ENDPROC
19178 -END(page_fault)
19179 +ENDPROC(page_fault)
19180
19181 /*
19182 * Debug traps and NMI can happen at the one SYSENTER instruction
19183 @@ -1360,7 +1602,7 @@ debug_stack_correct:
19184 call do_debug
19185 jmp ret_from_exception
19186 CFI_ENDPROC
19187 -END(debug)
19188 +ENDPROC(debug)
19189
19190 /*
19191 * NMI is doubly nasty. It can happen _while_ we're handling
19192 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
19193 xorl %edx,%edx # zero error code
19194 movl %esp,%eax # pt_regs pointer
19195 call do_nmi
19196 +
19197 + pax_exit_kernel
19198 +
19199 jmp restore_all_notrace
19200 CFI_ENDPROC
19201
19202 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
19203 FIXUP_ESPFIX_STACK # %eax == %esp
19204 xorl %edx,%edx # zero error code
19205 call do_nmi
19206 +
19207 + pax_exit_kernel
19208 +
19209 RESTORE_REGS
19210 lss 12+4(%esp), %esp # back to espfix stack
19211 CFI_ADJUST_CFA_OFFSET -24
19212 jmp irq_return
19213 CFI_ENDPROC
19214 -END(nmi)
19215 +ENDPROC(nmi)
19216
19217 ENTRY(int3)
19218 RING0_INT_FRAME
19219 @@ -1452,14 +1700,14 @@ ENTRY(int3)
19220 call do_int3
19221 jmp ret_from_exception
19222 CFI_ENDPROC
19223 -END(int3)
19224 +ENDPROC(int3)
19225
19226 ENTRY(general_protection)
19227 RING0_EC_FRAME
19228 pushl_cfi $do_general_protection
19229 jmp error_code
19230 CFI_ENDPROC
19231 -END(general_protection)
19232 +ENDPROC(general_protection)
19233
19234 #ifdef CONFIG_KVM_GUEST
19235 ENTRY(async_page_fault)
19236 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
19237 pushl_cfi $do_async_page_fault
19238 jmp error_code
19239 CFI_ENDPROC
19240 -END(async_page_fault)
19241 +ENDPROC(async_page_fault)
19242 #endif
19243
19244 /*
19245 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
19246 index cb3c591..7ba137c 100644
19247 --- a/arch/x86/kernel/entry_64.S
19248 +++ b/arch/x86/kernel/entry_64.S
19249 @@ -59,6 +59,8 @@
19250 #include <asm/context_tracking.h>
19251 #include <asm/smap.h>
19252 #include <linux/err.h>
19253 +#include <asm/pgtable.h>
19254 +#include <asm/alternative-asm.h>
19255
19256 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19257 #include <linux/elf-em.h>
19258 @@ -80,8 +82,9 @@
19259 #ifdef CONFIG_DYNAMIC_FTRACE
19260
19261 ENTRY(function_hook)
19262 + pax_force_retaddr
19263 retq
19264 -END(function_hook)
19265 +ENDPROC(function_hook)
19266
19267 /* skip is set if stack has been adjusted */
19268 .macro ftrace_caller_setup skip=0
19269 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19270 #endif
19271
19272 GLOBAL(ftrace_stub)
19273 + pax_force_retaddr
19274 retq
19275 -END(ftrace_caller)
19276 +ENDPROC(ftrace_caller)
19277
19278 ENTRY(ftrace_regs_caller)
19279 /* Save the current flags before compare (in SS location)*/
19280 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19281 popfq
19282 jmp ftrace_stub
19283
19284 -END(ftrace_regs_caller)
19285 +ENDPROC(ftrace_regs_caller)
19286
19287
19288 #else /* ! CONFIG_DYNAMIC_FTRACE */
19289 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19290 #endif
19291
19292 GLOBAL(ftrace_stub)
19293 + pax_force_retaddr
19294 retq
19295
19296 trace:
19297 @@ -225,12 +230,13 @@ trace:
19298 #endif
19299 subq $MCOUNT_INSN_SIZE, %rdi
19300
19301 + pax_force_fptr ftrace_trace_function
19302 call *ftrace_trace_function
19303
19304 MCOUNT_RESTORE_FRAME
19305
19306 jmp ftrace_stub
19307 -END(function_hook)
19308 +ENDPROC(function_hook)
19309 #endif /* CONFIG_DYNAMIC_FTRACE */
19310 #endif /* CONFIG_FUNCTION_TRACER */
19311
19312 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19313
19314 MCOUNT_RESTORE_FRAME
19315
19316 + pax_force_retaddr
19317 retq
19318 -END(ftrace_graph_caller)
19319 +ENDPROC(ftrace_graph_caller)
19320
19321 GLOBAL(return_to_handler)
19322 subq $24, %rsp
19323 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19324 movq 8(%rsp), %rdx
19325 movq (%rsp), %rax
19326 addq $24, %rsp
19327 + pax_force_fptr %rdi
19328 jmp *%rdi
19329 +ENDPROC(return_to_handler)
19330 #endif
19331
19332
19333 @@ -284,6 +293,273 @@ ENTRY(native_usergs_sysret64)
19334 ENDPROC(native_usergs_sysret64)
19335 #endif /* CONFIG_PARAVIRT */
19336
19337 + .macro ljmpq sel, off
19338 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19339 + .byte 0x48; ljmp *1234f(%rip)
19340 + .pushsection .rodata
19341 + .align 16
19342 + 1234: .quad \off; .word \sel
19343 + .popsection
19344 +#else
19345 + pushq $\sel
19346 + pushq $\off
19347 + lretq
19348 +#endif
19349 + .endm
19350 +
19351 + .macro pax_enter_kernel
19352 + pax_set_fptr_mask
19353 +#ifdef CONFIG_PAX_KERNEXEC
19354 + call pax_enter_kernel
19355 +#endif
19356 + .endm
19357 +
19358 + .macro pax_exit_kernel
19359 +#ifdef CONFIG_PAX_KERNEXEC
19360 + call pax_exit_kernel
19361 +#endif
19362 + .endm
19363 +
19364 +#ifdef CONFIG_PAX_KERNEXEC
19365 +ENTRY(pax_enter_kernel)
19366 + pushq %rdi
19367 +
19368 +#ifdef CONFIG_PARAVIRT
19369 + PV_SAVE_REGS(CLBR_RDI)
19370 +#endif
19371 +
19372 + GET_CR0_INTO_RDI
19373 + bts $16,%rdi
19374 + jnc 3f
19375 + mov %cs,%edi
19376 + cmp $__KERNEL_CS,%edi
19377 + jnz 2f
19378 +1:
19379 +
19380 +#ifdef CONFIG_PARAVIRT
19381 + PV_RESTORE_REGS(CLBR_RDI)
19382 +#endif
19383 +
19384 + popq %rdi
19385 + pax_force_retaddr
19386 + retq
19387 +
19388 +2: ljmpq __KERNEL_CS,1b
19389 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19390 +4: SET_RDI_INTO_CR0
19391 + jmp 1b
19392 +ENDPROC(pax_enter_kernel)
19393 +
19394 +ENTRY(pax_exit_kernel)
19395 + pushq %rdi
19396 +
19397 +#ifdef CONFIG_PARAVIRT
19398 + PV_SAVE_REGS(CLBR_RDI)
19399 +#endif
19400 +
19401 + mov %cs,%rdi
19402 + cmp $__KERNEXEC_KERNEL_CS,%edi
19403 + jz 2f
19404 +1:
19405 +
19406 +#ifdef CONFIG_PARAVIRT
19407 + PV_RESTORE_REGS(CLBR_RDI);
19408 +#endif
19409 +
19410 + popq %rdi
19411 + pax_force_retaddr
19412 + retq
19413 +
19414 +2: GET_CR0_INTO_RDI
19415 + btr $16,%rdi
19416 + ljmpq __KERNEL_CS,3f
19417 +3: SET_RDI_INTO_CR0
19418 + jmp 1b
19419 +ENDPROC(pax_exit_kernel)
19420 +#endif
19421 +
19422 + .macro pax_enter_kernel_user
19423 + pax_set_fptr_mask
19424 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19425 + call pax_enter_kernel_user
19426 +#endif
19427 + .endm
19428 +
19429 + .macro pax_exit_kernel_user
19430 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19431 + call pax_exit_kernel_user
19432 +#endif
19433 +#ifdef CONFIG_PAX_RANDKSTACK
19434 + pushq %rax
19435 + call pax_randomize_kstack
19436 + popq %rax
19437 +#endif
19438 + .endm
19439 +
19440 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19441 +ENTRY(pax_enter_kernel_user)
19442 + pushq %rdi
19443 + pushq %rbx
19444 +
19445 +#ifdef CONFIG_PARAVIRT
19446 + PV_SAVE_REGS(CLBR_RDI)
19447 +#endif
19448 +
19449 + GET_CR3_INTO_RDI
19450 + mov %rdi,%rbx
19451 + add $__START_KERNEL_map,%rbx
19452 + sub phys_base(%rip),%rbx
19453 +
19454 +#ifdef CONFIG_PARAVIRT
19455 + pushq %rdi
19456 + cmpl $0, pv_info+PARAVIRT_enabled
19457 + jz 1f
19458 + i = 0
19459 + .rept USER_PGD_PTRS
19460 + mov i*8(%rbx),%rsi
19461 + mov $0,%sil
19462 + lea i*8(%rbx),%rdi
19463 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19464 + i = i + 1
19465 + .endr
19466 + jmp 2f
19467 +1:
19468 +#endif
19469 +
19470 + i = 0
19471 + .rept USER_PGD_PTRS
19472 + movb $0,i*8(%rbx)
19473 + i = i + 1
19474 + .endr
19475 +
19476 +#ifdef CONFIG_PARAVIRT
19477 +2: popq %rdi
19478 +#endif
19479 + SET_RDI_INTO_CR3
19480 +
19481 +#ifdef CONFIG_PAX_KERNEXEC
19482 + GET_CR0_INTO_RDI
19483 + bts $16,%rdi
19484 + SET_RDI_INTO_CR0
19485 +#endif
19486 +
19487 +#ifdef CONFIG_PARAVIRT
19488 + PV_RESTORE_REGS(CLBR_RDI)
19489 +#endif
19490 +
19491 + popq %rbx
19492 + popq %rdi
19493 + pax_force_retaddr
19494 + retq
19495 +ENDPROC(pax_enter_kernel_user)
19496 +
19497 +ENTRY(pax_exit_kernel_user)
19498 + push %rdi
19499 +
19500 +#ifdef CONFIG_PARAVIRT
19501 + pushq %rbx
19502 + PV_SAVE_REGS(CLBR_RDI)
19503 +#endif
19504 +
19505 +#ifdef CONFIG_PAX_KERNEXEC
19506 + GET_CR0_INTO_RDI
19507 + btr $16,%rdi
19508 + SET_RDI_INTO_CR0
19509 +#endif
19510 +
19511 + GET_CR3_INTO_RDI
19512 + add $__START_KERNEL_map,%rdi
19513 + sub phys_base(%rip),%rdi
19514 +
19515 +#ifdef CONFIG_PARAVIRT
19516 + cmpl $0, pv_info+PARAVIRT_enabled
19517 + jz 1f
19518 + mov %rdi,%rbx
19519 + i = 0
19520 + .rept USER_PGD_PTRS
19521 + mov i*8(%rbx),%rsi
19522 + mov $0x67,%sil
19523 + lea i*8(%rbx),%rdi
19524 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19525 + i = i + 1
19526 + .endr
19527 + jmp 2f
19528 +1:
19529 +#endif
19530 +
19531 + i = 0
19532 + .rept USER_PGD_PTRS
19533 + movb $0x67,i*8(%rdi)
19534 + i = i + 1
19535 + .endr
19536 +
19537 +#ifdef CONFIG_PARAVIRT
19538 +2: PV_RESTORE_REGS(CLBR_RDI)
19539 + popq %rbx
19540 +#endif
19541 +
19542 + popq %rdi
19543 + pax_force_retaddr
19544 + retq
19545 +ENDPROC(pax_exit_kernel_user)
19546 +#endif
19547 +
19548 +.macro pax_erase_kstack
19549 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19550 + call pax_erase_kstack
19551 +#endif
19552 +.endm
19553 +
19554 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19555 +ENTRY(pax_erase_kstack)
19556 + pushq %rdi
19557 + pushq %rcx
19558 + pushq %rax
19559 + pushq %r11
19560 +
19561 + GET_THREAD_INFO(%r11)
19562 + mov TI_lowest_stack(%r11), %rdi
19563 + mov $-0xBEEF, %rax
19564 + std
19565 +
19566 +1: mov %edi, %ecx
19567 + and $THREAD_SIZE_asm - 1, %ecx
19568 + shr $3, %ecx
19569 + repne scasq
19570 + jecxz 2f
19571 +
19572 + cmp $2*8, %ecx
19573 + jc 2f
19574 +
19575 + mov $2*8, %ecx
19576 + repe scasq
19577 + jecxz 2f
19578 + jne 1b
19579 +
19580 +2: cld
19581 + mov %esp, %ecx
19582 + sub %edi, %ecx
19583 +
19584 + cmp $THREAD_SIZE_asm, %rcx
19585 + jb 3f
19586 + ud2
19587 +3:
19588 +
19589 + shr $3, %ecx
19590 + rep stosq
19591 +
19592 + mov TI_task_thread_sp0(%r11), %rdi
19593 + sub $256, %rdi
19594 + mov %rdi, TI_lowest_stack(%r11)
19595 +
19596 + popq %r11
19597 + popq %rax
19598 + popq %rcx
19599 + popq %rdi
19600 + pax_force_retaddr
19601 + ret
19602 +ENDPROC(pax_erase_kstack)
19603 +#endif
19604
19605 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19606 #ifdef CONFIG_TRACE_IRQFLAGS
19607 @@ -375,8 +651,8 @@ ENDPROC(native_usergs_sysret64)
19608 .endm
19609
19610 .macro UNFAKE_STACK_FRAME
19611 - addq $8*6, %rsp
19612 - CFI_ADJUST_CFA_OFFSET -(6*8)
19613 + addq $8*6 + ARG_SKIP, %rsp
19614 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19615 .endm
19616
19617 /*
19618 @@ -463,7 +739,7 @@ ENDPROC(native_usergs_sysret64)
19619 movq %rsp, %rsi
19620
19621 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19622 - testl $3, CS-RBP(%rsi)
19623 + testb $3, CS-RBP(%rsi)
19624 je 1f
19625 SWAPGS
19626 /*
19627 @@ -498,9 +774,10 @@ ENTRY(save_rest)
19628 movq_cfi r15, R15+16
19629 movq %r11, 8(%rsp) /* return address */
19630 FIXUP_TOP_OF_STACK %r11, 16
19631 + pax_force_retaddr
19632 ret
19633 CFI_ENDPROC
19634 -END(save_rest)
19635 +ENDPROC(save_rest)
19636
19637 /* save complete stack frame */
19638 .pushsection .kprobes.text, "ax"
19639 @@ -529,9 +806,10 @@ ENTRY(save_paranoid)
19640 js 1f /* negative -> in kernel */
19641 SWAPGS
19642 xorl %ebx,%ebx
19643 -1: ret
19644 +1: pax_force_retaddr_bts
19645 + ret
19646 CFI_ENDPROC
19647 -END(save_paranoid)
19648 +ENDPROC(save_paranoid)
19649 .popsection
19650
19651 /*
19652 @@ -553,7 +831,7 @@ ENTRY(ret_from_fork)
19653
19654 RESTORE_REST
19655
19656 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19657 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19658 jz 1f
19659
19660 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19661 @@ -571,7 +849,7 @@ ENTRY(ret_from_fork)
19662 RESTORE_REST
19663 jmp int_ret_from_sys_call
19664 CFI_ENDPROC
19665 -END(ret_from_fork)
19666 +ENDPROC(ret_from_fork)
19667
19668 /*
19669 * System call entry. Up to 6 arguments in registers are supported.
19670 @@ -608,7 +886,7 @@ END(ret_from_fork)
19671 ENTRY(system_call)
19672 CFI_STARTPROC simple
19673 CFI_SIGNAL_FRAME
19674 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19675 + CFI_DEF_CFA rsp,0
19676 CFI_REGISTER rip,rcx
19677 /*CFI_REGISTER rflags,r11*/
19678 SWAPGS_UNSAFE_STACK
19679 @@ -621,16 +899,23 @@ GLOBAL(system_call_after_swapgs)
19680
19681 movq %rsp,PER_CPU_VAR(old_rsp)
19682 movq PER_CPU_VAR(kernel_stack),%rsp
19683 + SAVE_ARGS 8*6,0
19684 + pax_enter_kernel_user
19685 +
19686 +#ifdef CONFIG_PAX_RANDKSTACK
19687 + pax_erase_kstack
19688 +#endif
19689 +
19690 /*
19691 * No need to follow this irqs off/on section - it's straight
19692 * and short:
19693 */
19694 ENABLE_INTERRUPTS(CLBR_NONE)
19695 - SAVE_ARGS 8,0
19696 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19697 movq %rcx,RIP-ARGOFFSET(%rsp)
19698 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19699 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19700 + GET_THREAD_INFO(%rcx)
19701 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19702 jnz tracesys
19703 system_call_fastpath:
19704 #if __SYSCALL_MASK == ~0
19705 @@ -640,7 +925,7 @@ system_call_fastpath:
19706 cmpl $__NR_syscall_max,%eax
19707 #endif
19708 ja badsys
19709 - movq %r10,%rcx
19710 + movq R10-ARGOFFSET(%rsp),%rcx
19711 call *sys_call_table(,%rax,8) # XXX: rip relative
19712 movq %rax,RAX-ARGOFFSET(%rsp)
19713 /*
19714 @@ -654,10 +939,13 @@ sysret_check:
19715 LOCKDEP_SYS_EXIT
19716 DISABLE_INTERRUPTS(CLBR_NONE)
19717 TRACE_IRQS_OFF
19718 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19719 + GET_THREAD_INFO(%rcx)
19720 + movl TI_flags(%rcx),%edx
19721 andl %edi,%edx
19722 jnz sysret_careful
19723 CFI_REMEMBER_STATE
19724 + pax_exit_kernel_user
19725 + pax_erase_kstack
19726 /*
19727 * sysretq will re-enable interrupts:
19728 */
19729 @@ -709,14 +997,18 @@ badsys:
19730 * jump back to the normal fast path.
19731 */
19732 auditsys:
19733 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19734 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19735 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19736 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19737 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19738 movq %rax,%rsi /* 2nd arg: syscall number */
19739 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19740 call __audit_syscall_entry
19741 +
19742 + pax_erase_kstack
19743 +
19744 LOAD_ARGS 0 /* reload call-clobbered registers */
19745 + pax_set_fptr_mask
19746 jmp system_call_fastpath
19747
19748 /*
19749 @@ -737,7 +1029,7 @@ sysret_audit:
19750 /* Do syscall tracing */
19751 tracesys:
19752 #ifdef CONFIG_AUDITSYSCALL
19753 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19754 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19755 jz auditsys
19756 #endif
19757 SAVE_REST
19758 @@ -745,12 +1037,16 @@ tracesys:
19759 FIXUP_TOP_OF_STACK %rdi
19760 movq %rsp,%rdi
19761 call syscall_trace_enter
19762 +
19763 + pax_erase_kstack
19764 +
19765 /*
19766 * Reload arg registers from stack in case ptrace changed them.
19767 * We don't reload %rax because syscall_trace_enter() returned
19768 * the value it wants us to use in the table lookup.
19769 */
19770 LOAD_ARGS ARGOFFSET, 1
19771 + pax_set_fptr_mask
19772 RESTORE_REST
19773 #if __SYSCALL_MASK == ~0
19774 cmpq $__NR_syscall_max,%rax
19775 @@ -759,7 +1055,7 @@ tracesys:
19776 cmpl $__NR_syscall_max,%eax
19777 #endif
19778 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19779 - movq %r10,%rcx /* fixup for C */
19780 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19781 call *sys_call_table(,%rax,8)
19782 movq %rax,RAX-ARGOFFSET(%rsp)
19783 /* Use IRET because user could have changed frame */
19784 @@ -780,7 +1076,9 @@ GLOBAL(int_with_check)
19785 andl %edi,%edx
19786 jnz int_careful
19787 andl $~TS_COMPAT,TI_status(%rcx)
19788 - jmp retint_swapgs
19789 + pax_exit_kernel_user
19790 + pax_erase_kstack
19791 + jmp retint_swapgs_pax
19792
19793 /* Either reschedule or signal or syscall exit tracking needed. */
19794 /* First do a reschedule test. */
19795 @@ -826,7 +1124,7 @@ int_restore_rest:
19796 TRACE_IRQS_OFF
19797 jmp int_with_check
19798 CFI_ENDPROC
19799 -END(system_call)
19800 +ENDPROC(system_call)
19801
19802 /*
19803 * Certain special system calls that need to save a complete full stack frame.
19804 @@ -842,7 +1140,7 @@ ENTRY(\label)
19805 call \func
19806 jmp ptregscall_common
19807 CFI_ENDPROC
19808 -END(\label)
19809 +ENDPROC(\label)
19810 .endm
19811
19812 .macro FORK_LIKE func
19813 @@ -856,9 +1154,10 @@ ENTRY(stub_\func)
19814 DEFAULT_FRAME 0 8 /* offset 8: return address */
19815 call sys_\func
19816 RESTORE_TOP_OF_STACK %r11, 8
19817 + pax_force_retaddr
19818 ret $REST_SKIP /* pop extended registers */
19819 CFI_ENDPROC
19820 -END(stub_\func)
19821 +ENDPROC(stub_\func)
19822 .endm
19823
19824 FORK_LIKE clone
19825 @@ -875,9 +1174,10 @@ ENTRY(ptregscall_common)
19826 movq_cfi_restore R12+8, r12
19827 movq_cfi_restore RBP+8, rbp
19828 movq_cfi_restore RBX+8, rbx
19829 + pax_force_retaddr
19830 ret $REST_SKIP /* pop extended registers */
19831 CFI_ENDPROC
19832 -END(ptregscall_common)
19833 +ENDPROC(ptregscall_common)
19834
19835 ENTRY(stub_execve)
19836 CFI_STARTPROC
19837 @@ -891,7 +1191,7 @@ ENTRY(stub_execve)
19838 RESTORE_REST
19839 jmp int_ret_from_sys_call
19840 CFI_ENDPROC
19841 -END(stub_execve)
19842 +ENDPROC(stub_execve)
19843
19844 /*
19845 * sigreturn is special because it needs to restore all registers on return.
19846 @@ -909,7 +1209,7 @@ ENTRY(stub_rt_sigreturn)
19847 RESTORE_REST
19848 jmp int_ret_from_sys_call
19849 CFI_ENDPROC
19850 -END(stub_rt_sigreturn)
19851 +ENDPROC(stub_rt_sigreturn)
19852
19853 #ifdef CONFIG_X86_X32_ABI
19854 ENTRY(stub_x32_rt_sigreturn)
19855 @@ -975,7 +1275,7 @@ vector=vector+1
19856 2: jmp common_interrupt
19857 .endr
19858 CFI_ENDPROC
19859 -END(irq_entries_start)
19860 +ENDPROC(irq_entries_start)
19861
19862 .previous
19863 END(interrupt)
19864 @@ -995,6 +1295,16 @@ END(interrupt)
19865 subq $ORIG_RAX-RBP, %rsp
19866 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19867 SAVE_ARGS_IRQ
19868 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19869 + testb $3, CS(%rdi)
19870 + jnz 1f
19871 + pax_enter_kernel
19872 + jmp 2f
19873 +1: pax_enter_kernel_user
19874 +2:
19875 +#else
19876 + pax_enter_kernel
19877 +#endif
19878 call \func
19879 .endm
19880
19881 @@ -1027,7 +1337,7 @@ ret_from_intr:
19882
19883 exit_intr:
19884 GET_THREAD_INFO(%rcx)
19885 - testl $3,CS-ARGOFFSET(%rsp)
19886 + testb $3,CS-ARGOFFSET(%rsp)
19887 je retint_kernel
19888
19889 /* Interrupt came from user space */
19890 @@ -1049,12 +1359,16 @@ retint_swapgs: /* return to user-space */
19891 * The iretq could re-enable interrupts:
19892 */
19893 DISABLE_INTERRUPTS(CLBR_ANY)
19894 + pax_exit_kernel_user
19895 +retint_swapgs_pax:
19896 TRACE_IRQS_IRETQ
19897 SWAPGS
19898 jmp restore_args
19899
19900 retint_restore_args: /* return to kernel space */
19901 DISABLE_INTERRUPTS(CLBR_ANY)
19902 + pax_exit_kernel
19903 + pax_force_retaddr (RIP-ARGOFFSET)
19904 /*
19905 * The iretq could re-enable interrupts:
19906 */
19907 @@ -1137,7 +1451,7 @@ ENTRY(retint_kernel)
19908 #endif
19909
19910 CFI_ENDPROC
19911 -END(common_interrupt)
19912 +ENDPROC(common_interrupt)
19913 /*
19914 * End of kprobes section
19915 */
19916 @@ -1155,7 +1469,7 @@ ENTRY(\sym)
19917 interrupt \do_sym
19918 jmp ret_from_intr
19919 CFI_ENDPROC
19920 -END(\sym)
19921 +ENDPROC(\sym)
19922 .endm
19923
19924 #ifdef CONFIG_SMP
19925 @@ -1211,12 +1525,22 @@ ENTRY(\sym)
19926 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19927 call error_entry
19928 DEFAULT_FRAME 0
19929 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19930 + testb $3, CS(%rsp)
19931 + jnz 1f
19932 + pax_enter_kernel
19933 + jmp 2f
19934 +1: pax_enter_kernel_user
19935 +2:
19936 +#else
19937 + pax_enter_kernel
19938 +#endif
19939 movq %rsp,%rdi /* pt_regs pointer */
19940 xorl %esi,%esi /* no error code */
19941 call \do_sym
19942 jmp error_exit /* %ebx: no swapgs flag */
19943 CFI_ENDPROC
19944 -END(\sym)
19945 +ENDPROC(\sym)
19946 .endm
19947
19948 .macro paranoidzeroentry sym do_sym
19949 @@ -1229,15 +1553,25 @@ ENTRY(\sym)
19950 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19951 call save_paranoid
19952 TRACE_IRQS_OFF
19953 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19954 + testb $3, CS(%rsp)
19955 + jnz 1f
19956 + pax_enter_kernel
19957 + jmp 2f
19958 +1: pax_enter_kernel_user
19959 +2:
19960 +#else
19961 + pax_enter_kernel
19962 +#endif
19963 movq %rsp,%rdi /* pt_regs pointer */
19964 xorl %esi,%esi /* no error code */
19965 call \do_sym
19966 jmp paranoid_exit /* %ebx: no swapgs flag */
19967 CFI_ENDPROC
19968 -END(\sym)
19969 +ENDPROC(\sym)
19970 .endm
19971
19972 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19973 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19974 .macro paranoidzeroentry_ist sym do_sym ist
19975 ENTRY(\sym)
19976 INTR_FRAME
19977 @@ -1248,14 +1582,30 @@ ENTRY(\sym)
19978 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19979 call save_paranoid
19980 TRACE_IRQS_OFF_DEBUG
19981 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19982 + testb $3, CS(%rsp)
19983 + jnz 1f
19984 + pax_enter_kernel
19985 + jmp 2f
19986 +1: pax_enter_kernel_user
19987 +2:
19988 +#else
19989 + pax_enter_kernel
19990 +#endif
19991 movq %rsp,%rdi /* pt_regs pointer */
19992 xorl %esi,%esi /* no error code */
19993 +#ifdef CONFIG_SMP
19994 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19995 + lea init_tss(%r12), %r12
19996 +#else
19997 + lea init_tss(%rip), %r12
19998 +#endif
19999 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20000 call \do_sym
20001 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20002 jmp paranoid_exit /* %ebx: no swapgs flag */
20003 CFI_ENDPROC
20004 -END(\sym)
20005 +ENDPROC(\sym)
20006 .endm
20007
20008 .macro errorentry sym do_sym
20009 @@ -1267,13 +1617,23 @@ ENTRY(\sym)
20010 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20011 call error_entry
20012 DEFAULT_FRAME 0
20013 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20014 + testb $3, CS(%rsp)
20015 + jnz 1f
20016 + pax_enter_kernel
20017 + jmp 2f
20018 +1: pax_enter_kernel_user
20019 +2:
20020 +#else
20021 + pax_enter_kernel
20022 +#endif
20023 movq %rsp,%rdi /* pt_regs pointer */
20024 movq ORIG_RAX(%rsp),%rsi /* get error code */
20025 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20026 call \do_sym
20027 jmp error_exit /* %ebx: no swapgs flag */
20028 CFI_ENDPROC
20029 -END(\sym)
20030 +ENDPROC(\sym)
20031 .endm
20032
20033 /* error code is on the stack already */
20034 @@ -1287,13 +1647,23 @@ ENTRY(\sym)
20035 call save_paranoid
20036 DEFAULT_FRAME 0
20037 TRACE_IRQS_OFF
20038 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20039 + testb $3, CS(%rsp)
20040 + jnz 1f
20041 + pax_enter_kernel
20042 + jmp 2f
20043 +1: pax_enter_kernel_user
20044 +2:
20045 +#else
20046 + pax_enter_kernel
20047 +#endif
20048 movq %rsp,%rdi /* pt_regs pointer */
20049 movq ORIG_RAX(%rsp),%rsi /* get error code */
20050 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20051 call \do_sym
20052 jmp paranoid_exit /* %ebx: no swapgs flag */
20053 CFI_ENDPROC
20054 -END(\sym)
20055 +ENDPROC(\sym)
20056 .endm
20057
20058 zeroentry divide_error do_divide_error
20059 @@ -1323,9 +1693,10 @@ gs_change:
20060 2: mfence /* workaround */
20061 SWAPGS
20062 popfq_cfi
20063 + pax_force_retaddr
20064 ret
20065 CFI_ENDPROC
20066 -END(native_load_gs_index)
20067 +ENDPROC(native_load_gs_index)
20068
20069 _ASM_EXTABLE(gs_change,bad_gs)
20070 .section .fixup,"ax"
20071 @@ -1353,9 +1724,10 @@ ENTRY(call_softirq)
20072 CFI_DEF_CFA_REGISTER rsp
20073 CFI_ADJUST_CFA_OFFSET -8
20074 decl PER_CPU_VAR(irq_count)
20075 + pax_force_retaddr
20076 ret
20077 CFI_ENDPROC
20078 -END(call_softirq)
20079 +ENDPROC(call_softirq)
20080
20081 #ifdef CONFIG_XEN
20082 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
20083 @@ -1393,7 +1765,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
20084 decl PER_CPU_VAR(irq_count)
20085 jmp error_exit
20086 CFI_ENDPROC
20087 -END(xen_do_hypervisor_callback)
20088 +ENDPROC(xen_do_hypervisor_callback)
20089
20090 /*
20091 * Hypervisor uses this for application faults while it executes.
20092 @@ -1452,7 +1824,7 @@ ENTRY(xen_failsafe_callback)
20093 SAVE_ALL
20094 jmp error_exit
20095 CFI_ENDPROC
20096 -END(xen_failsafe_callback)
20097 +ENDPROC(xen_failsafe_callback)
20098
20099 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
20100 xen_hvm_callback_vector xen_evtchn_do_upcall
20101 @@ -1501,16 +1873,31 @@ ENTRY(paranoid_exit)
20102 TRACE_IRQS_OFF_DEBUG
20103 testl %ebx,%ebx /* swapgs needed? */
20104 jnz paranoid_restore
20105 - testl $3,CS(%rsp)
20106 + testb $3,CS(%rsp)
20107 jnz paranoid_userspace
20108 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20109 + pax_exit_kernel
20110 + TRACE_IRQS_IRETQ 0
20111 + SWAPGS_UNSAFE_STACK
20112 + RESTORE_ALL 8
20113 + pax_force_retaddr_bts
20114 + jmp irq_return
20115 +#endif
20116 paranoid_swapgs:
20117 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20118 + pax_exit_kernel_user
20119 +#else
20120 + pax_exit_kernel
20121 +#endif
20122 TRACE_IRQS_IRETQ 0
20123 SWAPGS_UNSAFE_STACK
20124 RESTORE_ALL 8
20125 jmp irq_return
20126 paranoid_restore:
20127 + pax_exit_kernel
20128 TRACE_IRQS_IRETQ_DEBUG 0
20129 RESTORE_ALL 8
20130 + pax_force_retaddr_bts
20131 jmp irq_return
20132 paranoid_userspace:
20133 GET_THREAD_INFO(%rcx)
20134 @@ -1539,7 +1926,7 @@ paranoid_schedule:
20135 TRACE_IRQS_OFF
20136 jmp paranoid_userspace
20137 CFI_ENDPROC
20138 -END(paranoid_exit)
20139 +ENDPROC(paranoid_exit)
20140
20141 /*
20142 * Exception entry point. This expects an error code/orig_rax on the stack.
20143 @@ -1566,12 +1953,13 @@ ENTRY(error_entry)
20144 movq_cfi r14, R14+8
20145 movq_cfi r15, R15+8
20146 xorl %ebx,%ebx
20147 - testl $3,CS+8(%rsp)
20148 + testb $3,CS+8(%rsp)
20149 je error_kernelspace
20150 error_swapgs:
20151 SWAPGS
20152 error_sti:
20153 TRACE_IRQS_OFF
20154 + pax_force_retaddr_bts
20155 ret
20156
20157 /*
20158 @@ -1598,7 +1986,7 @@ bstep_iret:
20159 movq %rcx,RIP+8(%rsp)
20160 jmp error_swapgs
20161 CFI_ENDPROC
20162 -END(error_entry)
20163 +ENDPROC(error_entry)
20164
20165
20166 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
20167 @@ -1618,7 +2006,7 @@ ENTRY(error_exit)
20168 jnz retint_careful
20169 jmp retint_swapgs
20170 CFI_ENDPROC
20171 -END(error_exit)
20172 +ENDPROC(error_exit)
20173
20174 /*
20175 * Test if a given stack is an NMI stack or not.
20176 @@ -1676,9 +2064,11 @@ ENTRY(nmi)
20177 * If %cs was not the kernel segment, then the NMI triggered in user
20178 * space, which means it is definitely not nested.
20179 */
20180 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20181 + je 1f
20182 cmpl $__KERNEL_CS, 16(%rsp)
20183 jne first_nmi
20184 -
20185 +1:
20186 /*
20187 * Check the special variable on the stack to see if NMIs are
20188 * executing.
20189 @@ -1712,14 +2102,13 @@ nested_nmi:
20190
20191 1:
20192 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
20193 - leaq -1*8(%rsp), %rdx
20194 - movq %rdx, %rsp
20195 + subq $8, %rsp
20196 CFI_ADJUST_CFA_OFFSET 1*8
20197 leaq -10*8(%rsp), %rdx
20198 pushq_cfi $__KERNEL_DS
20199 pushq_cfi %rdx
20200 pushfq_cfi
20201 - pushq_cfi $__KERNEL_CS
20202 + pushq_cfi 6*8(%rsp)
20203 pushq_cfi $repeat_nmi
20204
20205 /* Put stack back */
20206 @@ -1731,6 +2120,7 @@ nested_nmi_out:
20207 CFI_RESTORE rdx
20208
20209 /* No need to check faults here */
20210 + pax_force_retaddr_bts
20211 INTERRUPT_RETURN
20212
20213 CFI_RESTORE_STATE
20214 @@ -1847,6 +2237,17 @@ end_repeat_nmi:
20215 */
20216 movq %cr2, %r12
20217
20218 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20219 + testb $3, CS(%rsp)
20220 + jnz 1f
20221 + pax_enter_kernel
20222 + jmp 2f
20223 +1: pax_enter_kernel_user
20224 +2:
20225 +#else
20226 + pax_enter_kernel
20227 +#endif
20228 +
20229 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20230 movq %rsp,%rdi
20231 movq $-1,%rsi
20232 @@ -1862,23 +2263,34 @@ end_repeat_nmi:
20233 testl %ebx,%ebx /* swapgs needed? */
20234 jnz nmi_restore
20235 nmi_swapgs:
20236 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20237 + pax_exit_kernel_user
20238 +#else
20239 + pax_exit_kernel
20240 +#endif
20241 SWAPGS_UNSAFE_STACK
20242 + RESTORE_ALL 6*8
20243 + /* Clear the NMI executing stack variable */
20244 + movq $0, 5*8(%rsp)
20245 + jmp irq_return
20246 nmi_restore:
20247 + pax_exit_kernel
20248 /* Pop the extra iret frame at once */
20249 RESTORE_ALL 6*8
20250 + pax_force_retaddr_bts
20251
20252 /* Clear the NMI executing stack variable */
20253 movq $0, 5*8(%rsp)
20254 jmp irq_return
20255 CFI_ENDPROC
20256 -END(nmi)
20257 +ENDPROC(nmi)
20258
20259 ENTRY(ignore_sysret)
20260 CFI_STARTPROC
20261 mov $-ENOSYS,%eax
20262 sysret
20263 CFI_ENDPROC
20264 -END(ignore_sysret)
20265 +ENDPROC(ignore_sysret)
20266
20267 /*
20268 * End of kprobes section
20269 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20270 index 1d41402..af9a46a 100644
20271 --- a/arch/x86/kernel/ftrace.c
20272 +++ b/arch/x86/kernel/ftrace.c
20273 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20274 {
20275 unsigned char replaced[MCOUNT_INSN_SIZE];
20276
20277 + ip = ktla_ktva(ip);
20278 +
20279 /*
20280 * Note: Due to modules and __init, code can
20281 * disappear and change, we need to protect against faulting
20282 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20283 unsigned char old[MCOUNT_INSN_SIZE], *new;
20284 int ret;
20285
20286 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20287 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20288 new = ftrace_call_replace(ip, (unsigned long)func);
20289
20290 /* See comment above by declaration of modifying_ftrace_code */
20291 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20292 /* Also update the regs callback function */
20293 if (!ret) {
20294 ip = (unsigned long)(&ftrace_regs_call);
20295 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20296 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20297 new = ftrace_call_replace(ip, (unsigned long)func);
20298 ret = ftrace_modify_code(ip, old, new);
20299 }
20300 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20301 * kernel identity mapping to modify code.
20302 */
20303 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20304 - ip = (unsigned long)__va(__pa(ip));
20305 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
20306
20307 return probe_kernel_write((void *)ip, val, size);
20308 }
20309 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20310 unsigned char replaced[MCOUNT_INSN_SIZE];
20311 unsigned char brk = BREAKPOINT_INSTRUCTION;
20312
20313 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20314 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20315 return -EFAULT;
20316
20317 /* Make sure it is what we expect it to be */
20318 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20319 return ret;
20320
20321 fail_update:
20322 - probe_kernel_write((void *)ip, &old_code[0], 1);
20323 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20324 goto out;
20325 }
20326
20327 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20328 {
20329 unsigned char code[MCOUNT_INSN_SIZE];
20330
20331 + ip = ktla_ktva(ip);
20332 +
20333 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20334 return -EFAULT;
20335
20336 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
20337 index c18f59d..9c0c9f6 100644
20338 --- a/arch/x86/kernel/head32.c
20339 +++ b/arch/x86/kernel/head32.c
20340 @@ -18,6 +18,7 @@
20341 #include <asm/io_apic.h>
20342 #include <asm/bios_ebda.h>
20343 #include <asm/tlbflush.h>
20344 +#include <asm/boot.h>
20345
20346 static void __init i386_default_early_setup(void)
20347 {
20348 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
20349
20350 void __init i386_start_kernel(void)
20351 {
20352 - memblock_reserve(__pa_symbol(&_text),
20353 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
20354 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
20355
20356 #ifdef CONFIG_BLK_DEV_INITRD
20357 /* Reserve INITRD */
20358 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20359 index c8932c7..d56b622 100644
20360 --- a/arch/x86/kernel/head_32.S
20361 +++ b/arch/x86/kernel/head_32.S
20362 @@ -26,6 +26,12 @@
20363 /* Physical address */
20364 #define pa(X) ((X) - __PAGE_OFFSET)
20365
20366 +#ifdef CONFIG_PAX_KERNEXEC
20367 +#define ta(X) (X)
20368 +#else
20369 +#define ta(X) ((X) - __PAGE_OFFSET)
20370 +#endif
20371 +
20372 /*
20373 * References to members of the new_cpu_data structure.
20374 */
20375 @@ -55,11 +61,7 @@
20376 * and small than max_low_pfn, otherwise will waste some page table entries
20377 */
20378
20379 -#if PTRS_PER_PMD > 1
20380 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20381 -#else
20382 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20383 -#endif
20384 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20385
20386 /* Number of possible pages in the lowmem region */
20387 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20388 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20389 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20390
20391 /*
20392 + * Real beginning of normal "text" segment
20393 + */
20394 +ENTRY(stext)
20395 +ENTRY(_stext)
20396 +
20397 +/*
20398 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20399 * %esi points to the real-mode code as a 32-bit pointer.
20400 * CS and DS must be 4 GB flat segments, but we don't depend on
20401 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20402 * can.
20403 */
20404 __HEAD
20405 +
20406 +#ifdef CONFIG_PAX_KERNEXEC
20407 + jmp startup_32
20408 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20409 +.fill PAGE_SIZE-5,1,0xcc
20410 +#endif
20411 +
20412 ENTRY(startup_32)
20413 movl pa(stack_start),%ecx
20414
20415 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20416 2:
20417 leal -__PAGE_OFFSET(%ecx),%esp
20418
20419 +#ifdef CONFIG_SMP
20420 + movl $pa(cpu_gdt_table),%edi
20421 + movl $__per_cpu_load,%eax
20422 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20423 + rorl $16,%eax
20424 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20425 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20426 + movl $__per_cpu_end - 1,%eax
20427 + subl $__per_cpu_start,%eax
20428 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20429 +#endif
20430 +
20431 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20432 + movl $NR_CPUS,%ecx
20433 + movl $pa(cpu_gdt_table),%edi
20434 +1:
20435 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20436 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20437 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20438 + addl $PAGE_SIZE_asm,%edi
20439 + loop 1b
20440 +#endif
20441 +
20442 +#ifdef CONFIG_PAX_KERNEXEC
20443 + movl $pa(boot_gdt),%edi
20444 + movl $__LOAD_PHYSICAL_ADDR,%eax
20445 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20446 + rorl $16,%eax
20447 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20448 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20449 + rorl $16,%eax
20450 +
20451 + ljmp $(__BOOT_CS),$1f
20452 +1:
20453 +
20454 + movl $NR_CPUS,%ecx
20455 + movl $pa(cpu_gdt_table),%edi
20456 + addl $__PAGE_OFFSET,%eax
20457 +1:
20458 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20459 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20460 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20461 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20462 + rorl $16,%eax
20463 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20464 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20465 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20466 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20467 + rorl $16,%eax
20468 + addl $PAGE_SIZE_asm,%edi
20469 + loop 1b
20470 +#endif
20471 +
20472 /*
20473 * Clear BSS first so that there are no surprises...
20474 */
20475 @@ -196,8 +264,11 @@ ENTRY(startup_32)
20476 movl %eax, pa(max_pfn_mapped)
20477
20478 /* Do early initialization of the fixmap area */
20479 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20480 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20481 +#ifdef CONFIG_COMPAT_VDSO
20482 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20483 +#else
20484 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20485 +#endif
20486 #else /* Not PAE */
20487
20488 page_pde_offset = (__PAGE_OFFSET >> 20);
20489 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20490 movl %eax, pa(max_pfn_mapped)
20491
20492 /* Do early initialization of the fixmap area */
20493 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20494 - movl %eax,pa(initial_page_table+0xffc)
20495 +#ifdef CONFIG_COMPAT_VDSO
20496 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20497 +#else
20498 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20499 +#endif
20500 #endif
20501
20502 #ifdef CONFIG_PARAVIRT
20503 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20504 cmpl $num_subarch_entries, %eax
20505 jae bad_subarch
20506
20507 - movl pa(subarch_entries)(,%eax,4), %eax
20508 - subl $__PAGE_OFFSET, %eax
20509 - jmp *%eax
20510 + jmp *pa(subarch_entries)(,%eax,4)
20511
20512 bad_subarch:
20513 WEAK(lguest_entry)
20514 @@ -256,10 +328,10 @@ WEAK(xen_entry)
20515 __INITDATA
20516
20517 subarch_entries:
20518 - .long default_entry /* normal x86/PC */
20519 - .long lguest_entry /* lguest hypervisor */
20520 - .long xen_entry /* Xen hypervisor */
20521 - .long default_entry /* Moorestown MID */
20522 + .long ta(default_entry) /* normal x86/PC */
20523 + .long ta(lguest_entry) /* lguest hypervisor */
20524 + .long ta(xen_entry) /* Xen hypervisor */
20525 + .long ta(default_entry) /* Moorestown MID */
20526 num_subarch_entries = (. - subarch_entries) / 4
20527 .previous
20528 #else
20529 @@ -335,6 +407,7 @@ default_entry:
20530 movl pa(mmu_cr4_features),%eax
20531 movl %eax,%cr4
20532
20533 +#ifdef CONFIG_X86_PAE
20534 testb $X86_CR4_PAE, %al # check if PAE is enabled
20535 jz 6f
20536
20537 @@ -363,6 +436,9 @@ default_entry:
20538 /* Make changes effective */
20539 wrmsr
20540
20541 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20542 +#endif
20543 +
20544 6:
20545
20546 /*
20547 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
20548 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20549 movl %eax,%ss # after changing gdt.
20550
20551 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20552 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20553 movl %eax,%ds
20554 movl %eax,%es
20555
20556 movl $(__KERNEL_PERCPU), %eax
20557 movl %eax,%fs # set this cpu's percpu
20558
20559 +#ifdef CONFIG_CC_STACKPROTECTOR
20560 movl $(__KERNEL_STACK_CANARY),%eax
20561 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20562 + movl $(__USER_DS),%eax
20563 +#else
20564 + xorl %eax,%eax
20565 +#endif
20566 movl %eax,%gs
20567
20568 xorl %eax,%eax # Clear LDT
20569 @@ -544,8 +626,11 @@ setup_once:
20570 * relocation. Manually set base address in stack canary
20571 * segment descriptor.
20572 */
20573 - movl $gdt_page,%eax
20574 + movl $cpu_gdt_table,%eax
20575 movl $stack_canary,%ecx
20576 +#ifdef CONFIG_SMP
20577 + addl $__per_cpu_load,%ecx
20578 +#endif
20579 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20580 shrl $16, %ecx
20581 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20582 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
20583 /* This is global to keep gas from relaxing the jumps */
20584 ENTRY(early_idt_handler)
20585 cld
20586 - cmpl $2,%ss:early_recursion_flag
20587 + cmpl $1,%ss:early_recursion_flag
20588 je hlt_loop
20589 incl %ss:early_recursion_flag
20590
20591 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
20592 pushl (20+6*4)(%esp) /* trapno */
20593 pushl $fault_msg
20594 call printk
20595 -#endif
20596 call dump_stack
20597 +#endif
20598 hlt_loop:
20599 hlt
20600 jmp hlt_loop
20601 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
20602 /* This is the default interrupt "handler" :-) */
20603 ALIGN
20604 ignore_int:
20605 - cld
20606 #ifdef CONFIG_PRINTK
20607 + cmpl $2,%ss:early_recursion_flag
20608 + je hlt_loop
20609 + incl %ss:early_recursion_flag
20610 + cld
20611 pushl %eax
20612 pushl %ecx
20613 pushl %edx
20614 @@ -644,9 +732,6 @@ ignore_int:
20615 movl $(__KERNEL_DS),%eax
20616 movl %eax,%ds
20617 movl %eax,%es
20618 - cmpl $2,early_recursion_flag
20619 - je hlt_loop
20620 - incl early_recursion_flag
20621 pushl 16(%esp)
20622 pushl 24(%esp)
20623 pushl 32(%esp)
20624 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
20625 /*
20626 * BSS section
20627 */
20628 -__PAGE_ALIGNED_BSS
20629 - .align PAGE_SIZE
20630 #ifdef CONFIG_X86_PAE
20631 +.section .initial_pg_pmd,"a",@progbits
20632 initial_pg_pmd:
20633 .fill 1024*KPMDS,4,0
20634 #else
20635 +.section .initial_page_table,"a",@progbits
20636 ENTRY(initial_page_table)
20637 .fill 1024,4,0
20638 #endif
20639 +.section .initial_pg_fixmap,"a",@progbits
20640 initial_pg_fixmap:
20641 .fill 1024,4,0
20642 +.section .empty_zero_page,"a",@progbits
20643 ENTRY(empty_zero_page)
20644 .fill 4096,1,0
20645 +.section .swapper_pg_dir,"a",@progbits
20646 ENTRY(swapper_pg_dir)
20647 +#ifdef CONFIG_X86_PAE
20648 + .fill 4,8,0
20649 +#else
20650 .fill 1024,4,0
20651 +#endif
20652 +
20653 +/*
20654 + * The IDT has to be page-aligned to simplify the Pentium
20655 + * F0 0F bug workaround.. We have a special link segment
20656 + * for this.
20657 + */
20658 +.section .idt,"a",@progbits
20659 +ENTRY(idt_table)
20660 + .fill 256,8,0
20661
20662 /*
20663 * This starts the data section.
20664 */
20665 #ifdef CONFIG_X86_PAE
20666 -__PAGE_ALIGNED_DATA
20667 - /* Page-aligned for the benefit of paravirt? */
20668 - .align PAGE_SIZE
20669 +.section .initial_page_table,"a",@progbits
20670 ENTRY(initial_page_table)
20671 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20672 # if KPMDS == 3
20673 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
20674 # error "Kernel PMDs should be 1, 2 or 3"
20675 # endif
20676 .align PAGE_SIZE /* needs to be page-sized too */
20677 +
20678 +#ifdef CONFIG_PAX_PER_CPU_PGD
20679 +ENTRY(cpu_pgd)
20680 + .rept NR_CPUS
20681 + .fill 4,8,0
20682 + .endr
20683 +#endif
20684 +
20685 #endif
20686
20687 .data
20688 .balign 4
20689 ENTRY(stack_start)
20690 - .long init_thread_union+THREAD_SIZE
20691 + .long init_thread_union+THREAD_SIZE-8
20692
20693 __INITRODATA
20694 int_msg:
20695 @@ -754,7 +861,7 @@ fault_msg:
20696 * segment size, and 32-bit linear address value:
20697 */
20698
20699 - .data
20700 +.section .rodata,"a",@progbits
20701 .globl boot_gdt_descr
20702 .globl idt_descr
20703
20704 @@ -763,7 +870,7 @@ fault_msg:
20705 .word 0 # 32 bit align gdt_desc.address
20706 boot_gdt_descr:
20707 .word __BOOT_DS+7
20708 - .long boot_gdt - __PAGE_OFFSET
20709 + .long pa(boot_gdt)
20710
20711 .word 0 # 32-bit align idt_desc.address
20712 idt_descr:
20713 @@ -774,7 +881,7 @@ idt_descr:
20714 .word 0 # 32 bit align gdt_desc.address
20715 ENTRY(early_gdt_descr)
20716 .word GDT_ENTRIES*8-1
20717 - .long gdt_page /* Overwritten for secondary CPUs */
20718 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20719
20720 /*
20721 * The boot_gdt must mirror the equivalent in setup.S and is
20722 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
20723 .align L1_CACHE_BYTES
20724 ENTRY(boot_gdt)
20725 .fill GDT_ENTRY_BOOT_CS,8,0
20726 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20727 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20728 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20729 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20730 +
20731 + .align PAGE_SIZE_asm
20732 +ENTRY(cpu_gdt_table)
20733 + .rept NR_CPUS
20734 + .quad 0x0000000000000000 /* NULL descriptor */
20735 + .quad 0x0000000000000000 /* 0x0b reserved */
20736 + .quad 0x0000000000000000 /* 0x13 reserved */
20737 + .quad 0x0000000000000000 /* 0x1b reserved */
20738 +
20739 +#ifdef CONFIG_PAX_KERNEXEC
20740 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20741 +#else
20742 + .quad 0x0000000000000000 /* 0x20 unused */
20743 +#endif
20744 +
20745 + .quad 0x0000000000000000 /* 0x28 unused */
20746 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20747 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20748 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20749 + .quad 0x0000000000000000 /* 0x4b reserved */
20750 + .quad 0x0000000000000000 /* 0x53 reserved */
20751 + .quad 0x0000000000000000 /* 0x5b reserved */
20752 +
20753 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20754 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20755 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20756 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20757 +
20758 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20759 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20760 +
20761 + /*
20762 + * Segments used for calling PnP BIOS have byte granularity.
20763 + * The code segments and data segments have fixed 64k limits,
20764 + * the transfer segment sizes are set at run time.
20765 + */
20766 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20767 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20768 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20769 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20770 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20771 +
20772 + /*
20773 + * The APM segments have byte granularity and their bases
20774 + * are set at run time. All have 64k limits.
20775 + */
20776 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20777 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20778 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20779 +
20780 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20781 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20782 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20783 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20784 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20785 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20786 +
20787 + /* Be sure this is zeroed to avoid false validations in Xen */
20788 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20789 + .endr
20790 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20791 index 980053c..74d3b44 100644
20792 --- a/arch/x86/kernel/head_64.S
20793 +++ b/arch/x86/kernel/head_64.S
20794 @@ -20,6 +20,8 @@
20795 #include <asm/processor-flags.h>
20796 #include <asm/percpu.h>
20797 #include <asm/nops.h>
20798 +#include <asm/cpufeature.h>
20799 +#include <asm/alternative-asm.h>
20800
20801 #ifdef CONFIG_PARAVIRT
20802 #include <asm/asm-offsets.h>
20803 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20804 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20805 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20806 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20807 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20808 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20809 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20810 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20811 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20812 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20813
20814 .text
20815 __HEAD
20816 @@ -88,35 +96,23 @@ startup_64:
20817 */
20818 addq %rbp, init_level4_pgt + 0(%rip)
20819 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20820 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20821 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20822 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20823 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20824
20825 addq %rbp, level3_ident_pgt + 0(%rip)
20826 +#ifndef CONFIG_XEN
20827 + addq %rbp, level3_ident_pgt + 8(%rip)
20828 +#endif
20829
20830 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20831 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20832 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20833 +
20834 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20835 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
20836
20837 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20838 -
20839 - /* Add an Identity mapping if I am above 1G */
20840 - leaq _text(%rip), %rdi
20841 - andq $PMD_PAGE_MASK, %rdi
20842 -
20843 - movq %rdi, %rax
20844 - shrq $PUD_SHIFT, %rax
20845 - andq $(PTRS_PER_PUD - 1), %rax
20846 - jz ident_complete
20847 -
20848 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
20849 - leaq level3_ident_pgt(%rip), %rbx
20850 - movq %rdx, 0(%rbx, %rax, 8)
20851 -
20852 - movq %rdi, %rax
20853 - shrq $PMD_SHIFT, %rax
20854 - andq $(PTRS_PER_PMD - 1), %rax
20855 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
20856 - leaq level2_spare_pgt(%rip), %rbx
20857 - movq %rdx, 0(%rbx, %rax, 8)
20858 -ident_complete:
20859 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20860
20861 /*
20862 * Fixup the kernel text+data virtual addresses. Note that
20863 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
20864 * after the boot processor executes this code.
20865 */
20866
20867 - /* Enable PAE mode and PGE */
20868 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
20869 + /* Enable PAE mode and PSE/PGE */
20870 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
20871 movq %rax, %cr4
20872
20873 /* Setup early boot stage 4 level pagetables. */
20874 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
20875 movl $MSR_EFER, %ecx
20876 rdmsr
20877 btsl $_EFER_SCE, %eax /* Enable System Call */
20878 - btl $20,%edi /* No Execute supported? */
20879 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20880 jnc 1f
20881 btsl $_EFER_NX, %eax
20882 + leaq init_level4_pgt(%rip), %rdi
20883 +#ifndef CONFIG_EFI
20884 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20885 +#endif
20886 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20887 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20888 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20889 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20890 1: wrmsr /* Make changes effective */
20891
20892 /* Setup cr0 */
20893 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
20894 * jump. In addition we need to ensure %cs is set so we make this
20895 * a far return.
20896 */
20897 + pax_set_fptr_mask
20898 movq initial_code(%rip),%rax
20899 pushq $0 # fake return address to stop unwinder
20900 pushq $__KERNEL_CS # set correct cs
20901 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
20902 bad_address:
20903 jmp bad_address
20904
20905 - .section ".init.text","ax"
20906 + __INIT
20907 .globl early_idt_handlers
20908 early_idt_handlers:
20909 # 104(%rsp) %rflags
20910 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
20911 call dump_stack
20912 #ifdef CONFIG_KALLSYMS
20913 leaq early_idt_ripmsg(%rip),%rdi
20914 - movq 40(%rsp),%rsi # %rip again
20915 + movq 88(%rsp),%rsi # %rip again
20916 call __print_symbol
20917 #endif
20918 #endif /* EARLY_PRINTK */
20919 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
20920 addq $16,%rsp # drop vector number and error code
20921 decl early_recursion_flag(%rip)
20922 INTERRUPT_RETURN
20923 + .previous
20924
20925 + __INITDATA
20926 .balign 4
20927 early_recursion_flag:
20928 .long 0
20929 + .previous
20930
20931 + .section .rodata,"a",@progbits
20932 #ifdef CONFIG_EARLY_PRINTK
20933 early_idt_msg:
20934 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20935 @@ -376,6 +385,7 @@ early_idt_ripmsg:
20936 #endif /* CONFIG_EARLY_PRINTK */
20937 .previous
20938
20939 + .section .rodata,"a",@progbits
20940 #define NEXT_PAGE(name) \
20941 .balign PAGE_SIZE; \
20942 ENTRY(name)
20943 @@ -388,7 +398,6 @@ ENTRY(name)
20944 i = i + 1 ; \
20945 .endr
20946
20947 - .data
20948 /*
20949 * This default setting generates an ident mapping at address 0x100000
20950 * and a mapping for the kernel that precisely maps virtual address
20951 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
20952 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20953 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20954 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20955 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20956 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20957 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20958 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20959 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20960 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20961 .org init_level4_pgt + L4_START_KERNEL*8, 0
20962 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20963 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20964
20965 +#ifdef CONFIG_PAX_PER_CPU_PGD
20966 +NEXT_PAGE(cpu_pgd)
20967 + .rept NR_CPUS
20968 + .fill 512,8,0
20969 + .endr
20970 +#endif
20971 +
20972 NEXT_PAGE(level3_ident_pgt)
20973 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20974 +#ifdef CONFIG_XEN
20975 .fill 511,8,0
20976 +#else
20977 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20978 + .fill 510,8,0
20979 +#endif
20980 +
20981 +NEXT_PAGE(level3_vmalloc_start_pgt)
20982 + .fill 512,8,0
20983 +
20984 +NEXT_PAGE(level3_vmalloc_end_pgt)
20985 + .fill 512,8,0
20986 +
20987 +NEXT_PAGE(level3_vmemmap_pgt)
20988 + .fill L3_VMEMMAP_START,8,0
20989 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20990
20991 NEXT_PAGE(level3_kernel_pgt)
20992 .fill L3_START_KERNEL,8,0
20993 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
20994 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20995 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20996
20997 +NEXT_PAGE(level2_vmemmap_pgt)
20998 + .fill 512,8,0
20999 +
21000 NEXT_PAGE(level2_fixmap_pgt)
21001 - .fill 506,8,0
21002 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
21003 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
21004 - .fill 5,8,0
21005 + .fill 507,8,0
21006 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
21007 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
21008 + .fill 4,8,0
21009
21010 -NEXT_PAGE(level1_fixmap_pgt)
21011 +NEXT_PAGE(level1_vsyscall_pgt)
21012 .fill 512,8,0
21013
21014 -NEXT_PAGE(level2_ident_pgt)
21015 - /* Since I easily can, map the first 1G.
21016 + /* Since I easily can, map the first 2G.
21017 * Don't set NX because code runs from these pages.
21018 */
21019 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
21020 +NEXT_PAGE(level2_ident_pgt)
21021 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
21022
21023 NEXT_PAGE(level2_kernel_pgt)
21024 /*
21025 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
21026 * If you want to increase this then increase MODULES_VADDR
21027 * too.)
21028 */
21029 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
21030 - KERNEL_IMAGE_SIZE/PMD_SIZE)
21031 -
21032 -NEXT_PAGE(level2_spare_pgt)
21033 - .fill 512, 8, 0
21034 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
21035
21036 #undef PMDS
21037 #undef NEXT_PAGE
21038
21039 - .data
21040 + .align PAGE_SIZE
21041 +ENTRY(cpu_gdt_table)
21042 + .rept NR_CPUS
21043 + .quad 0x0000000000000000 /* NULL descriptor */
21044 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
21045 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
21046 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
21047 + .quad 0x00cffb000000ffff /* __USER32_CS */
21048 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
21049 + .quad 0x00affb000000ffff /* __USER_CS */
21050 +
21051 +#ifdef CONFIG_PAX_KERNEXEC
21052 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
21053 +#else
21054 + .quad 0x0 /* unused */
21055 +#endif
21056 +
21057 + .quad 0,0 /* TSS */
21058 + .quad 0,0 /* LDT */
21059 + .quad 0,0,0 /* three TLS descriptors */
21060 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
21061 + /* asm/segment.h:GDT_ENTRIES must match this */
21062 +
21063 + /* zero the remaining page */
21064 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
21065 + .endr
21066 +
21067 .align 16
21068 .globl early_gdt_descr
21069 early_gdt_descr:
21070 .word GDT_ENTRIES*8-1
21071 early_gdt_descr_base:
21072 - .quad INIT_PER_CPU_VAR(gdt_page)
21073 + .quad cpu_gdt_table
21074
21075 ENTRY(phys_base)
21076 /* This must match the first entry in level2_kernel_pgt */
21077 .quad 0x0000000000000000
21078
21079 #include "../../x86/xen/xen-head.S"
21080 -
21081 - .section .bss, "aw", @nobits
21082 +
21083 + .section .rodata,"a",@progbits
21084 .align L1_CACHE_BYTES
21085 ENTRY(idt_table)
21086 - .skip IDT_ENTRIES * 16
21087 + .fill 512,8,0
21088
21089 .align L1_CACHE_BYTES
21090 ENTRY(nmi_idt_table)
21091 - .skip IDT_ENTRIES * 16
21092 + .fill 512,8,0
21093
21094 __PAGE_ALIGNED_BSS
21095 .align PAGE_SIZE
21096 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
21097 index 9c3bd4a..e1d9b35 100644
21098 --- a/arch/x86/kernel/i386_ksyms_32.c
21099 +++ b/arch/x86/kernel/i386_ksyms_32.c
21100 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
21101 EXPORT_SYMBOL(cmpxchg8b_emu);
21102 #endif
21103
21104 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
21105 +
21106 /* Networking helper routines. */
21107 EXPORT_SYMBOL(csum_partial_copy_generic);
21108 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
21109 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
21110
21111 EXPORT_SYMBOL(__get_user_1);
21112 EXPORT_SYMBOL(__get_user_2);
21113 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
21114
21115 EXPORT_SYMBOL(csum_partial);
21116 EXPORT_SYMBOL(empty_zero_page);
21117 +
21118 +#ifdef CONFIG_PAX_KERNEXEC
21119 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
21120 +#endif
21121 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
21122 index 245a71d..89d9ce4 100644
21123 --- a/arch/x86/kernel/i387.c
21124 +++ b/arch/x86/kernel/i387.c
21125 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
21126 static inline bool interrupted_user_mode(void)
21127 {
21128 struct pt_regs *regs = get_irq_regs();
21129 - return regs && user_mode_vm(regs);
21130 + return regs && user_mode(regs);
21131 }
21132
21133 /*
21134 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
21135 index 9a5c460..b332a4b 100644
21136 --- a/arch/x86/kernel/i8259.c
21137 +++ b/arch/x86/kernel/i8259.c
21138 @@ -209,7 +209,7 @@ spurious_8259A_irq:
21139 "spurious 8259A interrupt: IRQ%d.\n", irq);
21140 spurious_irq_mask |= irqmask;
21141 }
21142 - atomic_inc(&irq_err_count);
21143 + atomic_inc_unchecked(&irq_err_count);
21144 /*
21145 * Theoretically we do not have to handle this IRQ,
21146 * but in Linux this does not cause problems and is
21147 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
21148 /* (slave's support for AEOI in flat mode is to be investigated) */
21149 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
21150
21151 + pax_open_kernel();
21152 if (auto_eoi)
21153 /*
21154 * In AEOI mode we just have to mask the interrupt
21155 * when acking.
21156 */
21157 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
21158 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
21159 else
21160 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21161 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21162 + pax_close_kernel();
21163
21164 udelay(100); /* wait for 8259A to initialize */
21165
21166 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
21167 index a979b5b..1d6db75 100644
21168 --- a/arch/x86/kernel/io_delay.c
21169 +++ b/arch/x86/kernel/io_delay.c
21170 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
21171 * Quirk table for systems that misbehave (lock up, etc.) if port
21172 * 0x80 is used:
21173 */
21174 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
21175 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
21176 {
21177 .callback = dmi_io_delay_0xed_port,
21178 .ident = "Compaq Presario V6000",
21179 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
21180 index 8c96897..be66bfa 100644
21181 --- a/arch/x86/kernel/ioport.c
21182 +++ b/arch/x86/kernel/ioport.c
21183 @@ -6,6 +6,7 @@
21184 #include <linux/sched.h>
21185 #include <linux/kernel.h>
21186 #include <linux/capability.h>
21187 +#include <linux/security.h>
21188 #include <linux/errno.h>
21189 #include <linux/types.h>
21190 #include <linux/ioport.h>
21191 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21192
21193 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
21194 return -EINVAL;
21195 +#ifdef CONFIG_GRKERNSEC_IO
21196 + if (turn_on && grsec_disable_privio) {
21197 + gr_handle_ioperm();
21198 + return -EPERM;
21199 + }
21200 +#endif
21201 if (turn_on && !capable(CAP_SYS_RAWIO))
21202 return -EPERM;
21203
21204 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21205 * because the ->io_bitmap_max value must match the bitmap
21206 * contents:
21207 */
21208 - tss = &per_cpu(init_tss, get_cpu());
21209 + tss = init_tss + get_cpu();
21210
21211 if (turn_on)
21212 bitmap_clear(t->io_bitmap_ptr, from, num);
21213 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
21214 return -EINVAL;
21215 /* Trying to gain more privileges? */
21216 if (level > old) {
21217 +#ifdef CONFIG_GRKERNSEC_IO
21218 + if (grsec_disable_privio) {
21219 + gr_handle_iopl();
21220 + return -EPERM;
21221 + }
21222 +#endif
21223 if (!capable(CAP_SYS_RAWIO))
21224 return -EPERM;
21225 }
21226 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21227 index e4595f1..ee3bfb8 100644
21228 --- a/arch/x86/kernel/irq.c
21229 +++ b/arch/x86/kernel/irq.c
21230 @@ -18,7 +18,7 @@
21231 #include <asm/mce.h>
21232 #include <asm/hw_irq.h>
21233
21234 -atomic_t irq_err_count;
21235 +atomic_unchecked_t irq_err_count;
21236
21237 /* Function pointer for generic interrupt vector handling */
21238 void (*x86_platform_ipi_callback)(void) = NULL;
21239 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21240 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21241 seq_printf(p, " Machine check polls\n");
21242 #endif
21243 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21244 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21245 #if defined(CONFIG_X86_IO_APIC)
21246 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21247 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21248 #endif
21249 return 0;
21250 }
21251 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21252
21253 u64 arch_irq_stat(void)
21254 {
21255 - u64 sum = atomic_read(&irq_err_count);
21256 + u64 sum = atomic_read_unchecked(&irq_err_count);
21257
21258 #ifdef CONFIG_X86_IO_APIC
21259 - sum += atomic_read(&irq_mis_count);
21260 + sum += atomic_read_unchecked(&irq_mis_count);
21261 #endif
21262 return sum;
21263 }
21264 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21265 index 344faf8..355f60d 100644
21266 --- a/arch/x86/kernel/irq_32.c
21267 +++ b/arch/x86/kernel/irq_32.c
21268 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21269 __asm__ __volatile__("andl %%esp,%0" :
21270 "=r" (sp) : "0" (THREAD_SIZE - 1));
21271
21272 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21273 + return sp < STACK_WARN;
21274 }
21275
21276 static void print_stack_overflow(void)
21277 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21278 * per-CPU IRQ handling contexts (thread information and stack)
21279 */
21280 union irq_ctx {
21281 - struct thread_info tinfo;
21282 - u32 stack[THREAD_SIZE/sizeof(u32)];
21283 + unsigned long previous_esp;
21284 + u32 stack[THREAD_SIZE/sizeof(u32)];
21285 } __attribute__((aligned(THREAD_SIZE)));
21286
21287 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21288 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21289 static inline int
21290 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21291 {
21292 - union irq_ctx *curctx, *irqctx;
21293 + union irq_ctx *irqctx;
21294 u32 *isp, arg1, arg2;
21295
21296 - curctx = (union irq_ctx *) current_thread_info();
21297 irqctx = __this_cpu_read(hardirq_ctx);
21298
21299 /*
21300 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21301 * handler) we can't do that and just have to keep using the
21302 * current stack (which is the irq stack already after all)
21303 */
21304 - if (unlikely(curctx == irqctx))
21305 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21306 return 0;
21307
21308 /* build the stack frame on the IRQ stack */
21309 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21310 - irqctx->tinfo.task = curctx->tinfo.task;
21311 - irqctx->tinfo.previous_esp = current_stack_pointer;
21312 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21313 + irqctx->previous_esp = current_stack_pointer;
21314
21315 - /* Copy the preempt_count so that the [soft]irq checks work. */
21316 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21317 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21318 + __set_fs(MAKE_MM_SEG(0));
21319 +#endif
21320
21321 if (unlikely(overflow))
21322 call_on_stack(print_stack_overflow, isp);
21323 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21324 : "0" (irq), "1" (desc), "2" (isp),
21325 "D" (desc->handle_irq)
21326 : "memory", "cc", "ecx");
21327 +
21328 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21329 + __set_fs(current_thread_info()->addr_limit);
21330 +#endif
21331 +
21332 return 1;
21333 }
21334
21335 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21336 */
21337 void __cpuinit irq_ctx_init(int cpu)
21338 {
21339 - union irq_ctx *irqctx;
21340 -
21341 if (per_cpu(hardirq_ctx, cpu))
21342 return;
21343
21344 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21345 - THREADINFO_GFP,
21346 - THREAD_SIZE_ORDER));
21347 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21348 - irqctx->tinfo.cpu = cpu;
21349 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21350 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21351 -
21352 - per_cpu(hardirq_ctx, cpu) = irqctx;
21353 -
21354 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21355 - THREADINFO_GFP,
21356 - THREAD_SIZE_ORDER));
21357 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21358 - irqctx->tinfo.cpu = cpu;
21359 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21360 -
21361 - per_cpu(softirq_ctx, cpu) = irqctx;
21362 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21363 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21364 +
21365 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21366 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21367
21368 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21369 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21370 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21371 asmlinkage void do_softirq(void)
21372 {
21373 unsigned long flags;
21374 - struct thread_info *curctx;
21375 union irq_ctx *irqctx;
21376 u32 *isp;
21377
21378 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21379 local_irq_save(flags);
21380
21381 if (local_softirq_pending()) {
21382 - curctx = current_thread_info();
21383 irqctx = __this_cpu_read(softirq_ctx);
21384 - irqctx->tinfo.task = curctx->task;
21385 - irqctx->tinfo.previous_esp = current_stack_pointer;
21386 + irqctx->previous_esp = current_stack_pointer;
21387
21388 /* build the stack frame on the softirq stack */
21389 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21390 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21391 +
21392 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21393 + __set_fs(MAKE_MM_SEG(0));
21394 +#endif
21395
21396 call_on_stack(__do_softirq, isp);
21397 +
21398 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21399 + __set_fs(current_thread_info()->addr_limit);
21400 +#endif
21401 +
21402 /*
21403 * Shouldn't happen, we returned above if in_interrupt():
21404 */
21405 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21406 if (unlikely(!desc))
21407 return false;
21408
21409 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21410 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21411 if (unlikely(overflow))
21412 print_stack_overflow();
21413 desc->handle_irq(irq, desc);
21414 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21415 index d04d3ec..ea4b374 100644
21416 --- a/arch/x86/kernel/irq_64.c
21417 +++ b/arch/x86/kernel/irq_64.c
21418 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21419 u64 estack_top, estack_bottom;
21420 u64 curbase = (u64)task_stack_page(current);
21421
21422 - if (user_mode_vm(regs))
21423 + if (user_mode(regs))
21424 return;
21425
21426 if (regs->sp >= curbase + sizeof(struct thread_info) +
21427 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21428 index dc1404b..bbc43e7 100644
21429 --- a/arch/x86/kernel/kdebugfs.c
21430 +++ b/arch/x86/kernel/kdebugfs.c
21431 @@ -27,7 +27,7 @@ struct setup_data_node {
21432 u32 len;
21433 };
21434
21435 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21436 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21437 size_t count, loff_t *ppos)
21438 {
21439 struct setup_data_node *node = file->private_data;
21440 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21441 index 836f832..a8bda67 100644
21442 --- a/arch/x86/kernel/kgdb.c
21443 +++ b/arch/x86/kernel/kgdb.c
21444 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21445 #ifdef CONFIG_X86_32
21446 switch (regno) {
21447 case GDB_SS:
21448 - if (!user_mode_vm(regs))
21449 + if (!user_mode(regs))
21450 *(unsigned long *)mem = __KERNEL_DS;
21451 break;
21452 case GDB_SP:
21453 - if (!user_mode_vm(regs))
21454 + if (!user_mode(regs))
21455 *(unsigned long *)mem = kernel_stack_pointer(regs);
21456 break;
21457 case GDB_GS:
21458 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21459 bp->attr.bp_addr = breakinfo[breakno].addr;
21460 bp->attr.bp_len = breakinfo[breakno].len;
21461 bp->attr.bp_type = breakinfo[breakno].type;
21462 - info->address = breakinfo[breakno].addr;
21463 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21464 + info->address = ktla_ktva(breakinfo[breakno].addr);
21465 + else
21466 + info->address = breakinfo[breakno].addr;
21467 info->len = breakinfo[breakno].len;
21468 info->type = breakinfo[breakno].type;
21469 val = arch_install_hw_breakpoint(bp);
21470 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21471 case 'k':
21472 /* clear the trace bit */
21473 linux_regs->flags &= ~X86_EFLAGS_TF;
21474 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21475 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21476
21477 /* set the trace bit if we're stepping */
21478 if (remcomInBuffer[0] == 's') {
21479 linux_regs->flags |= X86_EFLAGS_TF;
21480 - atomic_set(&kgdb_cpu_doing_single_step,
21481 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21482 raw_smp_processor_id());
21483 }
21484
21485 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21486
21487 switch (cmd) {
21488 case DIE_DEBUG:
21489 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21490 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21491 if (user_mode(regs))
21492 return single_step_cont(regs, args);
21493 break;
21494 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21495 #endif /* CONFIG_DEBUG_RODATA */
21496
21497 bpt->type = BP_BREAKPOINT;
21498 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21499 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21500 BREAK_INSTR_SIZE);
21501 if (err)
21502 return err;
21503 - err = probe_kernel_write((char *)bpt->bpt_addr,
21504 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21505 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21506 #ifdef CONFIG_DEBUG_RODATA
21507 if (!err)
21508 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21509 return -EBUSY;
21510 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21511 BREAK_INSTR_SIZE);
21512 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21513 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21514 if (err)
21515 return err;
21516 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21517 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21518 if (mutex_is_locked(&text_mutex))
21519 goto knl_write;
21520 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21521 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21522 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21523 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21524 goto knl_write;
21525 return err;
21526 knl_write:
21527 #endif /* CONFIG_DEBUG_RODATA */
21528 - return probe_kernel_write((char *)bpt->bpt_addr,
21529 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21530 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21531 }
21532
21533 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
21534 index c5e410e..ed5a7f0 100644
21535 --- a/arch/x86/kernel/kprobes-opt.c
21536 +++ b/arch/x86/kernel/kprobes-opt.c
21537 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21538 * Verify if the address gap is in 2GB range, because this uses
21539 * a relative jump.
21540 */
21541 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21542 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21543 if (abs(rel) > 0x7fffffff)
21544 return -ERANGE;
21545
21546 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21547 op->optinsn.size = ret;
21548
21549 /* Copy arch-dep-instance from template */
21550 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21551 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21552
21553 /* Set probe information */
21554 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21555
21556 /* Set probe function call */
21557 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21558 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21559
21560 /* Set returning jmp instruction at the tail of out-of-line buffer */
21561 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21562 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21563 (u8 *)op->kp.addr + op->optinsn.size);
21564
21565 flush_icache_range((unsigned long) buf,
21566 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21567 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21568
21569 /* Backup instructions which will be replaced by jump address */
21570 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21571 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21572 RELATIVE_ADDR_SIZE);
21573
21574 insn_buf[0] = RELATIVEJUMP_OPCODE;
21575 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21576 /* This kprobe is really able to run optimized path. */
21577 op = container_of(p, struct optimized_kprobe, kp);
21578 /* Detour through copied instructions */
21579 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21580 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21581 if (!reenter)
21582 reset_current_kprobe();
21583 preempt_enable_no_resched();
21584 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
21585 index 57916c0..9e0b9d0 100644
21586 --- a/arch/x86/kernel/kprobes.c
21587 +++ b/arch/x86/kernel/kprobes.c
21588 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21589 s32 raddr;
21590 } __attribute__((packed)) *insn;
21591
21592 - insn = (struct __arch_relative_insn *)from;
21593 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21594 +
21595 + pax_open_kernel();
21596 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21597 insn->op = op;
21598 + pax_close_kernel();
21599 }
21600
21601 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21602 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21603 kprobe_opcode_t opcode;
21604 kprobe_opcode_t *orig_opcodes = opcodes;
21605
21606 - if (search_exception_tables((unsigned long)opcodes))
21607 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21608 return 0; /* Page fault may occur on this address. */
21609
21610 retry:
21611 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21612 * for the first byte, we can recover the original instruction
21613 * from it and kp->opcode.
21614 */
21615 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21616 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21617 buf[0] = kp->opcode;
21618 - return (unsigned long)buf;
21619 + return ktva_ktla((unsigned long)buf);
21620 }
21621
21622 /*
21623 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21624 /* Another subsystem puts a breakpoint, failed to recover */
21625 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21626 return 0;
21627 + pax_open_kernel();
21628 memcpy(dest, insn.kaddr, insn.length);
21629 + pax_close_kernel();
21630
21631 #ifdef CONFIG_X86_64
21632 if (insn_rip_relative(&insn)) {
21633 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21634 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21635 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21636 disp = (u8 *) dest + insn_offset_displacement(&insn);
21637 + pax_open_kernel();
21638 *(s32 *) disp = (s32) newdisp;
21639 + pax_close_kernel();
21640 }
21641 #endif
21642 return insn.length;
21643 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21644 * nor set current_kprobe, because it doesn't use single
21645 * stepping.
21646 */
21647 - regs->ip = (unsigned long)p->ainsn.insn;
21648 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21649 preempt_enable_no_resched();
21650 return;
21651 }
21652 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21653 regs->flags &= ~X86_EFLAGS_IF;
21654 /* single step inline if the instruction is an int3 */
21655 if (p->opcode == BREAKPOINT_INSTRUCTION)
21656 - regs->ip = (unsigned long)p->addr;
21657 + regs->ip = ktla_ktva((unsigned long)p->addr);
21658 else
21659 - regs->ip = (unsigned long)p->ainsn.insn;
21660 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21661 }
21662
21663 /*
21664 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21665 setup_singlestep(p, regs, kcb, 0);
21666 return 1;
21667 }
21668 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21669 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21670 /*
21671 * The breakpoint instruction was removed right
21672 * after we hit it. Another cpu has removed
21673 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21674 " movq %rax, 152(%rsp)\n"
21675 RESTORE_REGS_STRING
21676 " popfq\n"
21677 +#ifdef KERNEXEC_PLUGIN
21678 + " btsq $63,(%rsp)\n"
21679 +#endif
21680 #else
21681 " pushf\n"
21682 SAVE_REGS_STRING
21683 @@ -788,7 +798,7 @@ static void __kprobes
21684 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21685 {
21686 unsigned long *tos = stack_addr(regs);
21687 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21688 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21689 unsigned long orig_ip = (unsigned long)p->addr;
21690 kprobe_opcode_t *insn = p->ainsn.insn;
21691
21692 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21693 struct die_args *args = data;
21694 int ret = NOTIFY_DONE;
21695
21696 - if (args->regs && user_mode_vm(args->regs))
21697 + if (args->regs && user_mode(args->regs))
21698 return ret;
21699
21700 switch (val) {
21701 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21702 index 9c2bd8b..bb1131c 100644
21703 --- a/arch/x86/kernel/kvm.c
21704 +++ b/arch/x86/kernel/kvm.c
21705 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21706 return NOTIFY_OK;
21707 }
21708
21709 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21710 +static struct notifier_block kvm_cpu_notifier = {
21711 .notifier_call = kvm_cpu_notify,
21712 };
21713 #endif
21714 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21715 index ebc9873..1b9724b 100644
21716 --- a/arch/x86/kernel/ldt.c
21717 +++ b/arch/x86/kernel/ldt.c
21718 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21719 if (reload) {
21720 #ifdef CONFIG_SMP
21721 preempt_disable();
21722 - load_LDT(pc);
21723 + load_LDT_nolock(pc);
21724 if (!cpumask_equal(mm_cpumask(current->mm),
21725 cpumask_of(smp_processor_id())))
21726 smp_call_function(flush_ldt, current->mm, 1);
21727 preempt_enable();
21728 #else
21729 - load_LDT(pc);
21730 + load_LDT_nolock(pc);
21731 #endif
21732 }
21733 if (oldsize) {
21734 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21735 return err;
21736
21737 for (i = 0; i < old->size; i++)
21738 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21739 + write_ldt_entry(new->ldt, i, old->ldt + i);
21740 return 0;
21741 }
21742
21743 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21744 retval = copy_ldt(&mm->context, &old_mm->context);
21745 mutex_unlock(&old_mm->context.lock);
21746 }
21747 +
21748 + if (tsk == current) {
21749 + mm->context.vdso = 0;
21750 +
21751 +#ifdef CONFIG_X86_32
21752 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21753 + mm->context.user_cs_base = 0UL;
21754 + mm->context.user_cs_limit = ~0UL;
21755 +
21756 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21757 + cpus_clear(mm->context.cpu_user_cs_mask);
21758 +#endif
21759 +
21760 +#endif
21761 +#endif
21762 +
21763 + }
21764 +
21765 return retval;
21766 }
21767
21768 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21769 }
21770 }
21771
21772 +#ifdef CONFIG_PAX_SEGMEXEC
21773 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21774 + error = -EINVAL;
21775 + goto out_unlock;
21776 + }
21777 +#endif
21778 +
21779 fill_ldt(&ldt, &ldt_info);
21780 if (oldmode)
21781 ldt.avl = 0;
21782 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21783 index 5b19e4d..6476a76 100644
21784 --- a/arch/x86/kernel/machine_kexec_32.c
21785 +++ b/arch/x86/kernel/machine_kexec_32.c
21786 @@ -26,7 +26,7 @@
21787 #include <asm/cacheflush.h>
21788 #include <asm/debugreg.h>
21789
21790 -static void set_idt(void *newidt, __u16 limit)
21791 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21792 {
21793 struct desc_ptr curidt;
21794
21795 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21796 }
21797
21798
21799 -static void set_gdt(void *newgdt, __u16 limit)
21800 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21801 {
21802 struct desc_ptr curgdt;
21803
21804 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21805 }
21806
21807 control_page = page_address(image->control_code_page);
21808 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21809 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21810
21811 relocate_kernel_ptr = control_page;
21812 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21813 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21814 index 3a04b22..1d2eb09 100644
21815 --- a/arch/x86/kernel/microcode_core.c
21816 +++ b/arch/x86/kernel/microcode_core.c
21817 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21818 return NOTIFY_OK;
21819 }
21820
21821 -static struct notifier_block __refdata mc_cpu_notifier = {
21822 +static struct notifier_block mc_cpu_notifier = {
21823 .notifier_call = mc_cpu_callback,
21824 };
21825
21826 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21827 index 3544aed..01ddc1c 100644
21828 --- a/arch/x86/kernel/microcode_intel.c
21829 +++ b/arch/x86/kernel/microcode_intel.c
21830 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21831
21832 static int get_ucode_user(void *to, const void *from, size_t n)
21833 {
21834 - return copy_from_user(to, from, n);
21835 + return copy_from_user(to, (const void __force_user *)from, n);
21836 }
21837
21838 static enum ucode_state
21839 request_microcode_user(int cpu, const void __user *buf, size_t size)
21840 {
21841 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21842 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21843 }
21844
21845 static void microcode_fini_cpu(int cpu)
21846 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21847 index 216a4d7..228255a 100644
21848 --- a/arch/x86/kernel/module.c
21849 +++ b/arch/x86/kernel/module.c
21850 @@ -43,15 +43,60 @@ do { \
21851 } while (0)
21852 #endif
21853
21854 -void *module_alloc(unsigned long size)
21855 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21856 {
21857 - if (PAGE_ALIGN(size) > MODULES_LEN)
21858 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21859 return NULL;
21860 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21861 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21862 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21863 -1, __builtin_return_address(0));
21864 }
21865
21866 +void *module_alloc(unsigned long size)
21867 +{
21868 +
21869 +#ifdef CONFIG_PAX_KERNEXEC
21870 + return __module_alloc(size, PAGE_KERNEL);
21871 +#else
21872 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21873 +#endif
21874 +
21875 +}
21876 +
21877 +#ifdef CONFIG_PAX_KERNEXEC
21878 +#ifdef CONFIG_X86_32
21879 +void *module_alloc_exec(unsigned long size)
21880 +{
21881 + struct vm_struct *area;
21882 +
21883 + if (size == 0)
21884 + return NULL;
21885 +
21886 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21887 + return area ? area->addr : NULL;
21888 +}
21889 +EXPORT_SYMBOL(module_alloc_exec);
21890 +
21891 +void module_free_exec(struct module *mod, void *module_region)
21892 +{
21893 + vunmap(module_region);
21894 +}
21895 +EXPORT_SYMBOL(module_free_exec);
21896 +#else
21897 +void module_free_exec(struct module *mod, void *module_region)
21898 +{
21899 + module_free(mod, module_region);
21900 +}
21901 +EXPORT_SYMBOL(module_free_exec);
21902 +
21903 +void *module_alloc_exec(unsigned long size)
21904 +{
21905 + return __module_alloc(size, PAGE_KERNEL_RX);
21906 +}
21907 +EXPORT_SYMBOL(module_alloc_exec);
21908 +#endif
21909 +#endif
21910 +
21911 #ifdef CONFIG_X86_32
21912 int apply_relocate(Elf32_Shdr *sechdrs,
21913 const char *strtab,
21914 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21915 unsigned int i;
21916 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21917 Elf32_Sym *sym;
21918 - uint32_t *location;
21919 + uint32_t *plocation, location;
21920
21921 DEBUGP("Applying relocate section %u to %u\n",
21922 relsec, sechdrs[relsec].sh_info);
21923 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21924 /* This is where to make the change */
21925 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21926 - + rel[i].r_offset;
21927 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21928 + location = (uint32_t)plocation;
21929 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21930 + plocation = ktla_ktva((void *)plocation);
21931 /* This is the symbol it is referring to. Note that all
21932 undefined symbols have been resolved. */
21933 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21934 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21935 switch (ELF32_R_TYPE(rel[i].r_info)) {
21936 case R_386_32:
21937 /* We add the value into the location given */
21938 - *location += sym->st_value;
21939 + pax_open_kernel();
21940 + *plocation += sym->st_value;
21941 + pax_close_kernel();
21942 break;
21943 case R_386_PC32:
21944 /* Add the value, subtract its position */
21945 - *location += sym->st_value - (uint32_t)location;
21946 + pax_open_kernel();
21947 + *plocation += sym->st_value - location;
21948 + pax_close_kernel();
21949 break;
21950 default:
21951 pr_err("%s: Unknown relocation: %u\n",
21952 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21953 case R_X86_64_NONE:
21954 break;
21955 case R_X86_64_64:
21956 + pax_open_kernel();
21957 *(u64 *)loc = val;
21958 + pax_close_kernel();
21959 break;
21960 case R_X86_64_32:
21961 + pax_open_kernel();
21962 *(u32 *)loc = val;
21963 + pax_close_kernel();
21964 if (val != *(u32 *)loc)
21965 goto overflow;
21966 break;
21967 case R_X86_64_32S:
21968 + pax_open_kernel();
21969 *(s32 *)loc = val;
21970 + pax_close_kernel();
21971 if ((s64)val != *(s32 *)loc)
21972 goto overflow;
21973 break;
21974 case R_X86_64_PC32:
21975 val -= (u64)loc;
21976 + pax_open_kernel();
21977 *(u32 *)loc = val;
21978 + pax_close_kernel();
21979 +
21980 #if 0
21981 if ((s64)val != *(s32 *)loc)
21982 goto overflow;
21983 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21984 index 4929502..686c291 100644
21985 --- a/arch/x86/kernel/msr.c
21986 +++ b/arch/x86/kernel/msr.c
21987 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21988 return notifier_from_errno(err);
21989 }
21990
21991 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21992 +static struct notifier_block msr_class_cpu_notifier = {
21993 .notifier_call = msr_class_cpu_callback,
21994 };
21995
21996 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21997 index f84f5c5..f404e81 100644
21998 --- a/arch/x86/kernel/nmi.c
21999 +++ b/arch/x86/kernel/nmi.c
22000 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
22001 return handled;
22002 }
22003
22004 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22005 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
22006 {
22007 struct nmi_desc *desc = nmi_to_desc(type);
22008 unsigned long flags;
22009 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22010 * event confuses some handlers (kdump uses this flag)
22011 */
22012 if (action->flags & NMI_FLAG_FIRST)
22013 - list_add_rcu(&action->list, &desc->head);
22014 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
22015 else
22016 - list_add_tail_rcu(&action->list, &desc->head);
22017 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
22018
22019 spin_unlock_irqrestore(&desc->lock, flags);
22020 return 0;
22021 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
22022 if (!strcmp(n->name, name)) {
22023 WARN(in_nmi(),
22024 "Trying to free NMI (%s) from NMI context!\n", n->name);
22025 - list_del_rcu(&n->list);
22026 + pax_list_del_rcu((struct list_head *)&n->list);
22027 break;
22028 }
22029 }
22030 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
22031 dotraplinkage notrace __kprobes void
22032 do_nmi(struct pt_regs *regs, long error_code)
22033 {
22034 +
22035 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
22036 + if (!user_mode(regs)) {
22037 + unsigned long cs = regs->cs & 0xFFFF;
22038 + unsigned long ip = ktva_ktla(regs->ip);
22039 +
22040 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
22041 + regs->ip = ip;
22042 + }
22043 +#endif
22044 +
22045 nmi_nesting_preprocess(regs);
22046
22047 nmi_enter();
22048 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
22049 index 6d9582e..f746287 100644
22050 --- a/arch/x86/kernel/nmi_selftest.c
22051 +++ b/arch/x86/kernel/nmi_selftest.c
22052 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
22053 {
22054 /* trap all the unknown NMIs we may generate */
22055 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
22056 - __initdata);
22057 + __initconst);
22058 }
22059
22060 static void __init cleanup_nmi_testsuite(void)
22061 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
22062 unsigned long timeout;
22063
22064 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
22065 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
22066 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
22067 nmi_fail = FAILURE;
22068 return;
22069 }
22070 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
22071 index 676b8c7..870ba04 100644
22072 --- a/arch/x86/kernel/paravirt-spinlocks.c
22073 +++ b/arch/x86/kernel/paravirt-spinlocks.c
22074 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
22075 arch_spin_lock(lock);
22076 }
22077
22078 -struct pv_lock_ops pv_lock_ops = {
22079 +struct pv_lock_ops pv_lock_ops __read_only = {
22080 #ifdef CONFIG_SMP
22081 .spin_is_locked = __ticket_spin_is_locked,
22082 .spin_is_contended = __ticket_spin_is_contended,
22083 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
22084 index 8bfb335..c1463c6 100644
22085 --- a/arch/x86/kernel/paravirt.c
22086 +++ b/arch/x86/kernel/paravirt.c
22087 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
22088 {
22089 return x;
22090 }
22091 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22092 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
22093 +#endif
22094
22095 void __init default_banner(void)
22096 {
22097 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
22098 if (opfunc == NULL)
22099 /* If there's no function, patch it with a ud2a (BUG) */
22100 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
22101 - else if (opfunc == _paravirt_nop)
22102 + else if (opfunc == (void *)_paravirt_nop)
22103 /* If the operation is a nop, then nop the callsite */
22104 ret = paravirt_patch_nop();
22105
22106 /* identity functions just return their single argument */
22107 - else if (opfunc == _paravirt_ident_32)
22108 + else if (opfunc == (void *)_paravirt_ident_32)
22109 ret = paravirt_patch_ident_32(insnbuf, len);
22110 - else if (opfunc == _paravirt_ident_64)
22111 + else if (opfunc == (void *)_paravirt_ident_64)
22112 ret = paravirt_patch_ident_64(insnbuf, len);
22113 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22114 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
22115 + ret = paravirt_patch_ident_64(insnbuf, len);
22116 +#endif
22117
22118 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
22119 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
22120 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
22121 if (insn_len > len || start == NULL)
22122 insn_len = len;
22123 else
22124 - memcpy(insnbuf, start, insn_len);
22125 + memcpy(insnbuf, ktla_ktva(start), insn_len);
22126
22127 return insn_len;
22128 }
22129 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
22130 return this_cpu_read(paravirt_lazy_mode);
22131 }
22132
22133 -struct pv_info pv_info = {
22134 +struct pv_info pv_info __read_only = {
22135 .name = "bare hardware",
22136 .paravirt_enabled = 0,
22137 .kernel_rpl = 0,
22138 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
22139 #endif
22140 };
22141
22142 -struct pv_init_ops pv_init_ops = {
22143 +struct pv_init_ops pv_init_ops __read_only = {
22144 .patch = native_patch,
22145 };
22146
22147 -struct pv_time_ops pv_time_ops = {
22148 +struct pv_time_ops pv_time_ops __read_only = {
22149 .sched_clock = native_sched_clock,
22150 .steal_clock = native_steal_clock,
22151 };
22152
22153 -struct pv_irq_ops pv_irq_ops = {
22154 +struct pv_irq_ops pv_irq_ops __read_only = {
22155 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
22156 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
22157 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
22158 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
22159 #endif
22160 };
22161
22162 -struct pv_cpu_ops pv_cpu_ops = {
22163 +struct pv_cpu_ops pv_cpu_ops __read_only = {
22164 .cpuid = native_cpuid,
22165 .get_debugreg = native_get_debugreg,
22166 .set_debugreg = native_set_debugreg,
22167 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
22168 .end_context_switch = paravirt_nop,
22169 };
22170
22171 -struct pv_apic_ops pv_apic_ops = {
22172 +struct pv_apic_ops pv_apic_ops __read_only= {
22173 #ifdef CONFIG_X86_LOCAL_APIC
22174 .startup_ipi_hook = paravirt_nop,
22175 #endif
22176 };
22177
22178 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
22179 +#ifdef CONFIG_X86_32
22180 +#ifdef CONFIG_X86_PAE
22181 +/* 64-bit pagetable entries */
22182 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
22183 +#else
22184 /* 32-bit pagetable entries */
22185 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
22186 +#endif
22187 #else
22188 /* 64-bit pagetable entries */
22189 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
22190 #endif
22191
22192 -struct pv_mmu_ops pv_mmu_ops = {
22193 +struct pv_mmu_ops pv_mmu_ops __read_only = {
22194
22195 .read_cr2 = native_read_cr2,
22196 .write_cr2 = native_write_cr2,
22197 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
22198 .make_pud = PTE_IDENT,
22199
22200 .set_pgd = native_set_pgd,
22201 + .set_pgd_batched = native_set_pgd_batched,
22202 #endif
22203 #endif /* PAGETABLE_LEVELS >= 3 */
22204
22205 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
22206 },
22207
22208 .set_fixmap = native_set_fixmap,
22209 +
22210 +#ifdef CONFIG_PAX_KERNEXEC
22211 + .pax_open_kernel = native_pax_open_kernel,
22212 + .pax_close_kernel = native_pax_close_kernel,
22213 +#endif
22214 +
22215 };
22216
22217 EXPORT_SYMBOL_GPL(pv_time_ops);
22218 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22219 index 35ccf75..7a15747 100644
22220 --- a/arch/x86/kernel/pci-iommu_table.c
22221 +++ b/arch/x86/kernel/pci-iommu_table.c
22222 @@ -2,7 +2,7 @@
22223 #include <asm/iommu_table.h>
22224 #include <linux/string.h>
22225 #include <linux/kallsyms.h>
22226 -
22227 +#include <linux/sched.h>
22228
22229 #define DEBUG 1
22230
22231 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22232 index 6c483ba..d10ce2f 100644
22233 --- a/arch/x86/kernel/pci-swiotlb.c
22234 +++ b/arch/x86/kernel/pci-swiotlb.c
22235 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22236 void *vaddr, dma_addr_t dma_addr,
22237 struct dma_attrs *attrs)
22238 {
22239 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22240 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22241 }
22242
22243 static struct dma_map_ops swiotlb_dma_ops = {
22244 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22245 index 2ed787f..f70c9f6 100644
22246 --- a/arch/x86/kernel/process.c
22247 +++ b/arch/x86/kernel/process.c
22248 @@ -36,7 +36,8 @@
22249 * section. Since TSS's are completely CPU-local, we want them
22250 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22251 */
22252 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22253 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22254 +EXPORT_SYMBOL(init_tss);
22255
22256 #ifdef CONFIG_X86_64
22257 static DEFINE_PER_CPU(unsigned char, is_idle);
22258 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22259 task_xstate_cachep =
22260 kmem_cache_create("task_xstate", xstate_size,
22261 __alignof__(union thread_xstate),
22262 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22263 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22264 }
22265
22266 /*
22267 @@ -105,7 +106,7 @@ void exit_thread(void)
22268 unsigned long *bp = t->io_bitmap_ptr;
22269
22270 if (bp) {
22271 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22272 + struct tss_struct *tss = init_tss + get_cpu();
22273
22274 t->io_bitmap_ptr = NULL;
22275 clear_thread_flag(TIF_IO_BITMAP);
22276 @@ -136,7 +137,7 @@ void show_regs_common(void)
22277 board = dmi_get_system_info(DMI_BOARD_NAME);
22278
22279 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
22280 - current->pid, current->comm, print_tainted(),
22281 + task_pid_nr(current), current->comm, print_tainted(),
22282 init_utsname()->release,
22283 (int)strcspn(init_utsname()->version, " "),
22284 init_utsname()->version,
22285 @@ -149,6 +150,9 @@ void flush_thread(void)
22286 {
22287 struct task_struct *tsk = current;
22288
22289 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22290 + loadsegment(gs, 0);
22291 +#endif
22292 flush_ptrace_hw_breakpoint(tsk);
22293 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22294 drop_init_fpu(tsk);
22295 @@ -301,7 +305,7 @@ static void __exit_idle(void)
22296 void exit_idle(void)
22297 {
22298 /* idle loop has pid 0 */
22299 - if (current->pid)
22300 + if (task_pid_nr(current))
22301 return;
22302 __exit_idle();
22303 }
22304 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
22305
22306 return ret;
22307 }
22308 -void stop_this_cpu(void *dummy)
22309 +__noreturn void stop_this_cpu(void *dummy)
22310 {
22311 local_irq_disable();
22312 /*
22313 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
22314 }
22315 early_param("idle", idle_setup);
22316
22317 -unsigned long arch_align_stack(unsigned long sp)
22318 +#ifdef CONFIG_PAX_RANDKSTACK
22319 +void pax_randomize_kstack(struct pt_regs *regs)
22320 {
22321 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22322 - sp -= get_random_int() % 8192;
22323 - return sp & ~0xf;
22324 -}
22325 + struct thread_struct *thread = &current->thread;
22326 + unsigned long time;
22327
22328 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22329 -{
22330 - unsigned long range_end = mm->brk + 0x02000000;
22331 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22332 -}
22333 + if (!randomize_va_space)
22334 + return;
22335 +
22336 + if (v8086_mode(regs))
22337 + return;
22338
22339 + rdtscl(time);
22340 +
22341 + /* P4 seems to return a 0 LSB, ignore it */
22342 +#ifdef CONFIG_MPENTIUM4
22343 + time &= 0x3EUL;
22344 + time <<= 2;
22345 +#elif defined(CONFIG_X86_64)
22346 + time &= 0xFUL;
22347 + time <<= 4;
22348 +#else
22349 + time &= 0x1FUL;
22350 + time <<= 3;
22351 +#endif
22352 +
22353 + thread->sp0 ^= time;
22354 + load_sp0(init_tss + smp_processor_id(), thread);
22355 +
22356 +#ifdef CONFIG_X86_64
22357 + this_cpu_write(kernel_stack, thread->sp0);
22358 +#endif
22359 +}
22360 +#endif
22361 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22362 index b5a8905..d9cacac 100644
22363 --- a/arch/x86/kernel/process_32.c
22364 +++ b/arch/x86/kernel/process_32.c
22365 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22366 unsigned long thread_saved_pc(struct task_struct *tsk)
22367 {
22368 return ((unsigned long *)tsk->thread.sp)[3];
22369 +//XXX return tsk->thread.eip;
22370 }
22371
22372 void __show_regs(struct pt_regs *regs, int all)
22373 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22374 unsigned long sp;
22375 unsigned short ss, gs;
22376
22377 - if (user_mode_vm(regs)) {
22378 + if (user_mode(regs)) {
22379 sp = regs->sp;
22380 ss = regs->ss & 0xffff;
22381 - gs = get_user_gs(regs);
22382 } else {
22383 sp = kernel_stack_pointer(regs);
22384 savesegment(ss, ss);
22385 - savesegment(gs, gs);
22386 }
22387 + gs = get_user_gs(regs);
22388
22389 show_regs_common();
22390
22391 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22392 (u16)regs->cs, regs->ip, regs->flags,
22393 - smp_processor_id());
22394 + raw_smp_processor_id());
22395 print_symbol("EIP is at %s\n", regs->ip);
22396
22397 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22398 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22399 int copy_thread(unsigned long clone_flags, unsigned long sp,
22400 unsigned long arg, struct task_struct *p)
22401 {
22402 - struct pt_regs *childregs = task_pt_regs(p);
22403 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22404 struct task_struct *tsk;
22405 int err;
22406
22407 p->thread.sp = (unsigned long) childregs;
22408 p->thread.sp0 = (unsigned long) (childregs+1);
22409 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22410
22411 if (unlikely(p->flags & PF_KTHREAD)) {
22412 /* kernel thread */
22413 memset(childregs, 0, sizeof(struct pt_regs));
22414 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22415 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22416 - childregs->ds = __USER_DS;
22417 - childregs->es = __USER_DS;
22418 + savesegment(gs, childregs->gs);
22419 + childregs->ds = __KERNEL_DS;
22420 + childregs->es = __KERNEL_DS;
22421 childregs->fs = __KERNEL_PERCPU;
22422 childregs->bx = sp; /* function */
22423 childregs->bp = arg;
22424 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22425 struct thread_struct *prev = &prev_p->thread,
22426 *next = &next_p->thread;
22427 int cpu = smp_processor_id();
22428 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22429 + struct tss_struct *tss = init_tss + cpu;
22430 fpu_switch_t fpu;
22431
22432 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22433 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22434 */
22435 lazy_save_gs(prev->gs);
22436
22437 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22438 + __set_fs(task_thread_info(next_p)->addr_limit);
22439 +#endif
22440 +
22441 /*
22442 * Load the per-thread Thread-Local Storage descriptor.
22443 */
22444 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22445 */
22446 arch_end_context_switch(next_p);
22447
22448 + this_cpu_write(current_task, next_p);
22449 + this_cpu_write(current_tinfo, &next_p->tinfo);
22450 +
22451 /*
22452 * Restore %gs if needed (which is common)
22453 */
22454 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22455
22456 switch_fpu_finish(next_p, fpu);
22457
22458 - this_cpu_write(current_task, next_p);
22459 -
22460 return prev_p;
22461 }
22462
22463 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22464 } while (count++ < 16);
22465 return 0;
22466 }
22467 -
22468 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22469 index 6e68a61..955a9a5 100644
22470 --- a/arch/x86/kernel/process_64.c
22471 +++ b/arch/x86/kernel/process_64.c
22472 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22473 struct pt_regs *childregs;
22474 struct task_struct *me = current;
22475
22476 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22477 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22478 childregs = task_pt_regs(p);
22479 p->thread.sp = (unsigned long) childregs;
22480 p->thread.usersp = me->thread.usersp;
22481 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22482 set_tsk_thread_flag(p, TIF_FORK);
22483 p->fpu_counter = 0;
22484 p->thread.io_bitmap_ptr = NULL;
22485 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22486 struct thread_struct *prev = &prev_p->thread;
22487 struct thread_struct *next = &next_p->thread;
22488 int cpu = smp_processor_id();
22489 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22490 + struct tss_struct *tss = init_tss + cpu;
22491 unsigned fsindex, gsindex;
22492 fpu_switch_t fpu;
22493
22494 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22495 prev->usersp = this_cpu_read(old_rsp);
22496 this_cpu_write(old_rsp, next->usersp);
22497 this_cpu_write(current_task, next_p);
22498 + this_cpu_write(current_tinfo, &next_p->tinfo);
22499
22500 - this_cpu_write(kernel_stack,
22501 - (unsigned long)task_stack_page(next_p) +
22502 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22503 + this_cpu_write(kernel_stack, next->sp0);
22504
22505 /*
22506 * Now maybe reload the debug registers and handle I/O bitmaps
22507 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22508 if (!p || p == current || p->state == TASK_RUNNING)
22509 return 0;
22510 stack = (unsigned long)task_stack_page(p);
22511 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22512 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22513 return 0;
22514 fp = *(u64 *)(p->thread.sp);
22515 do {
22516 - if (fp < (unsigned long)stack ||
22517 - fp >= (unsigned long)stack+THREAD_SIZE)
22518 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22519 return 0;
22520 ip = *(u64 *)(fp+8);
22521 if (!in_sched_functions(ip))
22522 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22523 index b629bbe..0fa615a 100644
22524 --- a/arch/x86/kernel/ptrace.c
22525 +++ b/arch/x86/kernel/ptrace.c
22526 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22527 {
22528 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22529 unsigned long sp = (unsigned long)&regs->sp;
22530 - struct thread_info *tinfo;
22531
22532 - if (context == (sp & ~(THREAD_SIZE - 1)))
22533 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22534 return sp;
22535
22536 - tinfo = (struct thread_info *)context;
22537 - if (tinfo->previous_esp)
22538 - return tinfo->previous_esp;
22539 + sp = *(unsigned long *)context;
22540 + if (sp)
22541 + return sp;
22542
22543 return (unsigned long)regs;
22544 }
22545 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22546 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22547 {
22548 int i;
22549 - int dr7 = 0;
22550 + unsigned long dr7 = 0;
22551 struct arch_hw_breakpoint *info;
22552
22553 for (i = 0; i < HBP_NUM; i++) {
22554 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22555 unsigned long addr, unsigned long data)
22556 {
22557 int ret;
22558 - unsigned long __user *datap = (unsigned long __user *)data;
22559 + unsigned long __user *datap = (__force unsigned long __user *)data;
22560
22561 switch (request) {
22562 /* read the word at location addr in the USER area. */
22563 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22564 if ((int) addr < 0)
22565 return -EIO;
22566 ret = do_get_thread_area(child, addr,
22567 - (struct user_desc __user *)data);
22568 + (__force struct user_desc __user *) data);
22569 break;
22570
22571 case PTRACE_SET_THREAD_AREA:
22572 if ((int) addr < 0)
22573 return -EIO;
22574 ret = do_set_thread_area(child, addr,
22575 - (struct user_desc __user *)data, 0);
22576 + (__force struct user_desc __user *) data, 0);
22577 break;
22578 #endif
22579
22580 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22581
22582 #ifdef CONFIG_X86_64
22583
22584 -static struct user_regset x86_64_regsets[] __read_mostly = {
22585 +static user_regset_no_const x86_64_regsets[] __read_only = {
22586 [REGSET_GENERAL] = {
22587 .core_note_type = NT_PRSTATUS,
22588 .n = sizeof(struct user_regs_struct) / sizeof(long),
22589 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22590 #endif /* CONFIG_X86_64 */
22591
22592 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22593 -static struct user_regset x86_32_regsets[] __read_mostly = {
22594 +static user_regset_no_const x86_32_regsets[] __read_only = {
22595 [REGSET_GENERAL] = {
22596 .core_note_type = NT_PRSTATUS,
22597 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22598 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22599 */
22600 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22601
22602 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22603 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22604 {
22605 #ifdef CONFIG_X86_64
22606 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22607 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22608 memset(info, 0, sizeof(*info));
22609 info->si_signo = SIGTRAP;
22610 info->si_code = si_code;
22611 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22612 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22613 }
22614
22615 void user_single_step_siginfo(struct task_struct *tsk,
22616 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22617 # define IS_IA32 0
22618 #endif
22619
22620 +#ifdef CONFIG_GRKERNSEC_SETXID
22621 +extern void gr_delayed_cred_worker(void);
22622 +#endif
22623 +
22624 /*
22625 * We must return the syscall number to actually look up in the table.
22626 * This can be -1L to skip running any syscall at all.
22627 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22628
22629 user_exit();
22630
22631 +#ifdef CONFIG_GRKERNSEC_SETXID
22632 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22633 + gr_delayed_cred_worker();
22634 +#endif
22635 +
22636 /*
22637 * If we stepped into a sysenter/syscall insn, it trapped in
22638 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22639 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22640 */
22641 user_exit();
22642
22643 +#ifdef CONFIG_GRKERNSEC_SETXID
22644 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22645 + gr_delayed_cred_worker();
22646 +#endif
22647 +
22648 audit_syscall_exit(regs);
22649
22650 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22651 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22652 index 2cb9470..ff1fd80 100644
22653 --- a/arch/x86/kernel/pvclock.c
22654 +++ b/arch/x86/kernel/pvclock.c
22655 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22656 return pv_tsc_khz;
22657 }
22658
22659 -static atomic64_t last_value = ATOMIC64_INIT(0);
22660 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22661
22662 void pvclock_resume(void)
22663 {
22664 - atomic64_set(&last_value, 0);
22665 + atomic64_set_unchecked(&last_value, 0);
22666 }
22667
22668 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22669 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22670 * updating at the same time, and one of them could be slightly behind,
22671 * making the assumption that last_value always go forward fail to hold.
22672 */
22673 - last = atomic64_read(&last_value);
22674 + last = atomic64_read_unchecked(&last_value);
22675 do {
22676 if (ret < last)
22677 return last;
22678 - last = atomic64_cmpxchg(&last_value, last, ret);
22679 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22680 } while (unlikely(last != ret));
22681
22682 return ret;
22683 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22684 index 76fa1e9..abf09ea 100644
22685 --- a/arch/x86/kernel/reboot.c
22686 +++ b/arch/x86/kernel/reboot.c
22687 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22688 EXPORT_SYMBOL(pm_power_off);
22689
22690 static const struct desc_ptr no_idt = {};
22691 -static int reboot_mode;
22692 +static unsigned short reboot_mode;
22693 enum reboot_type reboot_type = BOOT_ACPI;
22694 int reboot_force;
22695
22696 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22697
22698 void __noreturn machine_real_restart(unsigned int type)
22699 {
22700 +
22701 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22702 + struct desc_struct *gdt;
22703 +#endif
22704 +
22705 local_irq_disable();
22706
22707 /*
22708 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22709
22710 /* Jump to the identity-mapped low memory code */
22711 #ifdef CONFIG_X86_32
22712 - asm volatile("jmpl *%0" : :
22713 +
22714 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22715 + gdt = get_cpu_gdt_table(smp_processor_id());
22716 + pax_open_kernel();
22717 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22718 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22719 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22720 + loadsegment(ds, __KERNEL_DS);
22721 + loadsegment(es, __KERNEL_DS);
22722 + loadsegment(ss, __KERNEL_DS);
22723 +#endif
22724 +#ifdef CONFIG_PAX_KERNEXEC
22725 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22726 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22727 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22728 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22729 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22730 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22731 +#endif
22732 + pax_close_kernel();
22733 +#endif
22734 +
22735 + asm volatile("ljmpl *%0" : :
22736 "rm" (real_mode_header->machine_real_restart_asm),
22737 "a" (type));
22738 #else
22739 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22740 * try to force a triple fault and then cycle between hitting the keyboard
22741 * controller and doing that
22742 */
22743 -static void native_machine_emergency_restart(void)
22744 +static void __noreturn native_machine_emergency_restart(void)
22745 {
22746 int i;
22747 int attempt = 0;
22748 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22749 #endif
22750 }
22751
22752 -static void __machine_emergency_restart(int emergency)
22753 +static void __noreturn __machine_emergency_restart(int emergency)
22754 {
22755 reboot_emergency = emergency;
22756 machine_ops.emergency_restart();
22757 }
22758
22759 -static void native_machine_restart(char *__unused)
22760 +static void __noreturn native_machine_restart(char *__unused)
22761 {
22762 pr_notice("machine restart\n");
22763
22764 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22765 __machine_emergency_restart(0);
22766 }
22767
22768 -static void native_machine_halt(void)
22769 +static void __noreturn native_machine_halt(void)
22770 {
22771 /* Stop other cpus and apics */
22772 machine_shutdown();
22773 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22774 stop_this_cpu(NULL);
22775 }
22776
22777 -static void native_machine_power_off(void)
22778 +static void __noreturn native_machine_power_off(void)
22779 {
22780 if (pm_power_off) {
22781 if (!reboot_force)
22782 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22783 }
22784 /* A fallback in case there is no PM info available */
22785 tboot_shutdown(TB_SHUTDOWN_HALT);
22786 + unreachable();
22787 }
22788
22789 -struct machine_ops machine_ops = {
22790 +struct machine_ops machine_ops __read_only = {
22791 .power_off = native_machine_power_off,
22792 .shutdown = native_machine_shutdown,
22793 .emergency_restart = native_machine_emergency_restart,
22794 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22795 index 7a6f3b3..bed145d7 100644
22796 --- a/arch/x86/kernel/relocate_kernel_64.S
22797 +++ b/arch/x86/kernel/relocate_kernel_64.S
22798 @@ -11,6 +11,7 @@
22799 #include <asm/kexec.h>
22800 #include <asm/processor-flags.h>
22801 #include <asm/pgtable_types.h>
22802 +#include <asm/alternative-asm.h>
22803
22804 /*
22805 * Must be relocatable PIC code callable as a C function
22806 @@ -160,13 +161,14 @@ identity_mapped:
22807 xorq %rbp, %rbp
22808 xorq %r8, %r8
22809 xorq %r9, %r9
22810 - xorq %r10, %r9
22811 + xorq %r10, %r10
22812 xorq %r11, %r11
22813 xorq %r12, %r12
22814 xorq %r13, %r13
22815 xorq %r14, %r14
22816 xorq %r15, %r15
22817
22818 + pax_force_retaddr 0, 1
22819 ret
22820
22821 1:
22822 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22823 index 8b24289..d37b58b 100644
22824 --- a/arch/x86/kernel/setup.c
22825 +++ b/arch/x86/kernel/setup.c
22826 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
22827
22828 switch (data->type) {
22829 case SETUP_E820_EXT:
22830 - parse_e820_ext(data);
22831 + parse_e820_ext((struct setup_data __force_kernel *)data);
22832 break;
22833 case SETUP_DTB:
22834 add_dtb(pa_data);
22835 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
22836 * area (640->1Mb) as ram even though it is not.
22837 * take them out.
22838 */
22839 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22840 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22841
22842 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22843 }
22844 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
22845
22846 if (!boot_params.hdr.root_flags)
22847 root_mountflags &= ~MS_RDONLY;
22848 - init_mm.start_code = (unsigned long) _text;
22849 - init_mm.end_code = (unsigned long) _etext;
22850 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22851 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22852 init_mm.end_data = (unsigned long) _edata;
22853 init_mm.brk = _brk_end;
22854
22855 - code_resource.start = virt_to_phys(_text);
22856 - code_resource.end = virt_to_phys(_etext)-1;
22857 - data_resource.start = virt_to_phys(_etext);
22858 + code_resource.start = virt_to_phys(ktla_ktva(_text));
22859 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
22860 + data_resource.start = virt_to_phys(_sdata);
22861 data_resource.end = virt_to_phys(_edata)-1;
22862 bss_resource.start = virt_to_phys(&__bss_start);
22863 bss_resource.end = virt_to_phys(&__bss_stop)-1;
22864 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22865 index 5cdff03..80fa283 100644
22866 --- a/arch/x86/kernel/setup_percpu.c
22867 +++ b/arch/x86/kernel/setup_percpu.c
22868 @@ -21,19 +21,17 @@
22869 #include <asm/cpu.h>
22870 #include <asm/stackprotector.h>
22871
22872 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22873 +#ifdef CONFIG_SMP
22874 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22875 EXPORT_PER_CPU_SYMBOL(cpu_number);
22876 +#endif
22877
22878 -#ifdef CONFIG_X86_64
22879 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22880 -#else
22881 -#define BOOT_PERCPU_OFFSET 0
22882 -#endif
22883
22884 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22885 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22886
22887 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22888 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22889 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22890 };
22891 EXPORT_SYMBOL(__per_cpu_offset);
22892 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22893 {
22894 #ifdef CONFIG_NEED_MULTIPLE_NODES
22895 pg_data_t *last = NULL;
22896 - unsigned int cpu;
22897 + int cpu;
22898
22899 for_each_possible_cpu(cpu) {
22900 int node = early_cpu_to_node(cpu);
22901 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22902 {
22903 #ifdef CONFIG_X86_32
22904 struct desc_struct gdt;
22905 + unsigned long base = per_cpu_offset(cpu);
22906
22907 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22908 - 0x2 | DESCTYPE_S, 0x8);
22909 - gdt.s = 1;
22910 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22911 + 0x83 | DESCTYPE_S, 0xC);
22912 write_gdt_entry(get_cpu_gdt_table(cpu),
22913 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22914 #endif
22915 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22916 /* alrighty, percpu areas up and running */
22917 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22918 for_each_possible_cpu(cpu) {
22919 +#ifdef CONFIG_CC_STACKPROTECTOR
22920 +#ifdef CONFIG_X86_32
22921 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22922 +#endif
22923 +#endif
22924 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22925 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22926 per_cpu(cpu_number, cpu) = cpu;
22927 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22928 */
22929 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22930 #endif
22931 +#ifdef CONFIG_CC_STACKPROTECTOR
22932 +#ifdef CONFIG_X86_32
22933 + if (!cpu)
22934 + per_cpu(stack_canary.canary, cpu) = canary;
22935 +#endif
22936 +#endif
22937 /*
22938 * Up to this point, the boot CPU has been using .init.data
22939 * area. Reload any changed state for the boot CPU.
22940 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22941 index d6bf1f3..3ffce5a 100644
22942 --- a/arch/x86/kernel/signal.c
22943 +++ b/arch/x86/kernel/signal.c
22944 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22945 * Align the stack pointer according to the i386 ABI,
22946 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22947 */
22948 - sp = ((sp + 4) & -16ul) - 4;
22949 + sp = ((sp - 12) & -16ul) - 4;
22950 #else /* !CONFIG_X86_32 */
22951 sp = round_down(sp, 16) - 8;
22952 #endif
22953 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22954 }
22955
22956 if (current->mm->context.vdso)
22957 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22958 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22959 else
22960 - restorer = &frame->retcode;
22961 + restorer = (void __user *)&frame->retcode;
22962 if (ka->sa.sa_flags & SA_RESTORER)
22963 restorer = ka->sa.sa_restorer;
22964
22965 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22966 * reasons and because gdb uses it as a signature to notice
22967 * signal handler stack frames.
22968 */
22969 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22970 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22971
22972 if (err)
22973 return -EFAULT;
22974 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22975 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22976
22977 /* Set up to return from userspace. */
22978 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22979 + if (current->mm->context.vdso)
22980 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22981 + else
22982 + restorer = (void __user *)&frame->retcode;
22983 if (ka->sa.sa_flags & SA_RESTORER)
22984 restorer = ka->sa.sa_restorer;
22985 put_user_ex(restorer, &frame->pretcode);
22986 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22987 * reasons and because gdb uses it as a signature to notice
22988 * signal handler stack frames.
22989 */
22990 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22991 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22992 } put_user_catch(err);
22993
22994 err |= copy_siginfo_to_user(&frame->info, info);
22995 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22996 index 48d2b7d..90d328a 100644
22997 --- a/arch/x86/kernel/smp.c
22998 +++ b/arch/x86/kernel/smp.c
22999 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
23000
23001 __setup("nonmi_ipi", nonmi_ipi_setup);
23002
23003 -struct smp_ops smp_ops = {
23004 +struct smp_ops smp_ops __read_only = {
23005 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
23006 .smp_prepare_cpus = native_smp_prepare_cpus,
23007 .smp_cpus_done = native_smp_cpus_done,
23008 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
23009 index ed0fe38..87fc692 100644
23010 --- a/arch/x86/kernel/smpboot.c
23011 +++ b/arch/x86/kernel/smpboot.c
23012 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23013 idle->thread.sp = (unsigned long) (((struct pt_regs *)
23014 (THREAD_SIZE + task_stack_page(idle))) - 1);
23015 per_cpu(current_task, cpu) = idle;
23016 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
23017
23018 #ifdef CONFIG_X86_32
23019 /* Stack for startup_32 can be just as for start_secondary onwards */
23020 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23021 #else
23022 clear_tsk_thread_flag(idle, TIF_FORK);
23023 initial_gs = per_cpu_offset(cpu);
23024 - per_cpu(kernel_stack, cpu) =
23025 - (unsigned long)task_stack_page(idle) -
23026 - KERNEL_STACK_OFFSET + THREAD_SIZE;
23027 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
23028 #endif
23029 +
23030 + pax_open_kernel();
23031 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
23032 + pax_close_kernel();
23033 +
23034 initial_code = (unsigned long)start_secondary;
23035 stack_start = idle->thread.sp;
23036
23037 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
23038 /* the FPU context is blank, nobody can own it */
23039 __cpu_disable_lazy_restore(cpu);
23040
23041 +#ifdef CONFIG_PAX_PER_CPU_PGD
23042 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
23043 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
23044 + KERNEL_PGD_PTRS);
23045 +#endif
23046 +
23047 + /* the FPU context is blank, nobody can own it */
23048 + __cpu_disable_lazy_restore(cpu);
23049 +
23050 err = do_boot_cpu(apicid, cpu, tidle);
23051 if (err) {
23052 pr_debug("do_boot_cpu failed %d\n", err);
23053 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
23054 index 9b4d51d..5d28b58 100644
23055 --- a/arch/x86/kernel/step.c
23056 +++ b/arch/x86/kernel/step.c
23057 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23058 struct desc_struct *desc;
23059 unsigned long base;
23060
23061 - seg &= ~7UL;
23062 + seg >>= 3;
23063
23064 mutex_lock(&child->mm->context.lock);
23065 - if (unlikely((seg >> 3) >= child->mm->context.size))
23066 + if (unlikely(seg >= child->mm->context.size))
23067 addr = -1L; /* bogus selector, access would fault */
23068 else {
23069 desc = child->mm->context.ldt + seg;
23070 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23071 addr += base;
23072 }
23073 mutex_unlock(&child->mm->context.lock);
23074 - }
23075 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
23076 + addr = ktla_ktva(addr);
23077
23078 return addr;
23079 }
23080 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
23081 unsigned char opcode[15];
23082 unsigned long addr = convert_ip_to_linear(child, regs);
23083
23084 + if (addr == -EINVAL)
23085 + return 0;
23086 +
23087 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
23088 for (i = 0; i < copied; i++) {
23089 switch (opcode[i]) {
23090 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
23091 new file mode 100644
23092 index 0000000..207bec6
23093 --- /dev/null
23094 +++ b/arch/x86/kernel/sys_i386_32.c
23095 @@ -0,0 +1,250 @@
23096 +/*
23097 + * This file contains various random system calls that
23098 + * have a non-standard calling sequence on the Linux/i386
23099 + * platform.
23100 + */
23101 +
23102 +#include <linux/errno.h>
23103 +#include <linux/sched.h>
23104 +#include <linux/mm.h>
23105 +#include <linux/fs.h>
23106 +#include <linux/smp.h>
23107 +#include <linux/sem.h>
23108 +#include <linux/msg.h>
23109 +#include <linux/shm.h>
23110 +#include <linux/stat.h>
23111 +#include <linux/syscalls.h>
23112 +#include <linux/mman.h>
23113 +#include <linux/file.h>
23114 +#include <linux/utsname.h>
23115 +#include <linux/ipc.h>
23116 +
23117 +#include <linux/uaccess.h>
23118 +#include <linux/unistd.h>
23119 +
23120 +#include <asm/syscalls.h>
23121 +
23122 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
23123 +{
23124 + unsigned long pax_task_size = TASK_SIZE;
23125 +
23126 +#ifdef CONFIG_PAX_SEGMEXEC
23127 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
23128 + pax_task_size = SEGMEXEC_TASK_SIZE;
23129 +#endif
23130 +
23131 + if (flags & MAP_FIXED)
23132 + if (len > pax_task_size || addr > pax_task_size - len)
23133 + return -EINVAL;
23134 +
23135 + return 0;
23136 +}
23137 +
23138 +unsigned long
23139 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
23140 + unsigned long len, unsigned long pgoff, unsigned long flags)
23141 +{
23142 + struct mm_struct *mm = current->mm;
23143 + struct vm_area_struct *vma;
23144 + unsigned long start_addr, pax_task_size = TASK_SIZE;
23145 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23146 +
23147 +#ifdef CONFIG_PAX_SEGMEXEC
23148 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23149 + pax_task_size = SEGMEXEC_TASK_SIZE;
23150 +#endif
23151 +
23152 + pax_task_size -= PAGE_SIZE;
23153 +
23154 + if (len > pax_task_size)
23155 + return -ENOMEM;
23156 +
23157 + if (flags & MAP_FIXED)
23158 + return addr;
23159 +
23160 +#ifdef CONFIG_PAX_RANDMMAP
23161 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23162 +#endif
23163 +
23164 + if (addr) {
23165 + addr = PAGE_ALIGN(addr);
23166 + if (pax_task_size - len >= addr) {
23167 + vma = find_vma(mm, addr);
23168 + if (check_heap_stack_gap(vma, addr, len, offset))
23169 + return addr;
23170 + }
23171 + }
23172 + if (len > mm->cached_hole_size) {
23173 + start_addr = addr = mm->free_area_cache;
23174 + } else {
23175 + start_addr = addr = mm->mmap_base;
23176 + mm->cached_hole_size = 0;
23177 + }
23178 +
23179 +#ifdef CONFIG_PAX_PAGEEXEC
23180 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
23181 + start_addr = 0x00110000UL;
23182 +
23183 +#ifdef CONFIG_PAX_RANDMMAP
23184 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23185 + start_addr += mm->delta_mmap & 0x03FFF000UL;
23186 +#endif
23187 +
23188 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
23189 + start_addr = addr = mm->mmap_base;
23190 + else
23191 + addr = start_addr;
23192 + }
23193 +#endif
23194 +
23195 +full_search:
23196 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
23197 + /* At this point: (!vma || addr < vma->vm_end). */
23198 + if (pax_task_size - len < addr) {
23199 + /*
23200 + * Start a new search - just in case we missed
23201 + * some holes.
23202 + */
23203 + if (start_addr != mm->mmap_base) {
23204 + start_addr = addr = mm->mmap_base;
23205 + mm->cached_hole_size = 0;
23206 + goto full_search;
23207 + }
23208 + return -ENOMEM;
23209 + }
23210 + if (check_heap_stack_gap(vma, addr, len, offset))
23211 + break;
23212 + if (addr + mm->cached_hole_size < vma->vm_start)
23213 + mm->cached_hole_size = vma->vm_start - addr;
23214 + addr = vma->vm_end;
23215 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
23216 + start_addr = addr = mm->mmap_base;
23217 + mm->cached_hole_size = 0;
23218 + goto full_search;
23219 + }
23220 + }
23221 +
23222 + /*
23223 + * Remember the place where we stopped the search:
23224 + */
23225 + mm->free_area_cache = addr + len;
23226 + return addr;
23227 +}
23228 +
23229 +unsigned long
23230 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23231 + const unsigned long len, const unsigned long pgoff,
23232 + const unsigned long flags)
23233 +{
23234 + struct vm_area_struct *vma;
23235 + struct mm_struct *mm = current->mm;
23236 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
23237 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23238 +
23239 +#ifdef CONFIG_PAX_SEGMEXEC
23240 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23241 + pax_task_size = SEGMEXEC_TASK_SIZE;
23242 +#endif
23243 +
23244 + pax_task_size -= PAGE_SIZE;
23245 +
23246 + /* requested length too big for entire address space */
23247 + if (len > pax_task_size)
23248 + return -ENOMEM;
23249 +
23250 + if (flags & MAP_FIXED)
23251 + return addr;
23252 +
23253 +#ifdef CONFIG_PAX_PAGEEXEC
23254 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23255 + goto bottomup;
23256 +#endif
23257 +
23258 +#ifdef CONFIG_PAX_RANDMMAP
23259 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23260 +#endif
23261 +
23262 + /* requesting a specific address */
23263 + if (addr) {
23264 + addr = PAGE_ALIGN(addr);
23265 + if (pax_task_size - len >= addr) {
23266 + vma = find_vma(mm, addr);
23267 + if (check_heap_stack_gap(vma, addr, len, offset))
23268 + return addr;
23269 + }
23270 + }
23271 +
23272 + /* check if free_area_cache is useful for us */
23273 + if (len <= mm->cached_hole_size) {
23274 + mm->cached_hole_size = 0;
23275 + mm->free_area_cache = mm->mmap_base;
23276 + }
23277 +
23278 + /* either no address requested or can't fit in requested address hole */
23279 + addr = mm->free_area_cache;
23280 +
23281 + /* make sure it can fit in the remaining address space */
23282 + if (addr > len) {
23283 + vma = find_vma(mm, addr-len);
23284 + if (check_heap_stack_gap(vma, addr - len, len, offset))
23285 + /* remember the address as a hint for next time */
23286 + return (mm->free_area_cache = addr-len);
23287 + }
23288 +
23289 + if (mm->mmap_base < len)
23290 + goto bottomup;
23291 +
23292 + addr = mm->mmap_base-len;
23293 +
23294 + do {
23295 + /*
23296 + * Lookup failure means no vma is above this address,
23297 + * else if new region fits below vma->vm_start,
23298 + * return with success:
23299 + */
23300 + vma = find_vma(mm, addr);
23301 + if (check_heap_stack_gap(vma, addr, len, offset))
23302 + /* remember the address as a hint for next time */
23303 + return (mm->free_area_cache = addr);
23304 +
23305 + /* remember the largest hole we saw so far */
23306 + if (addr + mm->cached_hole_size < vma->vm_start)
23307 + mm->cached_hole_size = vma->vm_start - addr;
23308 +
23309 + /* try just below the current vma->vm_start */
23310 + addr = skip_heap_stack_gap(vma, len, offset);
23311 + } while (!IS_ERR_VALUE(addr));
23312 +
23313 +bottomup:
23314 + /*
23315 + * A failed mmap() very likely causes application failure,
23316 + * so fall back to the bottom-up function here. This scenario
23317 + * can happen with large stack limits and large mmap()
23318 + * allocations.
23319 + */
23320 +
23321 +#ifdef CONFIG_PAX_SEGMEXEC
23322 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23323 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23324 + else
23325 +#endif
23326 +
23327 + mm->mmap_base = TASK_UNMAPPED_BASE;
23328 +
23329 +#ifdef CONFIG_PAX_RANDMMAP
23330 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23331 + mm->mmap_base += mm->delta_mmap;
23332 +#endif
23333 +
23334 + mm->free_area_cache = mm->mmap_base;
23335 + mm->cached_hole_size = ~0UL;
23336 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23337 + /*
23338 + * Restore the topdown base:
23339 + */
23340 + mm->mmap_base = base;
23341 + mm->free_area_cache = base;
23342 + mm->cached_hole_size = ~0UL;
23343 +
23344 + return addr;
23345 +}
23346 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23347 index 97ef74b..57a1882 100644
23348 --- a/arch/x86/kernel/sys_x86_64.c
23349 +++ b/arch/x86/kernel/sys_x86_64.c
23350 @@ -81,8 +81,8 @@ out:
23351 return error;
23352 }
23353
23354 -static void find_start_end(unsigned long flags, unsigned long *begin,
23355 - unsigned long *end)
23356 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23357 + unsigned long *begin, unsigned long *end)
23358 {
23359 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23360 unsigned long new_begin;
23361 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23362 *begin = new_begin;
23363 }
23364 } else {
23365 - *begin = TASK_UNMAPPED_BASE;
23366 + *begin = mm->mmap_base;
23367 *end = TASK_SIZE;
23368 }
23369 }
23370 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23371 struct vm_area_struct *vma;
23372 struct vm_unmapped_area_info info;
23373 unsigned long begin, end;
23374 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23375
23376 if (flags & MAP_FIXED)
23377 return addr;
23378
23379 - find_start_end(flags, &begin, &end);
23380 + find_start_end(mm, flags, &begin, &end);
23381
23382 if (len > end)
23383 return -ENOMEM;
23384
23385 +#ifdef CONFIG_PAX_RANDMMAP
23386 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23387 +#endif
23388 +
23389 if (addr) {
23390 addr = PAGE_ALIGN(addr);
23391 vma = find_vma(mm, addr);
23392 - if (end - len >= addr &&
23393 - (!vma || addr + len <= vma->vm_start))
23394 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23395 return addr;
23396 }
23397
23398 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23399 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23400 goto bottomup;
23401
23402 +#ifdef CONFIG_PAX_RANDMMAP
23403 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23404 +#endif
23405 +
23406 /* requesting a specific address */
23407 if (addr) {
23408 addr = PAGE_ALIGN(addr);
23409 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23410 index f84fe00..f41d9f1 100644
23411 --- a/arch/x86/kernel/tboot.c
23412 +++ b/arch/x86/kernel/tboot.c
23413 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23414
23415 void tboot_shutdown(u32 shutdown_type)
23416 {
23417 - void (*shutdown)(void);
23418 + void (* __noreturn shutdown)(void);
23419
23420 if (!tboot_enabled())
23421 return;
23422 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23423
23424 switch_to_tboot_pt();
23425
23426 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23427 + shutdown = (void *)tboot->shutdown_entry;
23428 shutdown();
23429
23430 /* should not reach here */
23431 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23432 return 0;
23433 }
23434
23435 -static atomic_t ap_wfs_count;
23436 +static atomic_unchecked_t ap_wfs_count;
23437
23438 static int tboot_wait_for_aps(int num_aps)
23439 {
23440 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23441 {
23442 switch (action) {
23443 case CPU_DYING:
23444 - atomic_inc(&ap_wfs_count);
23445 + atomic_inc_unchecked(&ap_wfs_count);
23446 if (num_online_cpus() == 1)
23447 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23448 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23449 return NOTIFY_BAD;
23450 break;
23451 }
23452 return NOTIFY_OK;
23453 }
23454
23455 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23456 +static struct notifier_block tboot_cpu_notifier =
23457 {
23458 .notifier_call = tboot_cpu_callback,
23459 };
23460 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23461
23462 tboot_create_trampoline();
23463
23464 - atomic_set(&ap_wfs_count, 0);
23465 + atomic_set_unchecked(&ap_wfs_count, 0);
23466 register_hotcpu_notifier(&tboot_cpu_notifier);
23467
23468 acpi_os_set_prepare_sleep(&tboot_sleep);
23469 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23470 index 24d3c91..d06b473 100644
23471 --- a/arch/x86/kernel/time.c
23472 +++ b/arch/x86/kernel/time.c
23473 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23474 {
23475 unsigned long pc = instruction_pointer(regs);
23476
23477 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23478 + if (!user_mode(regs) && in_lock_functions(pc)) {
23479 #ifdef CONFIG_FRAME_POINTER
23480 - return *(unsigned long *)(regs->bp + sizeof(long));
23481 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23482 #else
23483 unsigned long *sp =
23484 (unsigned long *)kernel_stack_pointer(regs);
23485 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23486 * or above a saved flags. Eflags has bits 22-31 zero,
23487 * kernel addresses don't.
23488 */
23489 +
23490 +#ifdef CONFIG_PAX_KERNEXEC
23491 + return ktla_ktva(sp[0]);
23492 +#else
23493 if (sp[0] >> 22)
23494 return sp[0];
23495 if (sp[1] >> 22)
23496 return sp[1];
23497 #endif
23498 +
23499 +#endif
23500 }
23501 return pc;
23502 }
23503 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23504 index 9d9d2f9..cad418a 100644
23505 --- a/arch/x86/kernel/tls.c
23506 +++ b/arch/x86/kernel/tls.c
23507 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23508 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23509 return -EINVAL;
23510
23511 +#ifdef CONFIG_PAX_SEGMEXEC
23512 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23513 + return -EINVAL;
23514 +#endif
23515 +
23516 set_tls_desc(p, idx, &info, 1);
23517
23518 return 0;
23519 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23520
23521 if (kbuf)
23522 info = kbuf;
23523 - else if (__copy_from_user(infobuf, ubuf, count))
23524 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23525 return -EFAULT;
23526 else
23527 info = infobuf;
23528 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23529 index ecffca1..95c4d13 100644
23530 --- a/arch/x86/kernel/traps.c
23531 +++ b/arch/x86/kernel/traps.c
23532 @@ -68,12 +68,6 @@
23533 #include <asm/setup.h>
23534
23535 asmlinkage int system_call(void);
23536 -
23537 -/*
23538 - * The IDT has to be page-aligned to simplify the Pentium
23539 - * F0 0F bug workaround.
23540 - */
23541 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23542 #endif
23543
23544 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23545 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23546 }
23547
23548 static int __kprobes
23549 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23550 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23551 struct pt_regs *regs, long error_code)
23552 {
23553 #ifdef CONFIG_X86_32
23554 - if (regs->flags & X86_VM_MASK) {
23555 + if (v8086_mode(regs)) {
23556 /*
23557 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23558 * On nmi (interrupt 2), do_trap should not be called.
23559 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23560 return -1;
23561 }
23562 #endif
23563 - if (!user_mode(regs)) {
23564 + if (!user_mode_novm(regs)) {
23565 if (!fixup_exception(regs)) {
23566 tsk->thread.error_code = error_code;
23567 tsk->thread.trap_nr = trapnr;
23568 +
23569 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23570 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23571 + str = "PAX: suspicious stack segment fault";
23572 +#endif
23573 +
23574 die(str, regs, error_code);
23575 }
23576 +
23577 +#ifdef CONFIG_PAX_REFCOUNT
23578 + if (trapnr == 4)
23579 + pax_report_refcount_overflow(regs);
23580 +#endif
23581 +
23582 return 0;
23583 }
23584
23585 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23586 }
23587
23588 static void __kprobes
23589 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23590 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23591 long error_code, siginfo_t *info)
23592 {
23593 struct task_struct *tsk = current;
23594 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23595 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23596 printk_ratelimit()) {
23597 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23598 - tsk->comm, tsk->pid, str,
23599 + tsk->comm, task_pid_nr(tsk), str,
23600 regs->ip, regs->sp, error_code);
23601 print_vma_addr(" in ", regs->ip);
23602 pr_cont("\n");
23603 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23604 conditional_sti(regs);
23605
23606 #ifdef CONFIG_X86_32
23607 - if (regs->flags & X86_VM_MASK) {
23608 + if (v8086_mode(regs)) {
23609 local_irq_enable();
23610 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23611 goto exit;
23612 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23613 #endif
23614
23615 tsk = current;
23616 - if (!user_mode(regs)) {
23617 + if (!user_mode_novm(regs)) {
23618 if (fixup_exception(regs))
23619 goto exit;
23620
23621 tsk->thread.error_code = error_code;
23622 tsk->thread.trap_nr = X86_TRAP_GP;
23623 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23624 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23625 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23626 +
23627 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23628 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23629 + die("PAX: suspicious general protection fault", regs, error_code);
23630 + else
23631 +#endif
23632 +
23633 die("general protection fault", regs, error_code);
23634 + }
23635 goto exit;
23636 }
23637
23638 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23639 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23640 + struct mm_struct *mm = tsk->mm;
23641 + unsigned long limit;
23642 +
23643 + down_write(&mm->mmap_sem);
23644 + limit = mm->context.user_cs_limit;
23645 + if (limit < TASK_SIZE) {
23646 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23647 + up_write(&mm->mmap_sem);
23648 + return;
23649 + }
23650 + up_write(&mm->mmap_sem);
23651 + }
23652 +#endif
23653 +
23654 tsk->thread.error_code = error_code;
23655 tsk->thread.trap_nr = X86_TRAP_GP;
23656
23657 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23658 /* It's safe to allow irq's after DR6 has been saved */
23659 preempt_conditional_sti(regs);
23660
23661 - if (regs->flags & X86_VM_MASK) {
23662 + if (v8086_mode(regs)) {
23663 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23664 X86_TRAP_DB);
23665 preempt_conditional_cli(regs);
23666 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23667 * We already checked v86 mode above, so we can check for kernel mode
23668 * by just checking the CPL of CS.
23669 */
23670 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23671 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23672 tsk->thread.debugreg6 &= ~DR_STEP;
23673 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23674 regs->flags &= ~X86_EFLAGS_TF;
23675 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23676 return;
23677 conditional_sti(regs);
23678
23679 - if (!user_mode_vm(regs))
23680 + if (!user_mode(regs))
23681 {
23682 if (!fixup_exception(regs)) {
23683 task->thread.error_code = error_code;
23684 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23685 index c71025b..b117501 100644
23686 --- a/arch/x86/kernel/uprobes.c
23687 +++ b/arch/x86/kernel/uprobes.c
23688 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23689 int ret = NOTIFY_DONE;
23690
23691 /* We are only interested in userspace traps */
23692 - if (regs && !user_mode_vm(regs))
23693 + if (regs && !user_mode(regs))
23694 return NOTIFY_DONE;
23695
23696 switch (val) {
23697 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23698 index b9242ba..50c5edd 100644
23699 --- a/arch/x86/kernel/verify_cpu.S
23700 +++ b/arch/x86/kernel/verify_cpu.S
23701 @@ -20,6 +20,7 @@
23702 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23703 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23704 * arch/x86/kernel/head_32.S: processor startup
23705 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23706 *
23707 * verify_cpu, returns the status of longmode and SSE in register %eax.
23708 * 0: Success 1: Failure
23709 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23710 index 1dfe69c..a3df6f6 100644
23711 --- a/arch/x86/kernel/vm86_32.c
23712 +++ b/arch/x86/kernel/vm86_32.c
23713 @@ -43,6 +43,7 @@
23714 #include <linux/ptrace.h>
23715 #include <linux/audit.h>
23716 #include <linux/stddef.h>
23717 +#include <linux/grsecurity.h>
23718
23719 #include <asm/uaccess.h>
23720 #include <asm/io.h>
23721 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23722 do_exit(SIGSEGV);
23723 }
23724
23725 - tss = &per_cpu(init_tss, get_cpu());
23726 + tss = init_tss + get_cpu();
23727 current->thread.sp0 = current->thread.saved_sp0;
23728 current->thread.sysenter_cs = __KERNEL_CS;
23729 load_sp0(tss, &current->thread);
23730 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
23731 struct task_struct *tsk;
23732 int tmp, ret = -EPERM;
23733
23734 +#ifdef CONFIG_GRKERNSEC_VM86
23735 + if (!capable(CAP_SYS_RAWIO)) {
23736 + gr_handle_vm86();
23737 + goto out;
23738 + }
23739 +#endif
23740 +
23741 tsk = current;
23742 if (tsk->thread.saved_sp0)
23743 goto out;
23744 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
23745 int tmp, ret;
23746 struct vm86plus_struct __user *v86;
23747
23748 +#ifdef CONFIG_GRKERNSEC_VM86
23749 + if (!capable(CAP_SYS_RAWIO)) {
23750 + gr_handle_vm86();
23751 + ret = -EPERM;
23752 + goto out;
23753 + }
23754 +#endif
23755 +
23756 tsk = current;
23757 switch (cmd) {
23758 case VM86_REQUEST_IRQ:
23759 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23760 tsk->thread.saved_fs = info->regs32->fs;
23761 tsk->thread.saved_gs = get_user_gs(info->regs32);
23762
23763 - tss = &per_cpu(init_tss, get_cpu());
23764 + tss = init_tss + get_cpu();
23765 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23766 if (cpu_has_sep)
23767 tsk->thread.sysenter_cs = 0;
23768 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23769 goto cannot_handle;
23770 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23771 goto cannot_handle;
23772 - intr_ptr = (unsigned long __user *) (i << 2);
23773 + intr_ptr = (__force unsigned long __user *) (i << 2);
23774 if (get_user(segoffs, intr_ptr))
23775 goto cannot_handle;
23776 if ((segoffs >> 16) == BIOSSEG)
23777 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23778 index 22a1530..8fbaaad 100644
23779 --- a/arch/x86/kernel/vmlinux.lds.S
23780 +++ b/arch/x86/kernel/vmlinux.lds.S
23781 @@ -26,6 +26,13 @@
23782 #include <asm/page_types.h>
23783 #include <asm/cache.h>
23784 #include <asm/boot.h>
23785 +#include <asm/segment.h>
23786 +
23787 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23788 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23789 +#else
23790 +#define __KERNEL_TEXT_OFFSET 0
23791 +#endif
23792
23793 #undef i386 /* in case the preprocessor is a 32bit one */
23794
23795 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23796
23797 PHDRS {
23798 text PT_LOAD FLAGS(5); /* R_E */
23799 +#ifdef CONFIG_X86_32
23800 + module PT_LOAD FLAGS(5); /* R_E */
23801 +#endif
23802 +#ifdef CONFIG_XEN
23803 + rodata PT_LOAD FLAGS(5); /* R_E */
23804 +#else
23805 + rodata PT_LOAD FLAGS(4); /* R__ */
23806 +#endif
23807 data PT_LOAD FLAGS(6); /* RW_ */
23808 -#ifdef CONFIG_X86_64
23809 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23810 #ifdef CONFIG_SMP
23811 percpu PT_LOAD FLAGS(6); /* RW_ */
23812 #endif
23813 + text.init PT_LOAD FLAGS(5); /* R_E */
23814 + text.exit PT_LOAD FLAGS(5); /* R_E */
23815 init PT_LOAD FLAGS(7); /* RWE */
23816 -#endif
23817 note PT_NOTE FLAGS(0); /* ___ */
23818 }
23819
23820 SECTIONS
23821 {
23822 #ifdef CONFIG_X86_32
23823 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23824 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23825 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23826 #else
23827 - . = __START_KERNEL;
23828 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23829 + . = __START_KERNEL;
23830 #endif
23831
23832 /* Text and read-only data */
23833 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23834 - _text = .;
23835 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23836 /* bootstrapping code */
23837 +#ifdef CONFIG_X86_32
23838 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23839 +#else
23840 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23841 +#endif
23842 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23843 + _text = .;
23844 HEAD_TEXT
23845 #ifdef CONFIG_X86_32
23846 . = ALIGN(PAGE_SIZE);
23847 @@ -108,13 +128,48 @@ SECTIONS
23848 IRQENTRY_TEXT
23849 *(.fixup)
23850 *(.gnu.warning)
23851 - /* End of text section */
23852 - _etext = .;
23853 } :text = 0x9090
23854
23855 - NOTES :text :note
23856 + . += __KERNEL_TEXT_OFFSET;
23857
23858 - EXCEPTION_TABLE(16) :text = 0x9090
23859 +#ifdef CONFIG_X86_32
23860 + . = ALIGN(PAGE_SIZE);
23861 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23862 +
23863 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23864 + MODULES_EXEC_VADDR = .;
23865 + BYTE(0)
23866 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23867 + . = ALIGN(HPAGE_SIZE) - 1;
23868 + MODULES_EXEC_END = .;
23869 +#endif
23870 +
23871 + } :module
23872 +#endif
23873 +
23874 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23875 + /* End of text section */
23876 + BYTE(0)
23877 + _etext = . - __KERNEL_TEXT_OFFSET;
23878 + }
23879 +
23880 +#ifdef CONFIG_X86_32
23881 + . = ALIGN(PAGE_SIZE);
23882 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23883 + *(.idt)
23884 + . = ALIGN(PAGE_SIZE);
23885 + *(.empty_zero_page)
23886 + *(.initial_pg_fixmap)
23887 + *(.initial_pg_pmd)
23888 + *(.initial_page_table)
23889 + *(.swapper_pg_dir)
23890 + } :rodata
23891 +#endif
23892 +
23893 + . = ALIGN(PAGE_SIZE);
23894 + NOTES :rodata :note
23895 +
23896 + EXCEPTION_TABLE(16) :rodata
23897
23898 #if defined(CONFIG_DEBUG_RODATA)
23899 /* .text should occupy whole number of pages */
23900 @@ -126,16 +181,20 @@ SECTIONS
23901
23902 /* Data */
23903 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23904 +
23905 +#ifdef CONFIG_PAX_KERNEXEC
23906 + . = ALIGN(HPAGE_SIZE);
23907 +#else
23908 + . = ALIGN(PAGE_SIZE);
23909 +#endif
23910 +
23911 /* Start of data section */
23912 _sdata = .;
23913
23914 /* init_task */
23915 INIT_TASK_DATA(THREAD_SIZE)
23916
23917 -#ifdef CONFIG_X86_32
23918 - /* 32 bit has nosave before _edata */
23919 NOSAVE_DATA
23920 -#endif
23921
23922 PAGE_ALIGNED_DATA(PAGE_SIZE)
23923
23924 @@ -176,12 +235,19 @@ SECTIONS
23925 #endif /* CONFIG_X86_64 */
23926
23927 /* Init code and data - will be freed after init */
23928 - . = ALIGN(PAGE_SIZE);
23929 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23930 + BYTE(0)
23931 +
23932 +#ifdef CONFIG_PAX_KERNEXEC
23933 + . = ALIGN(HPAGE_SIZE);
23934 +#else
23935 + . = ALIGN(PAGE_SIZE);
23936 +#endif
23937 +
23938 __init_begin = .; /* paired with __init_end */
23939 - }
23940 + } :init.begin
23941
23942 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23943 +#ifdef CONFIG_SMP
23944 /*
23945 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23946 * output PHDR, so the next output section - .init.text - should
23947 @@ -190,12 +256,27 @@ SECTIONS
23948 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23949 #endif
23950
23951 - INIT_TEXT_SECTION(PAGE_SIZE)
23952 -#ifdef CONFIG_X86_64
23953 - :init
23954 -#endif
23955 + . = ALIGN(PAGE_SIZE);
23956 + init_begin = .;
23957 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23958 + VMLINUX_SYMBOL(_sinittext) = .;
23959 + INIT_TEXT
23960 + VMLINUX_SYMBOL(_einittext) = .;
23961 + . = ALIGN(PAGE_SIZE);
23962 + } :text.init
23963
23964 - INIT_DATA_SECTION(16)
23965 + /*
23966 + * .exit.text is discard at runtime, not link time, to deal with
23967 + * references from .altinstructions and .eh_frame
23968 + */
23969 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23970 + EXIT_TEXT
23971 + . = ALIGN(16);
23972 + } :text.exit
23973 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23974 +
23975 + . = ALIGN(PAGE_SIZE);
23976 + INIT_DATA_SECTION(16) :init
23977
23978 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23979 __x86_cpu_dev_start = .;
23980 @@ -257,19 +338,12 @@ SECTIONS
23981 }
23982
23983 . = ALIGN(8);
23984 - /*
23985 - * .exit.text is discard at runtime, not link time, to deal with
23986 - * references from .altinstructions and .eh_frame
23987 - */
23988 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23989 - EXIT_TEXT
23990 - }
23991
23992 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23993 EXIT_DATA
23994 }
23995
23996 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23997 +#ifndef CONFIG_SMP
23998 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23999 #endif
24000
24001 @@ -288,16 +362,10 @@ SECTIONS
24002 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
24003 __smp_locks = .;
24004 *(.smp_locks)
24005 - . = ALIGN(PAGE_SIZE);
24006 __smp_locks_end = .;
24007 + . = ALIGN(PAGE_SIZE);
24008 }
24009
24010 -#ifdef CONFIG_X86_64
24011 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
24012 - NOSAVE_DATA
24013 - }
24014 -#endif
24015 -
24016 /* BSS */
24017 . = ALIGN(PAGE_SIZE);
24018 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
24019 @@ -313,6 +381,7 @@ SECTIONS
24020 __brk_base = .;
24021 . += 64 * 1024; /* 64k alignment slop space */
24022 *(.brk_reservation) /* areas brk users have reserved */
24023 + . = ALIGN(HPAGE_SIZE);
24024 __brk_limit = .;
24025 }
24026
24027 @@ -339,13 +408,12 @@ SECTIONS
24028 * for the boot processor.
24029 */
24030 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
24031 -INIT_PER_CPU(gdt_page);
24032 INIT_PER_CPU(irq_stack_union);
24033
24034 /*
24035 * Build-time check on the image size:
24036 */
24037 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
24038 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
24039 "kernel image bigger than KERNEL_IMAGE_SIZE");
24040
24041 #ifdef CONFIG_SMP
24042 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
24043 index 9a907a6..f83f921 100644
24044 --- a/arch/x86/kernel/vsyscall_64.c
24045 +++ b/arch/x86/kernel/vsyscall_64.c
24046 @@ -56,15 +56,13 @@
24047 DEFINE_VVAR(int, vgetcpu_mode);
24048 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
24049
24050 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
24051 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
24052
24053 static int __init vsyscall_setup(char *str)
24054 {
24055 if (str) {
24056 if (!strcmp("emulate", str))
24057 vsyscall_mode = EMULATE;
24058 - else if (!strcmp("native", str))
24059 - vsyscall_mode = NATIVE;
24060 else if (!strcmp("none", str))
24061 vsyscall_mode = NONE;
24062 else
24063 @@ -323,8 +321,7 @@ do_ret:
24064 return true;
24065
24066 sigsegv:
24067 - force_sig(SIGSEGV, current);
24068 - return true;
24069 + do_group_exit(SIGKILL);
24070 }
24071
24072 /*
24073 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
24074 extern char __vvar_page;
24075 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
24076
24077 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
24078 - vsyscall_mode == NATIVE
24079 - ? PAGE_KERNEL_VSYSCALL
24080 - : PAGE_KERNEL_VVAR);
24081 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
24082 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
24083 (unsigned long)VSYSCALL_START);
24084
24085 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
24086 index 1330dd1..d220b99 100644
24087 --- a/arch/x86/kernel/x8664_ksyms_64.c
24088 +++ b/arch/x86/kernel/x8664_ksyms_64.c
24089 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
24090 EXPORT_SYMBOL(copy_user_generic_unrolled);
24091 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
24092 EXPORT_SYMBOL(__copy_user_nocache);
24093 -EXPORT_SYMBOL(_copy_from_user);
24094 -EXPORT_SYMBOL(_copy_to_user);
24095
24096 EXPORT_SYMBOL(copy_page);
24097 EXPORT_SYMBOL(clear_page);
24098 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
24099 index 7a3d075..6cb373d 100644
24100 --- a/arch/x86/kernel/x86_init.c
24101 +++ b/arch/x86/kernel/x86_init.c
24102 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
24103 },
24104 };
24105
24106 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24107 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
24108 .early_percpu_clock_init = x86_init_noop,
24109 .setup_percpu_clockev = setup_secondary_APIC_clock,
24110 };
24111 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24112 static void default_nmi_init(void) { };
24113 static int default_i8042_detect(void) { return 1; };
24114
24115 -struct x86_platform_ops x86_platform = {
24116 +struct x86_platform_ops x86_platform __read_only = {
24117 .calibrate_tsc = native_calibrate_tsc,
24118 .get_wallclock = mach_get_cmos_time,
24119 .set_wallclock = mach_set_rtc_mmss,
24120 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
24121 };
24122
24123 EXPORT_SYMBOL_GPL(x86_platform);
24124 -struct x86_msi_ops x86_msi = {
24125 +struct x86_msi_ops x86_msi __read_only = {
24126 .setup_msi_irqs = native_setup_msi_irqs,
24127 .teardown_msi_irq = native_teardown_msi_irq,
24128 .teardown_msi_irqs = default_teardown_msi_irqs,
24129 .restore_msi_irqs = default_restore_msi_irqs,
24130 };
24131
24132 -struct x86_io_apic_ops x86_io_apic_ops = {
24133 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
24134 .init = native_io_apic_init_mappings,
24135 .read = native_io_apic_read,
24136 .write = native_io_apic_write,
24137 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
24138 index ada87a3..afea76d 100644
24139 --- a/arch/x86/kernel/xsave.c
24140 +++ b/arch/x86/kernel/xsave.c
24141 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
24142 {
24143 int err;
24144
24145 + buf = (struct xsave_struct __user *)____m(buf);
24146 if (use_xsave())
24147 err = xsave_user(buf);
24148 else if (use_fxsr())
24149 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
24150 */
24151 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
24152 {
24153 + buf = (void __user *)____m(buf);
24154 if (use_xsave()) {
24155 if ((unsigned long)buf % 64 || fx_only) {
24156 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
24157 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
24158 index a20ecb5..d0e2194 100644
24159 --- a/arch/x86/kvm/cpuid.c
24160 +++ b/arch/x86/kvm/cpuid.c
24161 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
24162 struct kvm_cpuid2 *cpuid,
24163 struct kvm_cpuid_entry2 __user *entries)
24164 {
24165 - int r;
24166 + int r, i;
24167
24168 r = -E2BIG;
24169 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
24170 goto out;
24171 r = -EFAULT;
24172 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
24173 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24174 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24175 goto out;
24176 + for (i = 0; i < cpuid->nent; ++i) {
24177 + struct kvm_cpuid_entry2 cpuid_entry;
24178 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
24179 + goto out;
24180 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
24181 + }
24182 vcpu->arch.cpuid_nent = cpuid->nent;
24183 kvm_apic_set_version(vcpu);
24184 kvm_x86_ops->cpuid_update(vcpu);
24185 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24186 struct kvm_cpuid2 *cpuid,
24187 struct kvm_cpuid_entry2 __user *entries)
24188 {
24189 - int r;
24190 + int r, i;
24191
24192 r = -E2BIG;
24193 if (cpuid->nent < vcpu->arch.cpuid_nent)
24194 goto out;
24195 r = -EFAULT;
24196 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24197 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24198 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24199 goto out;
24200 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24201 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24202 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24203 + goto out;
24204 + }
24205 return 0;
24206
24207 out:
24208 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24209 index a27e763..54bfe43 100644
24210 --- a/arch/x86/kvm/emulate.c
24211 +++ b/arch/x86/kvm/emulate.c
24212 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24213
24214 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24215 do { \
24216 + unsigned long _tmp; \
24217 __asm__ __volatile__ ( \
24218 _PRE_EFLAGS("0", "4", "2") \
24219 _op _suffix " %"_x"3,%1; " \
24220 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24221 /* Raw emulation: instruction has two explicit operands. */
24222 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24223 do { \
24224 - unsigned long _tmp; \
24225 - \
24226 switch ((ctxt)->dst.bytes) { \
24227 case 2: \
24228 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24229 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24230
24231 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24232 do { \
24233 - unsigned long _tmp; \
24234 switch ((ctxt)->dst.bytes) { \
24235 case 1: \
24236 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24237 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24238 index 9392f52..0e56d77 100644
24239 --- a/arch/x86/kvm/lapic.c
24240 +++ b/arch/x86/kvm/lapic.c
24241 @@ -55,7 +55,7 @@
24242 #define APIC_BUS_CYCLE_NS 1
24243
24244 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24245 -#define apic_debug(fmt, arg...)
24246 +#define apic_debug(fmt, arg...) do {} while (0)
24247
24248 #define APIC_LVT_NUM 6
24249 /* 14 is the version for Xeon and Pentium 8.4.8*/
24250 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24251 index 891eb6d..e027900 100644
24252 --- a/arch/x86/kvm/paging_tmpl.h
24253 +++ b/arch/x86/kvm/paging_tmpl.h
24254 @@ -208,7 +208,7 @@ retry_walk:
24255 if (unlikely(kvm_is_error_hva(host_addr)))
24256 goto error;
24257
24258 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24259 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24260 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24261 goto error;
24262 walker->ptep_user[walker->level - 1] = ptep_user;
24263 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24264 index d29d3cd..ec9d522 100644
24265 --- a/arch/x86/kvm/svm.c
24266 +++ b/arch/x86/kvm/svm.c
24267 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24268 int cpu = raw_smp_processor_id();
24269
24270 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24271 +
24272 + pax_open_kernel();
24273 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24274 + pax_close_kernel();
24275 +
24276 load_TR_desc();
24277 }
24278
24279 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24280 #endif
24281 #endif
24282
24283 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24284 + __set_fs(current_thread_info()->addr_limit);
24285 +#endif
24286 +
24287 reload_tss(vcpu);
24288
24289 local_irq_disable();
24290 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24291 index 9120ae1..238abc0 100644
24292 --- a/arch/x86/kvm/vmx.c
24293 +++ b/arch/x86/kvm/vmx.c
24294 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
24295 struct desc_struct *descs;
24296
24297 descs = (void *)gdt->address;
24298 +
24299 + pax_open_kernel();
24300 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24301 + pax_close_kernel();
24302 +
24303 load_TR_desc();
24304 }
24305
24306 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24307 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24308 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24309
24310 +#ifdef CONFIG_PAX_PER_CPU_PGD
24311 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24312 +#endif
24313 +
24314 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24315 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24316 vmx->loaded_vmcs->cpu = cpu;
24317 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
24318 if (!cpu_has_vmx_flexpriority())
24319 flexpriority_enabled = 0;
24320
24321 - if (!cpu_has_vmx_tpr_shadow())
24322 - kvm_x86_ops->update_cr8_intercept = NULL;
24323 + if (!cpu_has_vmx_tpr_shadow()) {
24324 + pax_open_kernel();
24325 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24326 + pax_close_kernel();
24327 + }
24328
24329 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24330 kvm_disable_largepages();
24331 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
24332
24333 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24334 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24335 +
24336 +#ifndef CONFIG_PAX_PER_CPU_PGD
24337 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24338 +#endif
24339
24340 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24341 #ifdef CONFIG_X86_64
24342 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
24343 native_store_idt(&dt);
24344 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24345
24346 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24347 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24348
24349 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24350 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24351 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24352 "jmp 2f \n\t"
24353 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24354 "2: "
24355 +
24356 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24357 + "ljmp %[cs],$3f\n\t"
24358 + "3: "
24359 +#endif
24360 +
24361 /* Save guest registers, load host registers, keep flags */
24362 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24363 "pop %0 \n\t"
24364 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24365 #endif
24366 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24367 [wordsize]"i"(sizeof(ulong))
24368 +
24369 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24370 + ,[cs]"i"(__KERNEL_CS)
24371 +#endif
24372 +
24373 : "cc", "memory"
24374 #ifdef CONFIG_X86_64
24375 , "rax", "rbx", "rdi", "rsi"
24376 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24377 if (debugctlmsr)
24378 update_debugctlmsr(debugctlmsr);
24379
24380 -#ifndef CONFIG_X86_64
24381 +#ifdef CONFIG_X86_32
24382 /*
24383 * The sysexit path does not restore ds/es, so we must set them to
24384 * a reasonable value ourselves.
24385 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24386 * may be executed in interrupt context, which saves and restore segments
24387 * around it, nullifying its effect.
24388 */
24389 - loadsegment(ds, __USER_DS);
24390 - loadsegment(es, __USER_DS);
24391 + loadsegment(ds, __KERNEL_DS);
24392 + loadsegment(es, __KERNEL_DS);
24393 + loadsegment(ss, __KERNEL_DS);
24394 +
24395 +#ifdef CONFIG_PAX_KERNEXEC
24396 + loadsegment(fs, __KERNEL_PERCPU);
24397 +#endif
24398 +
24399 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24400 + __set_fs(current_thread_info()->addr_limit);
24401 +#endif
24402 +
24403 #endif
24404
24405 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24406 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24407 index c243b81..b692af3 100644
24408 --- a/arch/x86/kvm/x86.c
24409 +++ b/arch/x86/kvm/x86.c
24410 @@ -1408,10 +1408,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24411 unsigned long flags, this_tsc_khz;
24412 struct kvm_vcpu_arch *vcpu = &v->arch;
24413 struct kvm_arch *ka = &v->kvm->arch;
24414 - void *shared_kaddr;
24415 s64 kernel_ns, max_kernel_ns;
24416 u64 tsc_timestamp, host_tsc;
24417 - struct pvclock_vcpu_time_info *guest_hv_clock;
24418 + struct pvclock_vcpu_time_info guest_hv_clock;
24419 u8 pvclock_flags;
24420 bool use_master_clock;
24421
24422 @@ -1465,7 +1464,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24423
24424 local_irq_restore(flags);
24425
24426 - if (!vcpu->time_page)
24427 + if (!vcpu->pv_time_enabled)
24428 return 0;
24429
24430 /*
24431 @@ -1527,12 +1526,12 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24432 */
24433 vcpu->hv_clock.version += 2;
24434
24435 - shared_kaddr = kmap_atomic(vcpu->time_page);
24436 -
24437 - guest_hv_clock = shared_kaddr + vcpu->time_offset;
24438 + if (unlikely(kvm_read_guest_cached(v->kvm, &vcpu->pv_time,
24439 + &guest_hv_clock, sizeof(guest_hv_clock))))
24440 + return 0;
24441
24442 /* retain PVCLOCK_GUEST_STOPPED if set in guest copy */
24443 - pvclock_flags = (guest_hv_clock->flags & PVCLOCK_GUEST_STOPPED);
24444 + pvclock_flags = (guest_hv_clock.flags & PVCLOCK_GUEST_STOPPED);
24445
24446 if (vcpu->pvclock_set_guest_stopped_request) {
24447 pvclock_flags |= PVCLOCK_GUEST_STOPPED;
24448 @@ -1545,12 +1544,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24449
24450 vcpu->hv_clock.flags = pvclock_flags;
24451
24452 - memcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock,
24453 - sizeof(vcpu->hv_clock));
24454 -
24455 - kunmap_atomic(shared_kaddr);
24456 -
24457 - mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT);
24458 + kvm_write_guest_cached(v->kvm, &vcpu->pv_time,
24459 + &vcpu->hv_clock,
24460 + sizeof(vcpu->hv_clock));
24461 return 0;
24462 }
24463
24464 @@ -1692,8 +1688,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24465 {
24466 struct kvm *kvm = vcpu->kvm;
24467 int lm = is_long_mode(vcpu);
24468 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24469 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24470 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24471 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24472 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24473 : kvm->arch.xen_hvm_config.blob_size_32;
24474 u32 page_num = data & ~PAGE_MASK;
24475 @@ -1839,10 +1835,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
24476
24477 static void kvmclock_reset(struct kvm_vcpu *vcpu)
24478 {
24479 - if (vcpu->arch.time_page) {
24480 - kvm_release_page_dirty(vcpu->arch.time_page);
24481 - vcpu->arch.time_page = NULL;
24482 - }
24483 + vcpu->arch.pv_time_enabled = false;
24484 }
24485
24486 static void accumulate_steal_time(struct kvm_vcpu *vcpu)
24487 @@ -1948,6 +1941,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24488 break;
24489 case MSR_KVM_SYSTEM_TIME_NEW:
24490 case MSR_KVM_SYSTEM_TIME: {
24491 + u64 gpa_offset;
24492 kvmclock_reset(vcpu);
24493
24494 vcpu->arch.time = data;
24495 @@ -1957,14 +1951,17 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24496 if (!(data & 1))
24497 break;
24498
24499 - /* ...but clean it before doing the actual write */
24500 - vcpu->arch.time_offset = data & ~(PAGE_MASK | 1);
24501 + gpa_offset = data & ~(PAGE_MASK | 1);
24502
24503 - vcpu->arch.time_page =
24504 - gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT);
24505 + /* Check that the address is 32-byte aligned. */
24506 + if (gpa_offset & (sizeof(struct pvclock_vcpu_time_info) - 1))
24507 + break;
24508
24509 - if (is_error_page(vcpu->arch.time_page))
24510 - vcpu->arch.time_page = NULL;
24511 + if (kvm_gfn_to_hva_cache_init(vcpu->kvm,
24512 + &vcpu->arch.pv_time, data & ~1ULL))
24513 + vcpu->arch.pv_time_enabled = false;
24514 + else
24515 + vcpu->arch.pv_time_enabled = true;
24516
24517 break;
24518 }
24519 @@ -2571,6 +2568,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24520 if (n < msr_list.nmsrs)
24521 goto out;
24522 r = -EFAULT;
24523 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24524 + goto out;
24525 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24526 num_msrs_to_save * sizeof(u32)))
24527 goto out;
24528 @@ -2700,7 +2699,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24529 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24530 struct kvm_interrupt *irq)
24531 {
24532 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24533 + if (irq->irq >= KVM_NR_INTERRUPTS)
24534 return -EINVAL;
24535 if (irqchip_in_kernel(vcpu->kvm))
24536 return -ENXIO;
24537 @@ -2967,7 +2966,7 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,
24538 */
24539 static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
24540 {
24541 - if (!vcpu->arch.time_page)
24542 + if (!vcpu->arch.pv_time_enabled)
24543 return -EINVAL;
24544 vcpu->arch.pvclock_set_guest_stopped_request = true;
24545 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
24546 @@ -5213,7 +5212,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24547 };
24548 #endif
24549
24550 -int kvm_arch_init(void *opaque)
24551 +int kvm_arch_init(const void *opaque)
24552 {
24553 int r;
24554 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24555 @@ -6661,6 +6660,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
24556 goto fail_free_wbinvd_dirty_mask;
24557
24558 vcpu->arch.ia32_tsc_adjust_msr = 0x0;
24559 + vcpu->arch.pv_time_enabled = false;
24560 kvm_async_pf_hash_reset(vcpu);
24561 kvm_pmu_init(vcpu);
24562
24563 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24564 index 20a4fd4..d806083 100644
24565 --- a/arch/x86/lguest/boot.c
24566 +++ b/arch/x86/lguest/boot.c
24567 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24568 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24569 * Launcher to reboot us.
24570 */
24571 -static void lguest_restart(char *reason)
24572 +static __noreturn void lguest_restart(char *reason)
24573 {
24574 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24575 + BUG();
24576 }
24577
24578 /*G:050
24579 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24580 index 00933d5..3a64af9 100644
24581 --- a/arch/x86/lib/atomic64_386_32.S
24582 +++ b/arch/x86/lib/atomic64_386_32.S
24583 @@ -48,6 +48,10 @@ BEGIN(read)
24584 movl (v), %eax
24585 movl 4(v), %edx
24586 RET_ENDP
24587 +BEGIN(read_unchecked)
24588 + movl (v), %eax
24589 + movl 4(v), %edx
24590 +RET_ENDP
24591 #undef v
24592
24593 #define v %esi
24594 @@ -55,6 +59,10 @@ BEGIN(set)
24595 movl %ebx, (v)
24596 movl %ecx, 4(v)
24597 RET_ENDP
24598 +BEGIN(set_unchecked)
24599 + movl %ebx, (v)
24600 + movl %ecx, 4(v)
24601 +RET_ENDP
24602 #undef v
24603
24604 #define v %esi
24605 @@ -70,6 +78,20 @@ RET_ENDP
24606 BEGIN(add)
24607 addl %eax, (v)
24608 adcl %edx, 4(v)
24609 +
24610 +#ifdef CONFIG_PAX_REFCOUNT
24611 + jno 0f
24612 + subl %eax, (v)
24613 + sbbl %edx, 4(v)
24614 + int $4
24615 +0:
24616 + _ASM_EXTABLE(0b, 0b)
24617 +#endif
24618 +
24619 +RET_ENDP
24620 +BEGIN(add_unchecked)
24621 + addl %eax, (v)
24622 + adcl %edx, 4(v)
24623 RET_ENDP
24624 #undef v
24625
24626 @@ -77,6 +99,24 @@ RET_ENDP
24627 BEGIN(add_return)
24628 addl (v), %eax
24629 adcl 4(v), %edx
24630 +
24631 +#ifdef CONFIG_PAX_REFCOUNT
24632 + into
24633 +1234:
24634 + _ASM_EXTABLE(1234b, 2f)
24635 +#endif
24636 +
24637 + movl %eax, (v)
24638 + movl %edx, 4(v)
24639 +
24640 +#ifdef CONFIG_PAX_REFCOUNT
24641 +2:
24642 +#endif
24643 +
24644 +RET_ENDP
24645 +BEGIN(add_return_unchecked)
24646 + addl (v), %eax
24647 + adcl 4(v), %edx
24648 movl %eax, (v)
24649 movl %edx, 4(v)
24650 RET_ENDP
24651 @@ -86,6 +126,20 @@ RET_ENDP
24652 BEGIN(sub)
24653 subl %eax, (v)
24654 sbbl %edx, 4(v)
24655 +
24656 +#ifdef CONFIG_PAX_REFCOUNT
24657 + jno 0f
24658 + addl %eax, (v)
24659 + adcl %edx, 4(v)
24660 + int $4
24661 +0:
24662 + _ASM_EXTABLE(0b, 0b)
24663 +#endif
24664 +
24665 +RET_ENDP
24666 +BEGIN(sub_unchecked)
24667 + subl %eax, (v)
24668 + sbbl %edx, 4(v)
24669 RET_ENDP
24670 #undef v
24671
24672 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24673 sbbl $0, %edx
24674 addl (v), %eax
24675 adcl 4(v), %edx
24676 +
24677 +#ifdef CONFIG_PAX_REFCOUNT
24678 + into
24679 +1234:
24680 + _ASM_EXTABLE(1234b, 2f)
24681 +#endif
24682 +
24683 + movl %eax, (v)
24684 + movl %edx, 4(v)
24685 +
24686 +#ifdef CONFIG_PAX_REFCOUNT
24687 +2:
24688 +#endif
24689 +
24690 +RET_ENDP
24691 +BEGIN(sub_return_unchecked)
24692 + negl %edx
24693 + negl %eax
24694 + sbbl $0, %edx
24695 + addl (v), %eax
24696 + adcl 4(v), %edx
24697 movl %eax, (v)
24698 movl %edx, 4(v)
24699 RET_ENDP
24700 @@ -105,6 +180,20 @@ RET_ENDP
24701 BEGIN(inc)
24702 addl $1, (v)
24703 adcl $0, 4(v)
24704 +
24705 +#ifdef CONFIG_PAX_REFCOUNT
24706 + jno 0f
24707 + subl $1, (v)
24708 + sbbl $0, 4(v)
24709 + int $4
24710 +0:
24711 + _ASM_EXTABLE(0b, 0b)
24712 +#endif
24713 +
24714 +RET_ENDP
24715 +BEGIN(inc_unchecked)
24716 + addl $1, (v)
24717 + adcl $0, 4(v)
24718 RET_ENDP
24719 #undef v
24720
24721 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24722 movl 4(v), %edx
24723 addl $1, %eax
24724 adcl $0, %edx
24725 +
24726 +#ifdef CONFIG_PAX_REFCOUNT
24727 + into
24728 +1234:
24729 + _ASM_EXTABLE(1234b, 2f)
24730 +#endif
24731 +
24732 + movl %eax, (v)
24733 + movl %edx, 4(v)
24734 +
24735 +#ifdef CONFIG_PAX_REFCOUNT
24736 +2:
24737 +#endif
24738 +
24739 +RET_ENDP
24740 +BEGIN(inc_return_unchecked)
24741 + movl (v), %eax
24742 + movl 4(v), %edx
24743 + addl $1, %eax
24744 + adcl $0, %edx
24745 movl %eax, (v)
24746 movl %edx, 4(v)
24747 RET_ENDP
24748 @@ -123,6 +232,20 @@ RET_ENDP
24749 BEGIN(dec)
24750 subl $1, (v)
24751 sbbl $0, 4(v)
24752 +
24753 +#ifdef CONFIG_PAX_REFCOUNT
24754 + jno 0f
24755 + addl $1, (v)
24756 + adcl $0, 4(v)
24757 + int $4
24758 +0:
24759 + _ASM_EXTABLE(0b, 0b)
24760 +#endif
24761 +
24762 +RET_ENDP
24763 +BEGIN(dec_unchecked)
24764 + subl $1, (v)
24765 + sbbl $0, 4(v)
24766 RET_ENDP
24767 #undef v
24768
24769 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24770 movl 4(v), %edx
24771 subl $1, %eax
24772 sbbl $0, %edx
24773 +
24774 +#ifdef CONFIG_PAX_REFCOUNT
24775 + into
24776 +1234:
24777 + _ASM_EXTABLE(1234b, 2f)
24778 +#endif
24779 +
24780 + movl %eax, (v)
24781 + movl %edx, 4(v)
24782 +
24783 +#ifdef CONFIG_PAX_REFCOUNT
24784 +2:
24785 +#endif
24786 +
24787 +RET_ENDP
24788 +BEGIN(dec_return_unchecked)
24789 + movl (v), %eax
24790 + movl 4(v), %edx
24791 + subl $1, %eax
24792 + sbbl $0, %edx
24793 movl %eax, (v)
24794 movl %edx, 4(v)
24795 RET_ENDP
24796 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24797 adcl %edx, %edi
24798 addl (v), %eax
24799 adcl 4(v), %edx
24800 +
24801 +#ifdef CONFIG_PAX_REFCOUNT
24802 + into
24803 +1234:
24804 + _ASM_EXTABLE(1234b, 2f)
24805 +#endif
24806 +
24807 cmpl %eax, %ecx
24808 je 3f
24809 1:
24810 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24811 1:
24812 addl $1, %eax
24813 adcl $0, %edx
24814 +
24815 +#ifdef CONFIG_PAX_REFCOUNT
24816 + into
24817 +1234:
24818 + _ASM_EXTABLE(1234b, 2f)
24819 +#endif
24820 +
24821 movl %eax, (v)
24822 movl %edx, 4(v)
24823 movl $1, %eax
24824 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24825 movl 4(v), %edx
24826 subl $1, %eax
24827 sbbl $0, %edx
24828 +
24829 +#ifdef CONFIG_PAX_REFCOUNT
24830 + into
24831 +1234:
24832 + _ASM_EXTABLE(1234b, 1f)
24833 +#endif
24834 +
24835 js 1f
24836 movl %eax, (v)
24837 movl %edx, 4(v)
24838 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24839 index f5cc9eb..51fa319 100644
24840 --- a/arch/x86/lib/atomic64_cx8_32.S
24841 +++ b/arch/x86/lib/atomic64_cx8_32.S
24842 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24843 CFI_STARTPROC
24844
24845 read64 %ecx
24846 + pax_force_retaddr
24847 ret
24848 CFI_ENDPROC
24849 ENDPROC(atomic64_read_cx8)
24850
24851 +ENTRY(atomic64_read_unchecked_cx8)
24852 + CFI_STARTPROC
24853 +
24854 + read64 %ecx
24855 + pax_force_retaddr
24856 + ret
24857 + CFI_ENDPROC
24858 +ENDPROC(atomic64_read_unchecked_cx8)
24859 +
24860 ENTRY(atomic64_set_cx8)
24861 CFI_STARTPROC
24862
24863 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24864 cmpxchg8b (%esi)
24865 jne 1b
24866
24867 + pax_force_retaddr
24868 ret
24869 CFI_ENDPROC
24870 ENDPROC(atomic64_set_cx8)
24871
24872 +ENTRY(atomic64_set_unchecked_cx8)
24873 + CFI_STARTPROC
24874 +
24875 +1:
24876 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24877 + * are atomic on 586 and newer */
24878 + cmpxchg8b (%esi)
24879 + jne 1b
24880 +
24881 + pax_force_retaddr
24882 + ret
24883 + CFI_ENDPROC
24884 +ENDPROC(atomic64_set_unchecked_cx8)
24885 +
24886 ENTRY(atomic64_xchg_cx8)
24887 CFI_STARTPROC
24888
24889 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24890 cmpxchg8b (%esi)
24891 jne 1b
24892
24893 + pax_force_retaddr
24894 ret
24895 CFI_ENDPROC
24896 ENDPROC(atomic64_xchg_cx8)
24897
24898 -.macro addsub_return func ins insc
24899 -ENTRY(atomic64_\func\()_return_cx8)
24900 +.macro addsub_return func ins insc unchecked=""
24901 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24902 CFI_STARTPROC
24903 SAVE ebp
24904 SAVE ebx
24905 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24906 movl %edx, %ecx
24907 \ins\()l %esi, %ebx
24908 \insc\()l %edi, %ecx
24909 +
24910 +.ifb \unchecked
24911 +#ifdef CONFIG_PAX_REFCOUNT
24912 + into
24913 +2:
24914 + _ASM_EXTABLE(2b, 3f)
24915 +#endif
24916 +.endif
24917 +
24918 LOCK_PREFIX
24919 cmpxchg8b (%ebp)
24920 jne 1b
24921 -
24922 -10:
24923 movl %ebx, %eax
24924 movl %ecx, %edx
24925 +
24926 +.ifb \unchecked
24927 +#ifdef CONFIG_PAX_REFCOUNT
24928 +3:
24929 +#endif
24930 +.endif
24931 +
24932 RESTORE edi
24933 RESTORE esi
24934 RESTORE ebx
24935 RESTORE ebp
24936 + pax_force_retaddr
24937 ret
24938 CFI_ENDPROC
24939 -ENDPROC(atomic64_\func\()_return_cx8)
24940 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24941 .endm
24942
24943 addsub_return add add adc
24944 addsub_return sub sub sbb
24945 +addsub_return add add adc _unchecked
24946 +addsub_return sub sub sbb _unchecked
24947
24948 -.macro incdec_return func ins insc
24949 -ENTRY(atomic64_\func\()_return_cx8)
24950 +.macro incdec_return func ins insc unchecked=""
24951 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24952 CFI_STARTPROC
24953 SAVE ebx
24954
24955 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24956 movl %edx, %ecx
24957 \ins\()l $1, %ebx
24958 \insc\()l $0, %ecx
24959 +
24960 +.ifb \unchecked
24961 +#ifdef CONFIG_PAX_REFCOUNT
24962 + into
24963 +2:
24964 + _ASM_EXTABLE(2b, 3f)
24965 +#endif
24966 +.endif
24967 +
24968 LOCK_PREFIX
24969 cmpxchg8b (%esi)
24970 jne 1b
24971
24972 -10:
24973 movl %ebx, %eax
24974 movl %ecx, %edx
24975 +
24976 +.ifb \unchecked
24977 +#ifdef CONFIG_PAX_REFCOUNT
24978 +3:
24979 +#endif
24980 +.endif
24981 +
24982 RESTORE ebx
24983 + pax_force_retaddr
24984 ret
24985 CFI_ENDPROC
24986 -ENDPROC(atomic64_\func\()_return_cx8)
24987 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24988 .endm
24989
24990 incdec_return inc add adc
24991 incdec_return dec sub sbb
24992 +incdec_return inc add adc _unchecked
24993 +incdec_return dec sub sbb _unchecked
24994
24995 ENTRY(atomic64_dec_if_positive_cx8)
24996 CFI_STARTPROC
24997 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24998 movl %edx, %ecx
24999 subl $1, %ebx
25000 sbb $0, %ecx
25001 +
25002 +#ifdef CONFIG_PAX_REFCOUNT
25003 + into
25004 +1234:
25005 + _ASM_EXTABLE(1234b, 2f)
25006 +#endif
25007 +
25008 js 2f
25009 LOCK_PREFIX
25010 cmpxchg8b (%esi)
25011 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
25012 movl %ebx, %eax
25013 movl %ecx, %edx
25014 RESTORE ebx
25015 + pax_force_retaddr
25016 ret
25017 CFI_ENDPROC
25018 ENDPROC(atomic64_dec_if_positive_cx8)
25019 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
25020 movl %edx, %ecx
25021 addl %ebp, %ebx
25022 adcl %edi, %ecx
25023 +
25024 +#ifdef CONFIG_PAX_REFCOUNT
25025 + into
25026 +1234:
25027 + _ASM_EXTABLE(1234b, 3f)
25028 +#endif
25029 +
25030 LOCK_PREFIX
25031 cmpxchg8b (%esi)
25032 jne 1b
25033 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
25034 CFI_ADJUST_CFA_OFFSET -8
25035 RESTORE ebx
25036 RESTORE ebp
25037 + pax_force_retaddr
25038 ret
25039 4:
25040 cmpl %edx, 4(%esp)
25041 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
25042 xorl %ecx, %ecx
25043 addl $1, %ebx
25044 adcl %edx, %ecx
25045 +
25046 +#ifdef CONFIG_PAX_REFCOUNT
25047 + into
25048 +1234:
25049 + _ASM_EXTABLE(1234b, 3f)
25050 +#endif
25051 +
25052 LOCK_PREFIX
25053 cmpxchg8b (%esi)
25054 jne 1b
25055 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
25056 movl $1, %eax
25057 3:
25058 RESTORE ebx
25059 + pax_force_retaddr
25060 ret
25061 CFI_ENDPROC
25062 ENDPROC(atomic64_inc_not_zero_cx8)
25063 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
25064 index 2af5df3..62b1a5a 100644
25065 --- a/arch/x86/lib/checksum_32.S
25066 +++ b/arch/x86/lib/checksum_32.S
25067 @@ -29,7 +29,8 @@
25068 #include <asm/dwarf2.h>
25069 #include <asm/errno.h>
25070 #include <asm/asm.h>
25071 -
25072 +#include <asm/segment.h>
25073 +
25074 /*
25075 * computes a partial checksum, e.g. for TCP/UDP fragments
25076 */
25077 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
25078
25079 #define ARGBASE 16
25080 #define FP 12
25081 -
25082 -ENTRY(csum_partial_copy_generic)
25083 +
25084 +ENTRY(csum_partial_copy_generic_to_user)
25085 CFI_STARTPROC
25086 +
25087 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25088 + pushl_cfi %gs
25089 + popl_cfi %es
25090 + jmp csum_partial_copy_generic
25091 +#endif
25092 +
25093 +ENTRY(csum_partial_copy_generic_from_user)
25094 +
25095 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25096 + pushl_cfi %gs
25097 + popl_cfi %ds
25098 +#endif
25099 +
25100 +ENTRY(csum_partial_copy_generic)
25101 subl $4,%esp
25102 CFI_ADJUST_CFA_OFFSET 4
25103 pushl_cfi %edi
25104 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
25105 jmp 4f
25106 SRC(1: movw (%esi), %bx )
25107 addl $2, %esi
25108 -DST( movw %bx, (%edi) )
25109 +DST( movw %bx, %es:(%edi) )
25110 addl $2, %edi
25111 addw %bx, %ax
25112 adcl $0, %eax
25113 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
25114 SRC(1: movl (%esi), %ebx )
25115 SRC( movl 4(%esi), %edx )
25116 adcl %ebx, %eax
25117 -DST( movl %ebx, (%edi) )
25118 +DST( movl %ebx, %es:(%edi) )
25119 adcl %edx, %eax
25120 -DST( movl %edx, 4(%edi) )
25121 +DST( movl %edx, %es:4(%edi) )
25122
25123 SRC( movl 8(%esi), %ebx )
25124 SRC( movl 12(%esi), %edx )
25125 adcl %ebx, %eax
25126 -DST( movl %ebx, 8(%edi) )
25127 +DST( movl %ebx, %es:8(%edi) )
25128 adcl %edx, %eax
25129 -DST( movl %edx, 12(%edi) )
25130 +DST( movl %edx, %es:12(%edi) )
25131
25132 SRC( movl 16(%esi), %ebx )
25133 SRC( movl 20(%esi), %edx )
25134 adcl %ebx, %eax
25135 -DST( movl %ebx, 16(%edi) )
25136 +DST( movl %ebx, %es:16(%edi) )
25137 adcl %edx, %eax
25138 -DST( movl %edx, 20(%edi) )
25139 +DST( movl %edx, %es:20(%edi) )
25140
25141 SRC( movl 24(%esi), %ebx )
25142 SRC( movl 28(%esi), %edx )
25143 adcl %ebx, %eax
25144 -DST( movl %ebx, 24(%edi) )
25145 +DST( movl %ebx, %es:24(%edi) )
25146 adcl %edx, %eax
25147 -DST( movl %edx, 28(%edi) )
25148 +DST( movl %edx, %es:28(%edi) )
25149
25150 lea 32(%esi), %esi
25151 lea 32(%edi), %edi
25152 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
25153 shrl $2, %edx # This clears CF
25154 SRC(3: movl (%esi), %ebx )
25155 adcl %ebx, %eax
25156 -DST( movl %ebx, (%edi) )
25157 +DST( movl %ebx, %es:(%edi) )
25158 lea 4(%esi), %esi
25159 lea 4(%edi), %edi
25160 dec %edx
25161 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
25162 jb 5f
25163 SRC( movw (%esi), %cx )
25164 leal 2(%esi), %esi
25165 -DST( movw %cx, (%edi) )
25166 +DST( movw %cx, %es:(%edi) )
25167 leal 2(%edi), %edi
25168 je 6f
25169 shll $16,%ecx
25170 SRC(5: movb (%esi), %cl )
25171 -DST( movb %cl, (%edi) )
25172 +DST( movb %cl, %es:(%edi) )
25173 6: addl %ecx, %eax
25174 adcl $0, %eax
25175 7:
25176 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
25177
25178 6001:
25179 movl ARGBASE+20(%esp), %ebx # src_err_ptr
25180 - movl $-EFAULT, (%ebx)
25181 + movl $-EFAULT, %ss:(%ebx)
25182
25183 # zero the complete destination - computing the rest
25184 # is too much work
25185 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
25186
25187 6002:
25188 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25189 - movl $-EFAULT,(%ebx)
25190 + movl $-EFAULT,%ss:(%ebx)
25191 jmp 5000b
25192
25193 .previous
25194
25195 + pushl_cfi %ss
25196 + popl_cfi %ds
25197 + pushl_cfi %ss
25198 + popl_cfi %es
25199 popl_cfi %ebx
25200 CFI_RESTORE ebx
25201 popl_cfi %esi
25202 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
25203 popl_cfi %ecx # equivalent to addl $4,%esp
25204 ret
25205 CFI_ENDPROC
25206 -ENDPROC(csum_partial_copy_generic)
25207 +ENDPROC(csum_partial_copy_generic_to_user)
25208
25209 #else
25210
25211 /* Version for PentiumII/PPro */
25212
25213 #define ROUND1(x) \
25214 + nop; nop; nop; \
25215 SRC(movl x(%esi), %ebx ) ; \
25216 addl %ebx, %eax ; \
25217 - DST(movl %ebx, x(%edi) ) ;
25218 + DST(movl %ebx, %es:x(%edi)) ;
25219
25220 #define ROUND(x) \
25221 + nop; nop; nop; \
25222 SRC(movl x(%esi), %ebx ) ; \
25223 adcl %ebx, %eax ; \
25224 - DST(movl %ebx, x(%edi) ) ;
25225 + DST(movl %ebx, %es:x(%edi)) ;
25226
25227 #define ARGBASE 12
25228 -
25229 -ENTRY(csum_partial_copy_generic)
25230 +
25231 +ENTRY(csum_partial_copy_generic_to_user)
25232 CFI_STARTPROC
25233 +
25234 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25235 + pushl_cfi %gs
25236 + popl_cfi %es
25237 + jmp csum_partial_copy_generic
25238 +#endif
25239 +
25240 +ENTRY(csum_partial_copy_generic_from_user)
25241 +
25242 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25243 + pushl_cfi %gs
25244 + popl_cfi %ds
25245 +#endif
25246 +
25247 +ENTRY(csum_partial_copy_generic)
25248 pushl_cfi %ebx
25249 CFI_REL_OFFSET ebx, 0
25250 pushl_cfi %edi
25251 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
25252 subl %ebx, %edi
25253 lea -1(%esi),%edx
25254 andl $-32,%edx
25255 - lea 3f(%ebx,%ebx), %ebx
25256 + lea 3f(%ebx,%ebx,2), %ebx
25257 testl %esi, %esi
25258 jmp *%ebx
25259 1: addl $64,%esi
25260 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
25261 jb 5f
25262 SRC( movw (%esi), %dx )
25263 leal 2(%esi), %esi
25264 -DST( movw %dx, (%edi) )
25265 +DST( movw %dx, %es:(%edi) )
25266 leal 2(%edi), %edi
25267 je 6f
25268 shll $16,%edx
25269 5:
25270 SRC( movb (%esi), %dl )
25271 -DST( movb %dl, (%edi) )
25272 +DST( movb %dl, %es:(%edi) )
25273 6: addl %edx, %eax
25274 adcl $0, %eax
25275 7:
25276 .section .fixup, "ax"
25277 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25278 - movl $-EFAULT, (%ebx)
25279 + movl $-EFAULT, %ss:(%ebx)
25280 # zero the complete destination (computing the rest is too much work)
25281 movl ARGBASE+8(%esp),%edi # dst
25282 movl ARGBASE+12(%esp),%ecx # len
25283 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25284 rep; stosb
25285 jmp 7b
25286 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25287 - movl $-EFAULT, (%ebx)
25288 + movl $-EFAULT, %ss:(%ebx)
25289 jmp 7b
25290 .previous
25291
25292 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25293 + pushl_cfi %ss
25294 + popl_cfi %ds
25295 + pushl_cfi %ss
25296 + popl_cfi %es
25297 +#endif
25298 +
25299 popl_cfi %esi
25300 CFI_RESTORE esi
25301 popl_cfi %edi
25302 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25303 CFI_RESTORE ebx
25304 ret
25305 CFI_ENDPROC
25306 -ENDPROC(csum_partial_copy_generic)
25307 +ENDPROC(csum_partial_copy_generic_to_user)
25308
25309 #undef ROUND
25310 #undef ROUND1
25311 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25312 index f2145cf..cea889d 100644
25313 --- a/arch/x86/lib/clear_page_64.S
25314 +++ b/arch/x86/lib/clear_page_64.S
25315 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25316 movl $4096/8,%ecx
25317 xorl %eax,%eax
25318 rep stosq
25319 + pax_force_retaddr
25320 ret
25321 CFI_ENDPROC
25322 ENDPROC(clear_page_c)
25323 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25324 movl $4096,%ecx
25325 xorl %eax,%eax
25326 rep stosb
25327 + pax_force_retaddr
25328 ret
25329 CFI_ENDPROC
25330 ENDPROC(clear_page_c_e)
25331 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25332 leaq 64(%rdi),%rdi
25333 jnz .Lloop
25334 nop
25335 + pax_force_retaddr
25336 ret
25337 CFI_ENDPROC
25338 .Lclear_page_end:
25339 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25340
25341 #include <asm/cpufeature.h>
25342
25343 - .section .altinstr_replacement,"ax"
25344 + .section .altinstr_replacement,"a"
25345 1: .byte 0xeb /* jmp <disp8> */
25346 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25347 2: .byte 0xeb /* jmp <disp8> */
25348 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25349 index 1e572c5..2a162cd 100644
25350 --- a/arch/x86/lib/cmpxchg16b_emu.S
25351 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25352 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25353
25354 popf
25355 mov $1, %al
25356 + pax_force_retaddr
25357 ret
25358
25359 not_same:
25360 popf
25361 xor %al,%al
25362 + pax_force_retaddr
25363 ret
25364
25365 CFI_ENDPROC
25366 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25367 index 176cca6..1166c50 100644
25368 --- a/arch/x86/lib/copy_page_64.S
25369 +++ b/arch/x86/lib/copy_page_64.S
25370 @@ -9,6 +9,7 @@ copy_page_rep:
25371 CFI_STARTPROC
25372 movl $4096/8, %ecx
25373 rep movsq
25374 + pax_force_retaddr
25375 ret
25376 CFI_ENDPROC
25377 ENDPROC(copy_page_rep)
25378 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25379
25380 ENTRY(copy_page)
25381 CFI_STARTPROC
25382 - subq $2*8, %rsp
25383 - CFI_ADJUST_CFA_OFFSET 2*8
25384 + subq $3*8, %rsp
25385 + CFI_ADJUST_CFA_OFFSET 3*8
25386 movq %rbx, (%rsp)
25387 CFI_REL_OFFSET rbx, 0
25388 movq %r12, 1*8(%rsp)
25389 CFI_REL_OFFSET r12, 1*8
25390 + movq %r13, 2*8(%rsp)
25391 + CFI_REL_OFFSET r13, 2*8
25392
25393 movl $(4096/64)-5, %ecx
25394 .p2align 4
25395 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25396 movq 0x8*2(%rsi), %rdx
25397 movq 0x8*3(%rsi), %r8
25398 movq 0x8*4(%rsi), %r9
25399 - movq 0x8*5(%rsi), %r10
25400 + movq 0x8*5(%rsi), %r13
25401 movq 0x8*6(%rsi), %r11
25402 movq 0x8*7(%rsi), %r12
25403
25404 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25405 movq %rdx, 0x8*2(%rdi)
25406 movq %r8, 0x8*3(%rdi)
25407 movq %r9, 0x8*4(%rdi)
25408 - movq %r10, 0x8*5(%rdi)
25409 + movq %r13, 0x8*5(%rdi)
25410 movq %r11, 0x8*6(%rdi)
25411 movq %r12, 0x8*7(%rdi)
25412
25413 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25414 movq 0x8*2(%rsi), %rdx
25415 movq 0x8*3(%rsi), %r8
25416 movq 0x8*4(%rsi), %r9
25417 - movq 0x8*5(%rsi), %r10
25418 + movq 0x8*5(%rsi), %r13
25419 movq 0x8*6(%rsi), %r11
25420 movq 0x8*7(%rsi), %r12
25421
25422 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25423 movq %rdx, 0x8*2(%rdi)
25424 movq %r8, 0x8*3(%rdi)
25425 movq %r9, 0x8*4(%rdi)
25426 - movq %r10, 0x8*5(%rdi)
25427 + movq %r13, 0x8*5(%rdi)
25428 movq %r11, 0x8*6(%rdi)
25429 movq %r12, 0x8*7(%rdi)
25430
25431 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25432 CFI_RESTORE rbx
25433 movq 1*8(%rsp), %r12
25434 CFI_RESTORE r12
25435 - addq $2*8, %rsp
25436 - CFI_ADJUST_CFA_OFFSET -2*8
25437 + movq 2*8(%rsp), %r13
25438 + CFI_RESTORE r13
25439 + addq $3*8, %rsp
25440 + CFI_ADJUST_CFA_OFFSET -3*8
25441 + pax_force_retaddr
25442 ret
25443 .Lcopy_page_end:
25444 CFI_ENDPROC
25445 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25446
25447 #include <asm/cpufeature.h>
25448
25449 - .section .altinstr_replacement,"ax"
25450 + .section .altinstr_replacement,"a"
25451 1: .byte 0xeb /* jmp <disp8> */
25452 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25453 2:
25454 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25455 index a30ca15..d25fab6 100644
25456 --- a/arch/x86/lib/copy_user_64.S
25457 +++ b/arch/x86/lib/copy_user_64.S
25458 @@ -18,6 +18,7 @@
25459 #include <asm/alternative-asm.h>
25460 #include <asm/asm.h>
25461 #include <asm/smap.h>
25462 +#include <asm/pgtable.h>
25463
25464 /*
25465 * By placing feature2 after feature1 in altinstructions section, we logically
25466 @@ -31,7 +32,7 @@
25467 .byte 0xe9 /* 32bit jump */
25468 .long \orig-1f /* by default jump to orig */
25469 1:
25470 - .section .altinstr_replacement,"ax"
25471 + .section .altinstr_replacement,"a"
25472 2: .byte 0xe9 /* near jump with 32bit immediate */
25473 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25474 3: .byte 0xe9 /* near jump with 32bit immediate */
25475 @@ -70,47 +71,20 @@
25476 #endif
25477 .endm
25478
25479 -/* Standard copy_to_user with segment limit checking */
25480 -ENTRY(_copy_to_user)
25481 - CFI_STARTPROC
25482 - GET_THREAD_INFO(%rax)
25483 - movq %rdi,%rcx
25484 - addq %rdx,%rcx
25485 - jc bad_to_user
25486 - cmpq TI_addr_limit(%rax),%rcx
25487 - ja bad_to_user
25488 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25489 - copy_user_generic_unrolled,copy_user_generic_string, \
25490 - copy_user_enhanced_fast_string
25491 - CFI_ENDPROC
25492 -ENDPROC(_copy_to_user)
25493 -
25494 -/* Standard copy_from_user with segment limit checking */
25495 -ENTRY(_copy_from_user)
25496 - CFI_STARTPROC
25497 - GET_THREAD_INFO(%rax)
25498 - movq %rsi,%rcx
25499 - addq %rdx,%rcx
25500 - jc bad_from_user
25501 - cmpq TI_addr_limit(%rax),%rcx
25502 - ja bad_from_user
25503 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25504 - copy_user_generic_unrolled,copy_user_generic_string, \
25505 - copy_user_enhanced_fast_string
25506 - CFI_ENDPROC
25507 -ENDPROC(_copy_from_user)
25508 -
25509 .section .fixup,"ax"
25510 /* must zero dest */
25511 ENTRY(bad_from_user)
25512 bad_from_user:
25513 CFI_STARTPROC
25514 + testl %edx,%edx
25515 + js bad_to_user
25516 movl %edx,%ecx
25517 xorl %eax,%eax
25518 rep
25519 stosb
25520 bad_to_user:
25521 movl %edx,%eax
25522 + pax_force_retaddr
25523 ret
25524 CFI_ENDPROC
25525 ENDPROC(bad_from_user)
25526 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25527 jz 17f
25528 1: movq (%rsi),%r8
25529 2: movq 1*8(%rsi),%r9
25530 -3: movq 2*8(%rsi),%r10
25531 +3: movq 2*8(%rsi),%rax
25532 4: movq 3*8(%rsi),%r11
25533 5: movq %r8,(%rdi)
25534 6: movq %r9,1*8(%rdi)
25535 -7: movq %r10,2*8(%rdi)
25536 +7: movq %rax,2*8(%rdi)
25537 8: movq %r11,3*8(%rdi)
25538 9: movq 4*8(%rsi),%r8
25539 10: movq 5*8(%rsi),%r9
25540 -11: movq 6*8(%rsi),%r10
25541 +11: movq 6*8(%rsi),%rax
25542 12: movq 7*8(%rsi),%r11
25543 13: movq %r8,4*8(%rdi)
25544 14: movq %r9,5*8(%rdi)
25545 -15: movq %r10,6*8(%rdi)
25546 +15: movq %rax,6*8(%rdi)
25547 16: movq %r11,7*8(%rdi)
25548 leaq 64(%rsi),%rsi
25549 leaq 64(%rdi),%rdi
25550 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25551 jnz 21b
25552 23: xor %eax,%eax
25553 ASM_CLAC
25554 + pax_force_retaddr
25555 ret
25556
25557 .section .fixup,"ax"
25558 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25559 movsb
25560 4: xorl %eax,%eax
25561 ASM_CLAC
25562 + pax_force_retaddr
25563 ret
25564
25565 .section .fixup,"ax"
25566 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25567 movsb
25568 2: xorl %eax,%eax
25569 ASM_CLAC
25570 + pax_force_retaddr
25571 ret
25572
25573 .section .fixup,"ax"
25574 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25575 index 6a4f43c..f5f9e26 100644
25576 --- a/arch/x86/lib/copy_user_nocache_64.S
25577 +++ b/arch/x86/lib/copy_user_nocache_64.S
25578 @@ -8,6 +8,7 @@
25579
25580 #include <linux/linkage.h>
25581 #include <asm/dwarf2.h>
25582 +#include <asm/alternative-asm.h>
25583
25584 #define FIX_ALIGNMENT 1
25585
25586 @@ -16,6 +17,7 @@
25587 #include <asm/thread_info.h>
25588 #include <asm/asm.h>
25589 #include <asm/smap.h>
25590 +#include <asm/pgtable.h>
25591
25592 .macro ALIGN_DESTINATION
25593 #ifdef FIX_ALIGNMENT
25594 @@ -49,6 +51,15 @@
25595 */
25596 ENTRY(__copy_user_nocache)
25597 CFI_STARTPROC
25598 +
25599 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25600 + mov $PAX_USER_SHADOW_BASE,%rcx
25601 + cmp %rcx,%rsi
25602 + jae 1f
25603 + add %rcx,%rsi
25604 +1:
25605 +#endif
25606 +
25607 ASM_STAC
25608 cmpl $8,%edx
25609 jb 20f /* less then 8 bytes, go to byte copy loop */
25610 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25611 jz 17f
25612 1: movq (%rsi),%r8
25613 2: movq 1*8(%rsi),%r9
25614 -3: movq 2*8(%rsi),%r10
25615 +3: movq 2*8(%rsi),%rax
25616 4: movq 3*8(%rsi),%r11
25617 5: movnti %r8,(%rdi)
25618 6: movnti %r9,1*8(%rdi)
25619 -7: movnti %r10,2*8(%rdi)
25620 +7: movnti %rax,2*8(%rdi)
25621 8: movnti %r11,3*8(%rdi)
25622 9: movq 4*8(%rsi),%r8
25623 10: movq 5*8(%rsi),%r9
25624 -11: movq 6*8(%rsi),%r10
25625 +11: movq 6*8(%rsi),%rax
25626 12: movq 7*8(%rsi),%r11
25627 13: movnti %r8,4*8(%rdi)
25628 14: movnti %r9,5*8(%rdi)
25629 -15: movnti %r10,6*8(%rdi)
25630 +15: movnti %rax,6*8(%rdi)
25631 16: movnti %r11,7*8(%rdi)
25632 leaq 64(%rsi),%rsi
25633 leaq 64(%rdi),%rdi
25634 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25635 23: xorl %eax,%eax
25636 ASM_CLAC
25637 sfence
25638 + pax_force_retaddr
25639 ret
25640
25641 .section .fixup,"ax"
25642 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25643 index 2419d5f..953ee51 100644
25644 --- a/arch/x86/lib/csum-copy_64.S
25645 +++ b/arch/x86/lib/csum-copy_64.S
25646 @@ -9,6 +9,7 @@
25647 #include <asm/dwarf2.h>
25648 #include <asm/errno.h>
25649 #include <asm/asm.h>
25650 +#include <asm/alternative-asm.h>
25651
25652 /*
25653 * Checksum copy with exception handling.
25654 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25655 CFI_RESTORE rbp
25656 addq $7*8, %rsp
25657 CFI_ADJUST_CFA_OFFSET -7*8
25658 + pax_force_retaddr 0, 1
25659 ret
25660 CFI_RESTORE_STATE
25661
25662 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25663 index 25b7ae8..169fafc 100644
25664 --- a/arch/x86/lib/csum-wrappers_64.c
25665 +++ b/arch/x86/lib/csum-wrappers_64.c
25666 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25667 len -= 2;
25668 }
25669 }
25670 - isum = csum_partial_copy_generic((__force const void *)src,
25671 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25672 dst, len, isum, errp, NULL);
25673 if (unlikely(*errp))
25674 goto out_err;
25675 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25676 }
25677
25678 *errp = 0;
25679 - return csum_partial_copy_generic(src, (void __force *)dst,
25680 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25681 len, isum, NULL, errp);
25682 }
25683 EXPORT_SYMBOL(csum_partial_copy_to_user);
25684 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25685 index 156b9c8..b144132 100644
25686 --- a/arch/x86/lib/getuser.S
25687 +++ b/arch/x86/lib/getuser.S
25688 @@ -34,17 +34,40 @@
25689 #include <asm/thread_info.h>
25690 #include <asm/asm.h>
25691 #include <asm/smap.h>
25692 +#include <asm/segment.h>
25693 +#include <asm/pgtable.h>
25694 +#include <asm/alternative-asm.h>
25695 +
25696 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25697 +#define __copyuser_seg gs;
25698 +#else
25699 +#define __copyuser_seg
25700 +#endif
25701
25702 .text
25703 ENTRY(__get_user_1)
25704 CFI_STARTPROC
25705 +
25706 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25707 GET_THREAD_INFO(%_ASM_DX)
25708 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25709 jae bad_get_user
25710 ASM_STAC
25711 -1: movzb (%_ASM_AX),%edx
25712 +
25713 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25714 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25715 + cmp %_ASM_DX,%_ASM_AX
25716 + jae 1234f
25717 + add %_ASM_DX,%_ASM_AX
25718 +1234:
25719 +#endif
25720 +
25721 +#endif
25722 +
25723 +1: __copyuser_seg movzb (%_ASM_AX),%edx
25724 xor %eax,%eax
25725 ASM_CLAC
25726 + pax_force_retaddr
25727 ret
25728 CFI_ENDPROC
25729 ENDPROC(__get_user_1)
25730 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
25731 ENTRY(__get_user_2)
25732 CFI_STARTPROC
25733 add $1,%_ASM_AX
25734 +
25735 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25736 jc bad_get_user
25737 GET_THREAD_INFO(%_ASM_DX)
25738 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25739 jae bad_get_user
25740 ASM_STAC
25741 -2: movzwl -1(%_ASM_AX),%edx
25742 +
25743 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25744 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25745 + cmp %_ASM_DX,%_ASM_AX
25746 + jae 1234f
25747 + add %_ASM_DX,%_ASM_AX
25748 +1234:
25749 +#endif
25750 +
25751 +#endif
25752 +
25753 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25754 xor %eax,%eax
25755 ASM_CLAC
25756 + pax_force_retaddr
25757 ret
25758 CFI_ENDPROC
25759 ENDPROC(__get_user_2)
25760 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
25761 ENTRY(__get_user_4)
25762 CFI_STARTPROC
25763 add $3,%_ASM_AX
25764 +
25765 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25766 jc bad_get_user
25767 GET_THREAD_INFO(%_ASM_DX)
25768 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25769 jae bad_get_user
25770 ASM_STAC
25771 -3: mov -3(%_ASM_AX),%edx
25772 +
25773 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25774 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25775 + cmp %_ASM_DX,%_ASM_AX
25776 + jae 1234f
25777 + add %_ASM_DX,%_ASM_AX
25778 +1234:
25779 +#endif
25780 +
25781 +#endif
25782 +
25783 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
25784 xor %eax,%eax
25785 ASM_CLAC
25786 + pax_force_retaddr
25787 ret
25788 CFI_ENDPROC
25789 ENDPROC(__get_user_4)
25790 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
25791 GET_THREAD_INFO(%_ASM_DX)
25792 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25793 jae bad_get_user
25794 +
25795 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25796 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25797 + cmp %_ASM_DX,%_ASM_AX
25798 + jae 1234f
25799 + add %_ASM_DX,%_ASM_AX
25800 +1234:
25801 +#endif
25802 +
25803 ASM_STAC
25804 4: movq -7(%_ASM_AX),%_ASM_DX
25805 xor %eax,%eax
25806 ASM_CLAC
25807 + pax_force_retaddr
25808 ret
25809 CFI_ENDPROC
25810 ENDPROC(__get_user_8)
25811 @@ -101,6 +162,7 @@ bad_get_user:
25812 xor %edx,%edx
25813 mov $(-EFAULT),%_ASM_AX
25814 ASM_CLAC
25815 + pax_force_retaddr
25816 ret
25817 CFI_ENDPROC
25818 END(bad_get_user)
25819 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25820 index 54fcffe..7be149e 100644
25821 --- a/arch/x86/lib/insn.c
25822 +++ b/arch/x86/lib/insn.c
25823 @@ -20,8 +20,10 @@
25824
25825 #ifdef __KERNEL__
25826 #include <linux/string.h>
25827 +#include <asm/pgtable_types.h>
25828 #else
25829 #include <string.h>
25830 +#define ktla_ktva(addr) addr
25831 #endif
25832 #include <asm/inat.h>
25833 #include <asm/insn.h>
25834 @@ -53,8 +55,8 @@
25835 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25836 {
25837 memset(insn, 0, sizeof(*insn));
25838 - insn->kaddr = kaddr;
25839 - insn->next_byte = kaddr;
25840 + insn->kaddr = ktla_ktva(kaddr);
25841 + insn->next_byte = ktla_ktva(kaddr);
25842 insn->x86_64 = x86_64 ? 1 : 0;
25843 insn->opnd_bytes = 4;
25844 if (x86_64)
25845 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25846 index 05a95e7..326f2fa 100644
25847 --- a/arch/x86/lib/iomap_copy_64.S
25848 +++ b/arch/x86/lib/iomap_copy_64.S
25849 @@ -17,6 +17,7 @@
25850
25851 #include <linux/linkage.h>
25852 #include <asm/dwarf2.h>
25853 +#include <asm/alternative-asm.h>
25854
25855 /*
25856 * override generic version in lib/iomap_copy.c
25857 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25858 CFI_STARTPROC
25859 movl %edx,%ecx
25860 rep movsd
25861 + pax_force_retaddr
25862 ret
25863 CFI_ENDPROC
25864 ENDPROC(__iowrite32_copy)
25865 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25866 index 1c273be..da9cc0e 100644
25867 --- a/arch/x86/lib/memcpy_64.S
25868 +++ b/arch/x86/lib/memcpy_64.S
25869 @@ -33,6 +33,7 @@
25870 rep movsq
25871 movl %edx, %ecx
25872 rep movsb
25873 + pax_force_retaddr
25874 ret
25875 .Lmemcpy_e:
25876 .previous
25877 @@ -49,6 +50,7 @@
25878 movq %rdi, %rax
25879 movq %rdx, %rcx
25880 rep movsb
25881 + pax_force_retaddr
25882 ret
25883 .Lmemcpy_e_e:
25884 .previous
25885 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25886 */
25887 movq 0*8(%rsi), %r8
25888 movq 1*8(%rsi), %r9
25889 - movq 2*8(%rsi), %r10
25890 + movq 2*8(%rsi), %rcx
25891 movq 3*8(%rsi), %r11
25892 leaq 4*8(%rsi), %rsi
25893
25894 movq %r8, 0*8(%rdi)
25895 movq %r9, 1*8(%rdi)
25896 - movq %r10, 2*8(%rdi)
25897 + movq %rcx, 2*8(%rdi)
25898 movq %r11, 3*8(%rdi)
25899 leaq 4*8(%rdi), %rdi
25900 jae .Lcopy_forward_loop
25901 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25902 subq $0x20, %rdx
25903 movq -1*8(%rsi), %r8
25904 movq -2*8(%rsi), %r9
25905 - movq -3*8(%rsi), %r10
25906 + movq -3*8(%rsi), %rcx
25907 movq -4*8(%rsi), %r11
25908 leaq -4*8(%rsi), %rsi
25909 movq %r8, -1*8(%rdi)
25910 movq %r9, -2*8(%rdi)
25911 - movq %r10, -3*8(%rdi)
25912 + movq %rcx, -3*8(%rdi)
25913 movq %r11, -4*8(%rdi)
25914 leaq -4*8(%rdi), %rdi
25915 jae .Lcopy_backward_loop
25916 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25917 */
25918 movq 0*8(%rsi), %r8
25919 movq 1*8(%rsi), %r9
25920 - movq -2*8(%rsi, %rdx), %r10
25921 + movq -2*8(%rsi, %rdx), %rcx
25922 movq -1*8(%rsi, %rdx), %r11
25923 movq %r8, 0*8(%rdi)
25924 movq %r9, 1*8(%rdi)
25925 - movq %r10, -2*8(%rdi, %rdx)
25926 + movq %rcx, -2*8(%rdi, %rdx)
25927 movq %r11, -1*8(%rdi, %rdx)
25928 + pax_force_retaddr
25929 retq
25930 .p2align 4
25931 .Lless_16bytes:
25932 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25933 movq -1*8(%rsi, %rdx), %r9
25934 movq %r8, 0*8(%rdi)
25935 movq %r9, -1*8(%rdi, %rdx)
25936 + pax_force_retaddr
25937 retq
25938 .p2align 4
25939 .Lless_8bytes:
25940 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25941 movl -4(%rsi, %rdx), %r8d
25942 movl %ecx, (%rdi)
25943 movl %r8d, -4(%rdi, %rdx)
25944 + pax_force_retaddr
25945 retq
25946 .p2align 4
25947 .Lless_3bytes:
25948 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25949 movb %cl, (%rdi)
25950
25951 .Lend:
25952 + pax_force_retaddr
25953 retq
25954 CFI_ENDPROC
25955 ENDPROC(memcpy)
25956 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25957 index ee16461..c39c199 100644
25958 --- a/arch/x86/lib/memmove_64.S
25959 +++ b/arch/x86/lib/memmove_64.S
25960 @@ -61,13 +61,13 @@ ENTRY(memmove)
25961 5:
25962 sub $0x20, %rdx
25963 movq 0*8(%rsi), %r11
25964 - movq 1*8(%rsi), %r10
25965 + movq 1*8(%rsi), %rcx
25966 movq 2*8(%rsi), %r9
25967 movq 3*8(%rsi), %r8
25968 leaq 4*8(%rsi), %rsi
25969
25970 movq %r11, 0*8(%rdi)
25971 - movq %r10, 1*8(%rdi)
25972 + movq %rcx, 1*8(%rdi)
25973 movq %r9, 2*8(%rdi)
25974 movq %r8, 3*8(%rdi)
25975 leaq 4*8(%rdi), %rdi
25976 @@ -81,10 +81,10 @@ ENTRY(memmove)
25977 4:
25978 movq %rdx, %rcx
25979 movq -8(%rsi, %rdx), %r11
25980 - lea -8(%rdi, %rdx), %r10
25981 + lea -8(%rdi, %rdx), %r9
25982 shrq $3, %rcx
25983 rep movsq
25984 - movq %r11, (%r10)
25985 + movq %r11, (%r9)
25986 jmp 13f
25987 .Lmemmove_end_forward:
25988
25989 @@ -95,14 +95,14 @@ ENTRY(memmove)
25990 7:
25991 movq %rdx, %rcx
25992 movq (%rsi), %r11
25993 - movq %rdi, %r10
25994 + movq %rdi, %r9
25995 leaq -8(%rsi, %rdx), %rsi
25996 leaq -8(%rdi, %rdx), %rdi
25997 shrq $3, %rcx
25998 std
25999 rep movsq
26000 cld
26001 - movq %r11, (%r10)
26002 + movq %r11, (%r9)
26003 jmp 13f
26004
26005 /*
26006 @@ -127,13 +127,13 @@ ENTRY(memmove)
26007 8:
26008 subq $0x20, %rdx
26009 movq -1*8(%rsi), %r11
26010 - movq -2*8(%rsi), %r10
26011 + movq -2*8(%rsi), %rcx
26012 movq -3*8(%rsi), %r9
26013 movq -4*8(%rsi), %r8
26014 leaq -4*8(%rsi), %rsi
26015
26016 movq %r11, -1*8(%rdi)
26017 - movq %r10, -2*8(%rdi)
26018 + movq %rcx, -2*8(%rdi)
26019 movq %r9, -3*8(%rdi)
26020 movq %r8, -4*8(%rdi)
26021 leaq -4*8(%rdi), %rdi
26022 @@ -151,11 +151,11 @@ ENTRY(memmove)
26023 * Move data from 16 bytes to 31 bytes.
26024 */
26025 movq 0*8(%rsi), %r11
26026 - movq 1*8(%rsi), %r10
26027 + movq 1*8(%rsi), %rcx
26028 movq -2*8(%rsi, %rdx), %r9
26029 movq -1*8(%rsi, %rdx), %r8
26030 movq %r11, 0*8(%rdi)
26031 - movq %r10, 1*8(%rdi)
26032 + movq %rcx, 1*8(%rdi)
26033 movq %r9, -2*8(%rdi, %rdx)
26034 movq %r8, -1*8(%rdi, %rdx)
26035 jmp 13f
26036 @@ -167,9 +167,9 @@ ENTRY(memmove)
26037 * Move data from 8 bytes to 15 bytes.
26038 */
26039 movq 0*8(%rsi), %r11
26040 - movq -1*8(%rsi, %rdx), %r10
26041 + movq -1*8(%rsi, %rdx), %r9
26042 movq %r11, 0*8(%rdi)
26043 - movq %r10, -1*8(%rdi, %rdx)
26044 + movq %r9, -1*8(%rdi, %rdx)
26045 jmp 13f
26046 10:
26047 cmpq $4, %rdx
26048 @@ -178,9 +178,9 @@ ENTRY(memmove)
26049 * Move data from 4 bytes to 7 bytes.
26050 */
26051 movl (%rsi), %r11d
26052 - movl -4(%rsi, %rdx), %r10d
26053 + movl -4(%rsi, %rdx), %r9d
26054 movl %r11d, (%rdi)
26055 - movl %r10d, -4(%rdi, %rdx)
26056 + movl %r9d, -4(%rdi, %rdx)
26057 jmp 13f
26058 11:
26059 cmp $2, %rdx
26060 @@ -189,9 +189,9 @@ ENTRY(memmove)
26061 * Move data from 2 bytes to 3 bytes.
26062 */
26063 movw (%rsi), %r11w
26064 - movw -2(%rsi, %rdx), %r10w
26065 + movw -2(%rsi, %rdx), %r9w
26066 movw %r11w, (%rdi)
26067 - movw %r10w, -2(%rdi, %rdx)
26068 + movw %r9w, -2(%rdi, %rdx)
26069 jmp 13f
26070 12:
26071 cmp $1, %rdx
26072 @@ -202,6 +202,7 @@ ENTRY(memmove)
26073 movb (%rsi), %r11b
26074 movb %r11b, (%rdi)
26075 13:
26076 + pax_force_retaddr
26077 retq
26078 CFI_ENDPROC
26079
26080 @@ -210,6 +211,7 @@ ENTRY(memmove)
26081 /* Forward moving data. */
26082 movq %rdx, %rcx
26083 rep movsb
26084 + pax_force_retaddr
26085 retq
26086 .Lmemmove_end_forward_efs:
26087 .previous
26088 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
26089 index 2dcb380..963660a 100644
26090 --- a/arch/x86/lib/memset_64.S
26091 +++ b/arch/x86/lib/memset_64.S
26092 @@ -30,6 +30,7 @@
26093 movl %edx,%ecx
26094 rep stosb
26095 movq %r9,%rax
26096 + pax_force_retaddr
26097 ret
26098 .Lmemset_e:
26099 .previous
26100 @@ -52,6 +53,7 @@
26101 movq %rdx,%rcx
26102 rep stosb
26103 movq %r9,%rax
26104 + pax_force_retaddr
26105 ret
26106 .Lmemset_e_e:
26107 .previous
26108 @@ -59,7 +61,7 @@
26109 ENTRY(memset)
26110 ENTRY(__memset)
26111 CFI_STARTPROC
26112 - movq %rdi,%r10
26113 + movq %rdi,%r11
26114
26115 /* expand byte value */
26116 movzbl %sil,%ecx
26117 @@ -117,7 +119,8 @@ ENTRY(__memset)
26118 jnz .Lloop_1
26119
26120 .Lende:
26121 - movq %r10,%rax
26122 + movq %r11,%rax
26123 + pax_force_retaddr
26124 ret
26125
26126 CFI_RESTORE_STATE
26127 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
26128 index c9f2d9b..e7fd2c0 100644
26129 --- a/arch/x86/lib/mmx_32.c
26130 +++ b/arch/x86/lib/mmx_32.c
26131 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26132 {
26133 void *p;
26134 int i;
26135 + unsigned long cr0;
26136
26137 if (unlikely(in_interrupt()))
26138 return __memcpy(to, from, len);
26139 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26140 kernel_fpu_begin();
26141
26142 __asm__ __volatile__ (
26143 - "1: prefetch (%0)\n" /* This set is 28 bytes */
26144 - " prefetch 64(%0)\n"
26145 - " prefetch 128(%0)\n"
26146 - " prefetch 192(%0)\n"
26147 - " prefetch 256(%0)\n"
26148 + "1: prefetch (%1)\n" /* This set is 28 bytes */
26149 + " prefetch 64(%1)\n"
26150 + " prefetch 128(%1)\n"
26151 + " prefetch 192(%1)\n"
26152 + " prefetch 256(%1)\n"
26153 "2: \n"
26154 ".section .fixup, \"ax\"\n"
26155 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26156 + "3: \n"
26157 +
26158 +#ifdef CONFIG_PAX_KERNEXEC
26159 + " movl %%cr0, %0\n"
26160 + " movl %0, %%eax\n"
26161 + " andl $0xFFFEFFFF, %%eax\n"
26162 + " movl %%eax, %%cr0\n"
26163 +#endif
26164 +
26165 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26166 +
26167 +#ifdef CONFIG_PAX_KERNEXEC
26168 + " movl %0, %%cr0\n"
26169 +#endif
26170 +
26171 " jmp 2b\n"
26172 ".previous\n"
26173 _ASM_EXTABLE(1b, 3b)
26174 - : : "r" (from));
26175 + : "=&r" (cr0) : "r" (from) : "ax");
26176
26177 for ( ; i > 5; i--) {
26178 __asm__ __volatile__ (
26179 - "1: prefetch 320(%0)\n"
26180 - "2: movq (%0), %%mm0\n"
26181 - " movq 8(%0), %%mm1\n"
26182 - " movq 16(%0), %%mm2\n"
26183 - " movq 24(%0), %%mm3\n"
26184 - " movq %%mm0, (%1)\n"
26185 - " movq %%mm1, 8(%1)\n"
26186 - " movq %%mm2, 16(%1)\n"
26187 - " movq %%mm3, 24(%1)\n"
26188 - " movq 32(%0), %%mm0\n"
26189 - " movq 40(%0), %%mm1\n"
26190 - " movq 48(%0), %%mm2\n"
26191 - " movq 56(%0), %%mm3\n"
26192 - " movq %%mm0, 32(%1)\n"
26193 - " movq %%mm1, 40(%1)\n"
26194 - " movq %%mm2, 48(%1)\n"
26195 - " movq %%mm3, 56(%1)\n"
26196 + "1: prefetch 320(%1)\n"
26197 + "2: movq (%1), %%mm0\n"
26198 + " movq 8(%1), %%mm1\n"
26199 + " movq 16(%1), %%mm2\n"
26200 + " movq 24(%1), %%mm3\n"
26201 + " movq %%mm0, (%2)\n"
26202 + " movq %%mm1, 8(%2)\n"
26203 + " movq %%mm2, 16(%2)\n"
26204 + " movq %%mm3, 24(%2)\n"
26205 + " movq 32(%1), %%mm0\n"
26206 + " movq 40(%1), %%mm1\n"
26207 + " movq 48(%1), %%mm2\n"
26208 + " movq 56(%1), %%mm3\n"
26209 + " movq %%mm0, 32(%2)\n"
26210 + " movq %%mm1, 40(%2)\n"
26211 + " movq %%mm2, 48(%2)\n"
26212 + " movq %%mm3, 56(%2)\n"
26213 ".section .fixup, \"ax\"\n"
26214 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26215 + "3:\n"
26216 +
26217 +#ifdef CONFIG_PAX_KERNEXEC
26218 + " movl %%cr0, %0\n"
26219 + " movl %0, %%eax\n"
26220 + " andl $0xFFFEFFFF, %%eax\n"
26221 + " movl %%eax, %%cr0\n"
26222 +#endif
26223 +
26224 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26225 +
26226 +#ifdef CONFIG_PAX_KERNEXEC
26227 + " movl %0, %%cr0\n"
26228 +#endif
26229 +
26230 " jmp 2b\n"
26231 ".previous\n"
26232 _ASM_EXTABLE(1b, 3b)
26233 - : : "r" (from), "r" (to) : "memory");
26234 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26235
26236 from += 64;
26237 to += 64;
26238 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
26239 static void fast_copy_page(void *to, void *from)
26240 {
26241 int i;
26242 + unsigned long cr0;
26243
26244 kernel_fpu_begin();
26245
26246 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
26247 * but that is for later. -AV
26248 */
26249 __asm__ __volatile__(
26250 - "1: prefetch (%0)\n"
26251 - " prefetch 64(%0)\n"
26252 - " prefetch 128(%0)\n"
26253 - " prefetch 192(%0)\n"
26254 - " prefetch 256(%0)\n"
26255 + "1: prefetch (%1)\n"
26256 + " prefetch 64(%1)\n"
26257 + " prefetch 128(%1)\n"
26258 + " prefetch 192(%1)\n"
26259 + " prefetch 256(%1)\n"
26260 "2: \n"
26261 ".section .fixup, \"ax\"\n"
26262 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26263 + "3: \n"
26264 +
26265 +#ifdef CONFIG_PAX_KERNEXEC
26266 + " movl %%cr0, %0\n"
26267 + " movl %0, %%eax\n"
26268 + " andl $0xFFFEFFFF, %%eax\n"
26269 + " movl %%eax, %%cr0\n"
26270 +#endif
26271 +
26272 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26273 +
26274 +#ifdef CONFIG_PAX_KERNEXEC
26275 + " movl %0, %%cr0\n"
26276 +#endif
26277 +
26278 " jmp 2b\n"
26279 ".previous\n"
26280 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26281 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26282
26283 for (i = 0; i < (4096-320)/64; i++) {
26284 __asm__ __volatile__ (
26285 - "1: prefetch 320(%0)\n"
26286 - "2: movq (%0), %%mm0\n"
26287 - " movntq %%mm0, (%1)\n"
26288 - " movq 8(%0), %%mm1\n"
26289 - " movntq %%mm1, 8(%1)\n"
26290 - " movq 16(%0), %%mm2\n"
26291 - " movntq %%mm2, 16(%1)\n"
26292 - " movq 24(%0), %%mm3\n"
26293 - " movntq %%mm3, 24(%1)\n"
26294 - " movq 32(%0), %%mm4\n"
26295 - " movntq %%mm4, 32(%1)\n"
26296 - " movq 40(%0), %%mm5\n"
26297 - " movntq %%mm5, 40(%1)\n"
26298 - " movq 48(%0), %%mm6\n"
26299 - " movntq %%mm6, 48(%1)\n"
26300 - " movq 56(%0), %%mm7\n"
26301 - " movntq %%mm7, 56(%1)\n"
26302 + "1: prefetch 320(%1)\n"
26303 + "2: movq (%1), %%mm0\n"
26304 + " movntq %%mm0, (%2)\n"
26305 + " movq 8(%1), %%mm1\n"
26306 + " movntq %%mm1, 8(%2)\n"
26307 + " movq 16(%1), %%mm2\n"
26308 + " movntq %%mm2, 16(%2)\n"
26309 + " movq 24(%1), %%mm3\n"
26310 + " movntq %%mm3, 24(%2)\n"
26311 + " movq 32(%1), %%mm4\n"
26312 + " movntq %%mm4, 32(%2)\n"
26313 + " movq 40(%1), %%mm5\n"
26314 + " movntq %%mm5, 40(%2)\n"
26315 + " movq 48(%1), %%mm6\n"
26316 + " movntq %%mm6, 48(%2)\n"
26317 + " movq 56(%1), %%mm7\n"
26318 + " movntq %%mm7, 56(%2)\n"
26319 ".section .fixup, \"ax\"\n"
26320 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26321 + "3:\n"
26322 +
26323 +#ifdef CONFIG_PAX_KERNEXEC
26324 + " movl %%cr0, %0\n"
26325 + " movl %0, %%eax\n"
26326 + " andl $0xFFFEFFFF, %%eax\n"
26327 + " movl %%eax, %%cr0\n"
26328 +#endif
26329 +
26330 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26331 +
26332 +#ifdef CONFIG_PAX_KERNEXEC
26333 + " movl %0, %%cr0\n"
26334 +#endif
26335 +
26336 " jmp 2b\n"
26337 ".previous\n"
26338 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26339 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26340
26341 from += 64;
26342 to += 64;
26343 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26344 static void fast_copy_page(void *to, void *from)
26345 {
26346 int i;
26347 + unsigned long cr0;
26348
26349 kernel_fpu_begin();
26350
26351 __asm__ __volatile__ (
26352 - "1: prefetch (%0)\n"
26353 - " prefetch 64(%0)\n"
26354 - " prefetch 128(%0)\n"
26355 - " prefetch 192(%0)\n"
26356 - " prefetch 256(%0)\n"
26357 + "1: prefetch (%1)\n"
26358 + " prefetch 64(%1)\n"
26359 + " prefetch 128(%1)\n"
26360 + " prefetch 192(%1)\n"
26361 + " prefetch 256(%1)\n"
26362 "2: \n"
26363 ".section .fixup, \"ax\"\n"
26364 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26365 + "3: \n"
26366 +
26367 +#ifdef CONFIG_PAX_KERNEXEC
26368 + " movl %%cr0, %0\n"
26369 + " movl %0, %%eax\n"
26370 + " andl $0xFFFEFFFF, %%eax\n"
26371 + " movl %%eax, %%cr0\n"
26372 +#endif
26373 +
26374 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26375 +
26376 +#ifdef CONFIG_PAX_KERNEXEC
26377 + " movl %0, %%cr0\n"
26378 +#endif
26379 +
26380 " jmp 2b\n"
26381 ".previous\n"
26382 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26383 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26384
26385 for (i = 0; i < 4096/64; i++) {
26386 __asm__ __volatile__ (
26387 - "1: prefetch 320(%0)\n"
26388 - "2: movq (%0), %%mm0\n"
26389 - " movq 8(%0), %%mm1\n"
26390 - " movq 16(%0), %%mm2\n"
26391 - " movq 24(%0), %%mm3\n"
26392 - " movq %%mm0, (%1)\n"
26393 - " movq %%mm1, 8(%1)\n"
26394 - " movq %%mm2, 16(%1)\n"
26395 - " movq %%mm3, 24(%1)\n"
26396 - " movq 32(%0), %%mm0\n"
26397 - " movq 40(%0), %%mm1\n"
26398 - " movq 48(%0), %%mm2\n"
26399 - " movq 56(%0), %%mm3\n"
26400 - " movq %%mm0, 32(%1)\n"
26401 - " movq %%mm1, 40(%1)\n"
26402 - " movq %%mm2, 48(%1)\n"
26403 - " movq %%mm3, 56(%1)\n"
26404 + "1: prefetch 320(%1)\n"
26405 + "2: movq (%1), %%mm0\n"
26406 + " movq 8(%1), %%mm1\n"
26407 + " movq 16(%1), %%mm2\n"
26408 + " movq 24(%1), %%mm3\n"
26409 + " movq %%mm0, (%2)\n"
26410 + " movq %%mm1, 8(%2)\n"
26411 + " movq %%mm2, 16(%2)\n"
26412 + " movq %%mm3, 24(%2)\n"
26413 + " movq 32(%1), %%mm0\n"
26414 + " movq 40(%1), %%mm1\n"
26415 + " movq 48(%1), %%mm2\n"
26416 + " movq 56(%1), %%mm3\n"
26417 + " movq %%mm0, 32(%2)\n"
26418 + " movq %%mm1, 40(%2)\n"
26419 + " movq %%mm2, 48(%2)\n"
26420 + " movq %%mm3, 56(%2)\n"
26421 ".section .fixup, \"ax\"\n"
26422 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26423 + "3:\n"
26424 +
26425 +#ifdef CONFIG_PAX_KERNEXEC
26426 + " movl %%cr0, %0\n"
26427 + " movl %0, %%eax\n"
26428 + " andl $0xFFFEFFFF, %%eax\n"
26429 + " movl %%eax, %%cr0\n"
26430 +#endif
26431 +
26432 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26433 +
26434 +#ifdef CONFIG_PAX_KERNEXEC
26435 + " movl %0, %%cr0\n"
26436 +#endif
26437 +
26438 " jmp 2b\n"
26439 ".previous\n"
26440 _ASM_EXTABLE(1b, 3b)
26441 - : : "r" (from), "r" (to) : "memory");
26442 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26443
26444 from += 64;
26445 to += 64;
26446 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26447 index f6d13ee..aca5f0b 100644
26448 --- a/arch/x86/lib/msr-reg.S
26449 +++ b/arch/x86/lib/msr-reg.S
26450 @@ -3,6 +3,7 @@
26451 #include <asm/dwarf2.h>
26452 #include <asm/asm.h>
26453 #include <asm/msr.h>
26454 +#include <asm/alternative-asm.h>
26455
26456 #ifdef CONFIG_X86_64
26457 /*
26458 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26459 CFI_STARTPROC
26460 pushq_cfi %rbx
26461 pushq_cfi %rbp
26462 - movq %rdi, %r10 /* Save pointer */
26463 + movq %rdi, %r9 /* Save pointer */
26464 xorl %r11d, %r11d /* Return value */
26465 movl (%rdi), %eax
26466 movl 4(%rdi), %ecx
26467 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26468 movl 28(%rdi), %edi
26469 CFI_REMEMBER_STATE
26470 1: \op
26471 -2: movl %eax, (%r10)
26472 +2: movl %eax, (%r9)
26473 movl %r11d, %eax /* Return value */
26474 - movl %ecx, 4(%r10)
26475 - movl %edx, 8(%r10)
26476 - movl %ebx, 12(%r10)
26477 - movl %ebp, 20(%r10)
26478 - movl %esi, 24(%r10)
26479 - movl %edi, 28(%r10)
26480 + movl %ecx, 4(%r9)
26481 + movl %edx, 8(%r9)
26482 + movl %ebx, 12(%r9)
26483 + movl %ebp, 20(%r9)
26484 + movl %esi, 24(%r9)
26485 + movl %edi, 28(%r9)
26486 popq_cfi %rbp
26487 popq_cfi %rbx
26488 + pax_force_retaddr
26489 ret
26490 3:
26491 CFI_RESTORE_STATE
26492 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26493 index fc6ba17..04471c5 100644
26494 --- a/arch/x86/lib/putuser.S
26495 +++ b/arch/x86/lib/putuser.S
26496 @@ -16,7 +16,9 @@
26497 #include <asm/errno.h>
26498 #include <asm/asm.h>
26499 #include <asm/smap.h>
26500 -
26501 +#include <asm/segment.h>
26502 +#include <asm/pgtable.h>
26503 +#include <asm/alternative-asm.h>
26504
26505 /*
26506 * __put_user_X
26507 @@ -30,57 +32,125 @@
26508 * as they get called from within inline assembly.
26509 */
26510
26511 -#define ENTER CFI_STARTPROC ; \
26512 - GET_THREAD_INFO(%_ASM_BX)
26513 -#define EXIT ASM_CLAC ; \
26514 - ret ; \
26515 +#define ENTER CFI_STARTPROC
26516 +#define EXIT ASM_CLAC ; \
26517 + pax_force_retaddr ; \
26518 + ret ; \
26519 CFI_ENDPROC
26520
26521 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26522 +#define _DEST %_ASM_CX,%_ASM_BX
26523 +#else
26524 +#define _DEST %_ASM_CX
26525 +#endif
26526 +
26527 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26528 +#define __copyuser_seg gs;
26529 +#else
26530 +#define __copyuser_seg
26531 +#endif
26532 +
26533 .text
26534 ENTRY(__put_user_1)
26535 ENTER
26536 +
26537 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26538 + GET_THREAD_INFO(%_ASM_BX)
26539 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26540 jae bad_put_user
26541 ASM_STAC
26542 -1: movb %al,(%_ASM_CX)
26543 +
26544 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26545 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26546 + cmp %_ASM_BX,%_ASM_CX
26547 + jb 1234f
26548 + xor %ebx,%ebx
26549 +1234:
26550 +#endif
26551 +
26552 +#endif
26553 +
26554 +1: __copyuser_seg movb %al,(_DEST)
26555 xor %eax,%eax
26556 EXIT
26557 ENDPROC(__put_user_1)
26558
26559 ENTRY(__put_user_2)
26560 ENTER
26561 +
26562 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26563 + GET_THREAD_INFO(%_ASM_BX)
26564 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26565 sub $1,%_ASM_BX
26566 cmp %_ASM_BX,%_ASM_CX
26567 jae bad_put_user
26568 ASM_STAC
26569 -2: movw %ax,(%_ASM_CX)
26570 +
26571 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26572 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26573 + cmp %_ASM_BX,%_ASM_CX
26574 + jb 1234f
26575 + xor %ebx,%ebx
26576 +1234:
26577 +#endif
26578 +
26579 +#endif
26580 +
26581 +2: __copyuser_seg movw %ax,(_DEST)
26582 xor %eax,%eax
26583 EXIT
26584 ENDPROC(__put_user_2)
26585
26586 ENTRY(__put_user_4)
26587 ENTER
26588 +
26589 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26590 + GET_THREAD_INFO(%_ASM_BX)
26591 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26592 sub $3,%_ASM_BX
26593 cmp %_ASM_BX,%_ASM_CX
26594 jae bad_put_user
26595 ASM_STAC
26596 -3: movl %eax,(%_ASM_CX)
26597 +
26598 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26599 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26600 + cmp %_ASM_BX,%_ASM_CX
26601 + jb 1234f
26602 + xor %ebx,%ebx
26603 +1234:
26604 +#endif
26605 +
26606 +#endif
26607 +
26608 +3: __copyuser_seg movl %eax,(_DEST)
26609 xor %eax,%eax
26610 EXIT
26611 ENDPROC(__put_user_4)
26612
26613 ENTRY(__put_user_8)
26614 ENTER
26615 +
26616 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26617 + GET_THREAD_INFO(%_ASM_BX)
26618 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26619 sub $7,%_ASM_BX
26620 cmp %_ASM_BX,%_ASM_CX
26621 jae bad_put_user
26622 ASM_STAC
26623 -4: mov %_ASM_AX,(%_ASM_CX)
26624 +
26625 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26626 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26627 + cmp %_ASM_BX,%_ASM_CX
26628 + jb 1234f
26629 + xor %ebx,%ebx
26630 +1234:
26631 +#endif
26632 +
26633 +#endif
26634 +
26635 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26636 #ifdef CONFIG_X86_32
26637 -5: movl %edx,4(%_ASM_CX)
26638 +5: __copyuser_seg movl %edx,4(_DEST)
26639 #endif
26640 xor %eax,%eax
26641 EXIT
26642 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26643 index 1cad221..de671ee 100644
26644 --- a/arch/x86/lib/rwlock.S
26645 +++ b/arch/x86/lib/rwlock.S
26646 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26647 FRAME
26648 0: LOCK_PREFIX
26649 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26650 +
26651 +#ifdef CONFIG_PAX_REFCOUNT
26652 + jno 1234f
26653 + LOCK_PREFIX
26654 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26655 + int $4
26656 +1234:
26657 + _ASM_EXTABLE(1234b, 1234b)
26658 +#endif
26659 +
26660 1: rep; nop
26661 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26662 jne 1b
26663 LOCK_PREFIX
26664 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26665 +
26666 +#ifdef CONFIG_PAX_REFCOUNT
26667 + jno 1234f
26668 + LOCK_PREFIX
26669 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26670 + int $4
26671 +1234:
26672 + _ASM_EXTABLE(1234b, 1234b)
26673 +#endif
26674 +
26675 jnz 0b
26676 ENDFRAME
26677 + pax_force_retaddr
26678 ret
26679 CFI_ENDPROC
26680 END(__write_lock_failed)
26681 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26682 FRAME
26683 0: LOCK_PREFIX
26684 READ_LOCK_SIZE(inc) (%__lock_ptr)
26685 +
26686 +#ifdef CONFIG_PAX_REFCOUNT
26687 + jno 1234f
26688 + LOCK_PREFIX
26689 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26690 + int $4
26691 +1234:
26692 + _ASM_EXTABLE(1234b, 1234b)
26693 +#endif
26694 +
26695 1: rep; nop
26696 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26697 js 1b
26698 LOCK_PREFIX
26699 READ_LOCK_SIZE(dec) (%__lock_ptr)
26700 +
26701 +#ifdef CONFIG_PAX_REFCOUNT
26702 + jno 1234f
26703 + LOCK_PREFIX
26704 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26705 + int $4
26706 +1234:
26707 + _ASM_EXTABLE(1234b, 1234b)
26708 +#endif
26709 +
26710 js 0b
26711 ENDFRAME
26712 + pax_force_retaddr
26713 ret
26714 CFI_ENDPROC
26715 END(__read_lock_failed)
26716 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26717 index 5dff5f0..cadebf4 100644
26718 --- a/arch/x86/lib/rwsem.S
26719 +++ b/arch/x86/lib/rwsem.S
26720 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26721 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26722 CFI_RESTORE __ASM_REG(dx)
26723 restore_common_regs
26724 + pax_force_retaddr
26725 ret
26726 CFI_ENDPROC
26727 ENDPROC(call_rwsem_down_read_failed)
26728 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26729 movq %rax,%rdi
26730 call rwsem_down_write_failed
26731 restore_common_regs
26732 + pax_force_retaddr
26733 ret
26734 CFI_ENDPROC
26735 ENDPROC(call_rwsem_down_write_failed)
26736 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26737 movq %rax,%rdi
26738 call rwsem_wake
26739 restore_common_regs
26740 -1: ret
26741 +1: pax_force_retaddr
26742 + ret
26743 CFI_ENDPROC
26744 ENDPROC(call_rwsem_wake)
26745
26746 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26747 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26748 CFI_RESTORE __ASM_REG(dx)
26749 restore_common_regs
26750 + pax_force_retaddr
26751 ret
26752 CFI_ENDPROC
26753 ENDPROC(call_rwsem_downgrade_wake)
26754 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26755 index a63efd6..ccecad8 100644
26756 --- a/arch/x86/lib/thunk_64.S
26757 +++ b/arch/x86/lib/thunk_64.S
26758 @@ -8,6 +8,7 @@
26759 #include <linux/linkage.h>
26760 #include <asm/dwarf2.h>
26761 #include <asm/calling.h>
26762 +#include <asm/alternative-asm.h>
26763
26764 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26765 .macro THUNK name, func, put_ret_addr_in_rdi=0
26766 @@ -41,5 +42,6 @@
26767 SAVE_ARGS
26768 restore:
26769 RESTORE_ARGS
26770 + pax_force_retaddr
26771 ret
26772 CFI_ENDPROC
26773 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26774 index f0312d7..9c39d63 100644
26775 --- a/arch/x86/lib/usercopy_32.c
26776 +++ b/arch/x86/lib/usercopy_32.c
26777 @@ -42,11 +42,13 @@ do { \
26778 int __d0; \
26779 might_fault(); \
26780 __asm__ __volatile__( \
26781 + __COPYUSER_SET_ES \
26782 ASM_STAC "\n" \
26783 "0: rep; stosl\n" \
26784 " movl %2,%0\n" \
26785 "1: rep; stosb\n" \
26786 "2: " ASM_CLAC "\n" \
26787 + __COPYUSER_RESTORE_ES \
26788 ".section .fixup,\"ax\"\n" \
26789 "3: lea 0(%2,%0,4),%0\n" \
26790 " jmp 2b\n" \
26791 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26792
26793 #ifdef CONFIG_X86_INTEL_USERCOPY
26794 static unsigned long
26795 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26796 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26797 {
26798 int d0, d1;
26799 __asm__ __volatile__(
26800 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26801 " .align 2,0x90\n"
26802 "3: movl 0(%4), %%eax\n"
26803 "4: movl 4(%4), %%edx\n"
26804 - "5: movl %%eax, 0(%3)\n"
26805 - "6: movl %%edx, 4(%3)\n"
26806 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26807 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26808 "7: movl 8(%4), %%eax\n"
26809 "8: movl 12(%4),%%edx\n"
26810 - "9: movl %%eax, 8(%3)\n"
26811 - "10: movl %%edx, 12(%3)\n"
26812 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26813 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26814 "11: movl 16(%4), %%eax\n"
26815 "12: movl 20(%4), %%edx\n"
26816 - "13: movl %%eax, 16(%3)\n"
26817 - "14: movl %%edx, 20(%3)\n"
26818 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26819 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26820 "15: movl 24(%4), %%eax\n"
26821 "16: movl 28(%4), %%edx\n"
26822 - "17: movl %%eax, 24(%3)\n"
26823 - "18: movl %%edx, 28(%3)\n"
26824 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26825 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26826 "19: movl 32(%4), %%eax\n"
26827 "20: movl 36(%4), %%edx\n"
26828 - "21: movl %%eax, 32(%3)\n"
26829 - "22: movl %%edx, 36(%3)\n"
26830 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26831 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26832 "23: movl 40(%4), %%eax\n"
26833 "24: movl 44(%4), %%edx\n"
26834 - "25: movl %%eax, 40(%3)\n"
26835 - "26: movl %%edx, 44(%3)\n"
26836 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26837 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26838 "27: movl 48(%4), %%eax\n"
26839 "28: movl 52(%4), %%edx\n"
26840 - "29: movl %%eax, 48(%3)\n"
26841 - "30: movl %%edx, 52(%3)\n"
26842 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26843 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26844 "31: movl 56(%4), %%eax\n"
26845 "32: movl 60(%4), %%edx\n"
26846 - "33: movl %%eax, 56(%3)\n"
26847 - "34: movl %%edx, 60(%3)\n"
26848 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26849 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26850 " addl $-64, %0\n"
26851 " addl $64, %4\n"
26852 " addl $64, %3\n"
26853 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26854 " shrl $2, %0\n"
26855 " andl $3, %%eax\n"
26856 " cld\n"
26857 + __COPYUSER_SET_ES
26858 "99: rep; movsl\n"
26859 "36: movl %%eax, %0\n"
26860 "37: rep; movsb\n"
26861 "100:\n"
26862 + __COPYUSER_RESTORE_ES
26863 ".section .fixup,\"ax\"\n"
26864 "101: lea 0(%%eax,%0,4),%0\n"
26865 " jmp 100b\n"
26866 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26867 }
26868
26869 static unsigned long
26870 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26871 +{
26872 + int d0, d1;
26873 + __asm__ __volatile__(
26874 + " .align 2,0x90\n"
26875 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26876 + " cmpl $67, %0\n"
26877 + " jbe 3f\n"
26878 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26879 + " .align 2,0x90\n"
26880 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26881 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26882 + "5: movl %%eax, 0(%3)\n"
26883 + "6: movl %%edx, 4(%3)\n"
26884 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26885 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26886 + "9: movl %%eax, 8(%3)\n"
26887 + "10: movl %%edx, 12(%3)\n"
26888 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26889 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26890 + "13: movl %%eax, 16(%3)\n"
26891 + "14: movl %%edx, 20(%3)\n"
26892 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26893 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26894 + "17: movl %%eax, 24(%3)\n"
26895 + "18: movl %%edx, 28(%3)\n"
26896 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26897 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26898 + "21: movl %%eax, 32(%3)\n"
26899 + "22: movl %%edx, 36(%3)\n"
26900 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26901 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26902 + "25: movl %%eax, 40(%3)\n"
26903 + "26: movl %%edx, 44(%3)\n"
26904 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26905 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26906 + "29: movl %%eax, 48(%3)\n"
26907 + "30: movl %%edx, 52(%3)\n"
26908 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26909 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26910 + "33: movl %%eax, 56(%3)\n"
26911 + "34: movl %%edx, 60(%3)\n"
26912 + " addl $-64, %0\n"
26913 + " addl $64, %4\n"
26914 + " addl $64, %3\n"
26915 + " cmpl $63, %0\n"
26916 + " ja 1b\n"
26917 + "35: movl %0, %%eax\n"
26918 + " shrl $2, %0\n"
26919 + " andl $3, %%eax\n"
26920 + " cld\n"
26921 + "99: rep; "__copyuser_seg" movsl\n"
26922 + "36: movl %%eax, %0\n"
26923 + "37: rep; "__copyuser_seg" movsb\n"
26924 + "100:\n"
26925 + ".section .fixup,\"ax\"\n"
26926 + "101: lea 0(%%eax,%0,4),%0\n"
26927 + " jmp 100b\n"
26928 + ".previous\n"
26929 + _ASM_EXTABLE(1b,100b)
26930 + _ASM_EXTABLE(2b,100b)
26931 + _ASM_EXTABLE(3b,100b)
26932 + _ASM_EXTABLE(4b,100b)
26933 + _ASM_EXTABLE(5b,100b)
26934 + _ASM_EXTABLE(6b,100b)
26935 + _ASM_EXTABLE(7b,100b)
26936 + _ASM_EXTABLE(8b,100b)
26937 + _ASM_EXTABLE(9b,100b)
26938 + _ASM_EXTABLE(10b,100b)
26939 + _ASM_EXTABLE(11b,100b)
26940 + _ASM_EXTABLE(12b,100b)
26941 + _ASM_EXTABLE(13b,100b)
26942 + _ASM_EXTABLE(14b,100b)
26943 + _ASM_EXTABLE(15b,100b)
26944 + _ASM_EXTABLE(16b,100b)
26945 + _ASM_EXTABLE(17b,100b)
26946 + _ASM_EXTABLE(18b,100b)
26947 + _ASM_EXTABLE(19b,100b)
26948 + _ASM_EXTABLE(20b,100b)
26949 + _ASM_EXTABLE(21b,100b)
26950 + _ASM_EXTABLE(22b,100b)
26951 + _ASM_EXTABLE(23b,100b)
26952 + _ASM_EXTABLE(24b,100b)
26953 + _ASM_EXTABLE(25b,100b)
26954 + _ASM_EXTABLE(26b,100b)
26955 + _ASM_EXTABLE(27b,100b)
26956 + _ASM_EXTABLE(28b,100b)
26957 + _ASM_EXTABLE(29b,100b)
26958 + _ASM_EXTABLE(30b,100b)
26959 + _ASM_EXTABLE(31b,100b)
26960 + _ASM_EXTABLE(32b,100b)
26961 + _ASM_EXTABLE(33b,100b)
26962 + _ASM_EXTABLE(34b,100b)
26963 + _ASM_EXTABLE(35b,100b)
26964 + _ASM_EXTABLE(36b,100b)
26965 + _ASM_EXTABLE(37b,100b)
26966 + _ASM_EXTABLE(99b,101b)
26967 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26968 + : "1"(to), "2"(from), "0"(size)
26969 + : "eax", "edx", "memory");
26970 + return size;
26971 +}
26972 +
26973 +static unsigned long __size_overflow(3)
26974 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26975 {
26976 int d0, d1;
26977 __asm__ __volatile__(
26978 " .align 2,0x90\n"
26979 - "0: movl 32(%4), %%eax\n"
26980 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26981 " cmpl $67, %0\n"
26982 " jbe 2f\n"
26983 - "1: movl 64(%4), %%eax\n"
26984 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26985 " .align 2,0x90\n"
26986 - "2: movl 0(%4), %%eax\n"
26987 - "21: movl 4(%4), %%edx\n"
26988 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26989 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26990 " movl %%eax, 0(%3)\n"
26991 " movl %%edx, 4(%3)\n"
26992 - "3: movl 8(%4), %%eax\n"
26993 - "31: movl 12(%4),%%edx\n"
26994 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26995 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26996 " movl %%eax, 8(%3)\n"
26997 " movl %%edx, 12(%3)\n"
26998 - "4: movl 16(%4), %%eax\n"
26999 - "41: movl 20(%4), %%edx\n"
27000 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27001 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27002 " movl %%eax, 16(%3)\n"
27003 " movl %%edx, 20(%3)\n"
27004 - "10: movl 24(%4), %%eax\n"
27005 - "51: movl 28(%4), %%edx\n"
27006 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27007 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27008 " movl %%eax, 24(%3)\n"
27009 " movl %%edx, 28(%3)\n"
27010 - "11: movl 32(%4), %%eax\n"
27011 - "61: movl 36(%4), %%edx\n"
27012 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27013 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27014 " movl %%eax, 32(%3)\n"
27015 " movl %%edx, 36(%3)\n"
27016 - "12: movl 40(%4), %%eax\n"
27017 - "71: movl 44(%4), %%edx\n"
27018 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27019 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27020 " movl %%eax, 40(%3)\n"
27021 " movl %%edx, 44(%3)\n"
27022 - "13: movl 48(%4), %%eax\n"
27023 - "81: movl 52(%4), %%edx\n"
27024 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27025 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27026 " movl %%eax, 48(%3)\n"
27027 " movl %%edx, 52(%3)\n"
27028 - "14: movl 56(%4), %%eax\n"
27029 - "91: movl 60(%4), %%edx\n"
27030 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27031 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27032 " movl %%eax, 56(%3)\n"
27033 " movl %%edx, 60(%3)\n"
27034 " addl $-64, %0\n"
27035 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27036 " shrl $2, %0\n"
27037 " andl $3, %%eax\n"
27038 " cld\n"
27039 - "6: rep; movsl\n"
27040 + "6: rep; "__copyuser_seg" movsl\n"
27041 " movl %%eax,%0\n"
27042 - "7: rep; movsb\n"
27043 + "7: rep; "__copyuser_seg" movsb\n"
27044 "8:\n"
27045 ".section .fixup,\"ax\"\n"
27046 "9: lea 0(%%eax,%0,4),%0\n"
27047 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27048 * hyoshiok@miraclelinux.com
27049 */
27050
27051 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27052 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
27053 const void __user *from, unsigned long size)
27054 {
27055 int d0, d1;
27056
27057 __asm__ __volatile__(
27058 " .align 2,0x90\n"
27059 - "0: movl 32(%4), %%eax\n"
27060 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27061 " cmpl $67, %0\n"
27062 " jbe 2f\n"
27063 - "1: movl 64(%4), %%eax\n"
27064 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27065 " .align 2,0x90\n"
27066 - "2: movl 0(%4), %%eax\n"
27067 - "21: movl 4(%4), %%edx\n"
27068 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27069 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27070 " movnti %%eax, 0(%3)\n"
27071 " movnti %%edx, 4(%3)\n"
27072 - "3: movl 8(%4), %%eax\n"
27073 - "31: movl 12(%4),%%edx\n"
27074 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27075 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27076 " movnti %%eax, 8(%3)\n"
27077 " movnti %%edx, 12(%3)\n"
27078 - "4: movl 16(%4), %%eax\n"
27079 - "41: movl 20(%4), %%edx\n"
27080 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27081 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27082 " movnti %%eax, 16(%3)\n"
27083 " movnti %%edx, 20(%3)\n"
27084 - "10: movl 24(%4), %%eax\n"
27085 - "51: movl 28(%4), %%edx\n"
27086 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27087 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27088 " movnti %%eax, 24(%3)\n"
27089 " movnti %%edx, 28(%3)\n"
27090 - "11: movl 32(%4), %%eax\n"
27091 - "61: movl 36(%4), %%edx\n"
27092 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27093 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27094 " movnti %%eax, 32(%3)\n"
27095 " movnti %%edx, 36(%3)\n"
27096 - "12: movl 40(%4), %%eax\n"
27097 - "71: movl 44(%4), %%edx\n"
27098 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27099 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27100 " movnti %%eax, 40(%3)\n"
27101 " movnti %%edx, 44(%3)\n"
27102 - "13: movl 48(%4), %%eax\n"
27103 - "81: movl 52(%4), %%edx\n"
27104 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27105 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27106 " movnti %%eax, 48(%3)\n"
27107 " movnti %%edx, 52(%3)\n"
27108 - "14: movl 56(%4), %%eax\n"
27109 - "91: movl 60(%4), %%edx\n"
27110 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27111 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27112 " movnti %%eax, 56(%3)\n"
27113 " movnti %%edx, 60(%3)\n"
27114 " addl $-64, %0\n"
27115 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27116 " shrl $2, %0\n"
27117 " andl $3, %%eax\n"
27118 " cld\n"
27119 - "6: rep; movsl\n"
27120 + "6: rep; "__copyuser_seg" movsl\n"
27121 " movl %%eax,%0\n"
27122 - "7: rep; movsb\n"
27123 + "7: rep; "__copyuser_seg" movsb\n"
27124 "8:\n"
27125 ".section .fixup,\"ax\"\n"
27126 "9: lea 0(%%eax,%0,4),%0\n"
27127 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27128 return size;
27129 }
27130
27131 -static unsigned long __copy_user_intel_nocache(void *to,
27132 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
27133 const void __user *from, unsigned long size)
27134 {
27135 int d0, d1;
27136
27137 __asm__ __volatile__(
27138 " .align 2,0x90\n"
27139 - "0: movl 32(%4), %%eax\n"
27140 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27141 " cmpl $67, %0\n"
27142 " jbe 2f\n"
27143 - "1: movl 64(%4), %%eax\n"
27144 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27145 " .align 2,0x90\n"
27146 - "2: movl 0(%4), %%eax\n"
27147 - "21: movl 4(%4), %%edx\n"
27148 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27149 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27150 " movnti %%eax, 0(%3)\n"
27151 " movnti %%edx, 4(%3)\n"
27152 - "3: movl 8(%4), %%eax\n"
27153 - "31: movl 12(%4),%%edx\n"
27154 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27155 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27156 " movnti %%eax, 8(%3)\n"
27157 " movnti %%edx, 12(%3)\n"
27158 - "4: movl 16(%4), %%eax\n"
27159 - "41: movl 20(%4), %%edx\n"
27160 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27161 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27162 " movnti %%eax, 16(%3)\n"
27163 " movnti %%edx, 20(%3)\n"
27164 - "10: movl 24(%4), %%eax\n"
27165 - "51: movl 28(%4), %%edx\n"
27166 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27167 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27168 " movnti %%eax, 24(%3)\n"
27169 " movnti %%edx, 28(%3)\n"
27170 - "11: movl 32(%4), %%eax\n"
27171 - "61: movl 36(%4), %%edx\n"
27172 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27173 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27174 " movnti %%eax, 32(%3)\n"
27175 " movnti %%edx, 36(%3)\n"
27176 - "12: movl 40(%4), %%eax\n"
27177 - "71: movl 44(%4), %%edx\n"
27178 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27179 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27180 " movnti %%eax, 40(%3)\n"
27181 " movnti %%edx, 44(%3)\n"
27182 - "13: movl 48(%4), %%eax\n"
27183 - "81: movl 52(%4), %%edx\n"
27184 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27185 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27186 " movnti %%eax, 48(%3)\n"
27187 " movnti %%edx, 52(%3)\n"
27188 - "14: movl 56(%4), %%eax\n"
27189 - "91: movl 60(%4), %%edx\n"
27190 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27191 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27192 " movnti %%eax, 56(%3)\n"
27193 " movnti %%edx, 60(%3)\n"
27194 " addl $-64, %0\n"
27195 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
27196 " shrl $2, %0\n"
27197 " andl $3, %%eax\n"
27198 " cld\n"
27199 - "6: rep; movsl\n"
27200 + "6: rep; "__copyuser_seg" movsl\n"
27201 " movl %%eax,%0\n"
27202 - "7: rep; movsb\n"
27203 + "7: rep; "__copyuser_seg" movsb\n"
27204 "8:\n"
27205 ".section .fixup,\"ax\"\n"
27206 "9: lea 0(%%eax,%0,4),%0\n"
27207 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
27208 */
27209 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
27210 unsigned long size);
27211 -unsigned long __copy_user_intel(void __user *to, const void *from,
27212 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
27213 + unsigned long size);
27214 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
27215 unsigned long size);
27216 unsigned long __copy_user_zeroing_intel_nocache(void *to,
27217 const void __user *from, unsigned long size);
27218 #endif /* CONFIG_X86_INTEL_USERCOPY */
27219
27220 /* Generic arbitrary sized copy. */
27221 -#define __copy_user(to, from, size) \
27222 +#define __copy_user(to, from, size, prefix, set, restore) \
27223 do { \
27224 int __d0, __d1, __d2; \
27225 __asm__ __volatile__( \
27226 + set \
27227 " cmp $7,%0\n" \
27228 " jbe 1f\n" \
27229 " movl %1,%0\n" \
27230 " negl %0\n" \
27231 " andl $7,%0\n" \
27232 " subl %0,%3\n" \
27233 - "4: rep; movsb\n" \
27234 + "4: rep; "prefix"movsb\n" \
27235 " movl %3,%0\n" \
27236 " shrl $2,%0\n" \
27237 " andl $3,%3\n" \
27238 " .align 2,0x90\n" \
27239 - "0: rep; movsl\n" \
27240 + "0: rep; "prefix"movsl\n" \
27241 " movl %3,%0\n" \
27242 - "1: rep; movsb\n" \
27243 + "1: rep; "prefix"movsb\n" \
27244 "2:\n" \
27245 + restore \
27246 ".section .fixup,\"ax\"\n" \
27247 "5: addl %3,%0\n" \
27248 " jmp 2b\n" \
27249 @@ -538,14 +650,14 @@ do { \
27250 " negl %0\n" \
27251 " andl $7,%0\n" \
27252 " subl %0,%3\n" \
27253 - "4: rep; movsb\n" \
27254 + "4: rep; "__copyuser_seg"movsb\n" \
27255 " movl %3,%0\n" \
27256 " shrl $2,%0\n" \
27257 " andl $3,%3\n" \
27258 " .align 2,0x90\n" \
27259 - "0: rep; movsl\n" \
27260 + "0: rep; "__copyuser_seg"movsl\n" \
27261 " movl %3,%0\n" \
27262 - "1: rep; movsb\n" \
27263 + "1: rep; "__copyuser_seg"movsb\n" \
27264 "2:\n" \
27265 ".section .fixup,\"ax\"\n" \
27266 "5: addl %3,%0\n" \
27267 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27268 {
27269 stac();
27270 if (movsl_is_ok(to, from, n))
27271 - __copy_user(to, from, n);
27272 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27273 else
27274 - n = __copy_user_intel(to, from, n);
27275 + n = __generic_copy_to_user_intel(to, from, n);
27276 clac();
27277 return n;
27278 }
27279 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27280 {
27281 stac();
27282 if (movsl_is_ok(to, from, n))
27283 - __copy_user(to, from, n);
27284 + __copy_user(to, from, n, __copyuser_seg, "", "");
27285 else
27286 - n = __copy_user_intel((void __user *)to,
27287 - (const void *)from, n);
27288 + n = __generic_copy_from_user_intel(to, from, n);
27289 clac();
27290 return n;
27291 }
27292 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27293 if (n > 64 && cpu_has_xmm2)
27294 n = __copy_user_intel_nocache(to, from, n);
27295 else
27296 - __copy_user(to, from, n);
27297 + __copy_user(to, from, n, __copyuser_seg, "", "");
27298 #else
27299 - __copy_user(to, from, n);
27300 + __copy_user(to, from, n, __copyuser_seg, "", "");
27301 #endif
27302 clac();
27303 return n;
27304 }
27305 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27306
27307 -/**
27308 - * copy_to_user: - Copy a block of data into user space.
27309 - * @to: Destination address, in user space.
27310 - * @from: Source address, in kernel space.
27311 - * @n: Number of bytes to copy.
27312 - *
27313 - * Context: User context only. This function may sleep.
27314 - *
27315 - * Copy data from kernel space to user space.
27316 - *
27317 - * Returns number of bytes that could not be copied.
27318 - * On success, this will be zero.
27319 - */
27320 -unsigned long
27321 -copy_to_user(void __user *to, const void *from, unsigned long n)
27322 -{
27323 - if (access_ok(VERIFY_WRITE, to, n))
27324 - n = __copy_to_user(to, from, n);
27325 - return n;
27326 -}
27327 -EXPORT_SYMBOL(copy_to_user);
27328 -
27329 -/**
27330 - * copy_from_user: - Copy a block of data from user space.
27331 - * @to: Destination address, in kernel space.
27332 - * @from: Source address, in user space.
27333 - * @n: Number of bytes to copy.
27334 - *
27335 - * Context: User context only. This function may sleep.
27336 - *
27337 - * Copy data from user space to kernel space.
27338 - *
27339 - * Returns number of bytes that could not be copied.
27340 - * On success, this will be zero.
27341 - *
27342 - * If some data could not be copied, this function will pad the copied
27343 - * data to the requested size using zero bytes.
27344 - */
27345 -unsigned long
27346 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27347 -{
27348 - if (access_ok(VERIFY_READ, from, n))
27349 - n = __copy_from_user(to, from, n);
27350 - else
27351 - memset(to, 0, n);
27352 - return n;
27353 -}
27354 -EXPORT_SYMBOL(_copy_from_user);
27355 -
27356 void copy_from_user_overflow(void)
27357 {
27358 WARN(1, "Buffer overflow detected!\n");
27359 }
27360 EXPORT_SYMBOL(copy_from_user_overflow);
27361 +
27362 +void copy_to_user_overflow(void)
27363 +{
27364 + WARN(1, "Buffer overflow detected!\n");
27365 +}
27366 +EXPORT_SYMBOL(copy_to_user_overflow);
27367 +
27368 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27369 +void __set_fs(mm_segment_t x)
27370 +{
27371 + switch (x.seg) {
27372 + case 0:
27373 + loadsegment(gs, 0);
27374 + break;
27375 + case TASK_SIZE_MAX:
27376 + loadsegment(gs, __USER_DS);
27377 + break;
27378 + case -1UL:
27379 + loadsegment(gs, __KERNEL_DS);
27380 + break;
27381 + default:
27382 + BUG();
27383 + }
27384 + return;
27385 +}
27386 +EXPORT_SYMBOL(__set_fs);
27387 +
27388 +void set_fs(mm_segment_t x)
27389 +{
27390 + current_thread_info()->addr_limit = x;
27391 + __set_fs(x);
27392 +}
27393 +EXPORT_SYMBOL(set_fs);
27394 +#endif
27395 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27396 index 906fea3..ee8a097 100644
27397 --- a/arch/x86/lib/usercopy_64.c
27398 +++ b/arch/x86/lib/usercopy_64.c
27399 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27400 _ASM_EXTABLE(0b,3b)
27401 _ASM_EXTABLE(1b,2b)
27402 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27403 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27404 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27405 [zero] "r" (0UL), [eight] "r" (8UL));
27406 clac();
27407 return size;
27408 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27409 }
27410 EXPORT_SYMBOL(clear_user);
27411
27412 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27413 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27414 {
27415 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27416 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27417 - }
27418 - return len;
27419 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27420 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27421 + return len;
27422 }
27423 EXPORT_SYMBOL(copy_in_user);
27424
27425 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27426 * it is not necessary to optimize tail handling.
27427 */
27428 unsigned long
27429 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27430 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27431 {
27432 char c;
27433 unsigned zero_len;
27434 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27435 clac();
27436 return len;
27437 }
27438 +
27439 +void copy_from_user_overflow(void)
27440 +{
27441 + WARN(1, "Buffer overflow detected!\n");
27442 +}
27443 +EXPORT_SYMBOL(copy_from_user_overflow);
27444 +
27445 +void copy_to_user_overflow(void)
27446 +{
27447 + WARN(1, "Buffer overflow detected!\n");
27448 +}
27449 +EXPORT_SYMBOL(copy_to_user_overflow);
27450 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27451 index 903ec1e..c4166b2 100644
27452 --- a/arch/x86/mm/extable.c
27453 +++ b/arch/x86/mm/extable.c
27454 @@ -6,12 +6,24 @@
27455 static inline unsigned long
27456 ex_insn_addr(const struct exception_table_entry *x)
27457 {
27458 - return (unsigned long)&x->insn + x->insn;
27459 + unsigned long reloc = 0;
27460 +
27461 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27462 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27463 +#endif
27464 +
27465 + return (unsigned long)&x->insn + x->insn + reloc;
27466 }
27467 static inline unsigned long
27468 ex_fixup_addr(const struct exception_table_entry *x)
27469 {
27470 - return (unsigned long)&x->fixup + x->fixup;
27471 + unsigned long reloc = 0;
27472 +
27473 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27474 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27475 +#endif
27476 +
27477 + return (unsigned long)&x->fixup + x->fixup + reloc;
27478 }
27479
27480 int fixup_exception(struct pt_regs *regs)
27481 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27482 unsigned long new_ip;
27483
27484 #ifdef CONFIG_PNPBIOS
27485 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27486 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27487 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27488 extern u32 pnp_bios_is_utter_crap;
27489 pnp_bios_is_utter_crap = 1;
27490 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27491 i += 4;
27492 p->fixup -= i;
27493 i += 4;
27494 +
27495 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27496 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27497 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27498 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27499 +#endif
27500 +
27501 }
27502 }
27503
27504 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27505 index 4f7d793..165a8be 100644
27506 --- a/arch/x86/mm/fault.c
27507 +++ b/arch/x86/mm/fault.c
27508 @@ -13,12 +13,19 @@
27509 #include <linux/perf_event.h> /* perf_sw_event */
27510 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27511 #include <linux/prefetch.h> /* prefetchw */
27512 +#include <linux/unistd.h>
27513 +#include <linux/compiler.h>
27514
27515 #include <asm/traps.h> /* dotraplinkage, ... */
27516 #include <asm/pgalloc.h> /* pgd_*(), ... */
27517 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27518 #include <asm/fixmap.h> /* VSYSCALL_START */
27519 #include <asm/context_tracking.h> /* exception_enter(), ... */
27520 +#include <asm/tlbflush.h>
27521 +
27522 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27523 +#include <asm/stacktrace.h>
27524 +#endif
27525
27526 /*
27527 * Page fault error code bits:
27528 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27529 int ret = 0;
27530
27531 /* kprobe_running() needs smp_processor_id() */
27532 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27533 + if (kprobes_built_in() && !user_mode(regs)) {
27534 preempt_disable();
27535 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27536 ret = 1;
27537 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27538 return !instr_lo || (instr_lo>>1) == 1;
27539 case 0x00:
27540 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27541 - if (probe_kernel_address(instr, opcode))
27542 + if (user_mode(regs)) {
27543 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27544 + return 0;
27545 + } else if (probe_kernel_address(instr, opcode))
27546 return 0;
27547
27548 *prefetch = (instr_lo == 0xF) &&
27549 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27550 while (instr < max_instr) {
27551 unsigned char opcode;
27552
27553 - if (probe_kernel_address(instr, opcode))
27554 + if (user_mode(regs)) {
27555 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27556 + break;
27557 + } else if (probe_kernel_address(instr, opcode))
27558 break;
27559
27560 instr++;
27561 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27562 force_sig_info(si_signo, &info, tsk);
27563 }
27564
27565 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27566 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27567 +#endif
27568 +
27569 +#ifdef CONFIG_PAX_EMUTRAMP
27570 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27571 +#endif
27572 +
27573 +#ifdef CONFIG_PAX_PAGEEXEC
27574 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27575 +{
27576 + pgd_t *pgd;
27577 + pud_t *pud;
27578 + pmd_t *pmd;
27579 +
27580 + pgd = pgd_offset(mm, address);
27581 + if (!pgd_present(*pgd))
27582 + return NULL;
27583 + pud = pud_offset(pgd, address);
27584 + if (!pud_present(*pud))
27585 + return NULL;
27586 + pmd = pmd_offset(pud, address);
27587 + if (!pmd_present(*pmd))
27588 + return NULL;
27589 + return pmd;
27590 +}
27591 +#endif
27592 +
27593 DEFINE_SPINLOCK(pgd_lock);
27594 LIST_HEAD(pgd_list);
27595
27596 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27597 for (address = VMALLOC_START & PMD_MASK;
27598 address >= TASK_SIZE && address < FIXADDR_TOP;
27599 address += PMD_SIZE) {
27600 +
27601 +#ifdef CONFIG_PAX_PER_CPU_PGD
27602 + unsigned long cpu;
27603 +#else
27604 struct page *page;
27605 +#endif
27606
27607 spin_lock(&pgd_lock);
27608 +
27609 +#ifdef CONFIG_PAX_PER_CPU_PGD
27610 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27611 + pgd_t *pgd = get_cpu_pgd(cpu);
27612 + pmd_t *ret;
27613 +#else
27614 list_for_each_entry(page, &pgd_list, lru) {
27615 + pgd_t *pgd;
27616 spinlock_t *pgt_lock;
27617 pmd_t *ret;
27618
27619 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27620 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27621
27622 spin_lock(pgt_lock);
27623 - ret = vmalloc_sync_one(page_address(page), address);
27624 + pgd = page_address(page);
27625 +#endif
27626 +
27627 + ret = vmalloc_sync_one(pgd, address);
27628 +
27629 +#ifndef CONFIG_PAX_PER_CPU_PGD
27630 spin_unlock(pgt_lock);
27631 +#endif
27632
27633 if (!ret)
27634 break;
27635 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27636 * an interrupt in the middle of a task switch..
27637 */
27638 pgd_paddr = read_cr3();
27639 +
27640 +#ifdef CONFIG_PAX_PER_CPU_PGD
27641 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27642 +#endif
27643 +
27644 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27645 if (!pmd_k)
27646 return -1;
27647 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27648 * happen within a race in page table update. In the later
27649 * case just flush:
27650 */
27651 +
27652 +#ifdef CONFIG_PAX_PER_CPU_PGD
27653 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27654 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27655 +#else
27656 pgd = pgd_offset(current->active_mm, address);
27657 +#endif
27658 +
27659 pgd_ref = pgd_offset_k(address);
27660 if (pgd_none(*pgd_ref))
27661 return -1;
27662 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27663 static int is_errata100(struct pt_regs *regs, unsigned long address)
27664 {
27665 #ifdef CONFIG_X86_64
27666 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27667 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27668 return 1;
27669 #endif
27670 return 0;
27671 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27672 }
27673
27674 static const char nx_warning[] = KERN_CRIT
27675 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27676 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27677
27678 static void
27679 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27680 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27681 if (!oops_may_print())
27682 return;
27683
27684 - if (error_code & PF_INSTR) {
27685 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27686 unsigned int level;
27687
27688 pte_t *pte = lookup_address(address, &level);
27689
27690 if (pte && pte_present(*pte) && !pte_exec(*pte))
27691 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27692 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27693 }
27694
27695 +#ifdef CONFIG_PAX_KERNEXEC
27696 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27697 + if (current->signal->curr_ip)
27698 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27699 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27700 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27701 + else
27702 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27703 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27704 + }
27705 +#endif
27706 +
27707 printk(KERN_ALERT "BUG: unable to handle kernel ");
27708 if (address < PAGE_SIZE)
27709 printk(KERN_CONT "NULL pointer dereference");
27710 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27711 return;
27712 }
27713 #endif
27714 +
27715 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27716 + if (pax_is_fetch_fault(regs, error_code, address)) {
27717 +
27718 +#ifdef CONFIG_PAX_EMUTRAMP
27719 + switch (pax_handle_fetch_fault(regs)) {
27720 + case 2:
27721 + return;
27722 + }
27723 +#endif
27724 +
27725 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27726 + do_group_exit(SIGKILL);
27727 + }
27728 +#endif
27729 +
27730 /* Kernel addresses are always protection faults: */
27731 if (address >= TASK_SIZE)
27732 error_code |= PF_PROT;
27733 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27734 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27735 printk(KERN_ERR
27736 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27737 - tsk->comm, tsk->pid, address);
27738 + tsk->comm, task_pid_nr(tsk), address);
27739 code = BUS_MCEERR_AR;
27740 }
27741 #endif
27742 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27743 return 1;
27744 }
27745
27746 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27747 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27748 +{
27749 + pte_t *pte;
27750 + pmd_t *pmd;
27751 + spinlock_t *ptl;
27752 + unsigned char pte_mask;
27753 +
27754 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27755 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27756 + return 0;
27757 +
27758 + /* PaX: it's our fault, let's handle it if we can */
27759 +
27760 + /* PaX: take a look at read faults before acquiring any locks */
27761 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27762 + /* instruction fetch attempt from a protected page in user mode */
27763 + up_read(&mm->mmap_sem);
27764 +
27765 +#ifdef CONFIG_PAX_EMUTRAMP
27766 + switch (pax_handle_fetch_fault(regs)) {
27767 + case 2:
27768 + return 1;
27769 + }
27770 +#endif
27771 +
27772 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27773 + do_group_exit(SIGKILL);
27774 + }
27775 +
27776 + pmd = pax_get_pmd(mm, address);
27777 + if (unlikely(!pmd))
27778 + return 0;
27779 +
27780 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27781 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27782 + pte_unmap_unlock(pte, ptl);
27783 + return 0;
27784 + }
27785 +
27786 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27787 + /* write attempt to a protected page in user mode */
27788 + pte_unmap_unlock(pte, ptl);
27789 + return 0;
27790 + }
27791 +
27792 +#ifdef CONFIG_SMP
27793 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27794 +#else
27795 + if (likely(address > get_limit(regs->cs)))
27796 +#endif
27797 + {
27798 + set_pte(pte, pte_mkread(*pte));
27799 + __flush_tlb_one(address);
27800 + pte_unmap_unlock(pte, ptl);
27801 + up_read(&mm->mmap_sem);
27802 + return 1;
27803 + }
27804 +
27805 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27806 +
27807 + /*
27808 + * PaX: fill DTLB with user rights and retry
27809 + */
27810 + __asm__ __volatile__ (
27811 + "orb %2,(%1)\n"
27812 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27813 +/*
27814 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27815 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27816 + * page fault when examined during a TLB load attempt. this is true not only
27817 + * for PTEs holding a non-present entry but also present entries that will
27818 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27819 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27820 + * for our target pages since their PTEs are simply not in the TLBs at all.
27821 +
27822 + * the best thing in omitting it is that we gain around 15-20% speed in the
27823 + * fast path of the page fault handler and can get rid of tracing since we
27824 + * can no longer flush unintended entries.
27825 + */
27826 + "invlpg (%0)\n"
27827 +#endif
27828 + __copyuser_seg"testb $0,(%0)\n"
27829 + "xorb %3,(%1)\n"
27830 + :
27831 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27832 + : "memory", "cc");
27833 + pte_unmap_unlock(pte, ptl);
27834 + up_read(&mm->mmap_sem);
27835 + return 1;
27836 +}
27837 +#endif
27838 +
27839 /*
27840 * Handle a spurious fault caused by a stale TLB entry.
27841 *
27842 @@ -970,6 +1162,9 @@ int show_unhandled_signals = 1;
27843 static inline int
27844 access_error(unsigned long error_code, struct vm_area_struct *vma)
27845 {
27846 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27847 + return 1;
27848 +
27849 if (error_code & PF_WRITE) {
27850 /* write, present and write, not present: */
27851 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27852 @@ -998,7 +1193,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27853 if (error_code & PF_USER)
27854 return false;
27855
27856 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27857 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27858 return false;
27859
27860 return true;
27861 @@ -1014,18 +1209,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27862 {
27863 struct vm_area_struct *vma;
27864 struct task_struct *tsk;
27865 - unsigned long address;
27866 struct mm_struct *mm;
27867 int fault;
27868 int write = error_code & PF_WRITE;
27869 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27870 (write ? FAULT_FLAG_WRITE : 0);
27871
27872 - tsk = current;
27873 - mm = tsk->mm;
27874 -
27875 /* Get the faulting address: */
27876 - address = read_cr2();
27877 + unsigned long address = read_cr2();
27878 +
27879 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27880 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
27881 + if (!search_exception_tables(regs->ip)) {
27882 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27883 + bad_area_nosemaphore(regs, error_code, address);
27884 + return;
27885 + }
27886 + if (address < PAX_USER_SHADOW_BASE) {
27887 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27888 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27889 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27890 + } else
27891 + address -= PAX_USER_SHADOW_BASE;
27892 + }
27893 +#endif
27894 +
27895 + tsk = current;
27896 + mm = tsk->mm;
27897
27898 /*
27899 * Detect and handle instructions that would cause a page fault for
27900 @@ -1086,7 +1296,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27901 * User-mode registers count as a user access even for any
27902 * potential system fault or CPU buglet:
27903 */
27904 - if (user_mode_vm(regs)) {
27905 + if (user_mode(regs)) {
27906 local_irq_enable();
27907 error_code |= PF_USER;
27908 } else {
27909 @@ -1148,6 +1358,11 @@ retry:
27910 might_sleep();
27911 }
27912
27913 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27914 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27915 + return;
27916 +#endif
27917 +
27918 vma = find_vma(mm, address);
27919 if (unlikely(!vma)) {
27920 bad_area(regs, error_code, address);
27921 @@ -1159,18 +1374,24 @@ retry:
27922 bad_area(regs, error_code, address);
27923 return;
27924 }
27925 - if (error_code & PF_USER) {
27926 - /*
27927 - * Accessing the stack below %sp is always a bug.
27928 - * The large cushion allows instructions like enter
27929 - * and pusha to work. ("enter $65535, $31" pushes
27930 - * 32 pointers and then decrements %sp by 65535.)
27931 - */
27932 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27933 - bad_area(regs, error_code, address);
27934 - return;
27935 - }
27936 + /*
27937 + * Accessing the stack below %sp is always a bug.
27938 + * The large cushion allows instructions like enter
27939 + * and pusha to work. ("enter $65535, $31" pushes
27940 + * 32 pointers and then decrements %sp by 65535.)
27941 + */
27942 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27943 + bad_area(regs, error_code, address);
27944 + return;
27945 }
27946 +
27947 +#ifdef CONFIG_PAX_SEGMEXEC
27948 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27949 + bad_area(regs, error_code, address);
27950 + return;
27951 + }
27952 +#endif
27953 +
27954 if (unlikely(expand_stack(vma, address))) {
27955 bad_area(regs, error_code, address);
27956 return;
27957 @@ -1234,3 +1455,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27958 __do_page_fault(regs, error_code);
27959 exception_exit(regs);
27960 }
27961 +
27962 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27963 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27964 +{
27965 + struct mm_struct *mm = current->mm;
27966 + unsigned long ip = regs->ip;
27967 +
27968 + if (v8086_mode(regs))
27969 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27970 +
27971 +#ifdef CONFIG_PAX_PAGEEXEC
27972 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27973 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27974 + return true;
27975 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27976 + return true;
27977 + return false;
27978 + }
27979 +#endif
27980 +
27981 +#ifdef CONFIG_PAX_SEGMEXEC
27982 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27983 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27984 + return true;
27985 + return false;
27986 + }
27987 +#endif
27988 +
27989 + return false;
27990 +}
27991 +#endif
27992 +
27993 +#ifdef CONFIG_PAX_EMUTRAMP
27994 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27995 +{
27996 + int err;
27997 +
27998 + do { /* PaX: libffi trampoline emulation */
27999 + unsigned char mov, jmp;
28000 + unsigned int addr1, addr2;
28001 +
28002 +#ifdef CONFIG_X86_64
28003 + if ((regs->ip + 9) >> 32)
28004 + break;
28005 +#endif
28006 +
28007 + err = get_user(mov, (unsigned char __user *)regs->ip);
28008 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28009 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28010 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28011 +
28012 + if (err)
28013 + break;
28014 +
28015 + if (mov == 0xB8 && jmp == 0xE9) {
28016 + regs->ax = addr1;
28017 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28018 + return 2;
28019 + }
28020 + } while (0);
28021 +
28022 + do { /* PaX: gcc trampoline emulation #1 */
28023 + unsigned char mov1, mov2;
28024 + unsigned short jmp;
28025 + unsigned int addr1, addr2;
28026 +
28027 +#ifdef CONFIG_X86_64
28028 + if ((regs->ip + 11) >> 32)
28029 + break;
28030 +#endif
28031 +
28032 + err = get_user(mov1, (unsigned char __user *)regs->ip);
28033 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28034 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
28035 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28036 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
28037 +
28038 + if (err)
28039 + break;
28040 +
28041 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
28042 + regs->cx = addr1;
28043 + regs->ax = addr2;
28044 + regs->ip = addr2;
28045 + return 2;
28046 + }
28047 + } while (0);
28048 +
28049 + do { /* PaX: gcc trampoline emulation #2 */
28050 + unsigned char mov, jmp;
28051 + unsigned int addr1, addr2;
28052 +
28053 +#ifdef CONFIG_X86_64
28054 + if ((regs->ip + 9) >> 32)
28055 + break;
28056 +#endif
28057 +
28058 + err = get_user(mov, (unsigned char __user *)regs->ip);
28059 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28060 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28061 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28062 +
28063 + if (err)
28064 + break;
28065 +
28066 + if (mov == 0xB9 && jmp == 0xE9) {
28067 + regs->cx = addr1;
28068 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28069 + return 2;
28070 + }
28071 + } while (0);
28072 +
28073 + return 1; /* PaX in action */
28074 +}
28075 +
28076 +#ifdef CONFIG_X86_64
28077 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
28078 +{
28079 + int err;
28080 +
28081 + do { /* PaX: libffi trampoline emulation */
28082 + unsigned short mov1, mov2, jmp1;
28083 + unsigned char stcclc, jmp2;
28084 + unsigned long addr1, addr2;
28085 +
28086 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28087 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28088 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28089 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28090 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
28091 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
28092 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
28093 +
28094 + if (err)
28095 + break;
28096 +
28097 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28098 + regs->r11 = addr1;
28099 + regs->r10 = addr2;
28100 + if (stcclc == 0xF8)
28101 + regs->flags &= ~X86_EFLAGS_CF;
28102 + else
28103 + regs->flags |= X86_EFLAGS_CF;
28104 + regs->ip = addr1;
28105 + return 2;
28106 + }
28107 + } while (0);
28108 +
28109 + do { /* PaX: gcc trampoline emulation #1 */
28110 + unsigned short mov1, mov2, jmp1;
28111 + unsigned char jmp2;
28112 + unsigned int addr1;
28113 + unsigned long addr2;
28114 +
28115 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28116 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
28117 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
28118 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
28119 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
28120 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
28121 +
28122 + if (err)
28123 + break;
28124 +
28125 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28126 + regs->r11 = addr1;
28127 + regs->r10 = addr2;
28128 + regs->ip = addr1;
28129 + return 2;
28130 + }
28131 + } while (0);
28132 +
28133 + do { /* PaX: gcc trampoline emulation #2 */
28134 + unsigned short mov1, mov2, jmp1;
28135 + unsigned char jmp2;
28136 + unsigned long addr1, addr2;
28137 +
28138 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28139 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28140 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28141 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28142 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
28143 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
28144 +
28145 + if (err)
28146 + break;
28147 +
28148 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28149 + regs->r11 = addr1;
28150 + regs->r10 = addr2;
28151 + regs->ip = addr1;
28152 + return 2;
28153 + }
28154 + } while (0);
28155 +
28156 + return 1; /* PaX in action */
28157 +}
28158 +#endif
28159 +
28160 +/*
28161 + * PaX: decide what to do with offenders (regs->ip = fault address)
28162 + *
28163 + * returns 1 when task should be killed
28164 + * 2 when gcc trampoline was detected
28165 + */
28166 +static int pax_handle_fetch_fault(struct pt_regs *regs)
28167 +{
28168 + if (v8086_mode(regs))
28169 + return 1;
28170 +
28171 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
28172 + return 1;
28173 +
28174 +#ifdef CONFIG_X86_32
28175 + return pax_handle_fetch_fault_32(regs);
28176 +#else
28177 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
28178 + return pax_handle_fetch_fault_32(regs);
28179 + else
28180 + return pax_handle_fetch_fault_64(regs);
28181 +#endif
28182 +}
28183 +#endif
28184 +
28185 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28186 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
28187 +{
28188 + long i;
28189 +
28190 + printk(KERN_ERR "PAX: bytes at PC: ");
28191 + for (i = 0; i < 20; i++) {
28192 + unsigned char c;
28193 + if (get_user(c, (unsigned char __force_user *)pc+i))
28194 + printk(KERN_CONT "?? ");
28195 + else
28196 + printk(KERN_CONT "%02x ", c);
28197 + }
28198 + printk("\n");
28199 +
28200 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
28201 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
28202 + unsigned long c;
28203 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
28204 +#ifdef CONFIG_X86_32
28205 + printk(KERN_CONT "???????? ");
28206 +#else
28207 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
28208 + printk(KERN_CONT "???????? ???????? ");
28209 + else
28210 + printk(KERN_CONT "???????????????? ");
28211 +#endif
28212 + } else {
28213 +#ifdef CONFIG_X86_64
28214 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
28215 + printk(KERN_CONT "%08x ", (unsigned int)c);
28216 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
28217 + } else
28218 +#endif
28219 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
28220 + }
28221 + }
28222 + printk("\n");
28223 +}
28224 +#endif
28225 +
28226 +/**
28227 + * probe_kernel_write(): safely attempt to write to a location
28228 + * @dst: address to write to
28229 + * @src: pointer to the data that shall be written
28230 + * @size: size of the data chunk
28231 + *
28232 + * Safely write to address @dst from the buffer at @src. If a kernel fault
28233 + * happens, handle that and return -EFAULT.
28234 + */
28235 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
28236 +{
28237 + long ret;
28238 + mm_segment_t old_fs = get_fs();
28239 +
28240 + set_fs(KERNEL_DS);
28241 + pagefault_disable();
28242 + pax_open_kernel();
28243 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
28244 + pax_close_kernel();
28245 + pagefault_enable();
28246 + set_fs(old_fs);
28247 +
28248 + return ret ? -EFAULT : 0;
28249 +}
28250 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
28251 index dd74e46..7d26398 100644
28252 --- a/arch/x86/mm/gup.c
28253 +++ b/arch/x86/mm/gup.c
28254 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
28255 addr = start;
28256 len = (unsigned long) nr_pages << PAGE_SHIFT;
28257 end = start + len;
28258 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28259 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28260 (void __user *)start, len)))
28261 return 0;
28262
28263 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
28264 index 6f31ee5..8ee4164 100644
28265 --- a/arch/x86/mm/highmem_32.c
28266 +++ b/arch/x86/mm/highmem_32.c
28267 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
28268 idx = type + KM_TYPE_NR*smp_processor_id();
28269 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28270 BUG_ON(!pte_none(*(kmap_pte-idx)));
28271 +
28272 + pax_open_kernel();
28273 set_pte(kmap_pte-idx, mk_pte(page, prot));
28274 + pax_close_kernel();
28275 +
28276 arch_flush_lazy_mmu_mode();
28277
28278 return (void *)vaddr;
28279 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28280 index ae1aa71..56316db 100644
28281 --- a/arch/x86/mm/hugetlbpage.c
28282 +++ b/arch/x86/mm/hugetlbpage.c
28283 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28284 info.flags = 0;
28285 info.length = len;
28286 info.low_limit = TASK_UNMAPPED_BASE;
28287 +
28288 +#ifdef CONFIG_PAX_RANDMMAP
28289 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28290 + info.low_limit += current->mm->delta_mmap;
28291 +#endif
28292 +
28293 info.high_limit = TASK_SIZE;
28294 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28295 info.align_offset = 0;
28296 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28297 VM_BUG_ON(addr != -ENOMEM);
28298 info.flags = 0;
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 addr = vm_unmapped_area(&info);
28308 }
28309 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28310 struct hstate *h = hstate_file(file);
28311 struct mm_struct *mm = current->mm;
28312 struct vm_area_struct *vma;
28313 + unsigned long pax_task_size = TASK_SIZE;
28314 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28315
28316 if (len & ~huge_page_mask(h))
28317 return -EINVAL;
28318 - if (len > TASK_SIZE)
28319 +
28320 +#ifdef CONFIG_PAX_SEGMEXEC
28321 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28322 + pax_task_size = SEGMEXEC_TASK_SIZE;
28323 +#endif
28324 +
28325 + pax_task_size -= PAGE_SIZE;
28326 +
28327 + if (len > pax_task_size)
28328 return -ENOMEM;
28329
28330 if (flags & MAP_FIXED) {
28331 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28332 return addr;
28333 }
28334
28335 +#ifdef CONFIG_PAX_RANDMMAP
28336 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28337 +#endif
28338 +
28339 if (addr) {
28340 addr = ALIGN(addr, huge_page_size(h));
28341 vma = find_vma(mm, addr);
28342 - if (TASK_SIZE - len >= addr &&
28343 - (!vma || addr + len <= vma->vm_start))
28344 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28345 return addr;
28346 }
28347 if (mm->get_unmapped_area == arch_get_unmapped_area)
28348 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28349 index d7aea41..0fc945b 100644
28350 --- a/arch/x86/mm/init.c
28351 +++ b/arch/x86/mm/init.c
28352 @@ -4,6 +4,7 @@
28353 #include <linux/swap.h>
28354 #include <linux/memblock.h>
28355 #include <linux/bootmem.h> /* for max_low_pfn */
28356 +#include <linux/tboot.h>
28357
28358 #include <asm/cacheflush.h>
28359 #include <asm/e820.h>
28360 @@ -16,6 +17,8 @@
28361 #include <asm/tlb.h>
28362 #include <asm/proto.h>
28363 #include <asm/dma.h> /* for MAX_DMA_PFN */
28364 +#include <asm/desc.h>
28365 +#include <asm/bios_ebda.h>
28366
28367 unsigned long __initdata pgt_buf_start;
28368 unsigned long __meminitdata pgt_buf_end;
28369 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
28370 {
28371 int i;
28372 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
28373 - unsigned long start = 0, good_end;
28374 + unsigned long start = 0x100000, good_end;
28375 phys_addr_t base;
28376
28377 for (i = 0; i < nr_range; i++) {
28378 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
28379 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28380 * mmio resources as well as potential bios/acpi data regions.
28381 */
28382 +
28383 +#ifdef CONFIG_GRKERNSEC_KMEM
28384 +static unsigned int ebda_start __read_only;
28385 +static unsigned int ebda_end __read_only;
28386 +#endif
28387 +
28388 int devmem_is_allowed(unsigned long pagenr)
28389 {
28390 - if (pagenr < 256)
28391 +#ifdef CONFIG_GRKERNSEC_KMEM
28392 + /* allow BDA */
28393 + if (!pagenr)
28394 return 1;
28395 + /* allow EBDA */
28396 + if (pagenr >= ebda_start && pagenr < ebda_end)
28397 + return 1;
28398 + /* if tboot is in use, allow access to its hardcoded serial log range */
28399 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28400 + return 1;
28401 +#else
28402 + if (!pagenr)
28403 + return 1;
28404 +#ifdef CONFIG_VM86
28405 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28406 + return 1;
28407 +#endif
28408 +#endif
28409 +
28410 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28411 + return 1;
28412 +#ifdef CONFIG_GRKERNSEC_KMEM
28413 + /* throw out everything else below 1MB */
28414 + if (pagenr <= 256)
28415 + return 0;
28416 +#endif
28417 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28418 return 0;
28419 if (!page_is_ram(pagenr))
28420 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28421 #endif
28422 }
28423
28424 +#ifdef CONFIG_GRKERNSEC_KMEM
28425 +static inline void gr_init_ebda(void)
28426 +{
28427 + unsigned int ebda_addr;
28428 + unsigned int ebda_size = 0;
28429 +
28430 + ebda_addr = get_bios_ebda();
28431 + if (ebda_addr) {
28432 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28433 + ebda_size <<= 10;
28434 + }
28435 + if (ebda_addr && ebda_size) {
28436 + ebda_start = ebda_addr >> PAGE_SHIFT;
28437 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28438 + } else {
28439 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28440 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28441 + }
28442 +}
28443 +#else
28444 +static inline void gr_init_ebda(void) { }
28445 +#endif
28446 +
28447 void free_initmem(void)
28448 {
28449 +#ifdef CONFIG_PAX_KERNEXEC
28450 +#ifdef CONFIG_X86_32
28451 + /* PaX: limit KERNEL_CS to actual size */
28452 + unsigned long addr, limit;
28453 + struct desc_struct d;
28454 + int cpu;
28455 +#else
28456 + pgd_t *pgd;
28457 + pud_t *pud;
28458 + pmd_t *pmd;
28459 + unsigned long addr, end;
28460 +#endif
28461 +#endif
28462 +
28463 + gr_init_ebda();
28464 +
28465 +#ifdef CONFIG_PAX_KERNEXEC
28466 +#ifdef CONFIG_X86_32
28467 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28468 + limit = (limit - 1UL) >> PAGE_SHIFT;
28469 +
28470 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28471 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28472 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28473 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28474 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28475 + }
28476 +
28477 + /* PaX: make KERNEL_CS read-only */
28478 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28479 + if (!paravirt_enabled())
28480 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28481 +/*
28482 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28483 + pgd = pgd_offset_k(addr);
28484 + pud = pud_offset(pgd, addr);
28485 + pmd = pmd_offset(pud, addr);
28486 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28487 + }
28488 +*/
28489 +#ifdef CONFIG_X86_PAE
28490 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28491 +/*
28492 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28493 + pgd = pgd_offset_k(addr);
28494 + pud = pud_offset(pgd, addr);
28495 + pmd = pmd_offset(pud, addr);
28496 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28497 + }
28498 +*/
28499 +#endif
28500 +
28501 +#ifdef CONFIG_MODULES
28502 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28503 +#endif
28504 +
28505 +#else
28506 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28507 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28508 + pgd = pgd_offset_k(addr);
28509 + pud = pud_offset(pgd, addr);
28510 + pmd = pmd_offset(pud, addr);
28511 + if (!pmd_present(*pmd))
28512 + continue;
28513 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28514 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28515 + else
28516 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28517 + }
28518 +
28519 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28520 + end = addr + KERNEL_IMAGE_SIZE;
28521 + for (; addr < end; addr += PMD_SIZE) {
28522 + pgd = pgd_offset_k(addr);
28523 + pud = pud_offset(pgd, addr);
28524 + pmd = pmd_offset(pud, addr);
28525 + if (!pmd_present(*pmd))
28526 + continue;
28527 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28528 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28529 + }
28530 +#endif
28531 +
28532 + flush_tlb_all();
28533 +#endif
28534 +
28535 free_init_pages("unused kernel memory",
28536 (unsigned long)(&__init_begin),
28537 (unsigned long)(&__init_end));
28538 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28539 index 745d66b..56bf568 100644
28540 --- a/arch/x86/mm/init_32.c
28541 +++ b/arch/x86/mm/init_32.c
28542 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
28543 }
28544
28545 /*
28546 - * Creates a middle page table and puts a pointer to it in the
28547 - * given global directory entry. This only returns the gd entry
28548 - * in non-PAE compilation mode, since the middle layer is folded.
28549 - */
28550 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28551 -{
28552 - pud_t *pud;
28553 - pmd_t *pmd_table;
28554 -
28555 -#ifdef CONFIG_X86_PAE
28556 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28557 - if (after_bootmem)
28558 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
28559 - else
28560 - pmd_table = (pmd_t *)alloc_low_page();
28561 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28562 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28563 - pud = pud_offset(pgd, 0);
28564 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28565 -
28566 - return pmd_table;
28567 - }
28568 -#endif
28569 - pud = pud_offset(pgd, 0);
28570 - pmd_table = pmd_offset(pud, 0);
28571 -
28572 - return pmd_table;
28573 -}
28574 -
28575 -/*
28576 * Create a page table and place a pointer to it in a middle page
28577 * directory entry:
28578 */
28579 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28580 page_table = (pte_t *)alloc_low_page();
28581
28582 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28583 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28584 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28585 +#else
28586 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28587 +#endif
28588 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28589 }
28590
28591 return pte_offset_kernel(pmd, 0);
28592 }
28593
28594 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28595 +{
28596 + pud_t *pud;
28597 + pmd_t *pmd_table;
28598 +
28599 + pud = pud_offset(pgd, 0);
28600 + pmd_table = pmd_offset(pud, 0);
28601 +
28602 + return pmd_table;
28603 +}
28604 +
28605 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28606 {
28607 int pgd_idx = pgd_index(vaddr);
28608 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28609 int pgd_idx, pmd_idx;
28610 unsigned long vaddr;
28611 pgd_t *pgd;
28612 + pud_t *pud;
28613 pmd_t *pmd;
28614 pte_t *pte = NULL;
28615
28616 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28617 pgd = pgd_base + pgd_idx;
28618
28619 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28620 - pmd = one_md_table_init(pgd);
28621 - pmd = pmd + pmd_index(vaddr);
28622 + pud = pud_offset(pgd, vaddr);
28623 + pmd = pmd_offset(pud, vaddr);
28624 +
28625 +#ifdef CONFIG_X86_PAE
28626 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28627 +#endif
28628 +
28629 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28630 pmd++, pmd_idx++) {
28631 pte = page_table_kmap_check(one_page_table_init(pmd),
28632 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28633 }
28634 }
28635
28636 -static inline int is_kernel_text(unsigned long addr)
28637 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28638 {
28639 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28640 - return 1;
28641 - return 0;
28642 + if ((start > ktla_ktva((unsigned long)_etext) ||
28643 + end <= ktla_ktva((unsigned long)_stext)) &&
28644 + (start > ktla_ktva((unsigned long)_einittext) ||
28645 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28646 +
28647 +#ifdef CONFIG_ACPI_SLEEP
28648 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28649 +#endif
28650 +
28651 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28652 + return 0;
28653 + return 1;
28654 }
28655
28656 /*
28657 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
28658 unsigned long last_map_addr = end;
28659 unsigned long start_pfn, end_pfn;
28660 pgd_t *pgd_base = swapper_pg_dir;
28661 - int pgd_idx, pmd_idx, pte_ofs;
28662 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28663 unsigned long pfn;
28664 pgd_t *pgd;
28665 + pud_t *pud;
28666 pmd_t *pmd;
28667 pte_t *pte;
28668 unsigned pages_2m, pages_4k;
28669 @@ -280,8 +281,13 @@ repeat:
28670 pfn = start_pfn;
28671 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28672 pgd = pgd_base + pgd_idx;
28673 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28674 - pmd = one_md_table_init(pgd);
28675 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28676 + pud = pud_offset(pgd, 0);
28677 + pmd = pmd_offset(pud, 0);
28678 +
28679 +#ifdef CONFIG_X86_PAE
28680 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28681 +#endif
28682
28683 if (pfn >= end_pfn)
28684 continue;
28685 @@ -293,14 +299,13 @@ repeat:
28686 #endif
28687 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28688 pmd++, pmd_idx++) {
28689 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28690 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28691
28692 /*
28693 * Map with big pages if possible, otherwise
28694 * create normal page tables:
28695 */
28696 if (use_pse) {
28697 - unsigned int addr2;
28698 pgprot_t prot = PAGE_KERNEL_LARGE;
28699 /*
28700 * first pass will use the same initial
28701 @@ -310,11 +315,7 @@ repeat:
28702 __pgprot(PTE_IDENT_ATTR |
28703 _PAGE_PSE);
28704
28705 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28706 - PAGE_OFFSET + PAGE_SIZE-1;
28707 -
28708 - if (is_kernel_text(addr) ||
28709 - is_kernel_text(addr2))
28710 + if (is_kernel_text(address, address + PMD_SIZE))
28711 prot = PAGE_KERNEL_LARGE_EXEC;
28712
28713 pages_2m++;
28714 @@ -331,7 +332,7 @@ repeat:
28715 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28716 pte += pte_ofs;
28717 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28718 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28719 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28720 pgprot_t prot = PAGE_KERNEL;
28721 /*
28722 * first pass will use the same initial
28723 @@ -339,7 +340,7 @@ repeat:
28724 */
28725 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28726
28727 - if (is_kernel_text(addr))
28728 + if (is_kernel_text(address, address + PAGE_SIZE))
28729 prot = PAGE_KERNEL_EXEC;
28730
28731 pages_4k++;
28732 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
28733
28734 pud = pud_offset(pgd, va);
28735 pmd = pmd_offset(pud, va);
28736 - if (!pmd_present(*pmd))
28737 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
28738 break;
28739
28740 pte = pte_offset_kernel(pmd, va);
28741 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
28742
28743 static void __init pagetable_init(void)
28744 {
28745 - pgd_t *pgd_base = swapper_pg_dir;
28746 -
28747 - permanent_kmaps_init(pgd_base);
28748 + permanent_kmaps_init(swapper_pg_dir);
28749 }
28750
28751 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28752 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28753 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28754
28755 /* user-defined highmem size */
28756 @@ -728,6 +727,12 @@ void __init mem_init(void)
28757
28758 pci_iommu_alloc();
28759
28760 +#ifdef CONFIG_PAX_PER_CPU_PGD
28761 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28762 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28763 + KERNEL_PGD_PTRS);
28764 +#endif
28765 +
28766 #ifdef CONFIG_FLATMEM
28767 BUG_ON(!mem_map);
28768 #endif
28769 @@ -754,7 +759,7 @@ void __init mem_init(void)
28770 reservedpages++;
28771
28772 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28773 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28774 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28775 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28776
28777 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28778 @@ -795,10 +800,10 @@ void __init mem_init(void)
28779 ((unsigned long)&__init_end -
28780 (unsigned long)&__init_begin) >> 10,
28781
28782 - (unsigned long)&_etext, (unsigned long)&_edata,
28783 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28784 + (unsigned long)&_sdata, (unsigned long)&_edata,
28785 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28786
28787 - (unsigned long)&_text, (unsigned long)&_etext,
28788 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28789 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28790
28791 /*
28792 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
28793 if (!kernel_set_to_readonly)
28794 return;
28795
28796 + start = ktla_ktva(start);
28797 pr_debug("Set kernel text: %lx - %lx for read write\n",
28798 start, start+size);
28799
28800 @@ -890,6 +896,7 @@ void set_kernel_text_ro(void)
28801 if (!kernel_set_to_readonly)
28802 return;
28803
28804 + start = ktla_ktva(start);
28805 pr_debug("Set kernel text: %lx - %lx for read only\n",
28806 start, start+size);
28807
28808 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
28809 unsigned long start = PFN_ALIGN(_text);
28810 unsigned long size = PFN_ALIGN(_etext) - start;
28811
28812 + start = ktla_ktva(start);
28813 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28814 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28815 size >> 10);
28816 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28817 index 75c9a6a..498d677 100644
28818 --- a/arch/x86/mm/init_64.c
28819 +++ b/arch/x86/mm/init_64.c
28820 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28821 * around without checking the pgd every time.
28822 */
28823
28824 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28825 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28826 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28827
28828 int force_personality32;
28829 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28830
28831 for (address = start; address <= end; address += PGDIR_SIZE) {
28832 const pgd_t *pgd_ref = pgd_offset_k(address);
28833 +
28834 +#ifdef CONFIG_PAX_PER_CPU_PGD
28835 + unsigned long cpu;
28836 +#else
28837 struct page *page;
28838 +#endif
28839
28840 if (pgd_none(*pgd_ref))
28841 continue;
28842
28843 spin_lock(&pgd_lock);
28844 +
28845 +#ifdef CONFIG_PAX_PER_CPU_PGD
28846 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28847 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28848 +#else
28849 list_for_each_entry(page, &pgd_list, lru) {
28850 pgd_t *pgd;
28851 spinlock_t *pgt_lock;
28852 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28853 /* the pgt_lock only for Xen */
28854 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28855 spin_lock(pgt_lock);
28856 +#endif
28857
28858 if (pgd_none(*pgd))
28859 set_pgd(pgd, *pgd_ref);
28860 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28861 BUG_ON(pgd_page_vaddr(*pgd)
28862 != pgd_page_vaddr(*pgd_ref));
28863
28864 +#ifndef CONFIG_PAX_PER_CPU_PGD
28865 spin_unlock(pgt_lock);
28866 +#endif
28867 +
28868 }
28869 spin_unlock(&pgd_lock);
28870 }
28871 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28872 {
28873 if (pgd_none(*pgd)) {
28874 pud_t *pud = (pud_t *)spp_getpage();
28875 - pgd_populate(&init_mm, pgd, pud);
28876 + pgd_populate_kernel(&init_mm, pgd, pud);
28877 if (pud != pud_offset(pgd, 0))
28878 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28879 pud, pud_offset(pgd, 0));
28880 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28881 {
28882 if (pud_none(*pud)) {
28883 pmd_t *pmd = (pmd_t *) spp_getpage();
28884 - pud_populate(&init_mm, pud, pmd);
28885 + pud_populate_kernel(&init_mm, pud, pmd);
28886 if (pmd != pmd_offset(pud, 0))
28887 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28888 pmd, pmd_offset(pud, 0));
28889 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28890 pmd = fill_pmd(pud, vaddr);
28891 pte = fill_pte(pmd, vaddr);
28892
28893 + pax_open_kernel();
28894 set_pte(pte, new_pte);
28895 + pax_close_kernel();
28896
28897 /*
28898 * It's enough to flush this one mapping.
28899 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28900 pgd = pgd_offset_k((unsigned long)__va(phys));
28901 if (pgd_none(*pgd)) {
28902 pud = (pud_t *) spp_getpage();
28903 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28904 - _PAGE_USER));
28905 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28906 }
28907 pud = pud_offset(pgd, (unsigned long)__va(phys));
28908 if (pud_none(*pud)) {
28909 pmd = (pmd_t *) spp_getpage();
28910 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28911 - _PAGE_USER));
28912 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28913 }
28914 pmd = pmd_offset(pud, phys);
28915 BUG_ON(!pmd_none(*pmd));
28916 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
28917 if (pfn >= pgt_buf_top)
28918 panic("alloc_low_page: ran out of memory");
28919
28920 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28921 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28922 clear_page(adr);
28923 *phys = pfn * PAGE_SIZE;
28924 return adr;
28925 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
28926
28927 phys = __pa(virt);
28928 left = phys & (PAGE_SIZE - 1);
28929 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28930 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28931 adr = (void *)(((unsigned long)adr) | left);
28932
28933 return adr;
28934 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28935 unmap_low_page(pmd);
28936
28937 spin_lock(&init_mm.page_table_lock);
28938 - pud_populate(&init_mm, pud, __va(pmd_phys));
28939 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
28940 spin_unlock(&init_mm.page_table_lock);
28941 }
28942 __flush_tlb_all();
28943 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
28944 unmap_low_page(pud);
28945
28946 spin_lock(&init_mm.page_table_lock);
28947 - pgd_populate(&init_mm, pgd, __va(pud_phys));
28948 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
28949 spin_unlock(&init_mm.page_table_lock);
28950 pgd_changed = true;
28951 }
28952 @@ -693,6 +707,12 @@ void __init mem_init(void)
28953
28954 pci_iommu_alloc();
28955
28956 +#ifdef CONFIG_PAX_PER_CPU_PGD
28957 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28958 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28959 + KERNEL_PGD_PTRS);
28960 +#endif
28961 +
28962 /* clear_bss() already clear the empty_zero_page */
28963
28964 reservedpages = 0;
28965 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
28966 static struct vm_area_struct gate_vma = {
28967 .vm_start = VSYSCALL_START,
28968 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28969 - .vm_page_prot = PAGE_READONLY_EXEC,
28970 - .vm_flags = VM_READ | VM_EXEC
28971 + .vm_page_prot = PAGE_READONLY,
28972 + .vm_flags = VM_READ
28973 };
28974
28975 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28976 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
28977
28978 const char *arch_vma_name(struct vm_area_struct *vma)
28979 {
28980 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28981 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28982 return "[vdso]";
28983 if (vma == &gate_vma)
28984 return "[vsyscall]";
28985 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28986 index 7b179b4..6bd17777 100644
28987 --- a/arch/x86/mm/iomap_32.c
28988 +++ b/arch/x86/mm/iomap_32.c
28989 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28990 type = kmap_atomic_idx_push();
28991 idx = type + KM_TYPE_NR * smp_processor_id();
28992 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28993 +
28994 + pax_open_kernel();
28995 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28996 + pax_close_kernel();
28997 +
28998 arch_flush_lazy_mmu_mode();
28999
29000 return (void *)vaddr;
29001 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
29002 index 78fe3f1..73b95e2 100644
29003 --- a/arch/x86/mm/ioremap.c
29004 +++ b/arch/x86/mm/ioremap.c
29005 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
29006 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
29007 int is_ram = page_is_ram(pfn);
29008
29009 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
29010 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
29011 return NULL;
29012 WARN_ON_ONCE(is_ram);
29013 }
29014 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
29015 *
29016 * Caller must ensure there is only one unmapping for the same pointer.
29017 */
29018 -void iounmap(volatile void __iomem *addr)
29019 +void iounmap(const volatile void __iomem *addr)
29020 {
29021 struct vm_struct *p, *o;
29022
29023 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29024
29025 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
29026 if (page_is_ram(start >> PAGE_SHIFT))
29027 +#ifdef CONFIG_HIGHMEM
29028 + if ((start >> PAGE_SHIFT) < max_low_pfn)
29029 +#endif
29030 return __va(phys);
29031
29032 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
29033 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29034 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
29035 {
29036 if (page_is_ram(phys >> PAGE_SHIFT))
29037 +#ifdef CONFIG_HIGHMEM
29038 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
29039 +#endif
29040 return;
29041
29042 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
29043 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
29044 early_param("early_ioremap_debug", early_ioremap_debug_setup);
29045
29046 static __initdata int after_paging_init;
29047 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
29048 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
29049
29050 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
29051 {
29052 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
29053 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
29054
29055 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
29056 - memset(bm_pte, 0, sizeof(bm_pte));
29057 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
29058 + pmd_populate_user(&init_mm, pmd, bm_pte);
29059
29060 /*
29061 * The boot-ioremap range spans multiple pmds, for which
29062 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
29063 index d87dd6d..bf3fa66 100644
29064 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
29065 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
29066 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
29067 * memory (e.g. tracked pages)? For now, we need this to avoid
29068 * invoking kmemcheck for PnP BIOS calls.
29069 */
29070 - if (regs->flags & X86_VM_MASK)
29071 + if (v8086_mode(regs))
29072 return false;
29073 - if (regs->cs != __KERNEL_CS)
29074 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
29075 return false;
29076
29077 pte = kmemcheck_pte_lookup(address);
29078 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
29079 index 845df68..1d8d29f 100644
29080 --- a/arch/x86/mm/mmap.c
29081 +++ b/arch/x86/mm/mmap.c
29082 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
29083 * Leave an at least ~128 MB hole with possible stack randomization.
29084 */
29085 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
29086 -#define MAX_GAP (TASK_SIZE/6*5)
29087 +#define MAX_GAP (pax_task_size/6*5)
29088
29089 static int mmap_is_legacy(void)
29090 {
29091 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
29092 return rnd << PAGE_SHIFT;
29093 }
29094
29095 -static unsigned long mmap_base(void)
29096 +static unsigned long mmap_base(struct mm_struct *mm)
29097 {
29098 unsigned long gap = rlimit(RLIMIT_STACK);
29099 + unsigned long pax_task_size = TASK_SIZE;
29100 +
29101 +#ifdef CONFIG_PAX_SEGMEXEC
29102 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29103 + pax_task_size = SEGMEXEC_TASK_SIZE;
29104 +#endif
29105
29106 if (gap < MIN_GAP)
29107 gap = MIN_GAP;
29108 else if (gap > MAX_GAP)
29109 gap = MAX_GAP;
29110
29111 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
29112 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
29113 }
29114
29115 /*
29116 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
29117 * does, but not when emulating X86_32
29118 */
29119 -static unsigned long mmap_legacy_base(void)
29120 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
29121 {
29122 - if (mmap_is_ia32())
29123 + if (mmap_is_ia32()) {
29124 +
29125 +#ifdef CONFIG_PAX_SEGMEXEC
29126 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29127 + return SEGMEXEC_TASK_UNMAPPED_BASE;
29128 + else
29129 +#endif
29130 +
29131 return TASK_UNMAPPED_BASE;
29132 - else
29133 + } else
29134 return TASK_UNMAPPED_BASE + mmap_rnd();
29135 }
29136
29137 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
29138 void arch_pick_mmap_layout(struct mm_struct *mm)
29139 {
29140 if (mmap_is_legacy()) {
29141 - mm->mmap_base = mmap_legacy_base();
29142 + mm->mmap_base = mmap_legacy_base(mm);
29143 +
29144 +#ifdef CONFIG_PAX_RANDMMAP
29145 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29146 + mm->mmap_base += mm->delta_mmap;
29147 +#endif
29148 +
29149 mm->get_unmapped_area = arch_get_unmapped_area;
29150 mm->unmap_area = arch_unmap_area;
29151 } else {
29152 - mm->mmap_base = mmap_base();
29153 + mm->mmap_base = mmap_base(mm);
29154 +
29155 +#ifdef CONFIG_PAX_RANDMMAP
29156 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29157 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
29158 +#endif
29159 +
29160 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
29161 mm->unmap_area = arch_unmap_area_topdown;
29162 }
29163 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
29164 index dc0b727..f612039 100644
29165 --- a/arch/x86/mm/mmio-mod.c
29166 +++ b/arch/x86/mm/mmio-mod.c
29167 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
29168 break;
29169 default:
29170 {
29171 - unsigned char *ip = (unsigned char *)instptr;
29172 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
29173 my_trace->opcode = MMIO_UNKNOWN_OP;
29174 my_trace->width = 0;
29175 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
29176 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
29177 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29178 void __iomem *addr)
29179 {
29180 - static atomic_t next_id;
29181 + static atomic_unchecked_t next_id;
29182 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
29183 /* These are page-unaligned. */
29184 struct mmiotrace_map map = {
29185 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29186 .private = trace
29187 },
29188 .phys = offset,
29189 - .id = atomic_inc_return(&next_id)
29190 + .id = atomic_inc_return_unchecked(&next_id)
29191 };
29192 map.map_id = trace->id;
29193
29194 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
29195 ioremap_trace_core(offset, size, addr);
29196 }
29197
29198 -static void iounmap_trace_core(volatile void __iomem *addr)
29199 +static void iounmap_trace_core(const volatile void __iomem *addr)
29200 {
29201 struct mmiotrace_map map = {
29202 .phys = 0,
29203 @@ -328,7 +328,7 @@ not_enabled:
29204 }
29205 }
29206
29207 -void mmiotrace_iounmap(volatile void __iomem *addr)
29208 +void mmiotrace_iounmap(const volatile void __iomem *addr)
29209 {
29210 might_sleep();
29211 if (is_enabled()) /* recheck and proper locking in *_core() */
29212 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
29213 index 8504f36..5fc68f2 100644
29214 --- a/arch/x86/mm/numa.c
29215 +++ b/arch/x86/mm/numa.c
29216 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
29217 return true;
29218 }
29219
29220 -static int __init numa_register_memblks(struct numa_meminfo *mi)
29221 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
29222 {
29223 unsigned long uninitialized_var(pfn_align);
29224 int i, nid;
29225 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
29226 index b008656..773eac2 100644
29227 --- a/arch/x86/mm/pageattr-test.c
29228 +++ b/arch/x86/mm/pageattr-test.c
29229 @@ -36,7 +36,7 @@ enum {
29230
29231 static int pte_testbit(pte_t pte)
29232 {
29233 - return pte_flags(pte) & _PAGE_UNUSED1;
29234 + return pte_flags(pte) & _PAGE_CPA_TEST;
29235 }
29236
29237 struct split_state {
29238 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
29239 index a718e0d..77419bc 100644
29240 --- a/arch/x86/mm/pageattr.c
29241 +++ b/arch/x86/mm/pageattr.c
29242 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29243 */
29244 #ifdef CONFIG_PCI_BIOS
29245 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
29246 - pgprot_val(forbidden) |= _PAGE_NX;
29247 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29248 #endif
29249
29250 /*
29251 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29252 * Does not cover __inittext since that is gone later on. On
29253 * 64bit we do not enforce !NX on the low mapping
29254 */
29255 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
29256 - pgprot_val(forbidden) |= _PAGE_NX;
29257 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
29258 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29259
29260 +#ifdef CONFIG_DEBUG_RODATA
29261 /*
29262 * The .rodata section needs to be read-only. Using the pfn
29263 * catches all aliases.
29264 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29265 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
29266 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
29267 pgprot_val(forbidden) |= _PAGE_RW;
29268 +#endif
29269
29270 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29271 /*
29272 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29273 }
29274 #endif
29275
29276 +#ifdef CONFIG_PAX_KERNEXEC
29277 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29278 + pgprot_val(forbidden) |= _PAGE_RW;
29279 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29280 + }
29281 +#endif
29282 +
29283 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29284
29285 return prot;
29286 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
29287 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29288 {
29289 /* change init_mm */
29290 + pax_open_kernel();
29291 set_pte_atomic(kpte, pte);
29292 +
29293 #ifdef CONFIG_X86_32
29294 if (!SHARED_KERNEL_PMD) {
29295 +
29296 +#ifdef CONFIG_PAX_PER_CPU_PGD
29297 + unsigned long cpu;
29298 +#else
29299 struct page *page;
29300 +#endif
29301
29302 +#ifdef CONFIG_PAX_PER_CPU_PGD
29303 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29304 + pgd_t *pgd = get_cpu_pgd(cpu);
29305 +#else
29306 list_for_each_entry(page, &pgd_list, lru) {
29307 - pgd_t *pgd;
29308 + pgd_t *pgd = (pgd_t *)page_address(page);
29309 +#endif
29310 +
29311 pud_t *pud;
29312 pmd_t *pmd;
29313
29314 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29315 + pgd += pgd_index(address);
29316 pud = pud_offset(pgd, address);
29317 pmd = pmd_offset(pud, address);
29318 set_pte_atomic((pte_t *)pmd, pte);
29319 }
29320 }
29321 #endif
29322 + pax_close_kernel();
29323 }
29324
29325 static int
29326 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29327 index 0eb572e..92f5c1e 100644
29328 --- a/arch/x86/mm/pat.c
29329 +++ b/arch/x86/mm/pat.c
29330 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29331
29332 if (!entry) {
29333 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29334 - current->comm, current->pid, start, end - 1);
29335 + current->comm, task_pid_nr(current), start, end - 1);
29336 return -EINVAL;
29337 }
29338
29339 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29340
29341 while (cursor < to) {
29342 if (!devmem_is_allowed(pfn)) {
29343 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29344 - current->comm, from, to - 1);
29345 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29346 + current->comm, from, to - 1, cursor);
29347 return 0;
29348 }
29349 cursor += PAGE_SIZE;
29350 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29351 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29352 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29353 "for [mem %#010Lx-%#010Lx]\n",
29354 - current->comm, current->pid,
29355 + current->comm, task_pid_nr(current),
29356 cattr_name(flags),
29357 base, (unsigned long long)(base + size-1));
29358 return -EINVAL;
29359 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29360 flags = lookup_memtype(paddr);
29361 if (want_flags != flags) {
29362 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29363 - current->comm, current->pid,
29364 + current->comm, task_pid_nr(current),
29365 cattr_name(want_flags),
29366 (unsigned long long)paddr,
29367 (unsigned long long)(paddr + size - 1),
29368 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29369 free_memtype(paddr, paddr + size);
29370 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29371 " for [mem %#010Lx-%#010Lx], got %s\n",
29372 - current->comm, current->pid,
29373 + current->comm, task_pid_nr(current),
29374 cattr_name(want_flags),
29375 (unsigned long long)paddr,
29376 (unsigned long long)(paddr + size - 1),
29377 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29378 index 9f0614d..92ae64a 100644
29379 --- a/arch/x86/mm/pf_in.c
29380 +++ b/arch/x86/mm/pf_in.c
29381 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29382 int i;
29383 enum reason_type rv = OTHERS;
29384
29385 - p = (unsigned char *)ins_addr;
29386 + p = (unsigned char *)ktla_ktva(ins_addr);
29387 p += skip_prefix(p, &prf);
29388 p += get_opcode(p, &opcode);
29389
29390 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29391 struct prefix_bits prf;
29392 int i;
29393
29394 - p = (unsigned char *)ins_addr;
29395 + p = (unsigned char *)ktla_ktva(ins_addr);
29396 p += skip_prefix(p, &prf);
29397 p += get_opcode(p, &opcode);
29398
29399 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29400 struct prefix_bits prf;
29401 int i;
29402
29403 - p = (unsigned char *)ins_addr;
29404 + p = (unsigned char *)ktla_ktva(ins_addr);
29405 p += skip_prefix(p, &prf);
29406 p += get_opcode(p, &opcode);
29407
29408 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29409 struct prefix_bits prf;
29410 int i;
29411
29412 - p = (unsigned char *)ins_addr;
29413 + p = (unsigned char *)ktla_ktva(ins_addr);
29414 p += skip_prefix(p, &prf);
29415 p += get_opcode(p, &opcode);
29416 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29417 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29418 struct prefix_bits prf;
29419 int i;
29420
29421 - p = (unsigned char *)ins_addr;
29422 + p = (unsigned char *)ktla_ktva(ins_addr);
29423 p += skip_prefix(p, &prf);
29424 p += get_opcode(p, &opcode);
29425 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29426 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29427 index 395b3b4a..213e72b 100644
29428 --- a/arch/x86/mm/pgtable.c
29429 +++ b/arch/x86/mm/pgtable.c
29430 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29431 list_del(&page->lru);
29432 }
29433
29434 -#define UNSHARED_PTRS_PER_PGD \
29435 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29436 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29437 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29438
29439 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29440 +{
29441 + unsigned int count = USER_PGD_PTRS;
29442
29443 + while (count--)
29444 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29445 +}
29446 +#endif
29447 +
29448 +#ifdef CONFIG_PAX_PER_CPU_PGD
29449 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29450 +{
29451 + unsigned int count = USER_PGD_PTRS;
29452 +
29453 + while (count--) {
29454 + pgd_t pgd;
29455 +
29456 +#ifdef CONFIG_X86_64
29457 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29458 +#else
29459 + pgd = *src++;
29460 +#endif
29461 +
29462 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29463 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29464 +#endif
29465 +
29466 + *dst++ = pgd;
29467 + }
29468 +
29469 +}
29470 +#endif
29471 +
29472 +#ifdef CONFIG_X86_64
29473 +#define pxd_t pud_t
29474 +#define pyd_t pgd_t
29475 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29476 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29477 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29478 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29479 +#define PYD_SIZE PGDIR_SIZE
29480 +#else
29481 +#define pxd_t pmd_t
29482 +#define pyd_t pud_t
29483 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29484 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29485 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29486 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29487 +#define PYD_SIZE PUD_SIZE
29488 +#endif
29489 +
29490 +#ifdef CONFIG_PAX_PER_CPU_PGD
29491 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29492 +static inline void pgd_dtor(pgd_t *pgd) {}
29493 +#else
29494 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29495 {
29496 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29497 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29498 pgd_list_del(pgd);
29499 spin_unlock(&pgd_lock);
29500 }
29501 +#endif
29502
29503 /*
29504 * List of all pgd's needed for non-PAE so it can invalidate entries
29505 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29506 * -- nyc
29507 */
29508
29509 -#ifdef CONFIG_X86_PAE
29510 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29511 /*
29512 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29513 * updating the top-level pagetable entries to guarantee the
29514 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29515 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29516 * and initialize the kernel pmds here.
29517 */
29518 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29519 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29520
29521 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29522 {
29523 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29524 */
29525 flush_tlb_mm(mm);
29526 }
29527 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29528 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29529 #else /* !CONFIG_X86_PAE */
29530
29531 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29532 -#define PREALLOCATED_PMDS 0
29533 +#define PREALLOCATED_PXDS 0
29534
29535 #endif /* CONFIG_X86_PAE */
29536
29537 -static void free_pmds(pmd_t *pmds[])
29538 +static void free_pxds(pxd_t *pxds[])
29539 {
29540 int i;
29541
29542 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29543 - if (pmds[i])
29544 - free_page((unsigned long)pmds[i]);
29545 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29546 + if (pxds[i])
29547 + free_page((unsigned long)pxds[i]);
29548 }
29549
29550 -static int preallocate_pmds(pmd_t *pmds[])
29551 +static int preallocate_pxds(pxd_t *pxds[])
29552 {
29553 int i;
29554 bool failed = false;
29555
29556 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29557 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29558 - if (pmd == NULL)
29559 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29560 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29561 + if (pxd == NULL)
29562 failed = true;
29563 - pmds[i] = pmd;
29564 + pxds[i] = pxd;
29565 }
29566
29567 if (failed) {
29568 - free_pmds(pmds);
29569 + free_pxds(pxds);
29570 return -ENOMEM;
29571 }
29572
29573 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29574 * preallocate which never got a corresponding vma will need to be
29575 * freed manually.
29576 */
29577 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29578 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29579 {
29580 int i;
29581
29582 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29583 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29584 pgd_t pgd = pgdp[i];
29585
29586 if (pgd_val(pgd) != 0) {
29587 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29588 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29589
29590 - pgdp[i] = native_make_pgd(0);
29591 + set_pgd(pgdp + i, native_make_pgd(0));
29592
29593 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29594 - pmd_free(mm, pmd);
29595 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29596 + pxd_free(mm, pxd);
29597 }
29598 }
29599 }
29600
29601 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29602 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29603 {
29604 - pud_t *pud;
29605 + pyd_t *pyd;
29606 unsigned long addr;
29607 int i;
29608
29609 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29610 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29611 return;
29612
29613 - pud = pud_offset(pgd, 0);
29614 +#ifdef CONFIG_X86_64
29615 + pyd = pyd_offset(mm, 0L);
29616 +#else
29617 + pyd = pyd_offset(pgd, 0L);
29618 +#endif
29619
29620 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29621 - i++, pud++, addr += PUD_SIZE) {
29622 - pmd_t *pmd = pmds[i];
29623 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29624 + i++, pyd++, addr += PYD_SIZE) {
29625 + pxd_t *pxd = pxds[i];
29626
29627 if (i >= KERNEL_PGD_BOUNDARY)
29628 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29629 - sizeof(pmd_t) * PTRS_PER_PMD);
29630 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29631 + sizeof(pxd_t) * PTRS_PER_PMD);
29632
29633 - pud_populate(mm, pud, pmd);
29634 + pyd_populate(mm, pyd, pxd);
29635 }
29636 }
29637
29638 pgd_t *pgd_alloc(struct mm_struct *mm)
29639 {
29640 pgd_t *pgd;
29641 - pmd_t *pmds[PREALLOCATED_PMDS];
29642 + pxd_t *pxds[PREALLOCATED_PXDS];
29643
29644 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29645
29646 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29647
29648 mm->pgd = pgd;
29649
29650 - if (preallocate_pmds(pmds) != 0)
29651 + if (preallocate_pxds(pxds) != 0)
29652 goto out_free_pgd;
29653
29654 if (paravirt_pgd_alloc(mm) != 0)
29655 - goto out_free_pmds;
29656 + goto out_free_pxds;
29657
29658 /*
29659 * Make sure that pre-populating the pmds is atomic with
29660 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29661 spin_lock(&pgd_lock);
29662
29663 pgd_ctor(mm, pgd);
29664 - pgd_prepopulate_pmd(mm, pgd, pmds);
29665 + pgd_prepopulate_pxd(mm, pgd, pxds);
29666
29667 spin_unlock(&pgd_lock);
29668
29669 return pgd;
29670
29671 -out_free_pmds:
29672 - free_pmds(pmds);
29673 +out_free_pxds:
29674 + free_pxds(pxds);
29675 out_free_pgd:
29676 free_page((unsigned long)pgd);
29677 out:
29678 @@ -302,7 +363,7 @@ out:
29679
29680 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29681 {
29682 - pgd_mop_up_pmds(mm, pgd);
29683 + pgd_mop_up_pxds(mm, pgd);
29684 pgd_dtor(pgd);
29685 paravirt_pgd_free(mm, pgd);
29686 free_page((unsigned long)pgd);
29687 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29688 index a69bcb8..19068ab 100644
29689 --- a/arch/x86/mm/pgtable_32.c
29690 +++ b/arch/x86/mm/pgtable_32.c
29691 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29692 return;
29693 }
29694 pte = pte_offset_kernel(pmd, vaddr);
29695 +
29696 + pax_open_kernel();
29697 if (pte_val(pteval))
29698 set_pte_at(&init_mm, vaddr, pte, pteval);
29699 else
29700 pte_clear(&init_mm, vaddr, pte);
29701 + pax_close_kernel();
29702
29703 /*
29704 * It's enough to flush this one mapping.
29705 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29706 index d2e2735..5c6586f 100644
29707 --- a/arch/x86/mm/physaddr.c
29708 +++ b/arch/x86/mm/physaddr.c
29709 @@ -8,7 +8,7 @@
29710
29711 #ifdef CONFIG_X86_64
29712
29713 -unsigned long __phys_addr(unsigned long x)
29714 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29715 {
29716 if (x >= __START_KERNEL_map) {
29717 x -= __START_KERNEL_map;
29718 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29719 #else
29720
29721 #ifdef CONFIG_DEBUG_VIRTUAL
29722 -unsigned long __phys_addr(unsigned long x)
29723 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29724 {
29725 /* VMALLOC_* aren't constants */
29726 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
29727 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29728 index 410531d..0f16030 100644
29729 --- a/arch/x86/mm/setup_nx.c
29730 +++ b/arch/x86/mm/setup_nx.c
29731 @@ -5,8 +5,10 @@
29732 #include <asm/pgtable.h>
29733 #include <asm/proto.h>
29734
29735 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29736 static int disable_nx __cpuinitdata;
29737
29738 +#ifndef CONFIG_PAX_PAGEEXEC
29739 /*
29740 * noexec = on|off
29741 *
29742 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29743 return 0;
29744 }
29745 early_param("noexec", noexec_setup);
29746 +#endif
29747 +
29748 +#endif
29749
29750 void __cpuinit x86_configure_nx(void)
29751 {
29752 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29753 if (cpu_has_nx && !disable_nx)
29754 __supported_pte_mask |= _PAGE_NX;
29755 else
29756 +#endif
29757 __supported_pte_mask &= ~_PAGE_NX;
29758 }
29759
29760 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29761 index 13a6b29..c2fff23 100644
29762 --- a/arch/x86/mm/tlb.c
29763 +++ b/arch/x86/mm/tlb.c
29764 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29765 BUG();
29766 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29767 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29768 +
29769 +#ifndef CONFIG_PAX_PER_CPU_PGD
29770 load_cr3(swapper_pg_dir);
29771 +#endif
29772 +
29773 }
29774 }
29775 EXPORT_SYMBOL_GPL(leave_mm);
29776 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29777 index 877b9a1..a8ecf42 100644
29778 --- a/arch/x86/net/bpf_jit.S
29779 +++ b/arch/x86/net/bpf_jit.S
29780 @@ -9,6 +9,7 @@
29781 */
29782 #include <linux/linkage.h>
29783 #include <asm/dwarf2.h>
29784 +#include <asm/alternative-asm.h>
29785
29786 /*
29787 * Calling convention :
29788 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29789 jle bpf_slow_path_word
29790 mov (SKBDATA,%rsi),%eax
29791 bswap %eax /* ntohl() */
29792 + pax_force_retaddr
29793 ret
29794
29795 sk_load_half:
29796 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29797 jle bpf_slow_path_half
29798 movzwl (SKBDATA,%rsi),%eax
29799 rol $8,%ax # ntohs()
29800 + pax_force_retaddr
29801 ret
29802
29803 sk_load_byte:
29804 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29805 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29806 jle bpf_slow_path_byte
29807 movzbl (SKBDATA,%rsi),%eax
29808 + pax_force_retaddr
29809 ret
29810
29811 /**
29812 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29813 movzbl (SKBDATA,%rsi),%ebx
29814 and $15,%bl
29815 shl $2,%bl
29816 + pax_force_retaddr
29817 ret
29818
29819 /* rsi contains offset and can be scratched */
29820 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29821 js bpf_error
29822 mov -12(%rbp),%eax
29823 bswap %eax
29824 + pax_force_retaddr
29825 ret
29826
29827 bpf_slow_path_half:
29828 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29829 mov -12(%rbp),%ax
29830 rol $8,%ax
29831 movzwl %ax,%eax
29832 + pax_force_retaddr
29833 ret
29834
29835 bpf_slow_path_byte:
29836 bpf_slow_path_common(1)
29837 js bpf_error
29838 movzbl -12(%rbp),%eax
29839 + pax_force_retaddr
29840 ret
29841
29842 bpf_slow_path_byte_msh:
29843 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29844 and $15,%al
29845 shl $2,%al
29846 xchg %eax,%ebx
29847 + pax_force_retaddr
29848 ret
29849
29850 #define sk_negative_common(SIZE) \
29851 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29852 sk_negative_common(4)
29853 mov (%rax), %eax
29854 bswap %eax
29855 + pax_force_retaddr
29856 ret
29857
29858 bpf_slow_path_half_neg:
29859 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29860 mov (%rax),%ax
29861 rol $8,%ax
29862 movzwl %ax,%eax
29863 + pax_force_retaddr
29864 ret
29865
29866 bpf_slow_path_byte_neg:
29867 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29868 .globl sk_load_byte_negative_offset
29869 sk_negative_common(1)
29870 movzbl (%rax), %eax
29871 + pax_force_retaddr
29872 ret
29873
29874 bpf_slow_path_byte_msh_neg:
29875 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29876 and $15,%al
29877 shl $2,%al
29878 xchg %eax,%ebx
29879 + pax_force_retaddr
29880 ret
29881
29882 bpf_error:
29883 @@ -197,4 +210,5 @@ bpf_error:
29884 xor %eax,%eax
29885 mov -8(%rbp),%rbx
29886 leaveq
29887 + pax_force_retaddr
29888 ret
29889 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29890 index d11a470..3f9adff3 100644
29891 --- a/arch/x86/net/bpf_jit_comp.c
29892 +++ b/arch/x86/net/bpf_jit_comp.c
29893 @@ -12,6 +12,7 @@
29894 #include <linux/netdevice.h>
29895 #include <linux/filter.h>
29896 #include <linux/if_vlan.h>
29897 +#include <linux/random.h>
29898
29899 /*
29900 * Conventions :
29901 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29902 return ptr + len;
29903 }
29904
29905 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29906 +#define MAX_INSTR_CODE_SIZE 96
29907 +#else
29908 +#define MAX_INSTR_CODE_SIZE 64
29909 +#endif
29910 +
29911 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29912
29913 #define EMIT1(b1) EMIT(b1, 1)
29914 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29915 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29916 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29917 +
29918 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29919 +/* original constant will appear in ecx */
29920 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29921 +do { \
29922 + /* mov ecx, randkey */ \
29923 + EMIT1(0xb9); \
29924 + EMIT(_key, 4); \
29925 + /* xor ecx, randkey ^ off */ \
29926 + EMIT2(0x81, 0xf1); \
29927 + EMIT((_key) ^ (_off), 4); \
29928 +} while (0)
29929 +
29930 +#define EMIT1_off32(b1, _off) \
29931 +do { \
29932 + switch (b1) { \
29933 + case 0x05: /* add eax, imm32 */ \
29934 + case 0x2d: /* sub eax, imm32 */ \
29935 + case 0x25: /* and eax, imm32 */ \
29936 + case 0x0d: /* or eax, imm32 */ \
29937 + case 0xb8: /* mov eax, imm32 */ \
29938 + case 0x3d: /* cmp eax, imm32 */ \
29939 + case 0xa9: /* test eax, imm32 */ \
29940 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29941 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29942 + break; \
29943 + case 0xbb: /* mov ebx, imm32 */ \
29944 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29945 + /* mov ebx, ecx */ \
29946 + EMIT2(0x89, 0xcb); \
29947 + break; \
29948 + case 0xbe: /* mov esi, imm32 */ \
29949 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29950 + /* mov esi, ecx */ \
29951 + EMIT2(0x89, 0xce); \
29952 + break; \
29953 + case 0xe9: /* jmp rel imm32 */ \
29954 + EMIT1(b1); \
29955 + EMIT(_off, 4); \
29956 + /* prevent fall-through, we're not called if off = 0 */ \
29957 + EMIT(0xcccccccc, 4); \
29958 + EMIT(0xcccccccc, 4); \
29959 + break; \
29960 + default: \
29961 + EMIT1(b1); \
29962 + EMIT(_off, 4); \
29963 + } \
29964 +} while (0)
29965 +
29966 +#define EMIT2_off32(b1, b2, _off) \
29967 +do { \
29968 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29969 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29970 + EMIT(randkey, 4); \
29971 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29972 + EMIT((_off) - randkey, 4); \
29973 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29974 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29975 + /* imul eax, ecx */ \
29976 + EMIT3(0x0f, 0xaf, 0xc1); \
29977 + } else { \
29978 + EMIT2(b1, b2); \
29979 + EMIT(_off, 4); \
29980 + } \
29981 +} while (0)
29982 +#else
29983 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29984 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29985 +#endif
29986
29987 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29988 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29989 @@ -90,6 +165,24 @@ do { \
29990 #define X86_JBE 0x76
29991 #define X86_JA 0x77
29992
29993 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29994 +#define APPEND_FLOW_VERIFY() \
29995 +do { \
29996 + /* mov ecx, randkey */ \
29997 + EMIT1(0xb9); \
29998 + EMIT(randkey, 4); \
29999 + /* cmp ecx, randkey */ \
30000 + EMIT2(0x81, 0xf9); \
30001 + EMIT(randkey, 4); \
30002 + /* jz after 8 int 3s */ \
30003 + EMIT2(0x74, 0x08); \
30004 + EMIT(0xcccccccc, 4); \
30005 + EMIT(0xcccccccc, 4); \
30006 +} while (0)
30007 +#else
30008 +#define APPEND_FLOW_VERIFY() do { } while (0)
30009 +#endif
30010 +
30011 #define EMIT_COND_JMP(op, offset) \
30012 do { \
30013 if (is_near(offset)) \
30014 @@ -97,6 +190,7 @@ do { \
30015 else { \
30016 EMIT2(0x0f, op + 0x10); \
30017 EMIT(offset, 4); /* jxx .+off32 */ \
30018 + APPEND_FLOW_VERIFY(); \
30019 } \
30020 } while (0)
30021
30022 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
30023 set_fs(old_fs);
30024 }
30025
30026 +struct bpf_jit_work {
30027 + struct work_struct work;
30028 + void *image;
30029 +};
30030 +
30031 #define CHOOSE_LOAD_FUNC(K, func) \
30032 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
30033
30034 void bpf_jit_compile(struct sk_filter *fp)
30035 {
30036 - u8 temp[64];
30037 + u8 temp[MAX_INSTR_CODE_SIZE];
30038 u8 *prog;
30039 unsigned int proglen, oldproglen = 0;
30040 int ilen, i;
30041 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
30042 unsigned int *addrs;
30043 const struct sock_filter *filter = fp->insns;
30044 int flen = fp->len;
30045 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30046 + unsigned int randkey;
30047 +#endif
30048
30049 if (!bpf_jit_enable)
30050 return;
30051 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
30052 if (addrs == NULL)
30053 return;
30054
30055 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
30056 + if (!fp->work)
30057 + goto out;
30058 +
30059 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30060 + randkey = get_random_int();
30061 +#endif
30062 +
30063 /* Before first pass, make a rough estimation of addrs[]
30064 - * each bpf instruction is translated to less than 64 bytes
30065 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
30066 */
30067 for (proglen = 0, i = 0; i < flen; i++) {
30068 - proglen += 64;
30069 + proglen += MAX_INSTR_CODE_SIZE;
30070 addrs[i] = proglen;
30071 }
30072 cleanup_addr = proglen; /* epilogue address */
30073 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
30074 case BPF_S_ALU_MUL_K: /* A *= K */
30075 if (is_imm8(K))
30076 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
30077 - else {
30078 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
30079 - EMIT(K, 4);
30080 - }
30081 + else
30082 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
30083 break;
30084 case BPF_S_ALU_DIV_X: /* A /= X; */
30085 seen |= SEEN_XREG;
30086 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
30087 break;
30088 case BPF_S_ALU_MOD_K: /* A %= K; */
30089 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
30090 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30091 + DILUTE_CONST_SEQUENCE(K, randkey);
30092 +#else
30093 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
30094 +#endif
30095 EMIT2(0xf7, 0xf1); /* div %ecx */
30096 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
30097 break;
30098 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
30099 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30100 + DILUTE_CONST_SEQUENCE(K, randkey);
30101 + // imul rax, rcx
30102 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
30103 +#else
30104 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
30105 EMIT(K, 4);
30106 +#endif
30107 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
30108 break;
30109 case BPF_S_ALU_AND_X:
30110 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
30111 if (is_imm8(K)) {
30112 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
30113 } else {
30114 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
30115 - EMIT(K, 4);
30116 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
30117 }
30118 } else {
30119 EMIT2(0x89,0xde); /* mov %ebx,%esi */
30120 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30121 break;
30122 default:
30123 /* hmm, too complex filter, give up with jit compiler */
30124 - goto out;
30125 + goto error;
30126 }
30127 ilen = prog - temp;
30128 if (image) {
30129 if (unlikely(proglen + ilen > oldproglen)) {
30130 pr_err("bpb_jit_compile fatal error\n");
30131 - kfree(addrs);
30132 - module_free(NULL, image);
30133 - return;
30134 + module_free_exec(NULL, image);
30135 + goto error;
30136 }
30137 + pax_open_kernel();
30138 memcpy(image + proglen, temp, ilen);
30139 + pax_close_kernel();
30140 }
30141 proglen += ilen;
30142 addrs[i] = proglen;
30143 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30144 break;
30145 }
30146 if (proglen == oldproglen) {
30147 - image = module_alloc(max_t(unsigned int,
30148 - proglen,
30149 - sizeof(struct work_struct)));
30150 + image = module_alloc_exec(proglen);
30151 if (!image)
30152 - goto out;
30153 + goto error;
30154 }
30155 oldproglen = proglen;
30156 }
30157 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30158 bpf_flush_icache(image, image + proglen);
30159
30160 fp->bpf_func = (void *)image;
30161 - }
30162 + } else
30163 +error:
30164 + kfree(fp->work);
30165 +
30166 out:
30167 kfree(addrs);
30168 return;
30169 @@ -707,18 +826,20 @@ out:
30170
30171 static void jit_free_defer(struct work_struct *arg)
30172 {
30173 - module_free(NULL, arg);
30174 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
30175 + kfree(arg);
30176 }
30177
30178 /* run from softirq, we must use a work_struct to call
30179 - * module_free() from process context
30180 + * module_free_exec() from process context
30181 */
30182 void bpf_jit_free(struct sk_filter *fp)
30183 {
30184 if (fp->bpf_func != sk_run_filter) {
30185 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
30186 + struct work_struct *work = &fp->work->work;
30187
30188 INIT_WORK(work, jit_free_defer);
30189 + fp->work->image = fp->bpf_func;
30190 schedule_work(work);
30191 }
30192 }
30193 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
30194 index d6aa6e8..266395a 100644
30195 --- a/arch/x86/oprofile/backtrace.c
30196 +++ b/arch/x86/oprofile/backtrace.c
30197 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
30198 struct stack_frame_ia32 *fp;
30199 unsigned long bytes;
30200
30201 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30202 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30203 if (bytes != sizeof(bufhead))
30204 return NULL;
30205
30206 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
30207 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
30208
30209 oprofile_add_trace(bufhead[0].return_address);
30210
30211 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
30212 struct stack_frame bufhead[2];
30213 unsigned long bytes;
30214
30215 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30216 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30217 if (bytes != sizeof(bufhead))
30218 return NULL;
30219
30220 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
30221 {
30222 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
30223
30224 - if (!user_mode_vm(regs)) {
30225 + if (!user_mode(regs)) {
30226 unsigned long stack = kernel_stack_pointer(regs);
30227 if (depth)
30228 dump_trace(NULL, regs, (unsigned long *)stack, 0,
30229 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
30230 index 48768df..ba9143c 100644
30231 --- a/arch/x86/oprofile/nmi_int.c
30232 +++ b/arch/x86/oprofile/nmi_int.c
30233 @@ -23,6 +23,7 @@
30234 #include <asm/nmi.h>
30235 #include <asm/msr.h>
30236 #include <asm/apic.h>
30237 +#include <asm/pgtable.h>
30238
30239 #include "op_counter.h"
30240 #include "op_x86_model.h"
30241 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
30242 if (ret)
30243 return ret;
30244
30245 - if (!model->num_virt_counters)
30246 - model->num_virt_counters = model->num_counters;
30247 + if (!model->num_virt_counters) {
30248 + pax_open_kernel();
30249 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
30250 + pax_close_kernel();
30251 + }
30252
30253 mux_init(ops);
30254
30255 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
30256 index b2b9443..be58856 100644
30257 --- a/arch/x86/oprofile/op_model_amd.c
30258 +++ b/arch/x86/oprofile/op_model_amd.c
30259 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
30260 num_counters = AMD64_NUM_COUNTERS;
30261 }
30262
30263 - op_amd_spec.num_counters = num_counters;
30264 - op_amd_spec.num_controls = num_counters;
30265 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30266 + pax_open_kernel();
30267 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30268 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30269 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30270 + pax_close_kernel();
30271
30272 return 0;
30273 }
30274 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30275 index d90528e..0127e2b 100644
30276 --- a/arch/x86/oprofile/op_model_ppro.c
30277 +++ b/arch/x86/oprofile/op_model_ppro.c
30278 @@ -19,6 +19,7 @@
30279 #include <asm/msr.h>
30280 #include <asm/apic.h>
30281 #include <asm/nmi.h>
30282 +#include <asm/pgtable.h>
30283
30284 #include "op_x86_model.h"
30285 #include "op_counter.h"
30286 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30287
30288 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30289
30290 - op_arch_perfmon_spec.num_counters = num_counters;
30291 - op_arch_perfmon_spec.num_controls = num_counters;
30292 + pax_open_kernel();
30293 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30294 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30295 + pax_close_kernel();
30296 }
30297
30298 static int arch_perfmon_init(struct oprofile_operations *ignore)
30299 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30300 index 71e8a67..6a313bb 100644
30301 --- a/arch/x86/oprofile/op_x86_model.h
30302 +++ b/arch/x86/oprofile/op_x86_model.h
30303 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30304 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30305 struct op_msrs const * const msrs);
30306 #endif
30307 -};
30308 +} __do_const;
30309
30310 struct op_counter_config;
30311
30312 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30313 index e9e6ed5..e47ae67 100644
30314 --- a/arch/x86/pci/amd_bus.c
30315 +++ b/arch/x86/pci/amd_bus.c
30316 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30317 return NOTIFY_OK;
30318 }
30319
30320 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30321 +static struct notifier_block amd_cpu_notifier = {
30322 .notifier_call = amd_cpu_notify,
30323 };
30324
30325 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30326 index 372e9b8..e775a6c 100644
30327 --- a/arch/x86/pci/irq.c
30328 +++ b/arch/x86/pci/irq.c
30329 @@ -50,7 +50,7 @@ struct irq_router {
30330 struct irq_router_handler {
30331 u16 vendor;
30332 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30333 -};
30334 +} __do_const;
30335
30336 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30337 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30338 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30339 return 0;
30340 }
30341
30342 -static __initdata struct irq_router_handler pirq_routers[] = {
30343 +static __initconst const struct irq_router_handler pirq_routers[] = {
30344 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30345 { PCI_VENDOR_ID_AL, ali_router_probe },
30346 { PCI_VENDOR_ID_ITE, ite_router_probe },
30347 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30348 static void __init pirq_find_router(struct irq_router *r)
30349 {
30350 struct irq_routing_table *rt = pirq_table;
30351 - struct irq_router_handler *h;
30352 + const struct irq_router_handler *h;
30353
30354 #ifdef CONFIG_PCI_BIOS
30355 if (!rt->signature) {
30356 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30357 return 0;
30358 }
30359
30360 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30361 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30362 {
30363 .callback = fix_broken_hp_bios_irq9,
30364 .ident = "HP Pavilion N5400 Series Laptop",
30365 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30366 index 6eb18c4..20d83de 100644
30367 --- a/arch/x86/pci/mrst.c
30368 +++ b/arch/x86/pci/mrst.c
30369 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30370 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30371 pci_mmcfg_late_init();
30372 pcibios_enable_irq = mrst_pci_irq_enable;
30373 - pci_root_ops = pci_mrst_ops;
30374 + pax_open_kernel();
30375 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30376 + pax_close_kernel();
30377 pci_soc_mode = 1;
30378 /* Continue with standard init */
30379 return 1;
30380 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30381 index c77b24a..c979855 100644
30382 --- a/arch/x86/pci/pcbios.c
30383 +++ b/arch/x86/pci/pcbios.c
30384 @@ -79,7 +79,7 @@ union bios32 {
30385 static struct {
30386 unsigned long address;
30387 unsigned short segment;
30388 -} bios32_indirect = { 0, __KERNEL_CS };
30389 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30390
30391 /*
30392 * Returns the entry point for the given service, NULL on error
30393 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30394 unsigned long length; /* %ecx */
30395 unsigned long entry; /* %edx */
30396 unsigned long flags;
30397 + struct desc_struct d, *gdt;
30398
30399 local_irq_save(flags);
30400 - __asm__("lcall *(%%edi); cld"
30401 +
30402 + gdt = get_cpu_gdt_table(smp_processor_id());
30403 +
30404 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30405 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30406 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30407 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30408 +
30409 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30410 : "=a" (return_code),
30411 "=b" (address),
30412 "=c" (length),
30413 "=d" (entry)
30414 : "0" (service),
30415 "1" (0),
30416 - "D" (&bios32_indirect));
30417 + "D" (&bios32_indirect),
30418 + "r"(__PCIBIOS_DS)
30419 + : "memory");
30420 +
30421 + pax_open_kernel();
30422 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30423 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30424 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30425 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30426 + pax_close_kernel();
30427 +
30428 local_irq_restore(flags);
30429
30430 switch (return_code) {
30431 - case 0:
30432 - return address + entry;
30433 - case 0x80: /* Not present */
30434 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30435 - return 0;
30436 - default: /* Shouldn't happen */
30437 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30438 - service, return_code);
30439 + case 0: {
30440 + int cpu;
30441 + unsigned char flags;
30442 +
30443 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30444 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30445 + printk(KERN_WARNING "bios32_service: not valid\n");
30446 return 0;
30447 + }
30448 + address = address + PAGE_OFFSET;
30449 + length += 16UL; /* some BIOSs underreport this... */
30450 + flags = 4;
30451 + if (length >= 64*1024*1024) {
30452 + length >>= PAGE_SHIFT;
30453 + flags |= 8;
30454 + }
30455 +
30456 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30457 + gdt = get_cpu_gdt_table(cpu);
30458 + pack_descriptor(&d, address, length, 0x9b, flags);
30459 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30460 + pack_descriptor(&d, address, length, 0x93, flags);
30461 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30462 + }
30463 + return entry;
30464 + }
30465 + case 0x80: /* Not present */
30466 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30467 + return 0;
30468 + default: /* Shouldn't happen */
30469 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30470 + service, return_code);
30471 + return 0;
30472 }
30473 }
30474
30475 static struct {
30476 unsigned long address;
30477 unsigned short segment;
30478 -} pci_indirect = { 0, __KERNEL_CS };
30479 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30480
30481 -static int pci_bios_present;
30482 +static int pci_bios_present __read_only;
30483
30484 static int check_pcibios(void)
30485 {
30486 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30487 unsigned long flags, pcibios_entry;
30488
30489 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30490 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30491 + pci_indirect.address = pcibios_entry;
30492
30493 local_irq_save(flags);
30494 - __asm__(
30495 - "lcall *(%%edi); cld\n\t"
30496 + __asm__("movw %w6, %%ds\n\t"
30497 + "lcall *%%ss:(%%edi); cld\n\t"
30498 + "push %%ss\n\t"
30499 + "pop %%ds\n\t"
30500 "jc 1f\n\t"
30501 "xor %%ah, %%ah\n"
30502 "1:"
30503 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30504 "=b" (ebx),
30505 "=c" (ecx)
30506 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30507 - "D" (&pci_indirect)
30508 + "D" (&pci_indirect),
30509 + "r" (__PCIBIOS_DS)
30510 : "memory");
30511 local_irq_restore(flags);
30512
30513 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30514
30515 switch (len) {
30516 case 1:
30517 - __asm__("lcall *(%%esi); cld\n\t"
30518 + __asm__("movw %w6, %%ds\n\t"
30519 + "lcall *%%ss:(%%esi); cld\n\t"
30520 + "push %%ss\n\t"
30521 + "pop %%ds\n\t"
30522 "jc 1f\n\t"
30523 "xor %%ah, %%ah\n"
30524 "1:"
30525 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30526 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30527 "b" (bx),
30528 "D" ((long)reg),
30529 - "S" (&pci_indirect));
30530 + "S" (&pci_indirect),
30531 + "r" (__PCIBIOS_DS));
30532 /*
30533 * Zero-extend the result beyond 8 bits, do not trust the
30534 * BIOS having done it:
30535 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30536 *value &= 0xff;
30537 break;
30538 case 2:
30539 - __asm__("lcall *(%%esi); cld\n\t"
30540 + __asm__("movw %w6, %%ds\n\t"
30541 + "lcall *%%ss:(%%esi); cld\n\t"
30542 + "push %%ss\n\t"
30543 + "pop %%ds\n\t"
30544 "jc 1f\n\t"
30545 "xor %%ah, %%ah\n"
30546 "1:"
30547 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30548 : "1" (PCIBIOS_READ_CONFIG_WORD),
30549 "b" (bx),
30550 "D" ((long)reg),
30551 - "S" (&pci_indirect));
30552 + "S" (&pci_indirect),
30553 + "r" (__PCIBIOS_DS));
30554 /*
30555 * Zero-extend the result beyond 16 bits, do not trust the
30556 * BIOS having done it:
30557 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30558 *value &= 0xffff;
30559 break;
30560 case 4:
30561 - __asm__("lcall *(%%esi); cld\n\t"
30562 + __asm__("movw %w6, %%ds\n\t"
30563 + "lcall *%%ss:(%%esi); cld\n\t"
30564 + "push %%ss\n\t"
30565 + "pop %%ds\n\t"
30566 "jc 1f\n\t"
30567 "xor %%ah, %%ah\n"
30568 "1:"
30569 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30570 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30571 "b" (bx),
30572 "D" ((long)reg),
30573 - "S" (&pci_indirect));
30574 + "S" (&pci_indirect),
30575 + "r" (__PCIBIOS_DS));
30576 break;
30577 }
30578
30579 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30580
30581 switch (len) {
30582 case 1:
30583 - __asm__("lcall *(%%esi); cld\n\t"
30584 + __asm__("movw %w6, %%ds\n\t"
30585 + "lcall *%%ss:(%%esi); cld\n\t"
30586 + "push %%ss\n\t"
30587 + "pop %%ds\n\t"
30588 "jc 1f\n\t"
30589 "xor %%ah, %%ah\n"
30590 "1:"
30591 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30592 "c" (value),
30593 "b" (bx),
30594 "D" ((long)reg),
30595 - "S" (&pci_indirect));
30596 + "S" (&pci_indirect),
30597 + "r" (__PCIBIOS_DS));
30598 break;
30599 case 2:
30600 - __asm__("lcall *(%%esi); cld\n\t"
30601 + __asm__("movw %w6, %%ds\n\t"
30602 + "lcall *%%ss:(%%esi); cld\n\t"
30603 + "push %%ss\n\t"
30604 + "pop %%ds\n\t"
30605 "jc 1f\n\t"
30606 "xor %%ah, %%ah\n"
30607 "1:"
30608 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30609 "c" (value),
30610 "b" (bx),
30611 "D" ((long)reg),
30612 - "S" (&pci_indirect));
30613 + "S" (&pci_indirect),
30614 + "r" (__PCIBIOS_DS));
30615 break;
30616 case 4:
30617 - __asm__("lcall *(%%esi); cld\n\t"
30618 + __asm__("movw %w6, %%ds\n\t"
30619 + "lcall *%%ss:(%%esi); cld\n\t"
30620 + "push %%ss\n\t"
30621 + "pop %%ds\n\t"
30622 "jc 1f\n\t"
30623 "xor %%ah, %%ah\n"
30624 "1:"
30625 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30626 "c" (value),
30627 "b" (bx),
30628 "D" ((long)reg),
30629 - "S" (&pci_indirect));
30630 + "S" (&pci_indirect),
30631 + "r" (__PCIBIOS_DS));
30632 break;
30633 }
30634
30635 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30636
30637 DBG("PCI: Fetching IRQ routing table... ");
30638 __asm__("push %%es\n\t"
30639 + "movw %w8, %%ds\n\t"
30640 "push %%ds\n\t"
30641 "pop %%es\n\t"
30642 - "lcall *(%%esi); cld\n\t"
30643 + "lcall *%%ss:(%%esi); cld\n\t"
30644 "pop %%es\n\t"
30645 + "push %%ss\n\t"
30646 + "pop %%ds\n"
30647 "jc 1f\n\t"
30648 "xor %%ah, %%ah\n"
30649 "1:"
30650 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30651 "1" (0),
30652 "D" ((long) &opt),
30653 "S" (&pci_indirect),
30654 - "m" (opt)
30655 + "m" (opt),
30656 + "r" (__PCIBIOS_DS)
30657 : "memory");
30658 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30659 if (ret & 0xff00)
30660 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30661 {
30662 int ret;
30663
30664 - __asm__("lcall *(%%esi); cld\n\t"
30665 + __asm__("movw %w5, %%ds\n\t"
30666 + "lcall *%%ss:(%%esi); cld\n\t"
30667 + "push %%ss\n\t"
30668 + "pop %%ds\n"
30669 "jc 1f\n\t"
30670 "xor %%ah, %%ah\n"
30671 "1:"
30672 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30673 : "0" (PCIBIOS_SET_PCI_HW_INT),
30674 "b" ((dev->bus->number << 8) | dev->devfn),
30675 "c" ((irq << 8) | (pin + 10)),
30676 - "S" (&pci_indirect));
30677 + "S" (&pci_indirect),
30678 + "r" (__PCIBIOS_DS));
30679 return !(ret & 0xff00);
30680 }
30681 EXPORT_SYMBOL(pcibios_set_irq_routing);
30682 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30683 index 40e4469..1ab536e 100644
30684 --- a/arch/x86/platform/efi/efi_32.c
30685 +++ b/arch/x86/platform/efi/efi_32.c
30686 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30687 {
30688 struct desc_ptr gdt_descr;
30689
30690 +#ifdef CONFIG_PAX_KERNEXEC
30691 + struct desc_struct d;
30692 +#endif
30693 +
30694 local_irq_save(efi_rt_eflags);
30695
30696 load_cr3(initial_page_table);
30697 __flush_tlb_all();
30698
30699 +#ifdef CONFIG_PAX_KERNEXEC
30700 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30701 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30702 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30703 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30704 +#endif
30705 +
30706 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30707 gdt_descr.size = GDT_SIZE - 1;
30708 load_gdt(&gdt_descr);
30709 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30710 {
30711 struct desc_ptr gdt_descr;
30712
30713 +#ifdef CONFIG_PAX_KERNEXEC
30714 + struct desc_struct d;
30715 +
30716 + memset(&d, 0, sizeof d);
30717 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30718 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30719 +#endif
30720 +
30721 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30722 gdt_descr.size = GDT_SIZE - 1;
30723 load_gdt(&gdt_descr);
30724 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30725 index fbe66e6..eae5e38 100644
30726 --- a/arch/x86/platform/efi/efi_stub_32.S
30727 +++ b/arch/x86/platform/efi/efi_stub_32.S
30728 @@ -6,7 +6,9 @@
30729 */
30730
30731 #include <linux/linkage.h>
30732 +#include <linux/init.h>
30733 #include <asm/page_types.h>
30734 +#include <asm/segment.h>
30735
30736 /*
30737 * efi_call_phys(void *, ...) is a function with variable parameters.
30738 @@ -20,7 +22,7 @@
30739 * service functions will comply with gcc calling convention, too.
30740 */
30741
30742 -.text
30743 +__INIT
30744 ENTRY(efi_call_phys)
30745 /*
30746 * 0. The function can only be called in Linux kernel. So CS has been
30747 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30748 * The mapping of lower virtual memory has been created in prelog and
30749 * epilog.
30750 */
30751 - movl $1f, %edx
30752 - subl $__PAGE_OFFSET, %edx
30753 - jmp *%edx
30754 +#ifdef CONFIG_PAX_KERNEXEC
30755 + movl $(__KERNEXEC_EFI_DS), %edx
30756 + mov %edx, %ds
30757 + mov %edx, %es
30758 + mov %edx, %ss
30759 + addl $2f,(1f)
30760 + ljmp *(1f)
30761 +
30762 +__INITDATA
30763 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30764 +.previous
30765 +
30766 +2:
30767 + subl $2b,(1b)
30768 +#else
30769 + jmp 1f-__PAGE_OFFSET
30770 1:
30771 +#endif
30772
30773 /*
30774 * 2. Now on the top of stack is the return
30775 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30776 * parameter 2, ..., param n. To make things easy, we save the return
30777 * address of efi_call_phys in a global variable.
30778 */
30779 - popl %edx
30780 - movl %edx, saved_return_addr
30781 - /* get the function pointer into ECX*/
30782 - popl %ecx
30783 - movl %ecx, efi_rt_function_ptr
30784 - movl $2f, %edx
30785 - subl $__PAGE_OFFSET, %edx
30786 - pushl %edx
30787 + popl (saved_return_addr)
30788 + popl (efi_rt_function_ptr)
30789
30790 /*
30791 * 3. Clear PG bit in %CR0.
30792 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30793 /*
30794 * 5. Call the physical function.
30795 */
30796 - jmp *%ecx
30797 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30798
30799 -2:
30800 /*
30801 * 6. After EFI runtime service returns, control will return to
30802 * following instruction. We'd better readjust stack pointer first.
30803 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30804 movl %cr0, %edx
30805 orl $0x80000000, %edx
30806 movl %edx, %cr0
30807 - jmp 1f
30808 -1:
30809 +
30810 /*
30811 * 8. Now restore the virtual mode from flat mode by
30812 * adding EIP with PAGE_OFFSET.
30813 */
30814 - movl $1f, %edx
30815 - jmp *%edx
30816 +#ifdef CONFIG_PAX_KERNEXEC
30817 + movl $(__KERNEL_DS), %edx
30818 + mov %edx, %ds
30819 + mov %edx, %es
30820 + mov %edx, %ss
30821 + ljmp $(__KERNEL_CS),$1f
30822 +#else
30823 + jmp 1f+__PAGE_OFFSET
30824 +#endif
30825 1:
30826
30827 /*
30828 * 9. Balance the stack. And because EAX contain the return value,
30829 * we'd better not clobber it.
30830 */
30831 - leal efi_rt_function_ptr, %edx
30832 - movl (%edx), %ecx
30833 - pushl %ecx
30834 + pushl (efi_rt_function_ptr)
30835
30836 /*
30837 - * 10. Push the saved return address onto the stack and return.
30838 + * 10. Return to the saved return address.
30839 */
30840 - leal saved_return_addr, %edx
30841 - movl (%edx), %ecx
30842 - pushl %ecx
30843 - ret
30844 + jmpl *(saved_return_addr)
30845 ENDPROC(efi_call_phys)
30846 .previous
30847
30848 -.data
30849 +__INITDATA
30850 saved_return_addr:
30851 .long 0
30852 efi_rt_function_ptr:
30853 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30854 index 4c07cca..2c8427d 100644
30855 --- a/arch/x86/platform/efi/efi_stub_64.S
30856 +++ b/arch/x86/platform/efi/efi_stub_64.S
30857 @@ -7,6 +7,7 @@
30858 */
30859
30860 #include <linux/linkage.h>
30861 +#include <asm/alternative-asm.h>
30862
30863 #define SAVE_XMM \
30864 mov %rsp, %rax; \
30865 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30866 call *%rdi
30867 addq $32, %rsp
30868 RESTORE_XMM
30869 + pax_force_retaddr 0, 1
30870 ret
30871 ENDPROC(efi_call0)
30872
30873 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30874 call *%rdi
30875 addq $32, %rsp
30876 RESTORE_XMM
30877 + pax_force_retaddr 0, 1
30878 ret
30879 ENDPROC(efi_call1)
30880
30881 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30882 call *%rdi
30883 addq $32, %rsp
30884 RESTORE_XMM
30885 + pax_force_retaddr 0, 1
30886 ret
30887 ENDPROC(efi_call2)
30888
30889 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30890 call *%rdi
30891 addq $32, %rsp
30892 RESTORE_XMM
30893 + pax_force_retaddr 0, 1
30894 ret
30895 ENDPROC(efi_call3)
30896
30897 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30898 call *%rdi
30899 addq $32, %rsp
30900 RESTORE_XMM
30901 + pax_force_retaddr 0, 1
30902 ret
30903 ENDPROC(efi_call4)
30904
30905 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30906 call *%rdi
30907 addq $48, %rsp
30908 RESTORE_XMM
30909 + pax_force_retaddr 0, 1
30910 ret
30911 ENDPROC(efi_call5)
30912
30913 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30914 call *%rdi
30915 addq $48, %rsp
30916 RESTORE_XMM
30917 + pax_force_retaddr 0, 1
30918 ret
30919 ENDPROC(efi_call6)
30920 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30921 index e31bcd8..f12dc46 100644
30922 --- a/arch/x86/platform/mrst/mrst.c
30923 +++ b/arch/x86/platform/mrst/mrst.c
30924 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30925 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30926 int sfi_mrtc_num;
30927
30928 -static void mrst_power_off(void)
30929 +static __noreturn void mrst_power_off(void)
30930 {
30931 + BUG();
30932 }
30933
30934 -static void mrst_reboot(void)
30935 +static __noreturn void mrst_reboot(void)
30936 {
30937 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30938 + BUG();
30939 }
30940
30941 /* parse all the mtimer info to a static mtimer array */
30942 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30943 index d6ee929..3637cb5 100644
30944 --- a/arch/x86/platform/olpc/olpc_dt.c
30945 +++ b/arch/x86/platform/olpc/olpc_dt.c
30946 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30947 return res;
30948 }
30949
30950 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30951 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30952 .nextprop = olpc_dt_nextprop,
30953 .getproplen = olpc_dt_getproplen,
30954 .getproperty = olpc_dt_getproperty,
30955 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30956 index 3c68768..07e82b8 100644
30957 --- a/arch/x86/power/cpu.c
30958 +++ b/arch/x86/power/cpu.c
30959 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30960 static void fix_processor_context(void)
30961 {
30962 int cpu = smp_processor_id();
30963 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30964 + struct tss_struct *t = init_tss + cpu;
30965
30966 set_tss_desc(cpu, t); /*
30967 * This just modifies memory; should not be
30968 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30969 */
30970
30971 #ifdef CONFIG_X86_64
30972 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30973 -
30974 syscall_init(); /* This sets MSR_*STAR and related */
30975 #endif
30976 load_TR_desc(); /* This does ltr */
30977 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30978 index cbca565..bae7133 100644
30979 --- a/arch/x86/realmode/init.c
30980 +++ b/arch/x86/realmode/init.c
30981 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
30982 __va(real_mode_header->trampoline_header);
30983
30984 #ifdef CONFIG_X86_32
30985 - trampoline_header->start = __pa(startup_32_smp);
30986 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
30987 +
30988 +#ifdef CONFIG_PAX_KERNEXEC
30989 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30990 +#endif
30991 +
30992 + trampoline_header->boot_cs = __BOOT_CS;
30993 trampoline_header->gdt_limit = __BOOT_DS + 7;
30994 trampoline_header->gdt_base = __pa(boot_gdt);
30995 #else
30996 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30997 index 8869287..d577672 100644
30998 --- a/arch/x86/realmode/rm/Makefile
30999 +++ b/arch/x86/realmode/rm/Makefile
31000 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
31001 $(call cc-option, -fno-unit-at-a-time)) \
31002 $(call cc-option, -fno-stack-protector) \
31003 $(call cc-option, -mpreferred-stack-boundary=2)
31004 +ifdef CONSTIFY_PLUGIN
31005 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
31006 +endif
31007 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
31008 GCOV_PROFILE := n
31009 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
31010 index a28221d..93c40f1 100644
31011 --- a/arch/x86/realmode/rm/header.S
31012 +++ b/arch/x86/realmode/rm/header.S
31013 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
31014 #endif
31015 /* APM/BIOS reboot */
31016 .long pa_machine_real_restart_asm
31017 -#ifdef CONFIG_X86_64
31018 +#ifdef CONFIG_X86_32
31019 + .long __KERNEL_CS
31020 +#else
31021 .long __KERNEL32_CS
31022 #endif
31023 END(real_mode_header)
31024 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
31025 index c1b2791..f9e31c7 100644
31026 --- a/arch/x86/realmode/rm/trampoline_32.S
31027 +++ b/arch/x86/realmode/rm/trampoline_32.S
31028 @@ -25,6 +25,12 @@
31029 #include <asm/page_types.h>
31030 #include "realmode.h"
31031
31032 +#ifdef CONFIG_PAX_KERNEXEC
31033 +#define ta(X) (X)
31034 +#else
31035 +#define ta(X) (pa_ ## X)
31036 +#endif
31037 +
31038 .text
31039 .code16
31040
31041 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
31042
31043 cli # We should be safe anyway
31044
31045 - movl tr_start, %eax # where we need to go
31046 -
31047 movl $0xA5A5A5A5, trampoline_status
31048 # write marker for master knows we're running
31049
31050 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
31051 movw $1, %dx # protected mode (PE) bit
31052 lmsw %dx # into protected mode
31053
31054 - ljmpl $__BOOT_CS, $pa_startup_32
31055 + ljmpl *(trampoline_header)
31056
31057 .section ".text32","ax"
31058 .code32
31059 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
31060 .balign 8
31061 GLOBAL(trampoline_header)
31062 tr_start: .space 4
31063 - tr_gdt_pad: .space 2
31064 + tr_boot_cs: .space 2
31065 tr_gdt: .space 6
31066 END(trampoline_header)
31067
31068 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
31069 index bb360dc..3e5945f 100644
31070 --- a/arch/x86/realmode/rm/trampoline_64.S
31071 +++ b/arch/x86/realmode/rm/trampoline_64.S
31072 @@ -107,7 +107,7 @@ ENTRY(startup_32)
31073 wrmsr
31074
31075 # Enable paging and in turn activate Long Mode
31076 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
31077 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
31078 movl %eax, %cr0
31079
31080 /*
31081 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
31082 index 79d67bd..c7e1b90 100644
31083 --- a/arch/x86/tools/relocs.c
31084 +++ b/arch/x86/tools/relocs.c
31085 @@ -12,10 +12,13 @@
31086 #include <regex.h>
31087 #include <tools/le_byteshift.h>
31088
31089 +#include "../../../include/generated/autoconf.h"
31090 +
31091 static void die(char *fmt, ...);
31092
31093 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
31094 static Elf32_Ehdr ehdr;
31095 +static Elf32_Phdr *phdr;
31096 static unsigned long reloc_count, reloc_idx;
31097 static unsigned long *relocs;
31098 static unsigned long reloc16_count, reloc16_idx;
31099 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
31100 }
31101 }
31102
31103 +static void read_phdrs(FILE *fp)
31104 +{
31105 + unsigned int i;
31106 +
31107 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
31108 + if (!phdr) {
31109 + die("Unable to allocate %d program headers\n",
31110 + ehdr.e_phnum);
31111 + }
31112 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
31113 + die("Seek to %d failed: %s\n",
31114 + ehdr.e_phoff, strerror(errno));
31115 + }
31116 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
31117 + die("Cannot read ELF program headers: %s\n",
31118 + strerror(errno));
31119 + }
31120 + for(i = 0; i < ehdr.e_phnum; i++) {
31121 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
31122 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
31123 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
31124 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
31125 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
31126 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
31127 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
31128 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
31129 + }
31130 +
31131 +}
31132 +
31133 static void read_shdrs(FILE *fp)
31134 {
31135 - int i;
31136 + unsigned int i;
31137 Elf32_Shdr shdr;
31138
31139 secs = calloc(ehdr.e_shnum, sizeof(struct section));
31140 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
31141
31142 static void read_strtabs(FILE *fp)
31143 {
31144 - int i;
31145 + unsigned int i;
31146 for (i = 0; i < ehdr.e_shnum; i++) {
31147 struct section *sec = &secs[i];
31148 if (sec->shdr.sh_type != SHT_STRTAB) {
31149 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
31150
31151 static void read_symtabs(FILE *fp)
31152 {
31153 - int i,j;
31154 + unsigned int i,j;
31155 for (i = 0; i < ehdr.e_shnum; i++) {
31156 struct section *sec = &secs[i];
31157 if (sec->shdr.sh_type != SHT_SYMTAB) {
31158 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
31159 }
31160
31161
31162 -static void read_relocs(FILE *fp)
31163 +static void read_relocs(FILE *fp, int use_real_mode)
31164 {
31165 - int i,j;
31166 + unsigned int i,j;
31167 + uint32_t base;
31168 +
31169 for (i = 0; i < ehdr.e_shnum; i++) {
31170 struct section *sec = &secs[i];
31171 if (sec->shdr.sh_type != SHT_REL) {
31172 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
31173 die("Cannot read symbol table: %s\n",
31174 strerror(errno));
31175 }
31176 + base = 0;
31177 +
31178 +#ifdef CONFIG_X86_32
31179 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
31180 + if (phdr[j].p_type != PT_LOAD )
31181 + continue;
31182 + 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)
31183 + continue;
31184 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
31185 + break;
31186 + }
31187 +#endif
31188 +
31189 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
31190 Elf32_Rel *rel = &sec->reltab[j];
31191 - rel->r_offset = elf32_to_cpu(rel->r_offset);
31192 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
31193 rel->r_info = elf32_to_cpu(rel->r_info);
31194 }
31195 }
31196 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
31197
31198 static void print_absolute_symbols(void)
31199 {
31200 - int i;
31201 + unsigned int i;
31202 printf("Absolute symbols\n");
31203 printf(" Num: Value Size Type Bind Visibility Name\n");
31204 for (i = 0; i < ehdr.e_shnum; i++) {
31205 struct section *sec = &secs[i];
31206 char *sym_strtab;
31207 - int j;
31208 + unsigned int j;
31209
31210 if (sec->shdr.sh_type != SHT_SYMTAB) {
31211 continue;
31212 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
31213
31214 static void print_absolute_relocs(void)
31215 {
31216 - int i, printed = 0;
31217 + unsigned int i, printed = 0;
31218
31219 for (i = 0; i < ehdr.e_shnum; i++) {
31220 struct section *sec = &secs[i];
31221 struct section *sec_applies, *sec_symtab;
31222 char *sym_strtab;
31223 Elf32_Sym *sh_symtab;
31224 - int j;
31225 + unsigned int j;
31226 if (sec->shdr.sh_type != SHT_REL) {
31227 continue;
31228 }
31229 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
31230 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31231 int use_real_mode)
31232 {
31233 - int i;
31234 + unsigned int i;
31235 /* Walk through the relocations */
31236 for (i = 0; i < ehdr.e_shnum; i++) {
31237 char *sym_strtab;
31238 Elf32_Sym *sh_symtab;
31239 struct section *sec_applies, *sec_symtab;
31240 - int j;
31241 + unsigned int j;
31242 struct section *sec = &secs[i];
31243
31244 if (sec->shdr.sh_type != SHT_REL) {
31245 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31246 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
31247 r_type = ELF32_R_TYPE(rel->r_info);
31248
31249 + if (!use_real_mode) {
31250 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31251 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31252 + continue;
31253 +
31254 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
31255 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31256 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31257 + continue;
31258 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31259 + continue;
31260 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31261 + continue;
31262 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31263 + continue;
31264 +#endif
31265 + }
31266 +
31267 shn_abs = sym->st_shndx == SHN_ABS;
31268
31269 switch (r_type) {
31270 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
31271
31272 static void emit_relocs(int as_text, int use_real_mode)
31273 {
31274 - int i;
31275 + unsigned int i;
31276 /* Count how many relocations I have and allocate space for them. */
31277 reloc_count = 0;
31278 walk_relocs(count_reloc, use_real_mode);
31279 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
31280 fname, strerror(errno));
31281 }
31282 read_ehdr(fp);
31283 + read_phdrs(fp);
31284 read_shdrs(fp);
31285 read_strtabs(fp);
31286 read_symtabs(fp);
31287 - read_relocs(fp);
31288 + read_relocs(fp, use_real_mode);
31289 if (show_absolute_syms) {
31290 print_absolute_symbols();
31291 goto out;
31292 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31293 index fd14be1..e3c79c0 100644
31294 --- a/arch/x86/vdso/Makefile
31295 +++ b/arch/x86/vdso/Makefile
31296 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31297 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31298 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31299
31300 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31301 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31302 GCOV_PROFILE := n
31303
31304 #
31305 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31306 index 0faad64..39ef157 100644
31307 --- a/arch/x86/vdso/vdso32-setup.c
31308 +++ b/arch/x86/vdso/vdso32-setup.c
31309 @@ -25,6 +25,7 @@
31310 #include <asm/tlbflush.h>
31311 #include <asm/vdso.h>
31312 #include <asm/proto.h>
31313 +#include <asm/mman.h>
31314
31315 enum {
31316 VDSO_DISABLED = 0,
31317 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31318 void enable_sep_cpu(void)
31319 {
31320 int cpu = get_cpu();
31321 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31322 + struct tss_struct *tss = init_tss + cpu;
31323
31324 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31325 put_cpu();
31326 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31327 gate_vma.vm_start = FIXADDR_USER_START;
31328 gate_vma.vm_end = FIXADDR_USER_END;
31329 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31330 - gate_vma.vm_page_prot = __P101;
31331 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31332
31333 return 0;
31334 }
31335 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31336 if (compat)
31337 addr = VDSO_HIGH_BASE;
31338 else {
31339 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31340 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31341 if (IS_ERR_VALUE(addr)) {
31342 ret = addr;
31343 goto up_fail;
31344 }
31345 }
31346
31347 - current->mm->context.vdso = (void *)addr;
31348 + current->mm->context.vdso = addr;
31349
31350 if (compat_uses_vma || !compat) {
31351 /*
31352 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31353 }
31354
31355 current_thread_info()->sysenter_return =
31356 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31357 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31358
31359 up_fail:
31360 if (ret)
31361 - current->mm->context.vdso = NULL;
31362 + current->mm->context.vdso = 0;
31363
31364 up_write(&mm->mmap_sem);
31365
31366 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31367
31368 const char *arch_vma_name(struct vm_area_struct *vma)
31369 {
31370 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31371 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31372 return "[vdso]";
31373 +
31374 +#ifdef CONFIG_PAX_SEGMEXEC
31375 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31376 + return "[vdso]";
31377 +#endif
31378 +
31379 return NULL;
31380 }
31381
31382 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31383 * Check to see if the corresponding task was created in compat vdso
31384 * mode.
31385 */
31386 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31387 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31388 return &gate_vma;
31389 return NULL;
31390 }
31391 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31392 index 431e875..cbb23f3 100644
31393 --- a/arch/x86/vdso/vma.c
31394 +++ b/arch/x86/vdso/vma.c
31395 @@ -16,8 +16,6 @@
31396 #include <asm/vdso.h>
31397 #include <asm/page.h>
31398
31399 -unsigned int __read_mostly vdso_enabled = 1;
31400 -
31401 extern char vdso_start[], vdso_end[];
31402 extern unsigned short vdso_sync_cpuid;
31403
31404 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31405 * unaligned here as a result of stack start randomization.
31406 */
31407 addr = PAGE_ALIGN(addr);
31408 - addr = align_vdso_addr(addr);
31409
31410 return addr;
31411 }
31412 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31413 unsigned size)
31414 {
31415 struct mm_struct *mm = current->mm;
31416 - unsigned long addr;
31417 + unsigned long addr = 0;
31418 int ret;
31419
31420 - if (!vdso_enabled)
31421 - return 0;
31422 -
31423 down_write(&mm->mmap_sem);
31424 +
31425 +#ifdef CONFIG_PAX_RANDMMAP
31426 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31427 +#endif
31428 +
31429 addr = vdso_addr(mm->start_stack, size);
31430 + addr = align_vdso_addr(addr);
31431 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31432 if (IS_ERR_VALUE(addr)) {
31433 ret = addr;
31434 goto up_fail;
31435 }
31436
31437 - current->mm->context.vdso = (void *)addr;
31438 + mm->context.vdso = addr;
31439
31440 ret = install_special_mapping(mm, addr, size,
31441 VM_READ|VM_EXEC|
31442 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31443 pages);
31444 - if (ret) {
31445 - current->mm->context.vdso = NULL;
31446 - goto up_fail;
31447 - }
31448 + if (ret)
31449 + mm->context.vdso = 0;
31450
31451 up_fail:
31452 up_write(&mm->mmap_sem);
31453 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31454 vdsox32_size);
31455 }
31456 #endif
31457 -
31458 -static __init int vdso_setup(char *s)
31459 -{
31460 - vdso_enabled = simple_strtoul(s, NULL, 0);
31461 - return 0;
31462 -}
31463 -__setup("vdso=", vdso_setup);
31464 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31465 index 2262003..3ee61cf 100644
31466 --- a/arch/x86/xen/enlighten.c
31467 +++ b/arch/x86/xen/enlighten.c
31468 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31469
31470 struct shared_info xen_dummy_shared_info;
31471
31472 -void *xen_initial_gdt;
31473 -
31474 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31475 __read_mostly int xen_have_vector_callback;
31476 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31477 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31478 {
31479 unsigned long va = dtr->address;
31480 unsigned int size = dtr->size + 1;
31481 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31482 - unsigned long frames[pages];
31483 + unsigned long frames[65536 / PAGE_SIZE];
31484 int f;
31485
31486 /*
31487 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31488 {
31489 unsigned long va = dtr->address;
31490 unsigned int size = dtr->size + 1;
31491 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31492 - unsigned long frames[pages];
31493 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31494 int f;
31495
31496 /*
31497 @@ -554,7 +550,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31498 * 8-byte entries, or 16 4k pages..
31499 */
31500
31501 - BUG_ON(size > 65536);
31502 + BUG_ON(size > GDT_SIZE);
31503 BUG_ON(va & ~PAGE_MASK);
31504
31505 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31506 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31507 return 0;
31508 }
31509
31510 -static void set_xen_basic_apic_ops(void)
31511 +static void __init set_xen_basic_apic_ops(void)
31512 {
31513 apic->read = xen_apic_read;
31514 apic->write = xen_apic_write;
31515 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31516 #endif
31517 };
31518
31519 -static void xen_reboot(int reason)
31520 +static __noreturn void xen_reboot(int reason)
31521 {
31522 struct sched_shutdown r = { .reason = reason };
31523
31524 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31525 - BUG();
31526 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31527 + BUG();
31528 }
31529
31530 -static void xen_restart(char *msg)
31531 +static __noreturn void xen_restart(char *msg)
31532 {
31533 xen_reboot(SHUTDOWN_reboot);
31534 }
31535
31536 -static void xen_emergency_restart(void)
31537 +static __noreturn void xen_emergency_restart(void)
31538 {
31539 xen_reboot(SHUTDOWN_reboot);
31540 }
31541
31542 -static void xen_machine_halt(void)
31543 +static __noreturn void xen_machine_halt(void)
31544 {
31545 xen_reboot(SHUTDOWN_poweroff);
31546 }
31547
31548 -static void xen_machine_power_off(void)
31549 +static __noreturn void xen_machine_power_off(void)
31550 {
31551 if (pm_power_off)
31552 pm_power_off();
31553 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
31554 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31555
31556 /* Work out if we support NX */
31557 - x86_configure_nx();
31558 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31559 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31560 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31561 + unsigned l, h;
31562 +
31563 + __supported_pte_mask |= _PAGE_NX;
31564 + rdmsr(MSR_EFER, l, h);
31565 + l |= EFER_NX;
31566 + wrmsr(MSR_EFER, l, h);
31567 + }
31568 +#endif
31569
31570 xen_setup_features();
31571
31572 @@ -1401,13 +1407,6 @@ asmlinkage void __init xen_start_kernel(void)
31573
31574 machine_ops = xen_machine_ops;
31575
31576 - /*
31577 - * The only reliable way to retain the initial address of the
31578 - * percpu gdt_page is to remember it here, so we can go and
31579 - * mark it RW later, when the initial percpu area is freed.
31580 - */
31581 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31582 -
31583 xen_smp_init();
31584
31585 #ifdef CONFIG_ACPI_NUMA
31586 @@ -1598,7 +1597,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31587 return NOTIFY_OK;
31588 }
31589
31590 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31591 +static struct notifier_block xen_hvm_cpu_notifier = {
31592 .notifier_call = xen_hvm_cpu_notify,
31593 };
31594
31595 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31596 index cab96b6..8c629ba 100644
31597 --- a/arch/x86/xen/mmu.c
31598 +++ b/arch/x86/xen/mmu.c
31599 @@ -1739,14 +1739,18 @@ static void *m2v(phys_addr_t maddr)
31600 }
31601
31602 /* Set the page permissions on an identity-mapped pages */
31603 -static void set_page_prot(void *addr, pgprot_t prot)
31604 +static void set_page_prot_flags(void *addr, pgprot_t prot, unsigned long flags)
31605 {
31606 unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
31607 pte_t pte = pfn_pte(pfn, prot);
31608
31609 - if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, 0))
31610 + if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, flags))
31611 BUG();
31612 }
31613 +static void set_page_prot(void *addr, pgprot_t prot)
31614 +{
31615 + return set_page_prot_flags(addr, prot, UVMF_NONE);
31616 +}
31617 #ifdef CONFIG_X86_32
31618 static void __init xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
31619 {
31620 @@ -1830,12 +1834,12 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
31621 unsigned long addr)
31622 {
31623 if (*pt_base == PFN_DOWN(__pa(addr))) {
31624 - set_page_prot((void *)addr, PAGE_KERNEL);
31625 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31626 clear_page((void *)addr);
31627 (*pt_base)++;
31628 }
31629 if (*pt_end == PFN_DOWN(__pa(addr))) {
31630 - set_page_prot((void *)addr, PAGE_KERNEL);
31631 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31632 clear_page((void *)addr);
31633 (*pt_end)--;
31634 }
31635 @@ -1881,6 +1885,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31636 /* L3_k[510] -> level2_kernel_pgt
31637 * L3_i[511] -> level2_fixmap_pgt */
31638 convert_pfn_mfn(level3_kernel_pgt);
31639 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31640 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31641 + convert_pfn_mfn(level3_vmemmap_pgt);
31642
31643 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31644 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31645 @@ -1910,8 +1917,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31646 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31647 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31648 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31649 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31650 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31651 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31652 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31653 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31654 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31655 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31656 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31657
31658 @@ -2097,6 +2108,7 @@ static void __init xen_post_allocator_init(void)
31659 pv_mmu_ops.set_pud = xen_set_pud;
31660 #if PAGETABLE_LEVELS == 4
31661 pv_mmu_ops.set_pgd = xen_set_pgd;
31662 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31663 #endif
31664
31665 /* This will work as long as patching hasn't happened yet
31666 @@ -2178,6 +2190,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31667 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31668 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31669 .set_pgd = xen_set_pgd_hyper,
31670 + .set_pgd_batched = xen_set_pgd_hyper,
31671
31672 .alloc_pud = xen_alloc_pmd_init,
31673 .release_pud = xen_release_pmd_init,
31674 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31675 index 34bc4ce..c34aa24 100644
31676 --- a/arch/x86/xen/smp.c
31677 +++ b/arch/x86/xen/smp.c
31678 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31679 {
31680 BUG_ON(smp_processor_id() != 0);
31681 native_smp_prepare_boot_cpu();
31682 -
31683 - /* We've switched to the "real" per-cpu gdt, so make sure the
31684 - old memory can be recycled */
31685 - make_lowmem_page_readwrite(xen_initial_gdt);
31686 -
31687 xen_filter_cpu_maps();
31688 xen_setup_vcpu_info_placement();
31689 }
31690 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31691 gdt = get_cpu_gdt_table(cpu);
31692
31693 ctxt->flags = VGCF_IN_KERNEL;
31694 - ctxt->user_regs.ds = __USER_DS;
31695 - ctxt->user_regs.es = __USER_DS;
31696 + ctxt->user_regs.ds = __KERNEL_DS;
31697 + ctxt->user_regs.es = __KERNEL_DS;
31698 ctxt->user_regs.ss = __KERNEL_DS;
31699 #ifdef CONFIG_X86_32
31700 ctxt->user_regs.fs = __KERNEL_PERCPU;
31701 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31702 + savesegment(gs, ctxt->user_regs.gs);
31703 #else
31704 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31705 #endif
31706 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31707 int rc;
31708
31709 per_cpu(current_task, cpu) = idle;
31710 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31711 #ifdef CONFIG_X86_32
31712 irq_ctx_init(cpu);
31713 #else
31714 clear_tsk_thread_flag(idle, TIF_FORK);
31715 - per_cpu(kernel_stack, cpu) =
31716 - (unsigned long)task_stack_page(idle) -
31717 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31718 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31719 #endif
31720 xen_setup_runstate_info(cpu);
31721 xen_setup_timer(cpu);
31722 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31723
31724 void __init xen_smp_init(void)
31725 {
31726 - smp_ops = xen_smp_ops;
31727 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31728 xen_fill_possible_map();
31729 xen_init_spinlocks();
31730 }
31731 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31732 index 33ca6e4..0ded929 100644
31733 --- a/arch/x86/xen/xen-asm_32.S
31734 +++ b/arch/x86/xen/xen-asm_32.S
31735 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31736 ESP_OFFSET=4 # bytes pushed onto stack
31737
31738 /*
31739 - * Store vcpu_info pointer for easy access. Do it this way to
31740 - * avoid having to reload %fs
31741 + * Store vcpu_info pointer for easy access.
31742 */
31743 #ifdef CONFIG_SMP
31744 - GET_THREAD_INFO(%eax)
31745 - movl %ss:TI_cpu(%eax), %eax
31746 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31747 - mov %ss:xen_vcpu(%eax), %eax
31748 + push %fs
31749 + mov $(__KERNEL_PERCPU), %eax
31750 + mov %eax, %fs
31751 + mov PER_CPU_VAR(xen_vcpu), %eax
31752 + pop %fs
31753 #else
31754 movl %ss:xen_vcpu, %eax
31755 #endif
31756 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31757 index 7faed58..ba4427c 100644
31758 --- a/arch/x86/xen/xen-head.S
31759 +++ b/arch/x86/xen/xen-head.S
31760 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31761 #ifdef CONFIG_X86_32
31762 mov %esi,xen_start_info
31763 mov $init_thread_union+THREAD_SIZE,%esp
31764 +#ifdef CONFIG_SMP
31765 + movl $cpu_gdt_table,%edi
31766 + movl $__per_cpu_load,%eax
31767 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31768 + rorl $16,%eax
31769 + movb %al,__KERNEL_PERCPU + 4(%edi)
31770 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31771 + movl $__per_cpu_end - 1,%eax
31772 + subl $__per_cpu_start,%eax
31773 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31774 +#endif
31775 #else
31776 mov %rsi,xen_start_info
31777 mov $init_thread_union+THREAD_SIZE,%rsp
31778 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31779 index a95b417..b6dbd0b 100644
31780 --- a/arch/x86/xen/xen-ops.h
31781 +++ b/arch/x86/xen/xen-ops.h
31782 @@ -10,8 +10,6 @@
31783 extern const char xen_hypervisor_callback[];
31784 extern const char xen_failsafe_callback[];
31785
31786 -extern void *xen_initial_gdt;
31787 -
31788 struct trap_info;
31789 void xen_copy_trap_info(struct trap_info *traps);
31790
31791 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31792 index 525bd3d..ef888b1 100644
31793 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31794 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31795 @@ -119,9 +119,9 @@
31796 ----------------------------------------------------------------------*/
31797
31798 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31799 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31800 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31801 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31802 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31803
31804 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31805 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31806 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31807 index 2f33760..835e50a 100644
31808 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31809 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31810 @@ -11,6 +11,7 @@
31811 #ifndef _XTENSA_CORE_H
31812 #define _XTENSA_CORE_H
31813
31814 +#include <linux/const.h>
31815
31816 /****************************************************************************
31817 Parameters Useful for Any Code, USER or PRIVILEGED
31818 @@ -112,9 +113,9 @@
31819 ----------------------------------------------------------------------*/
31820
31821 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31822 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31823 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31824 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31825 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31826
31827 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31828 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31829 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31830 index af00795..2bb8105 100644
31831 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31832 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31833 @@ -11,6 +11,7 @@
31834 #ifndef _XTENSA_CORE_CONFIGURATION_H
31835 #define _XTENSA_CORE_CONFIGURATION_H
31836
31837 +#include <linux/const.h>
31838
31839 /****************************************************************************
31840 Parameters Useful for Any Code, USER or PRIVILEGED
31841 @@ -118,9 +119,9 @@
31842 ----------------------------------------------------------------------*/
31843
31844 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31845 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31846 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31847 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31848 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31849
31850 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31851 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31852 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31853 index 58916af..eb9dbcf6 100644
31854 --- a/block/blk-iopoll.c
31855 +++ b/block/blk-iopoll.c
31856 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31857 }
31858 EXPORT_SYMBOL(blk_iopoll_complete);
31859
31860 -static void blk_iopoll_softirq(struct softirq_action *h)
31861 +static void blk_iopoll_softirq(void)
31862 {
31863 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31864 int rearm = 0, budget = blk_iopoll_budget;
31865 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31866 return NOTIFY_OK;
31867 }
31868
31869 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31870 +static struct notifier_block blk_iopoll_cpu_notifier = {
31871 .notifier_call = blk_iopoll_cpu_notify,
31872 };
31873
31874 diff --git a/block/blk-map.c b/block/blk-map.c
31875 index 623e1cd..ca1e109 100644
31876 --- a/block/blk-map.c
31877 +++ b/block/blk-map.c
31878 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31879 if (!len || !kbuf)
31880 return -EINVAL;
31881
31882 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31883 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31884 if (do_copy)
31885 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31886 else
31887 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31888 index 467c8de..f3628c5 100644
31889 --- a/block/blk-softirq.c
31890 +++ b/block/blk-softirq.c
31891 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31892 * Softirq action handler - move entries to local list and loop over them
31893 * while passing them to the queue registered handler.
31894 */
31895 -static void blk_done_softirq(struct softirq_action *h)
31896 +static void blk_done_softirq(void)
31897 {
31898 struct list_head *cpu_list, local_list;
31899
31900 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31901 return NOTIFY_OK;
31902 }
31903
31904 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31905 +static struct notifier_block blk_cpu_notifier = {
31906 .notifier_call = blk_cpu_notify,
31907 };
31908
31909 diff --git a/block/bsg.c b/block/bsg.c
31910 index ff64ae3..593560c 100644
31911 --- a/block/bsg.c
31912 +++ b/block/bsg.c
31913 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31914 struct sg_io_v4 *hdr, struct bsg_device *bd,
31915 fmode_t has_write_perm)
31916 {
31917 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31918 + unsigned char *cmdptr;
31919 +
31920 if (hdr->request_len > BLK_MAX_CDB) {
31921 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31922 if (!rq->cmd)
31923 return -ENOMEM;
31924 - }
31925 + cmdptr = rq->cmd;
31926 + } else
31927 + cmdptr = tmpcmd;
31928
31929 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31930 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31931 hdr->request_len))
31932 return -EFAULT;
31933
31934 + if (cmdptr != rq->cmd)
31935 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31936 +
31937 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31938 if (blk_verify_command(rq->cmd, has_write_perm))
31939 return -EPERM;
31940 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31941 index 7c668c8..db3521c 100644
31942 --- a/block/compat_ioctl.c
31943 +++ b/block/compat_ioctl.c
31944 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31945 err |= __get_user(f->spec1, &uf->spec1);
31946 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31947 err |= __get_user(name, &uf->name);
31948 - f->name = compat_ptr(name);
31949 + f->name = (void __force_kernel *)compat_ptr(name);
31950 if (err) {
31951 err = -EFAULT;
31952 goto out;
31953 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31954 index b62fb88..bdab4c4 100644
31955 --- a/block/partitions/efi.c
31956 +++ b/block/partitions/efi.c
31957 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31958 if (!gpt)
31959 return NULL;
31960
31961 + if (!le32_to_cpu(gpt->num_partition_entries))
31962 + return NULL;
31963 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31964 + if (!pte)
31965 + return NULL;
31966 +
31967 count = le32_to_cpu(gpt->num_partition_entries) *
31968 le32_to_cpu(gpt->sizeof_partition_entry);
31969 - if (!count)
31970 - return NULL;
31971 - pte = kzalloc(count, GFP_KERNEL);
31972 - if (!pte)
31973 - return NULL;
31974 -
31975 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31976 (u8 *) pte,
31977 count) < count) {
31978 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31979 index 9a87daa..fb17486 100644
31980 --- a/block/scsi_ioctl.c
31981 +++ b/block/scsi_ioctl.c
31982 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31983 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31984 struct sg_io_hdr *hdr, fmode_t mode)
31985 {
31986 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31987 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31988 + unsigned char *cmdptr;
31989 +
31990 + if (rq->cmd != rq->__cmd)
31991 + cmdptr = rq->cmd;
31992 + else
31993 + cmdptr = tmpcmd;
31994 +
31995 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31996 return -EFAULT;
31997 +
31998 + if (cmdptr != rq->cmd)
31999 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
32000 +
32001 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
32002 return -EPERM;
32003
32004 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
32005 int err;
32006 unsigned int in_len, out_len, bytes, opcode, cmdlen;
32007 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
32008 + unsigned char tmpcmd[sizeof(rq->__cmd)];
32009 + unsigned char *cmdptr;
32010
32011 if (!sic)
32012 return -EINVAL;
32013 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
32014 */
32015 err = -EFAULT;
32016 rq->cmd_len = cmdlen;
32017 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
32018 +
32019 + if (rq->cmd != rq->__cmd)
32020 + cmdptr = rq->cmd;
32021 + else
32022 + cmdptr = tmpcmd;
32023 +
32024 + if (copy_from_user(cmdptr, sic->data, cmdlen))
32025 goto error;
32026
32027 + if (rq->cmd != cmdptr)
32028 + memcpy(rq->cmd, cmdptr, cmdlen);
32029 +
32030 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
32031 goto error;
32032
32033 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
32034 index 7bdd61b..afec999 100644
32035 --- a/crypto/cryptd.c
32036 +++ b/crypto/cryptd.c
32037 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
32038
32039 struct cryptd_blkcipher_request_ctx {
32040 crypto_completion_t complete;
32041 -};
32042 +} __no_const;
32043
32044 struct cryptd_hash_ctx {
32045 struct crypto_shash *child;
32046 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
32047
32048 struct cryptd_aead_request_ctx {
32049 crypto_completion_t complete;
32050 -};
32051 +} __no_const;
32052
32053 static void cryptd_queue_worker(struct work_struct *work);
32054
32055 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
32056 index f6d9baf..dfd511f 100644
32057 --- a/crypto/crypto_user.c
32058 +++ b/crypto/crypto_user.c
32059 @@ -30,6 +30,8 @@
32060
32061 #include "internal.h"
32062
32063 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
32064 +
32065 static DEFINE_MUTEX(crypto_cfg_mutex);
32066
32067 /* The crypto netlink socket */
32068 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
32069 struct crypto_dump_info info;
32070 int err;
32071
32072 - if (!p->cru_driver_name)
32073 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32074 + return -EINVAL;
32075 +
32076 + if (!p->cru_driver_name[0])
32077 return -EINVAL;
32078
32079 alg = crypto_alg_match(p, 1);
32080 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32081 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32082 LIST_HEAD(list);
32083
32084 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32085 + return -EINVAL;
32086 +
32087 if (priority && !strlen(p->cru_driver_name))
32088 return -EINVAL;
32089
32090 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32091 struct crypto_alg *alg;
32092 struct crypto_user_alg *p = nlmsg_data(nlh);
32093
32094 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32095 + return -EINVAL;
32096 +
32097 alg = crypto_alg_match(p, 1);
32098 if (!alg)
32099 return -ENOENT;
32100 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32101 struct crypto_user_alg *p = nlmsg_data(nlh);
32102 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32103
32104 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32105 + return -EINVAL;
32106 +
32107 if (strlen(p->cru_driver_name))
32108 exact = 1;
32109
32110 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
32111 index f220d64..d359ad6 100644
32112 --- a/drivers/acpi/apei/apei-internal.h
32113 +++ b/drivers/acpi/apei/apei-internal.h
32114 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
32115 struct apei_exec_ins_type {
32116 u32 flags;
32117 apei_exec_ins_func_t run;
32118 -};
32119 +} __do_const;
32120
32121 struct apei_exec_context {
32122 u32 ip;
32123 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
32124 index e6defd8..c26a225 100644
32125 --- a/drivers/acpi/apei/cper.c
32126 +++ b/drivers/acpi/apei/cper.c
32127 @@ -38,12 +38,12 @@
32128 */
32129 u64 cper_next_record_id(void)
32130 {
32131 - static atomic64_t seq;
32132 + static atomic64_unchecked_t seq;
32133
32134 - if (!atomic64_read(&seq))
32135 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
32136 + if (!atomic64_read_unchecked(&seq))
32137 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
32138
32139 - return atomic64_inc_return(&seq);
32140 + return atomic64_inc_return_unchecked(&seq);
32141 }
32142 EXPORT_SYMBOL_GPL(cper_next_record_id);
32143
32144 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
32145 index be60399..778b33e8 100644
32146 --- a/drivers/acpi/bgrt.c
32147 +++ b/drivers/acpi/bgrt.c
32148 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
32149 return -ENODEV;
32150
32151 sysfs_bin_attr_init(&image_attr);
32152 - image_attr.private = bgrt_image;
32153 - image_attr.size = bgrt_image_size;
32154 + pax_open_kernel();
32155 + *(void **)&image_attr.private = bgrt_image;
32156 + *(size_t *)&image_attr.size = bgrt_image_size;
32157 + pax_close_kernel();
32158
32159 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
32160 if (!bgrt_kobj)
32161 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
32162 index cb96296..b81293b 100644
32163 --- a/drivers/acpi/blacklist.c
32164 +++ b/drivers/acpi/blacklist.c
32165 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
32166 u32 is_critical_error;
32167 };
32168
32169 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
32170 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
32171
32172 /*
32173 * POLICY: If *anything* doesn't work, put it on the blacklist.
32174 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
32175 return 0;
32176 }
32177
32178 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
32179 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
32180 {
32181 .callback = dmi_disable_osi_vista,
32182 .ident = "Fujitsu Siemens",
32183 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
32184 index 7586544..636a2f0 100644
32185 --- a/drivers/acpi/ec_sys.c
32186 +++ b/drivers/acpi/ec_sys.c
32187 @@ -12,6 +12,7 @@
32188 #include <linux/acpi.h>
32189 #include <linux/debugfs.h>
32190 #include <linux/module.h>
32191 +#include <linux/uaccess.h>
32192 #include "internal.h"
32193
32194 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
32195 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32196 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
32197 */
32198 unsigned int size = EC_SPACE_SIZE;
32199 - u8 *data = (u8 *) buf;
32200 + u8 data;
32201 loff_t init_off = *off;
32202 int err = 0;
32203
32204 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32205 size = count;
32206
32207 while (size) {
32208 - err = ec_read(*off, &data[*off - init_off]);
32209 + err = ec_read(*off, &data);
32210 if (err)
32211 return err;
32212 + if (put_user(data, &buf[*off - init_off]))
32213 + return -EFAULT;
32214 *off += 1;
32215 size--;
32216 }
32217 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32218
32219 unsigned int size = count;
32220 loff_t init_off = *off;
32221 - u8 *data = (u8 *) buf;
32222 int err = 0;
32223
32224 if (*off >= EC_SPACE_SIZE)
32225 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32226 }
32227
32228 while (size) {
32229 - u8 byte_write = data[*off - init_off];
32230 + u8 byte_write;
32231 + if (get_user(byte_write, &buf[*off - init_off]))
32232 + return -EFAULT;
32233 err = ec_write(*off, byte_write);
32234 if (err)
32235 return err;
32236 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
32237 index e83311b..142b5cc 100644
32238 --- a/drivers/acpi/processor_driver.c
32239 +++ b/drivers/acpi/processor_driver.c
32240 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
32241 return 0;
32242 #endif
32243
32244 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
32245 + BUG_ON(pr->id >= nr_cpu_ids);
32246
32247 /*
32248 * Buggy BIOS check
32249 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32250 index ed9a1cc..f4a354c 100644
32251 --- a/drivers/acpi/processor_idle.c
32252 +++ b/drivers/acpi/processor_idle.c
32253 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32254 {
32255 int i, count = CPUIDLE_DRIVER_STATE_START;
32256 struct acpi_processor_cx *cx;
32257 - struct cpuidle_state *state;
32258 + cpuidle_state_no_const *state;
32259 struct cpuidle_driver *drv = &acpi_idle_driver;
32260
32261 if (!pr->flags.power_setup_done)
32262 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32263 index ea61ca9..3fdd70d 100644
32264 --- a/drivers/acpi/sysfs.c
32265 +++ b/drivers/acpi/sysfs.c
32266 @@ -420,11 +420,11 @@ static u32 num_counters;
32267 static struct attribute **all_attrs;
32268 static u32 acpi_gpe_count;
32269
32270 -static struct attribute_group interrupt_stats_attr_group = {
32271 +static attribute_group_no_const interrupt_stats_attr_group = {
32272 .name = "interrupts",
32273 };
32274
32275 -static struct kobj_attribute *counter_attrs;
32276 +static kobj_attribute_no_const *counter_attrs;
32277
32278 static void delete_gpe_attr_array(void)
32279 {
32280 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32281 index 6cd7805..07facb3 100644
32282 --- a/drivers/ata/libahci.c
32283 +++ b/drivers/ata/libahci.c
32284 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32285 }
32286 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32287
32288 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32289 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32290 struct ata_taskfile *tf, int is_cmd, u16 flags,
32291 unsigned long timeout_msec)
32292 {
32293 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32294 index 501c209..5f28b4d 100644
32295 --- a/drivers/ata/libata-core.c
32296 +++ b/drivers/ata/libata-core.c
32297 @@ -4784,7 +4784,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32298 struct ata_port *ap;
32299 unsigned int tag;
32300
32301 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32302 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32303 ap = qc->ap;
32304
32305 qc->flags = 0;
32306 @@ -4800,7 +4800,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32307 struct ata_port *ap;
32308 struct ata_link *link;
32309
32310 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32311 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32312 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32313 ap = qc->ap;
32314 link = qc->dev->link;
32315 @@ -5896,6 +5896,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32316 return;
32317
32318 spin_lock(&lock);
32319 + pax_open_kernel();
32320
32321 for (cur = ops->inherits; cur; cur = cur->inherits) {
32322 void **inherit = (void **)cur;
32323 @@ -5909,8 +5910,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32324 if (IS_ERR(*pp))
32325 *pp = NULL;
32326
32327 - ops->inherits = NULL;
32328 + *(struct ata_port_operations **)&ops->inherits = NULL;
32329
32330 + pax_close_kernel();
32331 spin_unlock(&lock);
32332 }
32333
32334 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32335 index 405022d..fb70e53 100644
32336 --- a/drivers/ata/pata_arasan_cf.c
32337 +++ b/drivers/ata/pata_arasan_cf.c
32338 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32339 /* Handle platform specific quirks */
32340 if (pdata->quirk) {
32341 if (pdata->quirk & CF_BROKEN_PIO) {
32342 - ap->ops->set_piomode = NULL;
32343 + pax_open_kernel();
32344 + *(void **)&ap->ops->set_piomode = NULL;
32345 + pax_close_kernel();
32346 ap->pio_mask = 0;
32347 }
32348 if (pdata->quirk & CF_BROKEN_MWDMA)
32349 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32350 index f9b983a..887b9d8 100644
32351 --- a/drivers/atm/adummy.c
32352 +++ b/drivers/atm/adummy.c
32353 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32354 vcc->pop(vcc, skb);
32355 else
32356 dev_kfree_skb_any(skb);
32357 - atomic_inc(&vcc->stats->tx);
32358 + atomic_inc_unchecked(&vcc->stats->tx);
32359
32360 return 0;
32361 }
32362 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32363 index 77a7480..05cde58 100644
32364 --- a/drivers/atm/ambassador.c
32365 +++ b/drivers/atm/ambassador.c
32366 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32367 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32368
32369 // VC layer stats
32370 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32371 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32372
32373 // free the descriptor
32374 kfree (tx_descr);
32375 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32376 dump_skb ("<<<", vc, skb);
32377
32378 // VC layer stats
32379 - atomic_inc(&atm_vcc->stats->rx);
32380 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32381 __net_timestamp(skb);
32382 // end of our responsibility
32383 atm_vcc->push (atm_vcc, skb);
32384 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32385 } else {
32386 PRINTK (KERN_INFO, "dropped over-size frame");
32387 // should we count this?
32388 - atomic_inc(&atm_vcc->stats->rx_drop);
32389 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32390 }
32391
32392 } else {
32393 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32394 }
32395
32396 if (check_area (skb->data, skb->len)) {
32397 - atomic_inc(&atm_vcc->stats->tx_err);
32398 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32399 return -ENOMEM; // ?
32400 }
32401
32402 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32403 index b22d71c..d6e1049 100644
32404 --- a/drivers/atm/atmtcp.c
32405 +++ b/drivers/atm/atmtcp.c
32406 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32407 if (vcc->pop) vcc->pop(vcc,skb);
32408 else dev_kfree_skb(skb);
32409 if (dev_data) return 0;
32410 - atomic_inc(&vcc->stats->tx_err);
32411 + atomic_inc_unchecked(&vcc->stats->tx_err);
32412 return -ENOLINK;
32413 }
32414 size = skb->len+sizeof(struct atmtcp_hdr);
32415 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32416 if (!new_skb) {
32417 if (vcc->pop) vcc->pop(vcc,skb);
32418 else dev_kfree_skb(skb);
32419 - atomic_inc(&vcc->stats->tx_err);
32420 + atomic_inc_unchecked(&vcc->stats->tx_err);
32421 return -ENOBUFS;
32422 }
32423 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32424 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32425 if (vcc->pop) vcc->pop(vcc,skb);
32426 else dev_kfree_skb(skb);
32427 out_vcc->push(out_vcc,new_skb);
32428 - atomic_inc(&vcc->stats->tx);
32429 - atomic_inc(&out_vcc->stats->rx);
32430 + atomic_inc_unchecked(&vcc->stats->tx);
32431 + atomic_inc_unchecked(&out_vcc->stats->rx);
32432 return 0;
32433 }
32434
32435 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32436 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32437 read_unlock(&vcc_sklist_lock);
32438 if (!out_vcc) {
32439 - atomic_inc(&vcc->stats->tx_err);
32440 + atomic_inc_unchecked(&vcc->stats->tx_err);
32441 goto done;
32442 }
32443 skb_pull(skb,sizeof(struct atmtcp_hdr));
32444 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32445 __net_timestamp(new_skb);
32446 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32447 out_vcc->push(out_vcc,new_skb);
32448 - atomic_inc(&vcc->stats->tx);
32449 - atomic_inc(&out_vcc->stats->rx);
32450 + atomic_inc_unchecked(&vcc->stats->tx);
32451 + atomic_inc_unchecked(&out_vcc->stats->rx);
32452 done:
32453 if (vcc->pop) vcc->pop(vcc,skb);
32454 else dev_kfree_skb(skb);
32455 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32456 index c1eb6fa..4c71be9 100644
32457 --- a/drivers/atm/eni.c
32458 +++ b/drivers/atm/eni.c
32459 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32460 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32461 vcc->dev->number);
32462 length = 0;
32463 - atomic_inc(&vcc->stats->rx_err);
32464 + atomic_inc_unchecked(&vcc->stats->rx_err);
32465 }
32466 else {
32467 length = ATM_CELL_SIZE-1; /* no HEC */
32468 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32469 size);
32470 }
32471 eff = length = 0;
32472 - atomic_inc(&vcc->stats->rx_err);
32473 + atomic_inc_unchecked(&vcc->stats->rx_err);
32474 }
32475 else {
32476 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32477 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32478 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32479 vcc->dev->number,vcc->vci,length,size << 2,descr);
32480 length = eff = 0;
32481 - atomic_inc(&vcc->stats->rx_err);
32482 + atomic_inc_unchecked(&vcc->stats->rx_err);
32483 }
32484 }
32485 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32486 @@ -767,7 +767,7 @@ rx_dequeued++;
32487 vcc->push(vcc,skb);
32488 pushed++;
32489 }
32490 - atomic_inc(&vcc->stats->rx);
32491 + atomic_inc_unchecked(&vcc->stats->rx);
32492 }
32493 wake_up(&eni_dev->rx_wait);
32494 }
32495 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32496 PCI_DMA_TODEVICE);
32497 if (vcc->pop) vcc->pop(vcc,skb);
32498 else dev_kfree_skb_irq(skb);
32499 - atomic_inc(&vcc->stats->tx);
32500 + atomic_inc_unchecked(&vcc->stats->tx);
32501 wake_up(&eni_dev->tx_wait);
32502 dma_complete++;
32503 }
32504 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32505 index b41c948..a002b17 100644
32506 --- a/drivers/atm/firestream.c
32507 +++ b/drivers/atm/firestream.c
32508 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32509 }
32510 }
32511
32512 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32513 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32514
32515 fs_dprintk (FS_DEBUG_TXMEM, "i");
32516 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32517 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32518 #endif
32519 skb_put (skb, qe->p1 & 0xffff);
32520 ATM_SKB(skb)->vcc = atm_vcc;
32521 - atomic_inc(&atm_vcc->stats->rx);
32522 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32523 __net_timestamp(skb);
32524 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32525 atm_vcc->push (atm_vcc, skb);
32526 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32527 kfree (pe);
32528 }
32529 if (atm_vcc)
32530 - atomic_inc(&atm_vcc->stats->rx_drop);
32531 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32532 break;
32533 case 0x1f: /* Reassembly abort: no buffers. */
32534 /* Silently increment error counter. */
32535 if (atm_vcc)
32536 - atomic_inc(&atm_vcc->stats->rx_drop);
32537 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32538 break;
32539 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32540 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32541 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32542 index 204814e..cede831 100644
32543 --- a/drivers/atm/fore200e.c
32544 +++ b/drivers/atm/fore200e.c
32545 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32546 #endif
32547 /* check error condition */
32548 if (*entry->status & STATUS_ERROR)
32549 - atomic_inc(&vcc->stats->tx_err);
32550 + atomic_inc_unchecked(&vcc->stats->tx_err);
32551 else
32552 - atomic_inc(&vcc->stats->tx);
32553 + atomic_inc_unchecked(&vcc->stats->tx);
32554 }
32555 }
32556
32557 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32558 if (skb == NULL) {
32559 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32560
32561 - atomic_inc(&vcc->stats->rx_drop);
32562 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32563 return -ENOMEM;
32564 }
32565
32566 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32567
32568 dev_kfree_skb_any(skb);
32569
32570 - atomic_inc(&vcc->stats->rx_drop);
32571 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32572 return -ENOMEM;
32573 }
32574
32575 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32576
32577 vcc->push(vcc, skb);
32578 - atomic_inc(&vcc->stats->rx);
32579 + atomic_inc_unchecked(&vcc->stats->rx);
32580
32581 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32582
32583 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32584 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32585 fore200e->atm_dev->number,
32586 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32587 - atomic_inc(&vcc->stats->rx_err);
32588 + atomic_inc_unchecked(&vcc->stats->rx_err);
32589 }
32590 }
32591
32592 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32593 goto retry_here;
32594 }
32595
32596 - atomic_inc(&vcc->stats->tx_err);
32597 + atomic_inc_unchecked(&vcc->stats->tx_err);
32598
32599 fore200e->tx_sat++;
32600 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32601 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32602 index 72b6960..cf9167a 100644
32603 --- a/drivers/atm/he.c
32604 +++ b/drivers/atm/he.c
32605 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32606
32607 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32608 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32609 - atomic_inc(&vcc->stats->rx_drop);
32610 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32611 goto return_host_buffers;
32612 }
32613
32614 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32615 RBRQ_LEN_ERR(he_dev->rbrq_head)
32616 ? "LEN_ERR" : "",
32617 vcc->vpi, vcc->vci);
32618 - atomic_inc(&vcc->stats->rx_err);
32619 + atomic_inc_unchecked(&vcc->stats->rx_err);
32620 goto return_host_buffers;
32621 }
32622
32623 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32624 vcc->push(vcc, skb);
32625 spin_lock(&he_dev->global_lock);
32626
32627 - atomic_inc(&vcc->stats->rx);
32628 + atomic_inc_unchecked(&vcc->stats->rx);
32629
32630 return_host_buffers:
32631 ++pdus_assembled;
32632 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32633 tpd->vcc->pop(tpd->vcc, tpd->skb);
32634 else
32635 dev_kfree_skb_any(tpd->skb);
32636 - atomic_inc(&tpd->vcc->stats->tx_err);
32637 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32638 }
32639 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32640 return;
32641 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32642 vcc->pop(vcc, skb);
32643 else
32644 dev_kfree_skb_any(skb);
32645 - atomic_inc(&vcc->stats->tx_err);
32646 + atomic_inc_unchecked(&vcc->stats->tx_err);
32647 return -EINVAL;
32648 }
32649
32650 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32651 vcc->pop(vcc, skb);
32652 else
32653 dev_kfree_skb_any(skb);
32654 - atomic_inc(&vcc->stats->tx_err);
32655 + atomic_inc_unchecked(&vcc->stats->tx_err);
32656 return -EINVAL;
32657 }
32658 #endif
32659 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32660 vcc->pop(vcc, skb);
32661 else
32662 dev_kfree_skb_any(skb);
32663 - atomic_inc(&vcc->stats->tx_err);
32664 + atomic_inc_unchecked(&vcc->stats->tx_err);
32665 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32666 return -ENOMEM;
32667 }
32668 @@ -2581,7 +2581,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 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32675 return -ENOMEM;
32676 }
32677 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32678 __enqueue_tpd(he_dev, tpd, cid);
32679 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32680
32681 - atomic_inc(&vcc->stats->tx);
32682 + atomic_inc_unchecked(&vcc->stats->tx);
32683
32684 return 0;
32685 }
32686 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32687 index 1dc0519..1aadaf7 100644
32688 --- a/drivers/atm/horizon.c
32689 +++ b/drivers/atm/horizon.c
32690 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32691 {
32692 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32693 // VC layer stats
32694 - atomic_inc(&vcc->stats->rx);
32695 + atomic_inc_unchecked(&vcc->stats->rx);
32696 __net_timestamp(skb);
32697 // end of our responsibility
32698 vcc->push (vcc, skb);
32699 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32700 dev->tx_iovec = NULL;
32701
32702 // VC layer stats
32703 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32704 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32705
32706 // free the skb
32707 hrz_kfree_skb (skb);
32708 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32709 index 272f009..a18ba55 100644
32710 --- a/drivers/atm/idt77252.c
32711 +++ b/drivers/atm/idt77252.c
32712 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32713 else
32714 dev_kfree_skb(skb);
32715
32716 - atomic_inc(&vcc->stats->tx);
32717 + atomic_inc_unchecked(&vcc->stats->tx);
32718 }
32719
32720 atomic_dec(&scq->used);
32721 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32722 if ((sb = dev_alloc_skb(64)) == NULL) {
32723 printk("%s: Can't allocate buffers for aal0.\n",
32724 card->name);
32725 - atomic_add(i, &vcc->stats->rx_drop);
32726 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32727 break;
32728 }
32729 if (!atm_charge(vcc, sb->truesize)) {
32730 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32731 card->name);
32732 - atomic_add(i - 1, &vcc->stats->rx_drop);
32733 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32734 dev_kfree_skb(sb);
32735 break;
32736 }
32737 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32738 ATM_SKB(sb)->vcc = vcc;
32739 __net_timestamp(sb);
32740 vcc->push(vcc, sb);
32741 - atomic_inc(&vcc->stats->rx);
32742 + atomic_inc_unchecked(&vcc->stats->rx);
32743
32744 cell += ATM_CELL_PAYLOAD;
32745 }
32746 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32747 "(CDC: %08x)\n",
32748 card->name, len, rpp->len, readl(SAR_REG_CDC));
32749 recycle_rx_pool_skb(card, rpp);
32750 - atomic_inc(&vcc->stats->rx_err);
32751 + atomic_inc_unchecked(&vcc->stats->rx_err);
32752 return;
32753 }
32754 if (stat & SAR_RSQE_CRC) {
32755 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32756 recycle_rx_pool_skb(card, rpp);
32757 - atomic_inc(&vcc->stats->rx_err);
32758 + atomic_inc_unchecked(&vcc->stats->rx_err);
32759 return;
32760 }
32761 if (skb_queue_len(&rpp->queue) > 1) {
32762 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32763 RXPRINTK("%s: Can't alloc RX skb.\n",
32764 card->name);
32765 recycle_rx_pool_skb(card, rpp);
32766 - atomic_inc(&vcc->stats->rx_err);
32767 + atomic_inc_unchecked(&vcc->stats->rx_err);
32768 return;
32769 }
32770 if (!atm_charge(vcc, skb->truesize)) {
32771 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32772 __net_timestamp(skb);
32773
32774 vcc->push(vcc, skb);
32775 - atomic_inc(&vcc->stats->rx);
32776 + atomic_inc_unchecked(&vcc->stats->rx);
32777
32778 return;
32779 }
32780 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32781 __net_timestamp(skb);
32782
32783 vcc->push(vcc, skb);
32784 - atomic_inc(&vcc->stats->rx);
32785 + atomic_inc_unchecked(&vcc->stats->rx);
32786
32787 if (skb->truesize > SAR_FB_SIZE_3)
32788 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32789 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32790 if (vcc->qos.aal != ATM_AAL0) {
32791 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32792 card->name, vpi, vci);
32793 - atomic_inc(&vcc->stats->rx_drop);
32794 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32795 goto drop;
32796 }
32797
32798 if ((sb = dev_alloc_skb(64)) == NULL) {
32799 printk("%s: Can't allocate buffers for AAL0.\n",
32800 card->name);
32801 - atomic_inc(&vcc->stats->rx_err);
32802 + atomic_inc_unchecked(&vcc->stats->rx_err);
32803 goto drop;
32804 }
32805
32806 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32807 ATM_SKB(sb)->vcc = vcc;
32808 __net_timestamp(sb);
32809 vcc->push(vcc, sb);
32810 - atomic_inc(&vcc->stats->rx);
32811 + atomic_inc_unchecked(&vcc->stats->rx);
32812
32813 drop:
32814 skb_pull(queue, 64);
32815 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32816
32817 if (vc == NULL) {
32818 printk("%s: NULL connection in send().\n", card->name);
32819 - atomic_inc(&vcc->stats->tx_err);
32820 + atomic_inc_unchecked(&vcc->stats->tx_err);
32821 dev_kfree_skb(skb);
32822 return -EINVAL;
32823 }
32824 if (!test_bit(VCF_TX, &vc->flags)) {
32825 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32826 - atomic_inc(&vcc->stats->tx_err);
32827 + atomic_inc_unchecked(&vcc->stats->tx_err);
32828 dev_kfree_skb(skb);
32829 return -EINVAL;
32830 }
32831 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32832 break;
32833 default:
32834 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32835 - atomic_inc(&vcc->stats->tx_err);
32836 + atomic_inc_unchecked(&vcc->stats->tx_err);
32837 dev_kfree_skb(skb);
32838 return -EINVAL;
32839 }
32840
32841 if (skb_shinfo(skb)->nr_frags != 0) {
32842 printk("%s: No scatter-gather yet.\n", card->name);
32843 - atomic_inc(&vcc->stats->tx_err);
32844 + atomic_inc_unchecked(&vcc->stats->tx_err);
32845 dev_kfree_skb(skb);
32846 return -EINVAL;
32847 }
32848 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32849
32850 err = queue_skb(card, vc, skb, oam);
32851 if (err) {
32852 - atomic_inc(&vcc->stats->tx_err);
32853 + atomic_inc_unchecked(&vcc->stats->tx_err);
32854 dev_kfree_skb(skb);
32855 return err;
32856 }
32857 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32858 skb = dev_alloc_skb(64);
32859 if (!skb) {
32860 printk("%s: Out of memory in send_oam().\n", card->name);
32861 - atomic_inc(&vcc->stats->tx_err);
32862 + atomic_inc_unchecked(&vcc->stats->tx_err);
32863 return -ENOMEM;
32864 }
32865 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32866 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32867 index 4217f29..88f547a 100644
32868 --- a/drivers/atm/iphase.c
32869 +++ b/drivers/atm/iphase.c
32870 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32871 status = (u_short) (buf_desc_ptr->desc_mode);
32872 if (status & (RX_CER | RX_PTE | RX_OFL))
32873 {
32874 - atomic_inc(&vcc->stats->rx_err);
32875 + atomic_inc_unchecked(&vcc->stats->rx_err);
32876 IF_ERR(printk("IA: bad packet, dropping it");)
32877 if (status & RX_CER) {
32878 IF_ERR(printk(" cause: packet CRC error\n");)
32879 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32880 len = dma_addr - buf_addr;
32881 if (len > iadev->rx_buf_sz) {
32882 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32883 - atomic_inc(&vcc->stats->rx_err);
32884 + atomic_inc_unchecked(&vcc->stats->rx_err);
32885 goto out_free_desc;
32886 }
32887
32888 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32889 ia_vcc = INPH_IA_VCC(vcc);
32890 if (ia_vcc == NULL)
32891 {
32892 - atomic_inc(&vcc->stats->rx_err);
32893 + atomic_inc_unchecked(&vcc->stats->rx_err);
32894 atm_return(vcc, skb->truesize);
32895 dev_kfree_skb_any(skb);
32896 goto INCR_DLE;
32897 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32898 if ((length > iadev->rx_buf_sz) || (length >
32899 (skb->len - sizeof(struct cpcs_trailer))))
32900 {
32901 - atomic_inc(&vcc->stats->rx_err);
32902 + atomic_inc_unchecked(&vcc->stats->rx_err);
32903 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32904 length, skb->len);)
32905 atm_return(vcc, skb->truesize);
32906 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32907
32908 IF_RX(printk("rx_dle_intr: skb push");)
32909 vcc->push(vcc,skb);
32910 - atomic_inc(&vcc->stats->rx);
32911 + atomic_inc_unchecked(&vcc->stats->rx);
32912 iadev->rx_pkt_cnt++;
32913 }
32914 INCR_DLE:
32915 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32916 {
32917 struct k_sonet_stats *stats;
32918 stats = &PRIV(_ia_dev[board])->sonet_stats;
32919 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32920 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32921 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32922 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32923 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32924 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32925 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32926 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32927 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32928 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32929 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32930 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32931 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32932 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32933 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32934 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32935 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32936 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32937 }
32938 ia_cmds.status = 0;
32939 break;
32940 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32941 if ((desc == 0) || (desc > iadev->num_tx_desc))
32942 {
32943 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32944 - atomic_inc(&vcc->stats->tx);
32945 + atomic_inc_unchecked(&vcc->stats->tx);
32946 if (vcc->pop)
32947 vcc->pop(vcc, skb);
32948 else
32949 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32950 ATM_DESC(skb) = vcc->vci;
32951 skb_queue_tail(&iadev->tx_dma_q, skb);
32952
32953 - atomic_inc(&vcc->stats->tx);
32954 + atomic_inc_unchecked(&vcc->stats->tx);
32955 iadev->tx_pkt_cnt++;
32956 /* Increment transaction counter */
32957 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32958
32959 #if 0
32960 /* add flow control logic */
32961 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32962 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32963 if (iavcc->vc_desc_cnt > 10) {
32964 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32965 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32966 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32967 index fa7d701..1e404c7 100644
32968 --- a/drivers/atm/lanai.c
32969 +++ b/drivers/atm/lanai.c
32970 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32971 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32972 lanai_endtx(lanai, lvcc);
32973 lanai_free_skb(lvcc->tx.atmvcc, skb);
32974 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32975 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32976 }
32977
32978 /* Try to fill the buffer - don't call unless there is backlog */
32979 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32980 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32981 __net_timestamp(skb);
32982 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32983 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32984 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32985 out:
32986 lvcc->rx.buf.ptr = end;
32987 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32988 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32989 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32990 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32991 lanai->stats.service_rxnotaal5++;
32992 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32993 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32994 return 0;
32995 }
32996 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32997 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32998 int bytes;
32999 read_unlock(&vcc_sklist_lock);
33000 DPRINTK("got trashed rx pdu on vci %d\n", vci);
33001 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33002 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33003 lvcc->stats.x.aal5.service_trash++;
33004 bytes = (SERVICE_GET_END(s) * 16) -
33005 (((unsigned long) lvcc->rx.buf.ptr) -
33006 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33007 }
33008 if (s & SERVICE_STREAM) {
33009 read_unlock(&vcc_sklist_lock);
33010 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33011 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33012 lvcc->stats.x.aal5.service_stream++;
33013 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
33014 "PDU on VCI %d!\n", lanai->number, vci);
33015 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33016 return 0;
33017 }
33018 DPRINTK("got rx crc error on vci %d\n", vci);
33019 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33020 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33021 lvcc->stats.x.aal5.service_rxcrc++;
33022 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
33023 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
33024 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
33025 index ed1d2b7..8cffc1f 100644
33026 --- a/drivers/atm/nicstar.c
33027 +++ b/drivers/atm/nicstar.c
33028 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33029 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
33030 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
33031 card->index);
33032 - atomic_inc(&vcc->stats->tx_err);
33033 + atomic_inc_unchecked(&vcc->stats->tx_err);
33034 dev_kfree_skb_any(skb);
33035 return -EINVAL;
33036 }
33037 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33038 if (!vc->tx) {
33039 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
33040 card->index);
33041 - atomic_inc(&vcc->stats->tx_err);
33042 + atomic_inc_unchecked(&vcc->stats->tx_err);
33043 dev_kfree_skb_any(skb);
33044 return -EINVAL;
33045 }
33046 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33047 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
33048 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
33049 card->index);
33050 - atomic_inc(&vcc->stats->tx_err);
33051 + atomic_inc_unchecked(&vcc->stats->tx_err);
33052 dev_kfree_skb_any(skb);
33053 return -EINVAL;
33054 }
33055
33056 if (skb_shinfo(skb)->nr_frags != 0) {
33057 printk("nicstar%d: No scatter-gather yet.\n", card->index);
33058 - atomic_inc(&vcc->stats->tx_err);
33059 + atomic_inc_unchecked(&vcc->stats->tx_err);
33060 dev_kfree_skb_any(skb);
33061 return -EINVAL;
33062 }
33063 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33064 }
33065
33066 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
33067 - atomic_inc(&vcc->stats->tx_err);
33068 + atomic_inc_unchecked(&vcc->stats->tx_err);
33069 dev_kfree_skb_any(skb);
33070 return -EIO;
33071 }
33072 - atomic_inc(&vcc->stats->tx);
33073 + atomic_inc_unchecked(&vcc->stats->tx);
33074
33075 return 0;
33076 }
33077 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33078 printk
33079 ("nicstar%d: Can't allocate buffers for aal0.\n",
33080 card->index);
33081 - atomic_add(i, &vcc->stats->rx_drop);
33082 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
33083 break;
33084 }
33085 if (!atm_charge(vcc, sb->truesize)) {
33086 RXPRINTK
33087 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
33088 card->index);
33089 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33090 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33091 dev_kfree_skb_any(sb);
33092 break;
33093 }
33094 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33095 ATM_SKB(sb)->vcc = vcc;
33096 __net_timestamp(sb);
33097 vcc->push(vcc, sb);
33098 - atomic_inc(&vcc->stats->rx);
33099 + atomic_inc_unchecked(&vcc->stats->rx);
33100 cell += ATM_CELL_PAYLOAD;
33101 }
33102
33103 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33104 if (iovb == NULL) {
33105 printk("nicstar%d: Out of iovec buffers.\n",
33106 card->index);
33107 - atomic_inc(&vcc->stats->rx_drop);
33108 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33109 recycle_rx_buf(card, skb);
33110 return;
33111 }
33112 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33113 small or large buffer itself. */
33114 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
33115 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
33116 - atomic_inc(&vcc->stats->rx_err);
33117 + atomic_inc_unchecked(&vcc->stats->rx_err);
33118 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33119 NS_MAX_IOVECS);
33120 NS_PRV_IOVCNT(iovb) = 0;
33121 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33122 ("nicstar%d: Expected a small buffer, and this is not one.\n",
33123 card->index);
33124 which_list(card, skb);
33125 - atomic_inc(&vcc->stats->rx_err);
33126 + atomic_inc_unchecked(&vcc->stats->rx_err);
33127 recycle_rx_buf(card, skb);
33128 vc->rx_iov = NULL;
33129 recycle_iov_buf(card, iovb);
33130 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33131 ("nicstar%d: Expected a large buffer, and this is not one.\n",
33132 card->index);
33133 which_list(card, skb);
33134 - atomic_inc(&vcc->stats->rx_err);
33135 + atomic_inc_unchecked(&vcc->stats->rx_err);
33136 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33137 NS_PRV_IOVCNT(iovb));
33138 vc->rx_iov = NULL;
33139 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33140 printk(" - PDU size mismatch.\n");
33141 else
33142 printk(".\n");
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_PRV_IOVCNT(iovb));
33147 vc->rx_iov = NULL;
33148 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33149 /* skb points to a small buffer */
33150 if (!atm_charge(vcc, skb->truesize)) {
33151 push_rxbufs(card, skb);
33152 - atomic_inc(&vcc->stats->rx_drop);
33153 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33154 } else {
33155 skb_put(skb, len);
33156 dequeue_sm_buf(card, skb);
33157 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33158 ATM_SKB(skb)->vcc = vcc;
33159 __net_timestamp(skb);
33160 vcc->push(vcc, skb);
33161 - atomic_inc(&vcc->stats->rx);
33162 + atomic_inc_unchecked(&vcc->stats->rx);
33163 }
33164 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
33165 struct sk_buff *sb;
33166 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33167 if (len <= NS_SMBUFSIZE) {
33168 if (!atm_charge(vcc, sb->truesize)) {
33169 push_rxbufs(card, sb);
33170 - atomic_inc(&vcc->stats->rx_drop);
33171 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33172 } else {
33173 skb_put(sb, len);
33174 dequeue_sm_buf(card, sb);
33175 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33176 ATM_SKB(sb)->vcc = vcc;
33177 __net_timestamp(sb);
33178 vcc->push(vcc, sb);
33179 - atomic_inc(&vcc->stats->rx);
33180 + atomic_inc_unchecked(&vcc->stats->rx);
33181 }
33182
33183 push_rxbufs(card, skb);
33184 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33185
33186 if (!atm_charge(vcc, skb->truesize)) {
33187 push_rxbufs(card, skb);
33188 - atomic_inc(&vcc->stats->rx_drop);
33189 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33190 } else {
33191 dequeue_lg_buf(card, skb);
33192 #ifdef NS_USE_DESTRUCTORS
33193 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33194 ATM_SKB(skb)->vcc = vcc;
33195 __net_timestamp(skb);
33196 vcc->push(vcc, skb);
33197 - atomic_inc(&vcc->stats->rx);
33198 + atomic_inc_unchecked(&vcc->stats->rx);
33199 }
33200
33201 push_rxbufs(card, sb);
33202 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33203 printk
33204 ("nicstar%d: Out of huge buffers.\n",
33205 card->index);
33206 - atomic_inc(&vcc->stats->rx_drop);
33207 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33208 recycle_iovec_rx_bufs(card,
33209 (struct iovec *)
33210 iovb->data,
33211 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33212 card->hbpool.count++;
33213 } else
33214 dev_kfree_skb_any(hb);
33215 - atomic_inc(&vcc->stats->rx_drop);
33216 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33217 } else {
33218 /* Copy the small buffer to the huge buffer */
33219 sb = (struct sk_buff *)iov->iov_base;
33220 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33221 #endif /* NS_USE_DESTRUCTORS */
33222 __net_timestamp(hb);
33223 vcc->push(vcc, hb);
33224 - atomic_inc(&vcc->stats->rx);
33225 + atomic_inc_unchecked(&vcc->stats->rx);
33226 }
33227 }
33228
33229 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
33230 index 0474a89..06ea4a1 100644
33231 --- a/drivers/atm/solos-pci.c
33232 +++ b/drivers/atm/solos-pci.c
33233 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33234 }
33235 atm_charge(vcc, skb->truesize);
33236 vcc->push(vcc, skb);
33237 - atomic_inc(&vcc->stats->rx);
33238 + atomic_inc_unchecked(&vcc->stats->rx);
33239 break;
33240
33241 case PKT_STATUS:
33242 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33243 vcc = SKB_CB(oldskb)->vcc;
33244
33245 if (vcc) {
33246 - atomic_inc(&vcc->stats->tx);
33247 + atomic_inc_unchecked(&vcc->stats->tx);
33248 solos_pop(vcc, oldskb);
33249 } else {
33250 dev_kfree_skb_irq(oldskb);
33251 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33252 index 0215934..ce9f5b1 100644
33253 --- a/drivers/atm/suni.c
33254 +++ b/drivers/atm/suni.c
33255 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33256
33257
33258 #define ADD_LIMITED(s,v) \
33259 - atomic_add((v),&stats->s); \
33260 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33261 + atomic_add_unchecked((v),&stats->s); \
33262 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33263
33264
33265 static void suni_hz(unsigned long from_timer)
33266 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33267 index 5120a96..e2572bd 100644
33268 --- a/drivers/atm/uPD98402.c
33269 +++ b/drivers/atm/uPD98402.c
33270 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33271 struct sonet_stats tmp;
33272 int error = 0;
33273
33274 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33275 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33276 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33277 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33278 if (zero && !error) {
33279 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33280
33281
33282 #define ADD_LIMITED(s,v) \
33283 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33284 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33285 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33286 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33287 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33288 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33289
33290
33291 static void stat_event(struct atm_dev *dev)
33292 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33293 if (reason & uPD98402_INT_PFM) stat_event(dev);
33294 if (reason & uPD98402_INT_PCO) {
33295 (void) GET(PCOCR); /* clear interrupt cause */
33296 - atomic_add(GET(HECCT),
33297 + atomic_add_unchecked(GET(HECCT),
33298 &PRIV(dev)->sonet_stats.uncorr_hcs);
33299 }
33300 if ((reason & uPD98402_INT_RFO) &&
33301 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33302 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33303 uPD98402_INT_LOS),PIMR); /* enable them */
33304 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33305 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33306 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33307 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33308 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33309 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33310 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33311 return 0;
33312 }
33313
33314 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33315 index 969c3c2..9b72956 100644
33316 --- a/drivers/atm/zatm.c
33317 +++ b/drivers/atm/zatm.c
33318 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33319 }
33320 if (!size) {
33321 dev_kfree_skb_irq(skb);
33322 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33323 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33324 continue;
33325 }
33326 if (!atm_charge(vcc,skb->truesize)) {
33327 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33328 skb->len = size;
33329 ATM_SKB(skb)->vcc = vcc;
33330 vcc->push(vcc,skb);
33331 - atomic_inc(&vcc->stats->rx);
33332 + atomic_inc_unchecked(&vcc->stats->rx);
33333 }
33334 zout(pos & 0xffff,MTA(mbx));
33335 #if 0 /* probably a stupid idea */
33336 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33337 skb_queue_head(&zatm_vcc->backlog,skb);
33338 break;
33339 }
33340 - atomic_inc(&vcc->stats->tx);
33341 + atomic_inc_unchecked(&vcc->stats->tx);
33342 wake_up(&zatm_vcc->tx_wait);
33343 }
33344
33345 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33346 index 6856303..0602d70 100644
33347 --- a/drivers/base/bus.c
33348 +++ b/drivers/base/bus.c
33349 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33350 return -EINVAL;
33351
33352 mutex_lock(&subsys->p->mutex);
33353 - list_add_tail(&sif->node, &subsys->p->interfaces);
33354 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33355 if (sif->add_dev) {
33356 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33357 while ((dev = subsys_dev_iter_next(&iter)))
33358 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33359 subsys = sif->subsys;
33360
33361 mutex_lock(&subsys->p->mutex);
33362 - list_del_init(&sif->node);
33363 + pax_list_del_init((struct list_head *)&sif->node);
33364 if (sif->remove_dev) {
33365 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33366 while ((dev = subsys_dev_iter_next(&iter)))
33367 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33368 index 17cf7ca..7e553e1 100644
33369 --- a/drivers/base/devtmpfs.c
33370 +++ b/drivers/base/devtmpfs.c
33371 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
33372 if (!thread)
33373 return 0;
33374
33375 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33376 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33377 if (err)
33378 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33379 else
33380 diff --git a/drivers/base/node.c b/drivers/base/node.c
33381 index fac124a..66bd4ab 100644
33382 --- a/drivers/base/node.c
33383 +++ b/drivers/base/node.c
33384 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33385 struct node_attr {
33386 struct device_attribute attr;
33387 enum node_states state;
33388 -};
33389 +} __do_const;
33390
33391 static ssize_t show_node_state(struct device *dev,
33392 struct device_attribute *attr, char *buf)
33393 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33394 index acc3a8d..981c236 100644
33395 --- a/drivers/base/power/domain.c
33396 +++ b/drivers/base/power/domain.c
33397 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33398 {
33399 struct cpuidle_driver *cpuidle_drv;
33400 struct gpd_cpu_data *cpu_data;
33401 - struct cpuidle_state *idle_state;
33402 + cpuidle_state_no_const *idle_state;
33403 int ret = 0;
33404
33405 if (IS_ERR_OR_NULL(genpd) || state < 0)
33406 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33407 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33408 {
33409 struct gpd_cpu_data *cpu_data;
33410 - struct cpuidle_state *idle_state;
33411 + cpuidle_state_no_const *idle_state;
33412 int ret = 0;
33413
33414 if (IS_ERR_OR_NULL(genpd))
33415 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33416 index e6ee5e8..98ad7fc 100644
33417 --- a/drivers/base/power/wakeup.c
33418 +++ b/drivers/base/power/wakeup.c
33419 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33420 * They need to be modified together atomically, so it's better to use one
33421 * atomic variable to hold them both.
33422 */
33423 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33424 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33425
33426 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33427 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33428
33429 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33430 {
33431 - unsigned int comb = atomic_read(&combined_event_count);
33432 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33433
33434 *cnt = (comb >> IN_PROGRESS_BITS);
33435 *inpr = comb & MAX_IN_PROGRESS;
33436 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33437 ws->start_prevent_time = ws->last_time;
33438
33439 /* Increment the counter of events in progress. */
33440 - cec = atomic_inc_return(&combined_event_count);
33441 + cec = atomic_inc_return_unchecked(&combined_event_count);
33442
33443 trace_wakeup_source_activate(ws->name, cec);
33444 }
33445 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33446 * Increment the counter of registered wakeup events and decrement the
33447 * couter of wakeup events in progress simultaneously.
33448 */
33449 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33450 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33451 trace_wakeup_source_deactivate(ws->name, cec);
33452
33453 split_counters(&cnt, &inpr);
33454 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33455 index e8d11b6..7b1b36f 100644
33456 --- a/drivers/base/syscore.c
33457 +++ b/drivers/base/syscore.c
33458 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33459 void register_syscore_ops(struct syscore_ops *ops)
33460 {
33461 mutex_lock(&syscore_ops_lock);
33462 - list_add_tail(&ops->node, &syscore_ops_list);
33463 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33464 mutex_unlock(&syscore_ops_lock);
33465 }
33466 EXPORT_SYMBOL_GPL(register_syscore_ops);
33467 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33468 void unregister_syscore_ops(struct syscore_ops *ops)
33469 {
33470 mutex_lock(&syscore_ops_lock);
33471 - list_del(&ops->node);
33472 + pax_list_del((struct list_head *)&ops->node);
33473 mutex_unlock(&syscore_ops_lock);
33474 }
33475 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33476 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33477 index ade58bc..867143d 100644
33478 --- a/drivers/block/cciss.c
33479 +++ b/drivers/block/cciss.c
33480 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33481 int err;
33482 u32 cp;
33483
33484 + memset(&arg64, 0, sizeof(arg64));
33485 +
33486 err = 0;
33487 err |=
33488 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33489 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33490 while (!list_empty(&h->reqQ)) {
33491 c = list_entry(h->reqQ.next, CommandList_struct, list);
33492 /* can't do anything if fifo is full */
33493 - if ((h->access.fifo_full(h))) {
33494 + if ((h->access->fifo_full(h))) {
33495 dev_warn(&h->pdev->dev, "fifo full\n");
33496 break;
33497 }
33498 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33499 h->Qdepth--;
33500
33501 /* Tell the controller execute command */
33502 - h->access.submit_command(h, c);
33503 + h->access->submit_command(h, c);
33504
33505 /* Put job onto the completed Q */
33506 addQ(&h->cmpQ, c);
33507 @@ -3441,17 +3443,17 @@ startio:
33508
33509 static inline unsigned long get_next_completion(ctlr_info_t *h)
33510 {
33511 - return h->access.command_completed(h);
33512 + return h->access->command_completed(h);
33513 }
33514
33515 static inline int interrupt_pending(ctlr_info_t *h)
33516 {
33517 - return h->access.intr_pending(h);
33518 + return h->access->intr_pending(h);
33519 }
33520
33521 static inline long interrupt_not_for_us(ctlr_info_t *h)
33522 {
33523 - return ((h->access.intr_pending(h) == 0) ||
33524 + return ((h->access->intr_pending(h) == 0) ||
33525 (h->interrupts_enabled == 0));
33526 }
33527
33528 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33529 u32 a;
33530
33531 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33532 - return h->access.command_completed(h);
33533 + return h->access->command_completed(h);
33534
33535 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33536 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33537 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33538 trans_support & CFGTBL_Trans_use_short_tags);
33539
33540 /* Change the access methods to the performant access methods */
33541 - h->access = SA5_performant_access;
33542 + h->access = &SA5_performant_access;
33543 h->transMethod = CFGTBL_Trans_Performant;
33544
33545 return;
33546 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33547 if (prod_index < 0)
33548 return -ENODEV;
33549 h->product_name = products[prod_index].product_name;
33550 - h->access = *(products[prod_index].access);
33551 + h->access = products[prod_index].access;
33552
33553 if (cciss_board_disabled(h)) {
33554 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33555 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33556 }
33557
33558 /* make sure the board interrupts are off */
33559 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33560 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33561 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33562 if (rc)
33563 goto clean2;
33564 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33565 * fake ones to scoop up any residual completions.
33566 */
33567 spin_lock_irqsave(&h->lock, flags);
33568 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33569 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33570 spin_unlock_irqrestore(&h->lock, flags);
33571 free_irq(h->intr[h->intr_mode], h);
33572 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33573 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33574 dev_info(&h->pdev->dev, "Board READY.\n");
33575 dev_info(&h->pdev->dev,
33576 "Waiting for stale completions to drain.\n");
33577 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33578 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33579 msleep(10000);
33580 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33581 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33582
33583 rc = controller_reset_failed(h->cfgtable);
33584 if (rc)
33585 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33586 cciss_scsi_setup(h);
33587
33588 /* Turn the interrupts on so we can service requests */
33589 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33590 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33591
33592 /* Get the firmware version */
33593 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33594 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33595 kfree(flush_buf);
33596 if (return_code != IO_OK)
33597 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33598 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33599 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33600 free_irq(h->intr[h->intr_mode], h);
33601 }
33602
33603 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33604 index 7fda30e..eb5dfe0 100644
33605 --- a/drivers/block/cciss.h
33606 +++ b/drivers/block/cciss.h
33607 @@ -101,7 +101,7 @@ struct ctlr_info
33608 /* information about each logical volume */
33609 drive_info_struct *drv[CISS_MAX_LUN];
33610
33611 - struct access_method access;
33612 + struct access_method *access;
33613
33614 /* queue and queue Info */
33615 struct list_head reqQ;
33616 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33617 index 3f08713..56a586a 100644
33618 --- a/drivers/block/cpqarray.c
33619 +++ b/drivers/block/cpqarray.c
33620 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33621 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33622 goto Enomem4;
33623 }
33624 - hba[i]->access.set_intr_mask(hba[i], 0);
33625 + hba[i]->access->set_intr_mask(hba[i], 0);
33626 if (request_irq(hba[i]->intr, do_ida_intr,
33627 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33628 {
33629 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33630 add_timer(&hba[i]->timer);
33631
33632 /* Enable IRQ now that spinlock and rate limit timer are set up */
33633 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33634 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33635
33636 for(j=0; j<NWD; j++) {
33637 struct gendisk *disk = ida_gendisk[i][j];
33638 @@ -694,7 +694,7 @@ DBGINFO(
33639 for(i=0; i<NR_PRODUCTS; i++) {
33640 if (board_id == products[i].board_id) {
33641 c->product_name = products[i].product_name;
33642 - c->access = *(products[i].access);
33643 + c->access = products[i].access;
33644 break;
33645 }
33646 }
33647 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33648 hba[ctlr]->intr = intr;
33649 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33650 hba[ctlr]->product_name = products[j].product_name;
33651 - hba[ctlr]->access = *(products[j].access);
33652 + hba[ctlr]->access = products[j].access;
33653 hba[ctlr]->ctlr = ctlr;
33654 hba[ctlr]->board_id = board_id;
33655 hba[ctlr]->pci_dev = NULL; /* not PCI */
33656 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33657
33658 while((c = h->reqQ) != NULL) {
33659 /* Can't do anything if we're busy */
33660 - if (h->access.fifo_full(h) == 0)
33661 + if (h->access->fifo_full(h) == 0)
33662 return;
33663
33664 /* Get the first entry from the request Q */
33665 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33666 h->Qdepth--;
33667
33668 /* Tell the controller to do our bidding */
33669 - h->access.submit_command(h, c);
33670 + h->access->submit_command(h, c);
33671
33672 /* Get onto the completion Q */
33673 addQ(&h->cmpQ, c);
33674 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33675 unsigned long flags;
33676 __u32 a,a1;
33677
33678 - istat = h->access.intr_pending(h);
33679 + istat = h->access->intr_pending(h);
33680 /* Is this interrupt for us? */
33681 if (istat == 0)
33682 return IRQ_NONE;
33683 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33684 */
33685 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33686 if (istat & FIFO_NOT_EMPTY) {
33687 - while((a = h->access.command_completed(h))) {
33688 + while((a = h->access->command_completed(h))) {
33689 a1 = a; a &= ~3;
33690 if ((c = h->cmpQ) == NULL)
33691 {
33692 @@ -1449,11 +1449,11 @@ static int sendcmd(
33693 /*
33694 * Disable interrupt
33695 */
33696 - info_p->access.set_intr_mask(info_p, 0);
33697 + info_p->access->set_intr_mask(info_p, 0);
33698 /* Make sure there is room in the command FIFO */
33699 /* Actually it should be completely empty at this time. */
33700 for (i = 200000; i > 0; i--) {
33701 - temp = info_p->access.fifo_full(info_p);
33702 + temp = info_p->access->fifo_full(info_p);
33703 if (temp != 0) {
33704 break;
33705 }
33706 @@ -1466,7 +1466,7 @@ DBG(
33707 /*
33708 * Send the cmd
33709 */
33710 - info_p->access.submit_command(info_p, c);
33711 + info_p->access->submit_command(info_p, c);
33712 complete = pollcomplete(ctlr);
33713
33714 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33715 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33716 * we check the new geometry. Then turn interrupts back on when
33717 * we're done.
33718 */
33719 - host->access.set_intr_mask(host, 0);
33720 + host->access->set_intr_mask(host, 0);
33721 getgeometry(ctlr);
33722 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33723 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33724
33725 for(i=0; i<NWD; i++) {
33726 struct gendisk *disk = ida_gendisk[ctlr][i];
33727 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33728 /* Wait (up to 2 seconds) for a command to complete */
33729
33730 for (i = 200000; i > 0; i--) {
33731 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33732 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33733 if (done == 0) {
33734 udelay(10); /* a short fixed delay */
33735 } else
33736 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33737 index be73e9d..7fbf140 100644
33738 --- a/drivers/block/cpqarray.h
33739 +++ b/drivers/block/cpqarray.h
33740 @@ -99,7 +99,7 @@ struct ctlr_info {
33741 drv_info_t drv[NWD];
33742 struct proc_dir_entry *proc;
33743
33744 - struct access_method access;
33745 + struct access_method *access;
33746
33747 cmdlist_t *reqQ;
33748 cmdlist_t *cmpQ;
33749 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33750 index 6b51afa..17e1191 100644
33751 --- a/drivers/block/drbd/drbd_int.h
33752 +++ b/drivers/block/drbd/drbd_int.h
33753 @@ -582,7 +582,7 @@ struct drbd_epoch {
33754 struct drbd_tconn *tconn;
33755 struct list_head list;
33756 unsigned int barrier_nr;
33757 - atomic_t epoch_size; /* increased on every request added. */
33758 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33759 atomic_t active; /* increased on every req. added, and dec on every finished. */
33760 unsigned long flags;
33761 };
33762 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33763 int al_tr_cycle;
33764 int al_tr_pos; /* position of the next transaction in the journal */
33765 wait_queue_head_t seq_wait;
33766 - atomic_t packet_seq;
33767 + atomic_unchecked_t packet_seq;
33768 unsigned int peer_seq;
33769 spinlock_t peer_seq_lock;
33770 unsigned int minor;
33771 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33772 char __user *uoptval;
33773 int err;
33774
33775 - uoptval = (char __user __force *)optval;
33776 + uoptval = (char __force_user *)optval;
33777
33778 set_fs(KERNEL_DS);
33779 if (level == SOL_SOCKET)
33780 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33781 index 8c13eeb..217adee 100644
33782 --- a/drivers/block/drbd/drbd_main.c
33783 +++ b/drivers/block/drbd/drbd_main.c
33784 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33785 p->sector = sector;
33786 p->block_id = block_id;
33787 p->blksize = blksize;
33788 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33789 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33790 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33791 }
33792
33793 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33794 return -EIO;
33795 p->sector = cpu_to_be64(req->i.sector);
33796 p->block_id = (unsigned long)req;
33797 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33798 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33799 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33800 if (mdev->state.conn >= C_SYNC_SOURCE &&
33801 mdev->state.conn <= C_PAUSED_SYNC_T)
33802 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33803 {
33804 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33805
33806 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33807 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33808 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33809 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33810 kfree(tconn->current_epoch);
33811
33812 idr_destroy(&tconn->volumes);
33813 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33814 index a9eccfc..f5efe87 100644
33815 --- a/drivers/block/drbd/drbd_receiver.c
33816 +++ b/drivers/block/drbd/drbd_receiver.c
33817 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33818 {
33819 int err;
33820
33821 - atomic_set(&mdev->packet_seq, 0);
33822 + atomic_set_unchecked(&mdev->packet_seq, 0);
33823 mdev->peer_seq = 0;
33824
33825 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33826 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33827 do {
33828 next_epoch = NULL;
33829
33830 - epoch_size = atomic_read(&epoch->epoch_size);
33831 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33832
33833 switch (ev & ~EV_CLEANUP) {
33834 case EV_PUT:
33835 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33836 rv = FE_DESTROYED;
33837 } else {
33838 epoch->flags = 0;
33839 - atomic_set(&epoch->epoch_size, 0);
33840 + atomic_set_unchecked(&epoch->epoch_size, 0);
33841 /* atomic_set(&epoch->active, 0); is already zero */
33842 if (rv == FE_STILL_LIVE)
33843 rv = FE_RECYCLED;
33844 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33845 conn_wait_active_ee_empty(tconn);
33846 drbd_flush(tconn);
33847
33848 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33849 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33850 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33851 if (epoch)
33852 break;
33853 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33854 }
33855
33856 epoch->flags = 0;
33857 - atomic_set(&epoch->epoch_size, 0);
33858 + atomic_set_unchecked(&epoch->epoch_size, 0);
33859 atomic_set(&epoch->active, 0);
33860
33861 spin_lock(&tconn->epoch_lock);
33862 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33863 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33864 list_add(&epoch->list, &tconn->current_epoch->list);
33865 tconn->current_epoch = epoch;
33866 tconn->epochs++;
33867 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33868
33869 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33870 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33871 - atomic_inc(&tconn->current_epoch->epoch_size);
33872 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33873 err2 = drbd_drain_block(mdev, pi->size);
33874 if (!err)
33875 err = err2;
33876 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33877
33878 spin_lock(&tconn->epoch_lock);
33879 peer_req->epoch = tconn->current_epoch;
33880 - atomic_inc(&peer_req->epoch->epoch_size);
33881 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33882 atomic_inc(&peer_req->epoch->active);
33883 spin_unlock(&tconn->epoch_lock);
33884
33885 @@ -4346,7 +4346,7 @@ struct data_cmd {
33886 int expect_payload;
33887 size_t pkt_size;
33888 int (*fn)(struct drbd_tconn *, struct packet_info *);
33889 -};
33890 +} __do_const;
33891
33892 static struct data_cmd drbd_cmd_handler[] = {
33893 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33894 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33895 if (!list_empty(&tconn->current_epoch->list))
33896 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33897 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33898 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33899 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33900 tconn->send.seen_any_write_yet = false;
33901
33902 conn_info(tconn, "Connection closed\n");
33903 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33904 struct asender_cmd {
33905 size_t pkt_size;
33906 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33907 -};
33908 +} __do_const;
33909
33910 static struct asender_cmd asender_tbl[] = {
33911 [P_PING] = { 0, got_Ping },
33912 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33913 index f74f2c0..bb668af 100644
33914 --- a/drivers/block/loop.c
33915 +++ b/drivers/block/loop.c
33916 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
33917 mm_segment_t old_fs = get_fs();
33918
33919 set_fs(get_ds());
33920 - bw = file->f_op->write(file, buf, len, &pos);
33921 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33922 set_fs(old_fs);
33923 if (likely(bw == len))
33924 return 0;
33925 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33926 index d620b44..587561e 100644
33927 --- a/drivers/cdrom/cdrom.c
33928 +++ b/drivers/cdrom/cdrom.c
33929 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33930 ENSURE(reset, CDC_RESET);
33931 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33932 cdi->mc_flags = 0;
33933 - cdo->n_minors = 0;
33934 cdi->options = CDO_USE_FFLAGS;
33935
33936 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33937 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33938 else
33939 cdi->cdda_method = CDDA_OLD;
33940
33941 - if (!cdo->generic_packet)
33942 - cdo->generic_packet = cdrom_dummy_generic_packet;
33943 + if (!cdo->generic_packet) {
33944 + pax_open_kernel();
33945 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33946 + pax_close_kernel();
33947 + }
33948
33949 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33950 mutex_lock(&cdrom_mutex);
33951 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33952 if (cdi->exit)
33953 cdi->exit(cdi);
33954
33955 - cdi->ops->n_minors--;
33956 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33957 }
33958
33959 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33960 index d59cdcb..11afddf 100644
33961 --- a/drivers/cdrom/gdrom.c
33962 +++ b/drivers/cdrom/gdrom.c
33963 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33964 .audio_ioctl = gdrom_audio_ioctl,
33965 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33966 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33967 - .n_minors = 1,
33968 };
33969
33970 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33971 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33972 index 72bedad..8181ce1 100644
33973 --- a/drivers/char/Kconfig
33974 +++ b/drivers/char/Kconfig
33975 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33976
33977 config DEVKMEM
33978 bool "/dev/kmem virtual device support"
33979 - default y
33980 + default n
33981 + depends on !GRKERNSEC_KMEM
33982 help
33983 Say Y here if you want to support the /dev/kmem device. The
33984 /dev/kmem device is rarely used, but can be used for certain
33985 @@ -581,6 +582,7 @@ config DEVPORT
33986 bool
33987 depends on !M68K
33988 depends on ISA || PCI
33989 + depends on !GRKERNSEC_KMEM
33990 default y
33991
33992 source "drivers/s390/char/Kconfig"
33993 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33994 index 2e04433..22afc64 100644
33995 --- a/drivers/char/agp/frontend.c
33996 +++ b/drivers/char/agp/frontend.c
33997 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33998 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33999 return -EFAULT;
34000
34001 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
34002 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
34003 return -EFAULT;
34004
34005 client = agp_find_client_by_pid(reserve.pid);
34006 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
34007 index 21cb980..f15107c 100644
34008 --- a/drivers/char/genrtc.c
34009 +++ b/drivers/char/genrtc.c
34010 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
34011 switch (cmd) {
34012
34013 case RTC_PLL_GET:
34014 + memset(&pll, 0, sizeof(pll));
34015 if (get_rtc_pll(&pll))
34016 return -EINVAL;
34017 else
34018 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
34019 index fe6d4be..89f32100 100644
34020 --- a/drivers/char/hpet.c
34021 +++ b/drivers/char/hpet.c
34022 @@ -571,7 +571,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
34023 }
34024
34025 static int
34026 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
34027 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
34028 struct hpet_info *info)
34029 {
34030 struct hpet_timer __iomem *timer;
34031 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
34032 index 053201b0..8335cce 100644
34033 --- a/drivers/char/ipmi/ipmi_msghandler.c
34034 +++ b/drivers/char/ipmi/ipmi_msghandler.c
34035 @@ -420,7 +420,7 @@ struct ipmi_smi {
34036 struct proc_dir_entry *proc_dir;
34037 char proc_dir_name[10];
34038
34039 - atomic_t stats[IPMI_NUM_STATS];
34040 + atomic_unchecked_t stats[IPMI_NUM_STATS];
34041
34042 /*
34043 * run_to_completion duplicate of smb_info, smi_info
34044 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
34045
34046
34047 #define ipmi_inc_stat(intf, stat) \
34048 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
34049 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
34050 #define ipmi_get_stat(intf, stat) \
34051 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
34052 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
34053
34054 static int is_lan_addr(struct ipmi_addr *addr)
34055 {
34056 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
34057 INIT_LIST_HEAD(&intf->cmd_rcvrs);
34058 init_waitqueue_head(&intf->waitq);
34059 for (i = 0; i < IPMI_NUM_STATS; i++)
34060 - atomic_set(&intf->stats[i], 0);
34061 + atomic_set_unchecked(&intf->stats[i], 0);
34062
34063 intf->proc_dir = NULL;
34064
34065 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
34066 index 1c7fdcd..4899100 100644
34067 --- a/drivers/char/ipmi/ipmi_si_intf.c
34068 +++ b/drivers/char/ipmi/ipmi_si_intf.c
34069 @@ -275,7 +275,7 @@ struct smi_info {
34070 unsigned char slave_addr;
34071
34072 /* Counters and things for the proc filesystem. */
34073 - atomic_t stats[SI_NUM_STATS];
34074 + atomic_unchecked_t stats[SI_NUM_STATS];
34075
34076 struct task_struct *thread;
34077
34078 @@ -284,9 +284,9 @@ struct smi_info {
34079 };
34080
34081 #define smi_inc_stat(smi, stat) \
34082 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
34083 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
34084 #define smi_get_stat(smi, stat) \
34085 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
34086 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
34087
34088 #define SI_MAX_PARMS 4
34089
34090 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
34091 atomic_set(&new_smi->req_events, 0);
34092 new_smi->run_to_completion = 0;
34093 for (i = 0; i < SI_NUM_STATS; i++)
34094 - atomic_set(&new_smi->stats[i], 0);
34095 + atomic_set_unchecked(&new_smi->stats[i], 0);
34096
34097 new_smi->interrupt_disabled = 1;
34098 atomic_set(&new_smi->stop_operation, 0);
34099 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
34100 index c6fa3bc..4ca3e42 100644
34101 --- a/drivers/char/mem.c
34102 +++ b/drivers/char/mem.c
34103 @@ -18,6 +18,7 @@
34104 #include <linux/raw.h>
34105 #include <linux/tty.h>
34106 #include <linux/capability.h>
34107 +#include <linux/security.h>
34108 #include <linux/ptrace.h>
34109 #include <linux/device.h>
34110 #include <linux/highmem.h>
34111 @@ -37,6 +38,10 @@
34112
34113 #define DEVPORT_MINOR 4
34114
34115 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34116 +extern const struct file_operations grsec_fops;
34117 +#endif
34118 +
34119 static inline unsigned long size_inside_page(unsigned long start,
34120 unsigned long size)
34121 {
34122 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34123
34124 while (cursor < to) {
34125 if (!devmem_is_allowed(pfn)) {
34126 +#ifdef CONFIG_GRKERNSEC_KMEM
34127 + gr_handle_mem_readwrite(from, to);
34128 +#else
34129 printk(KERN_INFO
34130 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34131 current->comm, from, to);
34132 +#endif
34133 return 0;
34134 }
34135 cursor += PAGE_SIZE;
34136 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34137 }
34138 return 1;
34139 }
34140 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34141 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34142 +{
34143 + return 0;
34144 +}
34145 #else
34146 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34147 {
34148 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34149
34150 while (count > 0) {
34151 unsigned long remaining;
34152 + char *temp;
34153
34154 sz = size_inside_page(p, count);
34155
34156 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34157 if (!ptr)
34158 return -EFAULT;
34159
34160 - remaining = copy_to_user(buf, ptr, sz);
34161 +#ifdef CONFIG_PAX_USERCOPY
34162 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34163 + if (!temp) {
34164 + unxlate_dev_mem_ptr(p, ptr);
34165 + return -ENOMEM;
34166 + }
34167 + memcpy(temp, ptr, sz);
34168 +#else
34169 + temp = ptr;
34170 +#endif
34171 +
34172 + remaining = copy_to_user(buf, temp, sz);
34173 +
34174 +#ifdef CONFIG_PAX_USERCOPY
34175 + kfree(temp);
34176 +#endif
34177 +
34178 unxlate_dev_mem_ptr(p, ptr);
34179 if (remaining)
34180 return -EFAULT;
34181 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34182 size_t count, loff_t *ppos)
34183 {
34184 unsigned long p = *ppos;
34185 - ssize_t low_count, read, sz;
34186 + ssize_t low_count, read, sz, err = 0;
34187 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34188 - int err = 0;
34189
34190 read = 0;
34191 if (p < (unsigned long) high_memory) {
34192 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34193 }
34194 #endif
34195 while (low_count > 0) {
34196 + char *temp;
34197 +
34198 sz = size_inside_page(p, low_count);
34199
34200 /*
34201 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34202 */
34203 kbuf = xlate_dev_kmem_ptr((char *)p);
34204
34205 - if (copy_to_user(buf, kbuf, sz))
34206 +#ifdef CONFIG_PAX_USERCOPY
34207 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34208 + if (!temp)
34209 + return -ENOMEM;
34210 + memcpy(temp, kbuf, sz);
34211 +#else
34212 + temp = kbuf;
34213 +#endif
34214 +
34215 + err = copy_to_user(buf, temp, sz);
34216 +
34217 +#ifdef CONFIG_PAX_USERCOPY
34218 + kfree(temp);
34219 +#endif
34220 +
34221 + if (err)
34222 return -EFAULT;
34223 buf += sz;
34224 p += sz;
34225 @@ -833,6 +880,9 @@ static const struct memdev {
34226 #ifdef CONFIG_CRASH_DUMP
34227 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34228 #endif
34229 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34230 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34231 +#endif
34232 };
34233
34234 static int memory_open(struct inode *inode, struct file *filp)
34235 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34236 index 9df78e2..01ba9ae 100644
34237 --- a/drivers/char/nvram.c
34238 +++ b/drivers/char/nvram.c
34239 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34240
34241 spin_unlock_irq(&rtc_lock);
34242
34243 - if (copy_to_user(buf, contents, tmp - contents))
34244 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34245 return -EFAULT;
34246
34247 *ppos = i;
34248 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34249 index b66eaa0..2619d1b 100644
34250 --- a/drivers/char/pcmcia/synclink_cs.c
34251 +++ b/drivers/char/pcmcia/synclink_cs.c
34252 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34253
34254 if (debug_level >= DEBUG_LEVEL_INFO)
34255 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34256 - __FILE__,__LINE__, info->device_name, port->count);
34257 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
34258
34259 - WARN_ON(!port->count);
34260 + WARN_ON(!atomic_read(&port->count));
34261
34262 if (tty_port_close_start(port, tty, filp) == 0)
34263 goto cleanup;
34264 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34265 cleanup:
34266 if (debug_level >= DEBUG_LEVEL_INFO)
34267 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
34268 - tty->driver->name, port->count);
34269 + tty->driver->name, atomic_read(&port->count));
34270 }
34271
34272 /* Wait until the transmitter is empty.
34273 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34274
34275 if (debug_level >= DEBUG_LEVEL_INFO)
34276 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34277 - __FILE__,__LINE__,tty->driver->name, port->count);
34278 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
34279
34280 /* If port is closing, signal caller to try again */
34281 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34282 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34283 goto cleanup;
34284 }
34285 spin_lock(&port->lock);
34286 - port->count++;
34287 + atomic_inc(&port->count);
34288 spin_unlock(&port->lock);
34289 spin_unlock_irqrestore(&info->netlock, flags);
34290
34291 - if (port->count == 1) {
34292 + if (atomic_read(&port->count) == 1) {
34293 /* 1st open on this device, init hardware */
34294 retval = startup(info, tty);
34295 if (retval < 0)
34296 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34297 unsigned short new_crctype;
34298
34299 /* return error if TTY interface open */
34300 - if (info->port.count)
34301 + if (atomic_read(&info->port.count))
34302 return -EBUSY;
34303
34304 switch (encoding)
34305 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
34306
34307 /* arbitrate between network and tty opens */
34308 spin_lock_irqsave(&info->netlock, flags);
34309 - if (info->port.count != 0 || info->netcount != 0) {
34310 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34311 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34312 spin_unlock_irqrestore(&info->netlock, flags);
34313 return -EBUSY;
34314 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34315 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
34316
34317 /* return error if TTY interface open */
34318 - if (info->port.count)
34319 + if (atomic_read(&info->port.count))
34320 return -EBUSY;
34321
34322 if (cmd != SIOCWANDEV)
34323 diff --git a/drivers/char/random.c b/drivers/char/random.c
34324 index 57d4b15..253207b 100644
34325 --- a/drivers/char/random.c
34326 +++ b/drivers/char/random.c
34327 @@ -272,8 +272,13 @@
34328 /*
34329 * Configuration information
34330 */
34331 +#ifdef CONFIG_GRKERNSEC_RANDNET
34332 +#define INPUT_POOL_WORDS 512
34333 +#define OUTPUT_POOL_WORDS 128
34334 +#else
34335 #define INPUT_POOL_WORDS 128
34336 #define OUTPUT_POOL_WORDS 32
34337 +#endif
34338 #define SEC_XFER_SIZE 512
34339 #define EXTRACT_SIZE 10
34340
34341 @@ -313,10 +318,17 @@ static struct poolinfo {
34342 int poolwords;
34343 int tap1, tap2, tap3, tap4, tap5;
34344 } poolinfo_table[] = {
34345 +#ifdef CONFIG_GRKERNSEC_RANDNET
34346 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34347 + { 512, 411, 308, 208, 104, 1 },
34348 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34349 + { 128, 103, 76, 51, 25, 1 },
34350 +#else
34351 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34352 { 128, 103, 76, 51, 25, 1 },
34353 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34354 { 32, 26, 20, 14, 7, 1 },
34355 +#endif
34356 #if 0
34357 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34358 { 2048, 1638, 1231, 819, 411, 1 },
34359 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34360 input_rotate += i ? 7 : 14;
34361 }
34362
34363 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34364 - ACCESS_ONCE(r->add_ptr) = i;
34365 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34366 + ACCESS_ONCE_RW(r->add_ptr) = i;
34367 smp_wmb();
34368
34369 if (out)
34370 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34371
34372 extract_buf(r, tmp);
34373 i = min_t(int, nbytes, EXTRACT_SIZE);
34374 - if (copy_to_user(buf, tmp, i)) {
34375 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34376 ret = -EFAULT;
34377 break;
34378 }
34379 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34380 #include <linux/sysctl.h>
34381
34382 static int min_read_thresh = 8, min_write_thresh;
34383 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34384 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34385 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34386 static char sysctl_bootid[16];
34387
34388 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
34389 static int proc_do_uuid(ctl_table *table, int write,
34390 void __user *buffer, size_t *lenp, loff_t *ppos)
34391 {
34392 - ctl_table fake_table;
34393 + ctl_table_no_const fake_table;
34394 unsigned char buf[64], tmp_uuid[16], *uuid;
34395
34396 uuid = table->data;
34397 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34398 index d780295..b29f3a8 100644
34399 --- a/drivers/char/sonypi.c
34400 +++ b/drivers/char/sonypi.c
34401 @@ -54,6 +54,7 @@
34402
34403 #include <asm/uaccess.h>
34404 #include <asm/io.h>
34405 +#include <asm/local.h>
34406
34407 #include <linux/sonypi.h>
34408
34409 @@ -490,7 +491,7 @@ static struct sonypi_device {
34410 spinlock_t fifo_lock;
34411 wait_queue_head_t fifo_proc_list;
34412 struct fasync_struct *fifo_async;
34413 - int open_count;
34414 + local_t open_count;
34415 int model;
34416 struct input_dev *input_jog_dev;
34417 struct input_dev *input_key_dev;
34418 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34419 static int sonypi_misc_release(struct inode *inode, struct file *file)
34420 {
34421 mutex_lock(&sonypi_device.lock);
34422 - sonypi_device.open_count--;
34423 + local_dec(&sonypi_device.open_count);
34424 mutex_unlock(&sonypi_device.lock);
34425 return 0;
34426 }
34427 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34428 {
34429 mutex_lock(&sonypi_device.lock);
34430 /* Flush input queue on first open */
34431 - if (!sonypi_device.open_count)
34432 + if (!local_read(&sonypi_device.open_count))
34433 kfifo_reset(&sonypi_device.fifo);
34434 - sonypi_device.open_count++;
34435 + local_inc(&sonypi_device.open_count);
34436 mutex_unlock(&sonypi_device.lock);
34437
34438 return 0;
34439 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
34440 index 93211df..c7805f7 100644
34441 --- a/drivers/char/tpm/tpm.c
34442 +++ b/drivers/char/tpm/tpm.c
34443 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
34444 chip->vendor.req_complete_val)
34445 goto out_recv;
34446
34447 - if ((status == chip->vendor.req_canceled)) {
34448 + if (status == chip->vendor.req_canceled) {
34449 dev_err(chip->dev, "Operation Canceled\n");
34450 rc = -ECANCELED;
34451 goto out;
34452 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34453 index 56051d0..11cf3b7 100644
34454 --- a/drivers/char/tpm/tpm_acpi.c
34455 +++ b/drivers/char/tpm/tpm_acpi.c
34456 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34457 virt = acpi_os_map_memory(start, len);
34458 if (!virt) {
34459 kfree(log->bios_event_log);
34460 + log->bios_event_log = NULL;
34461 printk("%s: ERROR - Unable to map memory\n", __func__);
34462 return -EIO;
34463 }
34464
34465 - memcpy_fromio(log->bios_event_log, virt, len);
34466 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34467
34468 acpi_os_unmap_memory(virt, len);
34469 return 0;
34470 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34471 index 84ddc55..1d32f1e 100644
34472 --- a/drivers/char/tpm/tpm_eventlog.c
34473 +++ b/drivers/char/tpm/tpm_eventlog.c
34474 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34475 event = addr;
34476
34477 if ((event->event_type == 0 && event->event_size == 0) ||
34478 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34479 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34480 return NULL;
34481
34482 return addr;
34483 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34484 return NULL;
34485
34486 if ((event->event_type == 0 && event->event_size == 0) ||
34487 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34488 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34489 return NULL;
34490
34491 (*pos)++;
34492 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34493 int i;
34494
34495 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34496 - seq_putc(m, data[i]);
34497 + if (!seq_putc(m, data[i]))
34498 + return -EFAULT;
34499
34500 return 0;
34501 }
34502 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34503 index a4b7aa0..2faa0bc 100644
34504 --- a/drivers/char/virtio_console.c
34505 +++ b/drivers/char/virtio_console.c
34506 @@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34507 if (to_user) {
34508 ssize_t ret;
34509
34510 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34511 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34512 if (ret)
34513 return -EFAULT;
34514 } else {
34515 @@ -784,7 +784,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34516 if (!port_has_data(port) && !port->host_connected)
34517 return 0;
34518
34519 - return fill_readbuf(port, ubuf, count, true);
34520 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34521 }
34522
34523 static int wait_port_writable(struct port *port, bool nonblock)
34524 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
34525 index 8ae1a61..9c00613 100644
34526 --- a/drivers/clocksource/arm_generic.c
34527 +++ b/drivers/clocksource/arm_generic.c
34528 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34529 return NOTIFY_OK;
34530 }
34531
34532 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34533 +static struct notifier_block arch_timer_cpu_nb = {
34534 .notifier_call = arch_timer_cpu_notify,
34535 };
34536
34537 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34538 index 7b0d49d..134fac9 100644
34539 --- a/drivers/cpufreq/acpi-cpufreq.c
34540 +++ b/drivers/cpufreq/acpi-cpufreq.c
34541 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34542 return sprintf(buf, "%u\n", boost_enabled);
34543 }
34544
34545 -static struct global_attr global_boost = __ATTR(boost, 0644,
34546 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34547 show_global_boost,
34548 store_global_boost);
34549
34550 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34551 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34552 per_cpu(acfreq_data, cpu) = data;
34553
34554 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34555 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34556 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34557 + pax_open_kernel();
34558 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34559 + pax_close_kernel();
34560 + }
34561
34562 result = acpi_processor_register_performance(data->acpi_data, cpu);
34563 if (result)
34564 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34565 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34566 break;
34567 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34568 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34569 + pax_open_kernel();
34570 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34571 + pax_close_kernel();
34572 policy->cur = get_cur_freq_on_cpu(cpu);
34573 break;
34574 default:
34575 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34576 acpi_processor_notify_smm(THIS_MODULE);
34577
34578 /* Check for APERF/MPERF support in hardware */
34579 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34580 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34581 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34582 + pax_open_kernel();
34583 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34584 + pax_close_kernel();
34585 + }
34586
34587 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34588 for (i = 0; i < perf->state_count; i++)
34589 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34590 index 1f93dbd..305cef1 100644
34591 --- a/drivers/cpufreq/cpufreq.c
34592 +++ b/drivers/cpufreq/cpufreq.c
34593 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34594 return NOTIFY_OK;
34595 }
34596
34597 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34598 +static struct notifier_block cpufreq_cpu_notifier = {
34599 .notifier_call = cpufreq_cpu_callback,
34600 };
34601
34602 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34603
34604 pr_debug("trying to register driver %s\n", driver_data->name);
34605
34606 - if (driver_data->setpolicy)
34607 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34608 + if (driver_data->setpolicy) {
34609 + pax_open_kernel();
34610 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34611 + pax_close_kernel();
34612 + }
34613
34614 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34615 if (cpufreq_driver) {
34616 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34617 index 6c5f1d3..c7e2f35e 100644
34618 --- a/drivers/cpufreq/cpufreq_governor.c
34619 +++ b/drivers/cpufreq/cpufreq_governor.c
34620 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34621 * governor, thus we are bound to jiffes/HZ
34622 */
34623 if (dbs_data->governor == GOV_CONSERVATIVE) {
34624 - struct cs_ops *ops = dbs_data->gov_ops;
34625 + const struct cs_ops *ops = dbs_data->gov_ops;
34626
34627 cpufreq_register_notifier(ops->notifier_block,
34628 CPUFREQ_TRANSITION_NOTIFIER);
34629 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34630 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
34631 jiffies_to_usecs(10);
34632 } else {
34633 - struct od_ops *ops = dbs_data->gov_ops;
34634 + const struct od_ops *ops = dbs_data->gov_ops;
34635
34636 od_tuners->io_is_busy = ops->io_busy();
34637 }
34638 @@ -268,7 +268,7 @@ second_time:
34639 cs_dbs_info->enable = 1;
34640 cs_dbs_info->requested_freq = policy->cur;
34641 } else {
34642 - struct od_ops *ops = dbs_data->gov_ops;
34643 + const struct od_ops *ops = dbs_data->gov_ops;
34644 od_dbs_info->rate_mult = 1;
34645 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
34646 ops->powersave_bias_init_cpu(cpu);
34647 @@ -289,7 +289,7 @@ second_time:
34648 mutex_destroy(&cpu_cdbs->timer_mutex);
34649 dbs_data->enable--;
34650 if (!dbs_data->enable) {
34651 - struct cs_ops *ops = dbs_data->gov_ops;
34652 + const struct cs_ops *ops = dbs_data->gov_ops;
34653
34654 sysfs_remove_group(cpufreq_global_kobject,
34655 dbs_data->attr_group);
34656 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34657 index f661654..6c8e638 100644
34658 --- a/drivers/cpufreq/cpufreq_governor.h
34659 +++ b/drivers/cpufreq/cpufreq_governor.h
34660 @@ -142,7 +142,7 @@ struct dbs_data {
34661 void (*gov_check_cpu)(int cpu, unsigned int load);
34662
34663 /* Governor specific ops, see below */
34664 - void *gov_ops;
34665 + const void *gov_ops;
34666 };
34667
34668 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34669 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34670 index 9d7732b..0b1a793 100644
34671 --- a/drivers/cpufreq/cpufreq_stats.c
34672 +++ b/drivers/cpufreq/cpufreq_stats.c
34673 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34674 }
34675
34676 /* priority=1 so this will get called before cpufreq_remove_dev */
34677 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34678 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34679 .notifier_call = cpufreq_stat_cpu_callback,
34680 .priority = 1,
34681 };
34682 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34683 index 827629c9..0bc6a03 100644
34684 --- a/drivers/cpufreq/p4-clockmod.c
34685 +++ b/drivers/cpufreq/p4-clockmod.c
34686 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34687 case 0x0F: /* Core Duo */
34688 case 0x16: /* Celeron Core */
34689 case 0x1C: /* Atom */
34690 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34691 + pax_open_kernel();
34692 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34693 + pax_close_kernel();
34694 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34695 case 0x0D: /* Pentium M (Dothan) */
34696 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34697 + pax_open_kernel();
34698 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34699 + pax_close_kernel();
34700 /* fall through */
34701 case 0x09: /* Pentium M (Banias) */
34702 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34703 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34704
34705 /* on P-4s, the TSC runs with constant frequency independent whether
34706 * throttling is active or not. */
34707 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34708 + pax_open_kernel();
34709 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34710 + pax_close_kernel();
34711
34712 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34713 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34714 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34715 index 3a953d5..f5993f6 100644
34716 --- a/drivers/cpufreq/speedstep-centrino.c
34717 +++ b/drivers/cpufreq/speedstep-centrino.c
34718 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34719 !cpu_has(cpu, X86_FEATURE_EST))
34720 return -ENODEV;
34721
34722 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34723 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34724 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34725 + pax_open_kernel();
34726 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34727 + pax_close_kernel();
34728 + }
34729
34730 if (policy->cpu != 0)
34731 return -ENODEV;
34732 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34733 index e1f6860..f8de20b 100644
34734 --- a/drivers/cpuidle/cpuidle.c
34735 +++ b/drivers/cpuidle/cpuidle.c
34736 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
34737
34738 static void poll_idle_init(struct cpuidle_driver *drv)
34739 {
34740 - struct cpuidle_state *state = &drv->states[0];
34741 + cpuidle_state_no_const *state = &drv->states[0];
34742
34743 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34744 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34745 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34746 index ea2f8e7..70ac501 100644
34747 --- a/drivers/cpuidle/governor.c
34748 +++ b/drivers/cpuidle/governor.c
34749 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34750 mutex_lock(&cpuidle_lock);
34751 if (__cpuidle_find_governor(gov->name) == NULL) {
34752 ret = 0;
34753 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34754 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34755 if (!cpuidle_curr_governor ||
34756 cpuidle_curr_governor->rating < gov->rating)
34757 cpuidle_switch_governor(gov);
34758 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34759 new_gov = cpuidle_replace_governor(gov->rating);
34760 cpuidle_switch_governor(new_gov);
34761 }
34762 - list_del(&gov->governor_list);
34763 + pax_list_del((struct list_head *)&gov->governor_list);
34764 mutex_unlock(&cpuidle_lock);
34765 }
34766
34767 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34768 index 428754a..8bdf9cc 100644
34769 --- a/drivers/cpuidle/sysfs.c
34770 +++ b/drivers/cpuidle/sysfs.c
34771 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34772 NULL
34773 };
34774
34775 -static struct attribute_group cpuidle_attr_group = {
34776 +static attribute_group_no_const cpuidle_attr_group = {
34777 .attrs = cpuidle_default_attrs,
34778 .name = "cpuidle",
34779 };
34780 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34781 index 3b36797..289c16a 100644
34782 --- a/drivers/devfreq/devfreq.c
34783 +++ b/drivers/devfreq/devfreq.c
34784 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34785 goto err_out;
34786 }
34787
34788 - list_add(&governor->node, &devfreq_governor_list);
34789 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34790
34791 list_for_each_entry(devfreq, &devfreq_list, node) {
34792 int ret = 0;
34793 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34794 }
34795 }
34796
34797 - list_del(&governor->node);
34798 + pax_list_del((struct list_head *)&governor->node);
34799 err_out:
34800 mutex_unlock(&devfreq_list_lock);
34801
34802 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34803 index b70709b..1d8d02a 100644
34804 --- a/drivers/dma/sh/shdma.c
34805 +++ b/drivers/dma/sh/shdma.c
34806 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34807 return ret;
34808 }
34809
34810 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34811 +static struct notifier_block sh_dmae_nmi_notifier = {
34812 .notifier_call = sh_dmae_nmi_handler,
34813
34814 /* Run before NMI debug handler and KGDB */
34815 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34816 index 0ca1ca7..6e6f454 100644
34817 --- a/drivers/edac/edac_mc_sysfs.c
34818 +++ b/drivers/edac/edac_mc_sysfs.c
34819 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34820 struct dev_ch_attribute {
34821 struct device_attribute attr;
34822 int channel;
34823 -};
34824 +} __do_const;
34825
34826 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34827 struct dev_ch_attribute dev_attr_legacy_##_name = \
34828 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34829 index 0056c4d..23b54d9 100644
34830 --- a/drivers/edac/edac_pci_sysfs.c
34831 +++ b/drivers/edac/edac_pci_sysfs.c
34832 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34833 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34834 static int edac_pci_poll_msec = 1000; /* one second workq period */
34835
34836 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34837 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34838 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34839 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34840
34841 static struct kobject *edac_pci_top_main_kobj;
34842 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34843 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34844 void *value;
34845 ssize_t(*show) (void *, char *);
34846 ssize_t(*store) (void *, const char *, size_t);
34847 -};
34848 +} __do_const;
34849
34850 /* Set of show/store abstract level functions for PCI Parity object */
34851 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34852 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34853 edac_printk(KERN_CRIT, EDAC_PCI,
34854 "Signaled System Error on %s\n",
34855 pci_name(dev));
34856 - atomic_inc(&pci_nonparity_count);
34857 + atomic_inc_unchecked(&pci_nonparity_count);
34858 }
34859
34860 if (status & (PCI_STATUS_PARITY)) {
34861 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34862 "Master Data Parity Error on %s\n",
34863 pci_name(dev));
34864
34865 - atomic_inc(&pci_parity_count);
34866 + atomic_inc_unchecked(&pci_parity_count);
34867 }
34868
34869 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34870 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34871 "Detected Parity Error on %s\n",
34872 pci_name(dev));
34873
34874 - atomic_inc(&pci_parity_count);
34875 + atomic_inc_unchecked(&pci_parity_count);
34876 }
34877 }
34878
34879 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34880 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
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 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34889 "Master Data Parity Error on "
34890 "%s\n", 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 @@ -634,7 +634,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 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34907 if (!check_pci_errors)
34908 return;
34909
34910 - before_count = atomic_read(&pci_parity_count);
34911 + before_count = atomic_read_unchecked(&pci_parity_count);
34912
34913 /* scan all PCI devices looking for a Parity Error on devices and
34914 * bridges.
34915 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34916 /* Only if operator has selected panic on PCI Error */
34917 if (edac_pci_get_panic_on_pe()) {
34918 /* If the count is different 'after' from 'before' */
34919 - if (before_count != atomic_read(&pci_parity_count))
34920 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34921 panic("EDAC: PCI Parity Error");
34922 }
34923 }
34924 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34925 index 6796799..99e8377 100644
34926 --- a/drivers/edac/mce_amd.h
34927 +++ b/drivers/edac/mce_amd.h
34928 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
34929 struct amd_decoder_ops {
34930 bool (*mc0_mce)(u16, u8);
34931 bool (*mc1_mce)(u16, u8);
34932 -};
34933 +} __no_const;
34934
34935 void amd_report_gart_errors(bool);
34936 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34937 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34938 index 57ea7f4..789e3c3 100644
34939 --- a/drivers/firewire/core-card.c
34940 +++ b/drivers/firewire/core-card.c
34941 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34942
34943 void fw_core_remove_card(struct fw_card *card)
34944 {
34945 - struct fw_card_driver dummy_driver = dummy_driver_template;
34946 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34947
34948 card->driver->update_phy_reg(card, 4,
34949 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34950 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34951 index f8d2287..5aaf4db 100644
34952 --- a/drivers/firewire/core-cdev.c
34953 +++ b/drivers/firewire/core-cdev.c
34954 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
34955 int ret;
34956
34957 if ((request->channels == 0 && request->bandwidth == 0) ||
34958 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34959 - request->bandwidth < 0)
34960 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34961 return -EINVAL;
34962
34963 r = kmalloc(sizeof(*r), GFP_KERNEL);
34964 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34965 index af3e8aa..eb2f227 100644
34966 --- a/drivers/firewire/core-device.c
34967 +++ b/drivers/firewire/core-device.c
34968 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34969 struct config_rom_attribute {
34970 struct device_attribute attr;
34971 u32 key;
34972 -};
34973 +} __do_const;
34974
34975 static ssize_t show_immediate(struct device *dev,
34976 struct device_attribute *dattr, char *buf)
34977 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34978 index 28a94c7..58da63a 100644
34979 --- a/drivers/firewire/core-transaction.c
34980 +++ b/drivers/firewire/core-transaction.c
34981 @@ -38,6 +38,7 @@
34982 #include <linux/timer.h>
34983 #include <linux/types.h>
34984 #include <linux/workqueue.h>
34985 +#include <linux/sched.h>
34986
34987 #include <asm/byteorder.h>
34988
34989 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34990 index 515a42c..5ecf3ba 100644
34991 --- a/drivers/firewire/core.h
34992 +++ b/drivers/firewire/core.h
34993 @@ -111,6 +111,7 @@ struct fw_card_driver {
34994
34995 int (*stop_iso)(struct fw_iso_context *ctx);
34996 };
34997 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34998
34999 void fw_card_initialize(struct fw_card *card,
35000 const struct fw_card_driver *driver, struct device *device);
35001 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
35002 index 94a58a0..f5eba42 100644
35003 --- a/drivers/firmware/dmi-id.c
35004 +++ b/drivers/firmware/dmi-id.c
35005 @@ -16,7 +16,7 @@
35006 struct dmi_device_attribute{
35007 struct device_attribute dev_attr;
35008 int field;
35009 -};
35010 +} __do_const;
35011 #define to_dmi_dev_attr(_dev_attr) \
35012 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
35013
35014 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
35015 index 4cd392d..4b629e1 100644
35016 --- a/drivers/firmware/dmi_scan.c
35017 +++ b/drivers/firmware/dmi_scan.c
35018 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
35019 }
35020 }
35021 else {
35022 - /*
35023 - * no iounmap() for that ioremap(); it would be a no-op, but
35024 - * it's so early in setup that sucker gets confused into doing
35025 - * what it shouldn't if we actually call it.
35026 - */
35027 p = dmi_ioremap(0xF0000, 0x10000);
35028 if (p == NULL)
35029 goto error;
35030 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35031 if (buf == NULL)
35032 return -1;
35033
35034 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35035 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35036
35037 iounmap(buf);
35038 return 0;
35039 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
35040 index b07cb37..2a51037 100644
35041 --- a/drivers/firmware/efivars.c
35042 +++ b/drivers/firmware/efivars.c
35043 @@ -138,7 +138,7 @@ struct efivar_attribute {
35044 };
35045
35046 static struct efivars __efivars;
35047 -static struct efivar_operations ops;
35048 +static efivar_operations_no_const ops __read_only;
35049
35050 #define PSTORE_EFI_ATTRIBUTES \
35051 (EFI_VARIABLE_NON_VOLATILE | \
35052 @@ -1834,7 +1834,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
35053 static int
35054 create_efivars_bin_attributes(struct efivars *efivars)
35055 {
35056 - struct bin_attribute *attr;
35057 + bin_attribute_no_const *attr;
35058 int error;
35059
35060 /* new_var */
35061 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35062 index 2a90ba6..07f3733 100644
35063 --- a/drivers/firmware/google/memconsole.c
35064 +++ b/drivers/firmware/google/memconsole.c
35065 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35066 if (!found_memconsole())
35067 return -ENODEV;
35068
35069 - memconsole_bin_attr.size = memconsole_length;
35070 + pax_open_kernel();
35071 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35072 + pax_close_kernel();
35073
35074 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35075
35076 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35077 index 6f2306d..af9476a 100644
35078 --- a/drivers/gpio/gpio-ich.c
35079 +++ b/drivers/gpio/gpio-ich.c
35080 @@ -69,7 +69,7 @@ struct ichx_desc {
35081 /* Some chipsets have quirks, let these use their own request/get */
35082 int (*request)(struct gpio_chip *chip, unsigned offset);
35083 int (*get)(struct gpio_chip *chip, unsigned offset);
35084 -};
35085 +} __do_const;
35086
35087 static struct {
35088 spinlock_t lock;
35089 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35090 index 9902732..64b62dd 100644
35091 --- a/drivers/gpio/gpio-vr41xx.c
35092 +++ b/drivers/gpio/gpio-vr41xx.c
35093 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35094 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35095 maskl, pendl, maskh, pendh);
35096
35097 - atomic_inc(&irq_err_count);
35098 + atomic_inc_unchecked(&irq_err_count);
35099
35100 return -EINVAL;
35101 }
35102 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35103 index 7b2d378..cc947ea 100644
35104 --- a/drivers/gpu/drm/drm_crtc_helper.c
35105 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35106 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35107 struct drm_crtc *tmp;
35108 int crtc_mask = 1;
35109
35110 - WARN(!crtc, "checking null crtc?\n");
35111 + BUG_ON(!crtc);
35112
35113 dev = crtc->dev;
35114
35115 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35116 index be174ca..7f38143 100644
35117 --- a/drivers/gpu/drm/drm_drv.c
35118 +++ b/drivers/gpu/drm/drm_drv.c
35119 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
35120 /**
35121 * Copy and IOCTL return string to user space
35122 */
35123 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35124 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35125 {
35126 int len;
35127
35128 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
35129 struct drm_file *file_priv = filp->private_data;
35130 struct drm_device *dev;
35131 struct drm_ioctl_desc *ioctl;
35132 - drm_ioctl_t *func;
35133 + drm_ioctl_no_const_t func;
35134 unsigned int nr = DRM_IOCTL_NR(cmd);
35135 int retcode = -EINVAL;
35136 char stack_kdata[128];
35137 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
35138 return -ENODEV;
35139
35140 atomic_inc(&dev->ioctl_count);
35141 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35142 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35143 ++file_priv->ioctl_count;
35144
35145 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
35146 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35147 index 32d7775..c8be5e1 100644
35148 --- a/drivers/gpu/drm/drm_fops.c
35149 +++ b/drivers/gpu/drm/drm_fops.c
35150 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35151 }
35152
35153 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35154 - atomic_set(&dev->counts[i], 0);
35155 + atomic_set_unchecked(&dev->counts[i], 0);
35156
35157 dev->sigdata.lock = NULL;
35158
35159 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35160 if (drm_device_is_unplugged(dev))
35161 return -ENODEV;
35162
35163 - if (!dev->open_count++)
35164 + if (local_inc_return(&dev->open_count) == 1)
35165 need_setup = 1;
35166 mutex_lock(&dev->struct_mutex);
35167 old_imapping = inode->i_mapping;
35168 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35169 retcode = drm_open_helper(inode, filp, dev);
35170 if (retcode)
35171 goto err_undo;
35172 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35173 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35174 if (need_setup) {
35175 retcode = drm_setup(dev);
35176 if (retcode)
35177 @@ -166,7 +166,7 @@ err_undo:
35178 iput(container_of(dev->dev_mapping, struct inode, i_data));
35179 dev->dev_mapping = old_mapping;
35180 mutex_unlock(&dev->struct_mutex);
35181 - dev->open_count--;
35182 + local_dec(&dev->open_count);
35183 return retcode;
35184 }
35185 EXPORT_SYMBOL(drm_open);
35186 @@ -440,7 +440,7 @@ int drm_release(struct inode *inode, struct file *filp)
35187
35188 mutex_lock(&drm_global_mutex);
35189
35190 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35191 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35192
35193 if (dev->driver->preclose)
35194 dev->driver->preclose(dev, file_priv);
35195 @@ -449,10 +449,10 @@ int drm_release(struct inode *inode, struct file *filp)
35196 * Begin inline drm_release
35197 */
35198
35199 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35200 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35201 task_pid_nr(current),
35202 (long)old_encode_dev(file_priv->minor->device),
35203 - dev->open_count);
35204 + local_read(&dev->open_count));
35205
35206 /* Release any auth tokens that might point to this file_priv,
35207 (do that under the drm_global_mutex) */
35208 @@ -549,8 +549,8 @@ int drm_release(struct inode *inode, struct file *filp)
35209 * End inline drm_release
35210 */
35211
35212 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35213 - if (!--dev->open_count) {
35214 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35215 + if (local_dec_and_test(&dev->open_count)) {
35216 if (atomic_read(&dev->ioctl_count)) {
35217 DRM_ERROR("Device busy: %d\n",
35218 atomic_read(&dev->ioctl_count));
35219 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35220 index f731116..629842c 100644
35221 --- a/drivers/gpu/drm/drm_global.c
35222 +++ b/drivers/gpu/drm/drm_global.c
35223 @@ -36,7 +36,7 @@
35224 struct drm_global_item {
35225 struct mutex mutex;
35226 void *object;
35227 - int refcount;
35228 + atomic_t refcount;
35229 };
35230
35231 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35232 @@ -49,7 +49,7 @@ void drm_global_init(void)
35233 struct drm_global_item *item = &glob[i];
35234 mutex_init(&item->mutex);
35235 item->object = NULL;
35236 - item->refcount = 0;
35237 + atomic_set(&item->refcount, 0);
35238 }
35239 }
35240
35241 @@ -59,7 +59,7 @@ void drm_global_release(void)
35242 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35243 struct drm_global_item *item = &glob[i];
35244 BUG_ON(item->object != NULL);
35245 - BUG_ON(item->refcount != 0);
35246 + BUG_ON(atomic_read(&item->refcount) != 0);
35247 }
35248 }
35249
35250 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35251 void *object;
35252
35253 mutex_lock(&item->mutex);
35254 - if (item->refcount == 0) {
35255 + if (atomic_read(&item->refcount) == 0) {
35256 item->object = kzalloc(ref->size, GFP_KERNEL);
35257 if (unlikely(item->object == NULL)) {
35258 ret = -ENOMEM;
35259 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35260 goto out_err;
35261
35262 }
35263 - ++item->refcount;
35264 + atomic_inc(&item->refcount);
35265 ref->object = item->object;
35266 object = item->object;
35267 mutex_unlock(&item->mutex);
35268 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35269 struct drm_global_item *item = &glob[ref->global_type];
35270
35271 mutex_lock(&item->mutex);
35272 - BUG_ON(item->refcount == 0);
35273 + BUG_ON(atomic_read(&item->refcount) == 0);
35274 BUG_ON(ref->object != item->object);
35275 - if (--item->refcount == 0) {
35276 + if (atomic_dec_and_test(&item->refcount)) {
35277 ref->release(ref);
35278 item->object = NULL;
35279 }
35280 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35281 index d4b20ce..77a8d41 100644
35282 --- a/drivers/gpu/drm/drm_info.c
35283 +++ b/drivers/gpu/drm/drm_info.c
35284 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35285 struct drm_local_map *map;
35286 struct drm_map_list *r_list;
35287
35288 - /* Hardcoded from _DRM_FRAME_BUFFER,
35289 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35290 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35291 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35292 + static const char * const types[] = {
35293 + [_DRM_FRAME_BUFFER] = "FB",
35294 + [_DRM_REGISTERS] = "REG",
35295 + [_DRM_SHM] = "SHM",
35296 + [_DRM_AGP] = "AGP",
35297 + [_DRM_SCATTER_GATHER] = "SG",
35298 + [_DRM_CONSISTENT] = "PCI",
35299 + [_DRM_GEM] = "GEM" };
35300 const char *type;
35301 int i;
35302
35303 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35304 map = r_list->map;
35305 if (!map)
35306 continue;
35307 - if (map->type < 0 || map->type > 5)
35308 + if (map->type >= ARRAY_SIZE(types))
35309 type = "??";
35310 else
35311 type = types[map->type];
35312 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35313 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35314 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35315 vma->vm_flags & VM_IO ? 'i' : '-',
35316 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35317 + 0);
35318 +#else
35319 vma->vm_pgoff);
35320 +#endif
35321
35322 #if defined(__i386__)
35323 pgprot = pgprot_val(vma->vm_page_prot);
35324 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35325 index 2f4c434..dd12cd2 100644
35326 --- a/drivers/gpu/drm/drm_ioc32.c
35327 +++ b/drivers/gpu/drm/drm_ioc32.c
35328 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35329 request = compat_alloc_user_space(nbytes);
35330 if (!access_ok(VERIFY_WRITE, request, nbytes))
35331 return -EFAULT;
35332 - list = (struct drm_buf_desc *) (request + 1);
35333 + list = (struct drm_buf_desc __user *) (request + 1);
35334
35335 if (__put_user(count, &request->count)
35336 || __put_user(list, &request->list))
35337 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35338 request = compat_alloc_user_space(nbytes);
35339 if (!access_ok(VERIFY_WRITE, request, nbytes))
35340 return -EFAULT;
35341 - list = (struct drm_buf_pub *) (request + 1);
35342 + list = (struct drm_buf_pub __user *) (request + 1);
35343
35344 if (__put_user(count, &request->count)
35345 || __put_user(list, &request->list))
35346 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35347 return 0;
35348 }
35349
35350 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35351 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35352 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35353 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35354 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35355 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35356 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35357 {
35358 unsigned int nr = DRM_IOCTL_NR(cmd);
35359 - drm_ioctl_compat_t *fn;
35360 int ret;
35361
35362 /* Assume that ioctls without an explicit compat routine will just
35363 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35364 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35365 return drm_ioctl(filp, cmd, arg);
35366
35367 - fn = drm_compat_ioctls[nr];
35368 -
35369 - if (fn != NULL)
35370 - ret = (*fn) (filp, cmd, arg);
35371 + if (drm_compat_ioctls[nr] != NULL)
35372 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35373 else
35374 ret = drm_ioctl(filp, cmd, arg);
35375
35376 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35377 index e77bd8b..1571b85 100644
35378 --- a/drivers/gpu/drm/drm_ioctl.c
35379 +++ b/drivers/gpu/drm/drm_ioctl.c
35380 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35381 stats->data[i].value =
35382 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35383 else
35384 - stats->data[i].value = atomic_read(&dev->counts[i]);
35385 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35386 stats->data[i].type = dev->types[i];
35387 }
35388
35389 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35390 index d752c96..fe08455 100644
35391 --- a/drivers/gpu/drm/drm_lock.c
35392 +++ b/drivers/gpu/drm/drm_lock.c
35393 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35394 if (drm_lock_take(&master->lock, lock->context)) {
35395 master->lock.file_priv = file_priv;
35396 master->lock.lock_time = jiffies;
35397 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35398 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35399 break; /* Got lock */
35400 }
35401
35402 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35403 return -EINVAL;
35404 }
35405
35406 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35407 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35408
35409 if (drm_lock_free(&master->lock, lock->context)) {
35410 /* FIXME: Should really bail out here. */
35411 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35412 index 200e104..59facda 100644
35413 --- a/drivers/gpu/drm/drm_stub.c
35414 +++ b/drivers/gpu/drm/drm_stub.c
35415 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
35416
35417 drm_device_set_unplugged(dev);
35418
35419 - if (dev->open_count == 0) {
35420 + if (local_read(&dev->open_count) == 0) {
35421 drm_put_dev(dev);
35422 }
35423 mutex_unlock(&drm_global_mutex);
35424 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35425 index 004ecdf..db1f6e0 100644
35426 --- a/drivers/gpu/drm/i810/i810_dma.c
35427 +++ b/drivers/gpu/drm/i810/i810_dma.c
35428 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35429 dma->buflist[vertex->idx],
35430 vertex->discard, vertex->used);
35431
35432 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35433 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35434 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35435 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35436 sarea_priv->last_enqueue = dev_priv->counter - 1;
35437 sarea_priv->last_dispatch = (int)hw_status[5];
35438
35439 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35440 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35441 mc->last_render);
35442
35443 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35444 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35445 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35446 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35447 sarea_priv->last_enqueue = dev_priv->counter - 1;
35448 sarea_priv->last_dispatch = (int)hw_status[5];
35449
35450 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35451 index 6e0acad..93c8289 100644
35452 --- a/drivers/gpu/drm/i810/i810_drv.h
35453 +++ b/drivers/gpu/drm/i810/i810_drv.h
35454 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35455 int page_flipping;
35456
35457 wait_queue_head_t irq_queue;
35458 - atomic_t irq_received;
35459 - atomic_t irq_emitted;
35460 + atomic_unchecked_t irq_received;
35461 + atomic_unchecked_t irq_emitted;
35462
35463 int front_offset;
35464 } drm_i810_private_t;
35465 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35466 index 261efc8e..27af8a5 100644
35467 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35468 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35469 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35470 I915_READ(GTIMR));
35471 }
35472 seq_printf(m, "Interrupts received: %d\n",
35473 - atomic_read(&dev_priv->irq_received));
35474 + atomic_read_unchecked(&dev_priv->irq_received));
35475 for_each_ring(ring, dev_priv, i) {
35476 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35477 seq_printf(m,
35478 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35479 index 99daa89..84ebd44 100644
35480 --- a/drivers/gpu/drm/i915/i915_dma.c
35481 +++ b/drivers/gpu/drm/i915/i915_dma.c
35482 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35483 bool can_switch;
35484
35485 spin_lock(&dev->count_lock);
35486 - can_switch = (dev->open_count == 0);
35487 + can_switch = (local_read(&dev->open_count) == 0);
35488 spin_unlock(&dev->count_lock);
35489 return can_switch;
35490 }
35491 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35492 index 7339a4b..445aaba 100644
35493 --- a/drivers/gpu/drm/i915/i915_drv.h
35494 +++ b/drivers/gpu/drm/i915/i915_drv.h
35495 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
35496 drm_dma_handle_t *status_page_dmah;
35497 struct resource mch_res;
35498
35499 - atomic_t irq_received;
35500 + atomic_unchecked_t irq_received;
35501
35502 /* protects the irq masks */
35503 spinlock_t irq_lock;
35504 @@ -1102,7 +1102,7 @@ struct drm_i915_gem_object {
35505 * will be page flipped away on the next vblank. When it
35506 * reaches 0, dev_priv->pending_flip_queue will be woken up.
35507 */
35508 - atomic_t pending_flip;
35509 + atomic_unchecked_t pending_flip;
35510 };
35511 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
35512
35513 @@ -1633,7 +1633,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35514 struct drm_i915_private *dev_priv, unsigned port);
35515 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35516 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35517 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35518 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35519 {
35520 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35521 }
35522 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35523 index ba8805a..39d5330 100644
35524 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35525 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35526 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
35527 i915_gem_clflush_object(obj);
35528
35529 if (obj->base.pending_write_domain)
35530 - flips |= atomic_read(&obj->pending_flip);
35531 + flips |= atomic_read_unchecked(&obj->pending_flip);
35532
35533 flush_domains |= obj->base.write_domain;
35534 }
35535 @@ -703,9 +703,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35536
35537 static int
35538 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35539 - int count)
35540 + unsigned int count)
35541 {
35542 - int i;
35543 + unsigned int i;
35544 int relocs_total = 0;
35545 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35546
35547 @@ -1202,7 +1202,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35548 return -ENOMEM;
35549 }
35550 ret = copy_from_user(exec2_list,
35551 - (struct drm_i915_relocation_entry __user *)
35552 + (struct drm_i915_gem_exec_object2 __user *)
35553 (uintptr_t) args->buffers_ptr,
35554 sizeof(*exec2_list) * args->buffer_count);
35555 if (ret != 0) {
35556 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35557 index 3c59584..500f2e9 100644
35558 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35559 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35560 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35561 (unsigned long)request);
35562 }
35563
35564 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35565 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35566 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35567 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35568 [DRM_I915_GETPARAM] = compat_i915_getparam,
35569 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35570 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35571 {
35572 unsigned int nr = DRM_IOCTL_NR(cmd);
35573 - drm_ioctl_compat_t *fn = NULL;
35574 int ret;
35575
35576 if (nr < DRM_COMMAND_BASE)
35577 return drm_compat_ioctl(filp, cmd, arg);
35578
35579 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35580 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35581 -
35582 - if (fn != NULL)
35583 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35584 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35585 ret = (*fn) (filp, cmd, arg);
35586 - else
35587 + } else
35588 ret = drm_ioctl(filp, cmd, arg);
35589
35590 return ret;
35591 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35592 index fe84338..a863190 100644
35593 --- a/drivers/gpu/drm/i915/i915_irq.c
35594 +++ b/drivers/gpu/drm/i915/i915_irq.c
35595 @@ -535,7 +535,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35596 u32 pipe_stats[I915_MAX_PIPES];
35597 bool blc_event;
35598
35599 - atomic_inc(&dev_priv->irq_received);
35600 + atomic_inc_unchecked(&dev_priv->irq_received);
35601
35602 while (true) {
35603 iir = I915_READ(VLV_IIR);
35604 @@ -688,7 +688,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35605 irqreturn_t ret = IRQ_NONE;
35606 int i;
35607
35608 - atomic_inc(&dev_priv->irq_received);
35609 + atomic_inc_unchecked(&dev_priv->irq_received);
35610
35611 /* disable master interrupt before clearing iir */
35612 de_ier = I915_READ(DEIER);
35613 @@ -760,7 +760,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35614 int ret = IRQ_NONE;
35615 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
35616
35617 - atomic_inc(&dev_priv->irq_received);
35618 + atomic_inc_unchecked(&dev_priv->irq_received);
35619
35620 /* disable master interrupt before clearing iir */
35621 de_ier = I915_READ(DEIER);
35622 @@ -1787,7 +1787,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35623 {
35624 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35625
35626 - atomic_set(&dev_priv->irq_received, 0);
35627 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35628
35629 I915_WRITE(HWSTAM, 0xeffe);
35630
35631 @@ -1813,7 +1813,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35632 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35633 int pipe;
35634
35635 - atomic_set(&dev_priv->irq_received, 0);
35636 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35637
35638 /* VLV magic */
35639 I915_WRITE(VLV_IMR, 0);
35640 @@ -2108,7 +2108,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35641 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35642 int pipe;
35643
35644 - atomic_set(&dev_priv->irq_received, 0);
35645 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35646
35647 for_each_pipe(pipe)
35648 I915_WRITE(PIPESTAT(pipe), 0);
35649 @@ -2159,7 +2159,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35650 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35651 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35652
35653 - atomic_inc(&dev_priv->irq_received);
35654 + atomic_inc_unchecked(&dev_priv->irq_received);
35655
35656 iir = I915_READ16(IIR);
35657 if (iir == 0)
35658 @@ -2244,7 +2244,7 @@ static void i915_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 if (I915_HAS_HOTPLUG(dev)) {
35666 I915_WRITE(PORT_HOTPLUG_EN, 0);
35667 @@ -2339,7 +2339,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35668 };
35669 int pipe, ret = IRQ_NONE;
35670
35671 - atomic_inc(&dev_priv->irq_received);
35672 + atomic_inc_unchecked(&dev_priv->irq_received);
35673
35674 iir = I915_READ(IIR);
35675 do {
35676 @@ -2465,7 +2465,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35677 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35678 int pipe;
35679
35680 - atomic_set(&dev_priv->irq_received, 0);
35681 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35682
35683 I915_WRITE(PORT_HOTPLUG_EN, 0);
35684 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35685 @@ -2572,7 +2572,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35686 int irq_received;
35687 int ret = IRQ_NONE, pipe;
35688
35689 - atomic_inc(&dev_priv->irq_received);
35690 + atomic_inc_unchecked(&dev_priv->irq_received);
35691
35692 iir = I915_READ(IIR);
35693
35694 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35695 index d3f834a..0ad1b37 100644
35696 --- a/drivers/gpu/drm/i915/intel_display.c
35697 +++ b/drivers/gpu/drm/i915/intel_display.c
35698 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
35699
35700 wait_event(dev_priv->pending_flip_queue,
35701 atomic_read(&dev_priv->mm.wedged) ||
35702 - atomic_read(&obj->pending_flip) == 0);
35703 + atomic_read_unchecked(&obj->pending_flip) == 0);
35704
35705 /* Big Hammer, we also need to ensure that any pending
35706 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
35707 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
35708
35709 obj = work->old_fb_obj;
35710
35711 - atomic_clear_mask(1 << intel_crtc->plane,
35712 - &obj->pending_flip.counter);
35713 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
35714 wake_up(&dev_priv->pending_flip_queue);
35715
35716 queue_work(dev_priv->wq, &work->work);
35717 @@ -7486,7 +7485,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35718 /* Block clients from rendering to the new back buffer until
35719 * the flip occurs and the object is no longer visible.
35720 */
35721 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35722 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35723 atomic_inc(&intel_crtc->unpin_work_count);
35724
35725 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
35726 @@ -7504,7 +7503,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35727 cleanup_pending:
35728 atomic_dec(&intel_crtc->unpin_work_count);
35729 crtc->fb = old_fb;
35730 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35731 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35732 drm_gem_object_unreference(&work->old_fb_obj->base);
35733 drm_gem_object_unreference(&obj->base);
35734 mutex_unlock(&dev->struct_mutex);
35735 @@ -8846,13 +8845,13 @@ struct intel_quirk {
35736 int subsystem_vendor;
35737 int subsystem_device;
35738 void (*hook)(struct drm_device *dev);
35739 -};
35740 +} __do_const;
35741
35742 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35743 struct intel_dmi_quirk {
35744 void (*hook)(struct drm_device *dev);
35745 const struct dmi_system_id (*dmi_id_list)[];
35746 -};
35747 +} __do_const;
35748
35749 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35750 {
35751 @@ -8860,18 +8859,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35752 return 1;
35753 }
35754
35755 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35756 + {
35757 + .callback = intel_dmi_reverse_brightness,
35758 + .ident = "NCR Corporation",
35759 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35760 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35761 + },
35762 + },
35763 + { } /* terminating entry */
35764 +};
35765 +
35766 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35767 {
35768 - .dmi_id_list = &(const struct dmi_system_id[]) {
35769 - {
35770 - .callback = intel_dmi_reverse_brightness,
35771 - .ident = "NCR Corporation",
35772 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35773 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35774 - },
35775 - },
35776 - { } /* terminating entry */
35777 - },
35778 + .dmi_id_list = &intel_dmi_quirks_table,
35779 .hook = quirk_invert_brightness,
35780 },
35781 };
35782 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35783 index 54558a0..2d97005 100644
35784 --- a/drivers/gpu/drm/mga/mga_drv.h
35785 +++ b/drivers/gpu/drm/mga/mga_drv.h
35786 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35787 u32 clear_cmd;
35788 u32 maccess;
35789
35790 - atomic_t vbl_received; /**< Number of vblanks received. */
35791 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35792 wait_queue_head_t fence_queue;
35793 - atomic_t last_fence_retired;
35794 + atomic_unchecked_t last_fence_retired;
35795 u32 next_fence_to_post;
35796
35797 unsigned int fb_cpp;
35798 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35799 index 709e90d..89a1c0d 100644
35800 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35801 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35802 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35803 return 0;
35804 }
35805
35806 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35807 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35808 [DRM_MGA_INIT] = compat_mga_init,
35809 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35810 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35811 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35812 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35813 {
35814 unsigned int nr = DRM_IOCTL_NR(cmd);
35815 - drm_ioctl_compat_t *fn = NULL;
35816 int ret;
35817
35818 if (nr < DRM_COMMAND_BASE)
35819 return drm_compat_ioctl(filp, cmd, arg);
35820
35821 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35822 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35823 -
35824 - if (fn != NULL)
35825 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35826 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35827 ret = (*fn) (filp, cmd, arg);
35828 - else
35829 + } else
35830 ret = drm_ioctl(filp, cmd, arg);
35831
35832 return ret;
35833 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35834 index 598c281..60d590e 100644
35835 --- a/drivers/gpu/drm/mga/mga_irq.c
35836 +++ b/drivers/gpu/drm/mga/mga_irq.c
35837 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35838 if (crtc != 0)
35839 return 0;
35840
35841 - return atomic_read(&dev_priv->vbl_received);
35842 + return atomic_read_unchecked(&dev_priv->vbl_received);
35843 }
35844
35845
35846 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35847 /* VBLANK interrupt */
35848 if (status & MGA_VLINEPEN) {
35849 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35850 - atomic_inc(&dev_priv->vbl_received);
35851 + atomic_inc_unchecked(&dev_priv->vbl_received);
35852 drm_handle_vblank(dev, 0);
35853 handled = 1;
35854 }
35855 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35856 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35857 MGA_WRITE(MGA_PRIMEND, prim_end);
35858
35859 - atomic_inc(&dev_priv->last_fence_retired);
35860 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35861 DRM_WAKEUP(&dev_priv->fence_queue);
35862 handled = 1;
35863 }
35864 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35865 * using fences.
35866 */
35867 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35868 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35869 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35870 - *sequence) <= (1 << 23)));
35871
35872 *sequence = cur_fence;
35873 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35874 index 865eddf..62c4cc3 100644
35875 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35876 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35877 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35878 struct bit_table {
35879 const char id;
35880 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35881 -};
35882 +} __no_const;
35883
35884 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35885
35886 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35887 index aa89eb9..d45d38b 100644
35888 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35889 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35890 @@ -80,7 +80,7 @@ struct nouveau_drm {
35891 struct drm_global_reference mem_global_ref;
35892 struct ttm_bo_global_ref bo_global_ref;
35893 struct ttm_bo_device bdev;
35894 - atomic_t validate_sequence;
35895 + atomic_unchecked_t validate_sequence;
35896 int (*move)(struct nouveau_channel *,
35897 struct ttm_buffer_object *,
35898 struct ttm_mem_reg *, struct ttm_mem_reg *);
35899 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
35900 index cdb83ac..27f0a16 100644
35901 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
35902 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
35903 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
35904 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
35905 struct nouveau_channel *);
35906 u32 (*read)(struct nouveau_channel *);
35907 -};
35908 +} __no_const;
35909
35910 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
35911
35912 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35913 index 8bf695c..9fbc90a 100644
35914 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35915 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35916 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35917 int trycnt = 0;
35918 int ret, i;
35919
35920 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35921 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35922 retry:
35923 if (++trycnt > 100000) {
35924 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
35925 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35926 index 08214bc..9208577 100644
35927 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35928 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35929 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35930 unsigned long arg)
35931 {
35932 unsigned int nr = DRM_IOCTL_NR(cmd);
35933 - drm_ioctl_compat_t *fn = NULL;
35934 + drm_ioctl_compat_t fn = NULL;
35935 int ret;
35936
35937 if (nr < DRM_COMMAND_BASE)
35938 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35939 index 25d3495..d81aaf6 100644
35940 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35941 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35942 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35943 bool can_switch;
35944
35945 spin_lock(&dev->count_lock);
35946 - can_switch = (dev->open_count == 0);
35947 + can_switch = (local_read(&dev->open_count) == 0);
35948 spin_unlock(&dev->count_lock);
35949 return can_switch;
35950 }
35951 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35952 index d4660cf..70dbe65 100644
35953 --- a/drivers/gpu/drm/r128/r128_cce.c
35954 +++ b/drivers/gpu/drm/r128/r128_cce.c
35955 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35956
35957 /* GH: Simple idle check.
35958 */
35959 - atomic_set(&dev_priv->idle_count, 0);
35960 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35961
35962 /* We don't support anything other than bus-mastering ring mode,
35963 * but the ring can be in either AGP or PCI space for the ring
35964 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35965 index 930c71b..499aded 100644
35966 --- a/drivers/gpu/drm/r128/r128_drv.h
35967 +++ b/drivers/gpu/drm/r128/r128_drv.h
35968 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35969 int is_pci;
35970 unsigned long cce_buffers_offset;
35971
35972 - atomic_t idle_count;
35973 + atomic_unchecked_t idle_count;
35974
35975 int page_flipping;
35976 int current_page;
35977 u32 crtc_offset;
35978 u32 crtc_offset_cntl;
35979
35980 - atomic_t vbl_received;
35981 + atomic_unchecked_t vbl_received;
35982
35983 u32 color_fmt;
35984 unsigned int front_offset;
35985 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35986 index a954c54..9cc595c 100644
35987 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35988 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35989 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35990 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35991 }
35992
35993 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35994 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35995 [DRM_R128_INIT] = compat_r128_init,
35996 [DRM_R128_DEPTH] = compat_r128_depth,
35997 [DRM_R128_STIPPLE] = compat_r128_stipple,
35998 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35999 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36000 {
36001 unsigned int nr = DRM_IOCTL_NR(cmd);
36002 - drm_ioctl_compat_t *fn = NULL;
36003 int ret;
36004
36005 if (nr < DRM_COMMAND_BASE)
36006 return drm_compat_ioctl(filp, cmd, arg);
36007
36008 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36009 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36010 -
36011 - if (fn != NULL)
36012 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36013 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36014 ret = (*fn) (filp, cmd, arg);
36015 - else
36016 + } else
36017 ret = drm_ioctl(filp, cmd, arg);
36018
36019 return ret;
36020 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36021 index 2ea4f09..d391371 100644
36022 --- a/drivers/gpu/drm/r128/r128_irq.c
36023 +++ b/drivers/gpu/drm/r128/r128_irq.c
36024 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36025 if (crtc != 0)
36026 return 0;
36027
36028 - return atomic_read(&dev_priv->vbl_received);
36029 + return atomic_read_unchecked(&dev_priv->vbl_received);
36030 }
36031
36032 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36033 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36034 /* VBLANK interrupt */
36035 if (status & R128_CRTC_VBLANK_INT) {
36036 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36037 - atomic_inc(&dev_priv->vbl_received);
36038 + atomic_inc_unchecked(&dev_priv->vbl_received);
36039 drm_handle_vblank(dev, 0);
36040 return IRQ_HANDLED;
36041 }
36042 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36043 index 19bb7e6..de7e2a2 100644
36044 --- a/drivers/gpu/drm/r128/r128_state.c
36045 +++ b/drivers/gpu/drm/r128/r128_state.c
36046 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36047
36048 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36049 {
36050 - if (atomic_read(&dev_priv->idle_count) == 0)
36051 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36052 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36053 else
36054 - atomic_set(&dev_priv->idle_count, 0);
36055 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36056 }
36057
36058 #endif
36059 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36060 index 5a82b6b..9e69c73 100644
36061 --- a/drivers/gpu/drm/radeon/mkregtable.c
36062 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36063 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36064 regex_t mask_rex;
36065 regmatch_t match[4];
36066 char buf[1024];
36067 - size_t end;
36068 + long end;
36069 int len;
36070 int done = 0;
36071 int r;
36072 unsigned o;
36073 struct offset *offset;
36074 char last_reg_s[10];
36075 - int last_reg;
36076 + unsigned long last_reg;
36077
36078 if (regcomp
36079 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36080 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36081 index 0d6562b..a154330 100644
36082 --- a/drivers/gpu/drm/radeon/radeon_device.c
36083 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36084 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36085 bool can_switch;
36086
36087 spin_lock(&dev->count_lock);
36088 - can_switch = (dev->open_count == 0);
36089 + can_switch = (local_read(&dev->open_count) == 0);
36090 spin_unlock(&dev->count_lock);
36091 return can_switch;
36092 }
36093 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36094 index e7fdf16..f4f6490 100644
36095 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36096 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36097 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
36098
36099 /* SW interrupt */
36100 wait_queue_head_t swi_queue;
36101 - atomic_t swi_emitted;
36102 + atomic_unchecked_t swi_emitted;
36103 int vblank_crtc;
36104 uint32_t irq_enable_reg;
36105 uint32_t r500_disp_irq_reg;
36106 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36107 index c180df8..5fd8186 100644
36108 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36109 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36110 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36111 request = compat_alloc_user_space(sizeof(*request));
36112 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36113 || __put_user(req32.param, &request->param)
36114 - || __put_user((void __user *)(unsigned long)req32.value,
36115 + || __put_user((unsigned long)req32.value,
36116 &request->value))
36117 return -EFAULT;
36118
36119 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36120 #define compat_radeon_cp_setparam NULL
36121 #endif /* X86_64 || IA64 */
36122
36123 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36124 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36125 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36126 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36127 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36128 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36129 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36130 {
36131 unsigned int nr = DRM_IOCTL_NR(cmd);
36132 - drm_ioctl_compat_t *fn = NULL;
36133 int ret;
36134
36135 if (nr < DRM_COMMAND_BASE)
36136 return drm_compat_ioctl(filp, cmd, arg);
36137
36138 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36139 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36140 -
36141 - if (fn != NULL)
36142 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36143 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36144 ret = (*fn) (filp, cmd, arg);
36145 - else
36146 + } else
36147 ret = drm_ioctl(filp, cmd, arg);
36148
36149 return ret;
36150 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36151 index e771033..a0bc6b3 100644
36152 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36153 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36154 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36155 unsigned int ret;
36156 RING_LOCALS;
36157
36158 - atomic_inc(&dev_priv->swi_emitted);
36159 - ret = atomic_read(&dev_priv->swi_emitted);
36160 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36161 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36162
36163 BEGIN_RING(4);
36164 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36165 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36166 drm_radeon_private_t *dev_priv =
36167 (drm_radeon_private_t *) dev->dev_private;
36168
36169 - atomic_set(&dev_priv->swi_emitted, 0);
36170 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36171 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36172
36173 dev->max_vblank_count = 0x001fffff;
36174 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36175 index 8e9057b..af6dacb 100644
36176 --- a/drivers/gpu/drm/radeon/radeon_state.c
36177 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36178 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36179 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36180 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36181
36182 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36183 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36184 sarea_priv->nbox * sizeof(depth_boxes[0])))
36185 return -EFAULT;
36186
36187 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36188 {
36189 drm_radeon_private_t *dev_priv = dev->dev_private;
36190 drm_radeon_getparam_t *param = data;
36191 - int value;
36192 + int value = 0;
36193
36194 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36195
36196 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36197 index 93f760e..8088227 100644
36198 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36199 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36200 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36201 man->size = size >> PAGE_SHIFT;
36202 }
36203
36204 -static struct vm_operations_struct radeon_ttm_vm_ops;
36205 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36206 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36207
36208 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36209 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36210 }
36211 if (unlikely(ttm_vm_ops == NULL)) {
36212 ttm_vm_ops = vma->vm_ops;
36213 + pax_open_kernel();
36214 radeon_ttm_vm_ops = *ttm_vm_ops;
36215 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36216 + pax_close_kernel();
36217 }
36218 vma->vm_ops = &radeon_ttm_vm_ops;
36219 return 0;
36220 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36221 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36222 else
36223 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36224 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36225 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36226 - radeon_mem_types_list[i].driver_features = 0;
36227 + pax_open_kernel();
36228 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36229 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36230 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36231 if (i == 0)
36232 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36233 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36234 else
36235 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36236 -
36237 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36238 + pax_close_kernel();
36239 }
36240 /* Add ttm page pool to debugfs */
36241 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36242 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36243 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36244 - radeon_mem_types_list[i].driver_features = 0;
36245 - radeon_mem_types_list[i++].data = NULL;
36246 + pax_open_kernel();
36247 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36248 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36249 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36250 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36251 + pax_close_kernel();
36252 #ifdef CONFIG_SWIOTLB
36253 if (swiotlb_nr_tbl()) {
36254 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36255 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36256 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36257 - radeon_mem_types_list[i].driver_features = 0;
36258 - radeon_mem_types_list[i++].data = NULL;
36259 + pax_open_kernel();
36260 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36261 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36262 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36263 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36264 + pax_close_kernel();
36265 }
36266 #endif
36267 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36268 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36269 index 5706d2a..17aedaa 100644
36270 --- a/drivers/gpu/drm/radeon/rs690.c
36271 +++ b/drivers/gpu/drm/radeon/rs690.c
36272 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36273 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36274 rdev->pm.sideport_bandwidth.full)
36275 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36276 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36277 + read_delay_latency.full = dfixed_const(800 * 1000);
36278 read_delay_latency.full = dfixed_div(read_delay_latency,
36279 rdev->pm.igp_sideport_mclk);
36280 + a.full = dfixed_const(370);
36281 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36282 } else {
36283 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36284 rdev->pm.k8_bandwidth.full)
36285 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36286 index bd2a3b4..122d9ad 100644
36287 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36288 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36289 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36290 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36291 struct shrink_control *sc)
36292 {
36293 - static atomic_t start_pool = ATOMIC_INIT(0);
36294 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36295 unsigned i;
36296 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36297 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36298 struct ttm_page_pool *pool;
36299 int shrink_pages = sc->nr_to_scan;
36300
36301 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36302 index 1eb060c..188b1fc 100644
36303 --- a/drivers/gpu/drm/udl/udl_fb.c
36304 +++ b/drivers/gpu/drm/udl/udl_fb.c
36305 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36306 fb_deferred_io_cleanup(info);
36307 kfree(info->fbdefio);
36308 info->fbdefio = NULL;
36309 - info->fbops->fb_mmap = udl_fb_mmap;
36310 }
36311
36312 pr_warn("released /dev/fb%d user=%d count=%d\n",
36313 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36314 index 893a650..6190d3b 100644
36315 --- a/drivers/gpu/drm/via/via_drv.h
36316 +++ b/drivers/gpu/drm/via/via_drv.h
36317 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36318 typedef uint32_t maskarray_t[5];
36319
36320 typedef struct drm_via_irq {
36321 - atomic_t irq_received;
36322 + atomic_unchecked_t irq_received;
36323 uint32_t pending_mask;
36324 uint32_t enable_mask;
36325 wait_queue_head_t irq_queue;
36326 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36327 struct timeval last_vblank;
36328 int last_vblank_valid;
36329 unsigned usec_per_vblank;
36330 - atomic_t vbl_received;
36331 + atomic_unchecked_t vbl_received;
36332 drm_via_state_t hc_state;
36333 char pci_buf[VIA_PCI_BUF_SIZE];
36334 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36335 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36336 index ac98964..5dbf512 100644
36337 --- a/drivers/gpu/drm/via/via_irq.c
36338 +++ b/drivers/gpu/drm/via/via_irq.c
36339 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36340 if (crtc != 0)
36341 return 0;
36342
36343 - return atomic_read(&dev_priv->vbl_received);
36344 + return atomic_read_unchecked(&dev_priv->vbl_received);
36345 }
36346
36347 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36348 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36349
36350 status = VIA_READ(VIA_REG_INTERRUPT);
36351 if (status & VIA_IRQ_VBLANK_PENDING) {
36352 - atomic_inc(&dev_priv->vbl_received);
36353 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36354 + atomic_inc_unchecked(&dev_priv->vbl_received);
36355 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36356 do_gettimeofday(&cur_vblank);
36357 if (dev_priv->last_vblank_valid) {
36358 dev_priv->usec_per_vblank =
36359 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36360 dev_priv->last_vblank = cur_vblank;
36361 dev_priv->last_vblank_valid = 1;
36362 }
36363 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36364 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36365 DRM_DEBUG("US per vblank is: %u\n",
36366 dev_priv->usec_per_vblank);
36367 }
36368 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36369
36370 for (i = 0; i < dev_priv->num_irqs; ++i) {
36371 if (status & cur_irq->pending_mask) {
36372 - atomic_inc(&cur_irq->irq_received);
36373 + atomic_inc_unchecked(&cur_irq->irq_received);
36374 DRM_WAKEUP(&cur_irq->irq_queue);
36375 handled = 1;
36376 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36377 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36378 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36379 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36380 masks[irq][4]));
36381 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36382 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36383 } else {
36384 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36385 (((cur_irq_sequence =
36386 - atomic_read(&cur_irq->irq_received)) -
36387 + atomic_read_unchecked(&cur_irq->irq_received)) -
36388 *sequence) <= (1 << 23)));
36389 }
36390 *sequence = cur_irq_sequence;
36391 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36392 }
36393
36394 for (i = 0; i < dev_priv->num_irqs; ++i) {
36395 - atomic_set(&cur_irq->irq_received, 0);
36396 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36397 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36398 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36399 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36400 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36401 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36402 case VIA_IRQ_RELATIVE:
36403 irqwait->request.sequence +=
36404 - atomic_read(&cur_irq->irq_received);
36405 + atomic_read_unchecked(&cur_irq->irq_received);
36406 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36407 case VIA_IRQ_ABSOLUTE:
36408 break;
36409 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36410 index 13aeda7..4a952d1 100644
36411 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36412 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36413 @@ -290,7 +290,7 @@ struct vmw_private {
36414 * Fencing and IRQs.
36415 */
36416
36417 - atomic_t marker_seq;
36418 + atomic_unchecked_t marker_seq;
36419 wait_queue_head_t fence_queue;
36420 wait_queue_head_t fifo_queue;
36421 int fence_queue_waiters; /* Protected by hw_mutex */
36422 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36423 index 3eb1486..0a47ee9 100644
36424 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36425 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36426 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36427 (unsigned int) min,
36428 (unsigned int) fifo->capabilities);
36429
36430 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36431 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36432 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36433 vmw_marker_queue_init(&fifo->marker_queue);
36434 return vmw_fifo_send_fence(dev_priv, &dummy);
36435 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36436 if (reserveable)
36437 iowrite32(bytes, fifo_mem +
36438 SVGA_FIFO_RESERVED);
36439 - return fifo_mem + (next_cmd >> 2);
36440 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36441 } else {
36442 need_bounce = true;
36443 }
36444 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36445
36446 fm = vmw_fifo_reserve(dev_priv, bytes);
36447 if (unlikely(fm == NULL)) {
36448 - *seqno = atomic_read(&dev_priv->marker_seq);
36449 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36450 ret = -ENOMEM;
36451 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36452 false, 3*HZ);
36453 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36454 }
36455
36456 do {
36457 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36458 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36459 } while (*seqno == 0);
36460
36461 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36462 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36463 index 4640adb..e1384ed 100644
36464 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36465 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36466 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36467 * emitted. Then the fence is stale and signaled.
36468 */
36469
36470 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36471 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36472 > VMW_FENCE_WRAP);
36473
36474 return ret;
36475 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36476
36477 if (fifo_idle)
36478 down_read(&fifo_state->rwsem);
36479 - signal_seq = atomic_read(&dev_priv->marker_seq);
36480 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36481 ret = 0;
36482
36483 for (;;) {
36484 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36485 index 8a8725c..afed796 100644
36486 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36487 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36488 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36489 while (!vmw_lag_lt(queue, us)) {
36490 spin_lock(&queue->lock);
36491 if (list_empty(&queue->head))
36492 - seqno = atomic_read(&dev_priv->marker_seq);
36493 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36494 else {
36495 marker = list_first_entry(&queue->head,
36496 struct vmw_marker, head);
36497 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36498 index ceb3040..6160c5c 100644
36499 --- a/drivers/hid/hid-core.c
36500 +++ b/drivers/hid/hid-core.c
36501 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36502
36503 int hid_add_device(struct hid_device *hdev)
36504 {
36505 - static atomic_t id = ATOMIC_INIT(0);
36506 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36507 int ret;
36508
36509 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36510 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
36511 /* XXX hack, any other cleaner solution after the driver core
36512 * is converted to allow more than 20 bytes as the device name? */
36513 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36514 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36515 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36516
36517 hid_debug_register(hdev, dev_name(&hdev->dev));
36518 ret = device_add(&hdev->dev);
36519 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36520 index eec3291..8ed706b 100644
36521 --- a/drivers/hid/hid-wiimote-debug.c
36522 +++ b/drivers/hid/hid-wiimote-debug.c
36523 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36524 else if (size == 0)
36525 return -EIO;
36526
36527 - if (copy_to_user(u, buf, size))
36528 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36529 return -EFAULT;
36530
36531 *off += size;
36532 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36533 index 773a2f2..7ce08bc 100644
36534 --- a/drivers/hv/channel.c
36535 +++ b/drivers/hv/channel.c
36536 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36537 int ret = 0;
36538 int t;
36539
36540 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36541 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36542 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36543 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36544
36545 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36546 if (ret)
36547 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36548 index 3648f8f..30ef30d 100644
36549 --- a/drivers/hv/hv.c
36550 +++ b/drivers/hv/hv.c
36551 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36552 u64 output_address = (output) ? virt_to_phys(output) : 0;
36553 u32 output_address_hi = output_address >> 32;
36554 u32 output_address_lo = output_address & 0xFFFFFFFF;
36555 - void *hypercall_page = hv_context.hypercall_page;
36556 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36557
36558 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36559 "=a"(hv_status_lo) : "d" (control_hi),
36560 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36561 index d8d1fad..b91caf7 100644
36562 --- a/drivers/hv/hyperv_vmbus.h
36563 +++ b/drivers/hv/hyperv_vmbus.h
36564 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
36565 struct vmbus_connection {
36566 enum vmbus_connect_state conn_state;
36567
36568 - atomic_t next_gpadl_handle;
36569 + atomic_unchecked_t next_gpadl_handle;
36570
36571 /*
36572 * Represents channel interrupts. Each bit position represents a
36573 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36574 index 8e1a9ec..4687821 100644
36575 --- a/drivers/hv/vmbus_drv.c
36576 +++ b/drivers/hv/vmbus_drv.c
36577 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36578 {
36579 int ret = 0;
36580
36581 - static atomic_t device_num = ATOMIC_INIT(0);
36582 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36583
36584 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36585 - atomic_inc_return(&device_num));
36586 + atomic_inc_return_unchecked(&device_num));
36587
36588 child_device_obj->device.bus = &hv_bus;
36589 child_device_obj->device.parent = &hv_acpi_dev->dev;
36590 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36591 index 1672e2a..4a6297c 100644
36592 --- a/drivers/hwmon/acpi_power_meter.c
36593 +++ b/drivers/hwmon/acpi_power_meter.c
36594 @@ -117,7 +117,7 @@ struct sensor_template {
36595 struct device_attribute *devattr,
36596 const char *buf, size_t count);
36597 int index;
36598 -};
36599 +} __do_const;
36600
36601 /* Averaging interval */
36602 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36603 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36604 struct sensor_template *attrs)
36605 {
36606 struct device *dev = &resource->acpi_dev->dev;
36607 - struct sensor_device_attribute *sensors =
36608 + sensor_device_attribute_no_const *sensors =
36609 &resource->sensors[resource->num_sensors];
36610 int res = 0;
36611
36612 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36613 index b41baff..4953e4d 100644
36614 --- a/drivers/hwmon/applesmc.c
36615 +++ b/drivers/hwmon/applesmc.c
36616 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36617 {
36618 struct applesmc_node_group *grp;
36619 struct applesmc_dev_attr *node;
36620 - struct attribute *attr;
36621 + attribute_no_const *attr;
36622 int ret, i;
36623
36624 for (grp = groups; grp->format; grp++) {
36625 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36626 index 56dbcfb..9874bf1 100644
36627 --- a/drivers/hwmon/asus_atk0110.c
36628 +++ b/drivers/hwmon/asus_atk0110.c
36629 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36630 struct atk_sensor_data {
36631 struct list_head list;
36632 struct atk_data *data;
36633 - struct device_attribute label_attr;
36634 - struct device_attribute input_attr;
36635 - struct device_attribute limit1_attr;
36636 - struct device_attribute limit2_attr;
36637 + device_attribute_no_const label_attr;
36638 + device_attribute_no_const input_attr;
36639 + device_attribute_no_const limit1_attr;
36640 + device_attribute_no_const limit2_attr;
36641 char label_attr_name[ATTR_NAME_SIZE];
36642 char input_attr_name[ATTR_NAME_SIZE];
36643 char limit1_attr_name[ATTR_NAME_SIZE];
36644 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36645 static struct device_attribute atk_name_attr =
36646 __ATTR(name, 0444, atk_name_show, NULL);
36647
36648 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36649 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36650 sysfs_show_func show)
36651 {
36652 sysfs_attr_init(&attr->attr);
36653 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36654 index d64923d..72591e8 100644
36655 --- a/drivers/hwmon/coretemp.c
36656 +++ b/drivers/hwmon/coretemp.c
36657 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36658 return NOTIFY_OK;
36659 }
36660
36661 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36662 +static struct notifier_block coretemp_cpu_notifier = {
36663 .notifier_call = coretemp_cpu_callback,
36664 };
36665
36666 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36667 index a14f634..2916ee2 100644
36668 --- a/drivers/hwmon/ibmaem.c
36669 +++ b/drivers/hwmon/ibmaem.c
36670 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36671 struct aem_rw_sensor_template *rw)
36672 {
36673 struct device *dev = &data->pdev->dev;
36674 - struct sensor_device_attribute *sensors = data->sensors;
36675 + sensor_device_attribute_no_const *sensors = data->sensors;
36676 int err;
36677
36678 /* Set up read-only sensors */
36679 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36680 index 7d19b1b..8fdaaac 100644
36681 --- a/drivers/hwmon/pmbus/pmbus_core.c
36682 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36683 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
36684
36685 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
36686 do { \
36687 - struct sensor_device_attribute *a \
36688 + sensor_device_attribute_no_const *a \
36689 = &data->_type##s[data->num_##_type##s].attribute; \
36690 BUG_ON(data->num_attributes >= data->max_attributes); \
36691 sysfs_attr_init(&a->dev_attr.attr); \
36692 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36693 index 8047fed..1e956f0 100644
36694 --- a/drivers/hwmon/sht15.c
36695 +++ b/drivers/hwmon/sht15.c
36696 @@ -169,7 +169,7 @@ struct sht15_data {
36697 int supply_uV;
36698 bool supply_uV_valid;
36699 struct work_struct update_supply_work;
36700 - atomic_t interrupt_handled;
36701 + atomic_unchecked_t interrupt_handled;
36702 };
36703
36704 /**
36705 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
36706 return ret;
36707
36708 gpio_direction_input(data->pdata->gpio_data);
36709 - atomic_set(&data->interrupt_handled, 0);
36710 + atomic_set_unchecked(&data->interrupt_handled, 0);
36711
36712 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36713 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36714 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36715 /* Only relevant if the interrupt hasn't occurred. */
36716 - if (!atomic_read(&data->interrupt_handled))
36717 + if (!atomic_read_unchecked(&data->interrupt_handled))
36718 schedule_work(&data->read_work);
36719 }
36720 ret = wait_event_timeout(data->wait_queue,
36721 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36722
36723 /* First disable the interrupt */
36724 disable_irq_nosync(irq);
36725 - atomic_inc(&data->interrupt_handled);
36726 + atomic_inc_unchecked(&data->interrupt_handled);
36727 /* Then schedule a reading work struct */
36728 if (data->state != SHT15_READING_NOTHING)
36729 schedule_work(&data->read_work);
36730 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36731 * If not, then start the interrupt again - care here as could
36732 * have gone low in meantime so verify it hasn't!
36733 */
36734 - atomic_set(&data->interrupt_handled, 0);
36735 + atomic_set_unchecked(&data->interrupt_handled, 0);
36736 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36737 /* If still not occurred or another handler was scheduled */
36738 if (gpio_get_value(data->pdata->gpio_data)
36739 - || atomic_read(&data->interrupt_handled))
36740 + || atomic_read_unchecked(&data->interrupt_handled))
36741 return;
36742 }
36743
36744 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36745 index 76f157b..9c0db1b 100644
36746 --- a/drivers/hwmon/via-cputemp.c
36747 +++ b/drivers/hwmon/via-cputemp.c
36748 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36749 return NOTIFY_OK;
36750 }
36751
36752 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36753 +static struct notifier_block via_cputemp_cpu_notifier = {
36754 .notifier_call = via_cputemp_cpu_callback,
36755 };
36756
36757 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36758 index 378fcb5..5e91fa8 100644
36759 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36760 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36761 @@ -43,7 +43,7 @@
36762 extern struct i2c_adapter amd756_smbus;
36763
36764 static struct i2c_adapter *s4882_adapter;
36765 -static struct i2c_algorithm *s4882_algo;
36766 +static i2c_algorithm_no_const *s4882_algo;
36767
36768 /* Wrapper access functions for multiplexed SMBus */
36769 static DEFINE_MUTEX(amd756_lock);
36770 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36771 index 29015eb..af2d8e9 100644
36772 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36773 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36774 @@ -41,7 +41,7 @@
36775 extern struct i2c_adapter *nforce2_smbus;
36776
36777 static struct i2c_adapter *s4985_adapter;
36778 -static struct i2c_algorithm *s4985_algo;
36779 +static i2c_algorithm_no_const *s4985_algo;
36780
36781 /* Wrapper access functions for multiplexed SMBus */
36782 static DEFINE_MUTEX(nforce2_lock);
36783 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36784 index 8126824..55a2798 100644
36785 --- a/drivers/ide/ide-cd.c
36786 +++ b/drivers/ide/ide-cd.c
36787 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36788 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36789 if ((unsigned long)buf & alignment
36790 || blk_rq_bytes(rq) & q->dma_pad_mask
36791 - || object_is_on_stack(buf))
36792 + || object_starts_on_stack(buf))
36793 drive->dma = 0;
36794 }
36795 }
36796 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36797 index 8848f16..f8e6dd8 100644
36798 --- a/drivers/iio/industrialio-core.c
36799 +++ b/drivers/iio/industrialio-core.c
36800 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36801 }
36802
36803 static
36804 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36805 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36806 const char *postfix,
36807 struct iio_chan_spec const *chan,
36808 ssize_t (*readfunc)(struct device *dev,
36809 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36810 index 394fea2..c833880 100644
36811 --- a/drivers/infiniband/core/cm.c
36812 +++ b/drivers/infiniband/core/cm.c
36813 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36814
36815 struct cm_counter_group {
36816 struct kobject obj;
36817 - atomic_long_t counter[CM_ATTR_COUNT];
36818 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36819 };
36820
36821 struct cm_counter_attribute {
36822 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36823 struct ib_mad_send_buf *msg = NULL;
36824 int ret;
36825
36826 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36827 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36828 counter[CM_REQ_COUNTER]);
36829
36830 /* Quick state check to discard duplicate REQs. */
36831 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36832 if (!cm_id_priv)
36833 return;
36834
36835 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36836 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36837 counter[CM_REP_COUNTER]);
36838 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36839 if (ret)
36840 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
36841 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36842 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36843 spin_unlock_irq(&cm_id_priv->lock);
36844 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36845 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36846 counter[CM_RTU_COUNTER]);
36847 goto out;
36848 }
36849 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
36850 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36851 dreq_msg->local_comm_id);
36852 if (!cm_id_priv) {
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_DREQ_COUNTER]);
36856 cm_issue_drep(work->port, work->mad_recv_wc);
36857 return -EINVAL;
36858 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
36859 case IB_CM_MRA_REP_RCVD:
36860 break;
36861 case IB_CM_TIMEWAIT:
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_DREQ_COUNTER]);
36865 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36866 goto unlock;
36867 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
36868 cm_free_msg(msg);
36869 goto deref;
36870 case IB_CM_DREQ_RCVD:
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_DREQ_COUNTER]);
36874 goto unlock;
36875 default:
36876 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
36877 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36878 cm_id_priv->msg, timeout)) {
36879 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36880 - atomic_long_inc(&work->port->
36881 + atomic_long_inc_unchecked(&work->port->
36882 counter_group[CM_RECV_DUPLICATES].
36883 counter[CM_MRA_COUNTER]);
36884 goto out;
36885 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
36886 break;
36887 case IB_CM_MRA_REQ_RCVD:
36888 case IB_CM_MRA_REP_RCVD:
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_MRA_COUNTER]);
36892 /* fall through */
36893 default:
36894 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
36895 case IB_CM_LAP_IDLE:
36896 break;
36897 case IB_CM_MRA_LAP_SENT:
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_LAP_COUNTER]);
36901 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36902 goto unlock;
36903 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
36904 cm_free_msg(msg);
36905 goto deref;
36906 case IB_CM_LAP_RCVD:
36907 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36908 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36909 counter[CM_LAP_COUNTER]);
36910 goto unlock;
36911 default:
36912 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36913 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36914 if (cur_cm_id_priv) {
36915 spin_unlock_irq(&cm.lock);
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_SIDR_REQ_COUNTER]);
36919 goto out; /* Duplicate message. */
36920 }
36921 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36922 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36923 msg->retries = 1;
36924
36925 - atomic_long_add(1 + msg->retries,
36926 + atomic_long_add_unchecked(1 + msg->retries,
36927 &port->counter_group[CM_XMIT].counter[attr_index]);
36928 if (msg->retries)
36929 - atomic_long_add(msg->retries,
36930 + atomic_long_add_unchecked(msg->retries,
36931 &port->counter_group[CM_XMIT_RETRIES].
36932 counter[attr_index]);
36933
36934 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36935 }
36936
36937 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36938 - atomic_long_inc(&port->counter_group[CM_RECV].
36939 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36940 counter[attr_id - CM_ATTR_ID_OFFSET]);
36941
36942 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36943 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36944 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36945
36946 return sprintf(buf, "%ld\n",
36947 - atomic_long_read(&group->counter[cm_attr->index]));
36948 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36949 }
36950
36951 static const struct sysfs_ops cm_counter_ops = {
36952 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36953 index 176c8f9..2627b62 100644
36954 --- a/drivers/infiniband/core/fmr_pool.c
36955 +++ b/drivers/infiniband/core/fmr_pool.c
36956 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36957
36958 struct task_struct *thread;
36959
36960 - atomic_t req_ser;
36961 - atomic_t flush_ser;
36962 + atomic_unchecked_t req_ser;
36963 + atomic_unchecked_t flush_ser;
36964
36965 wait_queue_head_t force_wait;
36966 };
36967 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36968 struct ib_fmr_pool *pool = pool_ptr;
36969
36970 do {
36971 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36972 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36973 ib_fmr_batch_release(pool);
36974
36975 - atomic_inc(&pool->flush_ser);
36976 + atomic_inc_unchecked(&pool->flush_ser);
36977 wake_up_interruptible(&pool->force_wait);
36978
36979 if (pool->flush_function)
36980 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36981 }
36982
36983 set_current_state(TASK_INTERRUPTIBLE);
36984 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36985 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36986 !kthread_should_stop())
36987 schedule();
36988 __set_current_state(TASK_RUNNING);
36989 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36990 pool->dirty_watermark = params->dirty_watermark;
36991 pool->dirty_len = 0;
36992 spin_lock_init(&pool->pool_lock);
36993 - atomic_set(&pool->req_ser, 0);
36994 - atomic_set(&pool->flush_ser, 0);
36995 + atomic_set_unchecked(&pool->req_ser, 0);
36996 + atomic_set_unchecked(&pool->flush_ser, 0);
36997 init_waitqueue_head(&pool->force_wait);
36998
36999 pool->thread = kthread_run(ib_fmr_cleanup_thread,
37000 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
37001 }
37002 spin_unlock_irq(&pool->pool_lock);
37003
37004 - serial = atomic_inc_return(&pool->req_ser);
37005 + serial = atomic_inc_return_unchecked(&pool->req_ser);
37006 wake_up_process(pool->thread);
37007
37008 if (wait_event_interruptible(pool->force_wait,
37009 - atomic_read(&pool->flush_ser) - serial >= 0))
37010 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37011 return -EINTR;
37012
37013 return 0;
37014 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37015 } else {
37016 list_add_tail(&fmr->list, &pool->dirty_list);
37017 if (++pool->dirty_len >= pool->dirty_watermark) {
37018 - atomic_inc(&pool->req_ser);
37019 + atomic_inc_unchecked(&pool->req_ser);
37020 wake_up_process(pool->thread);
37021 }
37022 }
37023 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37024 index afd8179..598063f 100644
37025 --- a/drivers/infiniband/hw/cxgb4/mem.c
37026 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37027 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37028 int err;
37029 struct fw_ri_tpte tpt;
37030 u32 stag_idx;
37031 - static atomic_t key;
37032 + static atomic_unchecked_t key;
37033
37034 if (c4iw_fatal_error(rdev))
37035 return -EIO;
37036 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37037 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37038 rdev->stats.stag.max = rdev->stats.stag.cur;
37039 mutex_unlock(&rdev->stats.lock);
37040 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37041 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37042 }
37043 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37044 __func__, stag_state, type, pdid, stag_idx);
37045 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37046 index 79b3dbc..96e5fcc 100644
37047 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37048 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37049 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37050 struct ib_atomic_eth *ateth;
37051 struct ipath_ack_entry *e;
37052 u64 vaddr;
37053 - atomic64_t *maddr;
37054 + atomic64_unchecked_t *maddr;
37055 u64 sdata;
37056 u32 rkey;
37057 u8 next;
37058 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37059 IB_ACCESS_REMOTE_ATOMIC)))
37060 goto nack_acc_unlck;
37061 /* Perform atomic OP and save result. */
37062 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37063 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37064 sdata = be64_to_cpu(ateth->swap_data);
37065 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37066 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37067 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37068 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37069 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37070 be64_to_cpu(ateth->compare_data),
37071 sdata);
37072 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37073 index 1f95bba..9530f87 100644
37074 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37075 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37076 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37077 unsigned long flags;
37078 struct ib_wc wc;
37079 u64 sdata;
37080 - atomic64_t *maddr;
37081 + atomic64_unchecked_t *maddr;
37082 enum ib_wc_status send_status;
37083
37084 /*
37085 @@ -382,11 +382,11 @@ again:
37086 IB_ACCESS_REMOTE_ATOMIC)))
37087 goto acc_err;
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 = wqe->wr.wr.atomic.compare_add;
37092 *(u64 *) sqp->s_sge.sge.vaddr =
37093 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_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 sdata, wqe->wr.wr.atomic.swap);
37098 goto send_comp;
37099 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37100 index 9d3e5c1..d9afe4a 100644
37101 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37102 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37103 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37104 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37105 }
37106
37107 -int mthca_QUERY_FW(struct mthca_dev *dev)
37108 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37109 {
37110 struct mthca_mailbox *mailbox;
37111 u32 *outbox;
37112 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37113 index ed9a989..e0c5871 100644
37114 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37115 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37116 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37117 return key;
37118 }
37119
37120 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37121 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37122 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37123 {
37124 struct mthca_mailbox *mailbox;
37125 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37126 index 5b152a3..c1f3e83 100644
37127 --- a/drivers/infiniband/hw/nes/nes.c
37128 +++ b/drivers/infiniband/hw/nes/nes.c
37129 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37130 LIST_HEAD(nes_adapter_list);
37131 static LIST_HEAD(nes_dev_list);
37132
37133 -atomic_t qps_destroyed;
37134 +atomic_unchecked_t qps_destroyed;
37135
37136 static unsigned int ee_flsh_adapter;
37137 static unsigned int sysfs_nonidx_addr;
37138 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37139 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37140 struct nes_adapter *nesadapter = nesdev->nesadapter;
37141
37142 - atomic_inc(&qps_destroyed);
37143 + atomic_inc_unchecked(&qps_destroyed);
37144
37145 /* Free the control structures */
37146
37147 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37148 index 33cc589..3bd6538 100644
37149 --- a/drivers/infiniband/hw/nes/nes.h
37150 +++ b/drivers/infiniband/hw/nes/nes.h
37151 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37152 extern unsigned int wqm_quanta;
37153 extern struct list_head nes_adapter_list;
37154
37155 -extern atomic_t cm_connects;
37156 -extern atomic_t cm_accepts;
37157 -extern atomic_t cm_disconnects;
37158 -extern atomic_t cm_closes;
37159 -extern atomic_t cm_connecteds;
37160 -extern atomic_t cm_connect_reqs;
37161 -extern atomic_t cm_rejects;
37162 -extern atomic_t mod_qp_timouts;
37163 -extern atomic_t qps_created;
37164 -extern atomic_t qps_destroyed;
37165 -extern atomic_t sw_qps_destroyed;
37166 +extern atomic_unchecked_t cm_connects;
37167 +extern atomic_unchecked_t cm_accepts;
37168 +extern atomic_unchecked_t cm_disconnects;
37169 +extern atomic_unchecked_t cm_closes;
37170 +extern atomic_unchecked_t cm_connecteds;
37171 +extern atomic_unchecked_t cm_connect_reqs;
37172 +extern atomic_unchecked_t cm_rejects;
37173 +extern atomic_unchecked_t mod_qp_timouts;
37174 +extern atomic_unchecked_t qps_created;
37175 +extern atomic_unchecked_t qps_destroyed;
37176 +extern atomic_unchecked_t sw_qps_destroyed;
37177 extern u32 mh_detected;
37178 extern u32 mh_pauses_sent;
37179 extern u32 cm_packets_sent;
37180 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37181 extern u32 cm_packets_received;
37182 extern u32 cm_packets_dropped;
37183 extern u32 cm_packets_retrans;
37184 -extern atomic_t cm_listens_created;
37185 -extern atomic_t cm_listens_destroyed;
37186 +extern atomic_unchecked_t cm_listens_created;
37187 +extern atomic_unchecked_t cm_listens_destroyed;
37188 extern u32 cm_backlog_drops;
37189 -extern atomic_t cm_loopbacks;
37190 -extern atomic_t cm_nodes_created;
37191 -extern atomic_t cm_nodes_destroyed;
37192 -extern atomic_t cm_accel_dropped_pkts;
37193 -extern atomic_t cm_resets_recvd;
37194 -extern atomic_t pau_qps_created;
37195 -extern atomic_t pau_qps_destroyed;
37196 +extern atomic_unchecked_t cm_loopbacks;
37197 +extern atomic_unchecked_t cm_nodes_created;
37198 +extern atomic_unchecked_t cm_nodes_destroyed;
37199 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37200 +extern atomic_unchecked_t cm_resets_recvd;
37201 +extern atomic_unchecked_t pau_qps_created;
37202 +extern atomic_unchecked_t pau_qps_destroyed;
37203
37204 extern u32 int_mod_timer_init;
37205 extern u32 int_mod_cq_depth_256;
37206 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37207 index 22ea67e..dcbe3bc 100644
37208 --- a/drivers/infiniband/hw/nes/nes_cm.c
37209 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37210 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37211 u32 cm_packets_retrans;
37212 u32 cm_packets_created;
37213 u32 cm_packets_received;
37214 -atomic_t cm_listens_created;
37215 -atomic_t cm_listens_destroyed;
37216 +atomic_unchecked_t cm_listens_created;
37217 +atomic_unchecked_t cm_listens_destroyed;
37218 u32 cm_backlog_drops;
37219 -atomic_t cm_loopbacks;
37220 -atomic_t cm_nodes_created;
37221 -atomic_t cm_nodes_destroyed;
37222 -atomic_t cm_accel_dropped_pkts;
37223 -atomic_t cm_resets_recvd;
37224 +atomic_unchecked_t cm_loopbacks;
37225 +atomic_unchecked_t cm_nodes_created;
37226 +atomic_unchecked_t cm_nodes_destroyed;
37227 +atomic_unchecked_t cm_accel_dropped_pkts;
37228 +atomic_unchecked_t cm_resets_recvd;
37229
37230 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37231 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37232 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37233
37234 static struct nes_cm_core *g_cm_core;
37235
37236 -atomic_t cm_connects;
37237 -atomic_t cm_accepts;
37238 -atomic_t cm_disconnects;
37239 -atomic_t cm_closes;
37240 -atomic_t cm_connecteds;
37241 -atomic_t cm_connect_reqs;
37242 -atomic_t cm_rejects;
37243 +atomic_unchecked_t cm_connects;
37244 +atomic_unchecked_t cm_accepts;
37245 +atomic_unchecked_t cm_disconnects;
37246 +atomic_unchecked_t cm_closes;
37247 +atomic_unchecked_t cm_connecteds;
37248 +atomic_unchecked_t cm_connect_reqs;
37249 +atomic_unchecked_t cm_rejects;
37250
37251 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37252 {
37253 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37254 kfree(listener);
37255 listener = NULL;
37256 ret = 0;
37257 - atomic_inc(&cm_listens_destroyed);
37258 + atomic_inc_unchecked(&cm_listens_destroyed);
37259 } else {
37260 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37261 }
37262 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37263 cm_node->rem_mac);
37264
37265 add_hte_node(cm_core, cm_node);
37266 - atomic_inc(&cm_nodes_created);
37267 + atomic_inc_unchecked(&cm_nodes_created);
37268
37269 return cm_node;
37270 }
37271 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37272 }
37273
37274 atomic_dec(&cm_core->node_cnt);
37275 - atomic_inc(&cm_nodes_destroyed);
37276 + atomic_inc_unchecked(&cm_nodes_destroyed);
37277 nesqp = cm_node->nesqp;
37278 if (nesqp) {
37279 nesqp->cm_node = NULL;
37280 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37281
37282 static void drop_packet(struct sk_buff *skb)
37283 {
37284 - atomic_inc(&cm_accel_dropped_pkts);
37285 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37286 dev_kfree_skb_any(skb);
37287 }
37288
37289 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37290 {
37291
37292 int reset = 0; /* whether to send reset in case of err.. */
37293 - atomic_inc(&cm_resets_recvd);
37294 + atomic_inc_unchecked(&cm_resets_recvd);
37295 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37296 " refcnt=%d\n", cm_node, cm_node->state,
37297 atomic_read(&cm_node->ref_count));
37298 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37299 rem_ref_cm_node(cm_node->cm_core, cm_node);
37300 return NULL;
37301 }
37302 - atomic_inc(&cm_loopbacks);
37303 + atomic_inc_unchecked(&cm_loopbacks);
37304 loopbackremotenode->loopbackpartner = cm_node;
37305 loopbackremotenode->tcp_cntxt.rcv_wscale =
37306 NES_CM_DEFAULT_RCV_WND_SCALE;
37307 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37308 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37309 else {
37310 rem_ref_cm_node(cm_core, cm_node);
37311 - atomic_inc(&cm_accel_dropped_pkts);
37312 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37313 dev_kfree_skb_any(skb);
37314 }
37315 break;
37316 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37317
37318 if ((cm_id) && (cm_id->event_handler)) {
37319 if (issue_disconn) {
37320 - atomic_inc(&cm_disconnects);
37321 + atomic_inc_unchecked(&cm_disconnects);
37322 cm_event.event = IW_CM_EVENT_DISCONNECT;
37323 cm_event.status = disconn_status;
37324 cm_event.local_addr = cm_id->local_addr;
37325 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37326 }
37327
37328 if (issue_close) {
37329 - atomic_inc(&cm_closes);
37330 + atomic_inc_unchecked(&cm_closes);
37331 nes_disconnect(nesqp, 1);
37332
37333 cm_id->provider_data = nesqp;
37334 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37335
37336 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37337 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37338 - atomic_inc(&cm_accepts);
37339 + atomic_inc_unchecked(&cm_accepts);
37340
37341 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37342 netdev_refcnt_read(nesvnic->netdev));
37343 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37344 struct nes_cm_core *cm_core;
37345 u8 *start_buff;
37346
37347 - atomic_inc(&cm_rejects);
37348 + atomic_inc_unchecked(&cm_rejects);
37349 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37350 loopback = cm_node->loopbackpartner;
37351 cm_core = cm_node->cm_core;
37352 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37353 ntohl(cm_id->local_addr.sin_addr.s_addr),
37354 ntohs(cm_id->local_addr.sin_port));
37355
37356 - atomic_inc(&cm_connects);
37357 + atomic_inc_unchecked(&cm_connects);
37358 nesqp->active_conn = 1;
37359
37360 /* cache the cm_id in the qp */
37361 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37362 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37363 return err;
37364 }
37365 - atomic_inc(&cm_listens_created);
37366 + atomic_inc_unchecked(&cm_listens_created);
37367 }
37368
37369 cm_id->add_ref(cm_id);
37370 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37371
37372 if (nesqp->destroyed)
37373 return;
37374 - atomic_inc(&cm_connecteds);
37375 + atomic_inc_unchecked(&cm_connecteds);
37376 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37377 " local port 0x%04X. jiffies = %lu.\n",
37378 nesqp->hwqp.qp_id,
37379 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37380
37381 cm_id->add_ref(cm_id);
37382 ret = cm_id->event_handler(cm_id, &cm_event);
37383 - atomic_inc(&cm_closes);
37384 + atomic_inc_unchecked(&cm_closes);
37385 cm_event.event = IW_CM_EVENT_CLOSE;
37386 cm_event.status = 0;
37387 cm_event.provider_data = cm_id->provider_data;
37388 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37389 return;
37390 cm_id = cm_node->cm_id;
37391
37392 - atomic_inc(&cm_connect_reqs);
37393 + atomic_inc_unchecked(&cm_connect_reqs);
37394 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37395 cm_node, cm_id, jiffies);
37396
37397 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37398 return;
37399 cm_id = cm_node->cm_id;
37400
37401 - atomic_inc(&cm_connect_reqs);
37402 + atomic_inc_unchecked(&cm_connect_reqs);
37403 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37404 cm_node, cm_id, jiffies);
37405
37406 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37407 index 4166452..fc952c3 100644
37408 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37409 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37410 @@ -40,8 +40,8 @@
37411 #include "nes.h"
37412 #include "nes_mgt.h"
37413
37414 -atomic_t pau_qps_created;
37415 -atomic_t pau_qps_destroyed;
37416 +atomic_unchecked_t pau_qps_created;
37417 +atomic_unchecked_t pau_qps_destroyed;
37418
37419 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37420 {
37421 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37422 {
37423 struct sk_buff *skb;
37424 unsigned long flags;
37425 - atomic_inc(&pau_qps_destroyed);
37426 + atomic_inc_unchecked(&pau_qps_destroyed);
37427
37428 /* Free packets that have not yet been forwarded */
37429 /* Lock is acquired by skb_dequeue when removing the skb */
37430 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37431 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37432 skb_queue_head_init(&nesqp->pau_list);
37433 spin_lock_init(&nesqp->pau_lock);
37434 - atomic_inc(&pau_qps_created);
37435 + atomic_inc_unchecked(&pau_qps_created);
37436 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37437 }
37438
37439 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37440 index 9542e16..a008c40 100644
37441 --- a/drivers/infiniband/hw/nes/nes_nic.c
37442 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37443 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37444 target_stat_values[++index] = mh_detected;
37445 target_stat_values[++index] = mh_pauses_sent;
37446 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37447 - target_stat_values[++index] = atomic_read(&cm_connects);
37448 - target_stat_values[++index] = atomic_read(&cm_accepts);
37449 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37450 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37451 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37452 - target_stat_values[++index] = atomic_read(&cm_rejects);
37453 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37454 - target_stat_values[++index] = atomic_read(&qps_created);
37455 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37456 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37457 - target_stat_values[++index] = atomic_read(&cm_closes);
37458 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37459 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37460 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37461 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37462 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37463 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37464 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37465 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37466 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37467 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37468 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37469 target_stat_values[++index] = cm_packets_sent;
37470 target_stat_values[++index] = cm_packets_bounced;
37471 target_stat_values[++index] = cm_packets_created;
37472 target_stat_values[++index] = cm_packets_received;
37473 target_stat_values[++index] = cm_packets_dropped;
37474 target_stat_values[++index] = cm_packets_retrans;
37475 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37476 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37477 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37478 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37479 target_stat_values[++index] = cm_backlog_drops;
37480 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37481 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37482 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37483 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37484 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37485 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37486 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37487 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37488 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37489 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37490 target_stat_values[++index] = nesadapter->free_4kpbl;
37491 target_stat_values[++index] = nesadapter->free_256pbl;
37492 target_stat_values[++index] = int_mod_timer_init;
37493 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37494 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37495 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37496 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37497 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37498 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37499 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37500 }
37501
37502 /**
37503 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37504 index 07e4fba..685f041 100644
37505 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37506 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37507 @@ -46,9 +46,9 @@
37508
37509 #include <rdma/ib_umem.h>
37510
37511 -atomic_t mod_qp_timouts;
37512 -atomic_t qps_created;
37513 -atomic_t sw_qps_destroyed;
37514 +atomic_unchecked_t mod_qp_timouts;
37515 +atomic_unchecked_t qps_created;
37516 +atomic_unchecked_t sw_qps_destroyed;
37517
37518 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37519
37520 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37521 if (init_attr->create_flags)
37522 return ERR_PTR(-EINVAL);
37523
37524 - atomic_inc(&qps_created);
37525 + atomic_inc_unchecked(&qps_created);
37526 switch (init_attr->qp_type) {
37527 case IB_QPT_RC:
37528 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37529 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37530 struct iw_cm_event cm_event;
37531 int ret = 0;
37532
37533 - atomic_inc(&sw_qps_destroyed);
37534 + atomic_inc_unchecked(&sw_qps_destroyed);
37535 nesqp->destroyed = 1;
37536
37537 /* Blow away the connection if it exists. */
37538 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37539 index 4d11575..3e890e5 100644
37540 --- a/drivers/infiniband/hw/qib/qib.h
37541 +++ b/drivers/infiniband/hw/qib/qib.h
37542 @@ -51,6 +51,7 @@
37543 #include <linux/completion.h>
37544 #include <linux/kref.h>
37545 #include <linux/sched.h>
37546 +#include <linux/slab.h>
37547
37548 #include "qib_common.h"
37549 #include "qib_verbs.h"
37550 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37551 index da739d9..da1c7f4 100644
37552 --- a/drivers/input/gameport/gameport.c
37553 +++ b/drivers/input/gameport/gameport.c
37554 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37555 */
37556 static void gameport_init_port(struct gameport *gameport)
37557 {
37558 - static atomic_t gameport_no = ATOMIC_INIT(0);
37559 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37560
37561 __module_get(THIS_MODULE);
37562
37563 mutex_init(&gameport->drv_mutex);
37564 device_initialize(&gameport->dev);
37565 dev_set_name(&gameport->dev, "gameport%lu",
37566 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37567 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37568 gameport->dev.bus = &gameport_bus;
37569 gameport->dev.release = gameport_release_port;
37570 if (gameport->parent)
37571 diff --git a/drivers/input/input.c b/drivers/input/input.c
37572 index c044699..174d71a 100644
37573 --- a/drivers/input/input.c
37574 +++ b/drivers/input/input.c
37575 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37576 */
37577 int input_register_device(struct input_dev *dev)
37578 {
37579 - static atomic_t input_no = ATOMIC_INIT(0);
37580 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37581 struct input_devres *devres = NULL;
37582 struct input_handler *handler;
37583 unsigned int packet_size;
37584 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37585 dev->setkeycode = input_default_setkeycode;
37586
37587 dev_set_name(&dev->dev, "input%ld",
37588 - (unsigned long) atomic_inc_return(&input_no) - 1);
37589 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37590
37591 error = device_add(&dev->dev);
37592 if (error)
37593 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37594 index 04c69af..5f92d00 100644
37595 --- a/drivers/input/joystick/sidewinder.c
37596 +++ b/drivers/input/joystick/sidewinder.c
37597 @@ -30,6 +30,7 @@
37598 #include <linux/kernel.h>
37599 #include <linux/module.h>
37600 #include <linux/slab.h>
37601 +#include <linux/sched.h>
37602 #include <linux/init.h>
37603 #include <linux/input.h>
37604 #include <linux/gameport.h>
37605 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37606 index d6cbfe9..6225402 100644
37607 --- a/drivers/input/joystick/xpad.c
37608 +++ b/drivers/input/joystick/xpad.c
37609 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37610
37611 static int xpad_led_probe(struct usb_xpad *xpad)
37612 {
37613 - static atomic_t led_seq = ATOMIC_INIT(0);
37614 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37615 long led_no;
37616 struct xpad_led *led;
37617 struct led_classdev *led_cdev;
37618 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37619 if (!led)
37620 return -ENOMEM;
37621
37622 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37623 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37624
37625 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37626 led->xpad = xpad;
37627 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37628 index fe1df23..5b710f3 100644
37629 --- a/drivers/input/mouse/psmouse.h
37630 +++ b/drivers/input/mouse/psmouse.h
37631 @@ -115,7 +115,7 @@ struct psmouse_attribute {
37632 ssize_t (*set)(struct psmouse *psmouse, void *data,
37633 const char *buf, size_t count);
37634 bool protect;
37635 -};
37636 +} __do_const;
37637 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37638
37639 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37640 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37641 index 4c842c3..590b0bf 100644
37642 --- a/drivers/input/mousedev.c
37643 +++ b/drivers/input/mousedev.c
37644 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37645
37646 spin_unlock_irq(&client->packet_lock);
37647
37648 - if (copy_to_user(buffer, data, count))
37649 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37650 return -EFAULT;
37651
37652 return count;
37653 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37654 index 25fc597..558bf3b 100644
37655 --- a/drivers/input/serio/serio.c
37656 +++ b/drivers/input/serio/serio.c
37657 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37658 */
37659 static void serio_init_port(struct serio *serio)
37660 {
37661 - static atomic_t serio_no = ATOMIC_INIT(0);
37662 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37663
37664 __module_get(THIS_MODULE);
37665
37666 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37667 mutex_init(&serio->drv_mutex);
37668 device_initialize(&serio->dev);
37669 dev_set_name(&serio->dev, "serio%ld",
37670 - (long)atomic_inc_return(&serio_no) - 1);
37671 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37672 serio->dev.bus = &serio_bus;
37673 serio->dev.release = serio_release_port;
37674 serio->dev.groups = serio_device_attr_groups;
37675 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37676 index ddbdaca..be18a78 100644
37677 --- a/drivers/iommu/iommu.c
37678 +++ b/drivers/iommu/iommu.c
37679 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37680 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37681 {
37682 bus_register_notifier(bus, &iommu_bus_nb);
37683 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37684 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37685 }
37686
37687 /**
37688 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37689 index 89562a8..218999b 100644
37690 --- a/drivers/isdn/capi/capi.c
37691 +++ b/drivers/isdn/capi/capi.c
37692 @@ -81,8 +81,8 @@ struct capiminor {
37693
37694 struct capi20_appl *ap;
37695 u32 ncci;
37696 - atomic_t datahandle;
37697 - atomic_t msgid;
37698 + atomic_unchecked_t datahandle;
37699 + atomic_unchecked_t msgid;
37700
37701 struct tty_port port;
37702 int ttyinstop;
37703 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37704 capimsg_setu16(s, 2, mp->ap->applid);
37705 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37706 capimsg_setu8 (s, 5, CAPI_RESP);
37707 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37708 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37709 capimsg_setu32(s, 8, mp->ncci);
37710 capimsg_setu16(s, 12, datahandle);
37711 }
37712 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37713 mp->outbytes -= len;
37714 spin_unlock_bh(&mp->outlock);
37715
37716 - datahandle = atomic_inc_return(&mp->datahandle);
37717 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37718 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37719 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37720 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37721 capimsg_setu16(skb->data, 2, mp->ap->applid);
37722 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37723 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37724 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37725 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37726 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37727 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37728 capimsg_setu16(skb->data, 16, len); /* Data length */
37729 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37730 index 67abf3f..076b3a6 100644
37731 --- a/drivers/isdn/gigaset/interface.c
37732 +++ b/drivers/isdn/gigaset/interface.c
37733 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37734 }
37735 tty->driver_data = cs;
37736
37737 - ++cs->port.count;
37738 + atomic_inc(&cs->port.count);
37739
37740 - if (cs->port.count == 1) {
37741 + if (atomic_read(&cs->port.count) == 1) {
37742 tty_port_tty_set(&cs->port, tty);
37743 tty->low_latency = 1;
37744 }
37745 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37746
37747 if (!cs->connected)
37748 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37749 - else if (!cs->port.count)
37750 + else if (!atomic_read(&cs->port.count))
37751 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37752 - else if (!--cs->port.count)
37753 + else if (!atomic_dec_return(&cs->port.count))
37754 tty_port_tty_set(&cs->port, NULL);
37755
37756 mutex_unlock(&cs->mutex);
37757 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37758 index 821f7ac..28d4030 100644
37759 --- a/drivers/isdn/hardware/avm/b1.c
37760 +++ b/drivers/isdn/hardware/avm/b1.c
37761 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37762 }
37763 if (left) {
37764 if (t4file->user) {
37765 - if (copy_from_user(buf, dp, left))
37766 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37767 return -EFAULT;
37768 } else {
37769 memcpy(buf, dp, left);
37770 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37771 }
37772 if (left) {
37773 if (config->user) {
37774 - if (copy_from_user(buf, dp, left))
37775 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37776 return -EFAULT;
37777 } else {
37778 memcpy(buf, dp, left);
37779 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37780 index e09dc8a..15e2efb 100644
37781 --- a/drivers/isdn/i4l/isdn_tty.c
37782 +++ b/drivers/isdn/i4l/isdn_tty.c
37783 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37784
37785 #ifdef ISDN_DEBUG_MODEM_OPEN
37786 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37787 - port->count);
37788 + atomic_read(&port->count));
37789 #endif
37790 - port->count++;
37791 + atomic_inc(&port->count);
37792 port->tty = tty;
37793 /*
37794 * Start up serial port
37795 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37796 #endif
37797 return;
37798 }
37799 - if ((tty->count == 1) && (port->count != 1)) {
37800 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37801 /*
37802 * Uh, oh. tty->count is 1, which means that the tty
37803 * structure will be freed. Info->count should always
37804 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37805 * serial port won't be shutdown.
37806 */
37807 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37808 - "info->count is %d\n", port->count);
37809 - port->count = 1;
37810 + "info->count is %d\n", atomic_read(&port->count));
37811 + atomic_set(&port->count, 1);
37812 }
37813 - if (--port->count < 0) {
37814 + if (atomic_dec_return(&port->count) < 0) {
37815 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37816 - info->line, port->count);
37817 - port->count = 0;
37818 + info->line, atomic_read(&port->count));
37819 + atomic_set(&port->count, 0);
37820 }
37821 - if (port->count) {
37822 + if (atomic_read(&port->count)) {
37823 #ifdef ISDN_DEBUG_MODEM_OPEN
37824 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37825 #endif
37826 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37827 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37828 return;
37829 isdn_tty_shutdown(info);
37830 - port->count = 0;
37831 + atomic_set(&port->count, 0);
37832 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37833 port->tty = NULL;
37834 wake_up_interruptible(&port->open_wait);
37835 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37836 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37837 modem_info *info = &dev->mdm.info[i];
37838
37839 - if (info->port.count == 0)
37840 + if (atomic_read(&info->port.count) == 0)
37841 continue;
37842 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37843 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37844 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37845 index e74df7c..03a03ba 100644
37846 --- a/drivers/isdn/icn/icn.c
37847 +++ b/drivers/isdn/icn/icn.c
37848 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37849 if (count > len)
37850 count = len;
37851 if (user) {
37852 - if (copy_from_user(msg, buf, count))
37853 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37854 return -EFAULT;
37855 } else
37856 memcpy(msg, buf, count);
37857 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37858 index 6a8405d..0bd1c7e 100644
37859 --- a/drivers/leds/leds-clevo-mail.c
37860 +++ b/drivers/leds/leds-clevo-mail.c
37861 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37862 * detected as working, but in reality it is not) as low as
37863 * possible.
37864 */
37865 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37866 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37867 {
37868 .callback = clevo_mail_led_dmi_callback,
37869 .ident = "Clevo D410J",
37870 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37871 index ec9b287..65c9bf4 100644
37872 --- a/drivers/leds/leds-ss4200.c
37873 +++ b/drivers/leds/leds-ss4200.c
37874 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37875 * detected as working, but in reality it is not) as low as
37876 * possible.
37877 */
37878 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37879 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37880 {
37881 .callback = ss4200_led_dmi_callback,
37882 .ident = "Intel SS4200-E",
37883 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37884 index a5ebc00..982886f 100644
37885 --- a/drivers/lguest/core.c
37886 +++ b/drivers/lguest/core.c
37887 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37888 * it's worked so far. The end address needs +1 because __get_vm_area
37889 * allocates an extra guard page, so we need space for that.
37890 */
37891 +
37892 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37893 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37894 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37895 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37896 +#else
37897 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37898 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37899 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37900 +#endif
37901 +
37902 if (!switcher_vma) {
37903 err = -ENOMEM;
37904 printk("lguest: could not map switcher pages high\n");
37905 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37906 * Now the Switcher is mapped at the right address, we can't fail!
37907 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37908 */
37909 - memcpy(switcher_vma->addr, start_switcher_text,
37910 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37911 end_switcher_text - start_switcher_text);
37912
37913 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37914 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37915 index 3b62be16..e33134a 100644
37916 --- a/drivers/lguest/page_tables.c
37917 +++ b/drivers/lguest/page_tables.c
37918 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37919 /*:*/
37920
37921 #ifdef CONFIG_X86_PAE
37922 -static void release_pmd(pmd_t *spmd)
37923 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37924 {
37925 /* If the entry's not present, there's nothing to release. */
37926 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37927 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37928 index 4af12e1..0e89afe 100644
37929 --- a/drivers/lguest/x86/core.c
37930 +++ b/drivers/lguest/x86/core.c
37931 @@ -59,7 +59,7 @@ static struct {
37932 /* Offset from where switcher.S was compiled to where we've copied it */
37933 static unsigned long switcher_offset(void)
37934 {
37935 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37936 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37937 }
37938
37939 /* This cpu's struct lguest_pages. */
37940 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37941 * These copies are pretty cheap, so we do them unconditionally: */
37942 /* Save the current Host top-level page directory.
37943 */
37944 +
37945 +#ifdef CONFIG_PAX_PER_CPU_PGD
37946 + pages->state.host_cr3 = read_cr3();
37947 +#else
37948 pages->state.host_cr3 = __pa(current->mm->pgd);
37949 +#endif
37950 +
37951 /*
37952 * Set up the Guest's page tables to see this CPU's pages (and no
37953 * other CPU's pages).
37954 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37955 * compiled-in switcher code and the high-mapped copy we just made.
37956 */
37957 for (i = 0; i < IDT_ENTRIES; i++)
37958 - default_idt_entries[i] += switcher_offset();
37959 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37960
37961 /*
37962 * Set up the Switcher's per-cpu areas.
37963 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37964 * it will be undisturbed when we switch. To change %cs and jump we
37965 * need this structure to feed to Intel's "lcall" instruction.
37966 */
37967 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37968 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37969 lguest_entry.segment = LGUEST_CS;
37970
37971 /*
37972 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37973 index 40634b0..4f5855e 100644
37974 --- a/drivers/lguest/x86/switcher_32.S
37975 +++ b/drivers/lguest/x86/switcher_32.S
37976 @@ -87,6 +87,7 @@
37977 #include <asm/page.h>
37978 #include <asm/segment.h>
37979 #include <asm/lguest.h>
37980 +#include <asm/processor-flags.h>
37981
37982 // We mark the start of the code to copy
37983 // It's placed in .text tho it's never run here
37984 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37985 // Changes type when we load it: damn Intel!
37986 // For after we switch over our page tables
37987 // That entry will be read-only: we'd crash.
37988 +
37989 +#ifdef CONFIG_PAX_KERNEXEC
37990 + mov %cr0, %edx
37991 + xor $X86_CR0_WP, %edx
37992 + mov %edx, %cr0
37993 +#endif
37994 +
37995 movl $(GDT_ENTRY_TSS*8), %edx
37996 ltr %dx
37997
37998 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37999 // Let's clear it again for our return.
38000 // The GDT descriptor of the Host
38001 // Points to the table after two "size" bytes
38002 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38003 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38004 // Clear "used" from type field (byte 5, bit 2)
38005 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38006 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38007 +
38008 +#ifdef CONFIG_PAX_KERNEXEC
38009 + mov %cr0, %eax
38010 + xor $X86_CR0_WP, %eax
38011 + mov %eax, %cr0
38012 +#endif
38013
38014 // Once our page table's switched, the Guest is live!
38015 // The Host fades as we run this final step.
38016 @@ -295,13 +309,12 @@ deliver_to_host:
38017 // I consulted gcc, and it gave
38018 // These instructions, which I gladly credit:
38019 leal (%edx,%ebx,8), %eax
38020 - movzwl (%eax),%edx
38021 - movl 4(%eax), %eax
38022 - xorw %ax, %ax
38023 - orl %eax, %edx
38024 + movl 4(%eax), %edx
38025 + movw (%eax), %dx
38026 // Now the address of the handler's in %edx
38027 // We call it now: its "iret" drops us home.
38028 - jmp *%edx
38029 + ljmp $__KERNEL_CS, $1f
38030 +1: jmp *%edx
38031
38032 // Every interrupt can come to us here
38033 // But we must truly tell each apart.
38034 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38035 index 7155945..4bcc562 100644
38036 --- a/drivers/md/bitmap.c
38037 +++ b/drivers/md/bitmap.c
38038 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38039 chunk_kb ? "KB" : "B");
38040 if (bitmap->storage.file) {
38041 seq_printf(seq, ", file: ");
38042 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38043 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38044 }
38045
38046 seq_printf(seq, "\n");
38047 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38048 index eee353d..74504c4 100644
38049 --- a/drivers/md/dm-ioctl.c
38050 +++ b/drivers/md/dm-ioctl.c
38051 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38052 cmd == DM_LIST_VERSIONS_CMD)
38053 return 0;
38054
38055 - if ((cmd == DM_DEV_CREATE_CMD)) {
38056 + if (cmd == DM_DEV_CREATE_CMD) {
38057 if (!*param->name) {
38058 DMWARN("name not supplied when creating device");
38059 return -EINVAL;
38060 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38061 index 7f24190..0e18099 100644
38062 --- a/drivers/md/dm-raid1.c
38063 +++ b/drivers/md/dm-raid1.c
38064 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38065
38066 struct mirror {
38067 struct mirror_set *ms;
38068 - atomic_t error_count;
38069 + atomic_unchecked_t error_count;
38070 unsigned long error_type;
38071 struct dm_dev *dev;
38072 sector_t offset;
38073 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38074 struct mirror *m;
38075
38076 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38077 - if (!atomic_read(&m->error_count))
38078 + if (!atomic_read_unchecked(&m->error_count))
38079 return m;
38080
38081 return NULL;
38082 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38083 * simple way to tell if a device has encountered
38084 * errors.
38085 */
38086 - atomic_inc(&m->error_count);
38087 + atomic_inc_unchecked(&m->error_count);
38088
38089 if (test_and_set_bit(error_type, &m->error_type))
38090 return;
38091 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38092 struct mirror *m = get_default_mirror(ms);
38093
38094 do {
38095 - if (likely(!atomic_read(&m->error_count)))
38096 + if (likely(!atomic_read_unchecked(&m->error_count)))
38097 return m;
38098
38099 if (m-- == ms->mirror)
38100 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
38101 {
38102 struct mirror *default_mirror = get_default_mirror(m->ms);
38103
38104 - return !atomic_read(&default_mirror->error_count);
38105 + return !atomic_read_unchecked(&default_mirror->error_count);
38106 }
38107
38108 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38109 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38110 */
38111 if (likely(region_in_sync(ms, region, 1)))
38112 m = choose_mirror(ms, bio->bi_sector);
38113 - else if (m && atomic_read(&m->error_count))
38114 + else if (m && atomic_read_unchecked(&m->error_count))
38115 m = NULL;
38116
38117 if (likely(m))
38118 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38119 }
38120
38121 ms->mirror[mirror].ms = ms;
38122 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38123 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38124 ms->mirror[mirror].error_type = 0;
38125 ms->mirror[mirror].offset = offset;
38126
38127 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
38128 */
38129 static char device_status_char(struct mirror *m)
38130 {
38131 - if (!atomic_read(&(m->error_count)))
38132 + if (!atomic_read_unchecked(&(m->error_count)))
38133 return 'A';
38134
38135 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38136 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38137 index aaecefa..23b3026 100644
38138 --- a/drivers/md/dm-stripe.c
38139 +++ b/drivers/md/dm-stripe.c
38140 @@ -20,7 +20,7 @@ struct stripe {
38141 struct dm_dev *dev;
38142 sector_t physical_start;
38143
38144 - atomic_t error_count;
38145 + atomic_unchecked_t error_count;
38146 };
38147
38148 struct stripe_c {
38149 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38150 kfree(sc);
38151 return r;
38152 }
38153 - atomic_set(&(sc->stripe[i].error_count), 0);
38154 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38155 }
38156
38157 ti->private = sc;
38158 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38159 DMEMIT("%d ", sc->stripes);
38160 for (i = 0; i < sc->stripes; i++) {
38161 DMEMIT("%s ", sc->stripe[i].dev->name);
38162 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38163 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38164 'D' : 'A';
38165 }
38166 buffer[i] = '\0';
38167 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38168 */
38169 for (i = 0; i < sc->stripes; i++)
38170 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38171 - atomic_inc(&(sc->stripe[i].error_count));
38172 - if (atomic_read(&(sc->stripe[i].error_count)) <
38173 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38174 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38175 DM_IO_ERROR_THRESHOLD)
38176 schedule_work(&sc->trigger_event);
38177 }
38178 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38179 index daf25d0..d74f49f 100644
38180 --- a/drivers/md/dm-table.c
38181 +++ b/drivers/md/dm-table.c
38182 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38183 if (!dev_size)
38184 return 0;
38185
38186 - if ((start >= dev_size) || (start + len > dev_size)) {
38187 + if ((start >= dev_size) || (len > dev_size - start)) {
38188 DMWARN("%s: %s too small for target: "
38189 "start=%llu, len=%llu, dev_size=%llu",
38190 dm_device_name(ti->table->md), bdevname(bdev, b),
38191 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38192 index 4d6e853..a234157 100644
38193 --- a/drivers/md/dm-thin-metadata.c
38194 +++ b/drivers/md/dm-thin-metadata.c
38195 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38196 {
38197 pmd->info.tm = pmd->tm;
38198 pmd->info.levels = 2;
38199 - pmd->info.value_type.context = pmd->data_sm;
38200 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38201 pmd->info.value_type.size = sizeof(__le64);
38202 pmd->info.value_type.inc = data_block_inc;
38203 pmd->info.value_type.dec = data_block_dec;
38204 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38205
38206 pmd->bl_info.tm = pmd->tm;
38207 pmd->bl_info.levels = 1;
38208 - pmd->bl_info.value_type.context = pmd->data_sm;
38209 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38210 pmd->bl_info.value_type.size = sizeof(__le64);
38211 pmd->bl_info.value_type.inc = data_block_inc;
38212 pmd->bl_info.value_type.dec = data_block_dec;
38213 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38214 index 0d8f086..f5a91d5 100644
38215 --- a/drivers/md/dm.c
38216 +++ b/drivers/md/dm.c
38217 @@ -170,9 +170,9 @@ struct mapped_device {
38218 /*
38219 * Event handling.
38220 */
38221 - atomic_t event_nr;
38222 + atomic_unchecked_t event_nr;
38223 wait_queue_head_t eventq;
38224 - atomic_t uevent_seq;
38225 + atomic_unchecked_t uevent_seq;
38226 struct list_head uevent_list;
38227 spinlock_t uevent_lock; /* Protect access to uevent_list */
38228
38229 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
38230 rwlock_init(&md->map_lock);
38231 atomic_set(&md->holders, 1);
38232 atomic_set(&md->open_count, 0);
38233 - atomic_set(&md->event_nr, 0);
38234 - atomic_set(&md->uevent_seq, 0);
38235 + atomic_set_unchecked(&md->event_nr, 0);
38236 + atomic_set_unchecked(&md->uevent_seq, 0);
38237 INIT_LIST_HEAD(&md->uevent_list);
38238 spin_lock_init(&md->uevent_lock);
38239
38240 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38241
38242 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38243
38244 - atomic_inc(&md->event_nr);
38245 + atomic_inc_unchecked(&md->event_nr);
38246 wake_up(&md->eventq);
38247 }
38248
38249 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38250
38251 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38252 {
38253 - return atomic_add_return(1, &md->uevent_seq);
38254 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38255 }
38256
38257 uint32_t dm_get_event_nr(struct mapped_device *md)
38258 {
38259 - return atomic_read(&md->event_nr);
38260 + return atomic_read_unchecked(&md->event_nr);
38261 }
38262
38263 int dm_wait_event(struct mapped_device *md, int event_nr)
38264 {
38265 return wait_event_interruptible(md->eventq,
38266 - (event_nr != atomic_read(&md->event_nr)));
38267 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38268 }
38269
38270 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38271 diff --git a/drivers/md/md.c b/drivers/md/md.c
38272 index f363135..9b38815 100644
38273 --- a/drivers/md/md.c
38274 +++ b/drivers/md/md.c
38275 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38276 * start build, activate spare
38277 */
38278 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38279 -static atomic_t md_event_count;
38280 +static atomic_unchecked_t md_event_count;
38281 void md_new_event(struct mddev *mddev)
38282 {
38283 - atomic_inc(&md_event_count);
38284 + atomic_inc_unchecked(&md_event_count);
38285 wake_up(&md_event_waiters);
38286 }
38287 EXPORT_SYMBOL_GPL(md_new_event);
38288 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38289 */
38290 static void md_new_event_inintr(struct mddev *mddev)
38291 {
38292 - atomic_inc(&md_event_count);
38293 + atomic_inc_unchecked(&md_event_count);
38294 wake_up(&md_event_waiters);
38295 }
38296
38297 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38298 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38299 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38300 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38301 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38302 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38303
38304 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38305 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38306 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38307 else
38308 sb->resync_offset = cpu_to_le64(0);
38309
38310 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38311 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38312
38313 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38314 sb->size = cpu_to_le64(mddev->dev_sectors);
38315 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38316 static ssize_t
38317 errors_show(struct md_rdev *rdev, char *page)
38318 {
38319 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38320 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38321 }
38322
38323 static ssize_t
38324 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38325 char *e;
38326 unsigned long n = simple_strtoul(buf, &e, 10);
38327 if (*buf && (*e == 0 || *e == '\n')) {
38328 - atomic_set(&rdev->corrected_errors, n);
38329 + atomic_set_unchecked(&rdev->corrected_errors, n);
38330 return len;
38331 }
38332 return -EINVAL;
38333 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38334 rdev->sb_loaded = 0;
38335 rdev->bb_page = NULL;
38336 atomic_set(&rdev->nr_pending, 0);
38337 - atomic_set(&rdev->read_errors, 0);
38338 - atomic_set(&rdev->corrected_errors, 0);
38339 + atomic_set_unchecked(&rdev->read_errors, 0);
38340 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38341
38342 INIT_LIST_HEAD(&rdev->same_set);
38343 init_waitqueue_head(&rdev->blocked_wait);
38344 @@ -6987,7 +6987,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38345
38346 spin_unlock(&pers_lock);
38347 seq_printf(seq, "\n");
38348 - seq->poll_event = atomic_read(&md_event_count);
38349 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38350 return 0;
38351 }
38352 if (v == (void*)2) {
38353 @@ -7090,7 +7090,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38354 return error;
38355
38356 seq = file->private_data;
38357 - seq->poll_event = atomic_read(&md_event_count);
38358 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38359 return error;
38360 }
38361
38362 @@ -7104,7 +7104,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38363 /* always allow read */
38364 mask = POLLIN | POLLRDNORM;
38365
38366 - if (seq->poll_event != atomic_read(&md_event_count))
38367 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38368 mask |= POLLERR | POLLPRI;
38369 return mask;
38370 }
38371 @@ -7148,7 +7148,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38372 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38373 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38374 (int)part_stat_read(&disk->part0, sectors[1]) -
38375 - atomic_read(&disk->sync_io);
38376 + atomic_read_unchecked(&disk->sync_io);
38377 /* sync IO will cause sync_io to increase before the disk_stats
38378 * as sync_io is counted when a request starts, and
38379 * disk_stats is counted when it completes.
38380 diff --git a/drivers/md/md.h b/drivers/md/md.h
38381 index eca59c3..7c42285 100644
38382 --- a/drivers/md/md.h
38383 +++ b/drivers/md/md.h
38384 @@ -94,13 +94,13 @@ struct md_rdev {
38385 * only maintained for arrays that
38386 * support hot removal
38387 */
38388 - atomic_t read_errors; /* number of consecutive read errors that
38389 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38390 * we have tried to ignore.
38391 */
38392 struct timespec last_read_error; /* monotonic time since our
38393 * last read error
38394 */
38395 - atomic_t corrected_errors; /* number of corrected read errors,
38396 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38397 * for reporting to userspace and storing
38398 * in superblock.
38399 */
38400 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38401
38402 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38403 {
38404 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38405 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38406 }
38407
38408 struct md_personality
38409 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38410 index 1cbfc6b..56e1dbb 100644
38411 --- a/drivers/md/persistent-data/dm-space-map.h
38412 +++ b/drivers/md/persistent-data/dm-space-map.h
38413 @@ -60,6 +60,7 @@ struct dm_space_map {
38414 int (*root_size)(struct dm_space_map *sm, size_t *result);
38415 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38416 };
38417 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38418
38419 /*----------------------------------------------------------------*/
38420
38421 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38422 index 75b1f89..00ba344 100644
38423 --- a/drivers/md/raid1.c
38424 +++ b/drivers/md/raid1.c
38425 @@ -1819,7 +1819,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38426 if (r1_sync_page_io(rdev, sect, s,
38427 bio->bi_io_vec[idx].bv_page,
38428 READ) != 0)
38429 - atomic_add(s, &rdev->corrected_errors);
38430 + atomic_add_unchecked(s, &rdev->corrected_errors);
38431 }
38432 sectors -= s;
38433 sect += s;
38434 @@ -2041,7 +2041,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38435 test_bit(In_sync, &rdev->flags)) {
38436 if (r1_sync_page_io(rdev, sect, s,
38437 conf->tmppage, READ)) {
38438 - atomic_add(s, &rdev->corrected_errors);
38439 + atomic_add_unchecked(s, &rdev->corrected_errors);
38440 printk(KERN_INFO
38441 "md/raid1:%s: read error corrected "
38442 "(%d sectors at %llu on %s)\n",
38443 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38444 index 8d925dc..11d674f 100644
38445 --- a/drivers/md/raid10.c
38446 +++ b/drivers/md/raid10.c
38447 @@ -1878,7 +1878,7 @@ static void end_sync_read(struct bio *bio, int error)
38448 /* The write handler will notice the lack of
38449 * R10BIO_Uptodate and record any errors etc
38450 */
38451 - atomic_add(r10_bio->sectors,
38452 + atomic_add_unchecked(r10_bio->sectors,
38453 &conf->mirrors[d].rdev->corrected_errors);
38454
38455 /* for reconstruct, we always reschedule after a read.
38456 @@ -2227,7 +2227,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38457 {
38458 struct timespec cur_time_mon;
38459 unsigned long hours_since_last;
38460 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38461 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38462
38463 ktime_get_ts(&cur_time_mon);
38464
38465 @@ -2249,9 +2249,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38466 * overflowing the shift of read_errors by hours_since_last.
38467 */
38468 if (hours_since_last >= 8 * sizeof(read_errors))
38469 - atomic_set(&rdev->read_errors, 0);
38470 + atomic_set_unchecked(&rdev->read_errors, 0);
38471 else
38472 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38473 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38474 }
38475
38476 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38477 @@ -2305,8 +2305,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38478 return;
38479
38480 check_decay_read_errors(mddev, rdev);
38481 - atomic_inc(&rdev->read_errors);
38482 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38483 + atomic_inc_unchecked(&rdev->read_errors);
38484 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38485 char b[BDEVNAME_SIZE];
38486 bdevname(rdev->bdev, b);
38487
38488 @@ -2314,7 +2314,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38489 "md/raid10:%s: %s: Raid device exceeded "
38490 "read_error threshold [cur %d:max %d]\n",
38491 mdname(mddev), b,
38492 - atomic_read(&rdev->read_errors), max_read_errors);
38493 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38494 printk(KERN_NOTICE
38495 "md/raid10:%s: %s: Failing raid device\n",
38496 mdname(mddev), b);
38497 @@ -2469,7 +2469,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38498 sect +
38499 choose_data_offset(r10_bio, rdev)),
38500 bdevname(rdev->bdev, b));
38501 - atomic_add(s, &rdev->corrected_errors);
38502 + atomic_add_unchecked(s, &rdev->corrected_errors);
38503 }
38504
38505 rdev_dec_pending(rdev, mddev);
38506 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38507 index 94ce78e..df99e24 100644
38508 --- a/drivers/md/raid5.c
38509 +++ b/drivers/md/raid5.c
38510 @@ -1800,21 +1800,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38511 mdname(conf->mddev), STRIPE_SECTORS,
38512 (unsigned long long)s,
38513 bdevname(rdev->bdev, b));
38514 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38515 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38516 clear_bit(R5_ReadError, &sh->dev[i].flags);
38517 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38518 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38519 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38520
38521 - if (atomic_read(&rdev->read_errors))
38522 - atomic_set(&rdev->read_errors, 0);
38523 + if (atomic_read_unchecked(&rdev->read_errors))
38524 + atomic_set_unchecked(&rdev->read_errors, 0);
38525 } else {
38526 const char *bdn = bdevname(rdev->bdev, b);
38527 int retry = 0;
38528 int set_bad = 0;
38529
38530 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38531 - atomic_inc(&rdev->read_errors);
38532 + atomic_inc_unchecked(&rdev->read_errors);
38533 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38534 printk_ratelimited(
38535 KERN_WARNING
38536 @@ -1842,7 +1842,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38537 mdname(conf->mddev),
38538 (unsigned long long)s,
38539 bdn);
38540 - } else if (atomic_read(&rdev->read_errors)
38541 + } else if (atomic_read_unchecked(&rdev->read_errors)
38542 > conf->max_nr_stripes)
38543 printk(KERN_WARNING
38544 "md/raid:%s: Too many read errors, failing device %s.\n",
38545 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38546 index d33101a..6b13069 100644
38547 --- a/drivers/media/dvb-core/dvbdev.c
38548 +++ b/drivers/media/dvb-core/dvbdev.c
38549 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38550 const struct dvb_device *template, void *priv, int type)
38551 {
38552 struct dvb_device *dvbdev;
38553 - struct file_operations *dvbdevfops;
38554 + file_operations_no_const *dvbdevfops;
38555 struct device *clsdev;
38556 int minor;
38557 int id;
38558 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38559 index 404f63a..4796533 100644
38560 --- a/drivers/media/dvb-frontends/dib3000.h
38561 +++ b/drivers/media/dvb-frontends/dib3000.h
38562 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38563 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38564 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38565 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38566 -};
38567 +} __no_const;
38568
38569 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
38570 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38571 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38572 index bc78354..42c9459 100644
38573 --- a/drivers/media/pci/cx88/cx88-video.c
38574 +++ b/drivers/media/pci/cx88/cx88-video.c
38575 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38576
38577 /* ------------------------------------------------------------------ */
38578
38579 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38580 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38581 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38582 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38583 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38584 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38585
38586 module_param_array(video_nr, int, NULL, 0444);
38587 module_param_array(vbi_nr, int, NULL, 0444);
38588 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38589 index 8e9a668..78d6310 100644
38590 --- a/drivers/media/platform/omap/omap_vout.c
38591 +++ b/drivers/media/platform/omap/omap_vout.c
38592 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38593 OMAP_VIDEO2,
38594 };
38595
38596 -static struct videobuf_queue_ops video_vbq_ops;
38597 /* Variables configurable through module params*/
38598 static u32 video1_numbuffers = 3;
38599 static u32 video2_numbuffers = 3;
38600 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38601 {
38602 struct videobuf_queue *q;
38603 struct omap_vout_device *vout = NULL;
38604 + static struct videobuf_queue_ops video_vbq_ops = {
38605 + .buf_setup = omap_vout_buffer_setup,
38606 + .buf_prepare = omap_vout_buffer_prepare,
38607 + .buf_release = omap_vout_buffer_release,
38608 + .buf_queue = omap_vout_buffer_queue,
38609 + };
38610
38611 vout = video_drvdata(file);
38612 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38613 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38614 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38615
38616 q = &vout->vbq;
38617 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38618 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38619 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38620 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38621 spin_lock_init(&vout->vbq_lock);
38622
38623 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38624 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38625 index b671e20..34088b7 100644
38626 --- a/drivers/media/platform/s5p-tv/mixer.h
38627 +++ b/drivers/media/platform/s5p-tv/mixer.h
38628 @@ -155,7 +155,7 @@ struct mxr_layer {
38629 /** layer index (unique identifier) */
38630 int idx;
38631 /** callbacks for layer methods */
38632 - struct mxr_layer_ops ops;
38633 + struct mxr_layer_ops *ops;
38634 /** format array */
38635 const struct mxr_format **fmt_array;
38636 /** size of format array */
38637 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38638 index b93a21f..2535195 100644
38639 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38640 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38641 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38642 {
38643 struct mxr_layer *layer;
38644 int ret;
38645 - struct mxr_layer_ops ops = {
38646 + static struct mxr_layer_ops ops = {
38647 .release = mxr_graph_layer_release,
38648 .buffer_set = mxr_graph_buffer_set,
38649 .stream_set = mxr_graph_stream_set,
38650 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38651 index 3b1670a..595c939 100644
38652 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38653 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38654 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38655 layer->update_buf = next;
38656 }
38657
38658 - layer->ops.buffer_set(layer, layer->update_buf);
38659 + layer->ops->buffer_set(layer, layer->update_buf);
38660
38661 if (done && done != layer->shadow_buf)
38662 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38663 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38664 index 1f3b743..e839271 100644
38665 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38666 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38667 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38668 layer->geo.src.height = layer->geo.src.full_height;
38669
38670 mxr_geometry_dump(mdev, &layer->geo);
38671 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38672 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38673 mxr_geometry_dump(mdev, &layer->geo);
38674 }
38675
38676 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38677 layer->geo.dst.full_width = mbus_fmt.width;
38678 layer->geo.dst.full_height = mbus_fmt.height;
38679 layer->geo.dst.field = mbus_fmt.field;
38680 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38681 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38682
38683 mxr_geometry_dump(mdev, &layer->geo);
38684 }
38685 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38686 /* set source size to highest accepted value */
38687 geo->src.full_width = max(geo->dst.full_width, pix->width);
38688 geo->src.full_height = max(geo->dst.full_height, pix->height);
38689 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38690 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38691 mxr_geometry_dump(mdev, &layer->geo);
38692 /* set cropping to total visible screen */
38693 geo->src.width = pix->width;
38694 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38695 geo->src.x_offset = 0;
38696 geo->src.y_offset = 0;
38697 /* assure consistency of geometry */
38698 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38699 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38700 mxr_geometry_dump(mdev, &layer->geo);
38701 /* set full size to lowest possible value */
38702 geo->src.full_width = 0;
38703 geo->src.full_height = 0;
38704 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38705 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38706 mxr_geometry_dump(mdev, &layer->geo);
38707
38708 /* returning results */
38709 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38710 target->width = s->r.width;
38711 target->height = s->r.height;
38712
38713 - layer->ops.fix_geometry(layer, stage, s->flags);
38714 + layer->ops->fix_geometry(layer, stage, s->flags);
38715
38716 /* retrieve update selection rectangle */
38717 res.left = target->x_offset;
38718 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38719 mxr_output_get(mdev);
38720
38721 mxr_layer_update_output(layer);
38722 - layer->ops.format_set(layer);
38723 + layer->ops->format_set(layer);
38724 /* enabling layer in hardware */
38725 spin_lock_irqsave(&layer->enq_slock, flags);
38726 layer->state = MXR_LAYER_STREAMING;
38727 spin_unlock_irqrestore(&layer->enq_slock, flags);
38728
38729 - layer->ops.stream_set(layer, MXR_ENABLE);
38730 + layer->ops->stream_set(layer, MXR_ENABLE);
38731 mxr_streamer_get(mdev);
38732
38733 return 0;
38734 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
38735 spin_unlock_irqrestore(&layer->enq_slock, flags);
38736
38737 /* disabling layer in hardware */
38738 - layer->ops.stream_set(layer, MXR_DISABLE);
38739 + layer->ops->stream_set(layer, MXR_DISABLE);
38740 /* remove one streamer */
38741 mxr_streamer_put(mdev);
38742 /* allow changes in output configuration */
38743 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38744
38745 void mxr_layer_release(struct mxr_layer *layer)
38746 {
38747 - if (layer->ops.release)
38748 - layer->ops.release(layer);
38749 + if (layer->ops->release)
38750 + layer->ops->release(layer);
38751 }
38752
38753 void mxr_base_layer_release(struct mxr_layer *layer)
38754 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38755
38756 layer->mdev = mdev;
38757 layer->idx = idx;
38758 - layer->ops = *ops;
38759 + layer->ops = ops;
38760
38761 spin_lock_init(&layer->enq_slock);
38762 INIT_LIST_HEAD(&layer->enq_list);
38763 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38764 index 3d13a63..da31bf1 100644
38765 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38766 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38767 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38768 {
38769 struct mxr_layer *layer;
38770 int ret;
38771 - struct mxr_layer_ops ops = {
38772 + static struct mxr_layer_ops ops = {
38773 .release = mxr_vp_layer_release,
38774 .buffer_set = mxr_vp_buffer_set,
38775 .stream_set = mxr_vp_stream_set,
38776 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38777 index 643d80a..56bb96b 100644
38778 --- a/drivers/media/radio/radio-cadet.c
38779 +++ b/drivers/media/radio/radio-cadet.c
38780 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38781 unsigned char readbuf[RDS_BUFFER];
38782 int i = 0;
38783
38784 + if (count > RDS_BUFFER)
38785 + return -EFAULT;
38786 mutex_lock(&dev->lock);
38787 if (dev->rdsstat == 0)
38788 cadet_start_rds(dev);
38789 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38790 while (i < count && dev->rdsin != dev->rdsout)
38791 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38792
38793 - if (i && copy_to_user(data, readbuf, i))
38794 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38795 i = -EFAULT;
38796 unlock:
38797 mutex_unlock(&dev->lock);
38798 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38799 index 3940bb0..fb3952a 100644
38800 --- a/drivers/media/usb/dvb-usb/cxusb.c
38801 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38802 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38803
38804 struct dib0700_adapter_state {
38805 int (*set_param_save) (struct dvb_frontend *);
38806 -};
38807 +} __no_const;
38808
38809 static int dib7070_set_param_override(struct dvb_frontend *fe)
38810 {
38811 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38812 index 9382895..ac8093c 100644
38813 --- a/drivers/media/usb/dvb-usb/dw2102.c
38814 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38815 @@ -95,7 +95,7 @@ struct su3000_state {
38816
38817 struct s6x0_state {
38818 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38819 -};
38820 +} __no_const;
38821
38822 /* debug */
38823 static int dvb_usb_dw2102_debug;
38824 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38825 index aa6e7c7..4cd8061 100644
38826 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38827 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38828 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38829 struct file *file, void *fh, void *p);
38830 } u;
38831 void (*debug)(const void *arg, bool write_only);
38832 -};
38833 +} __do_const;
38834 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38835
38836 /* This control needs a priority check */
38837 #define INFO_FL_PRIO (1 << 0)
38838 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38839 struct video_device *vfd = video_devdata(file);
38840 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38841 bool write_only = false;
38842 - struct v4l2_ioctl_info default_info;
38843 + v4l2_ioctl_info_no_const default_info;
38844 const struct v4l2_ioctl_info *info;
38845 void *fh = file->private_data;
38846 struct v4l2_fh *vfh = NULL;
38847 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
38848 index 29b2172..a7c5b31 100644
38849 --- a/drivers/memstick/host/r592.c
38850 +++ b/drivers/memstick/host/r592.c
38851 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
38852 /* Executes one TPC (data is read/written from small or large fifo) */
38853 static void r592_execute_tpc(struct r592_device *dev)
38854 {
38855 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38856 + bool is_write;
38857 int len, error;
38858 u32 status, reg;
38859
38860 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
38861 return;
38862 }
38863
38864 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38865 len = dev->req->long_data ?
38866 dev->req->sg.length : dev->req->data_len;
38867
38868 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38869 index fb69baa..3aeea2e 100644
38870 --- a/drivers/message/fusion/mptbase.c
38871 +++ b/drivers/message/fusion/mptbase.c
38872 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38873 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38874 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38875
38876 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38877 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38878 +#else
38879 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38880 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38881 +#endif
38882 +
38883 /*
38884 * Rounding UP to nearest 4-kB boundary here...
38885 */
38886 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38887 ioc->facts.GlobalCredits);
38888
38889 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38890 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38891 + NULL, NULL);
38892 +#else
38893 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38894 +#endif
38895 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38896 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38897 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38898 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38899 index fa43c39..daeb158 100644
38900 --- a/drivers/message/fusion/mptsas.c
38901 +++ b/drivers/message/fusion/mptsas.c
38902 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38903 return 0;
38904 }
38905
38906 +static inline void
38907 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38908 +{
38909 + if (phy_info->port_details) {
38910 + phy_info->port_details->rphy = rphy;
38911 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38912 + ioc->name, rphy));
38913 + }
38914 +
38915 + if (rphy) {
38916 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38917 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38918 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38919 + ioc->name, rphy, rphy->dev.release));
38920 + }
38921 +}
38922 +
38923 /* no mutex */
38924 static void
38925 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38926 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38927 return NULL;
38928 }
38929
38930 -static inline void
38931 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38932 -{
38933 - if (phy_info->port_details) {
38934 - phy_info->port_details->rphy = rphy;
38935 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38936 - ioc->name, rphy));
38937 - }
38938 -
38939 - if (rphy) {
38940 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38941 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38942 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38943 - ioc->name, rphy, rphy->dev.release));
38944 - }
38945 -}
38946 -
38947 static inline struct sas_port *
38948 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38949 {
38950 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38951 index 164afa7..b6b2e74 100644
38952 --- a/drivers/message/fusion/mptscsih.c
38953 +++ b/drivers/message/fusion/mptscsih.c
38954 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38955
38956 h = shost_priv(SChost);
38957
38958 - if (h) {
38959 - if (h->info_kbuf == NULL)
38960 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38961 - return h->info_kbuf;
38962 - h->info_kbuf[0] = '\0';
38963 + if (!h)
38964 + return NULL;
38965
38966 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38967 - h->info_kbuf[size-1] = '\0';
38968 - }
38969 + if (h->info_kbuf == NULL)
38970 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38971 + return h->info_kbuf;
38972 + h->info_kbuf[0] = '\0';
38973 +
38974 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38975 + h->info_kbuf[size-1] = '\0';
38976
38977 return h->info_kbuf;
38978 }
38979 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38980 index 8001aa6..b137580 100644
38981 --- a/drivers/message/i2o/i2o_proc.c
38982 +++ b/drivers/message/i2o/i2o_proc.c
38983 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38984 "Array Controller Device"
38985 };
38986
38987 -static char *chtostr(char *tmp, u8 *chars, int n)
38988 -{
38989 - tmp[0] = 0;
38990 - return strncat(tmp, (char *)chars, n);
38991 -}
38992 -
38993 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38994 char *group)
38995 {
38996 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38997 } *result;
38998
38999 i2o_exec_execute_ddm_table ddm_table;
39000 - char tmp[28 + 1];
39001
39002 result = kmalloc(sizeof(*result), GFP_KERNEL);
39003 if (!result)
39004 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39005
39006 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39007 seq_printf(seq, "%-#8x", ddm_table.module_id);
39008 - seq_printf(seq, "%-29s",
39009 - chtostr(tmp, ddm_table.module_name_version, 28));
39010 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39011 seq_printf(seq, "%9d ", ddm_table.data_size);
39012 seq_printf(seq, "%8d", ddm_table.code_size);
39013
39014 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39015
39016 i2o_driver_result_table *result;
39017 i2o_driver_store_table *dst;
39018 - char tmp[28 + 1];
39019
39020 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39021 if (result == NULL)
39022 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39023
39024 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39025 seq_printf(seq, "%-#8x", dst->module_id);
39026 - seq_printf(seq, "%-29s",
39027 - chtostr(tmp, dst->module_name_version, 28));
39028 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39029 + seq_printf(seq, "%-.28s", dst->module_name_version);
39030 + seq_printf(seq, "%-.8s", dst->date);
39031 seq_printf(seq, "%8d ", dst->module_size);
39032 seq_printf(seq, "%8d ", dst->mpb_size);
39033 seq_printf(seq, "0x%04x", dst->module_flags);
39034 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39035 // == (allow) 512d bytes (max)
39036 static u16 *work16 = (u16 *) work32;
39037 int token;
39038 - char tmp[16 + 1];
39039
39040 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39041
39042 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39043 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39044 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39045 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39046 - seq_printf(seq, "Vendor info : %s\n",
39047 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39048 - seq_printf(seq, "Product info : %s\n",
39049 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39050 - seq_printf(seq, "Description : %s\n",
39051 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39052 - seq_printf(seq, "Product rev. : %s\n",
39053 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39054 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39055 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39056 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39057 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39058
39059 seq_printf(seq, "Serial number : ");
39060 print_serial_number(seq, (u8 *) (work32 + 16),
39061 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39062 u8 pad[256]; // allow up to 256 byte (max) serial number
39063 } result;
39064
39065 - char tmp[24 + 1];
39066 -
39067 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39068
39069 if (token < 0) {
39070 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39071 }
39072
39073 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39074 - seq_printf(seq, "Module name : %s\n",
39075 - chtostr(tmp, result.module_name, 24));
39076 - seq_printf(seq, "Module revision : %s\n",
39077 - chtostr(tmp, result.module_rev, 8));
39078 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39079 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39080
39081 seq_printf(seq, "Serial number : ");
39082 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39083 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39084 u8 instance_number[4];
39085 } result;
39086
39087 - char tmp[64 + 1];
39088 -
39089 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39090
39091 if (token < 0) {
39092 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39093 return 0;
39094 }
39095
39096 - seq_printf(seq, "Device name : %s\n",
39097 - chtostr(tmp, result.device_name, 64));
39098 - seq_printf(seq, "Service name : %s\n",
39099 - chtostr(tmp, result.service_name, 64));
39100 - seq_printf(seq, "Physical name : %s\n",
39101 - chtostr(tmp, result.physical_location, 64));
39102 - seq_printf(seq, "Instance number : %s\n",
39103 - chtostr(tmp, result.instance_number, 4));
39104 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39105 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39106 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39107 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39108
39109 return 0;
39110 }
39111 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39112 index a8c08f3..155fe3d 100644
39113 --- a/drivers/message/i2o/iop.c
39114 +++ b/drivers/message/i2o/iop.c
39115 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39116
39117 spin_lock_irqsave(&c->context_list_lock, flags);
39118
39119 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39120 - atomic_inc(&c->context_list_counter);
39121 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39122 + atomic_inc_unchecked(&c->context_list_counter);
39123
39124 - entry->context = atomic_read(&c->context_list_counter);
39125 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39126
39127 list_add(&entry->list, &c->context_list);
39128
39129 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39130
39131 #if BITS_PER_LONG == 64
39132 spin_lock_init(&c->context_list_lock);
39133 - atomic_set(&c->context_list_counter, 0);
39134 + atomic_set_unchecked(&c->context_list_counter, 0);
39135 INIT_LIST_HEAD(&c->context_list);
39136 #endif
39137
39138 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39139 index 45ece11..8efa218 100644
39140 --- a/drivers/mfd/janz-cmodio.c
39141 +++ b/drivers/mfd/janz-cmodio.c
39142 @@ -13,6 +13,7 @@
39143
39144 #include <linux/kernel.h>
39145 #include <linux/module.h>
39146 +#include <linux/slab.h>
39147 #include <linux/init.h>
39148 #include <linux/pci.h>
39149 #include <linux/interrupt.h>
39150 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39151 index a5f9888..1c0ed56 100644
39152 --- a/drivers/mfd/twl4030-irq.c
39153 +++ b/drivers/mfd/twl4030-irq.c
39154 @@ -35,6 +35,7 @@
39155 #include <linux/of.h>
39156 #include <linux/irqdomain.h>
39157 #include <linux/i2c/twl.h>
39158 +#include <asm/pgtable.h>
39159
39160 #include "twl-core.h"
39161
39162 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39163 * Install an irq handler for each of the SIH modules;
39164 * clone dummy irq_chip since PIH can't *do* anything
39165 */
39166 - twl4030_irq_chip = dummy_irq_chip;
39167 - twl4030_irq_chip.name = "twl4030";
39168 + pax_open_kernel();
39169 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39170 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39171
39172 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39173 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39174 + pax_close_kernel();
39175
39176 for (i = irq_base; i < irq_end; i++) {
39177 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39178 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39179 index 277a8db..0e0b754 100644
39180 --- a/drivers/mfd/twl6030-irq.c
39181 +++ b/drivers/mfd/twl6030-irq.c
39182 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39183 * install an irq handler for each of the modules;
39184 * clone dummy irq_chip since PIH can't *do* anything
39185 */
39186 - twl6030_irq_chip = dummy_irq_chip;
39187 - twl6030_irq_chip.name = "twl6030";
39188 - twl6030_irq_chip.irq_set_type = NULL;
39189 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39190 + pax_open_kernel();
39191 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39192 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39193 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39194 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39195 + pax_close_kernel();
39196
39197 for (i = irq_base; i < irq_end; i++) {
39198 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39199 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39200 index f428d86..274c368 100644
39201 --- a/drivers/misc/c2port/core.c
39202 +++ b/drivers/misc/c2port/core.c
39203 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
39204 mutex_init(&c2dev->mutex);
39205
39206 /* Create binary file */
39207 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39208 + pax_open_kernel();
39209 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39210 + pax_close_kernel();
39211 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39212 if (unlikely(ret))
39213 goto error_device_create_bin_file;
39214 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39215 index 3aa9a96..59cf685 100644
39216 --- a/drivers/misc/kgdbts.c
39217 +++ b/drivers/misc/kgdbts.c
39218 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
39219 char before[BREAK_INSTR_SIZE];
39220 char after[BREAK_INSTR_SIZE];
39221
39222 - probe_kernel_read(before, (char *)kgdbts_break_test,
39223 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39224 BREAK_INSTR_SIZE);
39225 init_simple_test();
39226 ts.tst = plant_and_detach_test;
39227 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
39228 /* Activate test with initial breakpoint */
39229 if (!is_early)
39230 kgdb_breakpoint();
39231 - probe_kernel_read(after, (char *)kgdbts_break_test,
39232 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39233 BREAK_INSTR_SIZE);
39234 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39235 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39236 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39237 index 4a87e5c..76bdf5c 100644
39238 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39239 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39240 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39241 * the lid is closed. This leads to interrupts as soon as a little move
39242 * is done.
39243 */
39244 - atomic_inc(&lis3->count);
39245 + atomic_inc_unchecked(&lis3->count);
39246
39247 wake_up_interruptible(&lis3->misc_wait);
39248 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39249 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39250 if (lis3->pm_dev)
39251 pm_runtime_get_sync(lis3->pm_dev);
39252
39253 - atomic_set(&lis3->count, 0);
39254 + atomic_set_unchecked(&lis3->count, 0);
39255 return 0;
39256 }
39257
39258 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39259 add_wait_queue(&lis3->misc_wait, &wait);
39260 while (true) {
39261 set_current_state(TASK_INTERRUPTIBLE);
39262 - data = atomic_xchg(&lis3->count, 0);
39263 + data = atomic_xchg_unchecked(&lis3->count, 0);
39264 if (data)
39265 break;
39266
39267 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39268 struct lis3lv02d, miscdev);
39269
39270 poll_wait(file, &lis3->misc_wait, wait);
39271 - if (atomic_read(&lis3->count))
39272 + if (atomic_read_unchecked(&lis3->count))
39273 return POLLIN | POLLRDNORM;
39274 return 0;
39275 }
39276 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39277 index c439c82..1f20f57 100644
39278 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39279 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39280 @@ -297,7 +297,7 @@ struct lis3lv02d {
39281 struct input_polled_dev *idev; /* input device */
39282 struct platform_device *pdev; /* platform device */
39283 struct regulator_bulk_data regulators[2];
39284 - atomic_t count; /* interrupt count after last read */
39285 + atomic_unchecked_t count; /* interrupt count after last read */
39286 union axis_conversion ac; /* hw -> logical axis */
39287 int mapped_btns[3];
39288
39289 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39290 index 2f30bad..c4c13d0 100644
39291 --- a/drivers/misc/sgi-gru/gruhandles.c
39292 +++ b/drivers/misc/sgi-gru/gruhandles.c
39293 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39294 unsigned long nsec;
39295
39296 nsec = CLKS2NSEC(clks);
39297 - atomic_long_inc(&mcs_op_statistics[op].count);
39298 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39299 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39300 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39301 if (mcs_op_statistics[op].max < nsec)
39302 mcs_op_statistics[op].max = nsec;
39303 }
39304 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39305 index 950dbe9..eeef0f8 100644
39306 --- a/drivers/misc/sgi-gru/gruprocfs.c
39307 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39308 @@ -32,9 +32,9 @@
39309
39310 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39311
39312 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39313 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39314 {
39315 - unsigned long val = atomic_long_read(v);
39316 + unsigned long val = atomic_long_read_unchecked(v);
39317
39318 seq_printf(s, "%16lu %s\n", val, id);
39319 }
39320 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39321
39322 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39323 for (op = 0; op < mcsop_last; op++) {
39324 - count = atomic_long_read(&mcs_op_statistics[op].count);
39325 - total = atomic_long_read(&mcs_op_statistics[op].total);
39326 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39327 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39328 max = mcs_op_statistics[op].max;
39329 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39330 count ? total / count : 0, max);
39331 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39332 index 5c3ce24..4915ccb 100644
39333 --- a/drivers/misc/sgi-gru/grutables.h
39334 +++ b/drivers/misc/sgi-gru/grutables.h
39335 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39336 * GRU statistics.
39337 */
39338 struct gru_stats_s {
39339 - atomic_long_t vdata_alloc;
39340 - atomic_long_t vdata_free;
39341 - atomic_long_t gts_alloc;
39342 - atomic_long_t gts_free;
39343 - atomic_long_t gms_alloc;
39344 - atomic_long_t gms_free;
39345 - atomic_long_t gts_double_allocate;
39346 - atomic_long_t assign_context;
39347 - atomic_long_t assign_context_failed;
39348 - atomic_long_t free_context;
39349 - atomic_long_t load_user_context;
39350 - atomic_long_t load_kernel_context;
39351 - atomic_long_t lock_kernel_context;
39352 - atomic_long_t unlock_kernel_context;
39353 - atomic_long_t steal_user_context;
39354 - atomic_long_t steal_kernel_context;
39355 - atomic_long_t steal_context_failed;
39356 - atomic_long_t nopfn;
39357 - atomic_long_t asid_new;
39358 - atomic_long_t asid_next;
39359 - atomic_long_t asid_wrap;
39360 - atomic_long_t asid_reuse;
39361 - atomic_long_t intr;
39362 - atomic_long_t intr_cbr;
39363 - atomic_long_t intr_tfh;
39364 - atomic_long_t intr_spurious;
39365 - atomic_long_t intr_mm_lock_failed;
39366 - atomic_long_t call_os;
39367 - atomic_long_t call_os_wait_queue;
39368 - atomic_long_t user_flush_tlb;
39369 - atomic_long_t user_unload_context;
39370 - atomic_long_t user_exception;
39371 - atomic_long_t set_context_option;
39372 - atomic_long_t check_context_retarget_intr;
39373 - atomic_long_t check_context_unload;
39374 - atomic_long_t tlb_dropin;
39375 - atomic_long_t tlb_preload_page;
39376 - atomic_long_t tlb_dropin_fail_no_asid;
39377 - atomic_long_t tlb_dropin_fail_upm;
39378 - atomic_long_t tlb_dropin_fail_invalid;
39379 - atomic_long_t tlb_dropin_fail_range_active;
39380 - atomic_long_t tlb_dropin_fail_idle;
39381 - atomic_long_t tlb_dropin_fail_fmm;
39382 - atomic_long_t tlb_dropin_fail_no_exception;
39383 - atomic_long_t tfh_stale_on_fault;
39384 - atomic_long_t mmu_invalidate_range;
39385 - atomic_long_t mmu_invalidate_page;
39386 - atomic_long_t flush_tlb;
39387 - atomic_long_t flush_tlb_gru;
39388 - atomic_long_t flush_tlb_gru_tgh;
39389 - atomic_long_t flush_tlb_gru_zero_asid;
39390 + atomic_long_unchecked_t vdata_alloc;
39391 + atomic_long_unchecked_t vdata_free;
39392 + atomic_long_unchecked_t gts_alloc;
39393 + atomic_long_unchecked_t gts_free;
39394 + atomic_long_unchecked_t gms_alloc;
39395 + atomic_long_unchecked_t gms_free;
39396 + atomic_long_unchecked_t gts_double_allocate;
39397 + atomic_long_unchecked_t assign_context;
39398 + atomic_long_unchecked_t assign_context_failed;
39399 + atomic_long_unchecked_t free_context;
39400 + atomic_long_unchecked_t load_user_context;
39401 + atomic_long_unchecked_t load_kernel_context;
39402 + atomic_long_unchecked_t lock_kernel_context;
39403 + atomic_long_unchecked_t unlock_kernel_context;
39404 + atomic_long_unchecked_t steal_user_context;
39405 + atomic_long_unchecked_t steal_kernel_context;
39406 + atomic_long_unchecked_t steal_context_failed;
39407 + atomic_long_unchecked_t nopfn;
39408 + atomic_long_unchecked_t asid_new;
39409 + atomic_long_unchecked_t asid_next;
39410 + atomic_long_unchecked_t asid_wrap;
39411 + atomic_long_unchecked_t asid_reuse;
39412 + atomic_long_unchecked_t intr;
39413 + atomic_long_unchecked_t intr_cbr;
39414 + atomic_long_unchecked_t intr_tfh;
39415 + atomic_long_unchecked_t intr_spurious;
39416 + atomic_long_unchecked_t intr_mm_lock_failed;
39417 + atomic_long_unchecked_t call_os;
39418 + atomic_long_unchecked_t call_os_wait_queue;
39419 + atomic_long_unchecked_t user_flush_tlb;
39420 + atomic_long_unchecked_t user_unload_context;
39421 + atomic_long_unchecked_t user_exception;
39422 + atomic_long_unchecked_t set_context_option;
39423 + atomic_long_unchecked_t check_context_retarget_intr;
39424 + atomic_long_unchecked_t check_context_unload;
39425 + atomic_long_unchecked_t tlb_dropin;
39426 + atomic_long_unchecked_t tlb_preload_page;
39427 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39428 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39429 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39430 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39431 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39432 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39433 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39434 + atomic_long_unchecked_t tfh_stale_on_fault;
39435 + atomic_long_unchecked_t mmu_invalidate_range;
39436 + atomic_long_unchecked_t mmu_invalidate_page;
39437 + atomic_long_unchecked_t flush_tlb;
39438 + atomic_long_unchecked_t flush_tlb_gru;
39439 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39440 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39441
39442 - atomic_long_t copy_gpa;
39443 - atomic_long_t read_gpa;
39444 + atomic_long_unchecked_t copy_gpa;
39445 + atomic_long_unchecked_t read_gpa;
39446
39447 - atomic_long_t mesq_receive;
39448 - atomic_long_t mesq_receive_none;
39449 - atomic_long_t mesq_send;
39450 - atomic_long_t mesq_send_failed;
39451 - atomic_long_t mesq_noop;
39452 - atomic_long_t mesq_send_unexpected_error;
39453 - atomic_long_t mesq_send_lb_overflow;
39454 - atomic_long_t mesq_send_qlimit_reached;
39455 - atomic_long_t mesq_send_amo_nacked;
39456 - atomic_long_t mesq_send_put_nacked;
39457 - atomic_long_t mesq_page_overflow;
39458 - atomic_long_t mesq_qf_locked;
39459 - atomic_long_t mesq_qf_noop_not_full;
39460 - atomic_long_t mesq_qf_switch_head_failed;
39461 - atomic_long_t mesq_qf_unexpected_error;
39462 - atomic_long_t mesq_noop_unexpected_error;
39463 - atomic_long_t mesq_noop_lb_overflow;
39464 - atomic_long_t mesq_noop_qlimit_reached;
39465 - atomic_long_t mesq_noop_amo_nacked;
39466 - atomic_long_t mesq_noop_put_nacked;
39467 - atomic_long_t mesq_noop_page_overflow;
39468 + atomic_long_unchecked_t mesq_receive;
39469 + atomic_long_unchecked_t mesq_receive_none;
39470 + atomic_long_unchecked_t mesq_send;
39471 + atomic_long_unchecked_t mesq_send_failed;
39472 + atomic_long_unchecked_t mesq_noop;
39473 + atomic_long_unchecked_t mesq_send_unexpected_error;
39474 + atomic_long_unchecked_t mesq_send_lb_overflow;
39475 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39476 + atomic_long_unchecked_t mesq_send_amo_nacked;
39477 + atomic_long_unchecked_t mesq_send_put_nacked;
39478 + atomic_long_unchecked_t mesq_page_overflow;
39479 + atomic_long_unchecked_t mesq_qf_locked;
39480 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39481 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39482 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39483 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39484 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39485 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39486 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39487 + atomic_long_unchecked_t mesq_noop_put_nacked;
39488 + atomic_long_unchecked_t mesq_noop_page_overflow;
39489
39490 };
39491
39492 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39493 tghop_invalidate, mcsop_last};
39494
39495 struct mcs_op_statistic {
39496 - atomic_long_t count;
39497 - atomic_long_t total;
39498 + atomic_long_unchecked_t count;
39499 + atomic_long_unchecked_t total;
39500 unsigned long max;
39501 };
39502
39503 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39504
39505 #define STAT(id) do { \
39506 if (gru_options & OPT_STATS) \
39507 - atomic_long_inc(&gru_stats.id); \
39508 + atomic_long_inc_unchecked(&gru_stats.id); \
39509 } while (0)
39510
39511 #ifdef CONFIG_SGI_GRU_DEBUG
39512 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39513 index c862cd4..0d176fe 100644
39514 --- a/drivers/misc/sgi-xp/xp.h
39515 +++ b/drivers/misc/sgi-xp/xp.h
39516 @@ -288,7 +288,7 @@ struct xpc_interface {
39517 xpc_notify_func, void *);
39518 void (*received) (short, int, void *);
39519 enum xp_retval (*partid_to_nasids) (short, void *);
39520 -};
39521 +} __no_const;
39522
39523 extern struct xpc_interface xpc_interface;
39524
39525 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39526 index b94d5f7..7f494c5 100644
39527 --- a/drivers/misc/sgi-xp/xpc.h
39528 +++ b/drivers/misc/sgi-xp/xpc.h
39529 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39530 void (*received_payload) (struct xpc_channel *, void *);
39531 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39532 };
39533 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39534
39535 /* struct xpc_partition act_state values (for XPC HB) */
39536
39537 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39538 /* found in xpc_main.c */
39539 extern struct device *xpc_part;
39540 extern struct device *xpc_chan;
39541 -extern struct xpc_arch_operations xpc_arch_ops;
39542 +extern xpc_arch_operations_no_const xpc_arch_ops;
39543 extern int xpc_disengage_timelimit;
39544 extern int xpc_disengage_timedout;
39545 extern int xpc_activate_IRQ_rcvd;
39546 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39547 index d971817..33bdca5 100644
39548 --- a/drivers/misc/sgi-xp/xpc_main.c
39549 +++ b/drivers/misc/sgi-xp/xpc_main.c
39550 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39551 .notifier_call = xpc_system_die,
39552 };
39553
39554 -struct xpc_arch_operations xpc_arch_ops;
39555 +xpc_arch_operations_no_const xpc_arch_ops;
39556
39557 /*
39558 * Timer function to enforce the timelimit on the partition disengage.
39559 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39560
39561 if (((die_args->trapnr == X86_TRAP_MF) ||
39562 (die_args->trapnr == X86_TRAP_XF)) &&
39563 - !user_mode_vm(die_args->regs))
39564 + !user_mode(die_args->regs))
39565 xpc_die_deactivate();
39566
39567 break;
39568 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39569 index 6d8f701..35b6369 100644
39570 --- a/drivers/mmc/core/mmc_ops.c
39571 +++ b/drivers/mmc/core/mmc_ops.c
39572 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39573 void *data_buf;
39574 int is_on_stack;
39575
39576 - is_on_stack = object_is_on_stack(buf);
39577 + is_on_stack = object_starts_on_stack(buf);
39578 if (is_on_stack) {
39579 /*
39580 * dma onto stack is unsafe/nonportable, but callers to this
39581 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39582 index 53b8fd9..615b462 100644
39583 --- a/drivers/mmc/host/dw_mmc.h
39584 +++ b/drivers/mmc/host/dw_mmc.h
39585 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39586 int (*parse_dt)(struct dw_mci *host);
39587 int (*setup_bus)(struct dw_mci *host,
39588 struct device_node *slot_np, u8 bus_width);
39589 -};
39590 +} __do_const;
39591 #endif /* _DW_MMC_H_ */
39592 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39593 index 82a8de1..3c56ccb 100644
39594 --- a/drivers/mmc/host/sdhci-s3c.c
39595 +++ b/drivers/mmc/host/sdhci-s3c.c
39596 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39597 * we can use overriding functions instead of default.
39598 */
39599 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39600 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39601 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39602 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39603 + pax_open_kernel();
39604 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39605 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39606 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39607 + pax_close_kernel();
39608 }
39609
39610 /* It supports additional host capabilities if needed */
39611 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39612 index a4eb8b5..8c0628f 100644
39613 --- a/drivers/mtd/devices/doc2000.c
39614 +++ b/drivers/mtd/devices/doc2000.c
39615 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39616
39617 /* The ECC will not be calculated correctly if less than 512 is written */
39618 /* DBB-
39619 - if (len != 0x200 && eccbuf)
39620 + if (len != 0x200)
39621 printk(KERN_WARNING
39622 "ECC needs a full sector write (adr: %lx size %lx)\n",
39623 (long) to, (long) len);
39624 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39625 index 0c8bb6b..6f35deb 100644
39626 --- a/drivers/mtd/nand/denali.c
39627 +++ b/drivers/mtd/nand/denali.c
39628 @@ -24,6 +24,7 @@
39629 #include <linux/slab.h>
39630 #include <linux/mtd/mtd.h>
39631 #include <linux/module.h>
39632 +#include <linux/slab.h>
39633
39634 #include "denali.h"
39635
39636 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39637 index 51b9d6a..52af9a7 100644
39638 --- a/drivers/mtd/nftlmount.c
39639 +++ b/drivers/mtd/nftlmount.c
39640 @@ -24,6 +24,7 @@
39641 #include <asm/errno.h>
39642 #include <linux/delay.h>
39643 #include <linux/slab.h>
39644 +#include <linux/sched.h>
39645 #include <linux/mtd/mtd.h>
39646 #include <linux/mtd/nand.h>
39647 #include <linux/mtd/nftl.h>
39648 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39649 index 8dd6ba5..419cc1d 100644
39650 --- a/drivers/mtd/sm_ftl.c
39651 +++ b/drivers/mtd/sm_ftl.c
39652 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39653 #define SM_CIS_VENDOR_OFFSET 0x59
39654 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39655 {
39656 - struct attribute_group *attr_group;
39657 + attribute_group_no_const *attr_group;
39658 struct attribute **attributes;
39659 struct sm_sysfs_attribute *vendor_attribute;
39660
39661 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39662 index 27cdf1f..8c37357 100644
39663 --- a/drivers/net/bonding/bond_main.c
39664 +++ b/drivers/net/bonding/bond_main.c
39665 @@ -4859,7 +4859,7 @@ static unsigned int bond_get_num_tx_queues(void)
39666 return tx_queues;
39667 }
39668
39669 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39670 +static struct rtnl_link_ops bond_link_ops = {
39671 .kind = "bond",
39672 .priv_size = sizeof(struct bonding),
39673 .setup = bond_setup,
39674 @@ -4975,8 +4975,8 @@ static void __exit bonding_exit(void)
39675
39676 bond_destroy_debugfs();
39677
39678 - rtnl_link_unregister(&bond_link_ops);
39679 unregister_pernet_subsys(&bond_net_ops);
39680 + rtnl_link_unregister(&bond_link_ops);
39681
39682 #ifdef CONFIG_NET_POLL_CONTROLLER
39683 /*
39684 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39685 index 70dba5d..11a0919 100644
39686 --- a/drivers/net/ethernet/8390/ax88796.c
39687 +++ b/drivers/net/ethernet/8390/ax88796.c
39688 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39689 if (ax->plat->reg_offsets)
39690 ei_local->reg_offset = ax->plat->reg_offsets;
39691 else {
39692 + resource_size_t _mem_size = mem_size;
39693 + do_div(_mem_size, 0x18);
39694 ei_local->reg_offset = ax->reg_offsets;
39695 for (ret = 0; ret < 0x18; ret++)
39696 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39697 + ax->reg_offsets[ret] = _mem_size * ret;
39698 }
39699
39700 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39701 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39702 index 0991534..8098e92 100644
39703 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39704 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39705 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39706 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39707 {
39708 /* RX_MODE controlling object */
39709 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39710 + bnx2x_init_rx_mode_obj(bp);
39711
39712 /* multicast configuration controlling object */
39713 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39714 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39715 index 10bc093..a2fb42a 100644
39716 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39717 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39718 @@ -2136,12 +2136,12 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
39719 break;
39720 default:
39721 BNX2X_ERR("Non valid capability ID\n");
39722 - rval = -EINVAL;
39723 + rval = 1;
39724 break;
39725 }
39726 } else {
39727 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39728 - rval = -EINVAL;
39729 + rval = 1;
39730 }
39731
39732 DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap);
39733 @@ -2167,12 +2167,12 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num)
39734 break;
39735 default:
39736 BNX2X_ERR("Non valid TC-ID\n");
39737 - rval = -EINVAL;
39738 + rval = 1;
39739 break;
39740 }
39741 } else {
39742 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39743 - rval = -EINVAL;
39744 + rval = 1;
39745 }
39746
39747 return rval;
39748 @@ -2185,7 +2185,7 @@ static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num)
39749 return -EINVAL;
39750 }
39751
39752 -static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39753 +static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39754 {
39755 struct bnx2x *bp = netdev_priv(netdev);
39756 DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled);
39757 @@ -2387,12 +2387,12 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
39758 break;
39759 default:
39760 BNX2X_ERR("Non valid featrue-ID\n");
39761 - rval = -EINVAL;
39762 + rval = 1;
39763 break;
39764 }
39765 } else {
39766 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39767 - rval = -EINVAL;
39768 + rval = 1;
39769 }
39770
39771 return rval;
39772 @@ -2428,12 +2428,12 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid,
39773 break;
39774 default:
39775 BNX2X_ERR("Non valid featrue-ID\n");
39776 - rval = -EINVAL;
39777 + rval = 1;
39778 break;
39779 }
39780 } else {
39781 DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
39782 - rval = -EINVAL;
39783 + rval = 1;
39784 }
39785
39786 return rval;
39787 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39788 index 5523da3..4fcf274 100644
39789 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39790 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39791 @@ -4767,7 +4767,7 @@ static void bnx2x_after_function_update(struct bnx2x *bp)
39792 q);
39793 }
39794
39795 - if (!NO_FCOE(bp)) {
39796 + if (!NO_FCOE(bp) && CNIC_ENABLED(bp)) {
39797 fp = &bp->fp[FCOE_IDX(bp)];
39798 queue_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
39799
39800 @@ -13047,6 +13047,7 @@ static int bnx2x_unregister_cnic(struct net_device *dev)
39801 RCU_INIT_POINTER(bp->cnic_ops, NULL);
39802 mutex_unlock(&bp->cnic_mutex);
39803 synchronize_rcu();
39804 + bp->cnic_enabled = false;
39805 kfree(bp->cnic_kwq);
39806 bp->cnic_kwq = NULL;
39807
39808 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39809 index 09b625e..15b16fe 100644
39810 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39811 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39812 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39813 return rc;
39814 }
39815
39816 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39817 - struct bnx2x_rx_mode_obj *o)
39818 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39819 {
39820 if (CHIP_IS_E1x(bp)) {
39821 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39822 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39823 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39824 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39825 } else {
39826 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39827 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39828 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39829 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39830 }
39831 }
39832
39833 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39834 index adbd91b..58ec94a 100644
39835 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39836 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39837 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39838
39839 /********************* RX MODE ****************/
39840
39841 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39842 - struct bnx2x_rx_mode_obj *o);
39843 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39844
39845 /**
39846 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39847 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39848 index d330e81..ce1fb9a 100644
39849 --- a/drivers/net/ethernet/broadcom/tg3.h
39850 +++ b/drivers/net/ethernet/broadcom/tg3.h
39851 @@ -146,6 +146,7 @@
39852 #define CHIPREV_ID_5750_A0 0x4000
39853 #define CHIPREV_ID_5750_A1 0x4001
39854 #define CHIPREV_ID_5750_A3 0x4003
39855 +#define CHIPREV_ID_5750_C1 0x4201
39856 #define CHIPREV_ID_5750_C2 0x4202
39857 #define CHIPREV_ID_5752_A0_HW 0x5000
39858 #define CHIPREV_ID_5752_A0 0x6000
39859 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39860 index 8cffcdf..aadf043 100644
39861 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39862 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39863 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39864 */
39865 struct l2t_skb_cb {
39866 arp_failure_handler_func arp_failure_handler;
39867 -};
39868 +} __no_const;
39869
39870 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39871
39872 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39873 index 4c83003..2a2a5b9 100644
39874 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39875 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39876 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39877 for (i=0; i<ETH_ALEN; i++) {
39878 tmp.addr[i] = dev->dev_addr[i];
39879 }
39880 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39881 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39882 break;
39883
39884 case DE4X5_SET_HWADDR: /* Set the hardware address */
39885 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39886 spin_lock_irqsave(&lp->lock, flags);
39887 memcpy(&statbuf, &lp->pktStats, ioc->len);
39888 spin_unlock_irqrestore(&lp->lock, flags);
39889 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39890 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39891 return -EFAULT;
39892 break;
39893 }
39894 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39895 index 4d6f3c5..6169e60 100644
39896 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39897 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39898 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39899
39900 if (wrapped)
39901 newacc += 65536;
39902 - ACCESS_ONCE(*acc) = newacc;
39903 + ACCESS_ONCE_RW(*acc) = newacc;
39904 }
39905
39906 void be_parse_stats(struct be_adapter *adapter)
39907 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39908 index 74d749e..eefb1bd 100644
39909 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39910 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39911 @@ -31,6 +31,8 @@
39912 #include <linux/netdevice.h>
39913 #include <linux/phy.h>
39914 #include <linux/platform_device.h>
39915 +#include <linux/interrupt.h>
39916 +#include <linux/irqreturn.h>
39917 #include <net/ip.h>
39918
39919 #include "ftgmac100.h"
39920 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39921 index b901a01..1ff32ee 100644
39922 --- a/drivers/net/ethernet/faraday/ftmac100.c
39923 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39924 @@ -31,6 +31,8 @@
39925 #include <linux/module.h>
39926 #include <linux/netdevice.h>
39927 #include <linux/platform_device.h>
39928 +#include <linux/interrupt.h>
39929 +#include <linux/irqreturn.h>
39930
39931 #include "ftmac100.h"
39932
39933 diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
39934 index a59f077..7925d77 100644
39935 --- a/drivers/net/ethernet/intel/e100.c
39936 +++ b/drivers/net/ethernet/intel/e100.c
39937 @@ -870,7 +870,7 @@ err_unlock:
39938 }
39939
39940 static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39941 - void (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39942 + int (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39943 {
39944 struct cb *cb;
39945 unsigned long flags;
39946 @@ -888,10 +888,13 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39947 nic->cbs_avail--;
39948 cb->skb = skb;
39949
39950 + err = cb_prepare(nic, cb, skb);
39951 + if (err)
39952 + goto err_unlock;
39953 +
39954 if (unlikely(!nic->cbs_avail))
39955 err = -ENOSPC;
39956
39957 - cb_prepare(nic, cb, skb);
39958
39959 /* Order is important otherwise we'll be in a race with h/w:
39960 * set S-bit in current first, then clear S-bit in previous. */
39961 @@ -1091,7 +1094,7 @@ static void e100_get_defaults(struct nic *nic)
39962 nic->mii.mdio_write = mdio_write;
39963 }
39964
39965 -static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39966 +static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39967 {
39968 struct config *config = &cb->u.config;
39969 u8 *c = (u8 *)config;
39970 @@ -1181,6 +1184,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39971 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
39972 "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
39973 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
39974 + return 0;
39975 }
39976
39977 /*************************************************************************
39978 @@ -1331,7 +1335,7 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
39979 return fw;
39980 }
39981
39982 -static void e100_setup_ucode(struct nic *nic, struct cb *cb,
39983 +static int e100_setup_ucode(struct nic *nic, struct cb *cb,
39984 struct sk_buff *skb)
39985 {
39986 const struct firmware *fw = (void *)skb;
39987 @@ -1358,6 +1362,7 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb,
39988 cb->u.ucode[min_size] |= cpu_to_le32((BUNDLESMALL) ? 0xFFFF : 0xFF80);
39989
39990 cb->command = cpu_to_le16(cb_ucode | cb_el);
39991 + return 0;
39992 }
39993
39994 static inline int e100_load_ucode_wait(struct nic *nic)
39995 @@ -1400,18 +1405,20 @@ static inline int e100_load_ucode_wait(struct nic *nic)
39996 return err;
39997 }
39998
39999 -static void e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40000 +static int e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40001 struct sk_buff *skb)
40002 {
40003 cb->command = cpu_to_le16(cb_iaaddr);
40004 memcpy(cb->u.iaaddr, nic->netdev->dev_addr, ETH_ALEN);
40005 + return 0;
40006 }
40007
40008 -static void e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40009 +static int e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40010 {
40011 cb->command = cpu_to_le16(cb_dump);
40012 cb->u.dump_buffer_addr = cpu_to_le32(nic->dma_addr +
40013 offsetof(struct mem, dump_buf));
40014 + return 0;
40015 }
40016
40017 static int e100_phy_check_without_mii(struct nic *nic)
40018 @@ -1581,7 +1588,7 @@ static int e100_hw_init(struct nic *nic)
40019 return 0;
40020 }
40021
40022 -static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40023 +static int e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40024 {
40025 struct net_device *netdev = nic->netdev;
40026 struct netdev_hw_addr *ha;
40027 @@ -1596,6 +1603,7 @@ static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40028 memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &ha->addr,
40029 ETH_ALEN);
40030 }
40031 + return 0;
40032 }
40033
40034 static void e100_set_multicast_list(struct net_device *netdev)
40035 @@ -1756,11 +1764,18 @@ static void e100_watchdog(unsigned long data)
40036 round_jiffies(jiffies + E100_WATCHDOG_PERIOD));
40037 }
40038
40039 -static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40040 +static int e100_xmit_prepare(struct nic *nic, struct cb *cb,
40041 struct sk_buff *skb)
40042 {
40043 + dma_addr_t dma_addr;
40044 cb->command = nic->tx_command;
40045
40046 + dma_addr = pci_map_single(nic->pdev,
40047 + skb->data, skb->len, PCI_DMA_TODEVICE);
40048 + /* If we can't map the skb, have the upper layer try later */
40049 + if (pci_dma_mapping_error(nic->pdev, dma_addr))
40050 + return -ENOMEM;
40051 +
40052 /*
40053 * Use the last 4 bytes of the SKB payload packet as the CRC, used for
40054 * testing, ie sending frames with bad CRC.
40055 @@ -1777,11 +1792,10 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40056 cb->u.tcb.tcb_byte_count = 0;
40057 cb->u.tcb.threshold = nic->tx_threshold;
40058 cb->u.tcb.tbd_count = 1;
40059 - cb->u.tcb.tbd.buf_addr = cpu_to_le32(pci_map_single(nic->pdev,
40060 - skb->data, skb->len, PCI_DMA_TODEVICE));
40061 - /* check for mapping failure? */
40062 + cb->u.tcb.tbd.buf_addr = cpu_to_le32(dma_addr);
40063 cb->u.tcb.tbd.size = cpu_to_le16(skb->len);
40064 skb_tx_timestamp(skb);
40065 + return 0;
40066 }
40067
40068 static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
40069 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40070 index bb9256a..56d8752 100644
40071 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40072 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40073 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40074 }
40075
40076 /* update the base incval used to calculate frequency adjustment */
40077 - ACCESS_ONCE(adapter->base_incval) = incval;
40078 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40079 smp_mb();
40080
40081 /* need lock to prevent incorrect read while modifying cyclecounter */
40082 diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
40083 index c124e67..db9b897 100644
40084 --- a/drivers/net/ethernet/lantiq_etop.c
40085 +++ b/drivers/net/ethernet/lantiq_etop.c
40086 @@ -769,7 +769,7 @@ ltq_etop_probe(struct platform_device *pdev)
40087 return 0;
40088
40089 err_free:
40090 - kfree(dev);
40091 + free_netdev(dev);
40092 err_out:
40093 return err;
40094 }
40095 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40096 index fbe5363..266b4e3 100644
40097 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40098 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40099 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40100 struct __vxge_hw_fifo *fifo;
40101 struct vxge_hw_fifo_config *config;
40102 u32 txdl_size, txdl_per_memblock;
40103 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40104 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40105 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40106 + };
40107 +
40108 struct __vxge_hw_virtualpath *vpath;
40109
40110 if ((vp == NULL) || (attr == NULL)) {
40111 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40112 goto exit;
40113 }
40114
40115 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40116 -
40117 fifo->mempool =
40118 __vxge_hw_mempool_create(vpath->hldev,
40119 fifo->config->memblock_size,
40120 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40121 index 2d849da..23bba3b 100644
40122 --- a/drivers/net/ethernet/realtek/r8169.c
40123 +++ b/drivers/net/ethernet/realtek/r8169.c
40124 @@ -741,22 +741,22 @@ struct rtl8169_private {
40125 struct mdio_ops {
40126 void (*write)(struct rtl8169_private *, int, int);
40127 int (*read)(struct rtl8169_private *, int);
40128 - } mdio_ops;
40129 + } __no_const mdio_ops;
40130
40131 struct pll_power_ops {
40132 void (*down)(struct rtl8169_private *);
40133 void (*up)(struct rtl8169_private *);
40134 - } pll_power_ops;
40135 + } __no_const pll_power_ops;
40136
40137 struct jumbo_ops {
40138 void (*enable)(struct rtl8169_private *);
40139 void (*disable)(struct rtl8169_private *);
40140 - } jumbo_ops;
40141 + } __no_const jumbo_ops;
40142
40143 struct csi_ops {
40144 void (*write)(struct rtl8169_private *, int, int);
40145 u32 (*read)(struct rtl8169_private *, int);
40146 - } csi_ops;
40147 + } __no_const csi_ops;
40148
40149 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40150 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40151 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40152 index 3f93624..cf01144 100644
40153 --- a/drivers/net/ethernet/sfc/ptp.c
40154 +++ b/drivers/net/ethernet/sfc/ptp.c
40155 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40156 (u32)((u64)ptp->start.dma_addr >> 32));
40157
40158 /* Clear flag that signals MC ready */
40159 - ACCESS_ONCE(*start) = 0;
40160 + ACCESS_ONCE_RW(*start) = 0;
40161 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40162 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40163
40164 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40165 index 0c74a70..3bc6f68 100644
40166 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40167 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40168 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40169
40170 writel(value, ioaddr + MMC_CNTRL);
40171
40172 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40173 - MMC_CNTRL, value);
40174 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40175 +// MMC_CNTRL, value);
40176 }
40177
40178 /* To mask all all interrupts.*/
40179 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40180 index e6fe0d8..2b7d752 100644
40181 --- a/drivers/net/hyperv/hyperv_net.h
40182 +++ b/drivers/net/hyperv/hyperv_net.h
40183 @@ -101,7 +101,7 @@ struct rndis_device {
40184
40185 enum rndis_device_state state;
40186 bool link_state;
40187 - atomic_t new_req_id;
40188 + atomic_unchecked_t new_req_id;
40189
40190 spinlock_t request_lock;
40191 struct list_head req_list;
40192 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40193 index 2b657d4..9903bc0 100644
40194 --- a/drivers/net/hyperv/rndis_filter.c
40195 +++ b/drivers/net/hyperv/rndis_filter.c
40196 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40197 * template
40198 */
40199 set = &rndis_msg->msg.set_req;
40200 - set->req_id = atomic_inc_return(&dev->new_req_id);
40201 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40202
40203 /* Add to the request list */
40204 spin_lock_irqsave(&dev->request_lock, flags);
40205 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40206
40207 /* Setup the rndis set */
40208 halt = &request->request_msg.msg.halt_req;
40209 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40210 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40211
40212 /* Ignore return since this msg is optional. */
40213 rndis_filter_send_request(dev, request);
40214 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40215 index 1e9cb0b..7839125 100644
40216 --- a/drivers/net/ieee802154/fakehard.c
40217 +++ b/drivers/net/ieee802154/fakehard.c
40218 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40219 phy->transmit_power = 0xbf;
40220
40221 dev->netdev_ops = &fake_ops;
40222 - dev->ml_priv = &fake_mlme;
40223 + dev->ml_priv = (void *)&fake_mlme;
40224
40225 priv = netdev_priv(dev);
40226 priv->phy = phy;
40227 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40228 index e5cb723..1fc0461 100644
40229 --- a/drivers/net/macvlan.c
40230 +++ b/drivers/net/macvlan.c
40231 @@ -852,13 +852,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40232 int macvlan_link_register(struct rtnl_link_ops *ops)
40233 {
40234 /* common fields */
40235 - ops->priv_size = sizeof(struct macvlan_dev);
40236 - ops->validate = macvlan_validate;
40237 - ops->maxtype = IFLA_MACVLAN_MAX;
40238 - ops->policy = macvlan_policy;
40239 - ops->changelink = macvlan_changelink;
40240 - ops->get_size = macvlan_get_size;
40241 - ops->fill_info = macvlan_fill_info;
40242 + pax_open_kernel();
40243 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40244 + *(void **)&ops->validate = macvlan_validate;
40245 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40246 + *(const void **)&ops->policy = macvlan_policy;
40247 + *(void **)&ops->changelink = macvlan_changelink;
40248 + *(void **)&ops->get_size = macvlan_get_size;
40249 + *(void **)&ops->fill_info = macvlan_fill_info;
40250 + pax_close_kernel();
40251
40252 return rtnl_link_register(ops);
40253 };
40254 @@ -914,7 +916,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40255 return NOTIFY_DONE;
40256 }
40257
40258 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40259 +static struct notifier_block macvlan_notifier_block = {
40260 .notifier_call = macvlan_device_event,
40261 };
40262
40263 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40264 index 0f0f9ce..0ca5819 100644
40265 --- a/drivers/net/macvtap.c
40266 +++ b/drivers/net/macvtap.c
40267 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40268 return NOTIFY_DONE;
40269 }
40270
40271 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40272 +static struct notifier_block macvtap_notifier_block = {
40273 .notifier_call = macvtap_device_event,
40274 };
40275
40276 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40277 index daec9b0..6428fcb 100644
40278 --- a/drivers/net/phy/mdio-bitbang.c
40279 +++ b/drivers/net/phy/mdio-bitbang.c
40280 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40281 struct mdiobb_ctrl *ctrl = bus->priv;
40282
40283 module_put(ctrl->ops->owner);
40284 + mdiobus_unregister(bus);
40285 mdiobus_free(bus);
40286 }
40287 EXPORT_SYMBOL(free_mdio_bitbang);
40288 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40289 index 508570e..f706dc7 100644
40290 --- a/drivers/net/ppp/ppp_generic.c
40291 +++ b/drivers/net/ppp/ppp_generic.c
40292 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40293 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40294 struct ppp_stats stats;
40295 struct ppp_comp_stats cstats;
40296 - char *vers;
40297
40298 switch (cmd) {
40299 case SIOCGPPPSTATS:
40300 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40301 break;
40302
40303 case SIOCGPPPVER:
40304 - vers = PPP_VERSION;
40305 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40306 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40307 break;
40308 err = 0;
40309 break;
40310 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40311 index 8efe47a..a8075c5 100644
40312 --- a/drivers/net/team/team.c
40313 +++ b/drivers/net/team/team.c
40314 @@ -2603,7 +2603,7 @@ static int team_device_event(struct notifier_block *unused,
40315 return NOTIFY_DONE;
40316 }
40317
40318 -static struct notifier_block team_notifier_block __read_mostly = {
40319 +static struct notifier_block team_notifier_block = {
40320 .notifier_call = team_device_event,
40321 };
40322
40323 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40324 index cb95fe5..a5bdab5 100644
40325 --- a/drivers/net/tun.c
40326 +++ b/drivers/net/tun.c
40327 @@ -1838,7 +1838,7 @@ unlock:
40328 }
40329
40330 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40331 - unsigned long arg, int ifreq_len)
40332 + unsigned long arg, size_t ifreq_len)
40333 {
40334 struct tun_file *tfile = file->private_data;
40335 struct tun_struct *tun;
40336 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40337 int vnet_hdr_sz;
40338 int ret;
40339
40340 + if (ifreq_len > sizeof ifr)
40341 + return -EFAULT;
40342 +
40343 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40344 if (copy_from_user(&ifr, argp, ifreq_len))
40345 return -EFAULT;
40346 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40347 index cd8ccb2..cff5144 100644
40348 --- a/drivers/net/usb/hso.c
40349 +++ b/drivers/net/usb/hso.c
40350 @@ -71,7 +71,7 @@
40351 #include <asm/byteorder.h>
40352 #include <linux/serial_core.h>
40353 #include <linux/serial.h>
40354 -
40355 +#include <asm/local.h>
40356
40357 #define MOD_AUTHOR "Option Wireless"
40358 #define MOD_DESCRIPTION "USB High Speed Option driver"
40359 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40360 struct urb *urb;
40361
40362 urb = serial->rx_urb[0];
40363 - if (serial->port.count > 0) {
40364 + if (atomic_read(&serial->port.count) > 0) {
40365 count = put_rxbuf_data(urb, serial);
40366 if (count == -1)
40367 return;
40368 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40369 DUMP1(urb->transfer_buffer, urb->actual_length);
40370
40371 /* Anyone listening? */
40372 - if (serial->port.count == 0)
40373 + if (atomic_read(&serial->port.count) == 0)
40374 return;
40375
40376 if (status == 0) {
40377 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40378 tty_port_tty_set(&serial->port, tty);
40379
40380 /* check for port already opened, if not set the termios */
40381 - serial->port.count++;
40382 - if (serial->port.count == 1) {
40383 + if (atomic_inc_return(&serial->port.count) == 1) {
40384 serial->rx_state = RX_IDLE;
40385 /* Force default termio settings */
40386 _hso_serial_set_termios(tty, NULL);
40387 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40388 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40389 if (result) {
40390 hso_stop_serial_device(serial->parent);
40391 - serial->port.count--;
40392 + atomic_dec(&serial->port.count);
40393 kref_put(&serial->parent->ref, hso_serial_ref_free);
40394 }
40395 } else {
40396 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40397
40398 /* reset the rts and dtr */
40399 /* do the actual close */
40400 - serial->port.count--;
40401 + atomic_dec(&serial->port.count);
40402
40403 - if (serial->port.count <= 0) {
40404 - serial->port.count = 0;
40405 + if (atomic_read(&serial->port.count) <= 0) {
40406 + atomic_set(&serial->port.count, 0);
40407 tty_port_tty_set(&serial->port, NULL);
40408 if (!usb_gone)
40409 hso_stop_serial_device(serial->parent);
40410 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40411
40412 /* the actual setup */
40413 spin_lock_irqsave(&serial->serial_lock, flags);
40414 - if (serial->port.count)
40415 + if (atomic_read(&serial->port.count))
40416 _hso_serial_set_termios(tty, old);
40417 else
40418 tty->termios = *old;
40419 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40420 D1("Pending read interrupt on port %d\n", i);
40421 spin_lock(&serial->serial_lock);
40422 if (serial->rx_state == RX_IDLE &&
40423 - serial->port.count > 0) {
40424 + atomic_read(&serial->port.count) > 0) {
40425 /* Setup and send a ctrl req read on
40426 * port i */
40427 if (!serial->rx_urb_filled[0]) {
40428 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
40429 /* Start all serial ports */
40430 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40431 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40432 - if (dev2ser(serial_table[i])->port.count) {
40433 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40434 result =
40435 hso_start_serial_device(serial_table[i], GFP_NOIO);
40436 hso_kick_transmit(dev2ser(serial_table[i]));
40437 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40438 index 6993bfa..9053a34 100644
40439 --- a/drivers/net/vxlan.c
40440 +++ b/drivers/net/vxlan.c
40441 @@ -1428,7 +1428,7 @@ nla_put_failure:
40442 return -EMSGSIZE;
40443 }
40444
40445 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40446 +static struct rtnl_link_ops vxlan_link_ops = {
40447 .kind = "vxlan",
40448 .maxtype = IFLA_VXLAN_MAX,
40449 .policy = vxlan_policy,
40450 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40451 index 77fa428..996b355 100644
40452 --- a/drivers/net/wireless/at76c50x-usb.c
40453 +++ b/drivers/net/wireless/at76c50x-usb.c
40454 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40455 }
40456
40457 /* Convert timeout from the DFU status to jiffies */
40458 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40459 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40460 {
40461 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40462 | (s->poll_timeout[1] << 8)
40463 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40464 index 8d78253..bebbb68 100644
40465 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40466 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40467 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40468 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40469 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40470
40471 - ACCESS_ONCE(ads->ds_link) = i->link;
40472 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40473 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40474 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40475
40476 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40477 ctl6 = SM(i->keytype, AR_EncrType);
40478 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40479
40480 if ((i->is_first || i->is_last) &&
40481 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40482 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40483 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40484 | set11nTries(i->rates, 1)
40485 | set11nTries(i->rates, 2)
40486 | set11nTries(i->rates, 3)
40487 | (i->dur_update ? AR_DurUpdateEna : 0)
40488 | SM(0, AR_BurstDur);
40489
40490 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40491 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40492 | set11nRate(i->rates, 1)
40493 | set11nRate(i->rates, 2)
40494 | set11nRate(i->rates, 3);
40495 } else {
40496 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40497 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40498 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40499 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40500 }
40501
40502 if (!i->is_first) {
40503 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40504 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40505 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40506 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40507 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40508 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40509 return;
40510 }
40511
40512 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40513 break;
40514 }
40515
40516 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40517 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40518 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40519 | SM(i->txpower, AR_XmitPower)
40520 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40521 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40522 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40523 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40524
40525 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40526 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40527 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40528 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40529
40530 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40531 return;
40532
40533 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40534 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40535 | set11nPktDurRTSCTS(i->rates, 1);
40536
40537 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40538 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40539 | set11nPktDurRTSCTS(i->rates, 3);
40540
40541 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40542 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40543 | set11nRateFlags(i->rates, 1)
40544 | set11nRateFlags(i->rates, 2)
40545 | set11nRateFlags(i->rates, 3)
40546 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40547 index 301bf72..3f5654f 100644
40548 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40549 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40550 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40551 (i->qcu << AR_TxQcuNum_S) | desc_len;
40552
40553 checksum += val;
40554 - ACCESS_ONCE(ads->info) = val;
40555 + ACCESS_ONCE_RW(ads->info) = val;
40556
40557 checksum += i->link;
40558 - ACCESS_ONCE(ads->link) = i->link;
40559 + ACCESS_ONCE_RW(ads->link) = i->link;
40560
40561 checksum += i->buf_addr[0];
40562 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40563 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40564 checksum += i->buf_addr[1];
40565 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40566 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40567 checksum += i->buf_addr[2];
40568 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40569 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40570 checksum += i->buf_addr[3];
40571 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40572 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40573
40574 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40575 - ACCESS_ONCE(ads->ctl3) = val;
40576 + ACCESS_ONCE_RW(ads->ctl3) = val;
40577 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40578 - ACCESS_ONCE(ads->ctl5) = val;
40579 + ACCESS_ONCE_RW(ads->ctl5) = val;
40580 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40581 - ACCESS_ONCE(ads->ctl7) = val;
40582 + ACCESS_ONCE_RW(ads->ctl7) = val;
40583 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40584 - ACCESS_ONCE(ads->ctl9) = val;
40585 + ACCESS_ONCE_RW(ads->ctl9) = val;
40586
40587 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40588 - ACCESS_ONCE(ads->ctl10) = checksum;
40589 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40590
40591 if (i->is_first || i->is_last) {
40592 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40593 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40594 | set11nTries(i->rates, 1)
40595 | set11nTries(i->rates, 2)
40596 | set11nTries(i->rates, 3)
40597 | (i->dur_update ? AR_DurUpdateEna : 0)
40598 | SM(0, AR_BurstDur);
40599
40600 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40601 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40602 | set11nRate(i->rates, 1)
40603 | set11nRate(i->rates, 2)
40604 | set11nRate(i->rates, 3);
40605 } else {
40606 - ACCESS_ONCE(ads->ctl13) = 0;
40607 - ACCESS_ONCE(ads->ctl14) = 0;
40608 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40609 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40610 }
40611
40612 ads->ctl20 = 0;
40613 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40614
40615 ctl17 = SM(i->keytype, AR_EncrType);
40616 if (!i->is_first) {
40617 - ACCESS_ONCE(ads->ctl11) = 0;
40618 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40619 - ACCESS_ONCE(ads->ctl15) = 0;
40620 - ACCESS_ONCE(ads->ctl16) = 0;
40621 - ACCESS_ONCE(ads->ctl17) = ctl17;
40622 - ACCESS_ONCE(ads->ctl18) = 0;
40623 - ACCESS_ONCE(ads->ctl19) = 0;
40624 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40625 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40626 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40627 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40628 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40629 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40630 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40631 return;
40632 }
40633
40634 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40635 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40636 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40637 | SM(i->txpower, AR_XmitPower)
40638 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40639 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40640 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40641 ctl12 |= SM(val, AR_PAPRDChainMask);
40642
40643 - ACCESS_ONCE(ads->ctl12) = ctl12;
40644 - ACCESS_ONCE(ads->ctl17) = ctl17;
40645 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40646 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40647
40648 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40649 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40650 | set11nPktDurRTSCTS(i->rates, 1);
40651
40652 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40653 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40654 | set11nPktDurRTSCTS(i->rates, 3);
40655
40656 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40657 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40658 | set11nRateFlags(i->rates, 1)
40659 | set11nRateFlags(i->rates, 2)
40660 | set11nRateFlags(i->rates, 3)
40661 | SM(i->rtscts_rate, AR_RTSCTSRate);
40662
40663 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40664 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40665 }
40666
40667 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40668 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40669 index 9d26fc5..60d9f14 100644
40670 --- a/drivers/net/wireless/ath/ath9k/hw.h
40671 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40672 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
40673
40674 /* ANI */
40675 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40676 -};
40677 +} __no_const;
40678
40679 /**
40680 * struct ath_hw_ops - callbacks used by hardware code and driver code
40681 @@ -688,7 +688,7 @@ struct ath_hw_ops {
40682 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
40683 struct ath_hw_antcomb_conf *antconf);
40684 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
40685 -};
40686 +} __no_const;
40687
40688 struct ath_nf_limits {
40689 s16 max;
40690 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40691 index 3726cd6..b655808 100644
40692 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40693 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40694 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40695 */
40696 if (il3945_mod_params.disable_hw_scan) {
40697 D_INFO("Disabling hw_scan\n");
40698 - il3945_mac_ops.hw_scan = NULL;
40699 + pax_open_kernel();
40700 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40701 + pax_close_kernel();
40702 }
40703
40704 D_INFO("*** LOAD DRIVER ***\n");
40705 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40706 index 5b9533e..7733880 100644
40707 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40708 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40709 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40710 {
40711 struct iwl_priv *priv = file->private_data;
40712 char buf[64];
40713 - int buf_size;
40714 + size_t buf_size;
40715 u32 offset, len;
40716
40717 memset(buf, 0, sizeof(buf));
40718 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40719 struct iwl_priv *priv = file->private_data;
40720
40721 char buf[8];
40722 - int buf_size;
40723 + size_t buf_size;
40724 u32 reset_flag;
40725
40726 memset(buf, 0, sizeof(buf));
40727 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40728 {
40729 struct iwl_priv *priv = file->private_data;
40730 char buf[8];
40731 - int buf_size;
40732 + size_t buf_size;
40733 int ht40;
40734
40735 memset(buf, 0, sizeof(buf));
40736 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40737 {
40738 struct iwl_priv *priv = file->private_data;
40739 char buf[8];
40740 - int buf_size;
40741 + size_t buf_size;
40742 int value;
40743
40744 memset(buf, 0, sizeof(buf));
40745 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40746 {
40747 struct iwl_priv *priv = file->private_data;
40748 char buf[8];
40749 - int buf_size;
40750 + size_t buf_size;
40751 int clear;
40752
40753 memset(buf, 0, sizeof(buf));
40754 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_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 trace;
40761
40762 memset(buf, 0, sizeof(buf));
40763 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_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 missed;
40770
40771 memset(buf, 0, sizeof(buf));
40772 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_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 plcp;
40779
40780 memset(buf, 0, sizeof(buf));
40781 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_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 flush;
40788
40789 memset(buf, 0, sizeof(buf));
40790 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_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 rts;
40797
40798 if (!priv->cfg->ht_params)
40799 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_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
40806 memset(buf, 0, sizeof(buf));
40807 buf_size = min(count, sizeof(buf) - 1);
40808 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40809 struct iwl_priv *priv = file->private_data;
40810 u32 event_log_flag;
40811 char buf[8];
40812 - int buf_size;
40813 + size_t buf_size;
40814
40815 /* check that the interface is up */
40816 if (!iwl_is_ready(priv))
40817 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40818 struct iwl_priv *priv = file->private_data;
40819 char buf[8];
40820 u32 calib_disabled;
40821 - int buf_size;
40822 + size_t buf_size;
40823
40824 memset(buf, 0, sizeof(buf));
40825 buf_size = min(count, sizeof(buf) - 1);
40826 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40827 index 35708b9..31f7754 100644
40828 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40829 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40830 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40831 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40832
40833 char buf[8];
40834 - int buf_size;
40835 + size_t buf_size;
40836 u32 reset_flag;
40837
40838 memset(buf, 0, sizeof(buf));
40839 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40840 {
40841 struct iwl_trans *trans = file->private_data;
40842 char buf[8];
40843 - int buf_size;
40844 + size_t buf_size;
40845 int csr;
40846
40847 memset(buf, 0, sizeof(buf));
40848 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40849 index ff90855..e46d223 100644
40850 --- a/drivers/net/wireless/mac80211_hwsim.c
40851 +++ b/drivers/net/wireless/mac80211_hwsim.c
40852 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
40853
40854 if (channels > 1) {
40855 hwsim_if_comb.num_different_channels = channels;
40856 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40857 - mac80211_hwsim_ops.cancel_hw_scan =
40858 - mac80211_hwsim_cancel_hw_scan;
40859 - mac80211_hwsim_ops.sw_scan_start = NULL;
40860 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40861 - mac80211_hwsim_ops.remain_on_channel =
40862 - mac80211_hwsim_roc;
40863 - mac80211_hwsim_ops.cancel_remain_on_channel =
40864 - mac80211_hwsim_croc;
40865 - mac80211_hwsim_ops.add_chanctx =
40866 - mac80211_hwsim_add_chanctx;
40867 - mac80211_hwsim_ops.remove_chanctx =
40868 - mac80211_hwsim_remove_chanctx;
40869 - mac80211_hwsim_ops.change_chanctx =
40870 - mac80211_hwsim_change_chanctx;
40871 - mac80211_hwsim_ops.assign_vif_chanctx =
40872 - mac80211_hwsim_assign_vif_chanctx;
40873 - mac80211_hwsim_ops.unassign_vif_chanctx =
40874 - mac80211_hwsim_unassign_vif_chanctx;
40875 + pax_open_kernel();
40876 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40877 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40878 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40879 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40880 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40881 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40882 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40883 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40884 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40885 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40886 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40887 + pax_close_kernel();
40888 }
40889
40890 spin_lock_init(&hwsim_radio_lock);
40891 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40892 index abe1d03..fb02c22 100644
40893 --- a/drivers/net/wireless/rndis_wlan.c
40894 +++ b/drivers/net/wireless/rndis_wlan.c
40895 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40896
40897 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40898
40899 - if (rts_threshold < 0 || rts_threshold > 2347)
40900 + if (rts_threshold > 2347)
40901 rts_threshold = 2347;
40902
40903 tmp = cpu_to_le32(rts_threshold);
40904 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40905 index 0751b35..246ba3e 100644
40906 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40907 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40908 @@ -398,7 +398,7 @@ struct rt2x00_intf {
40909 * for hardware which doesn't support hardware
40910 * sequence counting.
40911 */
40912 - atomic_t seqno;
40913 + atomic_unchecked_t seqno;
40914 };
40915
40916 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40917 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40918 index e488b94..14b6a0c 100644
40919 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40920 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40921 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40922 * sequence counter given by mac80211.
40923 */
40924 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40925 - seqno = atomic_add_return(0x10, &intf->seqno);
40926 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40927 else
40928 - seqno = atomic_read(&intf->seqno);
40929 + seqno = atomic_read_unchecked(&intf->seqno);
40930
40931 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40932 hdr->seq_ctrl |= cpu_to_le16(seqno);
40933 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40934 index e57ee48..541cf6c 100644
40935 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40936 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40937 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40938
40939 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40940
40941 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40942 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40943 + pax_open_kernel();
40944 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40945 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40946 + pax_close_kernel();
40947
40948 wl1251_info("using dedicated interrupt line");
40949 } else {
40950 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40951 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40952 + pax_open_kernel();
40953 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40954 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40955 + pax_close_kernel();
40956
40957 wl1251_info("using SDIO interrupt");
40958 }
40959 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40960 index e5f5f8f..fdf15b7 100644
40961 --- a/drivers/net/wireless/ti/wl12xx/main.c
40962 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40963 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40964 sizeof(wl->conf.mem));
40965
40966 /* read data preparation is only needed by wl127x */
40967 - wl->ops->prepare_read = wl127x_prepare_read;
40968 + pax_open_kernel();
40969 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40970 + pax_close_kernel();
40971
40972 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40973 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40974 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40975 sizeof(wl->conf.mem));
40976
40977 /* read data preparation is only needed by wl127x */
40978 - wl->ops->prepare_read = wl127x_prepare_read;
40979 + pax_open_kernel();
40980 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40981 + pax_close_kernel();
40982
40983 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40984 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40985 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40986 index 8d8c1f8..e754844 100644
40987 --- a/drivers/net/wireless/ti/wl18xx/main.c
40988 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40989 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40990 }
40991
40992 if (!checksum_param) {
40993 - wl18xx_ops.set_rx_csum = NULL;
40994 - wl18xx_ops.init_vif = NULL;
40995 + pax_open_kernel();
40996 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40997 + *(void **)&wl18xx_ops.init_vif = NULL;
40998 + pax_close_kernel();
40999 }
41000
41001 /* Enable 11a Band only if we have 5G antennas */
41002 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41003 index ef2b171..bb513a6 100644
41004 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41005 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41006 @@ -387,7 +387,7 @@ static inline void handle_regs_int(struct urb *urb)
41007 {
41008 struct zd_usb *usb = urb->context;
41009 struct zd_usb_interrupt *intr = &usb->intr;
41010 - int len;
41011 + unsigned int len;
41012 u16 int_num;
41013
41014 ZD_ASSERT(in_interrupt());
41015 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41016 index d93b2b6..ae50401 100644
41017 --- a/drivers/oprofile/buffer_sync.c
41018 +++ b/drivers/oprofile/buffer_sync.c
41019 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41020 if (cookie == NO_COOKIE)
41021 offset = pc;
41022 if (cookie == INVALID_COOKIE) {
41023 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41024 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41025 offset = pc;
41026 }
41027 if (cookie != last_cookie) {
41028 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41029 /* add userspace sample */
41030
41031 if (!mm) {
41032 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41033 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41034 return 0;
41035 }
41036
41037 cookie = lookup_dcookie(mm, s->eip, &offset);
41038
41039 if (cookie == INVALID_COOKIE) {
41040 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41041 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41042 return 0;
41043 }
41044
41045 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41046 /* ignore backtraces if failed to add a sample */
41047 if (state == sb_bt_start) {
41048 state = sb_bt_ignore;
41049 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41050 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41051 }
41052 }
41053 release_mm(mm);
41054 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41055 index c0cc4e7..44d4e54 100644
41056 --- a/drivers/oprofile/event_buffer.c
41057 +++ b/drivers/oprofile/event_buffer.c
41058 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41059 }
41060
41061 if (buffer_pos == buffer_size) {
41062 - atomic_inc(&oprofile_stats.event_lost_overflow);
41063 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41064 return;
41065 }
41066
41067 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41068 index ed2c3ec..deda85a 100644
41069 --- a/drivers/oprofile/oprof.c
41070 +++ b/drivers/oprofile/oprof.c
41071 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41072 if (oprofile_ops.switch_events())
41073 return;
41074
41075 - atomic_inc(&oprofile_stats.multiplex_counter);
41076 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41077 start_switch_worker();
41078 }
41079
41080 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41081 index 84a208d..d61b0a1 100644
41082 --- a/drivers/oprofile/oprofile_files.c
41083 +++ b/drivers/oprofile/oprofile_files.c
41084 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41085
41086 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41087
41088 -static ssize_t timeout_read(struct file *file, char __user *buf,
41089 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41090 size_t count, loff_t *offset)
41091 {
41092 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41093 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41094 index 917d28e..d62d981 100644
41095 --- a/drivers/oprofile/oprofile_stats.c
41096 +++ b/drivers/oprofile/oprofile_stats.c
41097 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41098 cpu_buf->sample_invalid_eip = 0;
41099 }
41100
41101 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41102 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41103 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41104 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41105 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41106 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41107 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41108 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41109 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41110 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41111 }
41112
41113
41114 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41115 index 38b6fc0..b5cbfce 100644
41116 --- a/drivers/oprofile/oprofile_stats.h
41117 +++ b/drivers/oprofile/oprofile_stats.h
41118 @@ -13,11 +13,11 @@
41119 #include <linux/atomic.h>
41120
41121 struct oprofile_stat_struct {
41122 - atomic_t sample_lost_no_mm;
41123 - atomic_t sample_lost_no_mapping;
41124 - atomic_t bt_lost_no_mapping;
41125 - atomic_t event_lost_overflow;
41126 - atomic_t multiplex_counter;
41127 + atomic_unchecked_t sample_lost_no_mm;
41128 + atomic_unchecked_t sample_lost_no_mapping;
41129 + atomic_unchecked_t bt_lost_no_mapping;
41130 + atomic_unchecked_t event_lost_overflow;
41131 + atomic_unchecked_t multiplex_counter;
41132 };
41133
41134 extern struct oprofile_stat_struct oprofile_stats;
41135 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41136 index 849357c..b83c1e0 100644
41137 --- a/drivers/oprofile/oprofilefs.c
41138 +++ b/drivers/oprofile/oprofilefs.c
41139 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
41140
41141
41142 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41143 - char const *name, atomic_t *val)
41144 + char const *name, atomic_unchecked_t *val)
41145 {
41146 return __oprofilefs_create_file(sb, root, name,
41147 &atomic_ro_fops, 0444, val);
41148 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41149 index 93404f7..4a313d8 100644
41150 --- a/drivers/oprofile/timer_int.c
41151 +++ b/drivers/oprofile/timer_int.c
41152 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41153 return NOTIFY_OK;
41154 }
41155
41156 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41157 +static struct notifier_block oprofile_cpu_notifier = {
41158 .notifier_call = oprofile_cpu_notify,
41159 };
41160
41161 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41162 index 3f56bc0..707d642 100644
41163 --- a/drivers/parport/procfs.c
41164 +++ b/drivers/parport/procfs.c
41165 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41166
41167 *ppos += len;
41168
41169 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41170 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41171 }
41172
41173 #ifdef CONFIG_PARPORT_1284
41174 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41175
41176 *ppos += len;
41177
41178 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41179 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41180 }
41181 #endif /* IEEE1284.3 support. */
41182
41183 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41184 index c35e8ad..fc33beb 100644
41185 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41186 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41187 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41188 goto init_cleanup;
41189 }
41190
41191 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41192 + pax_open_kernel();
41193 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41194 + pax_close_kernel();
41195 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41196
41197 return retval;
41198 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41199 index a6a71c4..c91097b 100644
41200 --- a/drivers/pci/hotplug/cpcihp_generic.c
41201 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41202 @@ -73,7 +73,6 @@ static u16 port;
41203 static unsigned int enum_bit;
41204 static u8 enum_mask;
41205
41206 -static struct cpci_hp_controller_ops generic_hpc_ops;
41207 static struct cpci_hp_controller generic_hpc;
41208
41209 static int __init validate_parameters(void)
41210 @@ -139,6 +138,10 @@ static int query_enum(void)
41211 return ((value & enum_mask) == enum_mask);
41212 }
41213
41214 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41215 + .query_enum = query_enum,
41216 +};
41217 +
41218 static int __init cpcihp_generic_init(void)
41219 {
41220 int status;
41221 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41222 pci_dev_put(dev);
41223
41224 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41225 - generic_hpc_ops.query_enum = query_enum;
41226 generic_hpc.ops = &generic_hpc_ops;
41227
41228 status = cpci_hp_register_controller(&generic_hpc);
41229 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41230 index 449b4bb..257e2e8 100644
41231 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41232 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41233 @@ -59,7 +59,6 @@
41234 /* local variables */
41235 static bool debug;
41236 static bool poll;
41237 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41238 static struct cpci_hp_controller zt5550_hpc;
41239
41240 /* Primary cPCI bus bridge device */
41241 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41242 return 0;
41243 }
41244
41245 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41246 + .query_enum = zt5550_hc_query_enum,
41247 +};
41248 +
41249 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41250 {
41251 int status;
41252 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41253 dbg("returned from zt5550_hc_config");
41254
41255 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41256 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41257 zt5550_hpc.ops = &zt5550_hpc_ops;
41258 if(!poll) {
41259 zt5550_hpc.irq = hc_dev->irq;
41260 zt5550_hpc.irq_flags = IRQF_SHARED;
41261 zt5550_hpc.dev_id = hc_dev;
41262
41263 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41264 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41265 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41266 + pax_open_kernel();
41267 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41268 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41269 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41270 + pax_open_kernel();
41271 } else {
41272 info("using ENUM# polling mode");
41273 }
41274 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41275 index 76ba8a1..20ca857 100644
41276 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41277 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41278 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41279
41280 void compaq_nvram_init (void __iomem *rom_start)
41281 {
41282 +
41283 +#ifndef CONFIG_PAX_KERNEXEC
41284 if (rom_start) {
41285 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41286 }
41287 +#endif
41288 +
41289 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41290
41291 /* initialize our int15 lock */
41292 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41293 index 202f4a9..8ee47d0 100644
41294 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41295 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41296 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41297 return -EINVAL;
41298 }
41299
41300 - slot->ops->owner = owner;
41301 - slot->ops->mod_name = mod_name;
41302 + pax_open_kernel();
41303 + *(struct module **)&slot->ops->owner = owner;
41304 + *(const char **)&slot->ops->mod_name = mod_name;
41305 + pax_close_kernel();
41306
41307 mutex_lock(&pci_hp_mutex);
41308 /*
41309 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41310 index 939bd1d..a1459c9 100644
41311 --- a/drivers/pci/hotplug/pciehp_core.c
41312 +++ b/drivers/pci/hotplug/pciehp_core.c
41313 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41314 struct slot *slot = ctrl->slot;
41315 struct hotplug_slot *hotplug = NULL;
41316 struct hotplug_slot_info *info = NULL;
41317 - struct hotplug_slot_ops *ops = NULL;
41318 + hotplug_slot_ops_no_const *ops = NULL;
41319 char name[SLOT_NAME_SIZE];
41320 int retval = -ENOMEM;
41321
41322 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41323 index 9c6e9bb..2916736 100644
41324 --- a/drivers/pci/pci-sysfs.c
41325 +++ b/drivers/pci/pci-sysfs.c
41326 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41327 {
41328 /* allocate attribute structure, piggyback attribute name */
41329 int name_len = write_combine ? 13 : 10;
41330 - struct bin_attribute *res_attr;
41331 + bin_attribute_no_const *res_attr;
41332 int retval;
41333
41334 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41335 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41336 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41337 {
41338 int retval;
41339 - struct bin_attribute *attr;
41340 + bin_attribute_no_const *attr;
41341
41342 /* If the device has VPD, try to expose it in sysfs. */
41343 if (dev->vpd) {
41344 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41345 {
41346 int retval;
41347 int rom_size = 0;
41348 - struct bin_attribute *attr;
41349 + bin_attribute_no_const *attr;
41350
41351 if (!sysfs_initialized)
41352 return -EACCES;
41353 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41354 index e851829..a1a7196 100644
41355 --- a/drivers/pci/pci.h
41356 +++ b/drivers/pci/pci.h
41357 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
41358 struct pci_vpd {
41359 unsigned int len;
41360 const struct pci_vpd_ops *ops;
41361 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41362 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41363 };
41364
41365 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41366 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41367 index 8474b6a..ee81993 100644
41368 --- a/drivers/pci/pcie/aspm.c
41369 +++ b/drivers/pci/pcie/aspm.c
41370 @@ -27,9 +27,9 @@
41371 #define MODULE_PARAM_PREFIX "pcie_aspm."
41372
41373 /* Note: those are not register definitions */
41374 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41375 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41376 -#define ASPM_STATE_L1 (4) /* L1 state */
41377 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41378 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41379 +#define ASPM_STATE_L1 (4U) /* L1 state */
41380 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41381 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41382
41383 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41384 index 6186f03..1a78714 100644
41385 --- a/drivers/pci/probe.c
41386 +++ b/drivers/pci/probe.c
41387 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41388 struct pci_bus_region region;
41389 bool bar_too_big = false, bar_disabled = false;
41390
41391 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41392 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41393
41394 /* No printks while decoding is disabled! */
41395 if (!dev->mmio_always_on) {
41396 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41397 index 9b8505c..f00870a 100644
41398 --- a/drivers/pci/proc.c
41399 +++ b/drivers/pci/proc.c
41400 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41401 static int __init pci_proc_init(void)
41402 {
41403 struct pci_dev *dev = NULL;
41404 +
41405 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41406 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41407 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41408 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41409 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41410 +#endif
41411 +#else
41412 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41413 +#endif
41414 proc_create("devices", 0, proc_bus_pci_dir,
41415 &proc_bus_pci_dev_operations);
41416 proc_initialized = 1;
41417 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41418 index 2111dbb..79e434b 100644
41419 --- a/drivers/platform/x86/msi-laptop.c
41420 +++ b/drivers/platform/x86/msi-laptop.c
41421 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41422 int result;
41423
41424 /* allow userland write sysfs file */
41425 - dev_attr_bluetooth.store = store_bluetooth;
41426 - dev_attr_wlan.store = store_wlan;
41427 - dev_attr_threeg.store = store_threeg;
41428 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41429 - dev_attr_wlan.attr.mode |= S_IWUSR;
41430 - dev_attr_threeg.attr.mode |= S_IWUSR;
41431 + pax_open_kernel();
41432 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41433 + *(void **)&dev_attr_wlan.store = store_wlan;
41434 + *(void **)&dev_attr_threeg.store = store_threeg;
41435 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41436 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41437 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41438 + pax_close_kernel();
41439
41440 /* disable hardware control by fn key */
41441 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
41442 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41443 index 0fe987f..6f3d5c3 100644
41444 --- a/drivers/platform/x86/sony-laptop.c
41445 +++ b/drivers/platform/x86/sony-laptop.c
41446 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
41447 }
41448
41449 /* High speed charging function */
41450 -static struct device_attribute *hsc_handle;
41451 +static device_attribute_no_const *hsc_handle;
41452
41453 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41454 struct device_attribute *attr,
41455 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41456 index f946ca7..f25c833 100644
41457 --- a/drivers/platform/x86/thinkpad_acpi.c
41458 +++ b/drivers/platform/x86/thinkpad_acpi.c
41459 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
41460 return 0;
41461 }
41462
41463 -void static hotkey_mask_warn_incomplete_mask(void)
41464 +static void hotkey_mask_warn_incomplete_mask(void)
41465 {
41466 /* log only what the user can fix... */
41467 const u32 wantedmask = hotkey_driver_mask &
41468 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41469 }
41470 }
41471
41472 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41473 - struct tp_nvram_state *newn,
41474 - const u32 event_mask)
41475 -{
41476 -
41477 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41478 do { \
41479 if ((event_mask & (1 << __scancode)) && \
41480 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41481 tpacpi_hotkey_send_key(__scancode); \
41482 } while (0)
41483
41484 - void issue_volchange(const unsigned int oldvol,
41485 - const unsigned int newvol)
41486 - {
41487 - unsigned int i = oldvol;
41488 +static void issue_volchange(const unsigned int oldvol,
41489 + const unsigned int newvol,
41490 + const u32 event_mask)
41491 +{
41492 + unsigned int i = oldvol;
41493
41494 - while (i > newvol) {
41495 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41496 - i--;
41497 - }
41498 - while (i < newvol) {
41499 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41500 - i++;
41501 - }
41502 + while (i > newvol) {
41503 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41504 + i--;
41505 }
41506 + while (i < newvol) {
41507 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41508 + i++;
41509 + }
41510 +}
41511
41512 - void issue_brightnesschange(const unsigned int oldbrt,
41513 - const unsigned int newbrt)
41514 - {
41515 - unsigned int i = oldbrt;
41516 +static void issue_brightnesschange(const unsigned int oldbrt,
41517 + const unsigned int newbrt,
41518 + const u32 event_mask)
41519 +{
41520 + unsigned int i = oldbrt;
41521
41522 - while (i > newbrt) {
41523 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41524 - i--;
41525 - }
41526 - while (i < newbrt) {
41527 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41528 - i++;
41529 - }
41530 + while (i > newbrt) {
41531 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41532 + i--;
41533 + }
41534 + while (i < newbrt) {
41535 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41536 + i++;
41537 }
41538 +}
41539
41540 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41541 + struct tp_nvram_state *newn,
41542 + const u32 event_mask)
41543 +{
41544 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41545 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41546 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41547 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41548 oldn->volume_level != newn->volume_level) {
41549 /* recently muted, or repeated mute keypress, or
41550 * multiple presses ending in mute */
41551 - issue_volchange(oldn->volume_level, newn->volume_level);
41552 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41553 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41554 }
41555 } else {
41556 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41557 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41558 }
41559 if (oldn->volume_level != newn->volume_level) {
41560 - issue_volchange(oldn->volume_level, newn->volume_level);
41561 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41562 } else if (oldn->volume_toggle != newn->volume_toggle) {
41563 /* repeated vol up/down keypress at end of scale ? */
41564 if (newn->volume_level == 0)
41565 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41566 /* handle brightness */
41567 if (oldn->brightness_level != newn->brightness_level) {
41568 issue_brightnesschange(oldn->brightness_level,
41569 - newn->brightness_level);
41570 + newn->brightness_level,
41571 + event_mask);
41572 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41573 /* repeated key presses that didn't change state */
41574 if (newn->brightness_level == 0)
41575 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41576 && !tp_features.bright_unkfw)
41577 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41578 }
41579 +}
41580
41581 #undef TPACPI_COMPARE_KEY
41582 #undef TPACPI_MAY_SEND_KEY
41583 -}
41584
41585 /*
41586 * Polling driver
41587 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41588 index 769d265..a3a05ca 100644
41589 --- a/drivers/pnp/pnpbios/bioscalls.c
41590 +++ b/drivers/pnp/pnpbios/bioscalls.c
41591 @@ -58,7 +58,7 @@ do { \
41592 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41593 } while(0)
41594
41595 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41596 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41597 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41598
41599 /*
41600 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41601
41602 cpu = get_cpu();
41603 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41604 +
41605 + pax_open_kernel();
41606 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41607 + pax_close_kernel();
41608
41609 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41610 spin_lock_irqsave(&pnp_bios_lock, flags);
41611 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41612 :"memory");
41613 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41614
41615 + pax_open_kernel();
41616 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41617 + pax_close_kernel();
41618 +
41619 put_cpu();
41620
41621 /* If we get here and this is set then the PnP BIOS faulted on us. */
41622 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41623 return status;
41624 }
41625
41626 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41627 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41628 {
41629 int i;
41630
41631 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41632 pnp_bios_callpoint.offset = header->fields.pm16offset;
41633 pnp_bios_callpoint.segment = PNP_CS16;
41634
41635 + pax_open_kernel();
41636 +
41637 for_each_possible_cpu(i) {
41638 struct desc_struct *gdt = get_cpu_gdt_table(i);
41639 if (!gdt)
41640 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41641 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41642 (unsigned long)__va(header->fields.pm16dseg));
41643 }
41644 +
41645 + pax_close_kernel();
41646 }
41647 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41648 index 3e6db1c..1fbbdae 100644
41649 --- a/drivers/pnp/resource.c
41650 +++ b/drivers/pnp/resource.c
41651 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41652 return 1;
41653
41654 /* check if the resource is valid */
41655 - if (*irq < 0 || *irq > 15)
41656 + if (*irq > 15)
41657 return 0;
41658
41659 /* check if the resource is reserved */
41660 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41661 return 1;
41662
41663 /* check if the resource is valid */
41664 - if (*dma < 0 || *dma == 4 || *dma > 7)
41665 + if (*dma == 4 || *dma > 7)
41666 return 0;
41667
41668 /* check if the resource is reserved */
41669 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41670 index 7df7c5f..bd48c47 100644
41671 --- a/drivers/power/pda_power.c
41672 +++ b/drivers/power/pda_power.c
41673 @@ -37,7 +37,11 @@ static int polling;
41674
41675 #ifdef CONFIG_USB_OTG_UTILS
41676 static struct usb_phy *transceiver;
41677 -static struct notifier_block otg_nb;
41678 +static int otg_handle_notification(struct notifier_block *nb,
41679 + unsigned long event, void *unused);
41680 +static struct notifier_block otg_nb = {
41681 + .notifier_call = otg_handle_notification
41682 +};
41683 #endif
41684
41685 static struct regulator *ac_draw;
41686 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41687
41688 #ifdef CONFIG_USB_OTG_UTILS
41689 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41690 - otg_nb.notifier_call = otg_handle_notification;
41691 ret = usb_register_notifier(transceiver, &otg_nb);
41692 if (ret) {
41693 dev_err(dev, "failure to register otg notifier\n");
41694 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41695 index cc439fd..8fa30df 100644
41696 --- a/drivers/power/power_supply.h
41697 +++ b/drivers/power/power_supply.h
41698 @@ -16,12 +16,12 @@ struct power_supply;
41699
41700 #ifdef CONFIG_SYSFS
41701
41702 -extern void power_supply_init_attrs(struct device_type *dev_type);
41703 +extern void power_supply_init_attrs(void);
41704 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41705
41706 #else
41707
41708 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41709 +static inline void power_supply_init_attrs(void) {}
41710 #define power_supply_uevent NULL
41711
41712 #endif /* CONFIG_SYSFS */
41713 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41714 index 8a7cfb3..72e6e9b 100644
41715 --- a/drivers/power/power_supply_core.c
41716 +++ b/drivers/power/power_supply_core.c
41717 @@ -24,7 +24,10 @@
41718 struct class *power_supply_class;
41719 EXPORT_SYMBOL_GPL(power_supply_class);
41720
41721 -static struct device_type power_supply_dev_type;
41722 +extern const struct attribute_group *power_supply_attr_groups[];
41723 +static struct device_type power_supply_dev_type = {
41724 + .groups = power_supply_attr_groups,
41725 +};
41726
41727 static int __power_supply_changed_work(struct device *dev, void *data)
41728 {
41729 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41730 return PTR_ERR(power_supply_class);
41731
41732 power_supply_class->dev_uevent = power_supply_uevent;
41733 - power_supply_init_attrs(&power_supply_dev_type);
41734 + power_supply_init_attrs();
41735
41736 return 0;
41737 }
41738 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41739 index 40fa3b7..d9c2e0e 100644
41740 --- a/drivers/power/power_supply_sysfs.c
41741 +++ b/drivers/power/power_supply_sysfs.c
41742 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
41743 .is_visible = power_supply_attr_is_visible,
41744 };
41745
41746 -static const struct attribute_group *power_supply_attr_groups[] = {
41747 +const struct attribute_group *power_supply_attr_groups[] = {
41748 &power_supply_attr_group,
41749 NULL,
41750 };
41751
41752 -void power_supply_init_attrs(struct device_type *dev_type)
41753 +void power_supply_init_attrs(void)
41754 {
41755 int i;
41756
41757 - dev_type->groups = power_supply_attr_groups;
41758 -
41759 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41760 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41761 }
41762 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41763 index 4d7c635..9860196 100644
41764 --- a/drivers/regulator/max8660.c
41765 +++ b/drivers/regulator/max8660.c
41766 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41767 max8660->shadow_regs[MAX8660_OVER1] = 5;
41768 } else {
41769 /* Otherwise devices can be toggled via software */
41770 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41771 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41772 + pax_open_kernel();
41773 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41774 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41775 + pax_close_kernel();
41776 }
41777
41778 /*
41779 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41780 index 9a8ea91..c483dd9 100644
41781 --- a/drivers/regulator/max8973-regulator.c
41782 +++ b/drivers/regulator/max8973-regulator.c
41783 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41784 if (!pdata->enable_ext_control) {
41785 max->desc.enable_reg = MAX8973_VOUT;
41786 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41787 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41788 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41789 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41790 + pax_open_kernel();
41791 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41792 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41793 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41794 + pax_close_kernel();
41795 }
41796
41797 max->enable_external_control = pdata->enable_ext_control;
41798 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41799 index 0d84b1f..c2da6ac 100644
41800 --- a/drivers/regulator/mc13892-regulator.c
41801 +++ b/drivers/regulator/mc13892-regulator.c
41802 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41803 }
41804 mc13xxx_unlock(mc13892);
41805
41806 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41807 + pax_open_kernel();
41808 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41809 = mc13892_vcam_set_mode;
41810 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41811 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41812 = mc13892_vcam_get_mode;
41813 + pax_close_kernel();
41814
41815 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41816 ARRAY_SIZE(mc13892_regulators));
41817 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41818 index 16630aa..6afc992 100644
41819 --- a/drivers/rtc/rtc-cmos.c
41820 +++ b/drivers/rtc/rtc-cmos.c
41821 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41822 hpet_rtc_timer_init();
41823
41824 /* export at least the first block of NVRAM */
41825 - nvram.size = address_space - NVRAM_OFFSET;
41826 + pax_open_kernel();
41827 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41828 + pax_close_kernel();
41829 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41830 if (retval < 0) {
41831 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41832 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41833 index 9a86b4b..3a383dc 100644
41834 --- a/drivers/rtc/rtc-dev.c
41835 +++ b/drivers/rtc/rtc-dev.c
41836 @@ -14,6 +14,7 @@
41837 #include <linux/module.h>
41838 #include <linux/rtc.h>
41839 #include <linux/sched.h>
41840 +#include <linux/grsecurity.h>
41841 #include "rtc-core.h"
41842
41843 static dev_t rtc_devt;
41844 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
41845 if (copy_from_user(&tm, uarg, sizeof(tm)))
41846 return -EFAULT;
41847
41848 + gr_log_timechange();
41849 +
41850 return rtc_set_time(rtc, &tm);
41851
41852 case RTC_PIE_ON:
41853 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41854 index e0d0ba4..3c65868 100644
41855 --- a/drivers/rtc/rtc-ds1307.c
41856 +++ b/drivers/rtc/rtc-ds1307.c
41857 @@ -106,7 +106,7 @@ struct ds1307 {
41858 u8 offset; /* register's offset */
41859 u8 regs[11];
41860 u16 nvram_offset;
41861 - struct bin_attribute *nvram;
41862 + bin_attribute_no_const *nvram;
41863 enum ds_type type;
41864 unsigned long flags;
41865 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41866 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41867 index 130f29a..6179d03 100644
41868 --- a/drivers/rtc/rtc-m48t59.c
41869 +++ b/drivers/rtc/rtc-m48t59.c
41870 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41871 goto out;
41872 }
41873
41874 - m48t59_nvram_attr.size = pdata->offset;
41875 + pax_open_kernel();
41876 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41877 + pax_close_kernel();
41878
41879 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41880 if (ret) {
41881 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41882 index e693af6..2e525b6 100644
41883 --- a/drivers/scsi/bfa/bfa_fcpim.h
41884 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41885 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41886
41887 struct bfa_itn_s {
41888 bfa_isr_func_t isr;
41889 -};
41890 +} __no_const;
41891
41892 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41893 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41894 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41895 index 23a90e7..9cf04ee 100644
41896 --- a/drivers/scsi/bfa/bfa_ioc.h
41897 +++ b/drivers/scsi/bfa/bfa_ioc.h
41898 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41899 bfa_ioc_disable_cbfn_t disable_cbfn;
41900 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41901 bfa_ioc_reset_cbfn_t reset_cbfn;
41902 -};
41903 +} __no_const;
41904
41905 /*
41906 * IOC event notification mechanism.
41907 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41908 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41909 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41910 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41911 -};
41912 +} __no_const;
41913
41914 /*
41915 * Queue element to wait for room in request queue. FIFO order is
41916 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41917 index 593085a..47aa999 100644
41918 --- a/drivers/scsi/hosts.c
41919 +++ b/drivers/scsi/hosts.c
41920 @@ -42,7 +42,7 @@
41921 #include "scsi_logging.h"
41922
41923
41924 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41925 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41926
41927
41928 static void scsi_host_cls_release(struct device *dev)
41929 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41930 * subtract one because we increment first then return, but we need to
41931 * know what the next host number was before increment
41932 */
41933 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41934 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41935 shost->dma_channel = 0xff;
41936
41937 /* These three are default values which can be overridden */
41938 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41939 index 4f33806..afd6f60 100644
41940 --- a/drivers/scsi/hpsa.c
41941 +++ b/drivers/scsi/hpsa.c
41942 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41943 unsigned long flags;
41944
41945 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41946 - return h->access.command_completed(h, q);
41947 + return h->access->command_completed(h, q);
41948
41949 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41950 a = rq->head[rq->current_entry];
41951 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
41952 while (!list_empty(&h->reqQ)) {
41953 c = list_entry(h->reqQ.next, struct CommandList, list);
41954 /* can't do anything if fifo is full */
41955 - if ((h->access.fifo_full(h))) {
41956 + if ((h->access->fifo_full(h))) {
41957 dev_warn(&h->pdev->dev, "fifo full\n");
41958 break;
41959 }
41960 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
41961
41962 /* Tell the controller execute command */
41963 spin_unlock_irqrestore(&h->lock, flags);
41964 - h->access.submit_command(h, c);
41965 + h->access->submit_command(h, c);
41966 spin_lock_irqsave(&h->lock, flags);
41967 }
41968 spin_unlock_irqrestore(&h->lock, flags);
41969 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
41970
41971 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41972 {
41973 - return h->access.command_completed(h, q);
41974 + return h->access->command_completed(h, q);
41975 }
41976
41977 static inline bool interrupt_pending(struct ctlr_info *h)
41978 {
41979 - return h->access.intr_pending(h);
41980 + return h->access->intr_pending(h);
41981 }
41982
41983 static inline long interrupt_not_for_us(struct ctlr_info *h)
41984 {
41985 - return (h->access.intr_pending(h) == 0) ||
41986 + return (h->access->intr_pending(h) == 0) ||
41987 (h->interrupts_enabled == 0);
41988 }
41989
41990 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41991 if (prod_index < 0)
41992 return -ENODEV;
41993 h->product_name = products[prod_index].product_name;
41994 - h->access = *(products[prod_index].access);
41995 + h->access = products[prod_index].access;
41996
41997 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41998 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41999 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42000
42001 assert_spin_locked(&lockup_detector_lock);
42002 remove_ctlr_from_lockup_detector_list(h);
42003 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42004 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42005 spin_lock_irqsave(&h->lock, flags);
42006 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42007 spin_unlock_irqrestore(&h->lock, flags);
42008 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
42009 }
42010
42011 /* make sure the board interrupts are off */
42012 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42013 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42014
42015 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42016 goto clean2;
42017 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
42018 * fake ones to scoop up any residual completions.
42019 */
42020 spin_lock_irqsave(&h->lock, flags);
42021 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42022 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42023 spin_unlock_irqrestore(&h->lock, flags);
42024 free_irqs(h);
42025 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42026 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
42027 dev_info(&h->pdev->dev, "Board READY.\n");
42028 dev_info(&h->pdev->dev,
42029 "Waiting for stale completions to drain.\n");
42030 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42031 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42032 msleep(10000);
42033 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42034 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42035
42036 rc = controller_reset_failed(h->cfgtable);
42037 if (rc)
42038 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
42039 }
42040
42041 /* Turn the interrupts on so we can service requests */
42042 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42043 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42044
42045 hpsa_hba_inquiry(h);
42046 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42047 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42048 * To write all data in the battery backed cache to disks
42049 */
42050 hpsa_flush_cache(h);
42051 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42052 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42053 hpsa_free_irqs_and_disable_msix(h);
42054 }
42055
42056 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42057 return;
42058 }
42059 /* Change the access methods to the performant access methods */
42060 - h->access = SA5_performant_access;
42061 + h->access = &SA5_performant_access;
42062 h->transMethod = CFGTBL_Trans_Performant;
42063 }
42064
42065 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42066 index 9816479..c5d4e97 100644
42067 --- a/drivers/scsi/hpsa.h
42068 +++ b/drivers/scsi/hpsa.h
42069 @@ -79,7 +79,7 @@ struct ctlr_info {
42070 unsigned int msix_vector;
42071 unsigned int msi_vector;
42072 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42073 - struct access_method access;
42074 + struct access_method *access;
42075
42076 /* queue and queue Info */
42077 struct list_head reqQ;
42078 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42079 index c772d8d..35c362c 100644
42080 --- a/drivers/scsi/libfc/fc_exch.c
42081 +++ b/drivers/scsi/libfc/fc_exch.c
42082 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42083 u16 pool_max_index;
42084
42085 struct {
42086 - atomic_t no_free_exch;
42087 - atomic_t no_free_exch_xid;
42088 - atomic_t xid_not_found;
42089 - atomic_t xid_busy;
42090 - atomic_t seq_not_found;
42091 - atomic_t non_bls_resp;
42092 + atomic_unchecked_t no_free_exch;
42093 + atomic_unchecked_t no_free_exch_xid;
42094 + atomic_unchecked_t xid_not_found;
42095 + atomic_unchecked_t xid_busy;
42096 + atomic_unchecked_t seq_not_found;
42097 + atomic_unchecked_t non_bls_resp;
42098 } stats;
42099 };
42100
42101 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42102 /* allocate memory for exchange */
42103 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42104 if (!ep) {
42105 - atomic_inc(&mp->stats.no_free_exch);
42106 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42107 goto out;
42108 }
42109 memset(ep, 0, sizeof(*ep));
42110 @@ -786,7 +786,7 @@ out:
42111 return ep;
42112 err:
42113 spin_unlock_bh(&pool->lock);
42114 - atomic_inc(&mp->stats.no_free_exch_xid);
42115 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42116 mempool_free(ep, mp->ep_pool);
42117 return NULL;
42118 }
42119 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42120 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42121 ep = fc_exch_find(mp, xid);
42122 if (!ep) {
42123 - atomic_inc(&mp->stats.xid_not_found);
42124 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42125 reject = FC_RJT_OX_ID;
42126 goto out;
42127 }
42128 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42129 ep = fc_exch_find(mp, xid);
42130 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42131 if (ep) {
42132 - atomic_inc(&mp->stats.xid_busy);
42133 + atomic_inc_unchecked(&mp->stats.xid_busy);
42134 reject = FC_RJT_RX_ID;
42135 goto rel;
42136 }
42137 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42138 }
42139 xid = ep->xid; /* get our XID */
42140 } else if (!ep) {
42141 - atomic_inc(&mp->stats.xid_not_found);
42142 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42143 reject = FC_RJT_RX_ID; /* XID not found */
42144 goto out;
42145 }
42146 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42147 } else {
42148 sp = &ep->seq;
42149 if (sp->id != fh->fh_seq_id) {
42150 - atomic_inc(&mp->stats.seq_not_found);
42151 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42152 if (f_ctl & FC_FC_END_SEQ) {
42153 /*
42154 * Update sequence_id based on incoming last
42155 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42156
42157 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42158 if (!ep) {
42159 - atomic_inc(&mp->stats.xid_not_found);
42160 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42161 goto out;
42162 }
42163 if (ep->esb_stat & ESB_ST_COMPLETE) {
42164 - atomic_inc(&mp->stats.xid_not_found);
42165 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42166 goto rel;
42167 }
42168 if (ep->rxid == FC_XID_UNKNOWN)
42169 ep->rxid = ntohs(fh->fh_rx_id);
42170 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42171 - atomic_inc(&mp->stats.xid_not_found);
42172 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42173 goto rel;
42174 }
42175 if (ep->did != ntoh24(fh->fh_s_id) &&
42176 ep->did != FC_FID_FLOGI) {
42177 - atomic_inc(&mp->stats.xid_not_found);
42178 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42179 goto rel;
42180 }
42181 sof = fr_sof(fp);
42182 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42183 sp->ssb_stat |= SSB_ST_RESP;
42184 sp->id = fh->fh_seq_id;
42185 } else if (sp->id != fh->fh_seq_id) {
42186 - atomic_inc(&mp->stats.seq_not_found);
42187 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42188 goto rel;
42189 }
42190
42191 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42192 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42193
42194 if (!sp)
42195 - atomic_inc(&mp->stats.xid_not_found);
42196 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42197 else
42198 - atomic_inc(&mp->stats.non_bls_resp);
42199 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42200
42201 fc_frame_free(fp);
42202 }
42203 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42204
42205 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42206 mp = ema->mp;
42207 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42208 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42209 st->fc_no_free_exch_xid +=
42210 - atomic_read(&mp->stats.no_free_exch_xid);
42211 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42212 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42213 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42214 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42215 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42216 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42217 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42218 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42219 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42220 }
42221 }
42222 EXPORT_SYMBOL(fc_exch_update_stats);
42223 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42224 index bdb81cd..d3c7c2c 100644
42225 --- a/drivers/scsi/libsas/sas_ata.c
42226 +++ b/drivers/scsi/libsas/sas_ata.c
42227 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42228 .postreset = ata_std_postreset,
42229 .error_handler = ata_std_error_handler,
42230 .post_internal_cmd = sas_ata_post_internal,
42231 - .qc_defer = ata_std_qc_defer,
42232 + .qc_defer = ata_std_qc_defer,
42233 .qc_prep = ata_noop_qc_prep,
42234 .qc_issue = sas_ata_qc_issue,
42235 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42236 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42237 index df4c13a..a51e90c 100644
42238 --- a/drivers/scsi/lpfc/lpfc.h
42239 +++ b/drivers/scsi/lpfc/lpfc.h
42240 @@ -424,7 +424,7 @@ struct lpfc_vport {
42241 struct dentry *debug_nodelist;
42242 struct dentry *vport_debugfs_root;
42243 struct lpfc_debugfs_trc *disc_trc;
42244 - atomic_t disc_trc_cnt;
42245 + atomic_unchecked_t disc_trc_cnt;
42246 #endif
42247 uint8_t stat_data_enabled;
42248 uint8_t stat_data_blocked;
42249 @@ -842,8 +842,8 @@ struct lpfc_hba {
42250 struct timer_list fabric_block_timer;
42251 unsigned long bit_flags;
42252 #define FABRIC_COMANDS_BLOCKED 0
42253 - atomic_t num_rsrc_err;
42254 - atomic_t num_cmd_success;
42255 + atomic_unchecked_t num_rsrc_err;
42256 + atomic_unchecked_t num_cmd_success;
42257 unsigned long last_rsrc_error_time;
42258 unsigned long last_ramp_down_time;
42259 unsigned long last_ramp_up_time;
42260 @@ -879,7 +879,7 @@ struct lpfc_hba {
42261
42262 struct dentry *debug_slow_ring_trc;
42263 struct lpfc_debugfs_trc *slow_ring_trc;
42264 - atomic_t slow_ring_trc_cnt;
42265 + atomic_unchecked_t slow_ring_trc_cnt;
42266 /* iDiag debugfs sub-directory */
42267 struct dentry *idiag_root;
42268 struct dentry *idiag_pci_cfg;
42269 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42270 index f63f5ff..de29189 100644
42271 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42272 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42273 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42274
42275 #include <linux/debugfs.h>
42276
42277 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42278 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42279 static unsigned long lpfc_debugfs_start_time = 0L;
42280
42281 /* iDiag */
42282 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42283 lpfc_debugfs_enable = 0;
42284
42285 len = 0;
42286 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42287 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42288 (lpfc_debugfs_max_disc_trc - 1);
42289 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42290 dtp = vport->disc_trc + i;
42291 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42292 lpfc_debugfs_enable = 0;
42293
42294 len = 0;
42295 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42296 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42297 (lpfc_debugfs_max_slow_ring_trc - 1);
42298 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42299 dtp = phba->slow_ring_trc + i;
42300 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42301 !vport || !vport->disc_trc)
42302 return;
42303
42304 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42305 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42306 (lpfc_debugfs_max_disc_trc - 1);
42307 dtp = vport->disc_trc + index;
42308 dtp->fmt = fmt;
42309 dtp->data1 = data1;
42310 dtp->data2 = data2;
42311 dtp->data3 = data3;
42312 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42313 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42314 dtp->jif = jiffies;
42315 #endif
42316 return;
42317 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42318 !phba || !phba->slow_ring_trc)
42319 return;
42320
42321 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42322 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42323 (lpfc_debugfs_max_slow_ring_trc - 1);
42324 dtp = phba->slow_ring_trc + index;
42325 dtp->fmt = fmt;
42326 dtp->data1 = data1;
42327 dtp->data2 = data2;
42328 dtp->data3 = data3;
42329 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42330 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42331 dtp->jif = jiffies;
42332 #endif
42333 return;
42334 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42335 "slow_ring buffer\n");
42336 goto debug_failed;
42337 }
42338 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42339 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42340 memset(phba->slow_ring_trc, 0,
42341 (sizeof(struct lpfc_debugfs_trc) *
42342 lpfc_debugfs_max_slow_ring_trc));
42343 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42344 "buffer\n");
42345 goto debug_failed;
42346 }
42347 - atomic_set(&vport->disc_trc_cnt, 0);
42348 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42349
42350 snprintf(name, sizeof(name), "discovery_trace");
42351 vport->debug_disc_trc =
42352 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42353 index 89ad558..76956c4 100644
42354 --- a/drivers/scsi/lpfc/lpfc_init.c
42355 +++ b/drivers/scsi/lpfc/lpfc_init.c
42356 @@ -10618,8 +10618,10 @@ lpfc_init(void)
42357 "misc_register returned with status %d", error);
42358
42359 if (lpfc_enable_npiv) {
42360 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42361 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42362 + pax_open_kernel();
42363 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42364 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42365 + pax_close_kernel();
42366 }
42367 lpfc_transport_template =
42368 fc_attach_transport(&lpfc_transport_functions);
42369 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42370 index 60e5a17..ff7a793 100644
42371 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42372 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42373 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42374 uint32_t evt_posted;
42375
42376 spin_lock_irqsave(&phba->hbalock, flags);
42377 - atomic_inc(&phba->num_rsrc_err);
42378 + atomic_inc_unchecked(&phba->num_rsrc_err);
42379 phba->last_rsrc_error_time = jiffies;
42380
42381 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42382 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42383 unsigned long flags;
42384 struct lpfc_hba *phba = vport->phba;
42385 uint32_t evt_posted;
42386 - atomic_inc(&phba->num_cmd_success);
42387 + atomic_inc_unchecked(&phba->num_cmd_success);
42388
42389 if (vport->cfg_lun_queue_depth <= queue_depth)
42390 return;
42391 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42392 unsigned long num_rsrc_err, num_cmd_success;
42393 int i;
42394
42395 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42396 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42397 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42398 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42399
42400 /*
42401 * The error and success command counters are global per
42402 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42403 }
42404 }
42405 lpfc_destroy_vport_work_array(phba, vports);
42406 - atomic_set(&phba->num_rsrc_err, 0);
42407 - atomic_set(&phba->num_cmd_success, 0);
42408 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42409 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42410 }
42411
42412 /**
42413 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42414 }
42415 }
42416 lpfc_destroy_vport_work_array(phba, vports);
42417 - atomic_set(&phba->num_rsrc_err, 0);
42418 - atomic_set(&phba->num_cmd_success, 0);
42419 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42420 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42421 }
42422
42423 /**
42424 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42425 index b46f5e9..c4c4ccb 100644
42426 --- a/drivers/scsi/pmcraid.c
42427 +++ b/drivers/scsi/pmcraid.c
42428 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42429 res->scsi_dev = scsi_dev;
42430 scsi_dev->hostdata = res;
42431 res->change_detected = 0;
42432 - atomic_set(&res->read_failures, 0);
42433 - atomic_set(&res->write_failures, 0);
42434 + atomic_set_unchecked(&res->read_failures, 0);
42435 + atomic_set_unchecked(&res->write_failures, 0);
42436 rc = 0;
42437 }
42438 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42439 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42440
42441 /* If this was a SCSI read/write command keep count of errors */
42442 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42443 - atomic_inc(&res->read_failures);
42444 + atomic_inc_unchecked(&res->read_failures);
42445 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42446 - atomic_inc(&res->write_failures);
42447 + atomic_inc_unchecked(&res->write_failures);
42448
42449 if (!RES_IS_GSCSI(res->cfg_entry) &&
42450 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42451 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42452 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42453 * hrrq_id assigned here in queuecommand
42454 */
42455 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42456 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42457 pinstance->num_hrrq;
42458 cmd->cmd_done = pmcraid_io_done;
42459
42460 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42461 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42462 * hrrq_id assigned here in queuecommand
42463 */
42464 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42465 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42466 pinstance->num_hrrq;
42467
42468 if (request_size) {
42469 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42470
42471 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42472 /* add resources only after host is added into system */
42473 - if (!atomic_read(&pinstance->expose_resources))
42474 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42475 return;
42476
42477 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42478 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42479 init_waitqueue_head(&pinstance->reset_wait_q);
42480
42481 atomic_set(&pinstance->outstanding_cmds, 0);
42482 - atomic_set(&pinstance->last_message_id, 0);
42483 - atomic_set(&pinstance->expose_resources, 0);
42484 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42485 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42486
42487 INIT_LIST_HEAD(&pinstance->free_res_q);
42488 INIT_LIST_HEAD(&pinstance->used_res_q);
42489 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42490 /* Schedule worker thread to handle CCN and take care of adding and
42491 * removing devices to OS
42492 */
42493 - atomic_set(&pinstance->expose_resources, 1);
42494 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42495 schedule_work(&pinstance->worker_q);
42496 return rc;
42497
42498 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42499 index e1d150f..6c6df44 100644
42500 --- a/drivers/scsi/pmcraid.h
42501 +++ b/drivers/scsi/pmcraid.h
42502 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42503 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42504
42505 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42506 - atomic_t last_message_id;
42507 + atomic_unchecked_t last_message_id;
42508
42509 /* configuration table */
42510 struct pmcraid_config_table *cfg_table;
42511 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42512 atomic_t outstanding_cmds;
42513
42514 /* should add/delete resources to mid-layer now ?*/
42515 - atomic_t expose_resources;
42516 + atomic_unchecked_t expose_resources;
42517
42518
42519
42520 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42521 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42522 };
42523 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42524 - atomic_t read_failures; /* count of failed READ commands */
42525 - atomic_t write_failures; /* count of failed WRITE commands */
42526 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42527 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42528
42529 /* To indicate add/delete/modify during CCN */
42530 u8 change_detected;
42531 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42532 index 83d7984..a27d947 100644
42533 --- a/drivers/scsi/qla2xxx/qla_attr.c
42534 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42535 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42536 return 0;
42537 }
42538
42539 -struct fc_function_template qla2xxx_transport_functions = {
42540 +fc_function_template_no_const qla2xxx_transport_functions = {
42541
42542 .show_host_node_name = 1,
42543 .show_host_port_name = 1,
42544 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42545 .bsg_timeout = qla24xx_bsg_timeout,
42546 };
42547
42548 -struct fc_function_template qla2xxx_transport_vport_functions = {
42549 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42550
42551 .show_host_node_name = 1,
42552 .show_host_port_name = 1,
42553 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42554 index 2411d1a..4673766 100644
42555 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42556 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42557 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42558 struct device_attribute;
42559 extern struct device_attribute *qla2x00_host_attrs[];
42560 struct fc_function_template;
42561 -extern struct fc_function_template qla2xxx_transport_functions;
42562 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42563 +extern fc_function_template_no_const qla2xxx_transport_functions;
42564 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42565 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42566 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42567 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42568 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42569 index 10d23f8..a7d5d4c 100644
42570 --- a/drivers/scsi/qla2xxx/qla_os.c
42571 +++ b/drivers/scsi/qla2xxx/qla_os.c
42572 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42573 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42574 /* Ok, a 64bit DMA mask is applicable. */
42575 ha->flags.enable_64bit_addressing = 1;
42576 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42577 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42578 + pax_open_kernel();
42579 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42580 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42581 + pax_close_kernel();
42582 return;
42583 }
42584 }
42585 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42586 index 329d553..f20d31d 100644
42587 --- a/drivers/scsi/qla4xxx/ql4_def.h
42588 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42589 @@ -273,7 +273,7 @@ struct ddb_entry {
42590 * (4000 only) */
42591 atomic_t relogin_timer; /* Max Time to wait for
42592 * relogin to complete */
42593 - atomic_t relogin_retry_count; /* Num of times relogin has been
42594 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42595 * retried */
42596 uint32_t default_time2wait; /* Default Min time between
42597 * relogins (+aens) */
42598 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42599 index 4cec123..7c1329f 100644
42600 --- a/drivers/scsi/qla4xxx/ql4_os.c
42601 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42602 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42603 */
42604 if (!iscsi_is_session_online(cls_sess)) {
42605 /* Reset retry relogin timer */
42606 - atomic_inc(&ddb_entry->relogin_retry_count);
42607 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42608 DEBUG2(ql4_printk(KERN_INFO, ha,
42609 "%s: index[%d] relogin timed out-retrying"
42610 " relogin (%d), retry (%d)\n", __func__,
42611 ddb_entry->fw_ddb_index,
42612 - atomic_read(&ddb_entry->relogin_retry_count),
42613 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42614 ddb_entry->default_time2wait + 4));
42615 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42616 atomic_set(&ddb_entry->retry_relogin_timer,
42617 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42618
42619 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42620 atomic_set(&ddb_entry->relogin_timer, 0);
42621 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42622 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42623 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42624 ddb_entry->default_relogin_timeout =
42625 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42626 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42627 index 2c0d0ec..4e8681a 100644
42628 --- a/drivers/scsi/scsi.c
42629 +++ b/drivers/scsi/scsi.c
42630 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42631 unsigned long timeout;
42632 int rtn = 0;
42633
42634 - atomic_inc(&cmd->device->iorequest_cnt);
42635 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42636
42637 /* check if the device is still usable */
42638 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42639 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42640 index f1bf5af..f67e943 100644
42641 --- a/drivers/scsi/scsi_lib.c
42642 +++ b/drivers/scsi/scsi_lib.c
42643 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42644 shost = sdev->host;
42645 scsi_init_cmd_errh(cmd);
42646 cmd->result = DID_NO_CONNECT << 16;
42647 - atomic_inc(&cmd->device->iorequest_cnt);
42648 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42649
42650 /*
42651 * SCSI request completion path will do scsi_device_unbusy(),
42652 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
42653
42654 INIT_LIST_HEAD(&cmd->eh_entry);
42655
42656 - atomic_inc(&cmd->device->iodone_cnt);
42657 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42658 if (cmd->result)
42659 - atomic_inc(&cmd->device->ioerr_cnt);
42660 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42661
42662 disposition = scsi_decide_disposition(cmd);
42663 if (disposition != SUCCESS &&
42664 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42665 index 931a7d9..0c2a754 100644
42666 --- a/drivers/scsi/scsi_sysfs.c
42667 +++ b/drivers/scsi/scsi_sysfs.c
42668 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42669 char *buf) \
42670 { \
42671 struct scsi_device *sdev = to_scsi_device(dev); \
42672 - unsigned long long count = atomic_read(&sdev->field); \
42673 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42674 return snprintf(buf, 20, "0x%llx\n", count); \
42675 } \
42676 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42677 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42678 index 84a1fdf..693b0d6 100644
42679 --- a/drivers/scsi/scsi_tgt_lib.c
42680 +++ b/drivers/scsi/scsi_tgt_lib.c
42681 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42682 int err;
42683
42684 dprintk("%lx %u\n", uaddr, len);
42685 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42686 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42687 if (err) {
42688 /*
42689 * TODO: need to fixup sg_tablesize, max_segment_size,
42690 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42691 index e894ca7..de9d7660 100644
42692 --- a/drivers/scsi/scsi_transport_fc.c
42693 +++ b/drivers/scsi/scsi_transport_fc.c
42694 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42695 * Netlink Infrastructure
42696 */
42697
42698 -static atomic_t fc_event_seq;
42699 +static atomic_unchecked_t fc_event_seq;
42700
42701 /**
42702 * fc_get_event_number - Obtain the next sequential FC event number
42703 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42704 u32
42705 fc_get_event_number(void)
42706 {
42707 - return atomic_add_return(1, &fc_event_seq);
42708 + return atomic_add_return_unchecked(1, &fc_event_seq);
42709 }
42710 EXPORT_SYMBOL(fc_get_event_number);
42711
42712 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42713 {
42714 int error;
42715
42716 - atomic_set(&fc_event_seq, 0);
42717 + atomic_set_unchecked(&fc_event_seq, 0);
42718
42719 error = transport_class_register(&fc_host_class);
42720 if (error)
42721 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42722 char *cp;
42723
42724 *val = simple_strtoul(buf, &cp, 0);
42725 - if ((*cp && (*cp != '\n')) || (*val < 0))
42726 + if (*cp && (*cp != '\n'))
42727 return -EINVAL;
42728 /*
42729 * Check for overflow; dev_loss_tmo is u32
42730 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42731 index 31969f2..2b348f0 100644
42732 --- a/drivers/scsi/scsi_transport_iscsi.c
42733 +++ b/drivers/scsi/scsi_transport_iscsi.c
42734 @@ -79,7 +79,7 @@ struct iscsi_internal {
42735 struct transport_container session_cont;
42736 };
42737
42738 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42739 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42740 static struct workqueue_struct *iscsi_eh_timer_workq;
42741
42742 static DEFINE_IDA(iscsi_sess_ida);
42743 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42744 int err;
42745
42746 ihost = shost->shost_data;
42747 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42748 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42749
42750 if (target_id == ISCSI_MAX_TARGET) {
42751 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42752 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
42753 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42754 ISCSI_TRANSPORT_VERSION);
42755
42756 - atomic_set(&iscsi_session_nr, 0);
42757 + atomic_set_unchecked(&iscsi_session_nr, 0);
42758
42759 err = class_register(&iscsi_transport_class);
42760 if (err)
42761 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42762 index f379c7f..e8fc69c 100644
42763 --- a/drivers/scsi/scsi_transport_srp.c
42764 +++ b/drivers/scsi/scsi_transport_srp.c
42765 @@ -33,7 +33,7 @@
42766 #include "scsi_transport_srp_internal.h"
42767
42768 struct srp_host_attrs {
42769 - atomic_t next_port_id;
42770 + atomic_unchecked_t next_port_id;
42771 };
42772 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42773
42774 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42775 struct Scsi_Host *shost = dev_to_shost(dev);
42776 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42777
42778 - atomic_set(&srp_host->next_port_id, 0);
42779 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42780 return 0;
42781 }
42782
42783 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42784 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42785 rport->roles = ids->roles;
42786
42787 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42788 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42789 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42790
42791 transport_setup_device(&rport->dev);
42792 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42793 index 7992635..609faf8 100644
42794 --- a/drivers/scsi/sd.c
42795 +++ b/drivers/scsi/sd.c
42796 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
42797 sdkp->disk = gd;
42798 sdkp->index = index;
42799 atomic_set(&sdkp->openers, 0);
42800 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42801 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42802
42803 if (!sdp->request_queue->rq_timeout) {
42804 if (sdp->type != TYPE_MOD)
42805 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42806 index be2c9a6..275525c 100644
42807 --- a/drivers/scsi/sg.c
42808 +++ b/drivers/scsi/sg.c
42809 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42810 sdp->disk->disk_name,
42811 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42812 NULL,
42813 - (char *)arg);
42814 + (char __user *)arg);
42815 case BLKTRACESTART:
42816 return blk_trace_startstop(sdp->device->request_queue, 1);
42817 case BLKTRACESTOP:
42818 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42819 index 19ee901..6e8c2ef 100644
42820 --- a/drivers/spi/spi.c
42821 +++ b/drivers/spi/spi.c
42822 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
42823 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42824
42825 /* portable code must never pass more than 32 bytes */
42826 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42827 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42828
42829 static u8 *buf;
42830
42831 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42832 index c7a5f97..71ecd35 100644
42833 --- a/drivers/staging/iio/iio_hwmon.c
42834 +++ b/drivers/staging/iio/iio_hwmon.c
42835 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
42836 static int iio_hwmon_probe(struct platform_device *pdev)
42837 {
42838 struct iio_hwmon_state *st;
42839 - struct sensor_device_attribute *a;
42840 + sensor_device_attribute_no_const *a;
42841 int ret, i;
42842 int in_i = 1, temp_i = 1, curr_i = 1;
42843 enum iio_chan_type type;
42844 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42845 index 34afc16..ffe44dd 100644
42846 --- a/drivers/staging/octeon/ethernet-rx.c
42847 +++ b/drivers/staging/octeon/ethernet-rx.c
42848 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42849 /* Increment RX stats for virtual ports */
42850 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42851 #ifdef CONFIG_64BIT
42852 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42853 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42854 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42855 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42856 #else
42857 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42858 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42859 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42860 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42861 #endif
42862 }
42863 netif_receive_skb(skb);
42864 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42865 dev->name);
42866 */
42867 #ifdef CONFIG_64BIT
42868 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42869 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42870 #else
42871 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42872 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42873 #endif
42874 dev_kfree_skb_irq(skb);
42875 }
42876 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42877 index ef32dc1..a159d68 100644
42878 --- a/drivers/staging/octeon/ethernet.c
42879 +++ b/drivers/staging/octeon/ethernet.c
42880 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42881 * since the RX tasklet also increments it.
42882 */
42883 #ifdef CONFIG_64BIT
42884 - atomic64_add(rx_status.dropped_packets,
42885 - (atomic64_t *)&priv->stats.rx_dropped);
42886 + atomic64_add_unchecked(rx_status.dropped_packets,
42887 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42888 #else
42889 - atomic_add(rx_status.dropped_packets,
42890 - (atomic_t *)&priv->stats.rx_dropped);
42891 + atomic_add_unchecked(rx_status.dropped_packets,
42892 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42893 #endif
42894 }
42895
42896 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
42897 index a2b7e03..aaf3630 100644
42898 --- a/drivers/staging/ramster/tmem.c
42899 +++ b/drivers/staging/ramster/tmem.c
42900 @@ -50,25 +50,25 @@
42901 * A tmem host implementation must use this function to register callbacks
42902 * for memory allocation.
42903 */
42904 -static struct tmem_hostops tmem_hostops;
42905 +static struct tmem_hostops *tmem_hostops;
42906
42907 static void tmem_objnode_tree_init(void);
42908
42909 void tmem_register_hostops(struct tmem_hostops *m)
42910 {
42911 tmem_objnode_tree_init();
42912 - tmem_hostops = *m;
42913 + tmem_hostops = m;
42914 }
42915
42916 /*
42917 * A tmem host implementation must use this function to register
42918 * callbacks for a page-accessible memory (PAM) implementation.
42919 */
42920 -static struct tmem_pamops tmem_pamops;
42921 +static struct tmem_pamops *tmem_pamops;
42922
42923 void tmem_register_pamops(struct tmem_pamops *m)
42924 {
42925 - tmem_pamops = *m;
42926 + tmem_pamops = m;
42927 }
42928
42929 /*
42930 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
42931 obj->pampd_count = 0;
42932 #ifdef CONFIG_RAMSTER
42933 if (tmem_pamops.new_obj != NULL)
42934 - (*tmem_pamops.new_obj)(obj);
42935 + (tmem_pamops->new_obj)(obj);
42936 #endif
42937 SET_SENTINEL(obj, OBJ);
42938
42939 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
42940 rbnode = rb_next(rbnode);
42941 tmem_pampd_destroy_all_in_obj(obj, true);
42942 tmem_obj_free(obj, hb);
42943 - (*tmem_hostops.obj_free)(obj, pool);
42944 + (tmem_hostops->obj_free)(obj, pool);
42945 }
42946 spin_unlock(&hb->lock);
42947 }
42948 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
42949 ASSERT_SENTINEL(obj, OBJ);
42950 BUG_ON(obj->pool == NULL);
42951 ASSERT_SENTINEL(obj->pool, POOL);
42952 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
42953 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
42954 if (unlikely(objnode == NULL))
42955 goto out;
42956 objnode->obj = obj;
42957 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
42958 ASSERT_SENTINEL(pool, POOL);
42959 objnode->obj->objnode_count--;
42960 objnode->obj = NULL;
42961 - (*tmem_hostops.objnode_free)(objnode, pool);
42962 + (tmem_hostops->objnode_free)(objnode, pool);
42963 }
42964
42965 /*
42966 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
42967 void *old_pampd = *(void **)slot;
42968 *(void **)slot = new_pampd;
42969 if (!no_free)
42970 - (*tmem_pamops.free)(old_pampd, obj->pool,
42971 + (tmem_pamops->free)(old_pampd, obj->pool,
42972 NULL, 0, false);
42973 ret = new_pampd;
42974 }
42975 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
42976 if (objnode->slots[i]) {
42977 if (ht == 1) {
42978 obj->pampd_count--;
42979 - (*tmem_pamops.free)(objnode->slots[i],
42980 + (tmem_pamops->free)(objnode->slots[i],
42981 obj->pool, NULL, 0, true);
42982 objnode->slots[i] = NULL;
42983 continue;
42984 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42985 return;
42986 if (obj->objnode_tree_height == 0) {
42987 obj->pampd_count--;
42988 - (*tmem_pamops.free)(obj->objnode_tree_root,
42989 + (tmem_pamops->free)(obj->objnode_tree_root,
42990 obj->pool, NULL, 0, true);
42991 } else {
42992 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
42993 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42994 obj->objnode_tree_root = NULL;
42995 #ifdef CONFIG_RAMSTER
42996 if (tmem_pamops.free_obj != NULL)
42997 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
42998 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
42999 #endif
43000 }
43001
43002 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43003 /* if found, is a dup put, flush the old one */
43004 pampd_del = tmem_pampd_delete_from_obj(obj, index);
43005 BUG_ON(pampd_del != pampd);
43006 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43007 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43008 if (obj->pampd_count == 0) {
43009 objnew = obj;
43010 objfound = NULL;
43011 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43012 pampd = NULL;
43013 }
43014 } else {
43015 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
43016 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
43017 if (unlikely(obj == NULL)) {
43018 ret = -ENOMEM;
43019 goto out;
43020 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43021 if (unlikely(ret == -ENOMEM))
43022 /* may have partially built objnode tree ("stump") */
43023 goto delete_and_free;
43024 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
43025 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
43026 goto out;
43027
43028 delete_and_free:
43029 (void)tmem_pampd_delete_from_obj(obj, index);
43030 if (pampd)
43031 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
43032 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
43033 if (objnew) {
43034 tmem_obj_free(objnew, hb);
43035 - (*tmem_hostops.obj_free)(objnew, pool);
43036 + (tmem_hostops->obj_free)(objnew, pool);
43037 }
43038 out:
43039 spin_unlock(&hb->lock);
43040 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
43041 if (pampd != NULL) {
43042 BUG_ON(obj == NULL);
43043 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
43044 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
43045 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
43046 } else if (delete) {
43047 BUG_ON(obj == NULL);
43048 (void)tmem_pampd_delete_from_obj(obj, index);
43049 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43050 int ret = 0;
43051
43052 if (!is_ephemeral(pool))
43053 - new_pampd = (*tmem_pamops.repatriate_preload)(
43054 + new_pampd = (tmem_pamops->repatriate_preload)(
43055 old_pampd, pool, oidp, index, &intransit);
43056 if (intransit)
43057 ret = -EAGAIN;
43058 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43059 /* must release the hb->lock else repatriate can't sleep */
43060 spin_unlock(&hb->lock);
43061 if (!intransit)
43062 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
43063 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
43064 oidp, index, free, data);
43065 if (ret == -EAGAIN) {
43066 /* rare I think, but should cond_resched()??? */
43067 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
43068 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
43069 /* if we bug here, pamops wasn't properly set up for ramster */
43070 BUG_ON(tmem_pamops.replace_in_obj == NULL);
43071 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
43072 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
43073 out:
43074 spin_unlock(&hb->lock);
43075 return ret;
43076 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43077 if (free) {
43078 if (obj->pampd_count == 0) {
43079 tmem_obj_free(obj, hb);
43080 - (*tmem_hostops.obj_free)(obj, pool);
43081 + (tmem_hostops->obj_free)(obj, pool);
43082 obj = NULL;
43083 }
43084 }
43085 if (free)
43086 - ret = (*tmem_pamops.get_data_and_free)(
43087 + ret = (tmem_pamops->get_data_and_free)(
43088 data, sizep, raw, pampd, pool, oidp, index);
43089 else
43090 - ret = (*tmem_pamops.get_data)(
43091 + ret = (tmem_pamops->get_data)(
43092 data, sizep, raw, pampd, pool, oidp, index);
43093 if (ret < 0)
43094 goto out;
43095 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
43096 pampd = tmem_pampd_delete_from_obj(obj, index);
43097 if (pampd == NULL)
43098 goto out;
43099 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43100 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43101 if (obj->pampd_count == 0) {
43102 tmem_obj_free(obj, hb);
43103 - (*tmem_hostops.obj_free)(obj, pool);
43104 + (tmem_hostops->obj_free)(obj, pool);
43105 }
43106 ret = 0;
43107
43108 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
43109 goto out;
43110 tmem_pampd_destroy_all_in_obj(obj, false);
43111 tmem_obj_free(obj, hb);
43112 - (*tmem_hostops.obj_free)(obj, pool);
43113 + (tmem_hostops->obj_free)(obj, pool);
43114 ret = 0;
43115
43116 out:
43117 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43118 index dc23395..cf7e9b1 100644
43119 --- a/drivers/staging/rtl8712/rtl871x_io.h
43120 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43121 @@ -108,7 +108,7 @@ struct _io_ops {
43122 u8 *pmem);
43123 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43124 u8 *pmem);
43125 -};
43126 +} __no_const;
43127
43128 struct io_req {
43129 struct list_head list;
43130 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43131 index 1f5088b..0e59820 100644
43132 --- a/drivers/staging/sbe-2t3e3/netdev.c
43133 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43134 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43135 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43136
43137 if (rlen)
43138 - if (copy_to_user(data, &resp, rlen))
43139 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43140 return -EFAULT;
43141
43142 return 0;
43143 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43144 index 5dddc4d..34fcb2f 100644
43145 --- a/drivers/staging/usbip/vhci.h
43146 +++ b/drivers/staging/usbip/vhci.h
43147 @@ -83,7 +83,7 @@ struct vhci_hcd {
43148 unsigned resuming:1;
43149 unsigned long re_timeout;
43150
43151 - atomic_t seqnum;
43152 + atomic_unchecked_t seqnum;
43153
43154 /*
43155 * NOTE:
43156 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43157 index c3aa219..bf8b3de 100644
43158 --- a/drivers/staging/usbip/vhci_hcd.c
43159 +++ b/drivers/staging/usbip/vhci_hcd.c
43160 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
43161 return;
43162 }
43163
43164 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43165 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43166 if (priv->seqnum == 0xffff)
43167 dev_info(&urb->dev->dev, "seqnum max\n");
43168
43169 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43170 return -ENOMEM;
43171 }
43172
43173 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43174 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43175 if (unlink->seqnum == 0xffff)
43176 pr_info("seqnum max\n");
43177
43178 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
43179 vdev->rhport = rhport;
43180 }
43181
43182 - atomic_set(&vhci->seqnum, 0);
43183 + atomic_set_unchecked(&vhci->seqnum, 0);
43184 spin_lock_init(&vhci->lock);
43185
43186 hcd->power_budget = 0; /* no limit */
43187 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43188 index ba5f1c0..11d8122 100644
43189 --- a/drivers/staging/usbip/vhci_rx.c
43190 +++ b/drivers/staging/usbip/vhci_rx.c
43191 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43192 if (!urb) {
43193 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43194 pr_info("max seqnum %d\n",
43195 - atomic_read(&the_controller->seqnum));
43196 + atomic_read_unchecked(&the_controller->seqnum));
43197 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43198 return;
43199 }
43200 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43201 index 5f13890..36a044b 100644
43202 --- a/drivers/staging/vt6655/hostap.c
43203 +++ b/drivers/staging/vt6655/hostap.c
43204 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
43205 *
43206 */
43207
43208 +static net_device_ops_no_const apdev_netdev_ops;
43209 +
43210 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43211 {
43212 PSDevice apdev_priv;
43213 struct net_device *dev = pDevice->dev;
43214 int ret;
43215 - const struct net_device_ops apdev_netdev_ops = {
43216 - .ndo_start_xmit = pDevice->tx_80211,
43217 - };
43218
43219 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43220
43221 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43222 *apdev_priv = *pDevice;
43223 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43224
43225 + /* only half broken now */
43226 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43227 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43228
43229 pDevice->apdev->type = ARPHRD_IEEE80211;
43230 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43231 index 26a7d0e..897b083 100644
43232 --- a/drivers/staging/vt6656/hostap.c
43233 +++ b/drivers/staging/vt6656/hostap.c
43234 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43235 *
43236 */
43237
43238 +static net_device_ops_no_const apdev_netdev_ops;
43239 +
43240 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43241 {
43242 PSDevice apdev_priv;
43243 struct net_device *dev = pDevice->dev;
43244 int ret;
43245 - const struct net_device_ops apdev_netdev_ops = {
43246 - .ndo_start_xmit = pDevice->tx_80211,
43247 - };
43248
43249 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43250
43251 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43252 *apdev_priv = *pDevice;
43253 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43254
43255 + /* only half broken now */
43256 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43257 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43258
43259 pDevice->apdev->type = ARPHRD_IEEE80211;
43260 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43261 index 56c8e60..1920c63 100644
43262 --- a/drivers/staging/zcache/tmem.c
43263 +++ b/drivers/staging/zcache/tmem.c
43264 @@ -39,7 +39,7 @@
43265 * A tmem host implementation must use this function to register callbacks
43266 * for memory allocation.
43267 */
43268 -static struct tmem_hostops tmem_hostops;
43269 +static tmem_hostops_no_const tmem_hostops;
43270
43271 static void tmem_objnode_tree_init(void);
43272
43273 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43274 * A tmem host implementation must use this function to register
43275 * callbacks for a page-accessible memory (PAM) implementation
43276 */
43277 -static struct tmem_pamops tmem_pamops;
43278 +static tmem_pamops_no_const tmem_pamops;
43279
43280 void tmem_register_pamops(struct tmem_pamops *m)
43281 {
43282 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43283 index 0d4aa82..f7832d4 100644
43284 --- a/drivers/staging/zcache/tmem.h
43285 +++ b/drivers/staging/zcache/tmem.h
43286 @@ -180,6 +180,7 @@ struct tmem_pamops {
43287 void (*new_obj)(struct tmem_obj *);
43288 int (*replace_in_obj)(void *, struct tmem_obj *);
43289 };
43290 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43291 extern void tmem_register_pamops(struct tmem_pamops *m);
43292
43293 /* memory allocation methods provided by the host implementation */
43294 @@ -189,6 +190,7 @@ struct tmem_hostops {
43295 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43296 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43297 };
43298 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43299 extern void tmem_register_hostops(struct tmem_hostops *m);
43300
43301 /* core tmem accessor functions */
43302 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43303 index 96f4981..4daaa7e 100644
43304 --- a/drivers/target/target_core_device.c
43305 +++ b/drivers/target/target_core_device.c
43306 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43307 spin_lock_init(&dev->se_port_lock);
43308 spin_lock_init(&dev->se_tmr_lock);
43309 spin_lock_init(&dev->qf_cmd_lock);
43310 - atomic_set(&dev->dev_ordered_id, 0);
43311 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43312 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43313 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43314 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43315 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43316 index fcf880f..a4d1e8f 100644
43317 --- a/drivers/target/target_core_transport.c
43318 +++ b/drivers/target/target_core_transport.c
43319 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43320 * Used to determine when ORDERED commands should go from
43321 * Dormant to Active status.
43322 */
43323 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43324 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43325 smp_mb__after_atomic_inc();
43326 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43327 cmd->se_ordered_id, cmd->sam_task_attr,
43328 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43329 index b09c8d1f..c4225c0 100644
43330 --- a/drivers/tty/cyclades.c
43331 +++ b/drivers/tty/cyclades.c
43332 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43333 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43334 info->port.count);
43335 #endif
43336 - info->port.count++;
43337 + atomic_inc(&info->port.count);
43338 #ifdef CY_DEBUG_COUNT
43339 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43340 - current->pid, info->port.count);
43341 + current->pid, atomic_read(&info->port.count));
43342 #endif
43343
43344 /*
43345 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43346 for (j = 0; j < cy_card[i].nports; j++) {
43347 info = &cy_card[i].ports[j];
43348
43349 - if (info->port.count) {
43350 + if (atomic_read(&info->port.count)) {
43351 /* XXX is the ldisc num worth this? */
43352 struct tty_struct *tty;
43353 struct tty_ldisc *ld;
43354 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43355 index 13ee53b..418d164 100644
43356 --- a/drivers/tty/hvc/hvc_console.c
43357 +++ b/drivers/tty/hvc/hvc_console.c
43358 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43359
43360 spin_lock_irqsave(&hp->port.lock, flags);
43361 /* Check and then increment for fast path open. */
43362 - if (hp->port.count++ > 0) {
43363 + if (atomic_inc_return(&hp->port.count) > 1) {
43364 spin_unlock_irqrestore(&hp->port.lock, flags);
43365 hvc_kick();
43366 return 0;
43367 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43368
43369 spin_lock_irqsave(&hp->port.lock, flags);
43370
43371 - if (--hp->port.count == 0) {
43372 + if (atomic_dec_return(&hp->port.count) == 0) {
43373 spin_unlock_irqrestore(&hp->port.lock, flags);
43374 /* We are done with the tty pointer now. */
43375 tty_port_tty_set(&hp->port, NULL);
43376 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43377 */
43378 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43379 } else {
43380 - if (hp->port.count < 0)
43381 + if (atomic_read(&hp->port.count) < 0)
43382 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43383 - hp->vtermno, hp->port.count);
43384 + hp->vtermno, atomic_read(&hp->port.count));
43385 spin_unlock_irqrestore(&hp->port.lock, flags);
43386 }
43387 }
43388 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43389 * open->hangup case this can be called after the final close so prevent
43390 * that from happening for now.
43391 */
43392 - if (hp->port.count <= 0) {
43393 + if (atomic_read(&hp->port.count) <= 0) {
43394 spin_unlock_irqrestore(&hp->port.lock, flags);
43395 return;
43396 }
43397
43398 - hp->port.count = 0;
43399 + atomic_set(&hp->port.count, 0);
43400 spin_unlock_irqrestore(&hp->port.lock, flags);
43401 tty_port_tty_set(&hp->port, NULL);
43402
43403 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43404 return -EPIPE;
43405
43406 /* FIXME what's this (unprotected) check for? */
43407 - if (hp->port.count <= 0)
43408 + if (atomic_read(&hp->port.count) <= 0)
43409 return -EIO;
43410
43411 spin_lock_irqsave(&hp->lock, flags);
43412 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43413 index 8776357..b2d4afd 100644
43414 --- a/drivers/tty/hvc/hvcs.c
43415 +++ b/drivers/tty/hvc/hvcs.c
43416 @@ -83,6 +83,7 @@
43417 #include <asm/hvcserver.h>
43418 #include <asm/uaccess.h>
43419 #include <asm/vio.h>
43420 +#include <asm/local.h>
43421
43422 /*
43423 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43424 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43425
43426 spin_lock_irqsave(&hvcsd->lock, flags);
43427
43428 - if (hvcsd->port.count > 0) {
43429 + if (atomic_read(&hvcsd->port.count) > 0) {
43430 spin_unlock_irqrestore(&hvcsd->lock, flags);
43431 printk(KERN_INFO "HVCS: vterm state unchanged. "
43432 "The hvcs device node is still in use.\n");
43433 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43434 }
43435 }
43436
43437 - hvcsd->port.count = 0;
43438 + atomic_set(&hvcsd->port.count, 0);
43439 hvcsd->port.tty = tty;
43440 tty->driver_data = hvcsd;
43441
43442 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43443 unsigned long flags;
43444
43445 spin_lock_irqsave(&hvcsd->lock, flags);
43446 - hvcsd->port.count++;
43447 + atomic_inc(&hvcsd->port.count);
43448 hvcsd->todo_mask |= HVCS_SCHED_READ;
43449 spin_unlock_irqrestore(&hvcsd->lock, flags);
43450
43451 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43452 hvcsd = tty->driver_data;
43453
43454 spin_lock_irqsave(&hvcsd->lock, flags);
43455 - if (--hvcsd->port.count == 0) {
43456 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43457
43458 vio_disable_interrupts(hvcsd->vdev);
43459
43460 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43461
43462 free_irq(irq, hvcsd);
43463 return;
43464 - } else if (hvcsd->port.count < 0) {
43465 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43466 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43467 " is missmanaged.\n",
43468 - hvcsd->vdev->unit_address, hvcsd->port.count);
43469 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43470 }
43471
43472 spin_unlock_irqrestore(&hvcsd->lock, flags);
43473 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43474
43475 spin_lock_irqsave(&hvcsd->lock, flags);
43476 /* Preserve this so that we know how many kref refs to put */
43477 - temp_open_count = hvcsd->port.count;
43478 + temp_open_count = atomic_read(&hvcsd->port.count);
43479
43480 /*
43481 * Don't kref put inside the spinlock because the destruction
43482 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43483 tty->driver_data = NULL;
43484 hvcsd->port.tty = NULL;
43485
43486 - hvcsd->port.count = 0;
43487 + atomic_set(&hvcsd->port.count, 0);
43488
43489 /* This will drop any buffered data on the floor which is OK in a hangup
43490 * scenario. */
43491 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
43492 * the middle of a write operation? This is a crummy place to do this
43493 * but we want to keep it all in the spinlock.
43494 */
43495 - if (hvcsd->port.count <= 0) {
43496 + if (atomic_read(&hvcsd->port.count) <= 0) {
43497 spin_unlock_irqrestore(&hvcsd->lock, flags);
43498 return -ENODEV;
43499 }
43500 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43501 {
43502 struct hvcs_struct *hvcsd = tty->driver_data;
43503
43504 - if (!hvcsd || hvcsd->port.count <= 0)
43505 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43506 return 0;
43507
43508 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43509 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43510 index 2cde13d..645d78f 100644
43511 --- a/drivers/tty/ipwireless/tty.c
43512 +++ b/drivers/tty/ipwireless/tty.c
43513 @@ -29,6 +29,7 @@
43514 #include <linux/tty_driver.h>
43515 #include <linux/tty_flip.h>
43516 #include <linux/uaccess.h>
43517 +#include <asm/local.h>
43518
43519 #include "tty.h"
43520 #include "network.h"
43521 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43522 mutex_unlock(&tty->ipw_tty_mutex);
43523 return -ENODEV;
43524 }
43525 - if (tty->port.count == 0)
43526 + if (atomic_read(&tty->port.count) == 0)
43527 tty->tx_bytes_queued = 0;
43528
43529 - tty->port.count++;
43530 + atomic_inc(&tty->port.count);
43531
43532 tty->port.tty = linux_tty;
43533 linux_tty->driver_data = tty;
43534 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43535
43536 static void do_ipw_close(struct ipw_tty *tty)
43537 {
43538 - tty->port.count--;
43539 -
43540 - if (tty->port.count == 0) {
43541 + if (atomic_dec_return(&tty->port.count) == 0) {
43542 struct tty_struct *linux_tty = tty->port.tty;
43543
43544 if (linux_tty != NULL) {
43545 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43546 return;
43547
43548 mutex_lock(&tty->ipw_tty_mutex);
43549 - if (tty->port.count == 0) {
43550 + if (atomic_read(&tty->port.count) == 0) {
43551 mutex_unlock(&tty->ipw_tty_mutex);
43552 return;
43553 }
43554 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43555 return;
43556 }
43557
43558 - if (!tty->port.count) {
43559 + if (!atomic_read(&tty->port.count)) {
43560 mutex_unlock(&tty->ipw_tty_mutex);
43561 return;
43562 }
43563 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43564 return -ENODEV;
43565
43566 mutex_lock(&tty->ipw_tty_mutex);
43567 - if (!tty->port.count) {
43568 + if (!atomic_read(&tty->port.count)) {
43569 mutex_unlock(&tty->ipw_tty_mutex);
43570 return -EINVAL;
43571 }
43572 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43573 if (!tty)
43574 return -ENODEV;
43575
43576 - if (!tty->port.count)
43577 + if (!atomic_read(&tty->port.count))
43578 return -EINVAL;
43579
43580 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43581 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43582 if (!tty)
43583 return 0;
43584
43585 - if (!tty->port.count)
43586 + if (!atomic_read(&tty->port.count))
43587 return 0;
43588
43589 return tty->tx_bytes_queued;
43590 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43591 if (!tty)
43592 return -ENODEV;
43593
43594 - if (!tty->port.count)
43595 + if (!atomic_read(&tty->port.count))
43596 return -EINVAL;
43597
43598 return get_control_lines(tty);
43599 @@ -391,7 +390,7 @@ ipw_tiocmset(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 return set_control_lines(tty, set, clear);
43608 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43609 if (!tty)
43610 return -ENODEV;
43611
43612 - if (!tty->port.count)
43613 + if (!atomic_read(&tty->port.count))
43614 return -EINVAL;
43615
43616 /* FIXME: Exactly how is the tty object locked here .. */
43617 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43618 * are gone */
43619 mutex_lock(&ttyj->ipw_tty_mutex);
43620 }
43621 - while (ttyj->port.count)
43622 + while (atomic_read(&ttyj->port.count))
43623 do_ipw_close(ttyj);
43624 ipwireless_disassociate_network_ttys(network,
43625 ttyj->channel_idx);
43626 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43627 index f9d2850..b006f04 100644
43628 --- a/drivers/tty/moxa.c
43629 +++ b/drivers/tty/moxa.c
43630 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43631 }
43632
43633 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43634 - ch->port.count++;
43635 + atomic_inc(&ch->port.count);
43636 tty->driver_data = ch;
43637 tty_port_tty_set(&ch->port, tty);
43638 mutex_lock(&ch->port.mutex);
43639 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43640 index bfd6771..e0d93c4 100644
43641 --- a/drivers/tty/n_gsm.c
43642 +++ b/drivers/tty/n_gsm.c
43643 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43644 spin_lock_init(&dlci->lock);
43645 mutex_init(&dlci->mutex);
43646 dlci->fifo = &dlci->_fifo;
43647 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43648 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43649 kfree(dlci);
43650 return NULL;
43651 }
43652 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43653 struct gsm_dlci *dlci = tty->driver_data;
43654 struct tty_port *port = &dlci->port;
43655
43656 - port->count++;
43657 + atomic_inc(&port->count);
43658 dlci_get(dlci);
43659 dlci_get(dlci->gsm->dlci[0]);
43660 mux_get(dlci->gsm);
43661 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43662 index 19083ef..6e34e97 100644
43663 --- a/drivers/tty/n_tty.c
43664 +++ b/drivers/tty/n_tty.c
43665 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43666 {
43667 *ops = tty_ldisc_N_TTY;
43668 ops->owner = NULL;
43669 - ops->refcount = ops->flags = 0;
43670 + atomic_set(&ops->refcount, 0);
43671 + ops->flags = 0;
43672 }
43673 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43674 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43675 index ac35c90..c47deac 100644
43676 --- a/drivers/tty/pty.c
43677 +++ b/drivers/tty/pty.c
43678 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
43679 panic("Couldn't register Unix98 pts driver");
43680
43681 /* Now create the /dev/ptmx special device */
43682 + pax_open_kernel();
43683 tty_default_fops(&ptmx_fops);
43684 - ptmx_fops.open = ptmx_open;
43685 + *(void **)&ptmx_fops.open = ptmx_open;
43686 + pax_close_kernel();
43687
43688 cdev_init(&ptmx_cdev, &ptmx_fops);
43689 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43690 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43691 index e42009a..566a036 100644
43692 --- a/drivers/tty/rocket.c
43693 +++ b/drivers/tty/rocket.c
43694 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43695 tty->driver_data = info;
43696 tty_port_tty_set(port, tty);
43697
43698 - if (port->count++ == 0) {
43699 + if (atomic_inc_return(&port->count) == 1) {
43700 atomic_inc(&rp_num_ports_open);
43701
43702 #ifdef ROCKET_DEBUG_OPEN
43703 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43704 #endif
43705 }
43706 #ifdef ROCKET_DEBUG_OPEN
43707 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43708 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43709 #endif
43710
43711 /*
43712 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
43713 spin_unlock_irqrestore(&info->port.lock, flags);
43714 return;
43715 }
43716 - if (info->port.count)
43717 + if (atomic_read(&info->port.count))
43718 atomic_dec(&rp_num_ports_open);
43719 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43720 spin_unlock_irqrestore(&info->port.lock, flags);
43721 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43722 index 1002054..dd644a8 100644
43723 --- a/drivers/tty/serial/kgdboc.c
43724 +++ b/drivers/tty/serial/kgdboc.c
43725 @@ -24,8 +24,9 @@
43726 #define MAX_CONFIG_LEN 40
43727
43728 static struct kgdb_io kgdboc_io_ops;
43729 +static struct kgdb_io kgdboc_io_ops_console;
43730
43731 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43732 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43733 static int configured = -1;
43734
43735 static char config[MAX_CONFIG_LEN];
43736 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43737 kgdboc_unregister_kbd();
43738 if (configured == 1)
43739 kgdb_unregister_io_module(&kgdboc_io_ops);
43740 + else if (configured == 2)
43741 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43742 }
43743
43744 static int configure_kgdboc(void)
43745 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43746 int err;
43747 char *cptr = config;
43748 struct console *cons;
43749 + int is_console = 0;
43750
43751 err = kgdboc_option_setup(config);
43752 if (err || !strlen(config) || isspace(config[0]))
43753 goto noconfig;
43754
43755 err = -ENODEV;
43756 - kgdboc_io_ops.is_console = 0;
43757 kgdb_tty_driver = NULL;
43758
43759 kgdboc_use_kms = 0;
43760 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43761 int idx;
43762 if (cons->device && cons->device(cons, &idx) == p &&
43763 idx == tty_line) {
43764 - kgdboc_io_ops.is_console = 1;
43765 + is_console = 1;
43766 break;
43767 }
43768 cons = cons->next;
43769 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43770 kgdb_tty_line = tty_line;
43771
43772 do_register:
43773 - err = kgdb_register_io_module(&kgdboc_io_ops);
43774 + if (is_console) {
43775 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43776 + configured = 2;
43777 + } else {
43778 + err = kgdb_register_io_module(&kgdboc_io_ops);
43779 + configured = 1;
43780 + }
43781 if (err)
43782 goto noconfig;
43783
43784 @@ -205,8 +214,6 @@ do_register:
43785 if (err)
43786 goto nmi_con_failed;
43787
43788 - configured = 1;
43789 -
43790 return 0;
43791
43792 nmi_con_failed:
43793 @@ -223,7 +230,7 @@ noconfig:
43794 static int __init init_kgdboc(void)
43795 {
43796 /* Already configured? */
43797 - if (configured == 1)
43798 + if (configured >= 1)
43799 return 0;
43800
43801 return configure_kgdboc();
43802 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43803 if (config[len - 1] == '\n')
43804 config[len - 1] = '\0';
43805
43806 - if (configured == 1)
43807 + if (configured >= 1)
43808 cleanup_kgdboc();
43809
43810 /* Go and configure with the new params. */
43811 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43812 .post_exception = kgdboc_post_exp_handler,
43813 };
43814
43815 +static struct kgdb_io kgdboc_io_ops_console = {
43816 + .name = "kgdboc",
43817 + .read_char = kgdboc_get_char,
43818 + .write_char = kgdboc_put_char,
43819 + .pre_exception = kgdboc_pre_exp_handler,
43820 + .post_exception = kgdboc_post_exp_handler,
43821 + .is_console = 1
43822 +};
43823 +
43824 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43825 /* This is only available if kgdboc is a built in for early debugging */
43826 static int __init kgdboc_early_init(char *opt)
43827 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43828 index e514b3a..c73d614 100644
43829 --- a/drivers/tty/serial/samsung.c
43830 +++ b/drivers/tty/serial/samsung.c
43831 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43832 }
43833 }
43834
43835 +static int s3c64xx_serial_startup(struct uart_port *port);
43836 static int s3c24xx_serial_startup(struct uart_port *port)
43837 {
43838 struct s3c24xx_uart_port *ourport = to_ourport(port);
43839 int ret;
43840
43841 + /* Startup sequence is different for s3c64xx and higher SoC's */
43842 + if (s3c24xx_serial_has_interrupt_mask(port))
43843 + return s3c64xx_serial_startup(port);
43844 +
43845 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43846 port->mapbase, port->membase);
43847
43848 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43849 /* setup info for port */
43850 port->dev = &platdev->dev;
43851
43852 - /* Startup sequence is different for s3c64xx and higher SoC's */
43853 - if (s3c24xx_serial_has_interrupt_mask(port))
43854 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43855 -
43856 port->uartclk = 1;
43857
43858 if (cfg->uart_flags & UPF_CONS_FLOW) {
43859 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43860 index 2c7230a..2104f16 100644
43861 --- a/drivers/tty/serial/serial_core.c
43862 +++ b/drivers/tty/serial/serial_core.c
43863 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
43864 uart_flush_buffer(tty);
43865 uart_shutdown(tty, state);
43866 spin_lock_irqsave(&port->lock, flags);
43867 - port->count = 0;
43868 + atomic_set(&port->count, 0);
43869 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43870 spin_unlock_irqrestore(&port->lock, flags);
43871 tty_port_tty_set(port, NULL);
43872 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43873 goto end;
43874 }
43875
43876 - port->count++;
43877 + atomic_inc(&port->count);
43878 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43879 retval = -ENXIO;
43880 goto err_dec_count;
43881 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43882 /*
43883 * Make sure the device is in D0 state.
43884 */
43885 - if (port->count == 1)
43886 + if (atomic_read(&port->count) == 1)
43887 uart_change_pm(state, 0);
43888
43889 /*
43890 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43891 end:
43892 return retval;
43893 err_dec_count:
43894 - port->count--;
43895 + atomic_inc(&port->count);
43896 mutex_unlock(&port->mutex);
43897 goto end;
43898 }
43899 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43900 index 9e071f6..f30ae69 100644
43901 --- a/drivers/tty/synclink.c
43902 +++ b/drivers/tty/synclink.c
43903 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43904
43905 if (debug_level >= DEBUG_LEVEL_INFO)
43906 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43907 - __FILE__,__LINE__, info->device_name, info->port.count);
43908 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43909
43910 if (tty_port_close_start(&info->port, tty, filp) == 0)
43911 goto cleanup;
43912 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43913 cleanup:
43914 if (debug_level >= DEBUG_LEVEL_INFO)
43915 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43916 - tty->driver->name, info->port.count);
43917 + tty->driver->name, atomic_read(&info->port.count));
43918
43919 } /* end of mgsl_close() */
43920
43921 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43922
43923 mgsl_flush_buffer(tty);
43924 shutdown(info);
43925 -
43926 - info->port.count = 0;
43927 +
43928 + atomic_set(&info->port.count, 0);
43929 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43930 info->port.tty = NULL;
43931
43932 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43933
43934 if (debug_level >= DEBUG_LEVEL_INFO)
43935 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43936 - __FILE__,__LINE__, tty->driver->name, port->count );
43937 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43938
43939 spin_lock_irqsave(&info->irq_spinlock, flags);
43940 if (!tty_hung_up_p(filp)) {
43941 extra_count = true;
43942 - port->count--;
43943 + atomic_dec(&port->count);
43944 }
43945 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43946 port->blocked_open++;
43947 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43948
43949 if (debug_level >= DEBUG_LEVEL_INFO)
43950 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43951 - __FILE__,__LINE__, tty->driver->name, port->count );
43952 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43953
43954 tty_unlock(tty);
43955 schedule();
43956 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43957
43958 /* FIXME: Racy on hangup during close wait */
43959 if (extra_count)
43960 - port->count++;
43961 + atomic_inc(&port->count);
43962 port->blocked_open--;
43963
43964 if (debug_level >= DEBUG_LEVEL_INFO)
43965 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43966 - __FILE__,__LINE__, tty->driver->name, port->count );
43967 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43968
43969 if (!retval)
43970 port->flags |= ASYNC_NORMAL_ACTIVE;
43971 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43972
43973 if (debug_level >= DEBUG_LEVEL_INFO)
43974 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43975 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43976 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43977
43978 /* If port is closing, signal caller to try again */
43979 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43980 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43981 spin_unlock_irqrestore(&info->netlock, flags);
43982 goto cleanup;
43983 }
43984 - info->port.count++;
43985 + atomic_inc(&info->port.count);
43986 spin_unlock_irqrestore(&info->netlock, flags);
43987
43988 - if (info->port.count == 1) {
43989 + if (atomic_read(&info->port.count) == 1) {
43990 /* 1st open on this device, init hardware */
43991 retval = startup(info);
43992 if (retval < 0)
43993 @@ -3451,8 +3451,8 @@ cleanup:
43994 if (retval) {
43995 if (tty->count == 1)
43996 info->port.tty = NULL; /* tty layer will release tty struct */
43997 - if(info->port.count)
43998 - info->port.count--;
43999 + if (atomic_read(&info->port.count))
44000 + atomic_dec(&info->port.count);
44001 }
44002
44003 return retval;
44004 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44005 unsigned short new_crctype;
44006
44007 /* return error if TTY interface open */
44008 - if (info->port.count)
44009 + if (atomic_read(&info->port.count))
44010 return -EBUSY;
44011
44012 switch (encoding)
44013 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
44014
44015 /* arbitrate between network and tty opens */
44016 spin_lock_irqsave(&info->netlock, flags);
44017 - if (info->port.count != 0 || info->netcount != 0) {
44018 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44019 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44020 spin_unlock_irqrestore(&info->netlock, flags);
44021 return -EBUSY;
44022 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44023 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44024
44025 /* return error if TTY interface open */
44026 - if (info->port.count)
44027 + if (atomic_read(&info->port.count))
44028 return -EBUSY;
44029
44030 if (cmd != SIOCWANDEV)
44031 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44032 index aba1e59..877ac33 100644
44033 --- a/drivers/tty/synclink_gt.c
44034 +++ b/drivers/tty/synclink_gt.c
44035 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44036 tty->driver_data = info;
44037 info->port.tty = tty;
44038
44039 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44040 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44041
44042 /* If port is closing, signal caller to try again */
44043 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44044 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44045 mutex_unlock(&info->port.mutex);
44046 goto cleanup;
44047 }
44048 - info->port.count++;
44049 + atomic_inc(&info->port.count);
44050 spin_unlock_irqrestore(&info->netlock, flags);
44051
44052 - if (info->port.count == 1) {
44053 + if (atomic_read(&info->port.count) == 1) {
44054 /* 1st open on this device, init hardware */
44055 retval = startup(info);
44056 if (retval < 0) {
44057 @@ -716,8 +716,8 @@ cleanup:
44058 if (retval) {
44059 if (tty->count == 1)
44060 info->port.tty = NULL; /* tty layer will release tty struct */
44061 - if(info->port.count)
44062 - info->port.count--;
44063 + if(atomic_read(&info->port.count))
44064 + atomic_dec(&info->port.count);
44065 }
44066
44067 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44068 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44069
44070 if (sanity_check(info, tty->name, "close"))
44071 return;
44072 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44073 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44074
44075 if (tty_port_close_start(&info->port, tty, filp) == 0)
44076 goto cleanup;
44077 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44078 tty_port_close_end(&info->port, tty);
44079 info->port.tty = NULL;
44080 cleanup:
44081 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44082 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44083 }
44084
44085 static void hangup(struct tty_struct *tty)
44086 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
44087 shutdown(info);
44088
44089 spin_lock_irqsave(&info->port.lock, flags);
44090 - info->port.count = 0;
44091 + atomic_set(&info->port.count, 0);
44092 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44093 info->port.tty = NULL;
44094 spin_unlock_irqrestore(&info->port.lock, flags);
44095 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44096 unsigned short new_crctype;
44097
44098 /* return error if TTY interface open */
44099 - if (info->port.count)
44100 + if (atomic_read(&info->port.count))
44101 return -EBUSY;
44102
44103 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44104 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
44105
44106 /* arbitrate between network and tty opens */
44107 spin_lock_irqsave(&info->netlock, flags);
44108 - if (info->port.count != 0 || info->netcount != 0) {
44109 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44110 DBGINFO(("%s hdlc_open busy\n", dev->name));
44111 spin_unlock_irqrestore(&info->netlock, flags);
44112 return -EBUSY;
44113 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44114 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44115
44116 /* return error if TTY interface open */
44117 - if (info->port.count)
44118 + if (atomic_read(&info->port.count))
44119 return -EBUSY;
44120
44121 if (cmd != SIOCWANDEV)
44122 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44123 if (port == NULL)
44124 continue;
44125 spin_lock(&port->lock);
44126 - if ((port->port.count || port->netcount) &&
44127 + if ((atomic_read(&port->port.count) || port->netcount) &&
44128 port->pending_bh && !port->bh_running &&
44129 !port->bh_requested) {
44130 DBGISR(("%s bh queued\n", port->device_name));
44131 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44132 spin_lock_irqsave(&info->lock, flags);
44133 if (!tty_hung_up_p(filp)) {
44134 extra_count = true;
44135 - port->count--;
44136 + atomic_dec(&port->count);
44137 }
44138 spin_unlock_irqrestore(&info->lock, flags);
44139 port->blocked_open++;
44140 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44141 remove_wait_queue(&port->open_wait, &wait);
44142
44143 if (extra_count)
44144 - port->count++;
44145 + atomic_inc(&port->count);
44146 port->blocked_open--;
44147
44148 if (!retval)
44149 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44150 index fd43fb6..34704ad 100644
44151 --- a/drivers/tty/synclinkmp.c
44152 +++ b/drivers/tty/synclinkmp.c
44153 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44154
44155 if (debug_level >= DEBUG_LEVEL_INFO)
44156 printk("%s(%d):%s open(), old ref count = %d\n",
44157 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44158 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44159
44160 /* If port is closing, signal caller to try again */
44161 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44162 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44163 spin_unlock_irqrestore(&info->netlock, flags);
44164 goto cleanup;
44165 }
44166 - info->port.count++;
44167 + atomic_inc(&info->port.count);
44168 spin_unlock_irqrestore(&info->netlock, flags);
44169
44170 - if (info->port.count == 1) {
44171 + if (atomic_read(&info->port.count) == 1) {
44172 /* 1st open on this device, init hardware */
44173 retval = startup(info);
44174 if (retval < 0)
44175 @@ -797,8 +797,8 @@ cleanup:
44176 if (retval) {
44177 if (tty->count == 1)
44178 info->port.tty = NULL; /* tty layer will release tty struct */
44179 - if(info->port.count)
44180 - info->port.count--;
44181 + if(atomic_read(&info->port.count))
44182 + atomic_dec(&info->port.count);
44183 }
44184
44185 return retval;
44186 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44187
44188 if (debug_level >= DEBUG_LEVEL_INFO)
44189 printk("%s(%d):%s close() entry, count=%d\n",
44190 - __FILE__,__LINE__, info->device_name, info->port.count);
44191 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44192
44193 if (tty_port_close_start(&info->port, tty, filp) == 0)
44194 goto cleanup;
44195 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44196 cleanup:
44197 if (debug_level >= DEBUG_LEVEL_INFO)
44198 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44199 - tty->driver->name, info->port.count);
44200 + tty->driver->name, atomic_read(&info->port.count));
44201 }
44202
44203 /* Called by tty_hangup() when a hangup is signaled.
44204 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
44205 shutdown(info);
44206
44207 spin_lock_irqsave(&info->port.lock, flags);
44208 - info->port.count = 0;
44209 + atomic_set(&info->port.count, 0);
44210 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44211 info->port.tty = NULL;
44212 spin_unlock_irqrestore(&info->port.lock, flags);
44213 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44214 unsigned short new_crctype;
44215
44216 /* return error if TTY interface open */
44217 - if (info->port.count)
44218 + if (atomic_read(&info->port.count))
44219 return -EBUSY;
44220
44221 switch (encoding)
44222 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
44223
44224 /* arbitrate between network and tty opens */
44225 spin_lock_irqsave(&info->netlock, flags);
44226 - if (info->port.count != 0 || info->netcount != 0) {
44227 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44228 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44229 spin_unlock_irqrestore(&info->netlock, flags);
44230 return -EBUSY;
44231 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44232 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44233
44234 /* return error if TTY interface open */
44235 - if (info->port.count)
44236 + if (atomic_read(&info->port.count))
44237 return -EBUSY;
44238
44239 if (cmd != SIOCWANDEV)
44240 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44241 * do not request bottom half processing if the
44242 * device is not open in a normal mode.
44243 */
44244 - if ( port && (port->port.count || port->netcount) &&
44245 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44246 port->pending_bh && !port->bh_running &&
44247 !port->bh_requested ) {
44248 if ( debug_level >= DEBUG_LEVEL_ISR )
44249 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44250
44251 if (debug_level >= DEBUG_LEVEL_INFO)
44252 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44253 - __FILE__,__LINE__, tty->driver->name, port->count );
44254 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44255
44256 spin_lock_irqsave(&info->lock, flags);
44257 if (!tty_hung_up_p(filp)) {
44258 extra_count = true;
44259 - port->count--;
44260 + atomic_dec(&port->count);
44261 }
44262 spin_unlock_irqrestore(&info->lock, flags);
44263 port->blocked_open++;
44264 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44265
44266 if (debug_level >= DEBUG_LEVEL_INFO)
44267 printk("%s(%d):%s block_til_ready() count=%d\n",
44268 - __FILE__,__LINE__, tty->driver->name, port->count );
44269 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44270
44271 tty_unlock(tty);
44272 schedule();
44273 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44274 remove_wait_queue(&port->open_wait, &wait);
44275
44276 if (extra_count)
44277 - port->count++;
44278 + atomic_inc(&port->count);
44279 port->blocked_open--;
44280
44281 if (debug_level >= DEBUG_LEVEL_INFO)
44282 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44283 - __FILE__,__LINE__, tty->driver->name, port->count );
44284 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44285
44286 if (!retval)
44287 port->flags |= ASYNC_NORMAL_ACTIVE;
44288 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44289 index b3c4a25..723916f 100644
44290 --- a/drivers/tty/sysrq.c
44291 +++ b/drivers/tty/sysrq.c
44292 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44293 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44294 size_t count, loff_t *ppos)
44295 {
44296 - if (count) {
44297 + if (count && capable(CAP_SYS_ADMIN)) {
44298 char c;
44299
44300 if (get_user(c, buf))
44301 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44302 index da9fde8..c07975f 100644
44303 --- a/drivers/tty/tty_io.c
44304 +++ b/drivers/tty/tty_io.c
44305 @@ -3391,7 +3391,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44306
44307 void tty_default_fops(struct file_operations *fops)
44308 {
44309 - *fops = tty_fops;
44310 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44311 }
44312
44313 /*
44314 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44315 index 78f1be2..3e98910 100644
44316 --- a/drivers/tty/tty_ldisc.c
44317 +++ b/drivers/tty/tty_ldisc.c
44318 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
44319 if (atomic_dec_and_test(&ld->users)) {
44320 struct tty_ldisc_ops *ldo = ld->ops;
44321
44322 - ldo->refcount--;
44323 + atomic_dec(&ldo->refcount);
44324 module_put(ldo->owner);
44325 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44326
44327 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44328 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44329 tty_ldiscs[disc] = new_ldisc;
44330 new_ldisc->num = disc;
44331 - new_ldisc->refcount = 0;
44332 + atomic_set(&new_ldisc->refcount, 0);
44333 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44334
44335 return ret;
44336 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
44337 return -EINVAL;
44338
44339 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44340 - if (tty_ldiscs[disc]->refcount)
44341 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44342 ret = -EBUSY;
44343 else
44344 tty_ldiscs[disc] = NULL;
44345 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44346 if (ldops) {
44347 ret = ERR_PTR(-EAGAIN);
44348 if (try_module_get(ldops->owner)) {
44349 - ldops->refcount++;
44350 + atomic_inc(&ldops->refcount);
44351 ret = ldops;
44352 }
44353 }
44354 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44355 unsigned long flags;
44356
44357 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44358 - ldops->refcount--;
44359 + atomic_dec(&ldops->refcount);
44360 module_put(ldops->owner);
44361 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44362 }
44363 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44364 index b7ff59d..7c6105e 100644
44365 --- a/drivers/tty/tty_port.c
44366 +++ b/drivers/tty/tty_port.c
44367 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
44368 unsigned long flags;
44369
44370 spin_lock_irqsave(&port->lock, flags);
44371 - port->count = 0;
44372 + atomic_set(&port->count, 0);
44373 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44374 if (port->tty) {
44375 set_bit(TTY_IO_ERROR, &port->tty->flags);
44376 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44377 /* The port lock protects the port counts */
44378 spin_lock_irqsave(&port->lock, flags);
44379 if (!tty_hung_up_p(filp))
44380 - port->count--;
44381 + atomic_dec(&port->count);
44382 port->blocked_open++;
44383 spin_unlock_irqrestore(&port->lock, flags);
44384
44385 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44386 we must not mess that up further */
44387 spin_lock_irqsave(&port->lock, flags);
44388 if (!tty_hung_up_p(filp))
44389 - port->count++;
44390 + atomic_inc(&port->count);
44391 port->blocked_open--;
44392 if (retval == 0)
44393 port->flags |= ASYNC_NORMAL_ACTIVE;
44394 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
44395 return 0;
44396 }
44397
44398 - if (tty->count == 1 && port->count != 1) {
44399 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44400 printk(KERN_WARNING
44401 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44402 - port->count);
44403 - port->count = 1;
44404 + atomic_read(&port->count));
44405 + atomic_set(&port->count, 1);
44406 }
44407 - if (--port->count < 0) {
44408 + if (atomic_dec_return(&port->count) < 0) {
44409 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44410 - port->count);
44411 - port->count = 0;
44412 + atomic_read(&port->count));
44413 + atomic_set(&port->count, 0);
44414 }
44415
44416 - if (port->count) {
44417 + if (atomic_read(&port->count)) {
44418 spin_unlock_irqrestore(&port->lock, flags);
44419 if (port->ops->drop)
44420 port->ops->drop(port);
44421 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44422 {
44423 spin_lock_irq(&port->lock);
44424 if (!tty_hung_up_p(filp))
44425 - ++port->count;
44426 + atomic_inc(&port->count);
44427 spin_unlock_irq(&port->lock);
44428 tty_port_tty_set(port, tty);
44429
44430 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44431 index 681765b..d3ccdf2 100644
44432 --- a/drivers/tty/vt/keyboard.c
44433 +++ b/drivers/tty/vt/keyboard.c
44434 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44435 kbd->kbdmode == VC_OFF) &&
44436 value != KVAL(K_SAK))
44437 return; /* SAK is allowed even in raw mode */
44438 +
44439 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44440 + {
44441 + void *func = fn_handler[value];
44442 + if (func == fn_show_state || func == fn_show_ptregs ||
44443 + func == fn_show_mem)
44444 + return;
44445 + }
44446 +#endif
44447 +
44448 fn_handler[value](vc);
44449 }
44450
44451 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44452 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44453 return -EFAULT;
44454
44455 - if (!capable(CAP_SYS_TTY_CONFIG))
44456 - perm = 0;
44457 -
44458 switch (cmd) {
44459 case KDGKBENT:
44460 /* Ensure another thread doesn't free it under us */
44461 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44462 spin_unlock_irqrestore(&kbd_event_lock, flags);
44463 return put_user(val, &user_kbe->kb_value);
44464 case KDSKBENT:
44465 + if (!capable(CAP_SYS_TTY_CONFIG))
44466 + perm = 0;
44467 +
44468 if (!perm)
44469 return -EPERM;
44470 if (!i && v == K_NOSUCHMAP) {
44471 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44472 int i, j, k;
44473 int ret;
44474
44475 - if (!capable(CAP_SYS_TTY_CONFIG))
44476 - perm = 0;
44477 -
44478 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44479 if (!kbs) {
44480 ret = -ENOMEM;
44481 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44482 kfree(kbs);
44483 return ((p && *p) ? -EOVERFLOW : 0);
44484 case KDSKBSENT:
44485 + if (!capable(CAP_SYS_TTY_CONFIG))
44486 + perm = 0;
44487 +
44488 if (!perm) {
44489 ret = -EPERM;
44490 goto reterr;
44491 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44492 index 5110f36..8dc0a74 100644
44493 --- a/drivers/uio/uio.c
44494 +++ b/drivers/uio/uio.c
44495 @@ -25,6 +25,7 @@
44496 #include <linux/kobject.h>
44497 #include <linux/cdev.h>
44498 #include <linux/uio_driver.h>
44499 +#include <asm/local.h>
44500
44501 #define UIO_MAX_DEVICES (1U << MINORBITS)
44502
44503 @@ -32,10 +33,10 @@ struct uio_device {
44504 struct module *owner;
44505 struct device *dev;
44506 int minor;
44507 - atomic_t event;
44508 + atomic_unchecked_t event;
44509 struct fasync_struct *async_queue;
44510 wait_queue_head_t wait;
44511 - int vma_count;
44512 + local_t vma_count;
44513 struct uio_info *info;
44514 struct kobject *map_dir;
44515 struct kobject *portio_dir;
44516 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44517 struct device_attribute *attr, char *buf)
44518 {
44519 struct uio_device *idev = dev_get_drvdata(dev);
44520 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44521 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44522 }
44523
44524 static struct device_attribute uio_class_attributes[] = {
44525 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
44526 {
44527 struct uio_device *idev = info->uio_dev;
44528
44529 - atomic_inc(&idev->event);
44530 + atomic_inc_unchecked(&idev->event);
44531 wake_up_interruptible(&idev->wait);
44532 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44533 }
44534 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44535 }
44536
44537 listener->dev = idev;
44538 - listener->event_count = atomic_read(&idev->event);
44539 + listener->event_count = atomic_read_unchecked(&idev->event);
44540 filep->private_data = listener;
44541
44542 if (idev->info->open) {
44543 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44544 return -EIO;
44545
44546 poll_wait(filep, &idev->wait, wait);
44547 - if (listener->event_count != atomic_read(&idev->event))
44548 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44549 return POLLIN | POLLRDNORM;
44550 return 0;
44551 }
44552 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44553 do {
44554 set_current_state(TASK_INTERRUPTIBLE);
44555
44556 - event_count = atomic_read(&idev->event);
44557 + event_count = atomic_read_unchecked(&idev->event);
44558 if (event_count != listener->event_count) {
44559 if (copy_to_user(buf, &event_count, count))
44560 retval = -EFAULT;
44561 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44562 static void uio_vma_open(struct vm_area_struct *vma)
44563 {
44564 struct uio_device *idev = vma->vm_private_data;
44565 - idev->vma_count++;
44566 + local_inc(&idev->vma_count);
44567 }
44568
44569 static void uio_vma_close(struct vm_area_struct *vma)
44570 {
44571 struct uio_device *idev = vma->vm_private_data;
44572 - idev->vma_count--;
44573 + local_dec(&idev->vma_count);
44574 }
44575
44576 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44577 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
44578 idev->owner = owner;
44579 idev->info = info;
44580 init_waitqueue_head(&idev->wait);
44581 - atomic_set(&idev->event, 0);
44582 + atomic_set_unchecked(&idev->event, 0);
44583
44584 ret = uio_get_minor(idev);
44585 if (ret)
44586 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44587 index b7eb86a..36d28af 100644
44588 --- a/drivers/usb/atm/cxacru.c
44589 +++ b/drivers/usb/atm/cxacru.c
44590 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44591 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44592 if (ret < 2)
44593 return -EINVAL;
44594 - if (index < 0 || index > 0x7f)
44595 + if (index > 0x7f)
44596 return -EINVAL;
44597 pos += tmp;
44598
44599 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44600 index 35f10bf..6a38a0b 100644
44601 --- a/drivers/usb/atm/usbatm.c
44602 +++ b/drivers/usb/atm/usbatm.c
44603 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44604 if (printk_ratelimit())
44605 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44606 __func__, vpi, vci);
44607 - atomic_inc(&vcc->stats->rx_err);
44608 + atomic_inc_unchecked(&vcc->stats->rx_err);
44609 return;
44610 }
44611
44612 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44613 if (length > ATM_MAX_AAL5_PDU) {
44614 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44615 __func__, length, vcc);
44616 - atomic_inc(&vcc->stats->rx_err);
44617 + atomic_inc_unchecked(&vcc->stats->rx_err);
44618 goto out;
44619 }
44620
44621 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44622 if (sarb->len < pdu_length) {
44623 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44624 __func__, pdu_length, sarb->len, vcc);
44625 - atomic_inc(&vcc->stats->rx_err);
44626 + atomic_inc_unchecked(&vcc->stats->rx_err);
44627 goto out;
44628 }
44629
44630 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44631 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44632 __func__, vcc);
44633 - atomic_inc(&vcc->stats->rx_err);
44634 + atomic_inc_unchecked(&vcc->stats->rx_err);
44635 goto out;
44636 }
44637
44638 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44639 if (printk_ratelimit())
44640 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44641 __func__, length);
44642 - atomic_inc(&vcc->stats->rx_drop);
44643 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44644 goto out;
44645 }
44646
44647 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44648
44649 vcc->push(vcc, skb);
44650
44651 - atomic_inc(&vcc->stats->rx);
44652 + atomic_inc_unchecked(&vcc->stats->rx);
44653 out:
44654 skb_trim(sarb, 0);
44655 }
44656 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44657 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44658
44659 usbatm_pop(vcc, skb);
44660 - atomic_inc(&vcc->stats->tx);
44661 + atomic_inc_unchecked(&vcc->stats->tx);
44662
44663 skb = skb_dequeue(&instance->sndqueue);
44664 }
44665 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44666 if (!left--)
44667 return sprintf(page,
44668 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44669 - atomic_read(&atm_dev->stats.aal5.tx),
44670 - atomic_read(&atm_dev->stats.aal5.tx_err),
44671 - atomic_read(&atm_dev->stats.aal5.rx),
44672 - atomic_read(&atm_dev->stats.aal5.rx_err),
44673 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44674 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44675 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44676 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44677 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44678 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44679
44680 if (!left--) {
44681 if (instance->disconnected)
44682 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44683 index cbacea9..246cccd 100644
44684 --- a/drivers/usb/core/devices.c
44685 +++ b/drivers/usb/core/devices.c
44686 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44687 * time it gets called.
44688 */
44689 static struct device_connect_event {
44690 - atomic_t count;
44691 + atomic_unchecked_t count;
44692 wait_queue_head_t wait;
44693 } device_event = {
44694 .count = ATOMIC_INIT(1),
44695 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44696
44697 void usbfs_conn_disc_event(void)
44698 {
44699 - atomic_add(2, &device_event.count);
44700 + atomic_add_unchecked(2, &device_event.count);
44701 wake_up(&device_event.wait);
44702 }
44703
44704 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
44705
44706 poll_wait(file, &device_event.wait, wait);
44707
44708 - event_count = atomic_read(&device_event.count);
44709 + event_count = atomic_read_unchecked(&device_event.count);
44710 if (file->f_version != event_count) {
44711 file->f_version = event_count;
44712 return POLLIN | POLLRDNORM;
44713 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44714 index 8e64adf..9a33a3c 100644
44715 --- a/drivers/usb/core/hcd.c
44716 +++ b/drivers/usb/core/hcd.c
44717 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44718 */
44719 usb_get_urb(urb);
44720 atomic_inc(&urb->use_count);
44721 - atomic_inc(&urb->dev->urbnum);
44722 + atomic_inc_unchecked(&urb->dev->urbnum);
44723 usbmon_urb_submit(&hcd->self, urb);
44724
44725 /* NOTE requirements on root-hub callers (usbfs and the hub
44726 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44727 urb->hcpriv = NULL;
44728 INIT_LIST_HEAD(&urb->urb_list);
44729 atomic_dec(&urb->use_count);
44730 - atomic_dec(&urb->dev->urbnum);
44731 + atomic_dec_unchecked(&urb->dev->urbnum);
44732 if (atomic_read(&urb->reject))
44733 wake_up(&usb_kill_urb_queue);
44734 usb_put_urb(urb);
44735 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44736 index 131f736..99004c3 100644
44737 --- a/drivers/usb/core/message.c
44738 +++ b/drivers/usb/core/message.c
44739 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44740 * method can wait for it to complete. Since you don't have a handle on the
44741 * URB used, you can't cancel the request.
44742 */
44743 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44744 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44745 __u8 requesttype, __u16 value, __u16 index, void *data,
44746 __u16 size, int timeout)
44747 {
44748 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44749 index 818e4a0..0fc9589 100644
44750 --- a/drivers/usb/core/sysfs.c
44751 +++ b/drivers/usb/core/sysfs.c
44752 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44753 struct usb_device *udev;
44754
44755 udev = to_usb_device(dev);
44756 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44757 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44758 }
44759 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44760
44761 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44762 index f81b925..78d22ec 100644
44763 --- a/drivers/usb/core/usb.c
44764 +++ b/drivers/usb/core/usb.c
44765 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44766 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44767 dev->state = USB_STATE_ATTACHED;
44768 dev->lpm_disable_count = 1;
44769 - atomic_set(&dev->urbnum, 0);
44770 + atomic_set_unchecked(&dev->urbnum, 0);
44771
44772 INIT_LIST_HEAD(&dev->ep0.urb_list);
44773 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44774 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44775 index 5e29dde..eca992f 100644
44776 --- a/drivers/usb/early/ehci-dbgp.c
44777 +++ b/drivers/usb/early/ehci-dbgp.c
44778 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44779
44780 #ifdef CONFIG_KGDB
44781 static struct kgdb_io kgdbdbgp_io_ops;
44782 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44783 +static struct kgdb_io kgdbdbgp_io_ops_console;
44784 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44785 #else
44786 #define dbgp_kgdb_mode (0)
44787 #endif
44788 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44789 .write_char = kgdbdbgp_write_char,
44790 };
44791
44792 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44793 + .name = "kgdbdbgp",
44794 + .read_char = kgdbdbgp_read_char,
44795 + .write_char = kgdbdbgp_write_char,
44796 + .is_console = 1
44797 +};
44798 +
44799 static int kgdbdbgp_wait_time;
44800
44801 static int __init kgdbdbgp_parse_config(char *str)
44802 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44803 ptr++;
44804 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44805 }
44806 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44807 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44808 + if (early_dbgp_console.index != -1)
44809 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44810 + else
44811 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44812
44813 return 0;
44814 }
44815 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44816 index 598dcc1..032dd4f 100644
44817 --- a/drivers/usb/gadget/u_serial.c
44818 +++ b/drivers/usb/gadget/u_serial.c
44819 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44820 spin_lock_irq(&port->port_lock);
44821
44822 /* already open? Great. */
44823 - if (port->port.count) {
44824 + if (atomic_read(&port->port.count)) {
44825 status = 0;
44826 - port->port.count++;
44827 + atomic_inc(&port->port.count);
44828
44829 /* currently opening/closing? wait ... */
44830 } else if (port->openclose) {
44831 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44832 tty->driver_data = port;
44833 port->port.tty = tty;
44834
44835 - port->port.count = 1;
44836 + atomic_set(&port->port.count, 1);
44837 port->openclose = false;
44838
44839 /* if connected, start the I/O stream */
44840 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44841
44842 spin_lock_irq(&port->port_lock);
44843
44844 - if (port->port.count != 1) {
44845 - if (port->port.count == 0)
44846 + if (atomic_read(&port->port.count) != 1) {
44847 + if (atomic_read(&port->port.count) == 0)
44848 WARN_ON(1);
44849 else
44850 - --port->port.count;
44851 + atomic_dec(&port->port.count);
44852 goto exit;
44853 }
44854
44855 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44856 * and sleep if necessary
44857 */
44858 port->openclose = true;
44859 - port->port.count = 0;
44860 + atomic_set(&port->port.count, 0);
44861
44862 gser = port->port_usb;
44863 if (gser && gser->disconnect)
44864 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
44865 int cond;
44866
44867 spin_lock_irq(&port->port_lock);
44868 - cond = (port->port.count == 0) && !port->openclose;
44869 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44870 spin_unlock_irq(&port->port_lock);
44871 return cond;
44872 }
44873 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44874 /* if it's already open, start I/O ... and notify the serial
44875 * protocol about open/close status (connect/disconnect).
44876 */
44877 - if (port->port.count) {
44878 + if (atomic_read(&port->port.count)) {
44879 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44880 gs_start_io(port);
44881 if (gser->connect)
44882 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
44883
44884 port->port_usb = NULL;
44885 gser->ioport = NULL;
44886 - if (port->port.count > 0 || port->openclose) {
44887 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44888 wake_up_interruptible(&port->drain_wait);
44889 if (port->port.tty)
44890 tty_hangup(port->port.tty);
44891 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
44892
44893 /* finally, free any unused/unusable I/O buffers */
44894 spin_lock_irqsave(&port->port_lock, flags);
44895 - if (port->port.count == 0 && !port->openclose)
44896 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44897 gs_buf_free(&port->port_write_buf);
44898 gs_free_requests(gser->out, &port->read_pool, NULL);
44899 gs_free_requests(gser->out, &port->read_queue, NULL);
44900 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44901 index 5f3bcd3..bfca43f 100644
44902 --- a/drivers/usb/serial/console.c
44903 +++ b/drivers/usb/serial/console.c
44904 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44905
44906 info->port = port;
44907
44908 - ++port->port.count;
44909 + atomic_inc(&port->port.count);
44910 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44911 if (serial->type->set_termios) {
44912 /*
44913 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44914 }
44915 /* Now that any required fake tty operations are completed restore
44916 * the tty port count */
44917 - --port->port.count;
44918 + atomic_dec(&port->port.count);
44919 /* The console is special in terms of closing the device so
44920 * indicate this port is now acting as a system console. */
44921 port->port.console = 1;
44922 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44923 free_tty:
44924 kfree(tty);
44925 reset_open_count:
44926 - port->port.count = 0;
44927 + atomic_set(&port->port.count, 0);
44928 usb_autopm_put_interface(serial->interface);
44929 error_get_interface:
44930 usb_serial_put(serial);
44931 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44932 index 6c3586a..a94e621 100644
44933 --- a/drivers/usb/storage/realtek_cr.c
44934 +++ b/drivers/usb/storage/realtek_cr.c
44935 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44936
44937 buf = kmalloc(len, GFP_NOIO);
44938 if (buf == NULL)
44939 - return USB_STOR_TRANSPORT_ERROR;
44940 + return -ENOMEM;
44941
44942 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44943
44944 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44945 index 75f70f0..d467e1a 100644
44946 --- a/drivers/usb/storage/usb.h
44947 +++ b/drivers/usb/storage/usb.h
44948 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44949 __u8 useProtocol;
44950 __u8 useTransport;
44951 int (*initFunction)(struct us_data *);
44952 -};
44953 +} __do_const;
44954
44955
44956 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44957 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44958 index d6bea3e..60b250e 100644
44959 --- a/drivers/usb/wusbcore/wa-hc.h
44960 +++ b/drivers/usb/wusbcore/wa-hc.h
44961 @@ -192,7 +192,7 @@ struct wahc {
44962 struct list_head xfer_delayed_list;
44963 spinlock_t xfer_list_lock;
44964 struct work_struct xfer_work;
44965 - atomic_t xfer_id_count;
44966 + atomic_unchecked_t xfer_id_count;
44967 };
44968
44969
44970 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44971 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44972 spin_lock_init(&wa->xfer_list_lock);
44973 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44974 - atomic_set(&wa->xfer_id_count, 1);
44975 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44976 }
44977
44978 /**
44979 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44980 index 57c01ab..8a05959 100644
44981 --- a/drivers/usb/wusbcore/wa-xfer.c
44982 +++ b/drivers/usb/wusbcore/wa-xfer.c
44983 @@ -296,7 +296,7 @@ out:
44984 */
44985 static void wa_xfer_id_init(struct wa_xfer *xfer)
44986 {
44987 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44988 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44989 }
44990
44991 /*
44992 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44993 index 8c55011..eed4ae1a 100644
44994 --- a/drivers/video/aty/aty128fb.c
44995 +++ b/drivers/video/aty/aty128fb.c
44996 @@ -149,7 +149,7 @@ enum {
44997 };
44998
44999 /* Must match above enum */
45000 -static char * const r128_family[] = {
45001 +static const char * const r128_family[] = {
45002 "AGP",
45003 "PCI",
45004 "PRO AGP",
45005 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
45006 index 4f27fdc..d3537e6 100644
45007 --- a/drivers/video/aty/atyfb_base.c
45008 +++ b/drivers/video/aty/atyfb_base.c
45009 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
45010 par->accel_flags = var->accel_flags; /* hack */
45011
45012 if (var->accel_flags) {
45013 - info->fbops->fb_sync = atyfb_sync;
45014 + pax_open_kernel();
45015 + *(void **)&info->fbops->fb_sync = atyfb_sync;
45016 + pax_close_kernel();
45017 info->flags &= ~FBINFO_HWACCEL_DISABLED;
45018 } else {
45019 - info->fbops->fb_sync = NULL;
45020 + pax_open_kernel();
45021 + *(void **)&info->fbops->fb_sync = NULL;
45022 + pax_close_kernel();
45023 info->flags |= FBINFO_HWACCEL_DISABLED;
45024 }
45025
45026 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
45027 index 95ec042..e6affdd 100644
45028 --- a/drivers/video/aty/mach64_cursor.c
45029 +++ b/drivers/video/aty/mach64_cursor.c
45030 @@ -7,6 +7,7 @@
45031 #include <linux/string.h>
45032
45033 #include <asm/io.h>
45034 +#include <asm/pgtable.h>
45035
45036 #ifdef __sparc__
45037 #include <asm/fbio.h>
45038 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45039 info->sprite.buf_align = 16; /* and 64 lines tall. */
45040 info->sprite.flags = FB_PIXMAP_IO;
45041
45042 - info->fbops->fb_cursor = atyfb_cursor;
45043 + pax_open_kernel();
45044 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45045 + pax_close_kernel();
45046
45047 return 0;
45048 }
45049 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45050 index 6c5ed6b..b727c88 100644
45051 --- a/drivers/video/backlight/kb3886_bl.c
45052 +++ b/drivers/video/backlight/kb3886_bl.c
45053 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45054 static unsigned long kb3886bl_flags;
45055 #define KB3886BL_SUSPENDED 0x01
45056
45057 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45058 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45059 {
45060 .ident = "Sahara Touch-iT",
45061 .matches = {
45062 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45063 index 88cad6b..dd746c7 100644
45064 --- a/drivers/video/fb_defio.c
45065 +++ b/drivers/video/fb_defio.c
45066 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45067
45068 BUG_ON(!fbdefio);
45069 mutex_init(&fbdefio->lock);
45070 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45071 + pax_open_kernel();
45072 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45073 + pax_close_kernel();
45074 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45075 INIT_LIST_HEAD(&fbdefio->pagelist);
45076 if (fbdefio->delay == 0) /* set a default of 1 s */
45077 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45078 page->mapping = NULL;
45079 }
45080
45081 - info->fbops->fb_mmap = NULL;
45082 + *(void **)&info->fbops->fb_mmap = NULL;
45083 mutex_destroy(&fbdefio->lock);
45084 }
45085 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45086 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45087 index 5c3960d..15cf8fc 100644
45088 --- a/drivers/video/fbcmap.c
45089 +++ b/drivers/video/fbcmap.c
45090 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45091 rc = -ENODEV;
45092 goto out;
45093 }
45094 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45095 - !info->fbops->fb_setcmap)) {
45096 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45097 rc = -EINVAL;
45098 goto out1;
45099 }
45100 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45101 index dc61c12..e29796e 100644
45102 --- a/drivers/video/fbmem.c
45103 +++ b/drivers/video/fbmem.c
45104 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45105 image->dx += image->width + 8;
45106 }
45107 } else if (rotate == FB_ROTATE_UD) {
45108 - for (x = 0; x < num && image->dx >= 0; x++) {
45109 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45110 info->fbops->fb_imageblit(info, image);
45111 image->dx -= image->width + 8;
45112 }
45113 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45114 image->dy += image->height + 8;
45115 }
45116 } else if (rotate == FB_ROTATE_CCW) {
45117 - for (x = 0; x < num && image->dy >= 0; x++) {
45118 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45119 info->fbops->fb_imageblit(info, image);
45120 image->dy -= image->height + 8;
45121 }
45122 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45123 return -EFAULT;
45124 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45125 return -EINVAL;
45126 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45127 + if (con2fb.framebuffer >= FB_MAX)
45128 return -EINVAL;
45129 if (!registered_fb[con2fb.framebuffer])
45130 request_module("fb%d", con2fb.framebuffer);
45131 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45132 index 7672d2e..b56437f 100644
45133 --- a/drivers/video/i810/i810_accel.c
45134 +++ b/drivers/video/i810/i810_accel.c
45135 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45136 }
45137 }
45138 printk("ringbuffer lockup!!!\n");
45139 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45140 i810_report_error(mmio);
45141 par->dev_flags |= LOCKUP;
45142 info->pixmap.scan_align = 1;
45143 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45144 index 3c14e43..eafa544 100644
45145 --- a/drivers/video/logo/logo_linux_clut224.ppm
45146 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45147 @@ -1,1604 +1,1123 @@
45148 P3
45149 -# Standard 224-color Linux logo
45150 80 80
45151 255
45152 - 0 0 0 0 0 0 0 0 0 0 0 0
45153 - 0 0 0 0 0 0 0 0 0 0 0 0
45154 - 0 0 0 0 0 0 0 0 0 0 0 0
45155 - 0 0 0 0 0 0 0 0 0 0 0 0
45156 - 0 0 0 0 0 0 0 0 0 0 0 0
45157 - 0 0 0 0 0 0 0 0 0 0 0 0
45158 - 0 0 0 0 0 0 0 0 0 0 0 0
45159 - 0 0 0 0 0 0 0 0 0 0 0 0
45160 - 0 0 0 0 0 0 0 0 0 0 0 0
45161 - 6 6 6 6 6 6 10 10 10 10 10 10
45162 - 10 10 10 6 6 6 6 6 6 6 6 6
45163 - 0 0 0 0 0 0 0 0 0 0 0 0
45164 - 0 0 0 0 0 0 0 0 0 0 0 0
45165 - 0 0 0 0 0 0 0 0 0 0 0 0
45166 - 0 0 0 0 0 0 0 0 0 0 0 0
45167 - 0 0 0 0 0 0 0 0 0 0 0 0
45168 - 0 0 0 0 0 0 0 0 0 0 0 0
45169 - 0 0 0 0 0 0 0 0 0 0 0 0
45170 - 0 0 0 0 0 0 0 0 0 0 0 0
45171 - 0 0 0 0 0 0 0 0 0 0 0 0
45172 - 0 0 0 0 0 0 0 0 0 0 0 0
45173 - 0 0 0 0 0 0 0 0 0 0 0 0
45174 - 0 0 0 0 0 0 0 0 0 0 0 0
45175 - 0 0 0 0 0 0 0 0 0 0 0 0
45176 - 0 0 0 0 0 0 0 0 0 0 0 0
45177 - 0 0 0 0 0 0 0 0 0 0 0 0
45178 - 0 0 0 0 0 0 0 0 0 0 0 0
45179 - 0 0 0 0 0 0 0 0 0 0 0 0
45180 - 0 0 0 6 6 6 10 10 10 14 14 14
45181 - 22 22 22 26 26 26 30 30 30 34 34 34
45182 - 30 30 30 30 30 30 26 26 26 18 18 18
45183 - 14 14 14 10 10 10 6 6 6 0 0 0
45184 - 0 0 0 0 0 0 0 0 0 0 0 0
45185 - 0 0 0 0 0 0 0 0 0 0 0 0
45186 - 0 0 0 0 0 0 0 0 0 0 0 0
45187 - 0 0 0 0 0 0 0 0 0 0 0 0
45188 - 0 0 0 0 0 0 0 0 0 0 0 0
45189 - 0 0 0 0 0 0 0 0 0 0 0 0
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 1 0 0 1 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 - 6 6 6 14 14 14 26 26 26 42 42 42
45201 - 54 54 54 66 66 66 78 78 78 78 78 78
45202 - 78 78 78 74 74 74 66 66 66 54 54 54
45203 - 42 42 42 26 26 26 18 18 18 10 10 10
45204 - 6 6 6 0 0 0 0 0 0 0 0 0
45205 - 0 0 0 0 0 0 0 0 0 0 0 0
45206 - 0 0 0 0 0 0 0 0 0 0 0 0
45207 - 0 0 0 0 0 0 0 0 0 0 0 0
45208 - 0 0 0 0 0 0 0 0 0 0 0 0
45209 - 0 0 0 0 0 0 0 0 0 0 0 0
45210 - 0 0 0 0 0 0 0 0 0 0 0 0
45211 - 0 0 0 0 0 0 0 0 0 0 0 0
45212 - 0 0 0 0 0 0 0 0 0 0 0 0
45213 - 0 0 1 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 10 10 10
45220 - 22 22 22 42 42 42 66 66 66 86 86 86
45221 - 66 66 66 38 38 38 38 38 38 22 22 22
45222 - 26 26 26 34 34 34 54 54 54 66 66 66
45223 - 86 86 86 70 70 70 46 46 46 26 26 26
45224 - 14 14 14 6 6 6 0 0 0 0 0 0
45225 - 0 0 0 0 0 0 0 0 0 0 0 0
45226 - 0 0 0 0 0 0 0 0 0 0 0 0
45227 - 0 0 0 0 0 0 0 0 0 0 0 0
45228 - 0 0 0 0 0 0 0 0 0 0 0 0
45229 - 0 0 0 0 0 0 0 0 0 0 0 0
45230 - 0 0 0 0 0 0 0 0 0 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 1 0 0 1 0 0 1 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 10 10 10 26 26 26
45240 - 50 50 50 82 82 82 58 58 58 6 6 6
45241 - 2 2 6 2 2 6 2 2 6 2 2 6
45242 - 2 2 6 2 2 6 2 2 6 2 2 6
45243 - 6 6 6 54 54 54 86 86 86 66 66 66
45244 - 38 38 38 18 18 18 6 6 6 0 0 0
45245 - 0 0 0 0 0 0 0 0 0 0 0 0
45246 - 0 0 0 0 0 0 0 0 0 0 0 0
45247 - 0 0 0 0 0 0 0 0 0 0 0 0
45248 - 0 0 0 0 0 0 0 0 0 0 0 0
45249 - 0 0 0 0 0 0 0 0 0 0 0 0
45250 - 0 0 0 0 0 0 0 0 0 0 0 0
45251 - 0 0 0 0 0 0 0 0 0 0 0 0
45252 - 0 0 0 0 0 0 0 0 0 0 0 0
45253 - 0 0 0 0 0 0 0 0 0 0 0 0
45254 - 0 0 0 0 0 0 0 0 0 0 0 0
45255 - 0 0 0 0 0 0 0 0 0 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 6 6 6 22 22 22 50 50 50
45260 - 78 78 78 34 34 34 2 2 6 2 2 6
45261 - 2 2 6 2 2 6 2 2 6 2 2 6
45262 - 2 2 6 2 2 6 2 2 6 2 2 6
45263 - 2 2 6 2 2 6 6 6 6 70 70 70
45264 - 78 78 78 46 46 46 22 22 22 6 6 6
45265 - 0 0 0 0 0 0 0 0 0 0 0 0
45266 - 0 0 0 0 0 0 0 0 0 0 0 0
45267 - 0 0 0 0 0 0 0 0 0 0 0 0
45268 - 0 0 0 0 0 0 0 0 0 0 0 0
45269 - 0 0 0 0 0 0 0 0 0 0 0 0
45270 - 0 0 0 0 0 0 0 0 0 0 0 0
45271 - 0 0 0 0 0 0 0 0 0 0 0 0
45272 - 0 0 0 0 0 0 0 0 0 0 0 0
45273 - 0 0 1 0 0 1 0 0 1 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 - 6 6 6 18 18 18 42 42 42 82 82 82
45280 - 26 26 26 2 2 6 2 2 6 2 2 6
45281 - 2 2 6 2 2 6 2 2 6 2 2 6
45282 - 2 2 6 2 2 6 2 2 6 14 14 14
45283 - 46 46 46 34 34 34 6 6 6 2 2 6
45284 - 42 42 42 78 78 78 42 42 42 18 18 18
45285 - 6 6 6 0 0 0 0 0 0 0 0 0
45286 - 0 0 0 0 0 0 0 0 0 0 0 0
45287 - 0 0 0 0 0 0 0 0 0 0 0 0
45288 - 0 0 0 0 0 0 0 0 0 0 0 0
45289 - 0 0 0 0 0 0 0 0 0 0 0 0
45290 - 0 0 0 0 0 0 0 0 0 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 1 0 0 0 0 0 1 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 - 10 10 10 30 30 30 66 66 66 58 58 58
45300 - 2 2 6 2 2 6 2 2 6 2 2 6
45301 - 2 2 6 2 2 6 2 2 6 2 2 6
45302 - 2 2 6 2 2 6 2 2 6 26 26 26
45303 - 86 86 86 101 101 101 46 46 46 10 10 10
45304 - 2 2 6 58 58 58 70 70 70 34 34 34
45305 - 10 10 10 0 0 0 0 0 0 0 0 0
45306 - 0 0 0 0 0 0 0 0 0 0 0 0
45307 - 0 0 0 0 0 0 0 0 0 0 0 0
45308 - 0 0 0 0 0 0 0 0 0 0 0 0
45309 - 0 0 0 0 0 0 0 0 0 0 0 0
45310 - 0 0 0 0 0 0 0 0 0 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 0 0 0 0 0 0 0 0 0 0 0 0
45313 - 0 0 1 0 0 1 0 0 1 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 - 14 14 14 42 42 42 86 86 86 10 10 10
45320 - 2 2 6 2 2 6 2 2 6 2 2 6
45321 - 2 2 6 2 2 6 2 2 6 2 2 6
45322 - 2 2 6 2 2 6 2 2 6 30 30 30
45323 - 94 94 94 94 94 94 58 58 58 26 26 26
45324 - 2 2 6 6 6 6 78 78 78 54 54 54
45325 - 22 22 22 6 6 6 0 0 0 0 0 0
45326 - 0 0 0 0 0 0 0 0 0 0 0 0
45327 - 0 0 0 0 0 0 0 0 0 0 0 0
45328 - 0 0 0 0 0 0 0 0 0 0 0 0
45329 - 0 0 0 0 0 0 0 0 0 0 0 0
45330 - 0 0 0 0 0 0 0 0 0 0 0 0
45331 - 0 0 0 0 0 0 0 0 0 0 0 0
45332 - 0 0 0 0 0 0 0 0 0 0 0 0
45333 - 0 0 0 0 0 0 0 0 0 0 0 0
45334 - 0 0 0 0 0 0 0 0 0 0 0 0
45335 - 0 0 0 0 0 0 0 0 0 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 6 6 6
45339 - 22 22 22 62 62 62 62 62 62 2 2 6
45340 - 2 2 6 2 2 6 2 2 6 2 2 6
45341 - 2 2 6 2 2 6 2 2 6 2 2 6
45342 - 2 2 6 2 2 6 2 2 6 26 26 26
45343 - 54 54 54 38 38 38 18 18 18 10 10 10
45344 - 2 2 6 2 2 6 34 34 34 82 82 82
45345 - 38 38 38 14 14 14 0 0 0 0 0 0
45346 - 0 0 0 0 0 0 0 0 0 0 0 0
45347 - 0 0 0 0 0 0 0 0 0 0 0 0
45348 - 0 0 0 0 0 0 0 0 0 0 0 0
45349 - 0 0 0 0 0 0 0 0 0 0 0 0
45350 - 0 0 0 0 0 0 0 0 0 0 0 0
45351 - 0 0 0 0 0 0 0 0 0 0 0 0
45352 - 0 0 0 0 0 0 0 0 0 0 0 0
45353 - 0 0 0 0 0 1 0 0 1 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 6 6 6
45359 - 30 30 30 78 78 78 30 30 30 2 2 6
45360 - 2 2 6 2 2 6 2 2 6 2 2 6
45361 - 2 2 6 2 2 6 2 2 6 2 2 6
45362 - 2 2 6 2 2 6 2 2 6 10 10 10
45363 - 10 10 10 2 2 6 2 2 6 2 2 6
45364 - 2 2 6 2 2 6 2 2 6 78 78 78
45365 - 50 50 50 18 18 18 6 6 6 0 0 0
45366 - 0 0 0 0 0 0 0 0 0 0 0 0
45367 - 0 0 0 0 0 0 0 0 0 0 0 0
45368 - 0 0 0 0 0 0 0 0 0 0 0 0
45369 - 0 0 0 0 0 0 0 0 0 0 0 0
45370 - 0 0 0 0 0 0 0 0 0 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 0 0 0
45372 - 0 0 0 0 0 0 0 0 0 0 0 0
45373 - 0 0 1 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 10 10 10
45379 - 38 38 38 86 86 86 14 14 14 2 2 6
45380 - 2 2 6 2 2 6 2 2 6 2 2 6
45381 - 2 2 6 2 2 6 2 2 6 2 2 6
45382 - 2 2 6 2 2 6 2 2 6 2 2 6
45383 - 2 2 6 2 2 6 2 2 6 2 2 6
45384 - 2 2 6 2 2 6 2 2 6 54 54 54
45385 - 66 66 66 26 26 26 6 6 6 0 0 0
45386 - 0 0 0 0 0 0 0 0 0 0 0 0
45387 - 0 0 0 0 0 0 0 0 0 0 0 0
45388 - 0 0 0 0 0 0 0 0 0 0 0 0
45389 - 0 0 0 0 0 0 0 0 0 0 0 0
45390 - 0 0 0 0 0 0 0 0 0 0 0 0
45391 - 0 0 0 0 0 0 0 0 0 0 0 0
45392 - 0 0 0 0 0 0 0 0 0 0 0 0
45393 - 0 0 0 0 0 1 0 0 1 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 14 14 14
45399 - 42 42 42 82 82 82 2 2 6 2 2 6
45400 - 2 2 6 6 6 6 10 10 10 2 2 6
45401 - 2 2 6 2 2 6 2 2 6 2 2 6
45402 - 2 2 6 2 2 6 2 2 6 6 6 6
45403 - 14 14 14 10 10 10 2 2 6 2 2 6
45404 - 2 2 6 2 2 6 2 2 6 18 18 18
45405 - 82 82 82 34 34 34 10 10 10 0 0 0
45406 - 0 0 0 0 0 0 0 0 0 0 0 0
45407 - 0 0 0 0 0 0 0 0 0 0 0 0
45408 - 0 0 0 0 0 0 0 0 0 0 0 0
45409 - 0 0 0 0 0 0 0 0 0 0 0 0
45410 - 0 0 0 0 0 0 0 0 0 0 0 0
45411 - 0 0 0 0 0 0 0 0 0 0 0 0
45412 - 0 0 0 0 0 0 0 0 0 0 0 0
45413 - 0 0 1 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 14 14 14
45419 - 46 46 46 86 86 86 2 2 6 2 2 6
45420 - 6 6 6 6 6 6 22 22 22 34 34 34
45421 - 6 6 6 2 2 6 2 2 6 2 2 6
45422 - 2 2 6 2 2 6 18 18 18 34 34 34
45423 - 10 10 10 50 50 50 22 22 22 2 2 6
45424 - 2 2 6 2 2 6 2 2 6 10 10 10
45425 - 86 86 86 42 42 42 14 14 14 0 0 0
45426 - 0 0 0 0 0 0 0 0 0 0 0 0
45427 - 0 0 0 0 0 0 0 0 0 0 0 0
45428 - 0 0 0 0 0 0 0 0 0 0 0 0
45429 - 0 0 0 0 0 0 0 0 0 0 0 0
45430 - 0 0 0 0 0 0 0 0 0 0 0 0
45431 - 0 0 0 0 0 0 0 0 0 0 0 0
45432 - 0 0 0 0 0 0 0 0 0 0 0 0
45433 - 0 0 1 0 0 1 0 0 1 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 14 14 14
45439 - 46 46 46 86 86 86 2 2 6 2 2 6
45440 - 38 38 38 116 116 116 94 94 94 22 22 22
45441 - 22 22 22 2 2 6 2 2 6 2 2 6
45442 - 14 14 14 86 86 86 138 138 138 162 162 162
45443 -154 154 154 38 38 38 26 26 26 6 6 6
45444 - 2 2 6 2 2 6 2 2 6 2 2 6
45445 - 86 86 86 46 46 46 14 14 14 0 0 0
45446 - 0 0 0 0 0 0 0 0 0 0 0 0
45447 - 0 0 0 0 0 0 0 0 0 0 0 0
45448 - 0 0 0 0 0 0 0 0 0 0 0 0
45449 - 0 0 0 0 0 0 0 0 0 0 0 0
45450 - 0 0 0 0 0 0 0 0 0 0 0 0
45451 - 0 0 0 0 0 0 0 0 0 0 0 0
45452 - 0 0 0 0 0 0 0 0 0 0 0 0
45453 - 0 0 0 0 0 0 0 0 0 0 0 0
45454 - 0 0 0 0 0 0 0 0 0 0 0 0
45455 - 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 14 14 14
45459 - 46 46 46 86 86 86 2 2 6 14 14 14
45460 -134 134 134 198 198 198 195 195 195 116 116 116
45461 - 10 10 10 2 2 6 2 2 6 6 6 6
45462 -101 98 89 187 187 187 210 210 210 218 218 218
45463 -214 214 214 134 134 134 14 14 14 6 6 6
45464 - 2 2 6 2 2 6 2 2 6 2 2 6
45465 - 86 86 86 50 50 50 18 18 18 6 6 6
45466 - 0 0 0 0 0 0 0 0 0 0 0 0
45467 - 0 0 0 0 0 0 0 0 0 0 0 0
45468 - 0 0 0 0 0 0 0 0 0 0 0 0
45469 - 0 0 0 0 0 0 0 0 0 0 0 0
45470 - 0 0 0 0 0 0 0 0 0 0 0 0
45471 - 0 0 0 0 0 0 0 0 0 0 0 0
45472 - 0 0 0 0 0 0 0 0 1 0 0 0
45473 - 0 0 1 0 0 1 0 0 1 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 14 14 14
45479 - 46 46 46 86 86 86 2 2 6 54 54 54
45480 -218 218 218 195 195 195 226 226 226 246 246 246
45481 - 58 58 58 2 2 6 2 2 6 30 30 30
45482 -210 210 210 253 253 253 174 174 174 123 123 123
45483 -221 221 221 234 234 234 74 74 74 2 2 6
45484 - 2 2 6 2 2 6 2 2 6 2 2 6
45485 - 70 70 70 58 58 58 22 22 22 6 6 6
45486 - 0 0 0 0 0 0 0 0 0 0 0 0
45487 - 0 0 0 0 0 0 0 0 0 0 0 0
45488 - 0 0 0 0 0 0 0 0 0 0 0 0
45489 - 0 0 0 0 0 0 0 0 0 0 0 0
45490 - 0 0 0 0 0 0 0 0 0 0 0 0
45491 - 0 0 0 0 0 0 0 0 0 0 0 0
45492 - 0 0 0 0 0 0 0 0 0 0 0 0
45493 - 0 0 0 0 0 0 0 0 0 0 0 0
45494 - 0 0 0 0 0 0 0 0 0 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 14 14 14
45499 - 46 46 46 82 82 82 2 2 6 106 106 106
45500 -170 170 170 26 26 26 86 86 86 226 226 226
45501 -123 123 123 10 10 10 14 14 14 46 46 46
45502 -231 231 231 190 190 190 6 6 6 70 70 70
45503 - 90 90 90 238 238 238 158 158 158 2 2 6
45504 - 2 2 6 2 2 6 2 2 6 2 2 6
45505 - 70 70 70 58 58 58 22 22 22 6 6 6
45506 - 0 0 0 0 0 0 0 0 0 0 0 0
45507 - 0 0 0 0 0 0 0 0 0 0 0 0
45508 - 0 0 0 0 0 0 0 0 0 0 0 0
45509 - 0 0 0 0 0 0 0 0 0 0 0 0
45510 - 0 0 0 0 0 0 0 0 0 0 0 0
45511 - 0 0 0 0 0 0 0 0 0 0 0 0
45512 - 0 0 0 0 0 0 0 0 1 0 0 0
45513 - 0 0 1 0 0 1 0 0 1 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 14 14 14
45519 - 42 42 42 86 86 86 6 6 6 116 116 116
45520 -106 106 106 6 6 6 70 70 70 149 149 149
45521 -128 128 128 18 18 18 38 38 38 54 54 54
45522 -221 221 221 106 106 106 2 2 6 14 14 14
45523 - 46 46 46 190 190 190 198 198 198 2 2 6
45524 - 2 2 6 2 2 6 2 2 6 2 2 6
45525 - 74 74 74 62 62 62 22 22 22 6 6 6
45526 - 0 0 0 0 0 0 0 0 0 0 0 0
45527 - 0 0 0 0 0 0 0 0 0 0 0 0
45528 - 0 0 0 0 0 0 0 0 0 0 0 0
45529 - 0 0 0 0 0 0 0 0 0 0 0 0
45530 - 0 0 0 0 0 0 0 0 0 0 0 0
45531 - 0 0 0 0 0 0 0 0 0 0 0 0
45532 - 0 0 0 0 0 0 0 0 1 0 0 0
45533 - 0 0 1 0 0 0 0 0 1 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 14 14 14
45539 - 42 42 42 94 94 94 14 14 14 101 101 101
45540 -128 128 128 2 2 6 18 18 18 116 116 116
45541 -118 98 46 121 92 8 121 92 8 98 78 10
45542 -162 162 162 106 106 106 2 2 6 2 2 6
45543 - 2 2 6 195 195 195 195 195 195 6 6 6
45544 - 2 2 6 2 2 6 2 2 6 2 2 6
45545 - 74 74 74 62 62 62 22 22 22 6 6 6
45546 - 0 0 0 0 0 0 0 0 0 0 0 0
45547 - 0 0 0 0 0 0 0 0 0 0 0 0
45548 - 0 0 0 0 0 0 0 0 0 0 0 0
45549 - 0 0 0 0 0 0 0 0 0 0 0 0
45550 - 0 0 0 0 0 0 0 0 0 0 0 0
45551 - 0 0 0 0 0 0 0 0 0 0 0 0
45552 - 0 0 0 0 0 0 0 0 1 0 0 1
45553 - 0 0 1 0 0 0 0 0 1 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 10 10 10
45559 - 38 38 38 90 90 90 14 14 14 58 58 58
45560 -210 210 210 26 26 26 54 38 6 154 114 10
45561 -226 170 11 236 186 11 225 175 15 184 144 12
45562 -215 174 15 175 146 61 37 26 9 2 2 6
45563 - 70 70 70 246 246 246 138 138 138 2 2 6
45564 - 2 2 6 2 2 6 2 2 6 2 2 6
45565 - 70 70 70 66 66 66 26 26 26 6 6 6
45566 - 0 0 0 0 0 0 0 0 0 0 0 0
45567 - 0 0 0 0 0 0 0 0 0 0 0 0
45568 - 0 0 0 0 0 0 0 0 0 0 0 0
45569 - 0 0 0 0 0 0 0 0 0 0 0 0
45570 - 0 0 0 0 0 0 0 0 0 0 0 0
45571 - 0 0 0 0 0 0 0 0 0 0 0 0
45572 - 0 0 0 0 0 0 0 0 0 0 0 0
45573 - 0 0 0 0 0 0 0 0 0 0 0 0
45574 - 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 10 10 10
45579 - 38 38 38 86 86 86 14 14 14 10 10 10
45580 -195 195 195 188 164 115 192 133 9 225 175 15
45581 -239 182 13 234 190 10 232 195 16 232 200 30
45582 -245 207 45 241 208 19 232 195 16 184 144 12
45583 -218 194 134 211 206 186 42 42 42 2 2 6
45584 - 2 2 6 2 2 6 2 2 6 2 2 6
45585 - 50 50 50 74 74 74 30 30 30 6 6 6
45586 - 0 0 0 0 0 0 0 0 0 0 0 0
45587 - 0 0 0 0 0 0 0 0 0 0 0 0
45588 - 0 0 0 0 0 0 0 0 0 0 0 0
45589 - 0 0 0 0 0 0 0 0 0 0 0 0
45590 - 0 0 0 0 0 0 0 0 0 0 0 0
45591 - 0 0 0 0 0 0 0 0 0 0 0 0
45592 - 0 0 0 0 0 0 0 0 0 0 0 0
45593 - 0 0 0 0 0 0 0 0 0 0 0 0
45594 - 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 10 10 10
45599 - 34 34 34 86 86 86 14 14 14 2 2 6
45600 -121 87 25 192 133 9 219 162 10 239 182 13
45601 -236 186 11 232 195 16 241 208 19 244 214 54
45602 -246 218 60 246 218 38 246 215 20 241 208 19
45603 -241 208 19 226 184 13 121 87 25 2 2 6
45604 - 2 2 6 2 2 6 2 2 6 2 2 6
45605 - 50 50 50 82 82 82 34 34 34 10 10 10
45606 - 0 0 0 0 0 0 0 0 0 0 0 0
45607 - 0 0 0 0 0 0 0 0 0 0 0 0
45608 - 0 0 0 0 0 0 0 0 0 0 0 0
45609 - 0 0 0 0 0 0 0 0 0 0 0 0
45610 - 0 0 0 0 0 0 0 0 0 0 0 0
45611 - 0 0 0 0 0 0 0 0 0 0 0 0
45612 - 0 0 0 0 0 0 0 0 0 0 0 0
45613 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45619 - 34 34 34 82 82 82 30 30 30 61 42 6
45620 -180 123 7 206 145 10 230 174 11 239 182 13
45621 -234 190 10 238 202 15 241 208 19 246 218 74
45622 -246 218 38 246 215 20 246 215 20 246 215 20
45623 -226 184 13 215 174 15 184 144 12 6 6 6
45624 - 2 2 6 2 2 6 2 2 6 2 2 6
45625 - 26 26 26 94 94 94 42 42 42 14 14 14
45626 - 0 0 0 0 0 0 0 0 0 0 0 0
45627 - 0 0 0 0 0 0 0 0 0 0 0 0
45628 - 0 0 0 0 0 0 0 0 0 0 0 0
45629 - 0 0 0 0 0 0 0 0 0 0 0 0
45630 - 0 0 0 0 0 0 0 0 0 0 0 0
45631 - 0 0 0 0 0 0 0 0 0 0 0 0
45632 - 0 0 0 0 0 0 0 0 0 0 0 0
45633 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45639 - 30 30 30 78 78 78 50 50 50 104 69 6
45640 -192 133 9 216 158 10 236 178 12 236 186 11
45641 -232 195 16 241 208 19 244 214 54 245 215 43
45642 -246 215 20 246 215 20 241 208 19 198 155 10
45643 -200 144 11 216 158 10 156 118 10 2 2 6
45644 - 2 2 6 2 2 6 2 2 6 2 2 6
45645 - 6 6 6 90 90 90 54 54 54 18 18 18
45646 - 6 6 6 0 0 0 0 0 0 0 0 0
45647 - 0 0 0 0 0 0 0 0 0 0 0 0
45648 - 0 0 0 0 0 0 0 0 0 0 0 0
45649 - 0 0 0 0 0 0 0 0 0 0 0 0
45650 - 0 0 0 0 0 0 0 0 0 0 0 0
45651 - 0 0 0 0 0 0 0 0 0 0 0 0
45652 - 0 0 0 0 0 0 0 0 0 0 0 0
45653 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45659 - 30 30 30 78 78 78 46 46 46 22 22 22
45660 -137 92 6 210 162 10 239 182 13 238 190 10
45661 -238 202 15 241 208 19 246 215 20 246 215 20
45662 -241 208 19 203 166 17 185 133 11 210 150 10
45663 -216 158 10 210 150 10 102 78 10 2 2 6
45664 - 6 6 6 54 54 54 14 14 14 2 2 6
45665 - 2 2 6 62 62 62 74 74 74 30 30 30
45666 - 10 10 10 0 0 0 0 0 0 0 0 0
45667 - 0 0 0 0 0 0 0 0 0 0 0 0
45668 - 0 0 0 0 0 0 0 0 0 0 0 0
45669 - 0 0 0 0 0 0 0 0 0 0 0 0
45670 - 0 0 0 0 0 0 0 0 0 0 0 0
45671 - 0 0 0 0 0 0 0 0 0 0 0 0
45672 - 0 0 0 0 0 0 0 0 0 0 0 0
45673 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45679 - 34 34 34 78 78 78 50 50 50 6 6 6
45680 - 94 70 30 139 102 15 190 146 13 226 184 13
45681 -232 200 30 232 195 16 215 174 15 190 146 13
45682 -168 122 10 192 133 9 210 150 10 213 154 11
45683 -202 150 34 182 157 106 101 98 89 2 2 6
45684 - 2 2 6 78 78 78 116 116 116 58 58 58
45685 - 2 2 6 22 22 22 90 90 90 46 46 46
45686 - 18 18 18 6 6 6 0 0 0 0 0 0
45687 - 0 0 0 0 0 0 0 0 0 0 0 0
45688 - 0 0 0 0 0 0 0 0 0 0 0 0
45689 - 0 0 0 0 0 0 0 0 0 0 0 0
45690 - 0 0 0 0 0 0 0 0 0 0 0 0
45691 - 0 0 0 0 0 0 0 0 0 0 0 0
45692 - 0 0 0 0 0 0 0 0 0 0 0 0
45693 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45699 - 38 38 38 86 86 86 50 50 50 6 6 6
45700 -128 128 128 174 154 114 156 107 11 168 122 10
45701 -198 155 10 184 144 12 197 138 11 200 144 11
45702 -206 145 10 206 145 10 197 138 11 188 164 115
45703 -195 195 195 198 198 198 174 174 174 14 14 14
45704 - 2 2 6 22 22 22 116 116 116 116 116 116
45705 - 22 22 22 2 2 6 74 74 74 70 70 70
45706 - 30 30 30 10 10 10 0 0 0 0 0 0
45707 - 0 0 0 0 0 0 0 0 0 0 0 0
45708 - 0 0 0 0 0 0 0 0 0 0 0 0
45709 - 0 0 0 0 0 0 0 0 0 0 0 0
45710 - 0 0 0 0 0 0 0 0 0 0 0 0
45711 - 0 0 0 0 0 0 0 0 0 0 0 0
45712 - 0 0 0 0 0 0 0 0 0 0 0 0
45713 - 0 0 0 0 0 0 0 0 0 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 6 6 6 18 18 18
45719 - 50 50 50 101 101 101 26 26 26 10 10 10
45720 -138 138 138 190 190 190 174 154 114 156 107 11
45721 -197 138 11 200 144 11 197 138 11 192 133 9
45722 -180 123 7 190 142 34 190 178 144 187 187 187
45723 -202 202 202 221 221 221 214 214 214 66 66 66
45724 - 2 2 6 2 2 6 50 50 50 62 62 62
45725 - 6 6 6 2 2 6 10 10 10 90 90 90
45726 - 50 50 50 18 18 18 6 6 6 0 0 0
45727 - 0 0 0 0 0 0 0 0 0 0 0 0
45728 - 0 0 0 0 0 0 0 0 0 0 0 0
45729 - 0 0 0 0 0 0 0 0 0 0 0 0
45730 - 0 0 0 0 0 0 0 0 0 0 0 0
45731 - 0 0 0 0 0 0 0 0 0 0 0 0
45732 - 0 0 0 0 0 0 0 0 0 0 0 0
45733 - 0 0 0 0 0 0 0 0 0 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 10 10 10 34 34 34
45739 - 74 74 74 74 74 74 2 2 6 6 6 6
45740 -144 144 144 198 198 198 190 190 190 178 166 146
45741 -154 121 60 156 107 11 156 107 11 168 124 44
45742 -174 154 114 187 187 187 190 190 190 210 210 210
45743 -246 246 246 253 253 253 253 253 253 182 182 182
45744 - 6 6 6 2 2 6 2 2 6 2 2 6
45745 - 2 2 6 2 2 6 2 2 6 62 62 62
45746 - 74 74 74 34 34 34 14 14 14 0 0 0
45747 - 0 0 0 0 0 0 0 0 0 0 0 0
45748 - 0 0 0 0 0 0 0 0 0 0 0 0
45749 - 0 0 0 0 0 0 0 0 0 0 0 0
45750 - 0 0 0 0 0 0 0 0 0 0 0 0
45751 - 0 0 0 0 0 0 0 0 0 0 0 0
45752 - 0 0 0 0 0 0 0 0 0 0 0 0
45753 - 0 0 0 0 0 0 0 0 0 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 10 10 10 22 22 22 54 54 54
45759 - 94 94 94 18 18 18 2 2 6 46 46 46
45760 -234 234 234 221 221 221 190 190 190 190 190 190
45761 -190 190 190 187 187 187 187 187 187 190 190 190
45762 -190 190 190 195 195 195 214 214 214 242 242 242
45763 -253 253 253 253 253 253 253 253 253 253 253 253
45764 - 82 82 82 2 2 6 2 2 6 2 2 6
45765 - 2 2 6 2 2 6 2 2 6 14 14 14
45766 - 86 86 86 54 54 54 22 22 22 6 6 6
45767 - 0 0 0 0 0 0 0 0 0 0 0 0
45768 - 0 0 0 0 0 0 0 0 0 0 0 0
45769 - 0 0 0 0 0 0 0 0 0 0 0 0
45770 - 0 0 0 0 0 0 0 0 0 0 0 0
45771 - 0 0 0 0 0 0 0 0 0 0 0 0
45772 - 0 0 0 0 0 0 0 0 0 0 0 0
45773 - 0 0 0 0 0 0 0 0 0 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 - 6 6 6 18 18 18 46 46 46 90 90 90
45779 - 46 46 46 18 18 18 6 6 6 182 182 182
45780 -253 253 253 246 246 246 206 206 206 190 190 190
45781 -190 190 190 190 190 190 190 190 190 190 190 190
45782 -206 206 206 231 231 231 250 250 250 253 253 253
45783 -253 253 253 253 253 253 253 253 253 253 253 253
45784 -202 202 202 14 14 14 2 2 6 2 2 6
45785 - 2 2 6 2 2 6 2 2 6 2 2 6
45786 - 42 42 42 86 86 86 42 42 42 18 18 18
45787 - 6 6 6 0 0 0 0 0 0 0 0 0
45788 - 0 0 0 0 0 0 0 0 0 0 0 0
45789 - 0 0 0 0 0 0 0 0 0 0 0 0
45790 - 0 0 0 0 0 0 0 0 0 0 0 0
45791 - 0 0 0 0 0 0 0 0 0 0 0 0
45792 - 0 0 0 0 0 0 0 0 0 0 0 0
45793 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6
45798 - 14 14 14 38 38 38 74 74 74 66 66 66
45799 - 2 2 6 6 6 6 90 90 90 250 250 250
45800 -253 253 253 253 253 253 238 238 238 198 198 198
45801 -190 190 190 190 190 190 195 195 195 221 221 221
45802 -246 246 246 253 253 253 253 253 253 253 253 253
45803 -253 253 253 253 253 253 253 253 253 253 253 253
45804 -253 253 253 82 82 82 2 2 6 2 2 6
45805 - 2 2 6 2 2 6 2 2 6 2 2 6
45806 - 2 2 6 78 78 78 70 70 70 34 34 34
45807 - 14 14 14 6 6 6 0 0 0 0 0 0
45808 - 0 0 0 0 0 0 0 0 0 0 0 0
45809 - 0 0 0 0 0 0 0 0 0 0 0 0
45810 - 0 0 0 0 0 0 0 0 0 0 0 0
45811 - 0 0 0 0 0 0 0 0 0 0 0 0
45812 - 0 0 0 0 0 0 0 0 0 0 0 0
45813 - 0 0 0 0 0 0 0 0 0 0 0 0
45814 - 0 0 0 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 14 14 14
45818 - 34 34 34 66 66 66 78 78 78 6 6 6
45819 - 2 2 6 18 18 18 218 218 218 253 253 253
45820 -253 253 253 253 253 253 253 253 253 246 246 246
45821 -226 226 226 231 231 231 246 246 246 253 253 253
45822 -253 253 253 253 253 253 253 253 253 253 253 253
45823 -253 253 253 253 253 253 253 253 253 253 253 253
45824 -253 253 253 178 178 178 2 2 6 2 2 6
45825 - 2 2 6 2 2 6 2 2 6 2 2 6
45826 - 2 2 6 18 18 18 90 90 90 62 62 62
45827 - 30 30 30 10 10 10 0 0 0 0 0 0
45828 - 0 0 0 0 0 0 0 0 0 0 0 0
45829 - 0 0 0 0 0 0 0 0 0 0 0 0
45830 - 0 0 0 0 0 0 0 0 0 0 0 0
45831 - 0 0 0 0 0 0 0 0 0 0 0 0
45832 - 0 0 0 0 0 0 0 0 0 0 0 0
45833 - 0 0 0 0 0 0 0 0 0 0 0 0
45834 - 0 0 0 0 0 0 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 10 10 10 26 26 26
45838 - 58 58 58 90 90 90 18 18 18 2 2 6
45839 - 2 2 6 110 110 110 253 253 253 253 253 253
45840 -253 253 253 253 253 253 253 253 253 253 253 253
45841 -250 250 250 253 253 253 253 253 253 253 253 253
45842 -253 253 253 253 253 253 253 253 253 253 253 253
45843 -253 253 253 253 253 253 253 253 253 253 253 253
45844 -253 253 253 231 231 231 18 18 18 2 2 6
45845 - 2 2 6 2 2 6 2 2 6 2 2 6
45846 - 2 2 6 2 2 6 18 18 18 94 94 94
45847 - 54 54 54 26 26 26 10 10 10 0 0 0
45848 - 0 0 0 0 0 0 0 0 0 0 0 0
45849 - 0 0 0 0 0 0 0 0 0 0 0 0
45850 - 0 0 0 0 0 0 0 0 0 0 0 0
45851 - 0 0 0 0 0 0 0 0 0 0 0 0
45852 - 0 0 0 0 0 0 0 0 0 0 0 0
45853 - 0 0 0 0 0 0 0 0 0 0 0 0
45854 - 0 0 0 0 0 0 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 6 6 6 22 22 22 50 50 50
45858 - 90 90 90 26 26 26 2 2 6 2 2 6
45859 - 14 14 14 195 195 195 250 250 250 253 253 253
45860 -253 253 253 253 253 253 253 253 253 253 253 253
45861 -253 253 253 253 253 253 253 253 253 253 253 253
45862 -253 253 253 253 253 253 253 253 253 253 253 253
45863 -253 253 253 253 253 253 253 253 253 253 253 253
45864 -250 250 250 242 242 242 54 54 54 2 2 6
45865 - 2 2 6 2 2 6 2 2 6 2 2 6
45866 - 2 2 6 2 2 6 2 2 6 38 38 38
45867 - 86 86 86 50 50 50 22 22 22 6 6 6
45868 - 0 0 0 0 0 0 0 0 0 0 0 0
45869 - 0 0 0 0 0 0 0 0 0 0 0 0
45870 - 0 0 0 0 0 0 0 0 0 0 0 0
45871 - 0 0 0 0 0 0 0 0 0 0 0 0
45872 - 0 0 0 0 0 0 0 0 0 0 0 0
45873 - 0 0 0 0 0 0 0 0 0 0 0 0
45874 - 0 0 0 0 0 0 0 0 0 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 - 6 6 6 14 14 14 38 38 38 82 82 82
45878 - 34 34 34 2 2 6 2 2 6 2 2 6
45879 - 42 42 42 195 195 195 246 246 246 253 253 253
45880 -253 253 253 253 253 253 253 253 253 250 250 250
45881 -242 242 242 242 242 242 250 250 250 253 253 253
45882 -253 253 253 253 253 253 253 253 253 253 253 253
45883 -253 253 253 250 250 250 246 246 246 238 238 238
45884 -226 226 226 231 231 231 101 101 101 6 6 6
45885 - 2 2 6 2 2 6 2 2 6 2 2 6
45886 - 2 2 6 2 2 6 2 2 6 2 2 6
45887 - 38 38 38 82 82 82 42 42 42 14 14 14
45888 - 6 6 6 0 0 0 0 0 0 0 0 0
45889 - 0 0 0 0 0 0 0 0 0 0 0 0
45890 - 0 0 0 0 0 0 0 0 0 0 0 0
45891 - 0 0 0 0 0 0 0 0 0 0 0 0
45892 - 0 0 0 0 0 0 0 0 0 0 0 0
45893 - 0 0 0 0 0 0 0 0 0 0 0 0
45894 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 10 10 10 26 26 26 62 62 62 66 66 66
45898 - 2 2 6 2 2 6 2 2 6 6 6 6
45899 - 70 70 70 170 170 170 206 206 206 234 234 234
45900 -246 246 246 250 250 250 250 250 250 238 238 238
45901 -226 226 226 231 231 231 238 238 238 250 250 250
45902 -250 250 250 250 250 250 246 246 246 231 231 231
45903 -214 214 214 206 206 206 202 202 202 202 202 202
45904 -198 198 198 202 202 202 182 182 182 18 18 18
45905 - 2 2 6 2 2 6 2 2 6 2 2 6
45906 - 2 2 6 2 2 6 2 2 6 2 2 6
45907 - 2 2 6 62 62 62 66 66 66 30 30 30
45908 - 10 10 10 0 0 0 0 0 0 0 0 0
45909 - 0 0 0 0 0 0 0 0 0 0 0 0
45910 - 0 0 0 0 0 0 0 0 0 0 0 0
45911 - 0 0 0 0 0 0 0 0 0 0 0 0
45912 - 0 0 0 0 0 0 0 0 0 0 0 0
45913 - 0 0 0 0 0 0 0 0 0 0 0 0
45914 - 0 0 0 0 0 0 0 0 0 0 0 0
45915 - 0 0 0 0 0 0 0 0 0 0 0 0
45916 - 0 0 0 0 0 0 0 0 0 0 0 0
45917 - 14 14 14 42 42 42 82 82 82 18 18 18
45918 - 2 2 6 2 2 6 2 2 6 10 10 10
45919 - 94 94 94 182 182 182 218 218 218 242 242 242
45920 -250 250 250 253 253 253 253 253 253 250 250 250
45921 -234 234 234 253 253 253 253 253 253 253 253 253
45922 -253 253 253 253 253 253 253 253 253 246 246 246
45923 -238 238 238 226 226 226 210 210 210 202 202 202
45924 -195 195 195 195 195 195 210 210 210 158 158 158
45925 - 6 6 6 14 14 14 50 50 50 14 14 14
45926 - 2 2 6 2 2 6 2 2 6 2 2 6
45927 - 2 2 6 6 6 6 86 86 86 46 46 46
45928 - 18 18 18 6 6 6 0 0 0 0 0 0
45929 - 0 0 0 0 0 0 0 0 0 0 0 0
45930 - 0 0 0 0 0 0 0 0 0 0 0 0
45931 - 0 0 0 0 0 0 0 0 0 0 0 0
45932 - 0 0 0 0 0 0 0 0 0 0 0 0
45933 - 0 0 0 0 0 0 0 0 0 0 0 0
45934 - 0 0 0 0 0 0 0 0 0 0 0 0
45935 - 0 0 0 0 0 0 0 0 0 0 0 0
45936 - 0 0 0 0 0 0 0 0 0 6 6 6
45937 - 22 22 22 54 54 54 70 70 70 2 2 6
45938 - 2 2 6 10 10 10 2 2 6 22 22 22
45939 -166 166 166 231 231 231 250 250 250 253 253 253
45940 -253 253 253 253 253 253 253 253 253 250 250 250
45941 -242 242 242 253 253 253 253 253 253 253 253 253
45942 -253 253 253 253 253 253 253 253 253 253 253 253
45943 -253 253 253 253 253 253 253 253 253 246 246 246
45944 -231 231 231 206 206 206 198 198 198 226 226 226
45945 - 94 94 94 2 2 6 6 6 6 38 38 38
45946 - 30 30 30 2 2 6 2 2 6 2 2 6
45947 - 2 2 6 2 2 6 62 62 62 66 66 66
45948 - 26 26 26 10 10 10 0 0 0 0 0 0
45949 - 0 0 0 0 0 0 0 0 0 0 0 0
45950 - 0 0 0 0 0 0 0 0 0 0 0 0
45951 - 0 0 0 0 0 0 0 0 0 0 0 0
45952 - 0 0 0 0 0 0 0 0 0 0 0 0
45953 - 0 0 0 0 0 0 0 0 0 0 0 0
45954 - 0 0 0 0 0 0 0 0 0 0 0 0
45955 - 0 0 0 0 0 0 0 0 0 0 0 0
45956 - 0 0 0 0 0 0 0 0 0 10 10 10
45957 - 30 30 30 74 74 74 50 50 50 2 2 6
45958 - 26 26 26 26 26 26 2 2 6 106 106 106
45959 -238 238 238 253 253 253 253 253 253 253 253 253
45960 -253 253 253 253 253 253 253 253 253 253 253 253
45961 -253 253 253 253 253 253 253 253 253 253 253 253
45962 -253 253 253 253 253 253 253 253 253 253 253 253
45963 -253 253 253 253 253 253 253 253 253 253 253 253
45964 -253 253 253 246 246 246 218 218 218 202 202 202
45965 -210 210 210 14 14 14 2 2 6 2 2 6
45966 - 30 30 30 22 22 22 2 2 6 2 2 6
45967 - 2 2 6 2 2 6 18 18 18 86 86 86
45968 - 42 42 42 14 14 14 0 0 0 0 0 0
45969 - 0 0 0 0 0 0 0 0 0 0 0 0
45970 - 0 0 0 0 0 0 0 0 0 0 0 0
45971 - 0 0 0 0 0 0 0 0 0 0 0 0
45972 - 0 0 0 0 0 0 0 0 0 0 0 0
45973 - 0 0 0 0 0 0 0 0 0 0 0 0
45974 - 0 0 0 0 0 0 0 0 0 0 0 0
45975 - 0 0 0 0 0 0 0 0 0 0 0 0
45976 - 0 0 0 0 0 0 0 0 0 14 14 14
45977 - 42 42 42 90 90 90 22 22 22 2 2 6
45978 - 42 42 42 2 2 6 18 18 18 218 218 218
45979 -253 253 253 253 253 253 253 253 253 253 253 253
45980 -253 253 253 253 253 253 253 253 253 253 253 253
45981 -253 253 253 253 253 253 253 253 253 253 253 253
45982 -253 253 253 253 253 253 253 253 253 253 253 253
45983 -253 253 253 253 253 253 253 253 253 253 253 253
45984 -253 253 253 253 253 253 250 250 250 221 221 221
45985 -218 218 218 101 101 101 2 2 6 14 14 14
45986 - 18 18 18 38 38 38 10 10 10 2 2 6
45987 - 2 2 6 2 2 6 2 2 6 78 78 78
45988 - 58 58 58 22 22 22 6 6 6 0 0 0
45989 - 0 0 0 0 0 0 0 0 0 0 0 0
45990 - 0 0 0 0 0 0 0 0 0 0 0 0
45991 - 0 0 0 0 0 0 0 0 0 0 0 0
45992 - 0 0 0 0 0 0 0 0 0 0 0 0
45993 - 0 0 0 0 0 0 0 0 0 0 0 0
45994 - 0 0 0 0 0 0 0 0 0 0 0 0
45995 - 0 0 0 0 0 0 0 0 0 0 0 0
45996 - 0 0 0 0 0 0 6 6 6 18 18 18
45997 - 54 54 54 82 82 82 2 2 6 26 26 26
45998 - 22 22 22 2 2 6 123 123 123 253 253 253
45999 -253 253 253 253 253 253 253 253 253 253 253 253
46000 -253 253 253 253 253 253 253 253 253 253 253 253
46001 -253 253 253 253 253 253 253 253 253 253 253 253
46002 -253 253 253 253 253 253 253 253 253 253 253 253
46003 -253 253 253 253 253 253 253 253 253 253 253 253
46004 -253 253 253 253 253 253 253 253 253 250 250 250
46005 -238 238 238 198 198 198 6 6 6 38 38 38
46006 - 58 58 58 26 26 26 38 38 38 2 2 6
46007 - 2 2 6 2 2 6 2 2 6 46 46 46
46008 - 78 78 78 30 30 30 10 10 10 0 0 0
46009 - 0 0 0 0 0 0 0 0 0 0 0 0
46010 - 0 0 0 0 0 0 0 0 0 0 0 0
46011 - 0 0 0 0 0 0 0 0 0 0 0 0
46012 - 0 0 0 0 0 0 0 0 0 0 0 0
46013 - 0 0 0 0 0 0 0 0 0 0 0 0
46014 - 0 0 0 0 0 0 0 0 0 0 0 0
46015 - 0 0 0 0 0 0 0 0 0 0 0 0
46016 - 0 0 0 0 0 0 10 10 10 30 30 30
46017 - 74 74 74 58 58 58 2 2 6 42 42 42
46018 - 2 2 6 22 22 22 231 231 231 253 253 253
46019 -253 253 253 253 253 253 253 253 253 253 253 253
46020 -253 253 253 253 253 253 253 253 253 250 250 250
46021 -253 253 253 253 253 253 253 253 253 253 253 253
46022 -253 253 253 253 253 253 253 253 253 253 253 253
46023 -253 253 253 253 253 253 253 253 253 253 253 253
46024 -253 253 253 253 253 253 253 253 253 253 253 253
46025 -253 253 253 246 246 246 46 46 46 38 38 38
46026 - 42 42 42 14 14 14 38 38 38 14 14 14
46027 - 2 2 6 2 2 6 2 2 6 6 6 6
46028 - 86 86 86 46 46 46 14 14 14 0 0 0
46029 - 0 0 0 0 0 0 0 0 0 0 0 0
46030 - 0 0 0 0 0 0 0 0 0 0 0 0
46031 - 0 0 0 0 0 0 0 0 0 0 0 0
46032 - 0 0 0 0 0 0 0 0 0 0 0 0
46033 - 0 0 0 0 0 0 0 0 0 0 0 0
46034 - 0 0 0 0 0 0 0 0 0 0 0 0
46035 - 0 0 0 0 0 0 0 0 0 0 0 0
46036 - 0 0 0 6 6 6 14 14 14 42 42 42
46037 - 90 90 90 18 18 18 18 18 18 26 26 26
46038 - 2 2 6 116 116 116 253 253 253 253 253 253
46039 -253 253 253 253 253 253 253 253 253 253 253 253
46040 -253 253 253 253 253 253 250 250 250 238 238 238
46041 -253 253 253 253 253 253 253 253 253 253 253 253
46042 -253 253 253 253 253 253 253 253 253 253 253 253
46043 -253 253 253 253 253 253 253 253 253 253 253 253
46044 -253 253 253 253 253 253 253 253 253 253 253 253
46045 -253 253 253 253 253 253 94 94 94 6 6 6
46046 - 2 2 6 2 2 6 10 10 10 34 34 34
46047 - 2 2 6 2 2 6 2 2 6 2 2 6
46048 - 74 74 74 58 58 58 22 22 22 6 6 6
46049 - 0 0 0 0 0 0 0 0 0 0 0 0
46050 - 0 0 0 0 0 0 0 0 0 0 0 0
46051 - 0 0 0 0 0 0 0 0 0 0 0 0
46052 - 0 0 0 0 0 0 0 0 0 0 0 0
46053 - 0 0 0 0 0 0 0 0 0 0 0 0
46054 - 0 0 0 0 0 0 0 0 0 0 0 0
46055 - 0 0 0 0 0 0 0 0 0 0 0 0
46056 - 0 0 0 10 10 10 26 26 26 66 66 66
46057 - 82 82 82 2 2 6 38 38 38 6 6 6
46058 - 14 14 14 210 210 210 253 253 253 253 253 253
46059 -253 253 253 253 253 253 253 253 253 253 253 253
46060 -253 253 253 253 253 253 246 246 246 242 242 242
46061 -253 253 253 253 253 253 253 253 253 253 253 253
46062 -253 253 253 253 253 253 253 253 253 253 253 253
46063 -253 253 253 253 253 253 253 253 253 253 253 253
46064 -253 253 253 253 253 253 253 253 253 253 253 253
46065 -253 253 253 253 253 253 144 144 144 2 2 6
46066 - 2 2 6 2 2 6 2 2 6 46 46 46
46067 - 2 2 6 2 2 6 2 2 6 2 2 6
46068 - 42 42 42 74 74 74 30 30 30 10 10 10
46069 - 0 0 0 0 0 0 0 0 0 0 0 0
46070 - 0 0 0 0 0 0 0 0 0 0 0 0
46071 - 0 0 0 0 0 0 0 0 0 0 0 0
46072 - 0 0 0 0 0 0 0 0 0 0 0 0
46073 - 0 0 0 0 0 0 0 0 0 0 0 0
46074 - 0 0 0 0 0 0 0 0 0 0 0 0
46075 - 0 0 0 0 0 0 0 0 0 0 0 0
46076 - 6 6 6 14 14 14 42 42 42 90 90 90
46077 - 26 26 26 6 6 6 42 42 42 2 2 6
46078 - 74 74 74 250 250 250 253 253 253 253 253 253
46079 -253 253 253 253 253 253 253 253 253 253 253 253
46080 -253 253 253 253 253 253 242 242 242 242 242 242
46081 -253 253 253 253 253 253 253 253 253 253 253 253
46082 -253 253 253 253 253 253 253 253 253 253 253 253
46083 -253 253 253 253 253 253 253 253 253 253 253 253
46084 -253 253 253 253 253 253 253 253 253 253 253 253
46085 -253 253 253 253 253 253 182 182 182 2 2 6
46086 - 2 2 6 2 2 6 2 2 6 46 46 46
46087 - 2 2 6 2 2 6 2 2 6 2 2 6
46088 - 10 10 10 86 86 86 38 38 38 10 10 10
46089 - 0 0 0 0 0 0 0 0 0 0 0 0
46090 - 0 0 0 0 0 0 0 0 0 0 0 0
46091 - 0 0 0 0 0 0 0 0 0 0 0 0
46092 - 0 0 0 0 0 0 0 0 0 0 0 0
46093 - 0 0 0 0 0 0 0 0 0 0 0 0
46094 - 0 0 0 0 0 0 0 0 0 0 0 0
46095 - 0 0 0 0 0 0 0 0 0 0 0 0
46096 - 10 10 10 26 26 26 66 66 66 82 82 82
46097 - 2 2 6 22 22 22 18 18 18 2 2 6
46098 -149 149 149 253 253 253 253 253 253 253 253 253
46099 -253 253 253 253 253 253 253 253 253 253 253 253
46100 -253 253 253 253 253 253 234 234 234 242 242 242
46101 -253 253 253 253 253 253 253 253 253 253 253 253
46102 -253 253 253 253 253 253 253 253 253 253 253 253
46103 -253 253 253 253 253 253 253 253 253 253 253 253
46104 -253 253 253 253 253 253 253 253 253 253 253 253
46105 -253 253 253 253 253 253 206 206 206 2 2 6
46106 - 2 2 6 2 2 6 2 2 6 38 38 38
46107 - 2 2 6 2 2 6 2 2 6 2 2 6
46108 - 6 6 6 86 86 86 46 46 46 14 14 14
46109 - 0 0 0 0 0 0 0 0 0 0 0 0
46110 - 0 0 0 0 0 0 0 0 0 0 0 0
46111 - 0 0 0 0 0 0 0 0 0 0 0 0
46112 - 0 0 0 0 0 0 0 0 0 0 0 0
46113 - 0 0 0 0 0 0 0 0 0 0 0 0
46114 - 0 0 0 0 0 0 0 0 0 0 0 0
46115 - 0 0 0 0 0 0 0 0 0 6 6 6
46116 - 18 18 18 46 46 46 86 86 86 18 18 18
46117 - 2 2 6 34 34 34 10 10 10 6 6 6
46118 -210 210 210 253 253 253 253 253 253 253 253 253
46119 -253 253 253 253 253 253 253 253 253 253 253 253
46120 -253 253 253 253 253 253 234 234 234 242 242 242
46121 -253 253 253 253 253 253 253 253 253 253 253 253
46122 -253 253 253 253 253 253 253 253 253 253 253 253
46123 -253 253 253 253 253 253 253 253 253 253 253 253
46124 -253 253 253 253 253 253 253 253 253 253 253 253
46125 -253 253 253 253 253 253 221 221 221 6 6 6
46126 - 2 2 6 2 2 6 6 6 6 30 30 30
46127 - 2 2 6 2 2 6 2 2 6 2 2 6
46128 - 2 2 6 82 82 82 54 54 54 18 18 18
46129 - 6 6 6 0 0 0 0 0 0 0 0 0
46130 - 0 0 0 0 0 0 0 0 0 0 0 0
46131 - 0 0 0 0 0 0 0 0 0 0 0 0
46132 - 0 0 0 0 0 0 0 0 0 0 0 0
46133 - 0 0 0 0 0 0 0 0 0 0 0 0
46134 - 0 0 0 0 0 0 0 0 0 0 0 0
46135 - 0 0 0 0 0 0 0 0 0 10 10 10
46136 - 26 26 26 66 66 66 62 62 62 2 2 6
46137 - 2 2 6 38 38 38 10 10 10 26 26 26
46138 -238 238 238 253 253 253 253 253 253 253 253 253
46139 -253 253 253 253 253 253 253 253 253 253 253 253
46140 -253 253 253 253 253 253 231 231 231 238 238 238
46141 -253 253 253 253 253 253 253 253 253 253 253 253
46142 -253 253 253 253 253 253 253 253 253 253 253 253
46143 -253 253 253 253 253 253 253 253 253 253 253 253
46144 -253 253 253 253 253 253 253 253 253 253 253 253
46145 -253 253 253 253 253 253 231 231 231 6 6 6
46146 - 2 2 6 2 2 6 10 10 10 30 30 30
46147 - 2 2 6 2 2 6 2 2 6 2 2 6
46148 - 2 2 6 66 66 66 58 58 58 22 22 22
46149 - 6 6 6 0 0 0 0 0 0 0 0 0
46150 - 0 0 0 0 0 0 0 0 0 0 0 0
46151 - 0 0 0 0 0 0 0 0 0 0 0 0
46152 - 0 0 0 0 0 0 0 0 0 0 0 0
46153 - 0 0 0 0 0 0 0 0 0 0 0 0
46154 - 0 0 0 0 0 0 0 0 0 0 0 0
46155 - 0 0 0 0 0 0 0 0 0 10 10 10
46156 - 38 38 38 78 78 78 6 6 6 2 2 6
46157 - 2 2 6 46 46 46 14 14 14 42 42 42
46158 -246 246 246 253 253 253 253 253 253 253 253 253
46159 -253 253 253 253 253 253 253 253 253 253 253 253
46160 -253 253 253 253 253 253 231 231 231 242 242 242
46161 -253 253 253 253 253 253 253 253 253 253 253 253
46162 -253 253 253 253 253 253 253 253 253 253 253 253
46163 -253 253 253 253 253 253 253 253 253 253 253 253
46164 -253 253 253 253 253 253 253 253 253 253 253 253
46165 -253 253 253 253 253 253 234 234 234 10 10 10
46166 - 2 2 6 2 2 6 22 22 22 14 14 14
46167 - 2 2 6 2 2 6 2 2 6 2 2 6
46168 - 2 2 6 66 66 66 62 62 62 22 22 22
46169 - 6 6 6 0 0 0 0 0 0 0 0 0
46170 - 0 0 0 0 0 0 0 0 0 0 0 0
46171 - 0 0 0 0 0 0 0 0 0 0 0 0
46172 - 0 0 0 0 0 0 0 0 0 0 0 0
46173 - 0 0 0 0 0 0 0 0 0 0 0 0
46174 - 0 0 0 0 0 0 0 0 0 0 0 0
46175 - 0 0 0 0 0 0 6 6 6 18 18 18
46176 - 50 50 50 74 74 74 2 2 6 2 2 6
46177 - 14 14 14 70 70 70 34 34 34 62 62 62
46178 -250 250 250 253 253 253 253 253 253 253 253 253
46179 -253 253 253 253 253 253 253 253 253 253 253 253
46180 -253 253 253 253 253 253 231 231 231 246 246 246
46181 -253 253 253 253 253 253 253 253 253 253 253 253
46182 -253 253 253 253 253 253 253 253 253 253 253 253
46183 -253 253 253 253 253 253 253 253 253 253 253 253
46184 -253 253 253 253 253 253 253 253 253 253 253 253
46185 -253 253 253 253 253 253 234 234 234 14 14 14
46186 - 2 2 6 2 2 6 30 30 30 2 2 6
46187 - 2 2 6 2 2 6 2 2 6 2 2 6
46188 - 2 2 6 66 66 66 62 62 62 22 22 22
46189 - 6 6 6 0 0 0 0 0 0 0 0 0
46190 - 0 0 0 0 0 0 0 0 0 0 0 0
46191 - 0 0 0 0 0 0 0 0 0 0 0 0
46192 - 0 0 0 0 0 0 0 0 0 0 0 0
46193 - 0 0 0 0 0 0 0 0 0 0 0 0
46194 - 0 0 0 0 0 0 0 0 0 0 0 0
46195 - 0 0 0 0 0 0 6 6 6 18 18 18
46196 - 54 54 54 62 62 62 2 2 6 2 2 6
46197 - 2 2 6 30 30 30 46 46 46 70 70 70
46198 -250 250 250 253 253 253 253 253 253 253 253 253
46199 -253 253 253 253 253 253 253 253 253 253 253 253
46200 -253 253 253 253 253 253 231 231 231 246 246 246
46201 -253 253 253 253 253 253 253 253 253 253 253 253
46202 -253 253 253 253 253 253 253 253 253 253 253 253
46203 -253 253 253 253 253 253 253 253 253 253 253 253
46204 -253 253 253 253 253 253 253 253 253 253 253 253
46205 -253 253 253 253 253 253 226 226 226 10 10 10
46206 - 2 2 6 6 6 6 30 30 30 2 2 6
46207 - 2 2 6 2 2 6 2 2 6 2 2 6
46208 - 2 2 6 66 66 66 58 58 58 22 22 22
46209 - 6 6 6 0 0 0 0 0 0 0 0 0
46210 - 0 0 0 0 0 0 0 0 0 0 0 0
46211 - 0 0 0 0 0 0 0 0 0 0 0 0
46212 - 0 0 0 0 0 0 0 0 0 0 0 0
46213 - 0 0 0 0 0 0 0 0 0 0 0 0
46214 - 0 0 0 0 0 0 0 0 0 0 0 0
46215 - 0 0 0 0 0 0 6 6 6 22 22 22
46216 - 58 58 58 62 62 62 2 2 6 2 2 6
46217 - 2 2 6 2 2 6 30 30 30 78 78 78
46218 -250 250 250 253 253 253 253 253 253 253 253 253
46219 -253 253 253 253 253 253 253 253 253 253 253 253
46220 -253 253 253 253 253 253 231 231 231 246 246 246
46221 -253 253 253 253 253 253 253 253 253 253 253 253
46222 -253 253 253 253 253 253 253 253 253 253 253 253
46223 -253 253 253 253 253 253 253 253 253 253 253 253
46224 -253 253 253 253 253 253 253 253 253 253 253 253
46225 -253 253 253 253 253 253 206 206 206 2 2 6
46226 - 22 22 22 34 34 34 18 14 6 22 22 22
46227 - 26 26 26 18 18 18 6 6 6 2 2 6
46228 - 2 2 6 82 82 82 54 54 54 18 18 18
46229 - 6 6 6 0 0 0 0 0 0 0 0 0
46230 - 0 0 0 0 0 0 0 0 0 0 0 0
46231 - 0 0 0 0 0 0 0 0 0 0 0 0
46232 - 0 0 0 0 0 0 0 0 0 0 0 0
46233 - 0 0 0 0 0 0 0 0 0 0 0 0
46234 - 0 0 0 0 0 0 0 0 0 0 0 0
46235 - 0 0 0 0 0 0 6 6 6 26 26 26
46236 - 62 62 62 106 106 106 74 54 14 185 133 11
46237 -210 162 10 121 92 8 6 6 6 62 62 62
46238 -238 238 238 253 253 253 253 253 253 253 253 253
46239 -253 253 253 253 253 253 253 253 253 253 253 253
46240 -253 253 253 253 253 253 231 231 231 246 246 246
46241 -253 253 253 253 253 253 253 253 253 253 253 253
46242 -253 253 253 253 253 253 253 253 253 253 253 253
46243 -253 253 253 253 253 253 253 253 253 253 253 253
46244 -253 253 253 253 253 253 253 253 253 253 253 253
46245 -253 253 253 253 253 253 158 158 158 18 18 18
46246 - 14 14 14 2 2 6 2 2 6 2 2 6
46247 - 6 6 6 18 18 18 66 66 66 38 38 38
46248 - 6 6 6 94 94 94 50 50 50 18 18 18
46249 - 6 6 6 0 0 0 0 0 0 0 0 0
46250 - 0 0 0 0 0 0 0 0 0 0 0 0
46251 - 0 0 0 0 0 0 0 0 0 0 0 0
46252 - 0 0 0 0 0 0 0 0 0 0 0 0
46253 - 0 0 0 0 0 0 0 0 0 0 0 0
46254 - 0 0 0 0 0 0 0 0 0 6 6 6
46255 - 10 10 10 10 10 10 18 18 18 38 38 38
46256 - 78 78 78 142 134 106 216 158 10 242 186 14
46257 -246 190 14 246 190 14 156 118 10 10 10 10
46258 - 90 90 90 238 238 238 253 253 253 253 253 253
46259 -253 253 253 253 253 253 253 253 253 253 253 253
46260 -253 253 253 253 253 253 231 231 231 250 250 250
46261 -253 253 253 253 253 253 253 253 253 253 253 253
46262 -253 253 253 253 253 253 253 253 253 253 253 253
46263 -253 253 253 253 253 253 253 253 253 253 253 253
46264 -253 253 253 253 253 253 253 253 253 246 230 190
46265 -238 204 91 238 204 91 181 142 44 37 26 9
46266 - 2 2 6 2 2 6 2 2 6 2 2 6
46267 - 2 2 6 2 2 6 38 38 38 46 46 46
46268 - 26 26 26 106 106 106 54 54 54 18 18 18
46269 - 6 6 6 0 0 0 0 0 0 0 0 0
46270 - 0 0 0 0 0 0 0 0 0 0 0 0
46271 - 0 0 0 0 0 0 0 0 0 0 0 0
46272 - 0 0 0 0 0 0 0 0 0 0 0 0
46273 - 0 0 0 0 0 0 0 0 0 0 0 0
46274 - 0 0 0 6 6 6 14 14 14 22 22 22
46275 - 30 30 30 38 38 38 50 50 50 70 70 70
46276 -106 106 106 190 142 34 226 170 11 242 186 14
46277 -246 190 14 246 190 14 246 190 14 154 114 10
46278 - 6 6 6 74 74 74 226 226 226 253 253 253
46279 -253 253 253 253 253 253 253 253 253 253 253 253
46280 -253 253 253 253 253 253 231 231 231 250 250 250
46281 -253 253 253 253 253 253 253 253 253 253 253 253
46282 -253 253 253 253 253 253 253 253 253 253 253 253
46283 -253 253 253 253 253 253 253 253 253 253 253 253
46284 -253 253 253 253 253 253 253 253 253 228 184 62
46285 -241 196 14 241 208 19 232 195 16 38 30 10
46286 - 2 2 6 2 2 6 2 2 6 2 2 6
46287 - 2 2 6 6 6 6 30 30 30 26 26 26
46288 -203 166 17 154 142 90 66 66 66 26 26 26
46289 - 6 6 6 0 0 0 0 0 0 0 0 0
46290 - 0 0 0 0 0 0 0 0 0 0 0 0
46291 - 0 0 0 0 0 0 0 0 0 0 0 0
46292 - 0 0 0 0 0 0 0 0 0 0 0 0
46293 - 0 0 0 0 0 0 0 0 0 0 0 0
46294 - 6 6 6 18 18 18 38 38 38 58 58 58
46295 - 78 78 78 86 86 86 101 101 101 123 123 123
46296 -175 146 61 210 150 10 234 174 13 246 186 14
46297 -246 190 14 246 190 14 246 190 14 238 190 10
46298 -102 78 10 2 2 6 46 46 46 198 198 198
46299 -253 253 253 253 253 253 253 253 253 253 253 253
46300 -253 253 253 253 253 253 234 234 234 242 242 242
46301 -253 253 253 253 253 253 253 253 253 253 253 253
46302 -253 253 253 253 253 253 253 253 253 253 253 253
46303 -253 253 253 253 253 253 253 253 253 253 253 253
46304 -253 253 253 253 253 253 253 253 253 224 178 62
46305 -242 186 14 241 196 14 210 166 10 22 18 6
46306 - 2 2 6 2 2 6 2 2 6 2 2 6
46307 - 2 2 6 2 2 6 6 6 6 121 92 8
46308 -238 202 15 232 195 16 82 82 82 34 34 34
46309 - 10 10 10 0 0 0 0 0 0 0 0 0
46310 - 0 0 0 0 0 0 0 0 0 0 0 0
46311 - 0 0 0 0 0 0 0 0 0 0 0 0
46312 - 0 0 0 0 0 0 0 0 0 0 0 0
46313 - 0 0 0 0 0 0 0 0 0 0 0 0
46314 - 14 14 14 38 38 38 70 70 70 154 122 46
46315 -190 142 34 200 144 11 197 138 11 197 138 11
46316 -213 154 11 226 170 11 242 186 14 246 190 14
46317 -246 190 14 246 190 14 246 190 14 246 190 14
46318 -225 175 15 46 32 6 2 2 6 22 22 22
46319 -158 158 158 250 250 250 253 253 253 253 253 253
46320 -253 253 253 253 253 253 253 253 253 253 253 253
46321 -253 253 253 253 253 253 253 253 253 253 253 253
46322 -253 253 253 253 253 253 253 253 253 253 253 253
46323 -253 253 253 253 253 253 253 253 253 253 253 253
46324 -253 253 253 250 250 250 242 242 242 224 178 62
46325 -239 182 13 236 186 11 213 154 11 46 32 6
46326 - 2 2 6 2 2 6 2 2 6 2 2 6
46327 - 2 2 6 2 2 6 61 42 6 225 175 15
46328 -238 190 10 236 186 11 112 100 78 42 42 42
46329 - 14 14 14 0 0 0 0 0 0 0 0 0
46330 - 0 0 0 0 0 0 0 0 0 0 0 0
46331 - 0 0 0 0 0 0 0 0 0 0 0 0
46332 - 0 0 0 0 0 0 0 0 0 0 0 0
46333 - 0 0 0 0 0 0 0 0 0 6 6 6
46334 - 22 22 22 54 54 54 154 122 46 213 154 11
46335 -226 170 11 230 174 11 226 170 11 226 170 11
46336 -236 178 12 242 186 14 246 190 14 246 190 14
46337 -246 190 14 246 190 14 246 190 14 246 190 14
46338 -241 196 14 184 144 12 10 10 10 2 2 6
46339 - 6 6 6 116 116 116 242 242 242 253 253 253
46340 -253 253 253 253 253 253 253 253 253 253 253 253
46341 -253 253 253 253 253 253 253 253 253 253 253 253
46342 -253 253 253 253 253 253 253 253 253 253 253 253
46343 -253 253 253 253 253 253 253 253 253 253 253 253
46344 -253 253 253 231 231 231 198 198 198 214 170 54
46345 -236 178 12 236 178 12 210 150 10 137 92 6
46346 - 18 14 6 2 2 6 2 2 6 2 2 6
46347 - 6 6 6 70 47 6 200 144 11 236 178 12
46348 -239 182 13 239 182 13 124 112 88 58 58 58
46349 - 22 22 22 6 6 6 0 0 0 0 0 0
46350 - 0 0 0 0 0 0 0 0 0 0 0 0
46351 - 0 0 0 0 0 0 0 0 0 0 0 0
46352 - 0 0 0 0 0 0 0 0 0 0 0 0
46353 - 0 0 0 0 0 0 0 0 0 10 10 10
46354 - 30 30 30 70 70 70 180 133 36 226 170 11
46355 -239 182 13 242 186 14 242 186 14 246 186 14
46356 -246 190 14 246 190 14 246 190 14 246 190 14
46357 -246 190 14 246 190 14 246 190 14 246 190 14
46358 -246 190 14 232 195 16 98 70 6 2 2 6
46359 - 2 2 6 2 2 6 66 66 66 221 221 221
46360 -253 253 253 253 253 253 253 253 253 253 253 253
46361 -253 253 253 253 253 253 253 253 253 253 253 253
46362 -253 253 253 253 253 253 253 253 253 253 253 253
46363 -253 253 253 253 253 253 253 253 253 253 253 253
46364 -253 253 253 206 206 206 198 198 198 214 166 58
46365 -230 174 11 230 174 11 216 158 10 192 133 9
46366 -163 110 8 116 81 8 102 78 10 116 81 8
46367 -167 114 7 197 138 11 226 170 11 239 182 13
46368 -242 186 14 242 186 14 162 146 94 78 78 78
46369 - 34 34 34 14 14 14 6 6 6 0 0 0
46370 - 0 0 0 0 0 0 0 0 0 0 0 0
46371 - 0 0 0 0 0 0 0 0 0 0 0 0
46372 - 0 0 0 0 0 0 0 0 0 0 0 0
46373 - 0 0 0 0 0 0 0 0 0 6 6 6
46374 - 30 30 30 78 78 78 190 142 34 226 170 11
46375 -239 182 13 246 190 14 246 190 14 246 190 14
46376 -246 190 14 246 190 14 246 190 14 246 190 14
46377 -246 190 14 246 190 14 246 190 14 246 190 14
46378 -246 190 14 241 196 14 203 166 17 22 18 6
46379 - 2 2 6 2 2 6 2 2 6 38 38 38
46380 -218 218 218 253 253 253 253 253 253 253 253 253
46381 -253 253 253 253 253 253 253 253 253 253 253 253
46382 -253 253 253 253 253 253 253 253 253 253 253 253
46383 -253 253 253 253 253 253 253 253 253 253 253 253
46384 -250 250 250 206 206 206 198 198 198 202 162 69
46385 -226 170 11 236 178 12 224 166 10 210 150 10
46386 -200 144 11 197 138 11 192 133 9 197 138 11
46387 -210 150 10 226 170 11 242 186 14 246 190 14
46388 -246 190 14 246 186 14 225 175 15 124 112 88
46389 - 62 62 62 30 30 30 14 14 14 6 6 6
46390 - 0 0 0 0 0 0 0 0 0 0 0 0
46391 - 0 0 0 0 0 0 0 0 0 0 0 0
46392 - 0 0 0 0 0 0 0 0 0 0 0 0
46393 - 0 0 0 0 0 0 0 0 0 10 10 10
46394 - 30 30 30 78 78 78 174 135 50 224 166 10
46395 -239 182 13 246 190 14 246 190 14 246 190 14
46396 -246 190 14 246 190 14 246 190 14 246 190 14
46397 -246 190 14 246 190 14 246 190 14 246 190 14
46398 -246 190 14 246 190 14 241 196 14 139 102 15
46399 - 2 2 6 2 2 6 2 2 6 2 2 6
46400 - 78 78 78 250 250 250 253 253 253 253 253 253
46401 -253 253 253 253 253 253 253 253 253 253 253 253
46402 -253 253 253 253 253 253 253 253 253 253 253 253
46403 -253 253 253 253 253 253 253 253 253 253 253 253
46404 -250 250 250 214 214 214 198 198 198 190 150 46
46405 -219 162 10 236 178 12 234 174 13 224 166 10
46406 -216 158 10 213 154 11 213 154 11 216 158 10
46407 -226 170 11 239 182 13 246 190 14 246 190 14
46408 -246 190 14 246 190 14 242 186 14 206 162 42
46409 -101 101 101 58 58 58 30 30 30 14 14 14
46410 - 6 6 6 0 0 0 0 0 0 0 0 0
46411 - 0 0 0 0 0 0 0 0 0 0 0 0
46412 - 0 0 0 0 0 0 0 0 0 0 0 0
46413 - 0 0 0 0 0 0 0 0 0 10 10 10
46414 - 30 30 30 74 74 74 174 135 50 216 158 10
46415 -236 178 12 246 190 14 246 190 14 246 190 14
46416 -246 190 14 246 190 14 246 190 14 246 190 14
46417 -246 190 14 246 190 14 246 190 14 246 190 14
46418 -246 190 14 246 190 14 241 196 14 226 184 13
46419 - 61 42 6 2 2 6 2 2 6 2 2 6
46420 - 22 22 22 238 238 238 253 253 253 253 253 253
46421 -253 253 253 253 253 253 253 253 253 253 253 253
46422 -253 253 253 253 253 253 253 253 253 253 253 253
46423 -253 253 253 253 253 253 253 253 253 253 253 253
46424 -253 253 253 226 226 226 187 187 187 180 133 36
46425 -216 158 10 236 178 12 239 182 13 236 178 12
46426 -230 174 11 226 170 11 226 170 11 230 174 11
46427 -236 178 12 242 186 14 246 190 14 246 190 14
46428 -246 190 14 246 190 14 246 186 14 239 182 13
46429 -206 162 42 106 106 106 66 66 66 34 34 34
46430 - 14 14 14 6 6 6 0 0 0 0 0 0
46431 - 0 0 0 0 0 0 0 0 0 0 0 0
46432 - 0 0 0 0 0 0 0 0 0 0 0 0
46433 - 0 0 0 0 0 0 0 0 0 6 6 6
46434 - 26 26 26 70 70 70 163 133 67 213 154 11
46435 -236 178 12 246 190 14 246 190 14 246 190 14
46436 -246 190 14 246 190 14 246 190 14 246 190 14
46437 -246 190 14 246 190 14 246 190 14 246 190 14
46438 -246 190 14 246 190 14 246 190 14 241 196 14
46439 -190 146 13 18 14 6 2 2 6 2 2 6
46440 - 46 46 46 246 246 246 253 253 253 253 253 253
46441 -253 253 253 253 253 253 253 253 253 253 253 253
46442 -253 253 253 253 253 253 253 253 253 253 253 253
46443 -253 253 253 253 253 253 253 253 253 253 253 253
46444 -253 253 253 221 221 221 86 86 86 156 107 11
46445 -216 158 10 236 178 12 242 186 14 246 186 14
46446 -242 186 14 239 182 13 239 182 13 242 186 14
46447 -242 186 14 246 186 14 246 190 14 246 190 14
46448 -246 190 14 246 190 14 246 190 14 246 190 14
46449 -242 186 14 225 175 15 142 122 72 66 66 66
46450 - 30 30 30 10 10 10 0 0 0 0 0 0
46451 - 0 0 0 0 0 0 0 0 0 0 0 0
46452 - 0 0 0 0 0 0 0 0 0 0 0 0
46453 - 0 0 0 0 0 0 0 0 0 6 6 6
46454 - 26 26 26 70 70 70 163 133 67 210 150 10
46455 -236 178 12 246 190 14 246 190 14 246 190 14
46456 -246 190 14 246 190 14 246 190 14 246 190 14
46457 -246 190 14 246 190 14 246 190 14 246 190 14
46458 -246 190 14 246 190 14 246 190 14 246 190 14
46459 -232 195 16 121 92 8 34 34 34 106 106 106
46460 -221 221 221 253 253 253 253 253 253 253 253 253
46461 -253 253 253 253 253 253 253 253 253 253 253 253
46462 -253 253 253 253 253 253 253 253 253 253 253 253
46463 -253 253 253 253 253 253 253 253 253 253 253 253
46464 -242 242 242 82 82 82 18 14 6 163 110 8
46465 -216 158 10 236 178 12 242 186 14 246 190 14
46466 -246 190 14 246 190 14 246 190 14 246 190 14
46467 -246 190 14 246 190 14 246 190 14 246 190 14
46468 -246 190 14 246 190 14 246 190 14 246 190 14
46469 -246 190 14 246 190 14 242 186 14 163 133 67
46470 - 46 46 46 18 18 18 6 6 6 0 0 0
46471 - 0 0 0 0 0 0 0 0 0 0 0 0
46472 - 0 0 0 0 0 0 0 0 0 0 0 0
46473 - 0 0 0 0 0 0 0 0 0 10 10 10
46474 - 30 30 30 78 78 78 163 133 67 210 150 10
46475 -236 178 12 246 186 14 246 190 14 246 190 14
46476 -246 190 14 246 190 14 246 190 14 246 190 14
46477 -246 190 14 246 190 14 246 190 14 246 190 14
46478 -246 190 14 246 190 14 246 190 14 246 190 14
46479 -241 196 14 215 174 15 190 178 144 253 253 253
46480 -253 253 253 253 253 253 253 253 253 253 253 253
46481 -253 253 253 253 253 253 253 253 253 253 253 253
46482 -253 253 253 253 253 253 253 253 253 253 253 253
46483 -253 253 253 253 253 253 253 253 253 218 218 218
46484 - 58 58 58 2 2 6 22 18 6 167 114 7
46485 -216 158 10 236 178 12 246 186 14 246 190 14
46486 -246 190 14 246 190 14 246 190 14 246 190 14
46487 -246 190 14 246 190 14 246 190 14 246 190 14
46488 -246 190 14 246 190 14 246 190 14 246 190 14
46489 -246 190 14 246 186 14 242 186 14 190 150 46
46490 - 54 54 54 22 22 22 6 6 6 0 0 0
46491 - 0 0 0 0 0 0 0 0 0 0 0 0
46492 - 0 0 0 0 0 0 0 0 0 0 0 0
46493 - 0 0 0 0 0 0 0 0 0 14 14 14
46494 - 38 38 38 86 86 86 180 133 36 213 154 11
46495 -236 178 12 246 186 14 246 190 14 246 190 14
46496 -246 190 14 246 190 14 246 190 14 246 190 14
46497 -246 190 14 246 190 14 246 190 14 246 190 14
46498 -246 190 14 246 190 14 246 190 14 246 190 14
46499 -246 190 14 232 195 16 190 146 13 214 214 214
46500 -253 253 253 253 253 253 253 253 253 253 253 253
46501 -253 253 253 253 253 253 253 253 253 253 253 253
46502 -253 253 253 253 253 253 253 253 253 253 253 253
46503 -253 253 253 250 250 250 170 170 170 26 26 26
46504 - 2 2 6 2 2 6 37 26 9 163 110 8
46505 -219 162 10 239 182 13 246 186 14 246 190 14
46506 -246 190 14 246 190 14 246 190 14 246 190 14
46507 -246 190 14 246 190 14 246 190 14 246 190 14
46508 -246 190 14 246 190 14 246 190 14 246 190 14
46509 -246 186 14 236 178 12 224 166 10 142 122 72
46510 - 46 46 46 18 18 18 6 6 6 0 0 0
46511 - 0 0 0 0 0 0 0 0 0 0 0 0
46512 - 0 0 0 0 0 0 0 0 0 0 0 0
46513 - 0 0 0 0 0 0 6 6 6 18 18 18
46514 - 50 50 50 109 106 95 192 133 9 224 166 10
46515 -242 186 14 246 190 14 246 190 14 246 190 14
46516 -246 190 14 246 190 14 246 190 14 246 190 14
46517 -246 190 14 246 190 14 246 190 14 246 190 14
46518 -246 190 14 246 190 14 246 190 14 246 190 14
46519 -242 186 14 226 184 13 210 162 10 142 110 46
46520 -226 226 226 253 253 253 253 253 253 253 253 253
46521 -253 253 253 253 253 253 253 253 253 253 253 253
46522 -253 253 253 253 253 253 253 253 253 253 253 253
46523 -198 198 198 66 66 66 2 2 6 2 2 6
46524 - 2 2 6 2 2 6 50 34 6 156 107 11
46525 -219 162 10 239 182 13 246 186 14 246 190 14
46526 -246 190 14 246 190 14 246 190 14 246 190 14
46527 -246 190 14 246 190 14 246 190 14 246 190 14
46528 -246 190 14 246 190 14 246 190 14 242 186 14
46529 -234 174 13 213 154 11 154 122 46 66 66 66
46530 - 30 30 30 10 10 10 0 0 0 0 0 0
46531 - 0 0 0 0 0 0 0 0 0 0 0 0
46532 - 0 0 0 0 0 0 0 0 0 0 0 0
46533 - 0 0 0 0 0 0 6 6 6 22 22 22
46534 - 58 58 58 154 121 60 206 145 10 234 174 13
46535 -242 186 14 246 186 14 246 190 14 246 190 14
46536 -246 190 14 246 190 14 246 190 14 246 190 14
46537 -246 190 14 246 190 14 246 190 14 246 190 14
46538 -246 190 14 246 190 14 246 190 14 246 190 14
46539 -246 186 14 236 178 12 210 162 10 163 110 8
46540 - 61 42 6 138 138 138 218 218 218 250 250 250
46541 -253 253 253 253 253 253 253 253 253 250 250 250
46542 -242 242 242 210 210 210 144 144 144 66 66 66
46543 - 6 6 6 2 2 6 2 2 6 2 2 6
46544 - 2 2 6 2 2 6 61 42 6 163 110 8
46545 -216 158 10 236 178 12 246 190 14 246 190 14
46546 -246 190 14 246 190 14 246 190 14 246 190 14
46547 -246 190 14 246 190 14 246 190 14 246 190 14
46548 -246 190 14 239 182 13 230 174 11 216 158 10
46549 -190 142 34 124 112 88 70 70 70 38 38 38
46550 - 18 18 18 6 6 6 0 0 0 0 0 0
46551 - 0 0 0 0 0 0 0 0 0 0 0 0
46552 - 0 0 0 0 0 0 0 0 0 0 0 0
46553 - 0 0 0 0 0 0 6 6 6 22 22 22
46554 - 62 62 62 168 124 44 206 145 10 224 166 10
46555 -236 178 12 239 182 13 242 186 14 242 186 14
46556 -246 186 14 246 190 14 246 190 14 246 190 14
46557 -246 190 14 246 190 14 246 190 14 246 190 14
46558 -246 190 14 246 190 14 246 190 14 246 190 14
46559 -246 190 14 236 178 12 216 158 10 175 118 6
46560 - 80 54 7 2 2 6 6 6 6 30 30 30
46561 - 54 54 54 62 62 62 50 50 50 38 38 38
46562 - 14 14 14 2 2 6 2 2 6 2 2 6
46563 - 2 2 6 2 2 6 2 2 6 2 2 6
46564 - 2 2 6 6 6 6 80 54 7 167 114 7
46565 -213 154 11 236 178 12 246 190 14 246 190 14
46566 -246 190 14 246 190 14 246 190 14 246 190 14
46567 -246 190 14 242 186 14 239 182 13 239 182 13
46568 -230 174 11 210 150 10 174 135 50 124 112 88
46569 - 82 82 82 54 54 54 34 34 34 18 18 18
46570 - 6 6 6 0 0 0 0 0 0 0 0 0
46571 - 0 0 0 0 0 0 0 0 0 0 0 0
46572 - 0 0 0 0 0 0 0 0 0 0 0 0
46573 - 0 0 0 0 0 0 6 6 6 18 18 18
46574 - 50 50 50 158 118 36 192 133 9 200 144 11
46575 -216 158 10 219 162 10 224 166 10 226 170 11
46576 -230 174 11 236 178 12 239 182 13 239 182 13
46577 -242 186 14 246 186 14 246 190 14 246 190 14
46578 -246 190 14 246 190 14 246 190 14 246 190 14
46579 -246 186 14 230 174 11 210 150 10 163 110 8
46580 -104 69 6 10 10 10 2 2 6 2 2 6
46581 - 2 2 6 2 2 6 2 2 6 2 2 6
46582 - 2 2 6 2 2 6 2 2 6 2 2 6
46583 - 2 2 6 2 2 6 2 2 6 2 2 6
46584 - 2 2 6 6 6 6 91 60 6 167 114 7
46585 -206 145 10 230 174 11 242 186 14 246 190 14
46586 -246 190 14 246 190 14 246 186 14 242 186 14
46587 -239 182 13 230 174 11 224 166 10 213 154 11
46588 -180 133 36 124 112 88 86 86 86 58 58 58
46589 - 38 38 38 22 22 22 10 10 10 6 6 6
46590 - 0 0 0 0 0 0 0 0 0 0 0 0
46591 - 0 0 0 0 0 0 0 0 0 0 0 0
46592 - 0 0 0 0 0 0 0 0 0 0 0 0
46593 - 0 0 0 0 0 0 0 0 0 14 14 14
46594 - 34 34 34 70 70 70 138 110 50 158 118 36
46595 -167 114 7 180 123 7 192 133 9 197 138 11
46596 -200 144 11 206 145 10 213 154 11 219 162 10
46597 -224 166 10 230 174 11 239 182 13 242 186 14
46598 -246 186 14 246 186 14 246 186 14 246 186 14
46599 -239 182 13 216 158 10 185 133 11 152 99 6
46600 -104 69 6 18 14 6 2 2 6 2 2 6
46601 - 2 2 6 2 2 6 2 2 6 2 2 6
46602 - 2 2 6 2 2 6 2 2 6 2 2 6
46603 - 2 2 6 2 2 6 2 2 6 2 2 6
46604 - 2 2 6 6 6 6 80 54 7 152 99 6
46605 -192 133 9 219 162 10 236 178 12 239 182 13
46606 -246 186 14 242 186 14 239 182 13 236 178 12
46607 -224 166 10 206 145 10 192 133 9 154 121 60
46608 - 94 94 94 62 62 62 42 42 42 22 22 22
46609 - 14 14 14 6 6 6 0 0 0 0 0 0
46610 - 0 0 0 0 0 0 0 0 0 0 0 0
46611 - 0 0 0 0 0 0 0 0 0 0 0 0
46612 - 0 0 0 0 0 0 0 0 0 0 0 0
46613 - 0 0 0 0 0 0 0 0 0 6 6 6
46614 - 18 18 18 34 34 34 58 58 58 78 78 78
46615 -101 98 89 124 112 88 142 110 46 156 107 11
46616 -163 110 8 167 114 7 175 118 6 180 123 7
46617 -185 133 11 197 138 11 210 150 10 219 162 10
46618 -226 170 11 236 178 12 236 178 12 234 174 13
46619 -219 162 10 197 138 11 163 110 8 130 83 6
46620 - 91 60 6 10 10 10 2 2 6 2 2 6
46621 - 18 18 18 38 38 38 38 38 38 38 38 38
46622 - 38 38 38 38 38 38 38 38 38 38 38 38
46623 - 38 38 38 38 38 38 26 26 26 2 2 6
46624 - 2 2 6 6 6 6 70 47 6 137 92 6
46625 -175 118 6 200 144 11 219 162 10 230 174 11
46626 -234 174 13 230 174 11 219 162 10 210 150 10
46627 -192 133 9 163 110 8 124 112 88 82 82 82
46628 - 50 50 50 30 30 30 14 14 14 6 6 6
46629 - 0 0 0 0 0 0 0 0 0 0 0 0
46630 - 0 0 0 0 0 0 0 0 0 0 0 0
46631 - 0 0 0 0 0 0 0 0 0 0 0 0
46632 - 0 0 0 0 0 0 0 0 0 0 0 0
46633 - 0 0 0 0 0 0 0 0 0 0 0 0
46634 - 6 6 6 14 14 14 22 22 22 34 34 34
46635 - 42 42 42 58 58 58 74 74 74 86 86 86
46636 -101 98 89 122 102 70 130 98 46 121 87 25
46637 -137 92 6 152 99 6 163 110 8 180 123 7
46638 -185 133 11 197 138 11 206 145 10 200 144 11
46639 -180 123 7 156 107 11 130 83 6 104 69 6
46640 - 50 34 6 54 54 54 110 110 110 101 98 89
46641 - 86 86 86 82 82 82 78 78 78 78 78 78
46642 - 78 78 78 78 78 78 78 78 78 78 78 78
46643 - 78 78 78 82 82 82 86 86 86 94 94 94
46644 -106 106 106 101 101 101 86 66 34 124 80 6
46645 -156 107 11 180 123 7 192 133 9 200 144 11
46646 -206 145 10 200 144 11 192 133 9 175 118 6
46647 -139 102 15 109 106 95 70 70 70 42 42 42
46648 - 22 22 22 10 10 10 0 0 0 0 0 0
46649 - 0 0 0 0 0 0 0 0 0 0 0 0
46650 - 0 0 0 0 0 0 0 0 0 0 0 0
46651 - 0 0 0 0 0 0 0 0 0 0 0 0
46652 - 0 0 0 0 0 0 0 0 0 0 0 0
46653 - 0 0 0 0 0 0 0 0 0 0 0 0
46654 - 0 0 0 0 0 0 6 6 6 10 10 10
46655 - 14 14 14 22 22 22 30 30 30 38 38 38
46656 - 50 50 50 62 62 62 74 74 74 90 90 90
46657 -101 98 89 112 100 78 121 87 25 124 80 6
46658 -137 92 6 152 99 6 152 99 6 152 99 6
46659 -138 86 6 124 80 6 98 70 6 86 66 30
46660 -101 98 89 82 82 82 58 58 58 46 46 46
46661 - 38 38 38 34 34 34 34 34 34 34 34 34
46662 - 34 34 34 34 34 34 34 34 34 34 34 34
46663 - 34 34 34 34 34 34 38 38 38 42 42 42
46664 - 54 54 54 82 82 82 94 86 76 91 60 6
46665 -134 86 6 156 107 11 167 114 7 175 118 6
46666 -175 118 6 167 114 7 152 99 6 121 87 25
46667 -101 98 89 62 62 62 34 34 34 18 18 18
46668 - 6 6 6 0 0 0 0 0 0 0 0 0
46669 - 0 0 0 0 0 0 0 0 0 0 0 0
46670 - 0 0 0 0 0 0 0 0 0 0 0 0
46671 - 0 0 0 0 0 0 0 0 0 0 0 0
46672 - 0 0 0 0 0 0 0 0 0 0 0 0
46673 - 0 0 0 0 0 0 0 0 0 0 0 0
46674 - 0 0 0 0 0 0 0 0 0 0 0 0
46675 - 0 0 0 6 6 6 6 6 6 10 10 10
46676 - 18 18 18 22 22 22 30 30 30 42 42 42
46677 - 50 50 50 66 66 66 86 86 86 101 98 89
46678 -106 86 58 98 70 6 104 69 6 104 69 6
46679 -104 69 6 91 60 6 82 62 34 90 90 90
46680 - 62 62 62 38 38 38 22 22 22 14 14 14
46681 - 10 10 10 10 10 10 10 10 10 10 10 10
46682 - 10 10 10 10 10 10 6 6 6 10 10 10
46683 - 10 10 10 10 10 10 10 10 10 14 14 14
46684 - 22 22 22 42 42 42 70 70 70 89 81 66
46685 - 80 54 7 104 69 6 124 80 6 137 92 6
46686 -134 86 6 116 81 8 100 82 52 86 86 86
46687 - 58 58 58 30 30 30 14 14 14 6 6 6
46688 - 0 0 0 0 0 0 0 0 0 0 0 0
46689 - 0 0 0 0 0 0 0 0 0 0 0 0
46690 - 0 0 0 0 0 0 0 0 0 0 0 0
46691 - 0 0 0 0 0 0 0 0 0 0 0 0
46692 - 0 0 0 0 0 0 0 0 0 0 0 0
46693 - 0 0 0 0 0 0 0 0 0 0 0 0
46694 - 0 0 0 0 0 0 0 0 0 0 0 0
46695 - 0 0 0 0 0 0 0 0 0 0 0 0
46696 - 0 0 0 6 6 6 10 10 10 14 14 14
46697 - 18 18 18 26 26 26 38 38 38 54 54 54
46698 - 70 70 70 86 86 86 94 86 76 89 81 66
46699 - 89 81 66 86 86 86 74 74 74 50 50 50
46700 - 30 30 30 14 14 14 6 6 6 0 0 0
46701 - 0 0 0 0 0 0 0 0 0 0 0 0
46702 - 0 0 0 0 0 0 0 0 0 0 0 0
46703 - 0 0 0 0 0 0 0 0 0 0 0 0
46704 - 6 6 6 18 18 18 34 34 34 58 58 58
46705 - 82 82 82 89 81 66 89 81 66 89 81 66
46706 - 94 86 66 94 86 76 74 74 74 50 50 50
46707 - 26 26 26 14 14 14 6 6 6 0 0 0
46708 - 0 0 0 0 0 0 0 0 0 0 0 0
46709 - 0 0 0 0 0 0 0 0 0 0 0 0
46710 - 0 0 0 0 0 0 0 0 0 0 0 0
46711 - 0 0 0 0 0 0 0 0 0 0 0 0
46712 - 0 0 0 0 0 0 0 0 0 0 0 0
46713 - 0 0 0 0 0 0 0 0 0 0 0 0
46714 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 6 6 6 6 6 6 14 14 14 18 18 18
46718 - 30 30 30 38 38 38 46 46 46 54 54 54
46719 - 50 50 50 42 42 42 30 30 30 18 18 18
46720 - 10 10 10 0 0 0 0 0 0 0 0 0
46721 - 0 0 0 0 0 0 0 0 0 0 0 0
46722 - 0 0 0 0 0 0 0 0 0 0 0 0
46723 - 0 0 0 0 0 0 0 0 0 0 0 0
46724 - 0 0 0 6 6 6 14 14 14 26 26 26
46725 - 38 38 38 50 50 50 58 58 58 58 58 58
46726 - 54 54 54 42 42 42 30 30 30 18 18 18
46727 - 10 10 10 0 0 0 0 0 0 0 0 0
46728 - 0 0 0 0 0 0 0 0 0 0 0 0
46729 - 0 0 0 0 0 0 0 0 0 0 0 0
46730 - 0 0 0 0 0 0 0 0 0 0 0 0
46731 - 0 0 0 0 0 0 0 0 0 0 0 0
46732 - 0 0 0 0 0 0 0 0 0 0 0 0
46733 - 0 0 0 0 0 0 0 0 0 0 0 0
46734 - 0 0 0 0 0 0 0 0 0 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 6 6 6
46738 - 6 6 6 10 10 10 14 14 14 18 18 18
46739 - 18 18 18 14 14 14 10 10 10 6 6 6
46740 - 0 0 0 0 0 0 0 0 0 0 0 0
46741 - 0 0 0 0 0 0 0 0 0 0 0 0
46742 - 0 0 0 0 0 0 0 0 0 0 0 0
46743 - 0 0 0 0 0 0 0 0 0 0 0 0
46744 - 0 0 0 0 0 0 0 0 0 6 6 6
46745 - 14 14 14 18 18 18 22 22 22 22 22 22
46746 - 18 18 18 14 14 14 10 10 10 6 6 6
46747 - 0 0 0 0 0 0 0 0 0 0 0 0
46748 - 0 0 0 0 0 0 0 0 0 0 0 0
46749 - 0 0 0 0 0 0 0 0 0 0 0 0
46750 - 0 0 0 0 0 0 0 0 0 0 0 0
46751 - 0 0 0 0 0 0 0 0 0 0 0 0
46752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46765 +4 4 4 4 4 4
46766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46779 +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 4 4 4 4 4 4 4 4 4 4 4 4
46793 +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 4 4 4 4 4 4 4 4 4 4 4 4
46807 +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 4 4 4 4 4 4 4 4 4 4 4 4
46821 +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 4 4 4 4 4 4 4 4 4 4 4 4
46835 +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 3 3 3 0 0 0 0 0 0
46841 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 1 1 1 0 0 0
46846 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46847 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46849 +4 4 4 4 4 4
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 2 2 2 0 0 0 3 4 3 26 28 28
46855 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46856 +5 5 5 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 3 3 3 0 0 0 1 1 1 6 6 6
46860 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46861 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46862 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46863 +4 4 4 4 4 4
46864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46868 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46869 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46870 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46873 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46874 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46875 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46876 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46877 +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 5 5 5 5 5 5 2 2 2 0 0 0
46882 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46883 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46884 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46886 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46887 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46888 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46889 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46890 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46891 +4 4 4 4 4 4
46892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46895 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46896 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46897 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46898 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46899 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46900 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46901 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46902 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46903 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46904 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46905 +4 4 4 4 4 4
46906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46909 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46910 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46911 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46912 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46913 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46914 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46915 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46916 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46917 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46918 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46919 +4 4 4 4 4 4
46920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46922 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46923 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46924 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46925 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46926 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46927 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46928 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46929 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46930 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46931 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46932 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46933 +4 4 4 4 4 4
46934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46936 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46937 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46938 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46939 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46940 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46941 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46942 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46943 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46944 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46945 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46946 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46947 +4 4 4 4 4 4
46948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46950 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46951 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46952 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46953 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46954 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46955 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46956 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46957 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46958 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46959 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46960 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46961 +4 4 4 4 4 4
46962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46964 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46965 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46966 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46967 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46968 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46969 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46970 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46971 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46972 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46973 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46974 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46975 +4 4 4 4 4 4
46976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46977 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46978 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46979 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46980 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46981 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46982 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46983 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46984 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46985 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46986 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46987 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46988 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46989 +4 4 4 4 4 4
46990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46991 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46992 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46993 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46994 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46995 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46996 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46997 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46998 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46999 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
47000 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
47001 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
47002 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
47003 +0 0 0 4 4 4
47004 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47005 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
47006 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
47007 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
47008 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
47009 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
47010 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
47011 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
47012 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
47013 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
47014 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
47015 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
47016 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
47017 +2 0 0 0 0 0
47018 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
47019 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
47020 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
47021 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
47022 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
47023 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
47024 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
47025 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
47026 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
47027 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
47028 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
47029 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
47030 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47031 +37 38 37 0 0 0
47032 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47033 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47034 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47035 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47036 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47037 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47038 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47039 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47040 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47041 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47042 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47043 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47044 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47045 +85 115 134 4 0 0
47046 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47047 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47048 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47049 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47050 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47051 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47052 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47053 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47054 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47055 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47056 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47057 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47058 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47059 +60 73 81 4 0 0
47060 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47061 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47062 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47063 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47064 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47065 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47066 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47067 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47068 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47069 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47070 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47071 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47072 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47073 +16 19 21 4 0 0
47074 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47075 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47076 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47077 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47078 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47079 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47080 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47081 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47082 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47083 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47084 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47085 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47086 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47087 +4 0 0 4 3 3
47088 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47089 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47090 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47091 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47092 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47093 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47094 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47095 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47096 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47097 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47098 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47099 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47100 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47101 +3 2 2 4 4 4
47102 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47103 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47104 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47105 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47106 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47107 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47108 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47109 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47110 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47111 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47112 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47113 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47114 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47115 +4 4 4 4 4 4
47116 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47117 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47118 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47119 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47120 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47121 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47122 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47123 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47124 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47125 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47126 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47127 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47128 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47129 +4 4 4 4 4 4
47130 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47131 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47132 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47133 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47134 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47135 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47136 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47137 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47138 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47139 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47140 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47141 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47142 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47143 +5 5 5 5 5 5
47144 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47145 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47146 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47147 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47148 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47149 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47150 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47151 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47152 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47153 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47154 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47155 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47156 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47157 +5 5 5 4 4 4
47158 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47159 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47160 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47161 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47162 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47163 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47164 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47165 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47166 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47167 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47168 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47169 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47170 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47171 +4 4 4 4 4 4
47172 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47173 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47174 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47175 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47176 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47177 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47178 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47179 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47180 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47181 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47182 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47183 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47184 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47185 +4 4 4 4 4 4
47186 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47187 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47188 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47189 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47190 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47191 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47192 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47193 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47194 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47195 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47196 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 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 4 4 4 4 4 4 4 4 4 4 4 4
47199 +4 4 4 4 4 4
47200 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47201 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47202 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47203 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47204 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47205 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47206 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47207 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47208 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47209 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47210 +6 6 6 4 0 0 4 0 0 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 4 4 4 4 4 4 4 4 4 4 4 4
47213 +4 4 4 4 4 4
47214 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47215 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47216 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47217 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47218 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47219 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47220 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47221 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47222 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47223 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47224 +4 0 0 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47227 +4 4 4 4 4 4
47228 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47229 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47230 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47231 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47232 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47233 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47234 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47235 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47236 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47237 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47238 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47240 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47241 +4 4 4 4 4 4
47242 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47243 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47244 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47245 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47246 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47247 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47248 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47249 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47250 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47251 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47252 +4 0 0 3 2 2 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47255 +4 4 4 4 4 4
47256 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47257 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47258 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47259 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47260 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47261 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47262 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47263 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47264 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47265 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47266 +4 0 0 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47269 +4 4 4 4 4 4
47270 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47271 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47272 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47273 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47274 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47275 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47276 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47277 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47278 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47279 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47280 +4 0 0 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47283 +4 4 4 4 4 4
47284 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47285 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47286 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47287 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47288 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47289 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47290 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47291 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47292 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47293 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47294 +4 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47297 +4 4 4 4 4 4
47298 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47299 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47300 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47301 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47302 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47303 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47304 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47305 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47306 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47307 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47308 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47311 +4 4 4 4 4 4
47312 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47313 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47314 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47315 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47316 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47317 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47318 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47319 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47320 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47321 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47322 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47325 +4 4 4 4 4 4
47326 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47327 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47328 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47329 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47330 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47331 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47332 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47333 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47334 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47335 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47336 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47339 +4 4 4 4 4 4
47340 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47341 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47342 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47343 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47344 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47345 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47346 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47347 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47348 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47349 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47350 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47353 +4 4 4 4 4 4
47354 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47355 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47356 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47357 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47358 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47359 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47360 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47361 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47362 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47363 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47364 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47367 +4 4 4 4 4 4
47368 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47369 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47370 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47371 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47372 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47373 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47374 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47375 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47376 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47377 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47378 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47381 +4 4 4 4 4 4
47382 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47383 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47384 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47385 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47386 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47387 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47388 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47389 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47390 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47391 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47392 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47395 +4 4 4 4 4 4
47396 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47397 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47398 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47399 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47400 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47401 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47402 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47403 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47404 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47405 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47406 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47409 +4 4 4 4 4 4
47410 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47411 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47412 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47413 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47414 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47415 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47416 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47417 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47418 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47419 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47420 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47423 +4 4 4 4 4 4
47424 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47425 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47426 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47427 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47428 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47429 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47430 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47431 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47432 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47433 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47434 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47437 +4 4 4 4 4 4
47438 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47439 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47440 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47441 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47442 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47443 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47444 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47445 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47446 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47447 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47448 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47451 +4 4 4 4 4 4
47452 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47453 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47454 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47455 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47456 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47457 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47458 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47459 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47460 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47461 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47462 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47465 +4 4 4 4 4 4
47466 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47467 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47468 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47469 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47470 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47471 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47472 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47473 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47474 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47475 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47476 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47479 +4 4 4 4 4 4
47480 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47481 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47482 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47483 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47484 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47485 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47486 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47487 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47488 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47489 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47490 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47493 +4 4 4 4 4 4
47494 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47495 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47496 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47497 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47498 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47499 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47500 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47501 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47502 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47503 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47504 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47507 +4 4 4 4 4 4
47508 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47509 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47510 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47511 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47512 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47513 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47514 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47515 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47516 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47517 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47518 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47521 +4 4 4 4 4 4
47522 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47523 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47524 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47525 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47526 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47527 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47528 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47529 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47530 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47531 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47532 +0 0 0 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 4 4 4 4 4 4 4 4 4 4 4 4
47535 +4 4 4 4 4 4
47536 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47537 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47538 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47539 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47540 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47541 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47542 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47543 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47544 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47545 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47546 +4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47549 +4 4 4 4 4 4
47550 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47551 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47552 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47553 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47554 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47555 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47556 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47557 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47558 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47559 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47560 +5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47563 +4 4 4 4 4 4
47564 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47565 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47566 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47567 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47568 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47569 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47570 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47571 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47572 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47573 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4
47577 +4 4 4 4 4 4
47578 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47579 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47580 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47581 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47582 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47583 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47584 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47585 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47586 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47587 +13 16 17 4 0 0 4 0 0 4 3 3 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 4 4 4 4 4 4 4 4 4 4 4 4
47591 +4 4 4 4 4 4
47592 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47593 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47594 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47595 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47596 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47597 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47598 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47599 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47600 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47601 +4 0 0 4 0 0 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47605 +4 4 4 4 4 4
47606 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47607 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47608 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47609 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47610 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47611 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47612 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47613 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47614 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47615 +4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47619 +4 4 4 4 4 4
47620 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47621 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47622 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47623 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47624 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47625 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47626 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47627 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47628 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
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 4 4 4 4 4 4 4 4 4 4 4 4
47633 +4 4 4 4 4 4
47634 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47635 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47636 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47637 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47638 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47639 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47640 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47641 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47642 +4 0 0 4 0 0 4 0 0 6 6 6 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 4 4 4 4 4 4 4 4 4 4 4 4
47647 +4 4 4 4 4 4
47648 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47649 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47650 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47651 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47652 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47653 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47654 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47655 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47656 +4 0 0 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 4 4 4 4 4 4 4 4 4 4 4 4
47661 +4 4 4 4 4 4
47662 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47663 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47664 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47665 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47666 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47667 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47668 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47669 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
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 4 4 4 4 4 4 4 4 4 4 4 4
47675 +4 4 4 4 4 4
47676 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47677 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47678 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47679 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47680 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47681 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47682 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47683 +6 6 6 4 0 0 4 0 0 4 3 3 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 4 4 4 4 4 4 4 4 4 4 4 4
47689 +4 4 4 4 4 4
47690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47691 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47692 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47693 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47694 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47695 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47696 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47697 +4 0 0 4 3 3 6 6 6 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 4 4 4 4 4 4 4 4 4 4 4 4
47703 +4 4 4 4 4 4
47704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47705 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47706 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47707 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47708 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47709 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47710 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47711 +6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47717 +4 4 4 4 4 4
47718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47719 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47720 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47721 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47722 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47723 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47724 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47725 +5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47731 +4 4 4 4 4 4
47732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47734 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47735 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47736 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47737 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47738 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47739 +4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47745 +4 4 4 4 4 4
47746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47749 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47750 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47751 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47752 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4
47759 +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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47763 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47764 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47765 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47766 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
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 4 4 4 4 4 4 4 4 4 4 4 4
47773 +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 4 4 4
47776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47777 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47778 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47779 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47780 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47787 +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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47791 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47792 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47793 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47794 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47801 +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 4 4 4 4 4 4 4 4 4 4 4 4
47805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47806 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47807 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47808 +6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47815 +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 4 4 4 4 4 4 4 4 4
47819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47820 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47821 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47822 +4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47829 +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 4 4 4
47833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47834 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47835 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47836 +5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47843 +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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47848 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47849 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4
47857 +4 4 4 4 4 4
47858 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47862 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47863 +5 5 5 4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47871 +4 4 4 4 4 4
47872 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47873 index fe92eed..106e085 100644
47874 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47875 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47876 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47877 struct mb862xxfb_par *par = info->par;
47878
47879 if (info->var.bits_per_pixel == 32) {
47880 - info->fbops->fb_fillrect = cfb_fillrect;
47881 - info->fbops->fb_copyarea = cfb_copyarea;
47882 - info->fbops->fb_imageblit = cfb_imageblit;
47883 + pax_open_kernel();
47884 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47885 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47886 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47887 + pax_close_kernel();
47888 } else {
47889 outreg(disp, GC_L0EM, 3);
47890 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47891 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47892 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47893 + pax_open_kernel();
47894 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47895 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47896 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47897 + pax_close_kernel();
47898 }
47899 outreg(draw, GDC_REG_DRAW_BASE, 0);
47900 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47901 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47902 index ff22871..b129bed 100644
47903 --- a/drivers/video/nvidia/nvidia.c
47904 +++ b/drivers/video/nvidia/nvidia.c
47905 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47906 info->fix.line_length = (info->var.xres_virtual *
47907 info->var.bits_per_pixel) >> 3;
47908 if (info->var.accel_flags) {
47909 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47910 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47911 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47912 - info->fbops->fb_sync = nvidiafb_sync;
47913 + pax_open_kernel();
47914 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47915 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47916 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47917 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47918 + pax_close_kernel();
47919 info->pixmap.scan_align = 4;
47920 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47921 info->flags |= FBINFO_READS_FAST;
47922 NVResetGraphics(info);
47923 } else {
47924 - info->fbops->fb_imageblit = cfb_imageblit;
47925 - info->fbops->fb_fillrect = cfb_fillrect;
47926 - info->fbops->fb_copyarea = cfb_copyarea;
47927 - info->fbops->fb_sync = NULL;
47928 + pax_open_kernel();
47929 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47930 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47931 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47932 + *(void **)&info->fbops->fb_sync = NULL;
47933 + pax_close_kernel();
47934 info->pixmap.scan_align = 1;
47935 info->flags |= FBINFO_HWACCEL_DISABLED;
47936 info->flags &= ~FBINFO_READS_FAST;
47937 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47938 info->pixmap.size = 8 * 1024;
47939 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47940
47941 - if (!hwcur)
47942 - info->fbops->fb_cursor = NULL;
47943 + if (!hwcur) {
47944 + pax_open_kernel();
47945 + *(void **)&info->fbops->fb_cursor = NULL;
47946 + pax_close_kernel();
47947 + }
47948
47949 info->var.accel_flags = (!noaccel);
47950
47951 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47952 index 76d9053..dec2bfd 100644
47953 --- a/drivers/video/s1d13xxxfb.c
47954 +++ b/drivers/video/s1d13xxxfb.c
47955 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47956
47957 switch(prod_id) {
47958 case S1D13506_PROD_ID: /* activate acceleration */
47959 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47960 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47961 + pax_open_kernel();
47962 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47963 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47964 + pax_close_kernel();
47965 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47966 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47967 break;
47968 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47969 index 97bd662..39fab85 100644
47970 --- a/drivers/video/smscufx.c
47971 +++ b/drivers/video/smscufx.c
47972 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47973 fb_deferred_io_cleanup(info);
47974 kfree(info->fbdefio);
47975 info->fbdefio = NULL;
47976 - info->fbops->fb_mmap = ufx_ops_mmap;
47977 + pax_open_kernel();
47978 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47979 + pax_close_kernel();
47980 }
47981
47982 pr_debug("released /dev/fb%d user=%d count=%d",
47983 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47984 index 86d449e..8e04dc5 100644
47985 --- a/drivers/video/udlfb.c
47986 +++ b/drivers/video/udlfb.c
47987 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47988 dlfb_urb_completion(urb);
47989
47990 error:
47991 - atomic_add(bytes_sent, &dev->bytes_sent);
47992 - atomic_add(bytes_identical, &dev->bytes_identical);
47993 - atomic_add(width*height*2, &dev->bytes_rendered);
47994 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47995 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47996 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47997 end_cycles = get_cycles();
47998 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47999 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48000 >> 10)), /* Kcycles */
48001 &dev->cpu_kcycles_used);
48002
48003 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
48004 dlfb_urb_completion(urb);
48005
48006 error:
48007 - atomic_add(bytes_sent, &dev->bytes_sent);
48008 - atomic_add(bytes_identical, &dev->bytes_identical);
48009 - atomic_add(bytes_rendered, &dev->bytes_rendered);
48010 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48011 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48012 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
48013 end_cycles = get_cycles();
48014 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48015 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48016 >> 10)), /* Kcycles */
48017 &dev->cpu_kcycles_used);
48018 }
48019 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
48020 fb_deferred_io_cleanup(info);
48021 kfree(info->fbdefio);
48022 info->fbdefio = NULL;
48023 - info->fbops->fb_mmap = dlfb_ops_mmap;
48024 + pax_open_kernel();
48025 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
48026 + pax_close_kernel();
48027 }
48028
48029 pr_warn("released /dev/fb%d user=%d count=%d\n",
48030 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48031 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48032 struct dlfb_data *dev = fb_info->par;
48033 return snprintf(buf, PAGE_SIZE, "%u\n",
48034 - atomic_read(&dev->bytes_rendered));
48035 + atomic_read_unchecked(&dev->bytes_rendered));
48036 }
48037
48038 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48039 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48040 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48041 struct dlfb_data *dev = fb_info->par;
48042 return snprintf(buf, PAGE_SIZE, "%u\n",
48043 - atomic_read(&dev->bytes_identical));
48044 + atomic_read_unchecked(&dev->bytes_identical));
48045 }
48046
48047 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48048 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48049 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48050 struct dlfb_data *dev = fb_info->par;
48051 return snprintf(buf, PAGE_SIZE, "%u\n",
48052 - atomic_read(&dev->bytes_sent));
48053 + atomic_read_unchecked(&dev->bytes_sent));
48054 }
48055
48056 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48057 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_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->cpu_kcycles_used));
48062 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48063 }
48064
48065 static ssize_t edid_show(
48066 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48067 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48068 struct dlfb_data *dev = fb_info->par;
48069
48070 - atomic_set(&dev->bytes_rendered, 0);
48071 - atomic_set(&dev->bytes_identical, 0);
48072 - atomic_set(&dev->bytes_sent, 0);
48073 - atomic_set(&dev->cpu_kcycles_used, 0);
48074 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48075 + atomic_set_unchecked(&dev->bytes_identical, 0);
48076 + atomic_set_unchecked(&dev->bytes_sent, 0);
48077 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48078
48079 return count;
48080 }
48081 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48082 index b75db01..ad2f34a 100644
48083 --- a/drivers/video/uvesafb.c
48084 +++ b/drivers/video/uvesafb.c
48085 @@ -19,6 +19,7 @@
48086 #include <linux/io.h>
48087 #include <linux/mutex.h>
48088 #include <linux/slab.h>
48089 +#include <linux/moduleloader.h>
48090 #include <video/edid.h>
48091 #include <video/uvesafb.h>
48092 #ifdef CONFIG_X86
48093 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48094 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48095 par->pmi_setpal = par->ypan = 0;
48096 } else {
48097 +
48098 +#ifdef CONFIG_PAX_KERNEXEC
48099 +#ifdef CONFIG_MODULES
48100 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48101 +#endif
48102 + if (!par->pmi_code) {
48103 + par->pmi_setpal = par->ypan = 0;
48104 + return 0;
48105 + }
48106 +#endif
48107 +
48108 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48109 + task->t.regs.edi);
48110 +
48111 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48112 + pax_open_kernel();
48113 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48114 + pax_close_kernel();
48115 +
48116 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48117 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48118 +#else
48119 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48120 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48121 +#endif
48122 +
48123 printk(KERN_INFO "uvesafb: protected mode interface info at "
48124 "%04x:%04x\n",
48125 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48126 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48127 par->ypan = ypan;
48128
48129 if (par->pmi_setpal || par->ypan) {
48130 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48131 if (__supported_pte_mask & _PAGE_NX) {
48132 par->pmi_setpal = par->ypan = 0;
48133 printk(KERN_WARNING "uvesafb: NX protection is actively."
48134 "We have better not to use the PMI.\n");
48135 - } else {
48136 + } else
48137 +#endif
48138 uvesafb_vbe_getpmi(task, par);
48139 - }
48140 }
48141 #else
48142 /* The protected mode interface is not available on non-x86. */
48143 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48144 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48145
48146 /* Disable blanking if the user requested so. */
48147 - if (!blank)
48148 - info->fbops->fb_blank = NULL;
48149 + if (!blank) {
48150 + pax_open_kernel();
48151 + *(void **)&info->fbops->fb_blank = NULL;
48152 + pax_close_kernel();
48153 + }
48154
48155 /*
48156 * Find out how much IO memory is required for the mode with
48157 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48158 info->flags = FBINFO_FLAG_DEFAULT |
48159 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48160
48161 - if (!par->ypan)
48162 - info->fbops->fb_pan_display = NULL;
48163 + if (!par->ypan) {
48164 + pax_open_kernel();
48165 + *(void **)&info->fbops->fb_pan_display = NULL;
48166 + pax_close_kernel();
48167 + }
48168 }
48169
48170 static void uvesafb_init_mtrr(struct fb_info *info)
48171 @@ -1836,6 +1866,11 @@ out:
48172 if (par->vbe_modes)
48173 kfree(par->vbe_modes);
48174
48175 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48176 + if (par->pmi_code)
48177 + module_free_exec(NULL, par->pmi_code);
48178 +#endif
48179 +
48180 framebuffer_release(info);
48181 return err;
48182 }
48183 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48184 kfree(par->vbe_state_orig);
48185 if (par->vbe_state_saved)
48186 kfree(par->vbe_state_saved);
48187 +
48188 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48189 + if (par->pmi_code)
48190 + module_free_exec(NULL, par->pmi_code);
48191 +#endif
48192 +
48193 }
48194
48195 framebuffer_release(info);
48196 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48197 index 501b340..d80aa17 100644
48198 --- a/drivers/video/vesafb.c
48199 +++ b/drivers/video/vesafb.c
48200 @@ -9,6 +9,7 @@
48201 */
48202
48203 #include <linux/module.h>
48204 +#include <linux/moduleloader.h>
48205 #include <linux/kernel.h>
48206 #include <linux/errno.h>
48207 #include <linux/string.h>
48208 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48209 static int vram_total __initdata; /* Set total amount of memory */
48210 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48211 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48212 -static void (*pmi_start)(void) __read_mostly;
48213 -static void (*pmi_pal) (void) __read_mostly;
48214 +static void (*pmi_start)(void) __read_only;
48215 +static void (*pmi_pal) (void) __read_only;
48216 static int depth __read_mostly;
48217 static int vga_compat __read_mostly;
48218 /* --------------------------------------------------------------------- */
48219 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48220 unsigned int size_vmode;
48221 unsigned int size_remap;
48222 unsigned int size_total;
48223 + void *pmi_code = NULL;
48224
48225 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48226 return -ENODEV;
48227 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48228 size_remap = size_total;
48229 vesafb_fix.smem_len = size_remap;
48230
48231 -#ifndef __i386__
48232 - screen_info.vesapm_seg = 0;
48233 -#endif
48234 -
48235 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48236 printk(KERN_WARNING
48237 "vesafb: cannot reserve video memory at 0x%lx\n",
48238 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48239 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48240 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48241
48242 +#ifdef __i386__
48243 +
48244 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48245 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48246 + if (!pmi_code)
48247 +#elif !defined(CONFIG_PAX_KERNEXEC)
48248 + if (0)
48249 +#endif
48250 +
48251 +#endif
48252 + screen_info.vesapm_seg = 0;
48253 +
48254 if (screen_info.vesapm_seg) {
48255 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48256 - screen_info.vesapm_seg,screen_info.vesapm_off);
48257 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48258 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48259 }
48260
48261 if (screen_info.vesapm_seg < 0xc000)
48262 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48263
48264 if (ypan || pmi_setpal) {
48265 unsigned short *pmi_base;
48266 +
48267 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48268 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48269 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48270 +
48271 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48272 + pax_open_kernel();
48273 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48274 +#else
48275 + pmi_code = pmi_base;
48276 +#endif
48277 +
48278 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48279 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48280 +
48281 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48282 + pmi_start = ktva_ktla(pmi_start);
48283 + pmi_pal = ktva_ktla(pmi_pal);
48284 + pax_close_kernel();
48285 +#endif
48286 +
48287 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48288 if (pmi_base[3]) {
48289 printk(KERN_INFO "vesafb: pmi: ports = ");
48290 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48291 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48292 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48293
48294 - if (!ypan)
48295 - info->fbops->fb_pan_display = NULL;
48296 + if (!ypan) {
48297 + pax_open_kernel();
48298 + *(void **)&info->fbops->fb_pan_display = NULL;
48299 + pax_close_kernel();
48300 + }
48301
48302 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48303 err = -ENOMEM;
48304 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48305 info->node, info->fix.id);
48306 return 0;
48307 err:
48308 +
48309 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48310 + module_free_exec(NULL, pmi_code);
48311 +#endif
48312 +
48313 if (info->screen_base)
48314 iounmap(info->screen_base);
48315 framebuffer_release(info);
48316 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48317 index 88714ae..16c2e11 100644
48318 --- a/drivers/video/via/via_clock.h
48319 +++ b/drivers/video/via/via_clock.h
48320 @@ -56,7 +56,7 @@ struct via_clock {
48321
48322 void (*set_engine_pll_state)(u8 state);
48323 void (*set_engine_pll)(struct via_pll_config config);
48324 -};
48325 +} __no_const;
48326
48327
48328 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48329 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48330 index fef20db..d28b1ab 100644
48331 --- a/drivers/xen/xenfs/xenstored.c
48332 +++ b/drivers/xen/xenfs/xenstored.c
48333 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48334 static int xsd_kva_open(struct inode *inode, struct file *file)
48335 {
48336 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48337 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48338 + NULL);
48339 +#else
48340 xen_store_interface);
48341 +#endif
48342 +
48343 if (!file->private_data)
48344 return -ENOMEM;
48345 return 0;
48346 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48347 index 890bed5..17ae73e 100644
48348 --- a/fs/9p/vfs_inode.c
48349 +++ b/fs/9p/vfs_inode.c
48350 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48351 void
48352 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48353 {
48354 - char *s = nd_get_link(nd);
48355 + const char *s = nd_get_link(nd);
48356
48357 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48358 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48359 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48360 index 0efd152..b5802ad 100644
48361 --- a/fs/Kconfig.binfmt
48362 +++ b/fs/Kconfig.binfmt
48363 @@ -89,7 +89,7 @@ config HAVE_AOUT
48364
48365 config BINFMT_AOUT
48366 tristate "Kernel support for a.out and ECOFF binaries"
48367 - depends on HAVE_AOUT
48368 + depends on HAVE_AOUT && BROKEN
48369 ---help---
48370 A.out (Assembler.OUTput) is a set of formats for libraries and
48371 executables used in the earliest versions of UNIX. Linux used
48372 diff --git a/fs/aio.c b/fs/aio.c
48373 index 71f613c..9d01f1f 100644
48374 --- a/fs/aio.c
48375 +++ b/fs/aio.c
48376 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48377 size += sizeof(struct io_event) * nr_events;
48378 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48379
48380 - if (nr_pages < 0)
48381 + if (nr_pages <= 0)
48382 return -EINVAL;
48383
48384 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48385 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
48386 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48387 {
48388 ssize_t ret;
48389 + struct iovec iovstack;
48390
48391 #ifdef CONFIG_COMPAT
48392 if (compat)
48393 ret = compat_rw_copy_check_uvector(type,
48394 (struct compat_iovec __user *)kiocb->ki_buf,
48395 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48396 + kiocb->ki_nbytes, 1, &iovstack,
48397 &kiocb->ki_iovec);
48398 else
48399 #endif
48400 ret = rw_copy_check_uvector(type,
48401 (struct iovec __user *)kiocb->ki_buf,
48402 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48403 + kiocb->ki_nbytes, 1, &iovstack,
48404 &kiocb->ki_iovec);
48405 if (ret < 0)
48406 goto out;
48407 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48408 if (ret < 0)
48409 goto out;
48410
48411 + if (kiocb->ki_iovec == &iovstack) {
48412 + kiocb->ki_inline_vec = iovstack;
48413 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48414 + }
48415 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48416 kiocb->ki_cur_seg = 0;
48417 /* ki_nbytes/left now reflect bytes instead of segs */
48418 diff --git a/fs/attr.c b/fs/attr.c
48419 index 1449adb..a2038c2 100644
48420 --- a/fs/attr.c
48421 +++ b/fs/attr.c
48422 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48423 unsigned long limit;
48424
48425 limit = rlimit(RLIMIT_FSIZE);
48426 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48427 if (limit != RLIM_INFINITY && offset > limit)
48428 goto out_sig;
48429 if (offset > inode->i_sb->s_maxbytes)
48430 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48431 index 03bc1d3..6205356 100644
48432 --- a/fs/autofs4/waitq.c
48433 +++ b/fs/autofs4/waitq.c
48434 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48435 {
48436 unsigned long sigpipe, flags;
48437 mm_segment_t fs;
48438 - const char *data = (const char *)addr;
48439 + const char __user *data = (const char __force_user *)addr;
48440 ssize_t wr = 0;
48441
48442 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48443 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48444 return 1;
48445 }
48446
48447 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48448 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48449 +#endif
48450 +
48451 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48452 enum autofs_notify notify)
48453 {
48454 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48455
48456 /* If this is a direct mount request create a dummy name */
48457 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48458 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48459 + /* this name does get written to userland via autofs4_write() */
48460 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48461 +#else
48462 qstr.len = sprintf(name, "%p", dentry);
48463 +#endif
48464 else {
48465 qstr.len = autofs4_getpath(sbi, dentry, &name);
48466 if (!qstr.len) {
48467 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48468 index 2722387..c8dd2a7 100644
48469 --- a/fs/befs/endian.h
48470 +++ b/fs/befs/endian.h
48471 @@ -11,7 +11,7 @@
48472
48473 #include <asm/byteorder.h>
48474
48475 -static inline u64
48476 +static inline u64 __intentional_overflow(-1)
48477 fs64_to_cpu(const struct super_block *sb, fs64 n)
48478 {
48479 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48480 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48481 return (__force fs64)cpu_to_be64(n);
48482 }
48483
48484 -static inline u32
48485 +static inline u32 __intentional_overflow(-1)
48486 fs32_to_cpu(const struct super_block *sb, fs32 n)
48487 {
48488 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48489 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48490 index 2b3bda8..6a2d4be 100644
48491 --- a/fs/befs/linuxvfs.c
48492 +++ b/fs/befs/linuxvfs.c
48493 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48494 {
48495 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48496 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48497 - char *link = nd_get_link(nd);
48498 + const char *link = nd_get_link(nd);
48499 if (!IS_ERR(link))
48500 kfree(link);
48501 }
48502 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48503 index 6043567..16a9239 100644
48504 --- a/fs/binfmt_aout.c
48505 +++ b/fs/binfmt_aout.c
48506 @@ -16,6 +16,7 @@
48507 #include <linux/string.h>
48508 #include <linux/fs.h>
48509 #include <linux/file.h>
48510 +#include <linux/security.h>
48511 #include <linux/stat.h>
48512 #include <linux/fcntl.h>
48513 #include <linux/ptrace.h>
48514 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48515 #endif
48516 # define START_STACK(u) ((void __user *)u.start_stack)
48517
48518 + memset(&dump, 0, sizeof(dump));
48519 +
48520 fs = get_fs();
48521 set_fs(KERNEL_DS);
48522 has_dumped = 1;
48523 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48524
48525 /* If the size of the dump file exceeds the rlimit, then see what would happen
48526 if we wrote the stack, but not the data area. */
48527 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48528 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48529 dump.u_dsize = 0;
48530
48531 /* Make sure we have enough room to write the stack and data areas. */
48532 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48533 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48534 dump.u_ssize = 0;
48535
48536 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48537 rlim = rlimit(RLIMIT_DATA);
48538 if (rlim >= RLIM_INFINITY)
48539 rlim = ~0;
48540 +
48541 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48542 if (ex.a_data + ex.a_bss > rlim)
48543 return -ENOMEM;
48544
48545 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48546
48547 install_exec_creds(bprm);
48548
48549 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48550 + current->mm->pax_flags = 0UL;
48551 +#endif
48552 +
48553 +#ifdef CONFIG_PAX_PAGEEXEC
48554 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48555 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48556 +
48557 +#ifdef CONFIG_PAX_EMUTRAMP
48558 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48559 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48560 +#endif
48561 +
48562 +#ifdef CONFIG_PAX_MPROTECT
48563 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48564 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48565 +#endif
48566 +
48567 + }
48568 +#endif
48569 +
48570 if (N_MAGIC(ex) == OMAGIC) {
48571 unsigned long text_addr, map_size;
48572 loff_t pos;
48573 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48574 }
48575
48576 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48577 - PROT_READ | PROT_WRITE | PROT_EXEC,
48578 + PROT_READ | PROT_WRITE,
48579 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48580 fd_offset + ex.a_text);
48581 if (error != N_DATADDR(ex)) {
48582 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48583 index 0c42cdb..b62581e9 100644
48584 --- a/fs/binfmt_elf.c
48585 +++ b/fs/binfmt_elf.c
48586 @@ -33,6 +33,7 @@
48587 #include <linux/elf.h>
48588 #include <linux/utsname.h>
48589 #include <linux/coredump.h>
48590 +#include <linux/xattr.h>
48591 #include <asm/uaccess.h>
48592 #include <asm/param.h>
48593 #include <asm/page.h>
48594 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48595 #define elf_core_dump NULL
48596 #endif
48597
48598 +#ifdef CONFIG_PAX_MPROTECT
48599 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48600 +#endif
48601 +
48602 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48603 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48604 #else
48605 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
48606 .load_binary = load_elf_binary,
48607 .load_shlib = load_elf_library,
48608 .core_dump = elf_core_dump,
48609 +
48610 +#ifdef CONFIG_PAX_MPROTECT
48611 + .handle_mprotect= elf_handle_mprotect,
48612 +#endif
48613 +
48614 .min_coredump = ELF_EXEC_PAGESIZE,
48615 };
48616
48617 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
48618
48619 static int set_brk(unsigned long start, unsigned long end)
48620 {
48621 + unsigned long e = end;
48622 +
48623 start = ELF_PAGEALIGN(start);
48624 end = ELF_PAGEALIGN(end);
48625 if (end > start) {
48626 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
48627 if (BAD_ADDR(addr))
48628 return addr;
48629 }
48630 - current->mm->start_brk = current->mm->brk = end;
48631 + current->mm->start_brk = current->mm->brk = e;
48632 return 0;
48633 }
48634
48635 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48636 elf_addr_t __user *u_rand_bytes;
48637 const char *k_platform = ELF_PLATFORM;
48638 const char *k_base_platform = ELF_BASE_PLATFORM;
48639 - unsigned char k_rand_bytes[16];
48640 + u32 k_rand_bytes[4];
48641 int items;
48642 elf_addr_t *elf_info;
48643 int ei_index = 0;
48644 const struct cred *cred = current_cred();
48645 struct vm_area_struct *vma;
48646 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48647
48648 /*
48649 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48650 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48651 * Generate 16 random bytes for userspace PRNG seeding.
48652 */
48653 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48654 - u_rand_bytes = (elf_addr_t __user *)
48655 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48656 + srandom32(k_rand_bytes[0] ^ random32());
48657 + srandom32(k_rand_bytes[1] ^ random32());
48658 + srandom32(k_rand_bytes[2] ^ random32());
48659 + srandom32(k_rand_bytes[3] ^ random32());
48660 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48661 + u_rand_bytes = (elf_addr_t __user *) p;
48662 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48663 return -EFAULT;
48664
48665 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48666 return -EFAULT;
48667 current->mm->env_end = p;
48668
48669 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48670 +
48671 /* Put the elf_info on the stack in the right place. */
48672 sp = (elf_addr_t __user *)envp + 1;
48673 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48674 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48675 return -EFAULT;
48676 return 0;
48677 }
48678 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48679 an ELF header */
48680
48681 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48682 - struct file *interpreter, unsigned long *interp_map_addr,
48683 - unsigned long no_base)
48684 + struct file *interpreter, unsigned long no_base)
48685 {
48686 struct elf_phdr *elf_phdata;
48687 struct elf_phdr *eppnt;
48688 - unsigned long load_addr = 0;
48689 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48690 int load_addr_set = 0;
48691 unsigned long last_bss = 0, elf_bss = 0;
48692 - unsigned long error = ~0UL;
48693 + unsigned long error = -EINVAL;
48694 unsigned long total_size;
48695 int retval, i, size;
48696
48697 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48698 goto out_close;
48699 }
48700
48701 +#ifdef CONFIG_PAX_SEGMEXEC
48702 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48703 + pax_task_size = SEGMEXEC_TASK_SIZE;
48704 +#endif
48705 +
48706 eppnt = elf_phdata;
48707 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48708 if (eppnt->p_type == PT_LOAD) {
48709 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48710 map_addr = elf_map(interpreter, load_addr + vaddr,
48711 eppnt, elf_prot, elf_type, total_size);
48712 total_size = 0;
48713 - if (!*interp_map_addr)
48714 - *interp_map_addr = map_addr;
48715 error = map_addr;
48716 if (BAD_ADDR(map_addr))
48717 goto out_close;
48718 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48719 k = load_addr + eppnt->p_vaddr;
48720 if (BAD_ADDR(k) ||
48721 eppnt->p_filesz > eppnt->p_memsz ||
48722 - eppnt->p_memsz > TASK_SIZE ||
48723 - TASK_SIZE - eppnt->p_memsz < k) {
48724 + eppnt->p_memsz > pax_task_size ||
48725 + pax_task_size - eppnt->p_memsz < k) {
48726 error = -ENOMEM;
48727 goto out_close;
48728 }
48729 @@ -530,6 +551,315 @@ out:
48730 return error;
48731 }
48732
48733 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48734 +#ifdef CONFIG_PAX_SOFTMODE
48735 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48736 +{
48737 + unsigned long pax_flags = 0UL;
48738 +
48739 +#ifdef CONFIG_PAX_PAGEEXEC
48740 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48741 + pax_flags |= MF_PAX_PAGEEXEC;
48742 +#endif
48743 +
48744 +#ifdef CONFIG_PAX_SEGMEXEC
48745 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48746 + pax_flags |= MF_PAX_SEGMEXEC;
48747 +#endif
48748 +
48749 +#ifdef CONFIG_PAX_EMUTRAMP
48750 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48751 + pax_flags |= MF_PAX_EMUTRAMP;
48752 +#endif
48753 +
48754 +#ifdef CONFIG_PAX_MPROTECT
48755 + if (elf_phdata->p_flags & PF_MPROTECT)
48756 + pax_flags |= MF_PAX_MPROTECT;
48757 +#endif
48758 +
48759 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48760 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48761 + pax_flags |= MF_PAX_RANDMMAP;
48762 +#endif
48763 +
48764 + return pax_flags;
48765 +}
48766 +#endif
48767 +
48768 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48769 +{
48770 + unsigned long pax_flags = 0UL;
48771 +
48772 +#ifdef CONFIG_PAX_PAGEEXEC
48773 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48774 + pax_flags |= MF_PAX_PAGEEXEC;
48775 +#endif
48776 +
48777 +#ifdef CONFIG_PAX_SEGMEXEC
48778 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48779 + pax_flags |= MF_PAX_SEGMEXEC;
48780 +#endif
48781 +
48782 +#ifdef CONFIG_PAX_EMUTRAMP
48783 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48784 + pax_flags |= MF_PAX_EMUTRAMP;
48785 +#endif
48786 +
48787 +#ifdef CONFIG_PAX_MPROTECT
48788 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48789 + pax_flags |= MF_PAX_MPROTECT;
48790 +#endif
48791 +
48792 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48793 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48794 + pax_flags |= MF_PAX_RANDMMAP;
48795 +#endif
48796 +
48797 + return pax_flags;
48798 +}
48799 +#endif
48800 +
48801 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48802 +#ifdef CONFIG_PAX_SOFTMODE
48803 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48804 +{
48805 + unsigned long pax_flags = 0UL;
48806 +
48807 +#ifdef CONFIG_PAX_PAGEEXEC
48808 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48809 + pax_flags |= MF_PAX_PAGEEXEC;
48810 +#endif
48811 +
48812 +#ifdef CONFIG_PAX_SEGMEXEC
48813 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48814 + pax_flags |= MF_PAX_SEGMEXEC;
48815 +#endif
48816 +
48817 +#ifdef CONFIG_PAX_EMUTRAMP
48818 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48819 + pax_flags |= MF_PAX_EMUTRAMP;
48820 +#endif
48821 +
48822 +#ifdef CONFIG_PAX_MPROTECT
48823 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48824 + pax_flags |= MF_PAX_MPROTECT;
48825 +#endif
48826 +
48827 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48828 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48829 + pax_flags |= MF_PAX_RANDMMAP;
48830 +#endif
48831 +
48832 + return pax_flags;
48833 +}
48834 +#endif
48835 +
48836 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48837 +{
48838 + unsigned long pax_flags = 0UL;
48839 +
48840 +#ifdef CONFIG_PAX_PAGEEXEC
48841 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48842 + pax_flags |= MF_PAX_PAGEEXEC;
48843 +#endif
48844 +
48845 +#ifdef CONFIG_PAX_SEGMEXEC
48846 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48847 + pax_flags |= MF_PAX_SEGMEXEC;
48848 +#endif
48849 +
48850 +#ifdef CONFIG_PAX_EMUTRAMP
48851 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48852 + pax_flags |= MF_PAX_EMUTRAMP;
48853 +#endif
48854 +
48855 +#ifdef CONFIG_PAX_MPROTECT
48856 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48857 + pax_flags |= MF_PAX_MPROTECT;
48858 +#endif
48859 +
48860 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48861 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48862 + pax_flags |= MF_PAX_RANDMMAP;
48863 +#endif
48864 +
48865 + return pax_flags;
48866 +}
48867 +#endif
48868 +
48869 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48870 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48871 +{
48872 + unsigned long pax_flags = 0UL;
48873 +
48874 +#ifdef CONFIG_PAX_EI_PAX
48875 +
48876 +#ifdef CONFIG_PAX_PAGEEXEC
48877 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48878 + pax_flags |= MF_PAX_PAGEEXEC;
48879 +#endif
48880 +
48881 +#ifdef CONFIG_PAX_SEGMEXEC
48882 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48883 + pax_flags |= MF_PAX_SEGMEXEC;
48884 +#endif
48885 +
48886 +#ifdef CONFIG_PAX_EMUTRAMP
48887 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48888 + pax_flags |= MF_PAX_EMUTRAMP;
48889 +#endif
48890 +
48891 +#ifdef CONFIG_PAX_MPROTECT
48892 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48893 + pax_flags |= MF_PAX_MPROTECT;
48894 +#endif
48895 +
48896 +#ifdef CONFIG_PAX_ASLR
48897 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48898 + pax_flags |= MF_PAX_RANDMMAP;
48899 +#endif
48900 +
48901 +#else
48902 +
48903 +#ifdef CONFIG_PAX_PAGEEXEC
48904 + pax_flags |= MF_PAX_PAGEEXEC;
48905 +#endif
48906 +
48907 +#ifdef CONFIG_PAX_SEGMEXEC
48908 + pax_flags |= MF_PAX_SEGMEXEC;
48909 +#endif
48910 +
48911 +#ifdef CONFIG_PAX_MPROTECT
48912 + pax_flags |= MF_PAX_MPROTECT;
48913 +#endif
48914 +
48915 +#ifdef CONFIG_PAX_RANDMMAP
48916 + if (randomize_va_space)
48917 + pax_flags |= MF_PAX_RANDMMAP;
48918 +#endif
48919 +
48920 +#endif
48921 +
48922 + return pax_flags;
48923 +}
48924 +
48925 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48926 +{
48927 +
48928 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48929 + unsigned long i;
48930 +
48931 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48932 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48933 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48934 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48935 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48936 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48937 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48938 + return ~0UL;
48939 +
48940 +#ifdef CONFIG_PAX_SOFTMODE
48941 + if (pax_softmode)
48942 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48943 + else
48944 +#endif
48945 +
48946 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48947 + break;
48948 + }
48949 +#endif
48950 +
48951 + return ~0UL;
48952 +}
48953 +
48954 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48955 +{
48956 +
48957 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48958 + ssize_t xattr_size, i;
48959 + unsigned char xattr_value[5];
48960 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48961 +
48962 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
48963 + if (xattr_size <= 0 || xattr_size > 5)
48964 + return ~0UL;
48965 +
48966 + for (i = 0; i < xattr_size; i++)
48967 + switch (xattr_value[i]) {
48968 + default:
48969 + return ~0UL;
48970 +
48971 +#define parse_flag(option1, option2, flag) \
48972 + case option1: \
48973 + if (pax_flags_hardmode & MF_PAX_##flag) \
48974 + return ~0UL; \
48975 + pax_flags_hardmode |= MF_PAX_##flag; \
48976 + break; \
48977 + case option2: \
48978 + if (pax_flags_softmode & MF_PAX_##flag) \
48979 + return ~0UL; \
48980 + pax_flags_softmode |= MF_PAX_##flag; \
48981 + break;
48982 +
48983 + parse_flag('p', 'P', PAGEEXEC);
48984 + parse_flag('e', 'E', EMUTRAMP);
48985 + parse_flag('m', 'M', MPROTECT);
48986 + parse_flag('r', 'R', RANDMMAP);
48987 + parse_flag('s', 'S', SEGMEXEC);
48988 +
48989 +#undef parse_flag
48990 + }
48991 +
48992 + if (pax_flags_hardmode & pax_flags_softmode)
48993 + return ~0UL;
48994 +
48995 +#ifdef CONFIG_PAX_SOFTMODE
48996 + if (pax_softmode)
48997 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48998 + else
48999 +#endif
49000 +
49001 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
49002 +#else
49003 + return ~0UL;
49004 +#endif
49005 +
49006 +}
49007 +
49008 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
49009 +{
49010 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
49011 +
49012 + pax_flags = pax_parse_ei_pax(elf_ex);
49013 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
49014 + xattr_pax_flags = pax_parse_xattr_pax(file);
49015 +
49016 + if (pt_pax_flags == ~0UL)
49017 + pt_pax_flags = xattr_pax_flags;
49018 + else if (xattr_pax_flags == ~0UL)
49019 + xattr_pax_flags = pt_pax_flags;
49020 + if (pt_pax_flags != xattr_pax_flags)
49021 + return -EINVAL;
49022 + if (pt_pax_flags != ~0UL)
49023 + pax_flags = pt_pax_flags;
49024 +
49025 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
49026 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49027 + if ((__supported_pte_mask & _PAGE_NX))
49028 + pax_flags &= ~MF_PAX_SEGMEXEC;
49029 + else
49030 + pax_flags &= ~MF_PAX_PAGEEXEC;
49031 + }
49032 +#endif
49033 +
49034 + if (0 > pax_check_flags(&pax_flags))
49035 + return -EINVAL;
49036 +
49037 + current->mm->pax_flags = pax_flags;
49038 + return 0;
49039 +}
49040 +#endif
49041 +
49042 /*
49043 * These are the functions used to load ELF style executables and shared
49044 * libraries. There is no binary dependent code anywhere else.
49045 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49046 {
49047 unsigned int random_variable = 0;
49048
49049 +#ifdef CONFIG_PAX_RANDUSTACK
49050 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49051 + return stack_top - current->mm->delta_stack;
49052 +#endif
49053 +
49054 if ((current->flags & PF_RANDOMIZE) &&
49055 !(current->personality & ADDR_NO_RANDOMIZE)) {
49056 random_variable = get_random_int() & STACK_RND_MASK;
49057 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49058 unsigned long load_addr = 0, load_bias = 0;
49059 int load_addr_set = 0;
49060 char * elf_interpreter = NULL;
49061 - unsigned long error;
49062 + unsigned long error = 0;
49063 struct elf_phdr *elf_ppnt, *elf_phdata;
49064 unsigned long elf_bss, elf_brk;
49065 int retval, i;
49066 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49067 unsigned long start_code, end_code, start_data, end_data;
49068 unsigned long reloc_func_desc __maybe_unused = 0;
49069 int executable_stack = EXSTACK_DEFAULT;
49070 - unsigned long def_flags = 0;
49071 struct pt_regs *regs = current_pt_regs();
49072 struct {
49073 struct elfhdr elf_ex;
49074 struct elfhdr interp_elf_ex;
49075 } *loc;
49076 + unsigned long pax_task_size = TASK_SIZE;
49077
49078 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49079 if (!loc) {
49080 @@ -715,11 +1050,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49081 goto out_free_dentry;
49082
49083 /* OK, This is the point of no return */
49084 - current->mm->def_flags = def_flags;
49085 +
49086 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49087 + current->mm->pax_flags = 0UL;
49088 +#endif
49089 +
49090 +#ifdef CONFIG_PAX_DLRESOLVE
49091 + current->mm->call_dl_resolve = 0UL;
49092 +#endif
49093 +
49094 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49095 + current->mm->call_syscall = 0UL;
49096 +#endif
49097 +
49098 +#ifdef CONFIG_PAX_ASLR
49099 + current->mm->delta_mmap = 0UL;
49100 + current->mm->delta_stack = 0UL;
49101 +#endif
49102 +
49103 + current->mm->def_flags = 0;
49104 +
49105 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49106 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49107 + send_sig(SIGKILL, current, 0);
49108 + goto out_free_dentry;
49109 + }
49110 +#endif
49111 +
49112 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49113 + pax_set_initial_flags(bprm);
49114 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49115 + if (pax_set_initial_flags_func)
49116 + (pax_set_initial_flags_func)(bprm);
49117 +#endif
49118 +
49119 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49120 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49121 + current->mm->context.user_cs_limit = PAGE_SIZE;
49122 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49123 + }
49124 +#endif
49125 +
49126 +#ifdef CONFIG_PAX_SEGMEXEC
49127 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49128 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49129 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49130 + pax_task_size = SEGMEXEC_TASK_SIZE;
49131 + current->mm->def_flags |= VM_NOHUGEPAGE;
49132 + }
49133 +#endif
49134 +
49135 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49136 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49137 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49138 + put_cpu();
49139 + }
49140 +#endif
49141
49142 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49143 may depend on the personality. */
49144 SET_PERSONALITY(loc->elf_ex);
49145 +
49146 +#ifdef CONFIG_PAX_ASLR
49147 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49148 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49149 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49150 + }
49151 +#endif
49152 +
49153 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49154 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49155 + executable_stack = EXSTACK_DISABLE_X;
49156 + current->personality &= ~READ_IMPLIES_EXEC;
49157 + } else
49158 +#endif
49159 +
49160 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49161 current->personality |= READ_IMPLIES_EXEC;
49162
49163 @@ -810,6 +1215,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49164 #else
49165 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49166 #endif
49167 +
49168 +#ifdef CONFIG_PAX_RANDMMAP
49169 + /* PaX: randomize base address at the default exe base if requested */
49170 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49171 +#ifdef CONFIG_SPARC64
49172 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49173 +#else
49174 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49175 +#endif
49176 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49177 + elf_flags |= MAP_FIXED;
49178 + }
49179 +#endif
49180 +
49181 }
49182
49183 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49184 @@ -842,9 +1261,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49185 * allowed task size. Note that p_filesz must always be
49186 * <= p_memsz so it is only necessary to check p_memsz.
49187 */
49188 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49189 - elf_ppnt->p_memsz > TASK_SIZE ||
49190 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49191 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49192 + elf_ppnt->p_memsz > pax_task_size ||
49193 + pax_task_size - elf_ppnt->p_memsz < k) {
49194 /* set_brk can never work. Avoid overflows. */
49195 send_sig(SIGKILL, current, 0);
49196 retval = -EINVAL;
49197 @@ -883,17 +1302,44 @@ static int load_elf_binary(struct linux_binprm *bprm)
49198 goto out_free_dentry;
49199 }
49200 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49201 - send_sig(SIGSEGV, current, 0);
49202 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49203 - goto out_free_dentry;
49204 + /*
49205 + * This bss-zeroing can fail if the ELF
49206 + * file specifies odd protections. So
49207 + * we don't check the return value
49208 + */
49209 }
49210
49211 +#ifdef CONFIG_PAX_RANDMMAP
49212 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49213 + unsigned long start, size, flags, vm_flags;
49214 +
49215 + start = ELF_PAGEALIGN(elf_brk);
49216 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49217 + flags = MAP_FIXED | MAP_PRIVATE;
49218 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49219 +
49220 + down_write(&current->mm->mmap_sem);
49221 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49222 + retval = -ENOMEM;
49223 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49224 +// if (current->personality & ADDR_NO_RANDOMIZE)
49225 +// vm_flags |= VM_READ | VM_MAYREAD;
49226 + start = mmap_region(NULL, start, PAGE_ALIGN(size), flags, vm_flags, 0);
49227 + retval = IS_ERR_VALUE(start) ? start : 0;
49228 + }
49229 + up_write(&current->mm->mmap_sem);
49230 + if (retval == 0)
49231 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49232 + if (retval < 0) {
49233 + send_sig(SIGKILL, current, 0);
49234 + goto out_free_dentry;
49235 + }
49236 + }
49237 +#endif
49238 +
49239 if (elf_interpreter) {
49240 - unsigned long interp_map_addr = 0;
49241 -
49242 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49243 interpreter,
49244 - &interp_map_addr,
49245 load_bias);
49246 if (!IS_ERR((void *)elf_entry)) {
49247 /*
49248 @@ -1115,7 +1561,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49249 * Decide what to dump of a segment, part, all or none.
49250 */
49251 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49252 - unsigned long mm_flags)
49253 + unsigned long mm_flags, long signr)
49254 {
49255 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49256
49257 @@ -1152,7 +1598,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49258 if (vma->vm_file == NULL)
49259 return 0;
49260
49261 - if (FILTER(MAPPED_PRIVATE))
49262 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49263 goto whole;
49264
49265 /*
49266 @@ -1374,9 +1820,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49267 {
49268 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49269 int i = 0;
49270 - do
49271 + do {
49272 i += 2;
49273 - while (auxv[i - 2] != AT_NULL);
49274 + } while (auxv[i - 2] != AT_NULL);
49275 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49276 }
49277
49278 @@ -2006,14 +2452,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49279 }
49280
49281 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49282 - unsigned long mm_flags)
49283 + struct coredump_params *cprm)
49284 {
49285 struct vm_area_struct *vma;
49286 size_t size = 0;
49287
49288 for (vma = first_vma(current, gate_vma); vma != NULL;
49289 vma = next_vma(vma, gate_vma))
49290 - size += vma_dump_size(vma, mm_flags);
49291 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49292 return size;
49293 }
49294
49295 @@ -2107,7 +2553,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49296
49297 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49298
49299 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49300 + offset += elf_core_vma_data_size(gate_vma, cprm);
49301 offset += elf_core_extra_data_size();
49302 e_shoff = offset;
49303
49304 @@ -2121,10 +2567,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49305 offset = dataoff;
49306
49307 size += sizeof(*elf);
49308 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49309 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49310 goto end_coredump;
49311
49312 size += sizeof(*phdr4note);
49313 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49314 if (size > cprm->limit
49315 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49316 goto end_coredump;
49317 @@ -2138,7 +2586,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49318 phdr.p_offset = offset;
49319 phdr.p_vaddr = vma->vm_start;
49320 phdr.p_paddr = 0;
49321 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49322 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49323 phdr.p_memsz = vma->vm_end - vma->vm_start;
49324 offset += phdr.p_filesz;
49325 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49326 @@ -2149,6 +2597,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49327 phdr.p_align = ELF_EXEC_PAGESIZE;
49328
49329 size += sizeof(phdr);
49330 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49331 if (size > cprm->limit
49332 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49333 goto end_coredump;
49334 @@ -2173,7 +2622,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49335 unsigned long addr;
49336 unsigned long end;
49337
49338 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49339 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49340
49341 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49342 struct page *page;
49343 @@ -2182,6 +2631,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49344 page = get_dump_page(addr);
49345 if (page) {
49346 void *kaddr = kmap(page);
49347 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49348 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49349 !dump_write(cprm->file, kaddr,
49350 PAGE_SIZE);
49351 @@ -2199,6 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49352
49353 if (e_phnum == PN_XNUM) {
49354 size += sizeof(*shdr4extnum);
49355 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49356 if (size > cprm->limit
49357 || !dump_write(cprm->file, shdr4extnum,
49358 sizeof(*shdr4extnum)))
49359 @@ -2219,6 +2670,97 @@ out:
49360
49361 #endif /* CONFIG_ELF_CORE */
49362
49363 +#ifdef CONFIG_PAX_MPROTECT
49364 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49365 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49366 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49367 + *
49368 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49369 + * basis because we want to allow the common case and not the special ones.
49370 + */
49371 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49372 +{
49373 + struct elfhdr elf_h;
49374 + struct elf_phdr elf_p;
49375 + unsigned long i;
49376 + unsigned long oldflags;
49377 + bool is_textrel_rw, is_textrel_rx, is_relro;
49378 +
49379 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49380 + return;
49381 +
49382 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49383 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49384 +
49385 +#ifdef CONFIG_PAX_ELFRELOCS
49386 + /* possible TEXTREL */
49387 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49388 + 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);
49389 +#else
49390 + is_textrel_rw = false;
49391 + is_textrel_rx = false;
49392 +#endif
49393 +
49394 + /* possible RELRO */
49395 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49396 +
49397 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49398 + return;
49399 +
49400 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49401 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49402 +
49403 +#ifdef CONFIG_PAX_ETEXECRELOCS
49404 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49405 +#else
49406 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49407 +#endif
49408 +
49409 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49410 + !elf_check_arch(&elf_h) ||
49411 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49412 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49413 + return;
49414 +
49415 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49416 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49417 + return;
49418 + switch (elf_p.p_type) {
49419 + case PT_DYNAMIC:
49420 + if (!is_textrel_rw && !is_textrel_rx)
49421 + continue;
49422 + i = 0UL;
49423 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49424 + elf_dyn dyn;
49425 +
49426 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49427 + return;
49428 + if (dyn.d_tag == DT_NULL)
49429 + return;
49430 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49431 + gr_log_textrel(vma);
49432 + if (is_textrel_rw)
49433 + vma->vm_flags |= VM_MAYWRITE;
49434 + else
49435 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49436 + vma->vm_flags &= ~VM_MAYWRITE;
49437 + return;
49438 + }
49439 + i++;
49440 + }
49441 + return;
49442 +
49443 + case PT_GNU_RELRO:
49444 + if (!is_relro)
49445 + continue;
49446 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49447 + vma->vm_flags &= ~VM_MAYWRITE;
49448 + return;
49449 + }
49450 + }
49451 +}
49452 +#endif
49453 +
49454 static int __init init_elf_binfmt(void)
49455 {
49456 register_binfmt(&elf_format);
49457 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49458 index b563719..3868998 100644
49459 --- a/fs/binfmt_flat.c
49460 +++ b/fs/binfmt_flat.c
49461 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49462 realdatastart = (unsigned long) -ENOMEM;
49463 printk("Unable to allocate RAM for process data, errno %d\n",
49464 (int)-realdatastart);
49465 + down_write(&current->mm->mmap_sem);
49466 vm_munmap(textpos, text_len);
49467 + up_write(&current->mm->mmap_sem);
49468 ret = realdatastart;
49469 goto err;
49470 }
49471 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49472 }
49473 if (IS_ERR_VALUE(result)) {
49474 printk("Unable to read data+bss, errno %d\n", (int)-result);
49475 + down_write(&current->mm->mmap_sem);
49476 vm_munmap(textpos, text_len);
49477 vm_munmap(realdatastart, len);
49478 + up_write(&current->mm->mmap_sem);
49479 ret = result;
49480 goto err;
49481 }
49482 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49483 }
49484 if (IS_ERR_VALUE(result)) {
49485 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49486 + down_write(&current->mm->mmap_sem);
49487 vm_munmap(textpos, text_len + data_len + extra +
49488 MAX_SHARED_LIBS * sizeof(unsigned long));
49489 + up_write(&current->mm->mmap_sem);
49490 ret = result;
49491 goto err;
49492 }
49493 diff --git a/fs/bio.c b/fs/bio.c
49494 index b96fc6c..431d628 100644
49495 --- a/fs/bio.c
49496 +++ b/fs/bio.c
49497 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49498 /*
49499 * Overflow, abort
49500 */
49501 - if (end < start)
49502 + if (end < start || end - start > INT_MAX - nr_pages)
49503 return ERR_PTR(-EINVAL);
49504
49505 nr_pages += end - start;
49506 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49507 /*
49508 * Overflow, abort
49509 */
49510 - if (end < start)
49511 + if (end < start || end - start > INT_MAX - nr_pages)
49512 return ERR_PTR(-EINVAL);
49513
49514 nr_pages += end - start;
49515 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49516 const int read = bio_data_dir(bio) == READ;
49517 struct bio_map_data *bmd = bio->bi_private;
49518 int i;
49519 - char *p = bmd->sgvecs[0].iov_base;
49520 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49521
49522 __bio_for_each_segment(bvec, bio, i, 0) {
49523 char *addr = page_address(bvec->bv_page);
49524 diff --git a/fs/block_dev.c b/fs/block_dev.c
49525 index 883dc49..f27794a 100644
49526 --- a/fs/block_dev.c
49527 +++ b/fs/block_dev.c
49528 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49529 else if (bdev->bd_contains == bdev)
49530 return true; /* is a whole device which isn't held */
49531
49532 - else if (whole->bd_holder == bd_may_claim)
49533 + else if (whole->bd_holder == (void *)bd_may_claim)
49534 return true; /* is a partition of a device that is being partitioned */
49535 else if (whole->bd_holder != NULL)
49536 return false; /* is a partition of a held device */
49537 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49538 index ce1c169..1ef484f 100644
49539 --- a/fs/btrfs/ctree.c
49540 +++ b/fs/btrfs/ctree.c
49541 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49542 free_extent_buffer(buf);
49543 add_root_to_dirty_list(root);
49544 } else {
49545 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49546 - parent_start = parent->start;
49547 - else
49548 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49549 + if (parent)
49550 + parent_start = parent->start;
49551 + else
49552 + parent_start = 0;
49553 + } else
49554 parent_start = 0;
49555
49556 WARN_ON(trans->transid != btrfs_header_generation(parent));
49557 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
49558 index 7c4e6cc..27bd5c2 100644
49559 --- a/fs/btrfs/inode.c
49560 +++ b/fs/btrfs/inode.c
49561 @@ -7314,7 +7314,7 @@ fail:
49562 return -ENOMEM;
49563 }
49564
49565 -static int btrfs_getattr(struct vfsmount *mnt,
49566 +int btrfs_getattr(struct vfsmount *mnt,
49567 struct dentry *dentry, struct kstat *stat)
49568 {
49569 struct inode *inode = dentry->d_inode;
49570 @@ -7328,6 +7328,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
49571 return 0;
49572 }
49573
49574 +EXPORT_SYMBOL(btrfs_getattr);
49575 +
49576 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
49577 +{
49578 + return BTRFS_I(inode)->root->anon_dev;
49579 +}
49580 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
49581 +
49582 /*
49583 * If a file is moved, it will inherit the cow and compression flags of the new
49584 * directory.
49585 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49586 index 338f259..b657640 100644
49587 --- a/fs/btrfs/ioctl.c
49588 +++ b/fs/btrfs/ioctl.c
49589 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49590 for (i = 0; i < num_types; i++) {
49591 struct btrfs_space_info *tmp;
49592
49593 + /* Don't copy in more than we allocated */
49594 if (!slot_count)
49595 break;
49596
49597 + slot_count--;
49598 +
49599 info = NULL;
49600 rcu_read_lock();
49601 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49602 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49603 memcpy(dest, &space, sizeof(space));
49604 dest++;
49605 space_args.total_spaces++;
49606 - slot_count--;
49607 }
49608 - if (!slot_count)
49609 - break;
49610 }
49611 up_read(&info->groups_sem);
49612 }
49613 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
49614 index 300e09a..9fe4539 100644
49615 --- a/fs/btrfs/relocation.c
49616 +++ b/fs/btrfs/relocation.c
49617 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
49618 }
49619 spin_unlock(&rc->reloc_root_tree.lock);
49620
49621 - BUG_ON((struct btrfs_root *)node->data != root);
49622 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
49623
49624 if (!del) {
49625 spin_lock(&rc->reloc_root_tree.lock);
49626 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49627 index d8982e9..29a85fa 100644
49628 --- a/fs/btrfs/super.c
49629 +++ b/fs/btrfs/super.c
49630 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49631 function, line, errstr);
49632 return;
49633 }
49634 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49635 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49636 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49637 }
49638 /*
49639 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49640 index 622f469..e8d2d55 100644
49641 --- a/fs/cachefiles/bind.c
49642 +++ b/fs/cachefiles/bind.c
49643 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49644 args);
49645
49646 /* start by checking things over */
49647 - ASSERT(cache->fstop_percent >= 0 &&
49648 - cache->fstop_percent < cache->fcull_percent &&
49649 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49650 cache->fcull_percent < cache->frun_percent &&
49651 cache->frun_percent < 100);
49652
49653 - ASSERT(cache->bstop_percent >= 0 &&
49654 - cache->bstop_percent < cache->bcull_percent &&
49655 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49656 cache->bcull_percent < cache->brun_percent &&
49657 cache->brun_percent < 100);
49658
49659 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49660 index 0a1467b..6a53245 100644
49661 --- a/fs/cachefiles/daemon.c
49662 +++ b/fs/cachefiles/daemon.c
49663 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49664 if (n > buflen)
49665 return -EMSGSIZE;
49666
49667 - if (copy_to_user(_buffer, buffer, n) != 0)
49668 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49669 return -EFAULT;
49670
49671 return n;
49672 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49673 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49674 return -EIO;
49675
49676 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49677 + if (datalen > PAGE_SIZE - 1)
49678 return -EOPNOTSUPP;
49679
49680 /* drag the command string into the kernel so we can parse it */
49681 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49682 if (args[0] != '%' || args[1] != '\0')
49683 return -EINVAL;
49684
49685 - if (fstop < 0 || fstop >= cache->fcull_percent)
49686 + if (fstop >= cache->fcull_percent)
49687 return cachefiles_daemon_range_error(cache, args);
49688
49689 cache->fstop_percent = fstop;
49690 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49691 if (args[0] != '%' || args[1] != '\0')
49692 return -EINVAL;
49693
49694 - if (bstop < 0 || bstop >= cache->bcull_percent)
49695 + if (bstop >= cache->bcull_percent)
49696 return cachefiles_daemon_range_error(cache, args);
49697
49698 cache->bstop_percent = bstop;
49699 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49700 index 4938251..7e01445 100644
49701 --- a/fs/cachefiles/internal.h
49702 +++ b/fs/cachefiles/internal.h
49703 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49704 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49705 struct rb_root active_nodes; /* active nodes (can't be culled) */
49706 rwlock_t active_lock; /* lock for active_nodes */
49707 - atomic_t gravecounter; /* graveyard uniquifier */
49708 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49709 unsigned frun_percent; /* when to stop culling (% files) */
49710 unsigned fcull_percent; /* when to start culling (% files) */
49711 unsigned fstop_percent; /* when to stop allocating (% files) */
49712 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49713 * proc.c
49714 */
49715 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49716 -extern atomic_t cachefiles_lookup_histogram[HZ];
49717 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49718 -extern atomic_t cachefiles_create_histogram[HZ];
49719 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49720 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49721 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49722
49723 extern int __init cachefiles_proc_init(void);
49724 extern void cachefiles_proc_cleanup(void);
49725 static inline
49726 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49727 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49728 {
49729 unsigned long jif = jiffies - start_jif;
49730 if (jif >= HZ)
49731 jif = HZ - 1;
49732 - atomic_inc(&histogram[jif]);
49733 + atomic_inc_unchecked(&histogram[jif]);
49734 }
49735
49736 #else
49737 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49738 index 8c01c5fc..15f982e 100644
49739 --- a/fs/cachefiles/namei.c
49740 +++ b/fs/cachefiles/namei.c
49741 @@ -317,7 +317,7 @@ try_again:
49742 /* first step is to make up a grave dentry in the graveyard */
49743 sprintf(nbuffer, "%08x%08x",
49744 (uint32_t) get_seconds(),
49745 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49746 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49747
49748 /* do the multiway lock magic */
49749 trap = lock_rename(cache->graveyard, dir);
49750 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49751 index eccd339..4c1d995 100644
49752 --- a/fs/cachefiles/proc.c
49753 +++ b/fs/cachefiles/proc.c
49754 @@ -14,9 +14,9 @@
49755 #include <linux/seq_file.h>
49756 #include "internal.h"
49757
49758 -atomic_t cachefiles_lookup_histogram[HZ];
49759 -atomic_t cachefiles_mkdir_histogram[HZ];
49760 -atomic_t cachefiles_create_histogram[HZ];
49761 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49762 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49763 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49764
49765 /*
49766 * display the latency histogram
49767 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49768 return 0;
49769 default:
49770 index = (unsigned long) v - 3;
49771 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49772 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49773 - z = atomic_read(&cachefiles_create_histogram[index]);
49774 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49775 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49776 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49777 if (x == 0 && y == 0 && z == 0)
49778 return 0;
49779
49780 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49781 index 4809922..aab2c39 100644
49782 --- a/fs/cachefiles/rdwr.c
49783 +++ b/fs/cachefiles/rdwr.c
49784 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49785 old_fs = get_fs();
49786 set_fs(KERNEL_DS);
49787 ret = file->f_op->write(
49788 - file, (const void __user *) data, len, &pos);
49789 + file, (const void __force_user *) data, len, &pos);
49790 set_fs(old_fs);
49791 kunmap(page);
49792 if (ret != len)
49793 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49794 index 8c1aabe..bbf856a 100644
49795 --- a/fs/ceph/dir.c
49796 +++ b/fs/ceph/dir.c
49797 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49798 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49799 struct ceph_mds_client *mdsc = fsc->mdsc;
49800 unsigned frag = fpos_frag(filp->f_pos);
49801 - int off = fpos_off(filp->f_pos);
49802 + unsigned int off = fpos_off(filp->f_pos);
49803 int err;
49804 u32 ftype;
49805 struct ceph_mds_reply_info_parsed *rinfo;
49806 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49807 index d9ea6ed..1e6c8ac 100644
49808 --- a/fs/cifs/cifs_debug.c
49809 +++ b/fs/cifs/cifs_debug.c
49810 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49811
49812 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49813 #ifdef CONFIG_CIFS_STATS2
49814 - atomic_set(&totBufAllocCount, 0);
49815 - atomic_set(&totSmBufAllocCount, 0);
49816 + atomic_set_unchecked(&totBufAllocCount, 0);
49817 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49818 #endif /* CONFIG_CIFS_STATS2 */
49819 spin_lock(&cifs_tcp_ses_lock);
49820 list_for_each(tmp1, &cifs_tcp_ses_list) {
49821 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49822 tcon = list_entry(tmp3,
49823 struct cifs_tcon,
49824 tcon_list);
49825 - atomic_set(&tcon->num_smbs_sent, 0);
49826 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49827 if (server->ops->clear_stats)
49828 server->ops->clear_stats(tcon);
49829 }
49830 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49831 smBufAllocCount.counter, cifs_min_small);
49832 #ifdef CONFIG_CIFS_STATS2
49833 seq_printf(m, "Total Large %d Small %d Allocations\n",
49834 - atomic_read(&totBufAllocCount),
49835 - atomic_read(&totSmBufAllocCount));
49836 + atomic_read_unchecked(&totBufAllocCount),
49837 + atomic_read_unchecked(&totSmBufAllocCount));
49838 #endif /* CONFIG_CIFS_STATS2 */
49839
49840 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49841 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49842 if (tcon->need_reconnect)
49843 seq_puts(m, "\tDISCONNECTED ");
49844 seq_printf(m, "\nSMBs: %d",
49845 - atomic_read(&tcon->num_smbs_sent));
49846 + atomic_read_unchecked(&tcon->num_smbs_sent));
49847 if (server->ops->print_stats)
49848 server->ops->print_stats(m, tcon);
49849 }
49850 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49851 index b9db388..9a73d6d 100644
49852 --- a/fs/cifs/cifsfs.c
49853 +++ b/fs/cifs/cifsfs.c
49854 @@ -1026,7 +1026,7 @@ cifs_init_request_bufs(void)
49855 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49856 cifs_req_cachep = kmem_cache_create("cifs_request",
49857 CIFSMaxBufSize + max_hdr_size, 0,
49858 - SLAB_HWCACHE_ALIGN, NULL);
49859 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49860 if (cifs_req_cachep == NULL)
49861 return -ENOMEM;
49862
49863 @@ -1053,7 +1053,7 @@ cifs_init_request_bufs(void)
49864 efficient to alloc 1 per page off the slab compared to 17K (5page)
49865 alloc of large cifs buffers even when page debugging is on */
49866 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49867 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49868 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49869 NULL);
49870 if (cifs_sm_req_cachep == NULL) {
49871 mempool_destroy(cifs_req_poolp);
49872 @@ -1138,8 +1138,8 @@ init_cifs(void)
49873 atomic_set(&bufAllocCount, 0);
49874 atomic_set(&smBufAllocCount, 0);
49875 #ifdef CONFIG_CIFS_STATS2
49876 - atomic_set(&totBufAllocCount, 0);
49877 - atomic_set(&totSmBufAllocCount, 0);
49878 + atomic_set_unchecked(&totBufAllocCount, 0);
49879 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49880 #endif /* CONFIG_CIFS_STATS2 */
49881
49882 atomic_set(&midCount, 0);
49883 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49884 index e6899ce..d6b2920 100644
49885 --- a/fs/cifs/cifsglob.h
49886 +++ b/fs/cifs/cifsglob.h
49887 @@ -751,35 +751,35 @@ struct cifs_tcon {
49888 __u16 Flags; /* optional support bits */
49889 enum statusEnum tidStatus;
49890 #ifdef CONFIG_CIFS_STATS
49891 - atomic_t num_smbs_sent;
49892 + atomic_unchecked_t num_smbs_sent;
49893 union {
49894 struct {
49895 - atomic_t num_writes;
49896 - atomic_t num_reads;
49897 - atomic_t num_flushes;
49898 - atomic_t num_oplock_brks;
49899 - atomic_t num_opens;
49900 - atomic_t num_closes;
49901 - atomic_t num_deletes;
49902 - atomic_t num_mkdirs;
49903 - atomic_t num_posixopens;
49904 - atomic_t num_posixmkdirs;
49905 - atomic_t num_rmdirs;
49906 - atomic_t num_renames;
49907 - atomic_t num_t2renames;
49908 - atomic_t num_ffirst;
49909 - atomic_t num_fnext;
49910 - atomic_t num_fclose;
49911 - atomic_t num_hardlinks;
49912 - atomic_t num_symlinks;
49913 - atomic_t num_locks;
49914 - atomic_t num_acl_get;
49915 - atomic_t num_acl_set;
49916 + atomic_unchecked_t num_writes;
49917 + atomic_unchecked_t num_reads;
49918 + atomic_unchecked_t num_flushes;
49919 + atomic_unchecked_t num_oplock_brks;
49920 + atomic_unchecked_t num_opens;
49921 + atomic_unchecked_t num_closes;
49922 + atomic_unchecked_t num_deletes;
49923 + atomic_unchecked_t num_mkdirs;
49924 + atomic_unchecked_t num_posixopens;
49925 + atomic_unchecked_t num_posixmkdirs;
49926 + atomic_unchecked_t num_rmdirs;
49927 + atomic_unchecked_t num_renames;
49928 + atomic_unchecked_t num_t2renames;
49929 + atomic_unchecked_t num_ffirst;
49930 + atomic_unchecked_t num_fnext;
49931 + atomic_unchecked_t num_fclose;
49932 + atomic_unchecked_t num_hardlinks;
49933 + atomic_unchecked_t num_symlinks;
49934 + atomic_unchecked_t num_locks;
49935 + atomic_unchecked_t num_acl_get;
49936 + atomic_unchecked_t num_acl_set;
49937 } cifs_stats;
49938 #ifdef CONFIG_CIFS_SMB2
49939 struct {
49940 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49941 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49942 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49943 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49944 } smb2_stats;
49945 #endif /* CONFIG_CIFS_SMB2 */
49946 } stats;
49947 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49948 }
49949
49950 #ifdef CONFIG_CIFS_STATS
49951 -#define cifs_stats_inc atomic_inc
49952 +#define cifs_stats_inc atomic_inc_unchecked
49953
49954 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49955 unsigned int bytes)
49956 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49957 /* Various Debug counters */
49958 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49959 #ifdef CONFIG_CIFS_STATS2
49960 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49961 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49962 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49963 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49964 #endif
49965 GLOBAL_EXTERN atomic_t smBufAllocCount;
49966 GLOBAL_EXTERN atomic_t midCount;
49967 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49968 index 51dc2fb..1e12a33 100644
49969 --- a/fs/cifs/link.c
49970 +++ b/fs/cifs/link.c
49971 @@ -616,7 +616,7 @@ symlink_exit:
49972
49973 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49974 {
49975 - char *p = nd_get_link(nd);
49976 + const char *p = nd_get_link(nd);
49977 if (!IS_ERR(p))
49978 kfree(p);
49979 }
49980 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49981 index 3a00c0d..42d901c 100644
49982 --- a/fs/cifs/misc.c
49983 +++ b/fs/cifs/misc.c
49984 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49985 memset(ret_buf, 0, buf_size + 3);
49986 atomic_inc(&bufAllocCount);
49987 #ifdef CONFIG_CIFS_STATS2
49988 - atomic_inc(&totBufAllocCount);
49989 + atomic_inc_unchecked(&totBufAllocCount);
49990 #endif /* CONFIG_CIFS_STATS2 */
49991 }
49992
49993 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49994 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49995 atomic_inc(&smBufAllocCount);
49996 #ifdef CONFIG_CIFS_STATS2
49997 - atomic_inc(&totSmBufAllocCount);
49998 + atomic_inc_unchecked(&totSmBufAllocCount);
49999 #endif /* CONFIG_CIFS_STATS2 */
50000
50001 }
50002 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
50003 index 47bc5a8..10decbe 100644
50004 --- a/fs/cifs/smb1ops.c
50005 +++ b/fs/cifs/smb1ops.c
50006 @@ -586,27 +586,27 @@ static void
50007 cifs_clear_stats(struct cifs_tcon *tcon)
50008 {
50009 #ifdef CONFIG_CIFS_STATS
50010 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
50011 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
50012 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
50013 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50014 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
50015 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
50016 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50017 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
50018 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
50019 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
50020 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
50021 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
50022 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
50023 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
50024 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
50025 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
50026 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
50027 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
50028 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
50029 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
50030 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50031 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50032 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50033 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50034 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50035 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50036 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50037 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50038 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50039 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50040 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50041 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50042 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50043 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50044 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50045 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50046 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50047 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50048 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50049 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50050 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50051 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50052 #endif
50053 }
50054
50055 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50056 {
50057 #ifdef CONFIG_CIFS_STATS
50058 seq_printf(m, " Oplocks breaks: %d",
50059 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50060 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50061 seq_printf(m, "\nReads: %d Bytes: %llu",
50062 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50063 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50064 (long long)(tcon->bytes_read));
50065 seq_printf(m, "\nWrites: %d Bytes: %llu",
50066 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50067 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50068 (long long)(tcon->bytes_written));
50069 seq_printf(m, "\nFlushes: %d",
50070 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50071 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50072 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50073 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50074 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50075 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50076 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50077 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50078 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50079 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50080 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50081 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50082 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50083 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50084 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50085 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50086 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50087 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50088 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50089 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50090 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50091 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50092 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50093 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50094 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50095 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50096 seq_printf(m, "\nRenames: %d T2 Renames %d",
50097 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50098 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50099 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50100 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50101 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50102 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50103 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50104 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50105 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50106 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50107 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50108 #endif
50109 }
50110
50111 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50112 index bceffe7..cd1ae59 100644
50113 --- a/fs/cifs/smb2ops.c
50114 +++ b/fs/cifs/smb2ops.c
50115 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50116 #ifdef CONFIG_CIFS_STATS
50117 int i;
50118 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50119 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50120 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50121 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50122 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50123 }
50124 #endif
50125 }
50126 @@ -284,66 +284,66 @@ static void
50127 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50128 {
50129 #ifdef CONFIG_CIFS_STATS
50130 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50131 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50132 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50133 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50134 seq_printf(m, "\nNegotiates: %d sent %d failed",
50135 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50136 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50137 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50138 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50139 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50140 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50141 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50142 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50143 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50144 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50145 seq_printf(m, "\nLogoffs: %d sent %d failed",
50146 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50147 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50148 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50149 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50150 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50151 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50152 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50153 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50154 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50155 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50156 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50157 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50158 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50159 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50160 seq_printf(m, "\nCreates: %d sent %d failed",
50161 - atomic_read(&sent[SMB2_CREATE_HE]),
50162 - atomic_read(&failed[SMB2_CREATE_HE]));
50163 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50164 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50165 seq_printf(m, "\nCloses: %d sent %d failed",
50166 - atomic_read(&sent[SMB2_CLOSE_HE]),
50167 - atomic_read(&failed[SMB2_CLOSE_HE]));
50168 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50169 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50170 seq_printf(m, "\nFlushes: %d sent %d failed",
50171 - atomic_read(&sent[SMB2_FLUSH_HE]),
50172 - atomic_read(&failed[SMB2_FLUSH_HE]));
50173 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50174 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50175 seq_printf(m, "\nReads: %d sent %d failed",
50176 - atomic_read(&sent[SMB2_READ_HE]),
50177 - atomic_read(&failed[SMB2_READ_HE]));
50178 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50179 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50180 seq_printf(m, "\nWrites: %d sent %d failed",
50181 - atomic_read(&sent[SMB2_WRITE_HE]),
50182 - atomic_read(&failed[SMB2_WRITE_HE]));
50183 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50184 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50185 seq_printf(m, "\nLocks: %d sent %d failed",
50186 - atomic_read(&sent[SMB2_LOCK_HE]),
50187 - atomic_read(&failed[SMB2_LOCK_HE]));
50188 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50189 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50190 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50191 - atomic_read(&sent[SMB2_IOCTL_HE]),
50192 - atomic_read(&failed[SMB2_IOCTL_HE]));
50193 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50194 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50195 seq_printf(m, "\nCancels: %d sent %d failed",
50196 - atomic_read(&sent[SMB2_CANCEL_HE]),
50197 - atomic_read(&failed[SMB2_CANCEL_HE]));
50198 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50199 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50200 seq_printf(m, "\nEchos: %d sent %d failed",
50201 - atomic_read(&sent[SMB2_ECHO_HE]),
50202 - atomic_read(&failed[SMB2_ECHO_HE]));
50203 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50204 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50205 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50206 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50207 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50208 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50209 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50210 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50211 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50212 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50213 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50214 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50215 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50216 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50217 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50218 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50219 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50220 seq_printf(m, "\nSetInfos: %d sent %d failed",
50221 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50222 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50223 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50224 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50225 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50226 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50227 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50228 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50229 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50230 #endif
50231 }
50232
50233 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50234 index 41d9d07..dbb4772 100644
50235 --- a/fs/cifs/smb2pdu.c
50236 +++ b/fs/cifs/smb2pdu.c
50237 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50238 default:
50239 cERROR(1, "info level %u isn't supported",
50240 srch_inf->info_level);
50241 - rc = -EINVAL;
50242 - goto qdir_exit;
50243 + return -EINVAL;
50244 }
50245
50246 req->FileIndex = cpu_to_le32(index);
50247 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50248 index 958ae0e..505c9d0 100644
50249 --- a/fs/coda/cache.c
50250 +++ b/fs/coda/cache.c
50251 @@ -24,7 +24,7 @@
50252 #include "coda_linux.h"
50253 #include "coda_cache.h"
50254
50255 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50256 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50257
50258 /* replace or extend an acl cache hit */
50259 void coda_cache_enter(struct inode *inode, int mask)
50260 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50261 struct coda_inode_info *cii = ITOC(inode);
50262
50263 spin_lock(&cii->c_lock);
50264 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50265 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50266 if (cii->c_uid != current_fsuid()) {
50267 cii->c_uid = current_fsuid();
50268 cii->c_cached_perm = mask;
50269 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50270 {
50271 struct coda_inode_info *cii = ITOC(inode);
50272 spin_lock(&cii->c_lock);
50273 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50274 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50275 spin_unlock(&cii->c_lock);
50276 }
50277
50278 /* remove all acl caches */
50279 void coda_cache_clear_all(struct super_block *sb)
50280 {
50281 - atomic_inc(&permission_epoch);
50282 + atomic_inc_unchecked(&permission_epoch);
50283 }
50284
50285
50286 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50287 spin_lock(&cii->c_lock);
50288 hit = (mask & cii->c_cached_perm) == mask &&
50289 cii->c_uid == current_fsuid() &&
50290 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50291 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50292 spin_unlock(&cii->c_lock);
50293
50294 return hit;
50295 diff --git a/fs/compat.c b/fs/compat.c
50296 index a06dcbc..dacb6d3 100644
50297 --- a/fs/compat.c
50298 +++ b/fs/compat.c
50299 @@ -54,7 +54,7 @@
50300 #include <asm/ioctls.h>
50301 #include "internal.h"
50302
50303 -int compat_log = 1;
50304 +int compat_log = 0;
50305
50306 int compat_printk(const char *fmt, ...)
50307 {
50308 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50309
50310 set_fs(KERNEL_DS);
50311 /* The __user pointer cast is valid because of the set_fs() */
50312 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50313 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50314 set_fs(oldfs);
50315 /* truncating is ok because it's a user address */
50316 if (!ret)
50317 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50318 goto out;
50319
50320 ret = -EINVAL;
50321 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50322 + if (nr_segs > UIO_MAXIOV)
50323 goto out;
50324 if (nr_segs > fast_segs) {
50325 ret = -ENOMEM;
50326 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
50327
50328 struct compat_readdir_callback {
50329 struct compat_old_linux_dirent __user *dirent;
50330 + struct file * file;
50331 int result;
50332 };
50333
50334 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50335 buf->result = -EOVERFLOW;
50336 return -EOVERFLOW;
50337 }
50338 +
50339 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50340 + return 0;
50341 +
50342 buf->result++;
50343 dirent = buf->dirent;
50344 if (!access_ok(VERIFY_WRITE, dirent,
50345 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50346
50347 buf.result = 0;
50348 buf.dirent = dirent;
50349 + buf.file = f.file;
50350
50351 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50352 if (buf.result)
50353 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
50354 struct compat_getdents_callback {
50355 struct compat_linux_dirent __user *current_dir;
50356 struct compat_linux_dirent __user *previous;
50357 + struct file * file;
50358 int count;
50359 int error;
50360 };
50361 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50362 buf->error = -EOVERFLOW;
50363 return -EOVERFLOW;
50364 }
50365 +
50366 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50367 + return 0;
50368 +
50369 dirent = buf->previous;
50370 if (dirent) {
50371 if (__put_user(offset, &dirent->d_off))
50372 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50373 buf.previous = NULL;
50374 buf.count = count;
50375 buf.error = 0;
50376 + buf.file = f.file;
50377
50378 error = vfs_readdir(f.file, compat_filldir, &buf);
50379 if (error >= 0)
50380 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50381 struct compat_getdents_callback64 {
50382 struct linux_dirent64 __user *current_dir;
50383 struct linux_dirent64 __user *previous;
50384 + struct file * file;
50385 int count;
50386 int error;
50387 };
50388 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50389 buf->error = -EINVAL; /* only used if we fail.. */
50390 if (reclen > buf->count)
50391 return -EINVAL;
50392 +
50393 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50394 + return 0;
50395 +
50396 dirent = buf->previous;
50397
50398 if (dirent) {
50399 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(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_filldir64, &buf);
50406 if (error >= 0)
50407 error = buf.error;
50408 lastdirent = buf.previous;
50409 if (lastdirent) {
50410 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50411 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50412 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50413 error = -EFAULT;
50414 else
50415 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50416 index a81147e..20bf2b5 100644
50417 --- a/fs/compat_binfmt_elf.c
50418 +++ b/fs/compat_binfmt_elf.c
50419 @@ -30,11 +30,13 @@
50420 #undef elf_phdr
50421 #undef elf_shdr
50422 #undef elf_note
50423 +#undef elf_dyn
50424 #undef elf_addr_t
50425 #define elfhdr elf32_hdr
50426 #define elf_phdr elf32_phdr
50427 #define elf_shdr elf32_shdr
50428 #define elf_note elf32_note
50429 +#define elf_dyn Elf32_Dyn
50430 #define elf_addr_t Elf32_Addr
50431
50432 /*
50433 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50434 index e2f57a0..3c78771 100644
50435 --- a/fs/compat_ioctl.c
50436 +++ b/fs/compat_ioctl.c
50437 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50438 return -EFAULT;
50439 if (__get_user(udata, &ss32->iomem_base))
50440 return -EFAULT;
50441 - ss.iomem_base = compat_ptr(udata);
50442 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50443 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50444 __get_user(ss.port_high, &ss32->port_high))
50445 return -EFAULT;
50446 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
50447 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50448 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50449 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50450 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50451 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50452 return -EFAULT;
50453
50454 return ioctl_preallocate(file, p);
50455 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50456 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50457 {
50458 unsigned int a, b;
50459 - a = *(unsigned int *)p;
50460 - b = *(unsigned int *)q;
50461 + a = *(const unsigned int *)p;
50462 + b = *(const unsigned int *)q;
50463 if (a > b)
50464 return 1;
50465 if (a < b)
50466 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50467 index 712b10f..c33c4ca 100644
50468 --- a/fs/configfs/dir.c
50469 +++ b/fs/configfs/dir.c
50470 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
50471 static int configfs_depend_prep(struct dentry *origin,
50472 struct config_item *target)
50473 {
50474 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
50475 + struct configfs_dirent *child_sd, *sd;
50476 int ret = 0;
50477
50478 - BUG_ON(!origin || !sd);
50479 + BUG_ON(!origin || !origin->d_fsdata);
50480 + sd = origin->d_fsdata;
50481
50482 if (sd->s_element == target) /* Boo-yah */
50483 goto out;
50484 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50485 }
50486 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50487 struct configfs_dirent *next;
50488 - const char * name;
50489 + const unsigned char * name;
50490 + char d_name[sizeof(next->s_dentry->d_iname)];
50491 int len;
50492 struct inode *inode = NULL;
50493
50494 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50495 continue;
50496
50497 name = configfs_get_name(next);
50498 - len = strlen(name);
50499 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50500 + len = next->s_dentry->d_name.len;
50501 + memcpy(d_name, name, len);
50502 + name = d_name;
50503 + } else
50504 + len = strlen(name);
50505
50506 /*
50507 * We'll have a dentry and an inode for
50508 diff --git a/fs/coredump.c b/fs/coredump.c
50509 index 1774932..5812106 100644
50510 --- a/fs/coredump.c
50511 +++ b/fs/coredump.c
50512 @@ -52,7 +52,7 @@ struct core_name {
50513 char *corename;
50514 int used, size;
50515 };
50516 -static atomic_t call_count = ATOMIC_INIT(1);
50517 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50518
50519 /* The maximal length of core_pattern is also specified in sysctl.c */
50520
50521 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50522 {
50523 char *old_corename = cn->corename;
50524
50525 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50526 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50527 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50528
50529 if (!cn->corename) {
50530 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50531 int pid_in_pattern = 0;
50532 int err = 0;
50533
50534 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50535 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50536 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50537 cn->used = 0;
50538
50539 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50540 pipe = file->f_path.dentry->d_inode->i_pipe;
50541
50542 pipe_lock(pipe);
50543 - pipe->readers++;
50544 - pipe->writers--;
50545 + atomic_inc(&pipe->readers);
50546 + atomic_dec(&pipe->writers);
50547
50548 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50549 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50550 wake_up_interruptible_sync(&pipe->wait);
50551 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50552 pipe_wait(pipe);
50553 }
50554
50555 - pipe->readers--;
50556 - pipe->writers++;
50557 + atomic_dec(&pipe->readers);
50558 + atomic_inc(&pipe->writers);
50559 pipe_unlock(pipe);
50560
50561 }
50562 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50563 int ispipe;
50564 struct files_struct *displaced;
50565 bool need_nonrelative = false;
50566 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50567 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50568 + long signr = siginfo->si_signo;
50569 struct coredump_params cprm = {
50570 .siginfo = siginfo,
50571 .regs = signal_pt_regs(),
50572 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50573 .mm_flags = mm->flags,
50574 };
50575
50576 - audit_core_dumps(siginfo->si_signo);
50577 + audit_core_dumps(signr);
50578 +
50579 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50580 + gr_handle_brute_attach(cprm.mm_flags);
50581
50582 binfmt = mm->binfmt;
50583 if (!binfmt || !binfmt->core_dump)
50584 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50585 need_nonrelative = true;
50586 }
50587
50588 - retval = coredump_wait(siginfo->si_signo, &core_state);
50589 + retval = coredump_wait(signr, &core_state);
50590 if (retval < 0)
50591 goto fail_creds;
50592
50593 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50594 }
50595 cprm.limit = RLIM_INFINITY;
50596
50597 - dump_count = atomic_inc_return(&core_dump_count);
50598 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50599 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50600 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50601 task_tgid_vnr(current), current->comm);
50602 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50603 } else {
50604 struct inode *inode;
50605
50606 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50607 +
50608 if (cprm.limit < binfmt->min_coredump)
50609 goto fail_unlock;
50610
50611 @@ -640,7 +646,7 @@ close_fail:
50612 filp_close(cprm.file, NULL);
50613 fail_dropcount:
50614 if (ispipe)
50615 - atomic_dec(&core_dump_count);
50616 + atomic_dec_unchecked(&core_dump_count);
50617 fail_unlock:
50618 kfree(cn.corename);
50619 fail_corename:
50620 @@ -659,7 +665,7 @@ fail:
50621 */
50622 int dump_write(struct file *file, const void *addr, int nr)
50623 {
50624 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50625 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50626 }
50627 EXPORT_SYMBOL(dump_write);
50628
50629 diff --git a/fs/dcache.c b/fs/dcache.c
50630 index c3bbf85..5b71101 100644
50631 --- a/fs/dcache.c
50632 +++ b/fs/dcache.c
50633 @@ -3139,7 +3139,7 @@ void __init vfs_caches_init(unsigned long mempages)
50634 mempages -= reserve;
50635
50636 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50637 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50638 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50639
50640 dcache_init();
50641 inode_init();
50642 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50643 index a5f12b7..4ee8a6f 100644
50644 --- a/fs/debugfs/inode.c
50645 +++ b/fs/debugfs/inode.c
50646 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50647 */
50648 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50649 {
50650 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50651 + return __create_file(name, S_IFDIR | S_IRWXU,
50652 +#else
50653 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50654 +#endif
50655 parent, NULL, NULL);
50656 }
50657 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50658 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50659 index cc7709e..7e7211f 100644
50660 --- a/fs/ecryptfs/inode.c
50661 +++ b/fs/ecryptfs/inode.c
50662 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50663 old_fs = get_fs();
50664 set_fs(get_ds());
50665 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50666 - (char __user *)lower_buf,
50667 + (char __force_user *)lower_buf,
50668 PATH_MAX);
50669 set_fs(old_fs);
50670 if (rc < 0)
50671 @@ -706,7 +706,7 @@ out:
50672 static void
50673 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50674 {
50675 - char *buf = nd_get_link(nd);
50676 + const char *buf = nd_get_link(nd);
50677 if (!IS_ERR(buf)) {
50678 /* Free the char* */
50679 kfree(buf);
50680 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50681 index 412e6ed..d8263e8 100644
50682 --- a/fs/ecryptfs/miscdev.c
50683 +++ b/fs/ecryptfs/miscdev.c
50684 @@ -80,13 +80,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50685 int rc;
50686
50687 mutex_lock(&ecryptfs_daemon_hash_mux);
50688 - rc = try_module_get(THIS_MODULE);
50689 - if (rc == 0) {
50690 - rc = -EIO;
50691 - printk(KERN_ERR "%s: Error attempting to increment module use "
50692 - "count; rc = [%d]\n", __func__, rc);
50693 - goto out_unlock_daemon_list;
50694 - }
50695 rc = ecryptfs_find_daemon_by_euid(&daemon);
50696 if (!rc) {
50697 rc = -EINVAL;
50698 @@ -96,7 +89,7 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50699 if (rc) {
50700 printk(KERN_ERR "%s: Error attempting to spawn daemon; "
50701 "rc = [%d]\n", __func__, rc);
50702 - goto out_module_put_unlock_daemon_list;
50703 + goto out_unlock_daemon_list;
50704 }
50705 mutex_lock(&daemon->mux);
50706 if (daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN) {
50707 @@ -108,9 +101,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50708 atomic_inc(&ecryptfs_num_miscdev_opens);
50709 out_unlock_daemon:
50710 mutex_unlock(&daemon->mux);
50711 -out_module_put_unlock_daemon_list:
50712 - if (rc)
50713 - module_put(THIS_MODULE);
50714 out_unlock_daemon_list:
50715 mutex_unlock(&ecryptfs_daemon_hash_mux);
50716 return rc;
50717 @@ -147,7 +137,6 @@ ecryptfs_miscdev_release(struct inode *inode, struct file *file)
50718 "bug.\n", __func__, rc);
50719 BUG();
50720 }
50721 - module_put(THIS_MODULE);
50722 return rc;
50723 }
50724
50725 @@ -315,7 +304,7 @@ check_list:
50726 goto out_unlock_msg_ctx;
50727 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50728 if (msg_ctx->msg) {
50729 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50730 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50731 goto out_unlock_msg_ctx;
50732 i += packet_length_size;
50733 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50734 @@ -471,6 +460,7 @@ out_free:
50735
50736
50737 static const struct file_operations ecryptfs_miscdev_fops = {
50738 + .owner = THIS_MODULE,
50739 .open = ecryptfs_miscdev_open,
50740 .poll = ecryptfs_miscdev_poll,
50741 .read = ecryptfs_miscdev_read,
50742 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50743 index b2a34a1..162fa69 100644
50744 --- a/fs/ecryptfs/read_write.c
50745 +++ b/fs/ecryptfs/read_write.c
50746 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
50747 return -EIO;
50748 fs_save = get_fs();
50749 set_fs(get_ds());
50750 - rc = vfs_write(lower_file, data, size, &offset);
50751 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
50752 set_fs(fs_save);
50753 mark_inode_dirty_sync(ecryptfs_inode);
50754 return rc;
50755 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50756 return -EIO;
50757 fs_save = get_fs();
50758 set_fs(get_ds());
50759 - rc = vfs_read(lower_file, data, size, &offset);
50760 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50761 set_fs(fs_save);
50762 return rc;
50763 }
50764 diff --git a/fs/exec.c b/fs/exec.c
50765 index 20df02c..c9a5bc9 100644
50766 --- a/fs/exec.c
50767 +++ b/fs/exec.c
50768 @@ -55,6 +55,17 @@
50769 #include <linux/pipe_fs_i.h>
50770 #include <linux/oom.h>
50771 #include <linux/compat.h>
50772 +#include <linux/random.h>
50773 +#include <linux/seq_file.h>
50774 +#include <linux/coredump.h>
50775 +#include <linux/mman.h>
50776 +
50777 +#ifdef CONFIG_PAX_REFCOUNT
50778 +#include <linux/kallsyms.h>
50779 +#include <linux/kdebug.h>
50780 +#endif
50781 +
50782 +#include <trace/events/fs.h>
50783
50784 #include <asm/uaccess.h>
50785 #include <asm/mmu_context.h>
50786 @@ -66,6 +77,18 @@
50787
50788 #include <trace/events/sched.h>
50789
50790 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50791 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50792 +{
50793 + 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");
50794 +}
50795 +#endif
50796 +
50797 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50798 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50799 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50800 +#endif
50801 +
50802 int suid_dumpable = 0;
50803
50804 static LIST_HEAD(formats);
50805 @@ -75,8 +98,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50806 {
50807 BUG_ON(!fmt);
50808 write_lock(&binfmt_lock);
50809 - insert ? list_add(&fmt->lh, &formats) :
50810 - list_add_tail(&fmt->lh, &formats);
50811 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50812 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50813 write_unlock(&binfmt_lock);
50814 }
50815
50816 @@ -85,7 +108,7 @@ EXPORT_SYMBOL(__register_binfmt);
50817 void unregister_binfmt(struct linux_binfmt * fmt)
50818 {
50819 write_lock(&binfmt_lock);
50820 - list_del(&fmt->lh);
50821 + pax_list_del((struct list_head *)&fmt->lh);
50822 write_unlock(&binfmt_lock);
50823 }
50824
50825 @@ -180,18 +203,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50826 int write)
50827 {
50828 struct page *page;
50829 - int ret;
50830
50831 -#ifdef CONFIG_STACK_GROWSUP
50832 - if (write) {
50833 - ret = expand_downwards(bprm->vma, pos);
50834 - if (ret < 0)
50835 - return NULL;
50836 - }
50837 -#endif
50838 - ret = get_user_pages(current, bprm->mm, pos,
50839 - 1, write, 1, &page, NULL);
50840 - if (ret <= 0)
50841 + if (0 > expand_downwards(bprm->vma, pos))
50842 + return NULL;
50843 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50844 return NULL;
50845
50846 if (write) {
50847 @@ -207,6 +222,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50848 if (size <= ARG_MAX)
50849 return page;
50850
50851 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50852 + // only allow 512KB for argv+env on suid/sgid binaries
50853 + // to prevent easy ASLR exhaustion
50854 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50855 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50856 + (size > (512 * 1024))) {
50857 + put_page(page);
50858 + return NULL;
50859 + }
50860 +#endif
50861 +
50862 /*
50863 * Limit to 1/4-th the stack size for the argv+env strings.
50864 * This ensures that:
50865 @@ -266,6 +292,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50866 vma->vm_end = STACK_TOP_MAX;
50867 vma->vm_start = vma->vm_end - PAGE_SIZE;
50868 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50869 +
50870 +#ifdef CONFIG_PAX_SEGMEXEC
50871 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50872 +#endif
50873 +
50874 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50875 INIT_LIST_HEAD(&vma->anon_vma_chain);
50876
50877 @@ -276,6 +307,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50878 mm->stack_vm = mm->total_vm = 1;
50879 up_write(&mm->mmap_sem);
50880 bprm->p = vma->vm_end - sizeof(void *);
50881 +
50882 +#ifdef CONFIG_PAX_RANDUSTACK
50883 + if (randomize_va_space)
50884 + bprm->p ^= random32() & ~PAGE_MASK;
50885 +#endif
50886 +
50887 return 0;
50888 err:
50889 up_write(&mm->mmap_sem);
50890 @@ -396,7 +433,7 @@ struct user_arg_ptr {
50891 } ptr;
50892 };
50893
50894 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50895 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50896 {
50897 const char __user *native;
50898
50899 @@ -405,14 +442,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50900 compat_uptr_t compat;
50901
50902 if (get_user(compat, argv.ptr.compat + nr))
50903 - return ERR_PTR(-EFAULT);
50904 + return (const char __force_user *)ERR_PTR(-EFAULT);
50905
50906 return compat_ptr(compat);
50907 }
50908 #endif
50909
50910 if (get_user(native, argv.ptr.native + nr))
50911 - return ERR_PTR(-EFAULT);
50912 + return (const char __force_user *)ERR_PTR(-EFAULT);
50913
50914 return native;
50915 }
50916 @@ -431,7 +468,7 @@ static int count(struct user_arg_ptr argv, int max)
50917 if (!p)
50918 break;
50919
50920 - if (IS_ERR(p))
50921 + if (IS_ERR((const char __force_kernel *)p))
50922 return -EFAULT;
50923
50924 if (i >= max)
50925 @@ -466,7 +503,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50926
50927 ret = -EFAULT;
50928 str = get_user_arg_ptr(argv, argc);
50929 - if (IS_ERR(str))
50930 + if (IS_ERR((const char __force_kernel *)str))
50931 goto out;
50932
50933 len = strnlen_user(str, MAX_ARG_STRLEN);
50934 @@ -548,7 +585,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50935 int r;
50936 mm_segment_t oldfs = get_fs();
50937 struct user_arg_ptr argv = {
50938 - .ptr.native = (const char __user *const __user *)__argv,
50939 + .ptr.native = (const char __force_user *const __force_user *)__argv,
50940 };
50941
50942 set_fs(KERNEL_DS);
50943 @@ -583,7 +620,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50944 unsigned long new_end = old_end - shift;
50945 struct mmu_gather tlb;
50946
50947 - BUG_ON(new_start > new_end);
50948 + if (new_start >= new_end || new_start < mmap_min_addr)
50949 + return -ENOMEM;
50950
50951 /*
50952 * ensure there are no vmas between where we want to go
50953 @@ -592,6 +630,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50954 if (vma != find_vma(mm, new_start))
50955 return -EFAULT;
50956
50957 +#ifdef CONFIG_PAX_SEGMEXEC
50958 + BUG_ON(pax_find_mirror_vma(vma));
50959 +#endif
50960 +
50961 /*
50962 * cover the whole range: [new_start, old_end)
50963 */
50964 @@ -672,10 +714,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50965 stack_top = arch_align_stack(stack_top);
50966 stack_top = PAGE_ALIGN(stack_top);
50967
50968 - if (unlikely(stack_top < mmap_min_addr) ||
50969 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50970 - return -ENOMEM;
50971 -
50972 stack_shift = vma->vm_end - stack_top;
50973
50974 bprm->p -= stack_shift;
50975 @@ -687,8 +725,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50976 bprm->exec -= stack_shift;
50977
50978 down_write(&mm->mmap_sem);
50979 +
50980 + /* Move stack pages down in memory. */
50981 + if (stack_shift) {
50982 + ret = shift_arg_pages(vma, stack_shift);
50983 + if (ret)
50984 + goto out_unlock;
50985 + }
50986 +
50987 vm_flags = VM_STACK_FLAGS;
50988
50989 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50990 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50991 + vm_flags &= ~VM_EXEC;
50992 +
50993 +#ifdef CONFIG_PAX_MPROTECT
50994 + if (mm->pax_flags & MF_PAX_MPROTECT)
50995 + vm_flags &= ~VM_MAYEXEC;
50996 +#endif
50997 +
50998 + }
50999 +#endif
51000 +
51001 /*
51002 * Adjust stack execute permissions; explicitly enable for
51003 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
51004 @@ -707,13 +765,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51005 goto out_unlock;
51006 BUG_ON(prev != vma);
51007
51008 - /* Move stack pages down in memory. */
51009 - if (stack_shift) {
51010 - ret = shift_arg_pages(vma, stack_shift);
51011 - if (ret)
51012 - goto out_unlock;
51013 - }
51014 -
51015 /* mprotect_fixup is overkill to remove the temporary stack flags */
51016 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
51017
51018 @@ -737,6 +788,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
51019 #endif
51020 current->mm->start_stack = bprm->p;
51021 ret = expand_stack(vma, stack_base);
51022 +
51023 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
51024 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
51025 + unsigned long size, flags, vm_flags;
51026 +
51027 + size = STACK_TOP - vma->vm_end;
51028 + flags = MAP_FIXED | MAP_PRIVATE;
51029 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
51030 +
51031 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
51032 +
51033 +#ifdef CONFIG_X86
51034 + if (!ret) {
51035 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
51036 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), flags, vm_flags, 0);
51037 + }
51038 +#endif
51039 +
51040 + }
51041 +#endif
51042 +
51043 if (ret)
51044 ret = -EFAULT;
51045
51046 @@ -772,6 +844,8 @@ struct file *open_exec(const char *name)
51047
51048 fsnotify_open(file);
51049
51050 + trace_open_exec(name);
51051 +
51052 err = deny_write_access(file);
51053 if (err)
51054 goto exit;
51055 @@ -795,7 +869,7 @@ int kernel_read(struct file *file, loff_t offset,
51056 old_fs = get_fs();
51057 set_fs(get_ds());
51058 /* The cast to a user pointer is valid due to the set_fs() */
51059 - result = vfs_read(file, (void __user *)addr, count, &pos);
51060 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51061 set_fs(old_fs);
51062 return result;
51063 }
51064 @@ -1247,7 +1321,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51065 }
51066 rcu_read_unlock();
51067
51068 - if (p->fs->users > n_fs) {
51069 + if (atomic_read(&p->fs->users) > n_fs) {
51070 bprm->unsafe |= LSM_UNSAFE_SHARE;
51071 } else {
51072 res = -EAGAIN;
51073 @@ -1447,6 +1521,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51074
51075 EXPORT_SYMBOL(search_binary_handler);
51076
51077 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51078 +static DEFINE_PER_CPU(u64, exec_counter);
51079 +static int __init init_exec_counters(void)
51080 +{
51081 + unsigned int cpu;
51082 +
51083 + for_each_possible_cpu(cpu) {
51084 + per_cpu(exec_counter, cpu) = (u64)cpu;
51085 + }
51086 +
51087 + return 0;
51088 +}
51089 +early_initcall(init_exec_counters);
51090 +static inline void increment_exec_counter(void)
51091 +{
51092 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51093 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51094 +}
51095 +#else
51096 +static inline void increment_exec_counter(void) {}
51097 +#endif
51098 +
51099 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51100 + struct user_arg_ptr argv);
51101 +
51102 /*
51103 * sys_execve() executes a new program.
51104 */
51105 @@ -1454,6 +1553,11 @@ static int do_execve_common(const char *filename,
51106 struct user_arg_ptr argv,
51107 struct user_arg_ptr envp)
51108 {
51109 +#ifdef CONFIG_GRKERNSEC
51110 + struct file *old_exec_file;
51111 + struct acl_subject_label *old_acl;
51112 + struct rlimit old_rlim[RLIM_NLIMITS];
51113 +#endif
51114 struct linux_binprm *bprm;
51115 struct file *file;
51116 struct files_struct *displaced;
51117 @@ -1461,6 +1565,8 @@ static int do_execve_common(const char *filename,
51118 int retval;
51119 const struct cred *cred = current_cred();
51120
51121 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
51122 +
51123 /*
51124 * We move the actual failure in case of RLIMIT_NPROC excess from
51125 * set*uid() to execve() because too many poorly written programs
51126 @@ -1501,12 +1607,27 @@ static int do_execve_common(const char *filename,
51127 if (IS_ERR(file))
51128 goto out_unmark;
51129
51130 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51131 + retval = -EPERM;
51132 + goto out_file;
51133 + }
51134 +
51135 sched_exec();
51136
51137 bprm->file = file;
51138 bprm->filename = filename;
51139 bprm->interp = filename;
51140
51141 + if (gr_process_user_ban()) {
51142 + retval = -EPERM;
51143 + goto out_file;
51144 + }
51145 +
51146 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
51147 + retval = -EACCES;
51148 + goto out_file;
51149 + }
51150 +
51151 retval = bprm_mm_init(bprm);
51152 if (retval)
51153 goto out_file;
51154 @@ -1523,24 +1644,65 @@ static int do_execve_common(const char *filename,
51155 if (retval < 0)
51156 goto out;
51157
51158 +#ifdef CONFIG_GRKERNSEC
51159 + old_acl = current->acl;
51160 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51161 + old_exec_file = current->exec_file;
51162 + get_file(file);
51163 + current->exec_file = file;
51164 +#endif
51165 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51166 + /* limit suid stack to 8MB
51167 + * we saved the old limits above and will restore them if this exec fails
51168 + */
51169 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51170 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51171 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51172 +#endif
51173 +
51174 + if (!gr_tpe_allow(file)) {
51175 + retval = -EACCES;
51176 + goto out_fail;
51177 + }
51178 +
51179 + if (gr_check_crash_exec(file)) {
51180 + retval = -EACCES;
51181 + goto out_fail;
51182 + }
51183 +
51184 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
51185 + bprm->unsafe);
51186 + if (retval < 0)
51187 + goto out_fail;
51188 +
51189 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51190 if (retval < 0)
51191 - goto out;
51192 + goto out_fail;
51193
51194 bprm->exec = bprm->p;
51195 retval = copy_strings(bprm->envc, envp, bprm);
51196 if (retval < 0)
51197 - goto out;
51198 + goto out_fail;
51199
51200 retval = copy_strings(bprm->argc, argv, bprm);
51201 if (retval < 0)
51202 - goto out;
51203 + goto out_fail;
51204 +
51205 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
51206 +
51207 + gr_handle_exec_args(bprm, argv);
51208
51209 retval = search_binary_handler(bprm);
51210 if (retval < 0)
51211 - goto out;
51212 + goto out_fail;
51213 +#ifdef CONFIG_GRKERNSEC
51214 + if (old_exec_file)
51215 + fput(old_exec_file);
51216 +#endif
51217
51218 /* execve succeeded */
51219 +
51220 + increment_exec_counter();
51221 current->fs->in_exec = 0;
51222 current->in_execve = 0;
51223 acct_update_integrals(current);
51224 @@ -1549,6 +1711,14 @@ static int do_execve_common(const char *filename,
51225 put_files_struct(displaced);
51226 return retval;
51227
51228 +out_fail:
51229 +#ifdef CONFIG_GRKERNSEC
51230 + current->acl = old_acl;
51231 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51232 + fput(current->exec_file);
51233 + current->exec_file = old_exec_file;
51234 +#endif
51235 +
51236 out:
51237 if (bprm->mm) {
51238 acct_arg_size(bprm, 0);
51239 @@ -1697,3 +1867,278 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51240 return error;
51241 }
51242 #endif
51243 +
51244 +int pax_check_flags(unsigned long *flags)
51245 +{
51246 + int retval = 0;
51247 +
51248 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51249 + if (*flags & MF_PAX_SEGMEXEC)
51250 + {
51251 + *flags &= ~MF_PAX_SEGMEXEC;
51252 + retval = -EINVAL;
51253 + }
51254 +#endif
51255 +
51256 + if ((*flags & MF_PAX_PAGEEXEC)
51257 +
51258 +#ifdef CONFIG_PAX_PAGEEXEC
51259 + && (*flags & MF_PAX_SEGMEXEC)
51260 +#endif
51261 +
51262 + )
51263 + {
51264 + *flags &= ~MF_PAX_PAGEEXEC;
51265 + retval = -EINVAL;
51266 + }
51267 +
51268 + if ((*flags & MF_PAX_MPROTECT)
51269 +
51270 +#ifdef CONFIG_PAX_MPROTECT
51271 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51272 +#endif
51273 +
51274 + )
51275 + {
51276 + *flags &= ~MF_PAX_MPROTECT;
51277 + retval = -EINVAL;
51278 + }
51279 +
51280 + if ((*flags & MF_PAX_EMUTRAMP)
51281 +
51282 +#ifdef CONFIG_PAX_EMUTRAMP
51283 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51284 +#endif
51285 +
51286 + )
51287 + {
51288 + *flags &= ~MF_PAX_EMUTRAMP;
51289 + retval = -EINVAL;
51290 + }
51291 +
51292 + return retval;
51293 +}
51294 +
51295 +EXPORT_SYMBOL(pax_check_flags);
51296 +
51297 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51298 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51299 +{
51300 + struct task_struct *tsk = current;
51301 + struct mm_struct *mm = current->mm;
51302 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51303 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51304 + char *path_exec = NULL;
51305 + char *path_fault = NULL;
51306 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51307 + siginfo_t info = { };
51308 +
51309 + if (buffer_exec && buffer_fault) {
51310 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51311 +
51312 + down_read(&mm->mmap_sem);
51313 + vma = mm->mmap;
51314 + while (vma && (!vma_exec || !vma_fault)) {
51315 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51316 + vma_exec = vma;
51317 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51318 + vma_fault = vma;
51319 + vma = vma->vm_next;
51320 + }
51321 + if (vma_exec) {
51322 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51323 + if (IS_ERR(path_exec))
51324 + path_exec = "<path too long>";
51325 + else {
51326 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51327 + if (path_exec) {
51328 + *path_exec = 0;
51329 + path_exec = buffer_exec;
51330 + } else
51331 + path_exec = "<path too long>";
51332 + }
51333 + }
51334 + if (vma_fault) {
51335 + start = vma_fault->vm_start;
51336 + end = vma_fault->vm_end;
51337 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51338 + if (vma_fault->vm_file) {
51339 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51340 + if (IS_ERR(path_fault))
51341 + path_fault = "<path too long>";
51342 + else {
51343 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51344 + if (path_fault) {
51345 + *path_fault = 0;
51346 + path_fault = buffer_fault;
51347 + } else
51348 + path_fault = "<path too long>";
51349 + }
51350 + } else
51351 + path_fault = "<anonymous mapping>";
51352 + }
51353 + up_read(&mm->mmap_sem);
51354 + }
51355 + if (tsk->signal->curr_ip)
51356 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51357 + else
51358 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51359 + 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),
51360 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51361 + free_page((unsigned long)buffer_exec);
51362 + free_page((unsigned long)buffer_fault);
51363 + pax_report_insns(regs, pc, sp);
51364 + info.si_signo = SIGKILL;
51365 + info.si_errno = 0;
51366 + info.si_code = SI_KERNEL;
51367 + info.si_pid = 0;
51368 + info.si_uid = 0;
51369 + do_coredump(&info);
51370 +}
51371 +#endif
51372 +
51373 +#ifdef CONFIG_PAX_REFCOUNT
51374 +void pax_report_refcount_overflow(struct pt_regs *regs)
51375 +{
51376 + if (current->signal->curr_ip)
51377 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51378 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51379 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51380 + else
51381 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51382 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51383 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51384 + show_regs(regs);
51385 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51386 +}
51387 +#endif
51388 +
51389 +#ifdef CONFIG_PAX_USERCOPY
51390 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51391 +static noinline int check_stack_object(const void *obj, unsigned long len)
51392 +{
51393 + const void * const stack = task_stack_page(current);
51394 + const void * const stackend = stack + THREAD_SIZE;
51395 +
51396 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51397 + const void *frame = NULL;
51398 + const void *oldframe;
51399 +#endif
51400 +
51401 + if (obj + len < obj)
51402 + return -1;
51403 +
51404 + if (obj + len <= stack || stackend <= obj)
51405 + return 0;
51406 +
51407 + if (obj < stack || stackend < obj + len)
51408 + return -1;
51409 +
51410 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51411 + oldframe = __builtin_frame_address(1);
51412 + if (oldframe)
51413 + frame = __builtin_frame_address(2);
51414 + /*
51415 + low ----------------------------------------------> high
51416 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51417 + ^----------------^
51418 + allow copies only within here
51419 + */
51420 + while (stack <= frame && frame < stackend) {
51421 + /* if obj + len extends past the last frame, this
51422 + check won't pass and the next frame will be 0,
51423 + causing us to bail out and correctly report
51424 + the copy as invalid
51425 + */
51426 + if (obj + len <= frame)
51427 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51428 + oldframe = frame;
51429 + frame = *(const void * const *)frame;
51430 + }
51431 + return -1;
51432 +#else
51433 + return 1;
51434 +#endif
51435 +}
51436 +
51437 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51438 +{
51439 + if (current->signal->curr_ip)
51440 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51441 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51442 + else
51443 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51444 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51445 + dump_stack();
51446 + gr_handle_kernel_exploit();
51447 + do_group_exit(SIGKILL);
51448 +}
51449 +#endif
51450 +
51451 +#ifdef CONFIG_PAX_USERCOPY
51452 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
51453 +{
51454 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
51455 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
51456 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
51457 +#else
51458 + unsigned long textlow = _stext;
51459 + unsigned long texthigh = _etext;
51460 +#endif
51461 +
51462 + if (high < textlow || low > texthigh)
51463 + return false;
51464 + else
51465 + return true;
51466 +}
51467 +#endif
51468 +
51469 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51470 +{
51471 +
51472 +#ifdef CONFIG_PAX_USERCOPY
51473 + const char *type;
51474 +
51475 + if (!n)
51476 + return;
51477 +
51478 + type = check_heap_object(ptr, n);
51479 + if (!type) {
51480 + int ret = check_stack_object(ptr, n);
51481 + if (ret == 1 || ret == 2)
51482 + return;
51483 + if (ret == 0) {
51484 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
51485 + type = "<kernel text>";
51486 + else
51487 + return;
51488 + } else
51489 + type = "<process stack>";
51490 + }
51491 +
51492 + pax_report_usercopy(ptr, n, to_user, type);
51493 +#endif
51494 +
51495 +}
51496 +EXPORT_SYMBOL(__check_object_size);
51497 +
51498 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51499 +void pax_track_stack(void)
51500 +{
51501 + unsigned long sp = (unsigned long)&sp;
51502 + if (sp < current_thread_info()->lowest_stack &&
51503 + sp > (unsigned long)task_stack_page(current))
51504 + current_thread_info()->lowest_stack = sp;
51505 +}
51506 +EXPORT_SYMBOL(pax_track_stack);
51507 +#endif
51508 +
51509 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51510 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51511 +{
51512 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51513 + dump_stack();
51514 + do_group_exit(SIGKILL);
51515 +}
51516 +EXPORT_SYMBOL(report_size_overflow);
51517 +#endif
51518 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51519 index 2616d0e..2ffdec9 100644
51520 --- a/fs/ext2/balloc.c
51521 +++ b/fs/ext2/balloc.c
51522 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51523
51524 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51525 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51526 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51527 + if (free_blocks < root_blocks + 1 &&
51528 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51529 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51530 - !in_group_p (sbi->s_resgid))) {
51531 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51532 return 0;
51533 }
51534 return 1;
51535 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51536 index 22548f5..41521d8 100644
51537 --- a/fs/ext3/balloc.c
51538 +++ b/fs/ext3/balloc.c
51539 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51540
51541 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51542 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51543 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51544 + if (free_blocks < root_blocks + 1 &&
51545 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51546 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51547 - !in_group_p (sbi->s_resgid))) {
51548 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51549 return 0;
51550 }
51551 return 1;
51552 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51553 index 92e68b3..115d987 100644
51554 --- a/fs/ext4/balloc.c
51555 +++ b/fs/ext4/balloc.c
51556 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51557 /* Hm, nope. Are (enough) root reserved clusters available? */
51558 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51559 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51560 - capable(CAP_SYS_RESOURCE) ||
51561 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51562 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51563 + capable_nolog(CAP_SYS_RESOURCE)) {
51564
51565 if (free_clusters >= (nclusters + dirty_clusters))
51566 return 1;
51567 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51568 index bbcd6a0..2824592 100644
51569 --- a/fs/ext4/ext4.h
51570 +++ b/fs/ext4/ext4.h
51571 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
51572 unsigned long s_mb_last_start;
51573
51574 /* stats for buddy allocator */
51575 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51576 - atomic_t s_bal_success; /* we found long enough chunks */
51577 - atomic_t s_bal_allocated; /* in blocks */
51578 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51579 - atomic_t s_bal_goals; /* goal hits */
51580 - atomic_t s_bal_breaks; /* too long searches */
51581 - atomic_t s_bal_2orders; /* 2^order hits */
51582 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51583 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51584 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51585 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51586 + atomic_unchecked_t s_bal_goals; /* goal hits */
51587 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51588 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51589 spinlock_t s_bal_lock;
51590 unsigned long s_mb_buddies_generated;
51591 unsigned long long s_mb_generation_time;
51592 - atomic_t s_mb_lost_chunks;
51593 - atomic_t s_mb_preallocated;
51594 - atomic_t s_mb_discarded;
51595 + atomic_unchecked_t s_mb_lost_chunks;
51596 + atomic_unchecked_t s_mb_preallocated;
51597 + atomic_unchecked_t s_mb_discarded;
51598 atomic_t s_lock_busy;
51599
51600 /* locality groups */
51601 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51602 index 82f8c2d..ce7c889 100644
51603 --- a/fs/ext4/mballoc.c
51604 +++ b/fs/ext4/mballoc.c
51605 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51606 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51607
51608 if (EXT4_SB(sb)->s_mb_stats)
51609 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51610 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51611
51612 break;
51613 }
51614 @@ -2044,7 +2044,7 @@ repeat:
51615 ac->ac_status = AC_STATUS_CONTINUE;
51616 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51617 cr = 3;
51618 - atomic_inc(&sbi->s_mb_lost_chunks);
51619 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51620 goto repeat;
51621 }
51622 }
51623 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
51624 if (sbi->s_mb_stats) {
51625 ext4_msg(sb, KERN_INFO,
51626 "mballoc: %u blocks %u reqs (%u success)",
51627 - atomic_read(&sbi->s_bal_allocated),
51628 - atomic_read(&sbi->s_bal_reqs),
51629 - atomic_read(&sbi->s_bal_success));
51630 + atomic_read_unchecked(&sbi->s_bal_allocated),
51631 + atomic_read_unchecked(&sbi->s_bal_reqs),
51632 + atomic_read_unchecked(&sbi->s_bal_success));
51633 ext4_msg(sb, KERN_INFO,
51634 "mballoc: %u extents scanned, %u goal hits, "
51635 "%u 2^N hits, %u breaks, %u lost",
51636 - atomic_read(&sbi->s_bal_ex_scanned),
51637 - atomic_read(&sbi->s_bal_goals),
51638 - atomic_read(&sbi->s_bal_2orders),
51639 - atomic_read(&sbi->s_bal_breaks),
51640 - atomic_read(&sbi->s_mb_lost_chunks));
51641 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51642 + atomic_read_unchecked(&sbi->s_bal_goals),
51643 + atomic_read_unchecked(&sbi->s_bal_2orders),
51644 + atomic_read_unchecked(&sbi->s_bal_breaks),
51645 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51646 ext4_msg(sb, KERN_INFO,
51647 "mballoc: %lu generated and it took %Lu",
51648 sbi->s_mb_buddies_generated,
51649 sbi->s_mb_generation_time);
51650 ext4_msg(sb, KERN_INFO,
51651 "mballoc: %u preallocated, %u discarded",
51652 - atomic_read(&sbi->s_mb_preallocated),
51653 - atomic_read(&sbi->s_mb_discarded));
51654 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51655 + atomic_read_unchecked(&sbi->s_mb_discarded));
51656 }
51657
51658 free_percpu(sbi->s_locality_groups);
51659 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51660 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51661
51662 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51663 - atomic_inc(&sbi->s_bal_reqs);
51664 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51665 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51666 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51667 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51668 - atomic_inc(&sbi->s_bal_success);
51669 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51670 + atomic_inc_unchecked(&sbi->s_bal_success);
51671 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51672 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51673 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51674 - atomic_inc(&sbi->s_bal_goals);
51675 + atomic_inc_unchecked(&sbi->s_bal_goals);
51676 if (ac->ac_found > sbi->s_mb_max_to_scan)
51677 - atomic_inc(&sbi->s_bal_breaks);
51678 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51679 }
51680
51681 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51682 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51683 trace_ext4_mb_new_inode_pa(ac, pa);
51684
51685 ext4_mb_use_inode_pa(ac, pa);
51686 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51687 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51688
51689 ei = EXT4_I(ac->ac_inode);
51690 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51691 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51692 trace_ext4_mb_new_group_pa(ac, pa);
51693
51694 ext4_mb_use_group_pa(ac, pa);
51695 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51696 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51697
51698 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51699 lg = ac->ac_lg;
51700 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51701 * from the bitmap and continue.
51702 */
51703 }
51704 - atomic_add(free, &sbi->s_mb_discarded);
51705 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51706
51707 return err;
51708 }
51709 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51710 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51711 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51712 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51713 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51714 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51715 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51716
51717 return 0;
51718 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51719 index 24c767d..893aa55 100644
51720 --- a/fs/ext4/super.c
51721 +++ b/fs/ext4/super.c
51722 @@ -2429,7 +2429,7 @@ struct ext4_attr {
51723 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51724 const char *, size_t);
51725 int offset;
51726 -};
51727 +} __do_const;
51728
51729 static int parse_strtoul(const char *buf,
51730 unsigned long max, unsigned long *value)
51731 diff --git a/fs/fcntl.c b/fs/fcntl.c
51732 index 71a600a..20d87b1 100644
51733 --- a/fs/fcntl.c
51734 +++ b/fs/fcntl.c
51735 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51736 if (err)
51737 return err;
51738
51739 + if (gr_handle_chroot_fowner(pid, type))
51740 + return -ENOENT;
51741 + if (gr_check_protected_task_fowner(pid, type))
51742 + return -EACCES;
51743 +
51744 f_modown(filp, pid, type, force);
51745 return 0;
51746 }
51747 diff --git a/fs/fhandle.c b/fs/fhandle.c
51748 index 999ff5c..41f4109 100644
51749 --- a/fs/fhandle.c
51750 +++ b/fs/fhandle.c
51751 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51752 } else
51753 retval = 0;
51754 /* copy the mount id */
51755 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51756 - sizeof(*mnt_id)) ||
51757 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51758 copy_to_user(ufh, handle,
51759 sizeof(struct file_handle) + handle_bytes))
51760 retval = -EFAULT;
51761 diff --git a/fs/fifo.c b/fs/fifo.c
51762 index cf6f434..3d7942c 100644
51763 --- a/fs/fifo.c
51764 +++ b/fs/fifo.c
51765 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51766 */
51767 filp->f_op = &read_pipefifo_fops;
51768 pipe->r_counter++;
51769 - if (pipe->readers++ == 0)
51770 + if (atomic_inc_return(&pipe->readers) == 1)
51771 wake_up_partner(inode);
51772
51773 - if (!pipe->writers) {
51774 + if (!atomic_read(&pipe->writers)) {
51775 if ((filp->f_flags & O_NONBLOCK)) {
51776 /* suppress POLLHUP until we have
51777 * seen a writer */
51778 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51779 * errno=ENXIO when there is no process reading the FIFO.
51780 */
51781 ret = -ENXIO;
51782 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51783 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51784 goto err;
51785
51786 filp->f_op = &write_pipefifo_fops;
51787 pipe->w_counter++;
51788 - if (!pipe->writers++)
51789 + if (atomic_inc_return(&pipe->writers) == 1)
51790 wake_up_partner(inode);
51791
51792 - if (!pipe->readers) {
51793 + if (!atomic_read(&pipe->readers)) {
51794 if (wait_for_partner(inode, &pipe->r_counter))
51795 goto err_wr;
51796 }
51797 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51798 */
51799 filp->f_op = &rdwr_pipefifo_fops;
51800
51801 - pipe->readers++;
51802 - pipe->writers++;
51803 + atomic_inc(&pipe->readers);
51804 + atomic_inc(&pipe->writers);
51805 pipe->r_counter++;
51806 pipe->w_counter++;
51807 - if (pipe->readers == 1 || pipe->writers == 1)
51808 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51809 wake_up_partner(inode);
51810 break;
51811
51812 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51813 return 0;
51814
51815 err_rd:
51816 - if (!--pipe->readers)
51817 + if (atomic_dec_and_test(&pipe->readers))
51818 wake_up_interruptible(&pipe->wait);
51819 ret = -ERESTARTSYS;
51820 goto err;
51821
51822 err_wr:
51823 - if (!--pipe->writers)
51824 + if (atomic_dec_and_test(&pipe->writers))
51825 wake_up_interruptible(&pipe->wait);
51826 ret = -ERESTARTSYS;
51827 goto err;
51828
51829 err:
51830 - if (!pipe->readers && !pipe->writers)
51831 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51832 free_pipe_info(inode);
51833
51834 err_nocleanup:
51835 diff --git a/fs/file.c b/fs/file.c
51836 index 2b3570b..c57924b 100644
51837 --- a/fs/file.c
51838 +++ b/fs/file.c
51839 @@ -16,6 +16,7 @@
51840 #include <linux/slab.h>
51841 #include <linux/vmalloc.h>
51842 #include <linux/file.h>
51843 +#include <linux/security.h>
51844 #include <linux/fdtable.h>
51845 #include <linux/bitops.h>
51846 #include <linux/interrupt.h>
51847 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51848 if (!file)
51849 return __close_fd(files, fd);
51850
51851 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51852 if (fd >= rlimit(RLIMIT_NOFILE))
51853 return -EBADF;
51854
51855 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51856 if (unlikely(oldfd == newfd))
51857 return -EINVAL;
51858
51859 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51860 if (newfd >= rlimit(RLIMIT_NOFILE))
51861 return -EBADF;
51862
51863 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51864 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51865 {
51866 int err;
51867 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51868 if (from >= rlimit(RLIMIT_NOFILE))
51869 return -EINVAL;
51870 err = alloc_fd(from, flags);
51871 diff --git a/fs/filesystems.c b/fs/filesystems.c
51872 index da165f6..3671bdb 100644
51873 --- a/fs/filesystems.c
51874 +++ b/fs/filesystems.c
51875 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
51876 int len = dot ? dot - name : strlen(name);
51877
51878 fs = __get_fs_type(name, len);
51879 +
51880 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51881 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
51882 +#else
51883 if (!fs && (request_module("%.*s", len, name) == 0))
51884 +#endif
51885 fs = __get_fs_type(name, len);
51886
51887 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51888 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51889 index fe6ca58..65318cf 100644
51890 --- a/fs/fs_struct.c
51891 +++ b/fs/fs_struct.c
51892 @@ -4,6 +4,7 @@
51893 #include <linux/path.h>
51894 #include <linux/slab.h>
51895 #include <linux/fs_struct.h>
51896 +#include <linux/grsecurity.h>
51897 #include "internal.h"
51898
51899 /*
51900 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
51901 write_seqcount_begin(&fs->seq);
51902 old_root = fs->root;
51903 fs->root = *path;
51904 + gr_set_chroot_entries(current, path);
51905 write_seqcount_end(&fs->seq);
51906 spin_unlock(&fs->lock);
51907 if (old_root.dentry)
51908 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
51909 return 1;
51910 }
51911
51912 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
51913 +{
51914 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
51915 + return 0;
51916 + *p = *new;
51917 +
51918 + /* This function is only called from pivot_root(). Leave our
51919 + gr_chroot_dentry and is_chrooted flags as-is, so that a
51920 + pivoted root isn't treated as a chroot
51921 + */
51922 + //gr_set_chroot_entries(task, new);
51923 +
51924 + return 1;
51925 +}
51926 +
51927 void chroot_fs_refs(struct path *old_root, struct path *new_root)
51928 {
51929 struct task_struct *g, *p;
51930 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
51931 int hits = 0;
51932 spin_lock(&fs->lock);
51933 write_seqcount_begin(&fs->seq);
51934 - hits += replace_path(&fs->root, old_root, new_root);
51935 + hits += replace_root_path(p, &fs->root, old_root, new_root);
51936 hits += replace_path(&fs->pwd, old_root, new_root);
51937 write_seqcount_end(&fs->seq);
51938 while (hits--) {
51939 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
51940 task_lock(tsk);
51941 spin_lock(&fs->lock);
51942 tsk->fs = NULL;
51943 - kill = !--fs->users;
51944 + gr_clear_chroot_entries(tsk);
51945 + kill = !atomic_dec_return(&fs->users);
51946 spin_unlock(&fs->lock);
51947 task_unlock(tsk);
51948 if (kill)
51949 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51950 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51951 /* We don't need to lock fs - think why ;-) */
51952 if (fs) {
51953 - fs->users = 1;
51954 + atomic_set(&fs->users, 1);
51955 fs->in_exec = 0;
51956 spin_lock_init(&fs->lock);
51957 seqcount_init(&fs->seq);
51958 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51959 spin_lock(&old->lock);
51960 fs->root = old->root;
51961 path_get(&fs->root);
51962 + /* instead of calling gr_set_chroot_entries here,
51963 + we call it from every caller of this function
51964 + */
51965 fs->pwd = old->pwd;
51966 path_get(&fs->pwd);
51967 spin_unlock(&old->lock);
51968 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
51969
51970 task_lock(current);
51971 spin_lock(&fs->lock);
51972 - kill = !--fs->users;
51973 + kill = !atomic_dec_return(&fs->users);
51974 current->fs = new_fs;
51975 + gr_set_chroot_entries(current, &new_fs->root);
51976 spin_unlock(&fs->lock);
51977 task_unlock(current);
51978
51979 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51980
51981 int current_umask(void)
51982 {
51983 - return current->fs->umask;
51984 + return current->fs->umask | gr_acl_umask();
51985 }
51986 EXPORT_SYMBOL(current_umask);
51987
51988 /* to be mentioned only in INIT_TASK */
51989 struct fs_struct init_fs = {
51990 - .users = 1,
51991 + .users = ATOMIC_INIT(1),
51992 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51993 .seq = SEQCNT_ZERO,
51994 .umask = 0022,
51995 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51996 index 8dcb114..b1072e2 100644
51997 --- a/fs/fscache/cookie.c
51998 +++ b/fs/fscache/cookie.c
51999 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
52000 parent ? (char *) parent->def->name : "<no-parent>",
52001 def->name, netfs_data);
52002
52003 - fscache_stat(&fscache_n_acquires);
52004 + fscache_stat_unchecked(&fscache_n_acquires);
52005
52006 /* if there's no parent cookie, then we don't create one here either */
52007 if (!parent) {
52008 - fscache_stat(&fscache_n_acquires_null);
52009 + fscache_stat_unchecked(&fscache_n_acquires_null);
52010 _leave(" [no parent]");
52011 return NULL;
52012 }
52013 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
52014 /* allocate and initialise a cookie */
52015 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
52016 if (!cookie) {
52017 - fscache_stat(&fscache_n_acquires_oom);
52018 + fscache_stat_unchecked(&fscache_n_acquires_oom);
52019 _leave(" [ENOMEM]");
52020 return NULL;
52021 }
52022 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52023
52024 switch (cookie->def->type) {
52025 case FSCACHE_COOKIE_TYPE_INDEX:
52026 - fscache_stat(&fscache_n_cookie_index);
52027 + fscache_stat_unchecked(&fscache_n_cookie_index);
52028 break;
52029 case FSCACHE_COOKIE_TYPE_DATAFILE:
52030 - fscache_stat(&fscache_n_cookie_data);
52031 + fscache_stat_unchecked(&fscache_n_cookie_data);
52032 break;
52033 default:
52034 - fscache_stat(&fscache_n_cookie_special);
52035 + fscache_stat_unchecked(&fscache_n_cookie_special);
52036 break;
52037 }
52038
52039 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52040 if (fscache_acquire_non_index_cookie(cookie) < 0) {
52041 atomic_dec(&parent->n_children);
52042 __fscache_cookie_put(cookie);
52043 - fscache_stat(&fscache_n_acquires_nobufs);
52044 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
52045 _leave(" = NULL");
52046 return NULL;
52047 }
52048 }
52049
52050 - fscache_stat(&fscache_n_acquires_ok);
52051 + fscache_stat_unchecked(&fscache_n_acquires_ok);
52052 _leave(" = %p", cookie);
52053 return cookie;
52054 }
52055 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
52056 cache = fscache_select_cache_for_object(cookie->parent);
52057 if (!cache) {
52058 up_read(&fscache_addremove_sem);
52059 - fscache_stat(&fscache_n_acquires_no_cache);
52060 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
52061 _leave(" = -ENOMEDIUM [no cache]");
52062 return -ENOMEDIUM;
52063 }
52064 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
52065 object = cache->ops->alloc_object(cache, cookie);
52066 fscache_stat_d(&fscache_n_cop_alloc_object);
52067 if (IS_ERR(object)) {
52068 - fscache_stat(&fscache_n_object_no_alloc);
52069 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
52070 ret = PTR_ERR(object);
52071 goto error;
52072 }
52073
52074 - fscache_stat(&fscache_n_object_alloc);
52075 + fscache_stat_unchecked(&fscache_n_object_alloc);
52076
52077 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
52078
52079 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
52080
52081 _enter("{%s}", cookie->def->name);
52082
52083 - fscache_stat(&fscache_n_invalidates);
52084 + fscache_stat_unchecked(&fscache_n_invalidates);
52085
52086 /* Only permit invalidation of data files. Invalidating an index will
52087 * require the caller to release all its attachments to the tree rooted
52088 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52089 struct fscache_object *object;
52090 struct hlist_node *_p;
52091
52092 - fscache_stat(&fscache_n_updates);
52093 + fscache_stat_unchecked(&fscache_n_updates);
52094
52095 if (!cookie) {
52096 - fscache_stat(&fscache_n_updates_null);
52097 + fscache_stat_unchecked(&fscache_n_updates_null);
52098 _leave(" [no cookie]");
52099 return;
52100 }
52101 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52102 struct fscache_object *object;
52103 unsigned long event;
52104
52105 - fscache_stat(&fscache_n_relinquishes);
52106 + fscache_stat_unchecked(&fscache_n_relinquishes);
52107 if (retire)
52108 - fscache_stat(&fscache_n_relinquishes_retire);
52109 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52110
52111 if (!cookie) {
52112 - fscache_stat(&fscache_n_relinquishes_null);
52113 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52114 _leave(" [no cookie]");
52115 return;
52116 }
52117 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52118
52119 /* wait for the cookie to finish being instantiated (or to fail) */
52120 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52121 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52122 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52123 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52124 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52125 }
52126 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52127 index ee38fef..0a326d4 100644
52128 --- a/fs/fscache/internal.h
52129 +++ b/fs/fscache/internal.h
52130 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52131 * stats.c
52132 */
52133 #ifdef CONFIG_FSCACHE_STATS
52134 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52135 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52136 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52137 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52138
52139 -extern atomic_t fscache_n_op_pend;
52140 -extern atomic_t fscache_n_op_run;
52141 -extern atomic_t fscache_n_op_enqueue;
52142 -extern atomic_t fscache_n_op_deferred_release;
52143 -extern atomic_t fscache_n_op_release;
52144 -extern atomic_t fscache_n_op_gc;
52145 -extern atomic_t fscache_n_op_cancelled;
52146 -extern atomic_t fscache_n_op_rejected;
52147 +extern atomic_unchecked_t fscache_n_op_pend;
52148 +extern atomic_unchecked_t fscache_n_op_run;
52149 +extern atomic_unchecked_t fscache_n_op_enqueue;
52150 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52151 +extern atomic_unchecked_t fscache_n_op_release;
52152 +extern atomic_unchecked_t fscache_n_op_gc;
52153 +extern atomic_unchecked_t fscache_n_op_cancelled;
52154 +extern atomic_unchecked_t fscache_n_op_rejected;
52155
52156 -extern atomic_t fscache_n_attr_changed;
52157 -extern atomic_t fscache_n_attr_changed_ok;
52158 -extern atomic_t fscache_n_attr_changed_nobufs;
52159 -extern atomic_t fscache_n_attr_changed_nomem;
52160 -extern atomic_t fscache_n_attr_changed_calls;
52161 +extern atomic_unchecked_t fscache_n_attr_changed;
52162 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52163 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52164 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52165 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52166
52167 -extern atomic_t fscache_n_allocs;
52168 -extern atomic_t fscache_n_allocs_ok;
52169 -extern atomic_t fscache_n_allocs_wait;
52170 -extern atomic_t fscache_n_allocs_nobufs;
52171 -extern atomic_t fscache_n_allocs_intr;
52172 -extern atomic_t fscache_n_allocs_object_dead;
52173 -extern atomic_t fscache_n_alloc_ops;
52174 -extern atomic_t fscache_n_alloc_op_waits;
52175 +extern atomic_unchecked_t fscache_n_allocs;
52176 +extern atomic_unchecked_t fscache_n_allocs_ok;
52177 +extern atomic_unchecked_t fscache_n_allocs_wait;
52178 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52179 +extern atomic_unchecked_t fscache_n_allocs_intr;
52180 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52181 +extern atomic_unchecked_t fscache_n_alloc_ops;
52182 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52183
52184 -extern atomic_t fscache_n_retrievals;
52185 -extern atomic_t fscache_n_retrievals_ok;
52186 -extern atomic_t fscache_n_retrievals_wait;
52187 -extern atomic_t fscache_n_retrievals_nodata;
52188 -extern atomic_t fscache_n_retrievals_nobufs;
52189 -extern atomic_t fscache_n_retrievals_intr;
52190 -extern atomic_t fscache_n_retrievals_nomem;
52191 -extern atomic_t fscache_n_retrievals_object_dead;
52192 -extern atomic_t fscache_n_retrieval_ops;
52193 -extern atomic_t fscache_n_retrieval_op_waits;
52194 +extern atomic_unchecked_t fscache_n_retrievals;
52195 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52196 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52197 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52198 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52199 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52200 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52201 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52202 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52203 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52204
52205 -extern atomic_t fscache_n_stores;
52206 -extern atomic_t fscache_n_stores_ok;
52207 -extern atomic_t fscache_n_stores_again;
52208 -extern atomic_t fscache_n_stores_nobufs;
52209 -extern atomic_t fscache_n_stores_oom;
52210 -extern atomic_t fscache_n_store_ops;
52211 -extern atomic_t fscache_n_store_calls;
52212 -extern atomic_t fscache_n_store_pages;
52213 -extern atomic_t fscache_n_store_radix_deletes;
52214 -extern atomic_t fscache_n_store_pages_over_limit;
52215 +extern atomic_unchecked_t fscache_n_stores;
52216 +extern atomic_unchecked_t fscache_n_stores_ok;
52217 +extern atomic_unchecked_t fscache_n_stores_again;
52218 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52219 +extern atomic_unchecked_t fscache_n_stores_oom;
52220 +extern atomic_unchecked_t fscache_n_store_ops;
52221 +extern atomic_unchecked_t fscache_n_store_calls;
52222 +extern atomic_unchecked_t fscache_n_store_pages;
52223 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52224 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52225
52226 -extern atomic_t fscache_n_store_vmscan_not_storing;
52227 -extern atomic_t fscache_n_store_vmscan_gone;
52228 -extern atomic_t fscache_n_store_vmscan_busy;
52229 -extern atomic_t fscache_n_store_vmscan_cancelled;
52230 -extern atomic_t fscache_n_store_vmscan_wait;
52231 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52232 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52233 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52234 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52235 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52236
52237 -extern atomic_t fscache_n_marks;
52238 -extern atomic_t fscache_n_uncaches;
52239 +extern atomic_unchecked_t fscache_n_marks;
52240 +extern atomic_unchecked_t fscache_n_uncaches;
52241
52242 -extern atomic_t fscache_n_acquires;
52243 -extern atomic_t fscache_n_acquires_null;
52244 -extern atomic_t fscache_n_acquires_no_cache;
52245 -extern atomic_t fscache_n_acquires_ok;
52246 -extern atomic_t fscache_n_acquires_nobufs;
52247 -extern atomic_t fscache_n_acquires_oom;
52248 +extern atomic_unchecked_t fscache_n_acquires;
52249 +extern atomic_unchecked_t fscache_n_acquires_null;
52250 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52251 +extern atomic_unchecked_t fscache_n_acquires_ok;
52252 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52253 +extern atomic_unchecked_t fscache_n_acquires_oom;
52254
52255 -extern atomic_t fscache_n_invalidates;
52256 -extern atomic_t fscache_n_invalidates_run;
52257 +extern atomic_unchecked_t fscache_n_invalidates;
52258 +extern atomic_unchecked_t fscache_n_invalidates_run;
52259
52260 -extern atomic_t fscache_n_updates;
52261 -extern atomic_t fscache_n_updates_null;
52262 -extern atomic_t fscache_n_updates_run;
52263 +extern atomic_unchecked_t fscache_n_updates;
52264 +extern atomic_unchecked_t fscache_n_updates_null;
52265 +extern atomic_unchecked_t fscache_n_updates_run;
52266
52267 -extern atomic_t fscache_n_relinquishes;
52268 -extern atomic_t fscache_n_relinquishes_null;
52269 -extern atomic_t fscache_n_relinquishes_waitcrt;
52270 -extern atomic_t fscache_n_relinquishes_retire;
52271 +extern atomic_unchecked_t fscache_n_relinquishes;
52272 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52273 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52274 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52275
52276 -extern atomic_t fscache_n_cookie_index;
52277 -extern atomic_t fscache_n_cookie_data;
52278 -extern atomic_t fscache_n_cookie_special;
52279 +extern atomic_unchecked_t fscache_n_cookie_index;
52280 +extern atomic_unchecked_t fscache_n_cookie_data;
52281 +extern atomic_unchecked_t fscache_n_cookie_special;
52282
52283 -extern atomic_t fscache_n_object_alloc;
52284 -extern atomic_t fscache_n_object_no_alloc;
52285 -extern atomic_t fscache_n_object_lookups;
52286 -extern atomic_t fscache_n_object_lookups_negative;
52287 -extern atomic_t fscache_n_object_lookups_positive;
52288 -extern atomic_t fscache_n_object_lookups_timed_out;
52289 -extern atomic_t fscache_n_object_created;
52290 -extern atomic_t fscache_n_object_avail;
52291 -extern atomic_t fscache_n_object_dead;
52292 +extern atomic_unchecked_t fscache_n_object_alloc;
52293 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52294 +extern atomic_unchecked_t fscache_n_object_lookups;
52295 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52296 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52297 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52298 +extern atomic_unchecked_t fscache_n_object_created;
52299 +extern atomic_unchecked_t fscache_n_object_avail;
52300 +extern atomic_unchecked_t fscache_n_object_dead;
52301
52302 -extern atomic_t fscache_n_checkaux_none;
52303 -extern atomic_t fscache_n_checkaux_okay;
52304 -extern atomic_t fscache_n_checkaux_update;
52305 -extern atomic_t fscache_n_checkaux_obsolete;
52306 +extern atomic_unchecked_t fscache_n_checkaux_none;
52307 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52308 +extern atomic_unchecked_t fscache_n_checkaux_update;
52309 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52310
52311 extern atomic_t fscache_n_cop_alloc_object;
52312 extern atomic_t fscache_n_cop_lookup_object;
52313 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52314 atomic_inc(stat);
52315 }
52316
52317 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52318 +{
52319 + atomic_inc_unchecked(stat);
52320 +}
52321 +
52322 static inline void fscache_stat_d(atomic_t *stat)
52323 {
52324 atomic_dec(stat);
52325 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52326
52327 #define __fscache_stat(stat) (NULL)
52328 #define fscache_stat(stat) do {} while (0)
52329 +#define fscache_stat_unchecked(stat) do {} while (0)
52330 #define fscache_stat_d(stat) do {} while (0)
52331 #endif
52332
52333 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52334 index 50d41c1..10ee117 100644
52335 --- a/fs/fscache/object.c
52336 +++ b/fs/fscache/object.c
52337 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52338 /* Invalidate an object on disk */
52339 case FSCACHE_OBJECT_INVALIDATING:
52340 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52341 - fscache_stat(&fscache_n_invalidates_run);
52342 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52343 fscache_stat(&fscache_n_cop_invalidate_object);
52344 fscache_invalidate_object(object);
52345 fscache_stat_d(&fscache_n_cop_invalidate_object);
52346 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52347 /* update the object metadata on disk */
52348 case FSCACHE_OBJECT_UPDATING:
52349 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52350 - fscache_stat(&fscache_n_updates_run);
52351 + fscache_stat_unchecked(&fscache_n_updates_run);
52352 fscache_stat(&fscache_n_cop_update_object);
52353 object->cache->ops->update_object(object);
52354 fscache_stat_d(&fscache_n_cop_update_object);
52355 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52356 spin_lock(&object->lock);
52357 object->state = FSCACHE_OBJECT_DEAD;
52358 spin_unlock(&object->lock);
52359 - fscache_stat(&fscache_n_object_dead);
52360 + fscache_stat_unchecked(&fscache_n_object_dead);
52361 goto terminal_transit;
52362
52363 /* handle the parent cache of this object being withdrawn from
52364 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52365 spin_lock(&object->lock);
52366 object->state = FSCACHE_OBJECT_DEAD;
52367 spin_unlock(&object->lock);
52368 - fscache_stat(&fscache_n_object_dead);
52369 + fscache_stat_unchecked(&fscache_n_object_dead);
52370 goto terminal_transit;
52371
52372 /* complain about the object being woken up once it is
52373 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52374 parent->cookie->def->name, cookie->def->name,
52375 object->cache->tag->name);
52376
52377 - fscache_stat(&fscache_n_object_lookups);
52378 + fscache_stat_unchecked(&fscache_n_object_lookups);
52379 fscache_stat(&fscache_n_cop_lookup_object);
52380 ret = object->cache->ops->lookup_object(object);
52381 fscache_stat_d(&fscache_n_cop_lookup_object);
52382 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52383 if (ret == -ETIMEDOUT) {
52384 /* probably stuck behind another object, so move this one to
52385 * the back of the queue */
52386 - fscache_stat(&fscache_n_object_lookups_timed_out);
52387 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52388 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52389 }
52390
52391 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52392
52393 spin_lock(&object->lock);
52394 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52395 - fscache_stat(&fscache_n_object_lookups_negative);
52396 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52397
52398 /* transit here to allow write requests to begin stacking up
52399 * and read requests to begin returning ENODATA */
52400 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52401 * result, in which case there may be data available */
52402 spin_lock(&object->lock);
52403 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52404 - fscache_stat(&fscache_n_object_lookups_positive);
52405 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52406
52407 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52408
52409 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52410 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52411 } else {
52412 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52413 - fscache_stat(&fscache_n_object_created);
52414 + fscache_stat_unchecked(&fscache_n_object_created);
52415
52416 object->state = FSCACHE_OBJECT_AVAILABLE;
52417 spin_unlock(&object->lock);
52418 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52419 fscache_enqueue_dependents(object);
52420
52421 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52422 - fscache_stat(&fscache_n_object_avail);
52423 + fscache_stat_unchecked(&fscache_n_object_avail);
52424
52425 _leave("");
52426 }
52427 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52428 enum fscache_checkaux result;
52429
52430 if (!object->cookie->def->check_aux) {
52431 - fscache_stat(&fscache_n_checkaux_none);
52432 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52433 return FSCACHE_CHECKAUX_OKAY;
52434 }
52435
52436 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52437 switch (result) {
52438 /* entry okay as is */
52439 case FSCACHE_CHECKAUX_OKAY:
52440 - fscache_stat(&fscache_n_checkaux_okay);
52441 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52442 break;
52443
52444 /* entry requires update */
52445 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52446 - fscache_stat(&fscache_n_checkaux_update);
52447 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52448 break;
52449
52450 /* entry requires deletion */
52451 case FSCACHE_CHECKAUX_OBSOLETE:
52452 - fscache_stat(&fscache_n_checkaux_obsolete);
52453 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52454 break;
52455
52456 default:
52457 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52458 index 762a9ec..2023284 100644
52459 --- a/fs/fscache/operation.c
52460 +++ b/fs/fscache/operation.c
52461 @@ -17,7 +17,7 @@
52462 #include <linux/slab.h>
52463 #include "internal.h"
52464
52465 -atomic_t fscache_op_debug_id;
52466 +atomic_unchecked_t fscache_op_debug_id;
52467 EXPORT_SYMBOL(fscache_op_debug_id);
52468
52469 /**
52470 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52471 ASSERTCMP(atomic_read(&op->usage), >, 0);
52472 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52473
52474 - fscache_stat(&fscache_n_op_enqueue);
52475 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52476 switch (op->flags & FSCACHE_OP_TYPE) {
52477 case FSCACHE_OP_ASYNC:
52478 _debug("queue async");
52479 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52480 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52481 if (op->processor)
52482 fscache_enqueue_operation(op);
52483 - fscache_stat(&fscache_n_op_run);
52484 + fscache_stat_unchecked(&fscache_n_op_run);
52485 }
52486
52487 /*
52488 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52489 if (object->n_in_progress > 0) {
52490 atomic_inc(&op->usage);
52491 list_add_tail(&op->pend_link, &object->pending_ops);
52492 - fscache_stat(&fscache_n_op_pend);
52493 + fscache_stat_unchecked(&fscache_n_op_pend);
52494 } else if (!list_empty(&object->pending_ops)) {
52495 atomic_inc(&op->usage);
52496 list_add_tail(&op->pend_link, &object->pending_ops);
52497 - fscache_stat(&fscache_n_op_pend);
52498 + fscache_stat_unchecked(&fscache_n_op_pend);
52499 fscache_start_operations(object);
52500 } else {
52501 ASSERTCMP(object->n_in_progress, ==, 0);
52502 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52503 object->n_exclusive++; /* reads and writes must wait */
52504 atomic_inc(&op->usage);
52505 list_add_tail(&op->pend_link, &object->pending_ops);
52506 - fscache_stat(&fscache_n_op_pend);
52507 + fscache_stat_unchecked(&fscache_n_op_pend);
52508 ret = 0;
52509 } else {
52510 /* If we're in any other state, there must have been an I/O
52511 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52512 if (object->n_exclusive > 0) {
52513 atomic_inc(&op->usage);
52514 list_add_tail(&op->pend_link, &object->pending_ops);
52515 - fscache_stat(&fscache_n_op_pend);
52516 + fscache_stat_unchecked(&fscache_n_op_pend);
52517 } else if (!list_empty(&object->pending_ops)) {
52518 atomic_inc(&op->usage);
52519 list_add_tail(&op->pend_link, &object->pending_ops);
52520 - fscache_stat(&fscache_n_op_pend);
52521 + fscache_stat_unchecked(&fscache_n_op_pend);
52522 fscache_start_operations(object);
52523 } else {
52524 ASSERTCMP(object->n_exclusive, ==, 0);
52525 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52526 object->n_ops++;
52527 atomic_inc(&op->usage);
52528 list_add_tail(&op->pend_link, &object->pending_ops);
52529 - fscache_stat(&fscache_n_op_pend);
52530 + fscache_stat_unchecked(&fscache_n_op_pend);
52531 ret = 0;
52532 } else if (object->state == FSCACHE_OBJECT_DYING ||
52533 object->state == FSCACHE_OBJECT_LC_DYING ||
52534 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52535 - fscache_stat(&fscache_n_op_rejected);
52536 + fscache_stat_unchecked(&fscache_n_op_rejected);
52537 op->state = FSCACHE_OP_ST_CANCELLED;
52538 ret = -ENOBUFS;
52539 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52540 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52541 ret = -EBUSY;
52542 if (op->state == FSCACHE_OP_ST_PENDING) {
52543 ASSERT(!list_empty(&op->pend_link));
52544 - fscache_stat(&fscache_n_op_cancelled);
52545 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52546 list_del_init(&op->pend_link);
52547 if (do_cancel)
52548 do_cancel(op);
52549 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52550 while (!list_empty(&object->pending_ops)) {
52551 op = list_entry(object->pending_ops.next,
52552 struct fscache_operation, pend_link);
52553 - fscache_stat(&fscache_n_op_cancelled);
52554 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52555 list_del_init(&op->pend_link);
52556
52557 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52558 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52559 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52560 op->state = FSCACHE_OP_ST_DEAD;
52561
52562 - fscache_stat(&fscache_n_op_release);
52563 + fscache_stat_unchecked(&fscache_n_op_release);
52564
52565 if (op->release) {
52566 op->release(op);
52567 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52568 * lock, and defer it otherwise */
52569 if (!spin_trylock(&object->lock)) {
52570 _debug("defer put");
52571 - fscache_stat(&fscache_n_op_deferred_release);
52572 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52573
52574 cache = object->cache;
52575 spin_lock(&cache->op_gc_list_lock);
52576 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52577
52578 _debug("GC DEFERRED REL OBJ%x OP%x",
52579 object->debug_id, op->debug_id);
52580 - fscache_stat(&fscache_n_op_gc);
52581 + fscache_stat_unchecked(&fscache_n_op_gc);
52582
52583 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52584 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52585 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52586 index ff000e5..c44ec6d 100644
52587 --- a/fs/fscache/page.c
52588 +++ b/fs/fscache/page.c
52589 @@ -61,7 +61,7 @@ try_again:
52590 val = radix_tree_lookup(&cookie->stores, page->index);
52591 if (!val) {
52592 rcu_read_unlock();
52593 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52594 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52595 __fscache_uncache_page(cookie, page);
52596 return true;
52597 }
52598 @@ -91,11 +91,11 @@ try_again:
52599 spin_unlock(&cookie->stores_lock);
52600
52601 if (xpage) {
52602 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52603 - fscache_stat(&fscache_n_store_radix_deletes);
52604 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52605 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52606 ASSERTCMP(xpage, ==, page);
52607 } else {
52608 - fscache_stat(&fscache_n_store_vmscan_gone);
52609 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52610 }
52611
52612 wake_up_bit(&cookie->flags, 0);
52613 @@ -110,11 +110,11 @@ page_busy:
52614 * sleeping on memory allocation, so we may need to impose a timeout
52615 * too. */
52616 if (!(gfp & __GFP_WAIT)) {
52617 - fscache_stat(&fscache_n_store_vmscan_busy);
52618 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52619 return false;
52620 }
52621
52622 - fscache_stat(&fscache_n_store_vmscan_wait);
52623 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52624 __fscache_wait_on_page_write(cookie, page);
52625 gfp &= ~__GFP_WAIT;
52626 goto try_again;
52627 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52628 FSCACHE_COOKIE_STORING_TAG);
52629 if (!radix_tree_tag_get(&cookie->stores, page->index,
52630 FSCACHE_COOKIE_PENDING_TAG)) {
52631 - fscache_stat(&fscache_n_store_radix_deletes);
52632 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52633 xpage = radix_tree_delete(&cookie->stores, page->index);
52634 }
52635 spin_unlock(&cookie->stores_lock);
52636 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52637
52638 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52639
52640 - fscache_stat(&fscache_n_attr_changed_calls);
52641 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52642
52643 if (fscache_object_is_active(object)) {
52644 fscache_stat(&fscache_n_cop_attr_changed);
52645 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52646
52647 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52648
52649 - fscache_stat(&fscache_n_attr_changed);
52650 + fscache_stat_unchecked(&fscache_n_attr_changed);
52651
52652 op = kzalloc(sizeof(*op), GFP_KERNEL);
52653 if (!op) {
52654 - fscache_stat(&fscache_n_attr_changed_nomem);
52655 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52656 _leave(" = -ENOMEM");
52657 return -ENOMEM;
52658 }
52659 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52660 if (fscache_submit_exclusive_op(object, op) < 0)
52661 goto nobufs;
52662 spin_unlock(&cookie->lock);
52663 - fscache_stat(&fscache_n_attr_changed_ok);
52664 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52665 fscache_put_operation(op);
52666 _leave(" = 0");
52667 return 0;
52668 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52669 nobufs:
52670 spin_unlock(&cookie->lock);
52671 kfree(op);
52672 - fscache_stat(&fscache_n_attr_changed_nobufs);
52673 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52674 _leave(" = %d", -ENOBUFS);
52675 return -ENOBUFS;
52676 }
52677 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52678 /* allocate a retrieval operation and attempt to submit it */
52679 op = kzalloc(sizeof(*op), GFP_NOIO);
52680 if (!op) {
52681 - fscache_stat(&fscache_n_retrievals_nomem);
52682 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52683 return NULL;
52684 }
52685
52686 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52687 return 0;
52688 }
52689
52690 - fscache_stat(&fscache_n_retrievals_wait);
52691 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52692
52693 jif = jiffies;
52694 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52695 fscache_wait_bit_interruptible,
52696 TASK_INTERRUPTIBLE) != 0) {
52697 - fscache_stat(&fscache_n_retrievals_intr);
52698 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52699 _leave(" = -ERESTARTSYS");
52700 return -ERESTARTSYS;
52701 }
52702 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52703 */
52704 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52705 struct fscache_retrieval *op,
52706 - atomic_t *stat_op_waits,
52707 - atomic_t *stat_object_dead)
52708 + atomic_unchecked_t *stat_op_waits,
52709 + atomic_unchecked_t *stat_object_dead)
52710 {
52711 int ret;
52712
52713 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52714 goto check_if_dead;
52715
52716 _debug(">>> WT");
52717 - fscache_stat(stat_op_waits);
52718 + fscache_stat_unchecked(stat_op_waits);
52719 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52720 fscache_wait_bit_interruptible,
52721 TASK_INTERRUPTIBLE) != 0) {
52722 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52723
52724 check_if_dead:
52725 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52726 - fscache_stat(stat_object_dead);
52727 + fscache_stat_unchecked(stat_object_dead);
52728 _leave(" = -ENOBUFS [cancelled]");
52729 return -ENOBUFS;
52730 }
52731 if (unlikely(fscache_object_is_dead(object))) {
52732 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52733 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52734 - fscache_stat(stat_object_dead);
52735 + fscache_stat_unchecked(stat_object_dead);
52736 return -ENOBUFS;
52737 }
52738 return 0;
52739 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52740
52741 _enter("%p,%p,,,", cookie, page);
52742
52743 - fscache_stat(&fscache_n_retrievals);
52744 + fscache_stat_unchecked(&fscache_n_retrievals);
52745
52746 if (hlist_empty(&cookie->backing_objects))
52747 goto nobufs;
52748 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52749 goto nobufs_unlock_dec;
52750 spin_unlock(&cookie->lock);
52751
52752 - fscache_stat(&fscache_n_retrieval_ops);
52753 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52754
52755 /* pin the netfs read context in case we need to do the actual netfs
52756 * read because we've encountered a cache read failure */
52757 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52758
52759 error:
52760 if (ret == -ENOMEM)
52761 - fscache_stat(&fscache_n_retrievals_nomem);
52762 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52763 else if (ret == -ERESTARTSYS)
52764 - fscache_stat(&fscache_n_retrievals_intr);
52765 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52766 else if (ret == -ENODATA)
52767 - fscache_stat(&fscache_n_retrievals_nodata);
52768 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52769 else if (ret < 0)
52770 - fscache_stat(&fscache_n_retrievals_nobufs);
52771 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52772 else
52773 - fscache_stat(&fscache_n_retrievals_ok);
52774 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52775
52776 fscache_put_retrieval(op);
52777 _leave(" = %d", ret);
52778 @@ -467,7 +467,7 @@ nobufs_unlock:
52779 spin_unlock(&cookie->lock);
52780 kfree(op);
52781 nobufs:
52782 - fscache_stat(&fscache_n_retrievals_nobufs);
52783 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52784 _leave(" = -ENOBUFS");
52785 return -ENOBUFS;
52786 }
52787 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52788
52789 _enter("%p,,%d,,,", cookie, *nr_pages);
52790
52791 - fscache_stat(&fscache_n_retrievals);
52792 + fscache_stat_unchecked(&fscache_n_retrievals);
52793
52794 if (hlist_empty(&cookie->backing_objects))
52795 goto nobufs;
52796 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52797 goto nobufs_unlock_dec;
52798 spin_unlock(&cookie->lock);
52799
52800 - fscache_stat(&fscache_n_retrieval_ops);
52801 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52802
52803 /* pin the netfs read context in case we need to do the actual netfs
52804 * read because we've encountered a cache read failure */
52805 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52806
52807 error:
52808 if (ret == -ENOMEM)
52809 - fscache_stat(&fscache_n_retrievals_nomem);
52810 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52811 else if (ret == -ERESTARTSYS)
52812 - fscache_stat(&fscache_n_retrievals_intr);
52813 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52814 else if (ret == -ENODATA)
52815 - fscache_stat(&fscache_n_retrievals_nodata);
52816 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52817 else if (ret < 0)
52818 - fscache_stat(&fscache_n_retrievals_nobufs);
52819 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52820 else
52821 - fscache_stat(&fscache_n_retrievals_ok);
52822 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52823
52824 fscache_put_retrieval(op);
52825 _leave(" = %d", ret);
52826 @@ -591,7 +591,7 @@ nobufs_unlock:
52827 spin_unlock(&cookie->lock);
52828 kfree(op);
52829 nobufs:
52830 - fscache_stat(&fscache_n_retrievals_nobufs);
52831 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52832 _leave(" = -ENOBUFS");
52833 return -ENOBUFS;
52834 }
52835 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52836
52837 _enter("%p,%p,,,", cookie, page);
52838
52839 - fscache_stat(&fscache_n_allocs);
52840 + fscache_stat_unchecked(&fscache_n_allocs);
52841
52842 if (hlist_empty(&cookie->backing_objects))
52843 goto nobufs;
52844 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52845 goto nobufs_unlock;
52846 spin_unlock(&cookie->lock);
52847
52848 - fscache_stat(&fscache_n_alloc_ops);
52849 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52850
52851 ret = fscache_wait_for_retrieval_activation(
52852 object, op,
52853 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52854
52855 error:
52856 if (ret == -ERESTARTSYS)
52857 - fscache_stat(&fscache_n_allocs_intr);
52858 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52859 else if (ret < 0)
52860 - fscache_stat(&fscache_n_allocs_nobufs);
52861 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52862 else
52863 - fscache_stat(&fscache_n_allocs_ok);
52864 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52865
52866 fscache_put_retrieval(op);
52867 _leave(" = %d", ret);
52868 @@ -677,7 +677,7 @@ nobufs_unlock:
52869 spin_unlock(&cookie->lock);
52870 kfree(op);
52871 nobufs:
52872 - fscache_stat(&fscache_n_allocs_nobufs);
52873 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52874 _leave(" = -ENOBUFS");
52875 return -ENOBUFS;
52876 }
52877 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52878
52879 spin_lock(&cookie->stores_lock);
52880
52881 - fscache_stat(&fscache_n_store_calls);
52882 + fscache_stat_unchecked(&fscache_n_store_calls);
52883
52884 /* find a page to store */
52885 page = NULL;
52886 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52887 page = results[0];
52888 _debug("gang %d [%lx]", n, page->index);
52889 if (page->index > op->store_limit) {
52890 - fscache_stat(&fscache_n_store_pages_over_limit);
52891 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52892 goto superseded;
52893 }
52894
52895 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52896 spin_unlock(&cookie->stores_lock);
52897 spin_unlock(&object->lock);
52898
52899 - fscache_stat(&fscache_n_store_pages);
52900 + fscache_stat_unchecked(&fscache_n_store_pages);
52901 fscache_stat(&fscache_n_cop_write_page);
52902 ret = object->cache->ops->write_page(op, page);
52903 fscache_stat_d(&fscache_n_cop_write_page);
52904 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52905 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52906 ASSERT(PageFsCache(page));
52907
52908 - fscache_stat(&fscache_n_stores);
52909 + fscache_stat_unchecked(&fscache_n_stores);
52910
52911 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52912 _leave(" = -ENOBUFS [invalidating]");
52913 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52914 spin_unlock(&cookie->stores_lock);
52915 spin_unlock(&object->lock);
52916
52917 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52918 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52919 op->store_limit = object->store_limit;
52920
52921 if (fscache_submit_op(object, &op->op) < 0)
52922 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52923
52924 spin_unlock(&cookie->lock);
52925 radix_tree_preload_end();
52926 - fscache_stat(&fscache_n_store_ops);
52927 - fscache_stat(&fscache_n_stores_ok);
52928 + fscache_stat_unchecked(&fscache_n_store_ops);
52929 + fscache_stat_unchecked(&fscache_n_stores_ok);
52930
52931 /* the work queue now carries its own ref on the object */
52932 fscache_put_operation(&op->op);
52933 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52934 return 0;
52935
52936 already_queued:
52937 - fscache_stat(&fscache_n_stores_again);
52938 + fscache_stat_unchecked(&fscache_n_stores_again);
52939 already_pending:
52940 spin_unlock(&cookie->stores_lock);
52941 spin_unlock(&object->lock);
52942 spin_unlock(&cookie->lock);
52943 radix_tree_preload_end();
52944 kfree(op);
52945 - fscache_stat(&fscache_n_stores_ok);
52946 + fscache_stat_unchecked(&fscache_n_stores_ok);
52947 _leave(" = 0");
52948 return 0;
52949
52950 @@ -959,14 +959,14 @@ nobufs:
52951 spin_unlock(&cookie->lock);
52952 radix_tree_preload_end();
52953 kfree(op);
52954 - fscache_stat(&fscache_n_stores_nobufs);
52955 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52956 _leave(" = -ENOBUFS");
52957 return -ENOBUFS;
52958
52959 nomem_free:
52960 kfree(op);
52961 nomem:
52962 - fscache_stat(&fscache_n_stores_oom);
52963 + fscache_stat_unchecked(&fscache_n_stores_oom);
52964 _leave(" = -ENOMEM");
52965 return -ENOMEM;
52966 }
52967 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52968 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52969 ASSERTCMP(page, !=, NULL);
52970
52971 - fscache_stat(&fscache_n_uncaches);
52972 + fscache_stat_unchecked(&fscache_n_uncaches);
52973
52974 /* cache withdrawal may beat us to it */
52975 if (!PageFsCache(page))
52976 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52977 struct fscache_cookie *cookie = op->op.object->cookie;
52978
52979 #ifdef CONFIG_FSCACHE_STATS
52980 - atomic_inc(&fscache_n_marks);
52981 + atomic_inc_unchecked(&fscache_n_marks);
52982 #endif
52983
52984 _debug("- mark %p{%lx}", page, page->index);
52985 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52986 index 8179e8b..5072cc7 100644
52987 --- a/fs/fscache/stats.c
52988 +++ b/fs/fscache/stats.c
52989 @@ -18,99 +18,99 @@
52990 /*
52991 * operation counters
52992 */
52993 -atomic_t fscache_n_op_pend;
52994 -atomic_t fscache_n_op_run;
52995 -atomic_t fscache_n_op_enqueue;
52996 -atomic_t fscache_n_op_requeue;
52997 -atomic_t fscache_n_op_deferred_release;
52998 -atomic_t fscache_n_op_release;
52999 -atomic_t fscache_n_op_gc;
53000 -atomic_t fscache_n_op_cancelled;
53001 -atomic_t fscache_n_op_rejected;
53002 +atomic_unchecked_t fscache_n_op_pend;
53003 +atomic_unchecked_t fscache_n_op_run;
53004 +atomic_unchecked_t fscache_n_op_enqueue;
53005 +atomic_unchecked_t fscache_n_op_requeue;
53006 +atomic_unchecked_t fscache_n_op_deferred_release;
53007 +atomic_unchecked_t fscache_n_op_release;
53008 +atomic_unchecked_t fscache_n_op_gc;
53009 +atomic_unchecked_t fscache_n_op_cancelled;
53010 +atomic_unchecked_t fscache_n_op_rejected;
53011
53012 -atomic_t fscache_n_attr_changed;
53013 -atomic_t fscache_n_attr_changed_ok;
53014 -atomic_t fscache_n_attr_changed_nobufs;
53015 -atomic_t fscache_n_attr_changed_nomem;
53016 -atomic_t fscache_n_attr_changed_calls;
53017 +atomic_unchecked_t fscache_n_attr_changed;
53018 +atomic_unchecked_t fscache_n_attr_changed_ok;
53019 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
53020 +atomic_unchecked_t fscache_n_attr_changed_nomem;
53021 +atomic_unchecked_t fscache_n_attr_changed_calls;
53022
53023 -atomic_t fscache_n_allocs;
53024 -atomic_t fscache_n_allocs_ok;
53025 -atomic_t fscache_n_allocs_wait;
53026 -atomic_t fscache_n_allocs_nobufs;
53027 -atomic_t fscache_n_allocs_intr;
53028 -atomic_t fscache_n_allocs_object_dead;
53029 -atomic_t fscache_n_alloc_ops;
53030 -atomic_t fscache_n_alloc_op_waits;
53031 +atomic_unchecked_t fscache_n_allocs;
53032 +atomic_unchecked_t fscache_n_allocs_ok;
53033 +atomic_unchecked_t fscache_n_allocs_wait;
53034 +atomic_unchecked_t fscache_n_allocs_nobufs;
53035 +atomic_unchecked_t fscache_n_allocs_intr;
53036 +atomic_unchecked_t fscache_n_allocs_object_dead;
53037 +atomic_unchecked_t fscache_n_alloc_ops;
53038 +atomic_unchecked_t fscache_n_alloc_op_waits;
53039
53040 -atomic_t fscache_n_retrievals;
53041 -atomic_t fscache_n_retrievals_ok;
53042 -atomic_t fscache_n_retrievals_wait;
53043 -atomic_t fscache_n_retrievals_nodata;
53044 -atomic_t fscache_n_retrievals_nobufs;
53045 -atomic_t fscache_n_retrievals_intr;
53046 -atomic_t fscache_n_retrievals_nomem;
53047 -atomic_t fscache_n_retrievals_object_dead;
53048 -atomic_t fscache_n_retrieval_ops;
53049 -atomic_t fscache_n_retrieval_op_waits;
53050 +atomic_unchecked_t fscache_n_retrievals;
53051 +atomic_unchecked_t fscache_n_retrievals_ok;
53052 +atomic_unchecked_t fscache_n_retrievals_wait;
53053 +atomic_unchecked_t fscache_n_retrievals_nodata;
53054 +atomic_unchecked_t fscache_n_retrievals_nobufs;
53055 +atomic_unchecked_t fscache_n_retrievals_intr;
53056 +atomic_unchecked_t fscache_n_retrievals_nomem;
53057 +atomic_unchecked_t fscache_n_retrievals_object_dead;
53058 +atomic_unchecked_t fscache_n_retrieval_ops;
53059 +atomic_unchecked_t fscache_n_retrieval_op_waits;
53060
53061 -atomic_t fscache_n_stores;
53062 -atomic_t fscache_n_stores_ok;
53063 -atomic_t fscache_n_stores_again;
53064 -atomic_t fscache_n_stores_nobufs;
53065 -atomic_t fscache_n_stores_oom;
53066 -atomic_t fscache_n_store_ops;
53067 -atomic_t fscache_n_store_calls;
53068 -atomic_t fscache_n_store_pages;
53069 -atomic_t fscache_n_store_radix_deletes;
53070 -atomic_t fscache_n_store_pages_over_limit;
53071 +atomic_unchecked_t fscache_n_stores;
53072 +atomic_unchecked_t fscache_n_stores_ok;
53073 +atomic_unchecked_t fscache_n_stores_again;
53074 +atomic_unchecked_t fscache_n_stores_nobufs;
53075 +atomic_unchecked_t fscache_n_stores_oom;
53076 +atomic_unchecked_t fscache_n_store_ops;
53077 +atomic_unchecked_t fscache_n_store_calls;
53078 +atomic_unchecked_t fscache_n_store_pages;
53079 +atomic_unchecked_t fscache_n_store_radix_deletes;
53080 +atomic_unchecked_t fscache_n_store_pages_over_limit;
53081
53082 -atomic_t fscache_n_store_vmscan_not_storing;
53083 -atomic_t fscache_n_store_vmscan_gone;
53084 -atomic_t fscache_n_store_vmscan_busy;
53085 -atomic_t fscache_n_store_vmscan_cancelled;
53086 -atomic_t fscache_n_store_vmscan_wait;
53087 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53088 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53089 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53090 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53091 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53092
53093 -atomic_t fscache_n_marks;
53094 -atomic_t fscache_n_uncaches;
53095 +atomic_unchecked_t fscache_n_marks;
53096 +atomic_unchecked_t fscache_n_uncaches;
53097
53098 -atomic_t fscache_n_acquires;
53099 -atomic_t fscache_n_acquires_null;
53100 -atomic_t fscache_n_acquires_no_cache;
53101 -atomic_t fscache_n_acquires_ok;
53102 -atomic_t fscache_n_acquires_nobufs;
53103 -atomic_t fscache_n_acquires_oom;
53104 +atomic_unchecked_t fscache_n_acquires;
53105 +atomic_unchecked_t fscache_n_acquires_null;
53106 +atomic_unchecked_t fscache_n_acquires_no_cache;
53107 +atomic_unchecked_t fscache_n_acquires_ok;
53108 +atomic_unchecked_t fscache_n_acquires_nobufs;
53109 +atomic_unchecked_t fscache_n_acquires_oom;
53110
53111 -atomic_t fscache_n_invalidates;
53112 -atomic_t fscache_n_invalidates_run;
53113 +atomic_unchecked_t fscache_n_invalidates;
53114 +atomic_unchecked_t fscache_n_invalidates_run;
53115
53116 -atomic_t fscache_n_updates;
53117 -atomic_t fscache_n_updates_null;
53118 -atomic_t fscache_n_updates_run;
53119 +atomic_unchecked_t fscache_n_updates;
53120 +atomic_unchecked_t fscache_n_updates_null;
53121 +atomic_unchecked_t fscache_n_updates_run;
53122
53123 -atomic_t fscache_n_relinquishes;
53124 -atomic_t fscache_n_relinquishes_null;
53125 -atomic_t fscache_n_relinquishes_waitcrt;
53126 -atomic_t fscache_n_relinquishes_retire;
53127 +atomic_unchecked_t fscache_n_relinquishes;
53128 +atomic_unchecked_t fscache_n_relinquishes_null;
53129 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53130 +atomic_unchecked_t fscache_n_relinquishes_retire;
53131
53132 -atomic_t fscache_n_cookie_index;
53133 -atomic_t fscache_n_cookie_data;
53134 -atomic_t fscache_n_cookie_special;
53135 +atomic_unchecked_t fscache_n_cookie_index;
53136 +atomic_unchecked_t fscache_n_cookie_data;
53137 +atomic_unchecked_t fscache_n_cookie_special;
53138
53139 -atomic_t fscache_n_object_alloc;
53140 -atomic_t fscache_n_object_no_alloc;
53141 -atomic_t fscache_n_object_lookups;
53142 -atomic_t fscache_n_object_lookups_negative;
53143 -atomic_t fscache_n_object_lookups_positive;
53144 -atomic_t fscache_n_object_lookups_timed_out;
53145 -atomic_t fscache_n_object_created;
53146 -atomic_t fscache_n_object_avail;
53147 -atomic_t fscache_n_object_dead;
53148 +atomic_unchecked_t fscache_n_object_alloc;
53149 +atomic_unchecked_t fscache_n_object_no_alloc;
53150 +atomic_unchecked_t fscache_n_object_lookups;
53151 +atomic_unchecked_t fscache_n_object_lookups_negative;
53152 +atomic_unchecked_t fscache_n_object_lookups_positive;
53153 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53154 +atomic_unchecked_t fscache_n_object_created;
53155 +atomic_unchecked_t fscache_n_object_avail;
53156 +atomic_unchecked_t fscache_n_object_dead;
53157
53158 -atomic_t fscache_n_checkaux_none;
53159 -atomic_t fscache_n_checkaux_okay;
53160 -atomic_t fscache_n_checkaux_update;
53161 -atomic_t fscache_n_checkaux_obsolete;
53162 +atomic_unchecked_t fscache_n_checkaux_none;
53163 +atomic_unchecked_t fscache_n_checkaux_okay;
53164 +atomic_unchecked_t fscache_n_checkaux_update;
53165 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53166
53167 atomic_t fscache_n_cop_alloc_object;
53168 atomic_t fscache_n_cop_lookup_object;
53169 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53170 seq_puts(m, "FS-Cache statistics\n");
53171
53172 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53173 - atomic_read(&fscache_n_cookie_index),
53174 - atomic_read(&fscache_n_cookie_data),
53175 - atomic_read(&fscache_n_cookie_special));
53176 + atomic_read_unchecked(&fscache_n_cookie_index),
53177 + atomic_read_unchecked(&fscache_n_cookie_data),
53178 + atomic_read_unchecked(&fscache_n_cookie_special));
53179
53180 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53181 - atomic_read(&fscache_n_object_alloc),
53182 - atomic_read(&fscache_n_object_no_alloc),
53183 - atomic_read(&fscache_n_object_avail),
53184 - atomic_read(&fscache_n_object_dead));
53185 + atomic_read_unchecked(&fscache_n_object_alloc),
53186 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53187 + atomic_read_unchecked(&fscache_n_object_avail),
53188 + atomic_read_unchecked(&fscache_n_object_dead));
53189 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53190 - atomic_read(&fscache_n_checkaux_none),
53191 - atomic_read(&fscache_n_checkaux_okay),
53192 - atomic_read(&fscache_n_checkaux_update),
53193 - atomic_read(&fscache_n_checkaux_obsolete));
53194 + atomic_read_unchecked(&fscache_n_checkaux_none),
53195 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53196 + atomic_read_unchecked(&fscache_n_checkaux_update),
53197 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53198
53199 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53200 - atomic_read(&fscache_n_marks),
53201 - atomic_read(&fscache_n_uncaches));
53202 + atomic_read_unchecked(&fscache_n_marks),
53203 + atomic_read_unchecked(&fscache_n_uncaches));
53204
53205 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53206 " oom=%u\n",
53207 - atomic_read(&fscache_n_acquires),
53208 - atomic_read(&fscache_n_acquires_null),
53209 - atomic_read(&fscache_n_acquires_no_cache),
53210 - atomic_read(&fscache_n_acquires_ok),
53211 - atomic_read(&fscache_n_acquires_nobufs),
53212 - atomic_read(&fscache_n_acquires_oom));
53213 + atomic_read_unchecked(&fscache_n_acquires),
53214 + atomic_read_unchecked(&fscache_n_acquires_null),
53215 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53216 + atomic_read_unchecked(&fscache_n_acquires_ok),
53217 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53218 + atomic_read_unchecked(&fscache_n_acquires_oom));
53219
53220 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53221 - atomic_read(&fscache_n_object_lookups),
53222 - atomic_read(&fscache_n_object_lookups_negative),
53223 - atomic_read(&fscache_n_object_lookups_positive),
53224 - atomic_read(&fscache_n_object_created),
53225 - atomic_read(&fscache_n_object_lookups_timed_out));
53226 + atomic_read_unchecked(&fscache_n_object_lookups),
53227 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53228 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53229 + atomic_read_unchecked(&fscache_n_object_created),
53230 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53231
53232 seq_printf(m, "Invals : n=%u run=%u\n",
53233 - atomic_read(&fscache_n_invalidates),
53234 - atomic_read(&fscache_n_invalidates_run));
53235 + atomic_read_unchecked(&fscache_n_invalidates),
53236 + atomic_read_unchecked(&fscache_n_invalidates_run));
53237
53238 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53239 - atomic_read(&fscache_n_updates),
53240 - atomic_read(&fscache_n_updates_null),
53241 - atomic_read(&fscache_n_updates_run));
53242 + atomic_read_unchecked(&fscache_n_updates),
53243 + atomic_read_unchecked(&fscache_n_updates_null),
53244 + atomic_read_unchecked(&fscache_n_updates_run));
53245
53246 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53247 - atomic_read(&fscache_n_relinquishes),
53248 - atomic_read(&fscache_n_relinquishes_null),
53249 - atomic_read(&fscache_n_relinquishes_waitcrt),
53250 - atomic_read(&fscache_n_relinquishes_retire));
53251 + atomic_read_unchecked(&fscache_n_relinquishes),
53252 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53253 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53254 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53255
53256 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53257 - atomic_read(&fscache_n_attr_changed),
53258 - atomic_read(&fscache_n_attr_changed_ok),
53259 - atomic_read(&fscache_n_attr_changed_nobufs),
53260 - atomic_read(&fscache_n_attr_changed_nomem),
53261 - atomic_read(&fscache_n_attr_changed_calls));
53262 + atomic_read_unchecked(&fscache_n_attr_changed),
53263 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53264 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53265 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53266 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53267
53268 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53269 - atomic_read(&fscache_n_allocs),
53270 - atomic_read(&fscache_n_allocs_ok),
53271 - atomic_read(&fscache_n_allocs_wait),
53272 - atomic_read(&fscache_n_allocs_nobufs),
53273 - atomic_read(&fscache_n_allocs_intr));
53274 + atomic_read_unchecked(&fscache_n_allocs),
53275 + atomic_read_unchecked(&fscache_n_allocs_ok),
53276 + atomic_read_unchecked(&fscache_n_allocs_wait),
53277 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53278 + atomic_read_unchecked(&fscache_n_allocs_intr));
53279 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53280 - atomic_read(&fscache_n_alloc_ops),
53281 - atomic_read(&fscache_n_alloc_op_waits),
53282 - atomic_read(&fscache_n_allocs_object_dead));
53283 + atomic_read_unchecked(&fscache_n_alloc_ops),
53284 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53285 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53286
53287 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53288 " int=%u oom=%u\n",
53289 - atomic_read(&fscache_n_retrievals),
53290 - atomic_read(&fscache_n_retrievals_ok),
53291 - atomic_read(&fscache_n_retrievals_wait),
53292 - atomic_read(&fscache_n_retrievals_nodata),
53293 - atomic_read(&fscache_n_retrievals_nobufs),
53294 - atomic_read(&fscache_n_retrievals_intr),
53295 - atomic_read(&fscache_n_retrievals_nomem));
53296 + atomic_read_unchecked(&fscache_n_retrievals),
53297 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53298 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53299 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53300 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53301 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53302 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53303 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53304 - atomic_read(&fscache_n_retrieval_ops),
53305 - atomic_read(&fscache_n_retrieval_op_waits),
53306 - atomic_read(&fscache_n_retrievals_object_dead));
53307 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53308 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53309 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53310
53311 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53312 - atomic_read(&fscache_n_stores),
53313 - atomic_read(&fscache_n_stores_ok),
53314 - atomic_read(&fscache_n_stores_again),
53315 - atomic_read(&fscache_n_stores_nobufs),
53316 - atomic_read(&fscache_n_stores_oom));
53317 + atomic_read_unchecked(&fscache_n_stores),
53318 + atomic_read_unchecked(&fscache_n_stores_ok),
53319 + atomic_read_unchecked(&fscache_n_stores_again),
53320 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53321 + atomic_read_unchecked(&fscache_n_stores_oom));
53322 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53323 - atomic_read(&fscache_n_store_ops),
53324 - atomic_read(&fscache_n_store_calls),
53325 - atomic_read(&fscache_n_store_pages),
53326 - atomic_read(&fscache_n_store_radix_deletes),
53327 - atomic_read(&fscache_n_store_pages_over_limit));
53328 + atomic_read_unchecked(&fscache_n_store_ops),
53329 + atomic_read_unchecked(&fscache_n_store_calls),
53330 + atomic_read_unchecked(&fscache_n_store_pages),
53331 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53332 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53333
53334 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53335 - atomic_read(&fscache_n_store_vmscan_not_storing),
53336 - atomic_read(&fscache_n_store_vmscan_gone),
53337 - atomic_read(&fscache_n_store_vmscan_busy),
53338 - atomic_read(&fscache_n_store_vmscan_cancelled),
53339 - atomic_read(&fscache_n_store_vmscan_wait));
53340 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53341 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53342 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53343 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53344 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53345
53346 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53347 - atomic_read(&fscache_n_op_pend),
53348 - atomic_read(&fscache_n_op_run),
53349 - atomic_read(&fscache_n_op_enqueue),
53350 - atomic_read(&fscache_n_op_cancelled),
53351 - atomic_read(&fscache_n_op_rejected));
53352 + atomic_read_unchecked(&fscache_n_op_pend),
53353 + atomic_read_unchecked(&fscache_n_op_run),
53354 + atomic_read_unchecked(&fscache_n_op_enqueue),
53355 + atomic_read_unchecked(&fscache_n_op_cancelled),
53356 + atomic_read_unchecked(&fscache_n_op_rejected));
53357 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53358 - atomic_read(&fscache_n_op_deferred_release),
53359 - atomic_read(&fscache_n_op_release),
53360 - atomic_read(&fscache_n_op_gc));
53361 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53362 + atomic_read_unchecked(&fscache_n_op_release),
53363 + atomic_read_unchecked(&fscache_n_op_gc));
53364
53365 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53366 atomic_read(&fscache_n_cop_alloc_object),
53367 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53368 index e397b67..b0d8709 100644
53369 --- a/fs/fuse/cuse.c
53370 +++ b/fs/fuse/cuse.c
53371 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
53372 INIT_LIST_HEAD(&cuse_conntbl[i]);
53373
53374 /* inherit and extend fuse_dev_operations */
53375 - cuse_channel_fops = fuse_dev_operations;
53376 - cuse_channel_fops.owner = THIS_MODULE;
53377 - cuse_channel_fops.open = cuse_channel_open;
53378 - cuse_channel_fops.release = cuse_channel_release;
53379 + pax_open_kernel();
53380 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53381 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53382 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53383 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53384 + pax_close_kernel();
53385
53386 cuse_class = class_create(THIS_MODULE, "cuse");
53387 if (IS_ERR(cuse_class))
53388 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53389 index e83351a..41e3c9c 100644
53390 --- a/fs/fuse/dev.c
53391 +++ b/fs/fuse/dev.c
53392 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53393 ret = 0;
53394 pipe_lock(pipe);
53395
53396 - if (!pipe->readers) {
53397 + if (!atomic_read(&pipe->readers)) {
53398 send_sig(SIGPIPE, current, 0);
53399 if (!ret)
53400 ret = -EPIPE;
53401 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53402 index 315e1f8..91f890c 100644
53403 --- a/fs/fuse/dir.c
53404 +++ b/fs/fuse/dir.c
53405 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
53406 return link;
53407 }
53408
53409 -static void free_link(char *link)
53410 +static void free_link(const char *link)
53411 {
53412 if (!IS_ERR(link))
53413 free_page((unsigned long) link);
53414 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53415 index 2b6f569..fcb4d1f 100644
53416 --- a/fs/gfs2/inode.c
53417 +++ b/fs/gfs2/inode.c
53418 @@ -1499,7 +1499,7 @@ out:
53419
53420 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53421 {
53422 - char *s = nd_get_link(nd);
53423 + const char *s = nd_get_link(nd);
53424 if (!IS_ERR(s))
53425 kfree(s);
53426 }
53427 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53428 index 78bde32..767e906 100644
53429 --- a/fs/hugetlbfs/inode.c
53430 +++ b/fs/hugetlbfs/inode.c
53431 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53432 struct mm_struct *mm = current->mm;
53433 struct vm_area_struct *vma;
53434 struct hstate *h = hstate_file(file);
53435 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53436 struct vm_unmapped_area_info info;
53437
53438 if (len & ~huge_page_mask(h))
53439 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53440 return addr;
53441 }
53442
53443 +#ifdef CONFIG_PAX_RANDMMAP
53444 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53445 +#endif
53446 +
53447 if (addr) {
53448 addr = ALIGN(addr, huge_page_size(h));
53449 vma = find_vma(mm, addr);
53450 - if (TASK_SIZE - len >= addr &&
53451 - (!vma || addr + len <= vma->vm_start))
53452 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53453 return addr;
53454 }
53455
53456 info.flags = 0;
53457 info.length = len;
53458 info.low_limit = TASK_UNMAPPED_BASE;
53459 +
53460 +#ifdef CONFIG_PAX_RANDMMAP
53461 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53462 + info.low_limit += mm->delta_mmap;
53463 +#endif
53464 +
53465 info.high_limit = TASK_SIZE;
53466 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53467 info.align_offset = 0;
53468 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53469 .kill_sb = kill_litter_super,
53470 };
53471
53472 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53473 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53474
53475 static int can_do_hugetlb_shm(void)
53476 {
53477 diff --git a/fs/inode.c b/fs/inode.c
53478 index b98540e..6a439ea 100644
53479 --- a/fs/inode.c
53480 +++ b/fs/inode.c
53481 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
53482
53483 #ifdef CONFIG_SMP
53484 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53485 - static atomic_t shared_last_ino;
53486 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53487 + static atomic_unchecked_t shared_last_ino;
53488 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53489
53490 res = next - LAST_INO_BATCH;
53491 }
53492 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53493 index 4a6cf28..d3a29d3 100644
53494 --- a/fs/jffs2/erase.c
53495 +++ b/fs/jffs2/erase.c
53496 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53497 struct jffs2_unknown_node marker = {
53498 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53499 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53500 - .totlen = cpu_to_je32(c->cleanmarker_size)
53501 + .totlen = cpu_to_je32(c->cleanmarker_size),
53502 + .hdr_crc = cpu_to_je32(0)
53503 };
53504
53505 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53506 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53507 index a6597d6..41b30ec 100644
53508 --- a/fs/jffs2/wbuf.c
53509 +++ b/fs/jffs2/wbuf.c
53510 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53511 {
53512 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53513 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53514 - .totlen = constant_cpu_to_je32(8)
53515 + .totlen = constant_cpu_to_je32(8),
53516 + .hdr_crc = constant_cpu_to_je32(0)
53517 };
53518
53519 /*
53520 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53521 index 1a543be..a4e1363 100644
53522 --- a/fs/jfs/super.c
53523 +++ b/fs/jfs/super.c
53524 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
53525 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53526 int *flag)
53527 {
53528 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
53529 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
53530 char *p;
53531 struct jfs_sb_info *sbi = JFS_SBI(sb);
53532
53533 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53534 /* Don't do anything ;-) */
53535 break;
53536 case Opt_iocharset:
53537 - if (nls_map && nls_map != (void *) -1)
53538 + if (nls_map && nls_map != (const void *) -1)
53539 unload_nls(nls_map);
53540 if (!strcmp(args[0].from, "none"))
53541 nls_map = NULL;
53542 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
53543
53544 jfs_inode_cachep =
53545 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53546 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53547 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53548 init_once);
53549 if (jfs_inode_cachep == NULL)
53550 return -ENOMEM;
53551 diff --git a/fs/libfs.c b/fs/libfs.c
53552 index 916da8c..1588998 100644
53553 --- a/fs/libfs.c
53554 +++ b/fs/libfs.c
53555 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53556
53557 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53558 struct dentry *next;
53559 + char d_name[sizeof(next->d_iname)];
53560 + const unsigned char *name;
53561 +
53562 next = list_entry(p, struct dentry, d_u.d_child);
53563 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53564 if (!simple_positive(next)) {
53565 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53566
53567 spin_unlock(&next->d_lock);
53568 spin_unlock(&dentry->d_lock);
53569 - if (filldir(dirent, next->d_name.name,
53570 + name = next->d_name.name;
53571 + if (name == next->d_iname) {
53572 + memcpy(d_name, name, next->d_name.len);
53573 + name = d_name;
53574 + }
53575 + if (filldir(dirent, name,
53576 next->d_name.len, filp->f_pos,
53577 next->d_inode->i_ino,
53578 dt_type(next->d_inode)) < 0)
53579 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53580 index 52e5120..808936e 100644
53581 --- a/fs/lockd/clntproc.c
53582 +++ b/fs/lockd/clntproc.c
53583 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53584 /*
53585 * Cookie counter for NLM requests
53586 */
53587 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53588 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53589
53590 void nlmclnt_next_cookie(struct nlm_cookie *c)
53591 {
53592 - u32 cookie = atomic_inc_return(&nlm_cookie);
53593 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53594
53595 memcpy(c->data, &cookie, 4);
53596 c->len=4;
53597 diff --git a/fs/locks.c b/fs/locks.c
53598 index a94e331..060bce3 100644
53599 --- a/fs/locks.c
53600 +++ b/fs/locks.c
53601 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53602 return;
53603
53604 if (filp->f_op && filp->f_op->flock) {
53605 - struct file_lock fl = {
53606 + struct file_lock flock = {
53607 .fl_pid = current->tgid,
53608 .fl_file = filp,
53609 .fl_flags = FL_FLOCK,
53610 .fl_type = F_UNLCK,
53611 .fl_end = OFFSET_MAX,
53612 };
53613 - filp->f_op->flock(filp, F_SETLKW, &fl);
53614 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53615 - fl.fl_ops->fl_release_private(&fl);
53616 + filp->f_op->flock(filp, F_SETLKW, &flock);
53617 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53618 + flock.fl_ops->fl_release_private(&flock);
53619 }
53620
53621 lock_flocks();
53622 diff --git a/fs/namei.c b/fs/namei.c
53623 index ec97aef..e67718d 100644
53624 --- a/fs/namei.c
53625 +++ b/fs/namei.c
53626 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53627 if (ret != -EACCES)
53628 return ret;
53629
53630 +#ifdef CONFIG_GRKERNSEC
53631 + /* we'll block if we have to log due to a denied capability use */
53632 + if (mask & MAY_NOT_BLOCK)
53633 + return -ECHILD;
53634 +#endif
53635 +
53636 if (S_ISDIR(inode->i_mode)) {
53637 /* DACs are overridable for directories */
53638 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53639 - return 0;
53640 if (!(mask & MAY_WRITE))
53641 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53642 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53643 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53644 return 0;
53645 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53646 + return 0;
53647 return -EACCES;
53648 }
53649 /*
53650 + * Searching includes executable on directories, else just read.
53651 + */
53652 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53653 + if (mask == MAY_READ)
53654 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53655 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53656 + return 0;
53657 +
53658 + /*
53659 * Read/write DACs are always overridable.
53660 * Executable DACs are overridable when there is
53661 * at least one exec bit set.
53662 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53663 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53664 return 0;
53665
53666 - /*
53667 - * Searching includes executable on directories, else just read.
53668 - */
53669 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53670 - if (mask == MAY_READ)
53671 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53672 - return 0;
53673 -
53674 return -EACCES;
53675 }
53676
53677 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53678 {
53679 struct dentry *dentry = link->dentry;
53680 int error;
53681 - char *s;
53682 + const char *s;
53683
53684 BUG_ON(nd->flags & LOOKUP_RCU);
53685
53686 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53687 if (error)
53688 goto out_put_nd_path;
53689
53690 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53691 + dentry->d_inode, dentry, nd->path.mnt)) {
53692 + error = -EACCES;
53693 + goto out_put_nd_path;
53694 + }
53695 +
53696 nd->last_type = LAST_BIND;
53697 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53698 error = PTR_ERR(*p);
53699 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53700 break;
53701 res = walk_component(nd, path, &nd->last,
53702 nd->last_type, LOOKUP_FOLLOW);
53703 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53704 + res = -EACCES;
53705 put_link(nd, &link, cookie);
53706 } while (res > 0);
53707
53708 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
53709 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53710 {
53711 unsigned long a, b, adata, bdata, mask, hash, len;
53712 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53713 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53714
53715 hash = a = 0;
53716 len = -sizeof(unsigned long);
53717 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
53718 if (err)
53719 break;
53720 err = lookup_last(nd, &path);
53721 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53722 + err = -EACCES;
53723 put_link(nd, &link, cookie);
53724 }
53725 }
53726 @@ -1984,6 +2002,13 @@ static int path_lookupat(int dfd, const char *name,
53727 if (!err)
53728 err = complete_walk(nd);
53729
53730 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53731 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53732 + path_put(&nd->path);
53733 + err = -ENOENT;
53734 + }
53735 + }
53736 +
53737 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53738 if (!nd->inode->i_op->lookup) {
53739 path_put(&nd->path);
53740 @@ -2011,8 +2036,15 @@ static int filename_lookup(int dfd, struct filename *name,
53741 retval = path_lookupat(dfd, name->name,
53742 flags | LOOKUP_REVAL, nd);
53743
53744 - if (likely(!retval))
53745 + if (likely(!retval)) {
53746 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53747 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53748 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53749 + path_put(&nd->path);
53750 + return -ENOENT;
53751 + }
53752 + }
53753 + }
53754 return retval;
53755 }
53756
53757 @@ -2390,6 +2422,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53758 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53759 return -EPERM;
53760
53761 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53762 + return -EPERM;
53763 + if (gr_handle_rawio(inode))
53764 + return -EPERM;
53765 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53766 + return -EACCES;
53767 +
53768 return 0;
53769 }
53770
53771 @@ -2611,7 +2650,7 @@ looked_up:
53772 * cleared otherwise prior to returning.
53773 */
53774 static int lookup_open(struct nameidata *nd, struct path *path,
53775 - struct file *file,
53776 + struct path *link, struct file *file,
53777 const struct open_flags *op,
53778 bool got_write, int *opened)
53779 {
53780 @@ -2646,6 +2685,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53781 /* Negative dentry, just create the file */
53782 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53783 umode_t mode = op->mode;
53784 +
53785 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53786 + error = -EACCES;
53787 + goto out_dput;
53788 + }
53789 +
53790 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53791 + error = -EACCES;
53792 + goto out_dput;
53793 + }
53794 +
53795 if (!IS_POSIXACL(dir->d_inode))
53796 mode &= ~current_umask();
53797 /*
53798 @@ -2667,6 +2717,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53799 nd->flags & LOOKUP_EXCL);
53800 if (error)
53801 goto out_dput;
53802 + else
53803 + gr_handle_create(dentry, nd->path.mnt);
53804 }
53805 out_no_open:
53806 path->dentry = dentry;
53807 @@ -2681,7 +2733,7 @@ out_dput:
53808 /*
53809 * Handle the last step of open()
53810 */
53811 -static int do_last(struct nameidata *nd, struct path *path,
53812 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53813 struct file *file, const struct open_flags *op,
53814 int *opened, struct filename *name)
53815 {
53816 @@ -2710,16 +2762,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53817 error = complete_walk(nd);
53818 if (error)
53819 return error;
53820 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53821 + error = -ENOENT;
53822 + goto out;
53823 + }
53824 audit_inode(name, nd->path.dentry, 0);
53825 if (open_flag & O_CREAT) {
53826 error = -EISDIR;
53827 goto out;
53828 }
53829 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53830 + error = -EACCES;
53831 + goto out;
53832 + }
53833 goto finish_open;
53834 case LAST_BIND:
53835 error = complete_walk(nd);
53836 if (error)
53837 return error;
53838 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53839 + error = -ENOENT;
53840 + goto out;
53841 + }
53842 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53843 + error = -EACCES;
53844 + goto out;
53845 + }
53846 audit_inode(name, dir, 0);
53847 goto finish_open;
53848 }
53849 @@ -2768,7 +2836,7 @@ retry_lookup:
53850 */
53851 }
53852 mutex_lock(&dir->d_inode->i_mutex);
53853 - error = lookup_open(nd, path, file, op, got_write, opened);
53854 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53855 mutex_unlock(&dir->d_inode->i_mutex);
53856
53857 if (error <= 0) {
53858 @@ -2792,11 +2860,28 @@ retry_lookup:
53859 goto finish_open_created;
53860 }
53861
53862 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53863 + error = -ENOENT;
53864 + goto exit_dput;
53865 + }
53866 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53867 + error = -EACCES;
53868 + goto exit_dput;
53869 + }
53870 +
53871 /*
53872 * create/update audit record if it already exists.
53873 */
53874 - if (path->dentry->d_inode)
53875 + if (path->dentry->d_inode) {
53876 + /* only check if O_CREAT is specified, all other checks need to go
53877 + into may_open */
53878 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53879 + error = -EACCES;
53880 + goto exit_dput;
53881 + }
53882 +
53883 audit_inode(name, path->dentry, 0);
53884 + }
53885
53886 /*
53887 * If atomic_open() acquired write access it is dropped now due to
53888 @@ -2837,6 +2922,11 @@ finish_lookup:
53889 }
53890 }
53891 BUG_ON(inode != path->dentry->d_inode);
53892 + /* if we're resolving a symlink to another symlink */
53893 + if (link && gr_handle_symlink_owner(link, inode)) {
53894 + error = -EACCES;
53895 + goto out;
53896 + }
53897 return 1;
53898 }
53899
53900 @@ -2846,7 +2936,6 @@ finish_lookup:
53901 save_parent.dentry = nd->path.dentry;
53902 save_parent.mnt = mntget(path->mnt);
53903 nd->path.dentry = path->dentry;
53904 -
53905 }
53906 nd->inode = inode;
53907 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53908 @@ -2855,6 +2944,16 @@ finish_lookup:
53909 path_put(&save_parent);
53910 return error;
53911 }
53912 +
53913 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53914 + error = -ENOENT;
53915 + goto out;
53916 + }
53917 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53918 + error = -EACCES;
53919 + goto out;
53920 + }
53921 +
53922 error = -EISDIR;
53923 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53924 goto out;
53925 @@ -2953,7 +3052,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53926 if (unlikely(error))
53927 goto out;
53928
53929 - error = do_last(nd, &path, file, op, &opened, pathname);
53930 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53931 while (unlikely(error > 0)) { /* trailing symlink */
53932 struct path link = path;
53933 void *cookie;
53934 @@ -2971,7 +3070,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53935 error = follow_link(&link, nd, &cookie);
53936 if (unlikely(error))
53937 break;
53938 - error = do_last(nd, &path, file, op, &opened, pathname);
53939 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53940 put_link(nd, &link, cookie);
53941 }
53942 out:
53943 @@ -3071,8 +3170,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53944 goto unlock;
53945
53946 error = -EEXIST;
53947 - if (dentry->d_inode)
53948 + if (dentry->d_inode) {
53949 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53950 + error = -ENOENT;
53951 + }
53952 goto fail;
53953 + }
53954 /*
53955 * Special case - lookup gave negative, but... we had foo/bar/
53956 * From the vfs_mknod() POV we just have a negative dentry -
53957 @@ -3124,6 +3227,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53958 }
53959 EXPORT_SYMBOL(user_path_create);
53960
53961 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53962 +{
53963 + struct filename *tmp = getname(pathname);
53964 + struct dentry *res;
53965 + if (IS_ERR(tmp))
53966 + return ERR_CAST(tmp);
53967 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53968 + if (IS_ERR(res))
53969 + putname(tmp);
53970 + else
53971 + *to = tmp;
53972 + return res;
53973 +}
53974 +
53975 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53976 {
53977 int error = may_create(dir, dentry);
53978 @@ -3186,6 +3303,17 @@ retry:
53979
53980 if (!IS_POSIXACL(path.dentry->d_inode))
53981 mode &= ~current_umask();
53982 +
53983 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53984 + error = -EPERM;
53985 + goto out;
53986 + }
53987 +
53988 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53989 + error = -EACCES;
53990 + goto out;
53991 + }
53992 +
53993 error = security_path_mknod(&path, dentry, mode, dev);
53994 if (error)
53995 goto out;
53996 @@ -3202,6 +3330,8 @@ retry:
53997 break;
53998 }
53999 out:
54000 + if (!error)
54001 + gr_handle_create(dentry, path.mnt);
54002 done_path_create(&path, dentry);
54003 if (retry_estale(error, lookup_flags)) {
54004 lookup_flags |= LOOKUP_REVAL;
54005 @@ -3254,9 +3384,16 @@ retry:
54006
54007 if (!IS_POSIXACL(path.dentry->d_inode))
54008 mode &= ~current_umask();
54009 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
54010 + error = -EACCES;
54011 + goto out;
54012 + }
54013 error = security_path_mkdir(&path, dentry, mode);
54014 if (!error)
54015 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
54016 + if (!error)
54017 + gr_handle_create(dentry, path.mnt);
54018 +out:
54019 done_path_create(&path, dentry);
54020 if (retry_estale(error, lookup_flags)) {
54021 lookup_flags |= LOOKUP_REVAL;
54022 @@ -3337,6 +3474,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
54023 struct filename *name;
54024 struct dentry *dentry;
54025 struct nameidata nd;
54026 + ino_t saved_ino = 0;
54027 + dev_t saved_dev = 0;
54028 unsigned int lookup_flags = 0;
54029 retry:
54030 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54031 @@ -3369,10 +3508,21 @@ retry:
54032 error = -ENOENT;
54033 goto exit3;
54034 }
54035 +
54036 + saved_ino = dentry->d_inode->i_ino;
54037 + saved_dev = gr_get_dev_from_dentry(dentry);
54038 +
54039 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
54040 + error = -EACCES;
54041 + goto exit3;
54042 + }
54043 +
54044 error = security_path_rmdir(&nd.path, dentry);
54045 if (error)
54046 goto exit3;
54047 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
54048 + if (!error && (saved_dev || saved_ino))
54049 + gr_handle_delete(saved_ino, saved_dev);
54050 exit3:
54051 dput(dentry);
54052 exit2:
54053 @@ -3438,6 +3588,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
54054 struct dentry *dentry;
54055 struct nameidata nd;
54056 struct inode *inode = NULL;
54057 + ino_t saved_ino = 0;
54058 + dev_t saved_dev = 0;
54059 unsigned int lookup_flags = 0;
54060 retry:
54061 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54062 @@ -3464,10 +3616,22 @@ retry:
54063 if (!inode)
54064 goto slashes;
54065 ihold(inode);
54066 +
54067 + if (inode->i_nlink <= 1) {
54068 + saved_ino = inode->i_ino;
54069 + saved_dev = gr_get_dev_from_dentry(dentry);
54070 + }
54071 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
54072 + error = -EACCES;
54073 + goto exit2;
54074 + }
54075 +
54076 error = security_path_unlink(&nd.path, dentry);
54077 if (error)
54078 goto exit2;
54079 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54080 + if (!error && (saved_ino || saved_dev))
54081 + gr_handle_delete(saved_ino, saved_dev);
54082 exit2:
54083 dput(dentry);
54084 }
54085 @@ -3545,9 +3709,17 @@ retry:
54086 if (IS_ERR(dentry))
54087 goto out_putname;
54088
54089 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54090 + error = -EACCES;
54091 + goto out;
54092 + }
54093 +
54094 error = security_path_symlink(&path, dentry, from->name);
54095 if (!error)
54096 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54097 + if (!error)
54098 + gr_handle_create(dentry, path.mnt);
54099 +out:
54100 done_path_create(&path, dentry);
54101 if (retry_estale(error, lookup_flags)) {
54102 lookup_flags |= LOOKUP_REVAL;
54103 @@ -3621,6 +3793,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54104 {
54105 struct dentry *new_dentry;
54106 struct path old_path, new_path;
54107 + struct filename *to = NULL;
54108 int how = 0;
54109 int error;
54110
54111 @@ -3644,7 +3817,7 @@ retry:
54112 if (error)
54113 return error;
54114
54115 - new_dentry = user_path_create(newdfd, newname, &new_path,
54116 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54117 (how & LOOKUP_REVAL));
54118 error = PTR_ERR(new_dentry);
54119 if (IS_ERR(new_dentry))
54120 @@ -3656,11 +3829,28 @@ retry:
54121 error = may_linkat(&old_path);
54122 if (unlikely(error))
54123 goto out_dput;
54124 +
54125 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54126 + old_path.dentry->d_inode,
54127 + old_path.dentry->d_inode->i_mode, to)) {
54128 + error = -EACCES;
54129 + goto out_dput;
54130 + }
54131 +
54132 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54133 + old_path.dentry, old_path.mnt, to)) {
54134 + error = -EACCES;
54135 + goto out_dput;
54136 + }
54137 +
54138 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54139 if (error)
54140 goto out_dput;
54141 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54142 + if (!error)
54143 + gr_handle_create(new_dentry, new_path.mnt);
54144 out_dput:
54145 + putname(to);
54146 done_path_create(&new_path, new_dentry);
54147 if (retry_estale(error, how)) {
54148 how |= LOOKUP_REVAL;
54149 @@ -3906,12 +4096,21 @@ retry:
54150 if (new_dentry == trap)
54151 goto exit5;
54152
54153 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54154 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54155 + to);
54156 + if (error)
54157 + goto exit5;
54158 +
54159 error = security_path_rename(&oldnd.path, old_dentry,
54160 &newnd.path, new_dentry);
54161 if (error)
54162 goto exit5;
54163 error = vfs_rename(old_dir->d_inode, old_dentry,
54164 new_dir->d_inode, new_dentry);
54165 + if (!error)
54166 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54167 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54168 exit5:
54169 dput(new_dentry);
54170 exit4:
54171 @@ -3943,6 +4142,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54172
54173 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54174 {
54175 + char tmpbuf[64];
54176 + const char *newlink;
54177 int len;
54178
54179 len = PTR_ERR(link);
54180 @@ -3952,7 +4153,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54181 len = strlen(link);
54182 if (len > (unsigned) buflen)
54183 len = buflen;
54184 - if (copy_to_user(buffer, link, len))
54185 +
54186 + if (len < sizeof(tmpbuf)) {
54187 + memcpy(tmpbuf, link, len);
54188 + newlink = tmpbuf;
54189 + } else
54190 + newlink = link;
54191 +
54192 + if (copy_to_user(buffer, newlink, len))
54193 len = -EFAULT;
54194 out:
54195 return len;
54196 diff --git a/fs/namespace.c b/fs/namespace.c
54197 index 5dd7709..6f64e9c 100644
54198 --- a/fs/namespace.c
54199 +++ b/fs/namespace.c
54200 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
54201 if (!(sb->s_flags & MS_RDONLY))
54202 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54203 up_write(&sb->s_umount);
54204 +
54205 + gr_log_remount(mnt->mnt_devname, retval);
54206 +
54207 return retval;
54208 }
54209
54210 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
54211 br_write_unlock(&vfsmount_lock);
54212 up_write(&namespace_sem);
54213 release_mounts(&umount_list);
54214 +
54215 + gr_log_unmount(mnt->mnt_devname, retval);
54216 +
54217 return retval;
54218 }
54219
54220 @@ -1713,7 +1719,7 @@ static int do_loopback(struct path *path, const char *old_name,
54221
54222 if (IS_ERR(mnt)) {
54223 err = PTR_ERR(mnt);
54224 - goto out;
54225 + goto out2;
54226 }
54227
54228 err = graft_tree(mnt, path);
54229 @@ -2294,6 +2300,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54230 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54231 MS_STRICTATIME);
54232
54233 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54234 + retval = -EPERM;
54235 + goto dput_out;
54236 + }
54237 +
54238 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54239 + retval = -EPERM;
54240 + goto dput_out;
54241 + }
54242 +
54243 if (flags & MS_REMOUNT)
54244 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54245 data_page);
54246 @@ -2308,6 +2324,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54247 dev_name, data_page);
54248 dput_out:
54249 path_put(&path);
54250 +
54251 + gr_log_mount(dev_name, dir_name, retval);
54252 +
54253 return retval;
54254 }
54255
54256 @@ -2594,6 +2613,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54257 if (error)
54258 goto out2;
54259
54260 + if (gr_handle_chroot_pivot()) {
54261 + error = -EPERM;
54262 + goto out2;
54263 + }
54264 +
54265 get_fs_root(current->fs, &root);
54266 error = lock_mount(&old);
54267 if (error)
54268 @@ -2842,7 +2866,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54269 !nsown_capable(CAP_SYS_ADMIN))
54270 return -EPERM;
54271
54272 - if (fs->users != 1)
54273 + if (atomic_read(&fs->users) != 1)
54274 return -EINVAL;
54275
54276 get_mnt_ns(mnt_ns);
54277 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54278 index 59461c9..b17c57e 100644
54279 --- a/fs/nfs/callback_xdr.c
54280 +++ b/fs/nfs/callback_xdr.c
54281 @@ -51,7 +51,7 @@ struct callback_op {
54282 callback_decode_arg_t decode_args;
54283 callback_encode_res_t encode_res;
54284 long res_maxsize;
54285 -};
54286 +} __do_const;
54287
54288 static struct callback_op callback_ops[];
54289
54290 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54291 index ebeb94c..ff35337 100644
54292 --- a/fs/nfs/inode.c
54293 +++ b/fs/nfs/inode.c
54294 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54295 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54296 }
54297
54298 -static atomic_long_t nfs_attr_generation_counter;
54299 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54300
54301 static unsigned long nfs_read_attr_generation_counter(void)
54302 {
54303 - return atomic_long_read(&nfs_attr_generation_counter);
54304 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54305 }
54306
54307 unsigned long nfs_inc_attr_generation_counter(void)
54308 {
54309 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54310 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54311 }
54312
54313 void nfs_fattr_init(struct nfs_fattr *fattr)
54314 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54315 index 9d1c5db..1e13db8 100644
54316 --- a/fs/nfsd/nfs4proc.c
54317 +++ b/fs/nfsd/nfs4proc.c
54318 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
54319 nfsd4op_rsize op_rsize_bop;
54320 stateid_getter op_get_currentstateid;
54321 stateid_setter op_set_currentstateid;
54322 -};
54323 +} __do_const;
54324
54325 static struct nfsd4_operation nfsd4_ops[];
54326
54327 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54328 index d1dd710..32ac0e8 100644
54329 --- a/fs/nfsd/nfs4xdr.c
54330 +++ b/fs/nfsd/nfs4xdr.c
54331 @@ -1456,7 +1456,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54332
54333 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54334
54335 -static nfsd4_dec nfsd4_dec_ops[] = {
54336 +static const nfsd4_dec nfsd4_dec_ops[] = {
54337 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54338 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54339 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54340 @@ -1496,7 +1496,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54341 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54342 };
54343
54344 -static nfsd4_dec nfsd41_dec_ops[] = {
54345 +static const nfsd4_dec nfsd41_dec_ops[] = {
54346 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54347 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54348 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54349 @@ -1558,7 +1558,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54350 };
54351
54352 struct nfsd4_minorversion_ops {
54353 - nfsd4_dec *decoders;
54354 + const nfsd4_dec *decoders;
54355 int nops;
54356 };
54357
54358 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54359 index 69c6413..c0408d2 100644
54360 --- a/fs/nfsd/vfs.c
54361 +++ b/fs/nfsd/vfs.c
54362 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54363 } else {
54364 oldfs = get_fs();
54365 set_fs(KERNEL_DS);
54366 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54367 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54368 set_fs(oldfs);
54369 }
54370
54371 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54372
54373 /* Write the data. */
54374 oldfs = get_fs(); set_fs(KERNEL_DS);
54375 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54376 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54377 set_fs(oldfs);
54378 if (host_err < 0)
54379 goto out_nfserr;
54380 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54381 */
54382
54383 oldfs = get_fs(); set_fs(KERNEL_DS);
54384 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54385 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54386 set_fs(oldfs);
54387
54388 if (host_err < 0)
54389 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54390 index fea6bd5..8ee9d81 100644
54391 --- a/fs/nls/nls_base.c
54392 +++ b/fs/nls/nls_base.c
54393 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54394
54395 int register_nls(struct nls_table * nls)
54396 {
54397 - struct nls_table ** tmp = &tables;
54398 + struct nls_table *tmp = tables;
54399
54400 if (nls->next)
54401 return -EBUSY;
54402
54403 spin_lock(&nls_lock);
54404 - while (*tmp) {
54405 - if (nls == *tmp) {
54406 + while (tmp) {
54407 + if (nls == tmp) {
54408 spin_unlock(&nls_lock);
54409 return -EBUSY;
54410 }
54411 - tmp = &(*tmp)->next;
54412 + tmp = tmp->next;
54413 }
54414 - nls->next = tables;
54415 + pax_open_kernel();
54416 + *(struct nls_table **)&nls->next = tables;
54417 + pax_close_kernel();
54418 tables = nls;
54419 spin_unlock(&nls_lock);
54420 return 0;
54421 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54422
54423 int unregister_nls(struct nls_table * nls)
54424 {
54425 - struct nls_table ** tmp = &tables;
54426 + struct nls_table * const * tmp = &tables;
54427
54428 spin_lock(&nls_lock);
54429 while (*tmp) {
54430 if (nls == *tmp) {
54431 - *tmp = nls->next;
54432 + pax_open_kernel();
54433 + *(struct nls_table **)tmp = nls->next;
54434 + pax_close_kernel();
54435 spin_unlock(&nls_lock);
54436 return 0;
54437 }
54438 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54439 index 7424929..35f6be5 100644
54440 --- a/fs/nls/nls_euc-jp.c
54441 +++ b/fs/nls/nls_euc-jp.c
54442 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54443 p_nls = load_nls("cp932");
54444
54445 if (p_nls) {
54446 - table.charset2upper = p_nls->charset2upper;
54447 - table.charset2lower = p_nls->charset2lower;
54448 + pax_open_kernel();
54449 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54450 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54451 + pax_close_kernel();
54452 return register_nls(&table);
54453 }
54454
54455 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54456 index e7bc1d7..06bd4bb 100644
54457 --- a/fs/nls/nls_koi8-ru.c
54458 +++ b/fs/nls/nls_koi8-ru.c
54459 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54460 p_nls = load_nls("koi8-u");
54461
54462 if (p_nls) {
54463 - table.charset2upper = p_nls->charset2upper;
54464 - table.charset2lower = p_nls->charset2lower;
54465 + pax_open_kernel();
54466 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54467 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54468 + pax_close_kernel();
54469 return register_nls(&table);
54470 }
54471
54472 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54473 index 9ff4a5e..deb1f0f 100644
54474 --- a/fs/notify/fanotify/fanotify_user.c
54475 +++ b/fs/notify/fanotify/fanotify_user.c
54476 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54477
54478 fd = fanotify_event_metadata.fd;
54479 ret = -EFAULT;
54480 - if (copy_to_user(buf, &fanotify_event_metadata,
54481 - fanotify_event_metadata.event_len))
54482 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54483 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54484 goto out_close_fd;
54485
54486 ret = prepare_for_access_response(group, event, fd);
54487 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54488 index 7b51b05..5ea5ef6 100644
54489 --- a/fs/notify/notification.c
54490 +++ b/fs/notify/notification.c
54491 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54492 * get set to 0 so it will never get 'freed'
54493 */
54494 static struct fsnotify_event *q_overflow_event;
54495 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54496 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54497
54498 /**
54499 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54500 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54501 */
54502 u32 fsnotify_get_cookie(void)
54503 {
54504 - return atomic_inc_return(&fsnotify_sync_cookie);
54505 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54506 }
54507 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54508
54509 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54510 index 99e3610..02c1068 100644
54511 --- a/fs/ntfs/dir.c
54512 +++ b/fs/ntfs/dir.c
54513 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54514 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54515 ~(s64)(ndir->itype.index.block_size - 1)));
54516 /* Bounds checks. */
54517 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54518 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54519 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54520 "inode 0x%lx or driver bug.", vdir->i_ino);
54521 goto err_out;
54522 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54523 index 5b2d4f0..c6de396 100644
54524 --- a/fs/ntfs/file.c
54525 +++ b/fs/ntfs/file.c
54526 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54527 #endif /* NTFS_RW */
54528 };
54529
54530 -const struct file_operations ntfs_empty_file_ops = {};
54531 +const struct file_operations ntfs_empty_file_ops __read_only;
54532
54533 -const struct inode_operations ntfs_empty_inode_ops = {};
54534 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54535 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54536 index a9f78c7..ed8a381 100644
54537 --- a/fs/ocfs2/localalloc.c
54538 +++ b/fs/ocfs2/localalloc.c
54539 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54540 goto bail;
54541 }
54542
54543 - atomic_inc(&osb->alloc_stats.moves);
54544 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54545
54546 bail:
54547 if (handle)
54548 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54549 index d355e6e..578d905 100644
54550 --- a/fs/ocfs2/ocfs2.h
54551 +++ b/fs/ocfs2/ocfs2.h
54552 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54553
54554 struct ocfs2_alloc_stats
54555 {
54556 - atomic_t moves;
54557 - atomic_t local_data;
54558 - atomic_t bitmap_data;
54559 - atomic_t bg_allocs;
54560 - atomic_t bg_extends;
54561 + atomic_unchecked_t moves;
54562 + atomic_unchecked_t local_data;
54563 + atomic_unchecked_t bitmap_data;
54564 + atomic_unchecked_t bg_allocs;
54565 + atomic_unchecked_t bg_extends;
54566 };
54567
54568 enum ocfs2_local_alloc_state
54569 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54570 index b7e74b5..19c6536 100644
54571 --- a/fs/ocfs2/suballoc.c
54572 +++ b/fs/ocfs2/suballoc.c
54573 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54574 mlog_errno(status);
54575 goto bail;
54576 }
54577 - atomic_inc(&osb->alloc_stats.bg_extends);
54578 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54579
54580 /* You should never ask for this much metadata */
54581 BUG_ON(bits_wanted >
54582 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54583 mlog_errno(status);
54584 goto bail;
54585 }
54586 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54587 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54588
54589 *suballoc_loc = res.sr_bg_blkno;
54590 *suballoc_bit_start = res.sr_bit_offset;
54591 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54592 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54593 res->sr_bits);
54594
54595 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54596 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54597
54598 BUG_ON(res->sr_bits != 1);
54599
54600 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54601 mlog_errno(status);
54602 goto bail;
54603 }
54604 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54605 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54606
54607 BUG_ON(res.sr_bits != 1);
54608
54609 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54610 cluster_start,
54611 num_clusters);
54612 if (!status)
54613 - atomic_inc(&osb->alloc_stats.local_data);
54614 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54615 } else {
54616 if (min_clusters > (osb->bitmap_cpg - 1)) {
54617 /* The only paths asking for contiguousness
54618 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54619 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54620 res.sr_bg_blkno,
54621 res.sr_bit_offset);
54622 - atomic_inc(&osb->alloc_stats.bitmap_data);
54623 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54624 *num_clusters = res.sr_bits;
54625 }
54626 }
54627 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54628 index 0e91ec2..f4b3fc6 100644
54629 --- a/fs/ocfs2/super.c
54630 +++ b/fs/ocfs2/super.c
54631 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54632 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54633 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54634 "Stats",
54635 - atomic_read(&osb->alloc_stats.bitmap_data),
54636 - atomic_read(&osb->alloc_stats.local_data),
54637 - atomic_read(&osb->alloc_stats.bg_allocs),
54638 - atomic_read(&osb->alloc_stats.moves),
54639 - atomic_read(&osb->alloc_stats.bg_extends));
54640 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54641 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54642 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54643 + atomic_read_unchecked(&osb->alloc_stats.moves),
54644 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54645
54646 out += snprintf(buf + out, len - out,
54647 "%10s => State: %u Descriptor: %llu Size: %u bits "
54648 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54649 spin_lock_init(&osb->osb_xattr_lock);
54650 ocfs2_init_steal_slots(osb);
54651
54652 - atomic_set(&osb->alloc_stats.moves, 0);
54653 - atomic_set(&osb->alloc_stats.local_data, 0);
54654 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54655 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54656 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54657 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54658 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54659 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54660 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54661 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54662
54663 /* Copy the blockcheck stats from the superblock probe */
54664 osb->osb_ecc_stats = *stats;
54665 diff --git a/fs/open.c b/fs/open.c
54666 index 9b33c0c..2ffcca2 100644
54667 --- a/fs/open.c
54668 +++ b/fs/open.c
54669 @@ -31,6 +31,8 @@
54670 #include <linux/ima.h>
54671 #include <linux/dnotify.h>
54672
54673 +#define CREATE_TRACE_POINTS
54674 +#include <trace/events/fs.h>
54675 #include "internal.h"
54676
54677 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54678 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
54679 error = locks_verify_truncate(inode, NULL, length);
54680 if (!error)
54681 error = security_path_truncate(path);
54682 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54683 + error = -EACCES;
54684 if (!error)
54685 error = do_truncate(path->dentry, length, 0, NULL);
54686
54687 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54688 error = locks_verify_truncate(inode, f.file, length);
54689 if (!error)
54690 error = security_path_truncate(&f.file->f_path);
54691 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54692 + error = -EACCES;
54693 if (!error)
54694 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54695 sb_end_write(inode->i_sb);
54696 @@ -373,6 +379,9 @@ retry:
54697 if (__mnt_is_readonly(path.mnt))
54698 res = -EROFS;
54699
54700 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54701 + res = -EACCES;
54702 +
54703 out_path_release:
54704 path_put(&path);
54705 if (retry_estale(res, lookup_flags)) {
54706 @@ -404,6 +413,8 @@ retry:
54707 if (error)
54708 goto dput_and_out;
54709
54710 + gr_log_chdir(path.dentry, path.mnt);
54711 +
54712 set_fs_pwd(current->fs, &path);
54713
54714 dput_and_out:
54715 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54716 goto out_putf;
54717
54718 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54719 +
54720 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54721 + error = -EPERM;
54722 +
54723 + if (!error)
54724 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54725 +
54726 if (!error)
54727 set_fs_pwd(current->fs, &f.file->f_path);
54728 out_putf:
54729 @@ -462,7 +480,13 @@ retry:
54730 if (error)
54731 goto dput_and_out;
54732
54733 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54734 + goto dput_and_out;
54735 +
54736 set_fs_root(current->fs, &path);
54737 +
54738 + gr_handle_chroot_chdir(&path);
54739 +
54740 error = 0;
54741 dput_and_out:
54742 path_put(&path);
54743 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
54744 if (error)
54745 return error;
54746 mutex_lock(&inode->i_mutex);
54747 +
54748 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54749 + error = -EACCES;
54750 + goto out_unlock;
54751 + }
54752 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54753 + error = -EACCES;
54754 + goto out_unlock;
54755 + }
54756 +
54757 error = security_path_chmod(path, mode);
54758 if (error)
54759 goto out_unlock;
54760 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54761 uid = make_kuid(current_user_ns(), user);
54762 gid = make_kgid(current_user_ns(), group);
54763
54764 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54765 + return -EACCES;
54766 +
54767 newattrs.ia_valid = ATTR_CTIME;
54768 if (user != (uid_t) -1) {
54769 if (!uid_valid(uid))
54770 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54771 } else {
54772 fsnotify_open(f);
54773 fd_install(fd, f);
54774 + trace_do_sys_open(tmp->name, flags, mode);
54775 }
54776 }
54777 putname(tmp);
54778 diff --git a/fs/pipe.c b/fs/pipe.c
54779 index 8e2e73f..1ef1048 100644
54780 --- a/fs/pipe.c
54781 +++ b/fs/pipe.c
54782 @@ -438,9 +438,9 @@ redo:
54783 }
54784 if (bufs) /* More to do? */
54785 continue;
54786 - if (!pipe->writers)
54787 + if (!atomic_read(&pipe->writers))
54788 break;
54789 - if (!pipe->waiting_writers) {
54790 + if (!atomic_read(&pipe->waiting_writers)) {
54791 /* syscall merging: Usually we must not sleep
54792 * if O_NONBLOCK is set, or if we got some data.
54793 * But if a writer sleeps in kernel space, then
54794 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54795 mutex_lock(&inode->i_mutex);
54796 pipe = inode->i_pipe;
54797
54798 - if (!pipe->readers) {
54799 + if (!atomic_read(&pipe->readers)) {
54800 send_sig(SIGPIPE, current, 0);
54801 ret = -EPIPE;
54802 goto out;
54803 @@ -553,7 +553,7 @@ redo1:
54804 for (;;) {
54805 int bufs;
54806
54807 - if (!pipe->readers) {
54808 + if (!atomic_read(&pipe->readers)) {
54809 send_sig(SIGPIPE, current, 0);
54810 if (!ret)
54811 ret = -EPIPE;
54812 @@ -644,9 +644,9 @@ redo2:
54813 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54814 do_wakeup = 0;
54815 }
54816 - pipe->waiting_writers++;
54817 + atomic_inc(&pipe->waiting_writers);
54818 pipe_wait(pipe);
54819 - pipe->waiting_writers--;
54820 + atomic_dec(&pipe->waiting_writers);
54821 }
54822 out:
54823 mutex_unlock(&inode->i_mutex);
54824 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54825 mask = 0;
54826 if (filp->f_mode & FMODE_READ) {
54827 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54828 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54829 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54830 mask |= POLLHUP;
54831 }
54832
54833 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54834 * Most Unices do not set POLLERR for FIFOs but on Linux they
54835 * behave exactly like pipes for poll().
54836 */
54837 - if (!pipe->readers)
54838 + if (!atomic_read(&pipe->readers))
54839 mask |= POLLERR;
54840 }
54841
54842 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54843
54844 mutex_lock(&inode->i_mutex);
54845 pipe = inode->i_pipe;
54846 - pipe->readers -= decr;
54847 - pipe->writers -= decw;
54848 + atomic_sub(decr, &pipe->readers);
54849 + atomic_sub(decw, &pipe->writers);
54850
54851 - if (!pipe->readers && !pipe->writers) {
54852 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54853 free_pipe_info(inode);
54854 } else {
54855 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54856 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54857
54858 if (inode->i_pipe) {
54859 ret = 0;
54860 - inode->i_pipe->readers++;
54861 + atomic_inc(&inode->i_pipe->readers);
54862 }
54863
54864 mutex_unlock(&inode->i_mutex);
54865 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54866
54867 if (inode->i_pipe) {
54868 ret = 0;
54869 - inode->i_pipe->writers++;
54870 + atomic_inc(&inode->i_pipe->writers);
54871 }
54872
54873 mutex_unlock(&inode->i_mutex);
54874 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54875 if (inode->i_pipe) {
54876 ret = 0;
54877 if (filp->f_mode & FMODE_READ)
54878 - inode->i_pipe->readers++;
54879 + atomic_inc(&inode->i_pipe->readers);
54880 if (filp->f_mode & FMODE_WRITE)
54881 - inode->i_pipe->writers++;
54882 + atomic_inc(&inode->i_pipe->writers);
54883 }
54884
54885 mutex_unlock(&inode->i_mutex);
54886 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54887 inode->i_pipe = NULL;
54888 }
54889
54890 -static struct vfsmount *pipe_mnt __read_mostly;
54891 +struct vfsmount *pipe_mnt __read_mostly;
54892
54893 /*
54894 * pipefs_dname() is called from d_path().
54895 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54896 goto fail_iput;
54897 inode->i_pipe = pipe;
54898
54899 - pipe->readers = pipe->writers = 1;
54900 + atomic_set(&pipe->readers, 1);
54901 + atomic_set(&pipe->writers, 1);
54902 inode->i_fop = &rdwr_pipefifo_fops;
54903
54904 /*
54905 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54906 index 15af622..0e9f4467 100644
54907 --- a/fs/proc/Kconfig
54908 +++ b/fs/proc/Kconfig
54909 @@ -30,12 +30,12 @@ config PROC_FS
54910
54911 config PROC_KCORE
54912 bool "/proc/kcore support" if !ARM
54913 - depends on PROC_FS && MMU
54914 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54915
54916 config PROC_VMCORE
54917 bool "/proc/vmcore support"
54918 - depends on PROC_FS && CRASH_DUMP
54919 - default y
54920 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54921 + default n
54922 help
54923 Exports the dump image of crashed kernel in ELF format.
54924
54925 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54926 limited in memory.
54927
54928 config PROC_PAGE_MONITOR
54929 - default y
54930 - depends on PROC_FS && MMU
54931 + default n
54932 + depends on PROC_FS && MMU && !GRKERNSEC
54933 bool "Enable /proc page monitoring" if EXPERT
54934 help
54935 Various /proc files exist to monitor process memory utilization:
54936 diff --git a/fs/proc/array.c b/fs/proc/array.c
54937 index 6a91e6f..e54dbc14 100644
54938 --- a/fs/proc/array.c
54939 +++ b/fs/proc/array.c
54940 @@ -60,6 +60,7 @@
54941 #include <linux/tty.h>
54942 #include <linux/string.h>
54943 #include <linux/mman.h>
54944 +#include <linux/grsecurity.h>
54945 #include <linux/proc_fs.h>
54946 #include <linux/ioport.h>
54947 #include <linux/uaccess.h>
54948 @@ -362,6 +363,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54949 seq_putc(m, '\n');
54950 }
54951
54952 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54953 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54954 +{
54955 + if (p->mm)
54956 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54957 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54958 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54959 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54960 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54961 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54962 + else
54963 + seq_printf(m, "PaX:\t-----\n");
54964 +}
54965 +#endif
54966 +
54967 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54968 struct pid *pid, struct task_struct *task)
54969 {
54970 @@ -380,9 +396,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54971 task_cpus_allowed(m, task);
54972 cpuset_task_status_allowed(m, task);
54973 task_context_switch_counts(m, task);
54974 +
54975 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54976 + task_pax(m, task);
54977 +#endif
54978 +
54979 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54980 + task_grsec_rbac(m, task);
54981 +#endif
54982 +
54983 return 0;
54984 }
54985
54986 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54987 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54988 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54989 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54990 +#endif
54991 +
54992 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54993 struct pid *pid, struct task_struct *task, int whole)
54994 {
54995 @@ -404,6 +435,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54996 char tcomm[sizeof(task->comm)];
54997 unsigned long flags;
54998
54999 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55000 + if (current->exec_id != m->exec_id) {
55001 + gr_log_badprocpid("stat");
55002 + return 0;
55003 + }
55004 +#endif
55005 +
55006 state = *get_task_state(task);
55007 vsize = eip = esp = 0;
55008 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55009 @@ -475,6 +513,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55010 gtime = task->gtime;
55011 }
55012
55013 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55014 + if (PAX_RAND_FLAGS(mm)) {
55015 + eip = 0;
55016 + esp = 0;
55017 + wchan = 0;
55018 + }
55019 +#endif
55020 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55021 + wchan = 0;
55022 + eip =0;
55023 + esp =0;
55024 +#endif
55025 +
55026 /* scale priority and nice values from timeslices to -20..20 */
55027 /* to make it look like a "normal" Unix priority/nice value */
55028 priority = task_prio(task);
55029 @@ -511,9 +562,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55030 seq_put_decimal_ull(m, ' ', vsize);
55031 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55032 seq_put_decimal_ull(m, ' ', rsslim);
55033 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55034 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55035 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55036 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55037 +#else
55038 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55039 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55040 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55041 +#endif
55042 seq_put_decimal_ull(m, ' ', esp);
55043 seq_put_decimal_ull(m, ' ', eip);
55044 /* The signal information here is obsolete.
55045 @@ -535,7 +592,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55046 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55047 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55048
55049 - if (mm && permitted) {
55050 + if (mm && permitted
55051 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55052 + && !PAX_RAND_FLAGS(mm)
55053 +#endif
55054 + ) {
55055 seq_put_decimal_ull(m, ' ', mm->start_data);
55056 seq_put_decimal_ull(m, ' ', mm->end_data);
55057 seq_put_decimal_ull(m, ' ', mm->start_brk);
55058 @@ -573,8 +634,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55059 struct pid *pid, struct task_struct *task)
55060 {
55061 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55062 - struct mm_struct *mm = get_task_mm(task);
55063 + struct mm_struct *mm;
55064
55065 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55066 + if (current->exec_id != m->exec_id) {
55067 + gr_log_badprocpid("statm");
55068 + return 0;
55069 + }
55070 +#endif
55071 + mm = get_task_mm(task);
55072 if (mm) {
55073 size = task_statm(mm, &shared, &text, &data, &resident);
55074 mmput(mm);
55075 @@ -597,6 +665,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55076 return 0;
55077 }
55078
55079 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55080 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55081 +{
55082 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55083 +}
55084 +#endif
55085 +
55086 #ifdef CONFIG_CHECKPOINT_RESTORE
55087 static struct pid *
55088 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55089 diff --git a/fs/proc/base.c b/fs/proc/base.c
55090 index 9b43ff77..0fa9564 100644
55091 --- a/fs/proc/base.c
55092 +++ b/fs/proc/base.c
55093 @@ -111,6 +111,14 @@ struct pid_entry {
55094 union proc_op op;
55095 };
55096
55097 +struct getdents_callback {
55098 + struct linux_dirent __user * current_dir;
55099 + struct linux_dirent __user * previous;
55100 + struct file * file;
55101 + int count;
55102 + int error;
55103 +};
55104 +
55105 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55106 .name = (NAME), \
55107 .len = sizeof(NAME) - 1, \
55108 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55109 if (!mm->arg_end)
55110 goto out_mm; /* Shh! No looking before we're done */
55111
55112 + if (gr_acl_handle_procpidmem(task))
55113 + goto out_mm;
55114 +
55115 len = mm->arg_end - mm->arg_start;
55116
55117 if (len > PAGE_SIZE)
55118 @@ -235,12 +246,28 @@ out:
55119 return res;
55120 }
55121
55122 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55123 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55124 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55125 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55126 +#endif
55127 +
55128 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55129 {
55130 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55131 int res = PTR_ERR(mm);
55132 if (mm && !IS_ERR(mm)) {
55133 unsigned int nwords = 0;
55134 +
55135 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55136 + /* allow if we're currently ptracing this task */
55137 + if (PAX_RAND_FLAGS(mm) &&
55138 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55139 + mmput(mm);
55140 + return 0;
55141 + }
55142 +#endif
55143 +
55144 do {
55145 nwords += 2;
55146 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55147 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55148 }
55149
55150
55151 -#ifdef CONFIG_KALLSYMS
55152 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55153 /*
55154 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55155 * Returns the resolved symbol. If that fails, simply return the address.
55156 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
55157 mutex_unlock(&task->signal->cred_guard_mutex);
55158 }
55159
55160 -#ifdef CONFIG_STACKTRACE
55161 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55162
55163 #define MAX_STACK_TRACE_DEPTH 64
55164
55165 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55166 return count;
55167 }
55168
55169 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55170 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55171 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55172 {
55173 long nr;
55174 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55175 /************************************************************************/
55176
55177 /* permission checks */
55178 -static int proc_fd_access_allowed(struct inode *inode)
55179 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55180 {
55181 struct task_struct *task;
55182 int allowed = 0;
55183 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55184 */
55185 task = get_proc_task(inode);
55186 if (task) {
55187 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55188 + if (log)
55189 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55190 + else
55191 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55192 put_task_struct(task);
55193 }
55194 return allowed;
55195 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55196 struct task_struct *task,
55197 int hide_pid_min)
55198 {
55199 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55200 + return false;
55201 +
55202 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55203 + rcu_read_lock();
55204 + {
55205 + const struct cred *tmpcred = current_cred();
55206 + const struct cred *cred = __task_cred(task);
55207 +
55208 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55209 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55210 + || in_group_p(grsec_proc_gid)
55211 +#endif
55212 + ) {
55213 + rcu_read_unlock();
55214 + return true;
55215 + }
55216 + }
55217 + rcu_read_unlock();
55218 +
55219 + if (!pid->hide_pid)
55220 + return false;
55221 +#endif
55222 +
55223 if (pid->hide_pid < hide_pid_min)
55224 return true;
55225 if (in_group_p(pid->pid_gid))
55226 return true;
55227 +
55228 return ptrace_may_access(task, PTRACE_MODE_READ);
55229 }
55230
55231 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55232 put_task_struct(task);
55233
55234 if (!has_perms) {
55235 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55236 + {
55237 +#else
55238 if (pid->hide_pid == 2) {
55239 +#endif
55240 /*
55241 * Let's make getdents(), stat(), and open()
55242 * consistent with each other. If a process
55243 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55244 if (!task)
55245 return -ESRCH;
55246
55247 + if (gr_acl_handle_procpidmem(task)) {
55248 + put_task_struct(task);
55249 + return -EPERM;
55250 + }
55251 +
55252 mm = mm_access(task, mode);
55253 put_task_struct(task);
55254
55255 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55256
55257 file->private_data = mm;
55258
55259 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55260 + file->f_version = current->exec_id;
55261 +#endif
55262 +
55263 return 0;
55264 }
55265
55266 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55267 ssize_t copied;
55268 char *page;
55269
55270 +#ifdef CONFIG_GRKERNSEC
55271 + if (write)
55272 + return -EPERM;
55273 +#endif
55274 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55275 + if (file->f_version != current->exec_id) {
55276 + gr_log_badprocpid("mem");
55277 + return 0;
55278 + }
55279 +#endif
55280 +
55281 if (!mm)
55282 return 0;
55283
55284 @@ -722,7 +801,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55285 goto free;
55286
55287 while (count > 0) {
55288 - int this_len = min_t(int, count, PAGE_SIZE);
55289 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55290
55291 if (write && copy_from_user(page, buf, this_len)) {
55292 copied = -EFAULT;
55293 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55294 if (!mm)
55295 return 0;
55296
55297 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55298 + if (file->f_version != current->exec_id) {
55299 + gr_log_badprocpid("environ");
55300 + return 0;
55301 + }
55302 +#endif
55303 +
55304 page = (char *)__get_free_page(GFP_TEMPORARY);
55305 if (!page)
55306 return -ENOMEM;
55307 @@ -823,7 +909,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55308 goto free;
55309 while (count > 0) {
55310 size_t this_len, max_len;
55311 - int retval;
55312 + ssize_t retval;
55313
55314 if (src >= (mm->env_end - mm->env_start))
55315 break;
55316 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55317 int error = -EACCES;
55318
55319 /* Are we allowed to snoop on the tasks file descriptors? */
55320 - if (!proc_fd_access_allowed(inode))
55321 + if (!proc_fd_access_allowed(inode, 0))
55322 goto out;
55323
55324 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55325 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55326 struct path path;
55327
55328 /* Are we allowed to snoop on the tasks file descriptors? */
55329 - if (!proc_fd_access_allowed(inode))
55330 - goto out;
55331 + /* logging this is needed for learning on chromium to work properly,
55332 + but we don't want to flood the logs from 'ps' which does a readlink
55333 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55334 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55335 + */
55336 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55337 + if (!proc_fd_access_allowed(inode,0))
55338 + goto out;
55339 + } else {
55340 + if (!proc_fd_access_allowed(inode,1))
55341 + goto out;
55342 + }
55343
55344 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55345 if (error)
55346 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55347 rcu_read_lock();
55348 cred = __task_cred(task);
55349 inode->i_uid = cred->euid;
55350 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55351 + inode->i_gid = grsec_proc_gid;
55352 +#else
55353 inode->i_gid = cred->egid;
55354 +#endif
55355 rcu_read_unlock();
55356 }
55357 security_task_to_inode(task, inode);
55358 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55359 return -ENOENT;
55360 }
55361 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55362 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55363 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55364 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55365 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55366 +#endif
55367 task_dumpable(task)) {
55368 cred = __task_cred(task);
55369 stat->uid = cred->euid;
55370 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55371 + stat->gid = grsec_proc_gid;
55372 +#else
55373 stat->gid = cred->egid;
55374 +#endif
55375 }
55376 }
55377 rcu_read_unlock();
55378 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55379
55380 if (task) {
55381 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55382 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55383 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55384 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55385 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55386 +#endif
55387 task_dumpable(task)) {
55388 rcu_read_lock();
55389 cred = __task_cred(task);
55390 inode->i_uid = cred->euid;
55391 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55392 + inode->i_gid = grsec_proc_gid;
55393 +#else
55394 inode->i_gid = cred->egid;
55395 +#endif
55396 rcu_read_unlock();
55397 } else {
55398 inode->i_uid = GLOBAL_ROOT_UID;
55399 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55400 if (!task)
55401 goto out_no_task;
55402
55403 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55404 + goto out;
55405 +
55406 /*
55407 * Yes, it does not scale. And it should not. Don't add
55408 * new entries into /proc/<tgid>/ without very good reasons.
55409 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
55410 if (!task)
55411 goto out_no_task;
55412
55413 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55414 + goto out;
55415 +
55416 ret = 0;
55417 i = filp->f_pos;
55418 switch (i) {
55419 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55420 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55421 #endif
55422 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55423 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55424 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55425 INF("syscall", S_IRUGO, proc_pid_syscall),
55426 #endif
55427 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55428 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55429 #ifdef CONFIG_SECURITY
55430 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55431 #endif
55432 -#ifdef CONFIG_KALLSYMS
55433 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55434 INF("wchan", S_IRUGO, proc_pid_wchan),
55435 #endif
55436 -#ifdef CONFIG_STACKTRACE
55437 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55438 ONE("stack", S_IRUGO, proc_pid_stack),
55439 #endif
55440 #ifdef CONFIG_SCHEDSTATS
55441 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55442 #ifdef CONFIG_HARDWALL
55443 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55444 #endif
55445 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55446 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55447 +#endif
55448 #ifdef CONFIG_USER_NS
55449 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55450 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55451 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55452 if (!inode)
55453 goto out;
55454
55455 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55456 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55457 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55458 + inode->i_gid = grsec_proc_gid;
55459 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55460 +#else
55461 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55462 +#endif
55463 inode->i_op = &proc_tgid_base_inode_operations;
55464 inode->i_fop = &proc_tgid_base_operations;
55465 inode->i_flags|=S_IMMUTABLE;
55466 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55467 if (!task)
55468 goto out;
55469
55470 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55471 + goto out_put_task;
55472 +
55473 result = proc_pid_instantiate(dir, dentry, task, NULL);
55474 +out_put_task:
55475 put_task_struct(task);
55476 out:
55477 return result;
55478 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55479 static int fake_filldir(void *buf, const char *name, int namelen,
55480 loff_t offset, u64 ino, unsigned d_type)
55481 {
55482 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55483 + __buf->error = -EINVAL;
55484 return 0;
55485 }
55486
55487 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
55488 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55489 #endif
55490 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55491 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55492 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55493 INF("syscall", S_IRUGO, proc_pid_syscall),
55494 #endif
55495 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55496 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
55497 #ifdef CONFIG_SECURITY
55498 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55499 #endif
55500 -#ifdef CONFIG_KALLSYMS
55501 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55502 INF("wchan", S_IRUGO, proc_pid_wchan),
55503 #endif
55504 -#ifdef CONFIG_STACKTRACE
55505 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55506 ONE("stack", S_IRUGO, proc_pid_stack),
55507 #endif
55508 #ifdef CONFIG_SCHEDSTATS
55509 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55510 index 82676e3..5f8518a 100644
55511 --- a/fs/proc/cmdline.c
55512 +++ b/fs/proc/cmdline.c
55513 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55514
55515 static int __init proc_cmdline_init(void)
55516 {
55517 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55518 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55519 +#else
55520 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55521 +#endif
55522 return 0;
55523 }
55524 module_init(proc_cmdline_init);
55525 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55526 index b143471..bb105e5 100644
55527 --- a/fs/proc/devices.c
55528 +++ b/fs/proc/devices.c
55529 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55530
55531 static int __init proc_devices_init(void)
55532 {
55533 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55534 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55535 +#else
55536 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55537 +#endif
55538 return 0;
55539 }
55540 module_init(proc_devices_init);
55541 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55542 index d7a4a28..0201742 100644
55543 --- a/fs/proc/fd.c
55544 +++ b/fs/proc/fd.c
55545 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55546 if (!task)
55547 return -ENOENT;
55548
55549 - files = get_files_struct(task);
55550 + if (!gr_acl_handle_procpidmem(task))
55551 + files = get_files_struct(task);
55552 put_task_struct(task);
55553
55554 if (files) {
55555 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55556 */
55557 int proc_fd_permission(struct inode *inode, int mask)
55558 {
55559 + struct task_struct *task;
55560 int rv = generic_permission(inode, mask);
55561 - if (rv == 0)
55562 - return 0;
55563 +
55564 if (task_pid(current) == proc_pid(inode))
55565 rv = 0;
55566 +
55567 + task = get_proc_task(inode);
55568 + if (task == NULL)
55569 + return rv;
55570 +
55571 + if (gr_acl_handle_procpidmem(task))
55572 + rv = -EACCES;
55573 +
55574 + put_task_struct(task);
55575 +
55576 return rv;
55577 }
55578
55579 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55580 index 0ac1e1b..0497e58 100644
55581 --- a/fs/proc/inode.c
55582 +++ b/fs/proc/inode.c
55583 @@ -21,11 +21,17 @@
55584 #include <linux/seq_file.h>
55585 #include <linux/slab.h>
55586 #include <linux/mount.h>
55587 +#include <linux/grsecurity.h>
55588
55589 #include <asm/uaccess.h>
55590
55591 #include "internal.h"
55592
55593 +#ifdef CONFIG_PROC_SYSCTL
55594 +extern const struct inode_operations proc_sys_inode_operations;
55595 +extern const struct inode_operations proc_sys_dir_operations;
55596 +#endif
55597 +
55598 static void proc_evict_inode(struct inode *inode)
55599 {
55600 struct proc_dir_entry *de;
55601 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
55602 ns = PROC_I(inode)->ns;
55603 if (ns_ops && ns)
55604 ns_ops->put(ns);
55605 +
55606 +#ifdef CONFIG_PROC_SYSCTL
55607 + if (inode->i_op == &proc_sys_inode_operations ||
55608 + inode->i_op == &proc_sys_dir_operations)
55609 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55610 +#endif
55611 +
55612 }
55613
55614 static struct kmem_cache * proc_inode_cachep;
55615 @@ -455,7 +468,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55616 if (de->mode) {
55617 inode->i_mode = de->mode;
55618 inode->i_uid = de->uid;
55619 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55620 + inode->i_gid = grsec_proc_gid;
55621 +#else
55622 inode->i_gid = de->gid;
55623 +#endif
55624 }
55625 if (de->size)
55626 inode->i_size = de->size;
55627 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55628 index 252544c..04395b9 100644
55629 --- a/fs/proc/internal.h
55630 +++ b/fs/proc/internal.h
55631 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55632 struct pid *pid, struct task_struct *task);
55633 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55634 struct pid *pid, struct task_struct *task);
55635 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55636 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55637 +#endif
55638 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55639
55640 extern const struct file_operations proc_tid_children_operations;
55641 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55642 index e96d4f1..8b116ed 100644
55643 --- a/fs/proc/kcore.c
55644 +++ b/fs/proc/kcore.c
55645 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55646 * the addresses in the elf_phdr on our list.
55647 */
55648 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55649 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55650 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55651 + if (tsz > buflen)
55652 tsz = buflen;
55653 -
55654 +
55655 while (buflen) {
55656 struct kcore_list *m;
55657
55658 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55659 kfree(elf_buf);
55660 } else {
55661 if (kern_addr_valid(start)) {
55662 - unsigned long n;
55663 + char *elf_buf;
55664 + mm_segment_t oldfs;
55665
55666 - n = copy_to_user(buffer, (char *)start, tsz);
55667 - /*
55668 - * We cannot distinguish between fault on source
55669 - * and fault on destination. When this happens
55670 - * we clear too and hope it will trigger the
55671 - * EFAULT again.
55672 - */
55673 - if (n) {
55674 - if (clear_user(buffer + tsz - n,
55675 - n))
55676 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55677 + if (!elf_buf)
55678 + return -ENOMEM;
55679 + oldfs = get_fs();
55680 + set_fs(KERNEL_DS);
55681 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55682 + set_fs(oldfs);
55683 + if (copy_to_user(buffer, elf_buf, tsz)) {
55684 + kfree(elf_buf);
55685 return -EFAULT;
55686 + }
55687 }
55688 + set_fs(oldfs);
55689 + kfree(elf_buf);
55690 } else {
55691 if (clear_user(buffer, tsz))
55692 return -EFAULT;
55693 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55694
55695 static int open_kcore(struct inode *inode, struct file *filp)
55696 {
55697 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55698 + return -EPERM;
55699 +#endif
55700 if (!capable(CAP_SYS_RAWIO))
55701 return -EPERM;
55702 if (kcore_need_update)
55703 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55704 index 80e4645..53e5fcf 100644
55705 --- a/fs/proc/meminfo.c
55706 +++ b/fs/proc/meminfo.c
55707 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55708 vmi.used >> 10,
55709 vmi.largest_chunk >> 10
55710 #ifdef CONFIG_MEMORY_FAILURE
55711 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
55712 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
55713 #endif
55714 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55715 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55716 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55717 index b1822dd..df622cb 100644
55718 --- a/fs/proc/nommu.c
55719 +++ b/fs/proc/nommu.c
55720 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55721 if (len < 1)
55722 len = 1;
55723 seq_printf(m, "%*c", len, ' ');
55724 - seq_path(m, &file->f_path, "");
55725 + seq_path(m, &file->f_path, "\n\\");
55726 }
55727
55728 seq_putc(m, '\n');
55729 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55730 index fe72cd0..21b52ff 100644
55731 --- a/fs/proc/proc_net.c
55732 +++ b/fs/proc/proc_net.c
55733 @@ -23,6 +23,7 @@
55734 #include <linux/nsproxy.h>
55735 #include <net/net_namespace.h>
55736 #include <linux/seq_file.h>
55737 +#include <linux/grsecurity.h>
55738
55739 #include "internal.h"
55740
55741 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55742 struct task_struct *task;
55743 struct nsproxy *ns;
55744 struct net *net = NULL;
55745 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55746 + const struct cred *cred = current_cred();
55747 +#endif
55748 +
55749 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55750 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55751 + return net;
55752 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55753 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55754 + return net;
55755 +#endif
55756
55757 rcu_read_lock();
55758 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55759 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55760 index 1827d88..43b0279 100644
55761 --- a/fs/proc/proc_sysctl.c
55762 +++ b/fs/proc/proc_sysctl.c
55763 @@ -12,11 +12,15 @@
55764 #include <linux/module.h>
55765 #include "internal.h"
55766
55767 +extern int gr_handle_chroot_sysctl(const int op);
55768 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55769 + const int op);
55770 +
55771 static const struct dentry_operations proc_sys_dentry_operations;
55772 static const struct file_operations proc_sys_file_operations;
55773 -static const struct inode_operations proc_sys_inode_operations;
55774 +const struct inode_operations proc_sys_inode_operations;
55775 static const struct file_operations proc_sys_dir_file_operations;
55776 -static const struct inode_operations proc_sys_dir_operations;
55777 +const struct inode_operations proc_sys_dir_operations;
55778
55779 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55780 {
55781 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55782
55783 err = NULL;
55784 d_set_d_op(dentry, &proc_sys_dentry_operations);
55785 +
55786 + gr_handle_proc_create(dentry, inode);
55787 +
55788 d_add(dentry, inode);
55789
55790 out:
55791 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55792 struct inode *inode = filp->f_path.dentry->d_inode;
55793 struct ctl_table_header *head = grab_header(inode);
55794 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55795 + int op = write ? MAY_WRITE : MAY_READ;
55796 ssize_t error;
55797 size_t res;
55798
55799 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55800 * and won't be until we finish.
55801 */
55802 error = -EPERM;
55803 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55804 + if (sysctl_perm(head, table, op))
55805 goto out;
55806
55807 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55808 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55809 if (!table->proc_handler)
55810 goto out;
55811
55812 +#ifdef CONFIG_GRKERNSEC
55813 + error = -EPERM;
55814 + if (gr_handle_chroot_sysctl(op))
55815 + goto out;
55816 + dget(filp->f_path.dentry);
55817 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55818 + dput(filp->f_path.dentry);
55819 + goto out;
55820 + }
55821 + dput(filp->f_path.dentry);
55822 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55823 + goto out;
55824 + if (write && !capable(CAP_SYS_ADMIN))
55825 + goto out;
55826 +#endif
55827 +
55828 /* careful: calling conventions are nasty here */
55829 res = count;
55830 error = table->proc_handler(table, write, buf, &res, ppos);
55831 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55832 return -ENOMEM;
55833 } else {
55834 d_set_d_op(child, &proc_sys_dentry_operations);
55835 +
55836 + gr_handle_proc_create(child, inode);
55837 +
55838 d_add(child, inode);
55839 }
55840 } else {
55841 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55842 if ((*pos)++ < file->f_pos)
55843 return 0;
55844
55845 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55846 + return 0;
55847 +
55848 if (unlikely(S_ISLNK(table->mode)))
55849 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55850 else
55851 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55852 if (IS_ERR(head))
55853 return PTR_ERR(head);
55854
55855 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55856 + return -ENOENT;
55857 +
55858 generic_fillattr(inode, stat);
55859 if (table)
55860 stat->mode = (stat->mode & S_IFMT) | table->mode;
55861 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55862 .llseek = generic_file_llseek,
55863 };
55864
55865 -static const struct inode_operations proc_sys_inode_operations = {
55866 +const struct inode_operations proc_sys_inode_operations = {
55867 .permission = proc_sys_permission,
55868 .setattr = proc_sys_setattr,
55869 .getattr = proc_sys_getattr,
55870 };
55871
55872 -static const struct inode_operations proc_sys_dir_operations = {
55873 +const struct inode_operations proc_sys_dir_operations = {
55874 .lookup = proc_sys_lookup,
55875 .permission = proc_sys_permission,
55876 .setattr = proc_sys_setattr,
55877 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55878 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55879 const char *name, int namelen)
55880 {
55881 - struct ctl_table *table;
55882 + ctl_table_no_const *table;
55883 struct ctl_dir *new;
55884 struct ctl_node *node;
55885 char *new_name;
55886 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55887 return NULL;
55888
55889 node = (struct ctl_node *)(new + 1);
55890 - table = (struct ctl_table *)(node + 1);
55891 + table = (ctl_table_no_const *)(node + 1);
55892 new_name = (char *)(table + 2);
55893 memcpy(new_name, name, namelen);
55894 new_name[namelen] = '\0';
55895 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55896 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55897 struct ctl_table_root *link_root)
55898 {
55899 - struct ctl_table *link_table, *entry, *link;
55900 + ctl_table_no_const *link_table, *link;
55901 + struct ctl_table *entry;
55902 struct ctl_table_header *links;
55903 struct ctl_node *node;
55904 char *link_name;
55905 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55906 return NULL;
55907
55908 node = (struct ctl_node *)(links + 1);
55909 - link_table = (struct ctl_table *)(node + nr_entries);
55910 + link_table = (ctl_table_no_const *)(node + nr_entries);
55911 link_name = (char *)&link_table[nr_entries + 1];
55912
55913 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55914 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55915 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55916 struct ctl_table *table)
55917 {
55918 - struct ctl_table *ctl_table_arg = NULL;
55919 - struct ctl_table *entry, *files;
55920 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55921 + struct ctl_table *entry;
55922 int nr_files = 0;
55923 int nr_dirs = 0;
55924 int err = -ENOMEM;
55925 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55926 nr_files++;
55927 }
55928
55929 - files = table;
55930 /* If there are mixed files and directories we need a new table */
55931 if (nr_dirs && nr_files) {
55932 - struct ctl_table *new;
55933 + ctl_table_no_const *new;
55934 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55935 GFP_KERNEL);
55936 if (!files)
55937 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55938 /* Register everything except a directory full of subdirectories */
55939 if (nr_files || !nr_dirs) {
55940 struct ctl_table_header *header;
55941 - header = __register_sysctl_table(set, path, files);
55942 + header = __register_sysctl_table(set, path, files ? files : table);
55943 if (!header) {
55944 kfree(ctl_table_arg);
55945 goto out;
55946 diff --git a/fs/proc/root.c b/fs/proc/root.c
55947 index 9c7fab1..ed1c8e0 100644
55948 --- a/fs/proc/root.c
55949 +++ b/fs/proc/root.c
55950 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
55951 #ifdef CONFIG_PROC_DEVICETREE
55952 proc_device_tree_init();
55953 #endif
55954 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55955 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55956 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55957 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55958 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55959 +#endif
55960 +#else
55961 proc_mkdir("bus", NULL);
55962 +#endif
55963 proc_sys_init();
55964 }
55965
55966 diff --git a/fs/proc/self.c b/fs/proc/self.c
55967 index aa5cc3b..c91a5d0 100644
55968 --- a/fs/proc/self.c
55969 +++ b/fs/proc/self.c
55970 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55971 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55972 void *cookie)
55973 {
55974 - char *s = nd_get_link(nd);
55975 + const char *s = nd_get_link(nd);
55976 if (!IS_ERR(s))
55977 kfree(s);
55978 }
55979 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55980 index ca5ce7f..02c1cf0 100644
55981 --- a/fs/proc/task_mmu.c
55982 +++ b/fs/proc/task_mmu.c
55983 @@ -11,12 +11,19 @@
55984 #include <linux/rmap.h>
55985 #include <linux/swap.h>
55986 #include <linux/swapops.h>
55987 +#include <linux/grsecurity.h>
55988
55989 #include <asm/elf.h>
55990 #include <asm/uaccess.h>
55991 #include <asm/tlbflush.h>
55992 #include "internal.h"
55993
55994 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55995 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55996 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55997 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55998 +#endif
55999 +
56000 void task_mem(struct seq_file *m, struct mm_struct *mm)
56001 {
56002 unsigned long data, text, lib, swap;
56003 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56004 "VmExe:\t%8lu kB\n"
56005 "VmLib:\t%8lu kB\n"
56006 "VmPTE:\t%8lu kB\n"
56007 - "VmSwap:\t%8lu kB\n",
56008 - hiwater_vm << (PAGE_SHIFT-10),
56009 + "VmSwap:\t%8lu kB\n"
56010 +
56011 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56012 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56013 +#endif
56014 +
56015 + ,hiwater_vm << (PAGE_SHIFT-10),
56016 total_vm << (PAGE_SHIFT-10),
56017 mm->locked_vm << (PAGE_SHIFT-10),
56018 mm->pinned_vm << (PAGE_SHIFT-10),
56019 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56020 data << (PAGE_SHIFT-10),
56021 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56022 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56023 - swap << (PAGE_SHIFT-10));
56024 + swap << (PAGE_SHIFT-10)
56025 +
56026 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56027 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56028 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56029 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56030 +#else
56031 + , mm->context.user_cs_base
56032 + , mm->context.user_cs_limit
56033 +#endif
56034 +#endif
56035 +
56036 + );
56037 }
56038
56039 unsigned long task_vsize(struct mm_struct *mm)
56040 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56041 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56042 }
56043
56044 - /* We don't show the stack guard page in /proc/maps */
56045 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56046 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56047 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56048 +#else
56049 start = vma->vm_start;
56050 - if (stack_guard_page_start(vma, start))
56051 - start += PAGE_SIZE;
56052 end = vma->vm_end;
56053 - if (stack_guard_page_end(vma, end))
56054 - end -= PAGE_SIZE;
56055 +#endif
56056
56057 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56058 start,
56059 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56060 flags & VM_WRITE ? 'w' : '-',
56061 flags & VM_EXEC ? 'x' : '-',
56062 flags & VM_MAYSHARE ? 's' : 'p',
56063 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56064 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56065 +#else
56066 pgoff,
56067 +#endif
56068 MAJOR(dev), MINOR(dev), ino, &len);
56069
56070 /*
56071 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56072 */
56073 if (file) {
56074 pad_len_spaces(m, len);
56075 - seq_path(m, &file->f_path, "\n");
56076 + seq_path(m, &file->f_path, "\n\\");
56077 goto done;
56078 }
56079
56080 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56081 * Thread stack in /proc/PID/task/TID/maps or
56082 * the main process stack.
56083 */
56084 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56085 - vma->vm_end >= mm->start_stack)) {
56086 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56087 + (vma->vm_start <= mm->start_stack &&
56088 + vma->vm_end >= mm->start_stack)) {
56089 name = "[stack]";
56090 } else {
56091 /* Thread stack in /proc/PID/maps */
56092 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56093 struct proc_maps_private *priv = m->private;
56094 struct task_struct *task = priv->task;
56095
56096 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56097 + if (current->exec_id != m->exec_id) {
56098 + gr_log_badprocpid("maps");
56099 + return 0;
56100 + }
56101 +#endif
56102 +
56103 show_map_vma(m, vma, is_pid);
56104
56105 if (m->count < m->size) /* vma is copied successfully */
56106 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56107 .private = &mss,
56108 };
56109
56110 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56111 + if (current->exec_id != m->exec_id) {
56112 + gr_log_badprocpid("smaps");
56113 + return 0;
56114 + }
56115 +#endif
56116 memset(&mss, 0, sizeof mss);
56117 - mss.vma = vma;
56118 - /* mmap_sem is held in m_start */
56119 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56120 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56121 -
56122 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56123 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56124 +#endif
56125 + mss.vma = vma;
56126 + /* mmap_sem is held in m_start */
56127 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56128 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56129 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56130 + }
56131 +#endif
56132 show_map_vma(m, vma, is_pid);
56133
56134 seq_printf(m,
56135 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56136 "KernelPageSize: %8lu kB\n"
56137 "MMUPageSize: %8lu kB\n"
56138 "Locked: %8lu kB\n",
56139 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56140 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56141 +#else
56142 (vma->vm_end - vma->vm_start) >> 10,
56143 +#endif
56144 mss.resident >> 10,
56145 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56146 mss.shared_clean >> 10,
56147 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56148 int n;
56149 char buffer[50];
56150
56151 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56152 + if (current->exec_id != m->exec_id) {
56153 + gr_log_badprocpid("numa_maps");
56154 + return 0;
56155 + }
56156 +#endif
56157 +
56158 if (!mm)
56159 return 0;
56160
56161 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56162 mpol_to_str(buffer, sizeof(buffer), pol);
56163 mpol_cond_put(pol);
56164
56165 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56166 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56167 +#else
56168 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56169 +#endif
56170
56171 if (file) {
56172 seq_printf(m, " file=");
56173 - seq_path(m, &file->f_path, "\n\t= ");
56174 + seq_path(m, &file->f_path, "\n\t\\= ");
56175 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56176 seq_printf(m, " heap");
56177 } else {
56178 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56179 index 1ccfa53..0848f95 100644
56180 --- a/fs/proc/task_nommu.c
56181 +++ b/fs/proc/task_nommu.c
56182 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56183 else
56184 bytes += kobjsize(mm);
56185
56186 - if (current->fs && current->fs->users > 1)
56187 + if (current->fs && atomic_read(&current->fs->users) > 1)
56188 sbytes += kobjsize(current->fs);
56189 else
56190 bytes += kobjsize(current->fs);
56191 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56192
56193 if (file) {
56194 pad_len_spaces(m, len);
56195 - seq_path(m, &file->f_path, "");
56196 + seq_path(m, &file->f_path, "\n\\");
56197 } else if (mm) {
56198 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56199
56200 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56201 index b00fcc9..e0c6381 100644
56202 --- a/fs/qnx6/qnx6.h
56203 +++ b/fs/qnx6/qnx6.h
56204 @@ -74,7 +74,7 @@ enum {
56205 BYTESEX_BE,
56206 };
56207
56208 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56209 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56210 {
56211 if (sbi->s_bytesex == BYTESEX_LE)
56212 return le64_to_cpu((__force __le64)n);
56213 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56214 return (__force __fs64)cpu_to_be64(n);
56215 }
56216
56217 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56218 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56219 {
56220 if (sbi->s_bytesex == BYTESEX_LE)
56221 return le32_to_cpu((__force __le32)n);
56222 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56223 index 16e8abb..2dcf914 100644
56224 --- a/fs/quota/netlink.c
56225 +++ b/fs/quota/netlink.c
56226 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56227 void quota_send_warning(struct kqid qid, dev_t dev,
56228 const char warntype)
56229 {
56230 - static atomic_t seq;
56231 + static atomic_unchecked_t seq;
56232 struct sk_buff *skb;
56233 void *msg_head;
56234 int ret;
56235 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56236 "VFS: Not enough memory to send quota warning.\n");
56237 return;
56238 }
56239 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56240 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56241 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56242 if (!msg_head) {
56243 printk(KERN_ERR
56244 diff --git a/fs/readdir.c b/fs/readdir.c
56245 index 5e69ef5..e5d9099 100644
56246 --- a/fs/readdir.c
56247 +++ b/fs/readdir.c
56248 @@ -17,6 +17,7 @@
56249 #include <linux/security.h>
56250 #include <linux/syscalls.h>
56251 #include <linux/unistd.h>
56252 +#include <linux/namei.h>
56253
56254 #include <asm/uaccess.h>
56255
56256 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56257
56258 struct readdir_callback {
56259 struct old_linux_dirent __user * dirent;
56260 + struct file * file;
56261 int result;
56262 };
56263
56264 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56265 buf->result = -EOVERFLOW;
56266 return -EOVERFLOW;
56267 }
56268 +
56269 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56270 + return 0;
56271 +
56272 buf->result++;
56273 dirent = buf->dirent;
56274 if (!access_ok(VERIFY_WRITE, dirent,
56275 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56276
56277 buf.result = 0;
56278 buf.dirent = dirent;
56279 + buf.file = f.file;
56280
56281 error = vfs_readdir(f.file, fillonedir, &buf);
56282 if (buf.result)
56283 @@ -139,6 +146,7 @@ struct linux_dirent {
56284 struct getdents_callback {
56285 struct linux_dirent __user * current_dir;
56286 struct linux_dirent __user * previous;
56287 + struct file * file;
56288 int count;
56289 int error;
56290 };
56291 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56292 buf->error = -EOVERFLOW;
56293 return -EOVERFLOW;
56294 }
56295 +
56296 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56297 + return 0;
56298 +
56299 dirent = buf->previous;
56300 if (dirent) {
56301 if (__put_user(offset, &dirent->d_off))
56302 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56303 buf.previous = NULL;
56304 buf.count = count;
56305 buf.error = 0;
56306 + buf.file = f.file;
56307
56308 error = vfs_readdir(f.file, filldir, &buf);
56309 if (error >= 0)
56310 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56311 struct getdents_callback64 {
56312 struct linux_dirent64 __user * current_dir;
56313 struct linux_dirent64 __user * previous;
56314 + struct file *file;
56315 int count;
56316 int error;
56317 };
56318 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56319 buf->error = -EINVAL; /* only used if we fail.. */
56320 if (reclen > buf->count)
56321 return -EINVAL;
56322 +
56323 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56324 + return 0;
56325 +
56326 dirent = buf->previous;
56327 if (dirent) {
56328 if (__put_user(offset, &dirent->d_off))
56329 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56330
56331 buf.current_dir = dirent;
56332 buf.previous = NULL;
56333 + buf.file = f.file;
56334 buf.count = count;
56335 buf.error = 0;
56336
56337 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56338 error = buf.error;
56339 lastdirent = buf.previous;
56340 if (lastdirent) {
56341 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56342 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56343 if (__put_user(d_off, &lastdirent->d_off))
56344 error = -EFAULT;
56345 else
56346 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56347 index 2b7882b..1c5ef48 100644
56348 --- a/fs/reiserfs/do_balan.c
56349 +++ b/fs/reiserfs/do_balan.c
56350 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56351 return;
56352 }
56353
56354 - atomic_inc(&(fs_generation(tb->tb_sb)));
56355 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56356 do_balance_starts(tb);
56357
56358 /* balance leaf returns 0 except if combining L R and S into
56359 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56360 index e60e870..f40ac16 100644
56361 --- a/fs/reiserfs/procfs.c
56362 +++ b/fs/reiserfs/procfs.c
56363 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56364 "SMALL_TAILS " : "NO_TAILS ",
56365 replay_only(sb) ? "REPLAY_ONLY " : "",
56366 convert_reiserfs(sb) ? "CONV " : "",
56367 - atomic_read(&r->s_generation_counter),
56368 + atomic_read_unchecked(&r->s_generation_counter),
56369 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56370 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56371 SF(s_good_search_by_key_reada), SF(s_bmaps),
56372 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56373 index 157e474..65a6114 100644
56374 --- a/fs/reiserfs/reiserfs.h
56375 +++ b/fs/reiserfs/reiserfs.h
56376 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56377 /* Comment? -Hans */
56378 wait_queue_head_t s_wait;
56379 /* To be obsoleted soon by per buffer seals.. -Hans */
56380 - atomic_t s_generation_counter; // increased by one every time the
56381 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56382 // tree gets re-balanced
56383 unsigned long s_properties; /* File system properties. Currently holds
56384 on-disk FS format */
56385 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56386 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56387
56388 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56389 -#define get_generation(s) atomic_read (&fs_generation(s))
56390 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56391 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56392 #define __fs_changed(gen,s) (gen != get_generation (s))
56393 #define fs_changed(gen,s) \
56394 diff --git a/fs/select.c b/fs/select.c
56395 index 2ef72d9..f213b17 100644
56396 --- a/fs/select.c
56397 +++ b/fs/select.c
56398 @@ -20,6 +20,7 @@
56399 #include <linux/export.h>
56400 #include <linux/slab.h>
56401 #include <linux/poll.h>
56402 +#include <linux/security.h>
56403 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56404 #include <linux/file.h>
56405 #include <linux/fdtable.h>
56406 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56407 struct poll_list *walk = head;
56408 unsigned long todo = nfds;
56409
56410 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56411 if (nfds > rlimit(RLIMIT_NOFILE))
56412 return -EINVAL;
56413
56414 diff --git a/fs/seq_file.c b/fs/seq_file.c
56415 index f2bc3df..239d4f6 100644
56416 --- a/fs/seq_file.c
56417 +++ b/fs/seq_file.c
56418 @@ -10,6 +10,7 @@
56419 #include <linux/seq_file.h>
56420 #include <linux/slab.h>
56421 #include <linux/cred.h>
56422 +#include <linux/sched.h>
56423
56424 #include <asm/uaccess.h>
56425 #include <asm/page.h>
56426 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56427 #ifdef CONFIG_USER_NS
56428 p->user_ns = file->f_cred->user_ns;
56429 #endif
56430 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56431 + p->exec_id = current->exec_id;
56432 +#endif
56433
56434 /*
56435 * Wrappers around seq_open(e.g. swaps_open) need to be
56436 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56437 return 0;
56438 }
56439 if (!m->buf) {
56440 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56441 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56442 if (!m->buf)
56443 return -ENOMEM;
56444 }
56445 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56446 Eoverflow:
56447 m->op->stop(m, p);
56448 kfree(m->buf);
56449 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56450 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56451 return !m->buf ? -ENOMEM : -EAGAIN;
56452 }
56453
56454 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56455
56456 /* grab buffer if we didn't have one */
56457 if (!m->buf) {
56458 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56459 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56460 if (!m->buf)
56461 goto Enomem;
56462 }
56463 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56464 goto Fill;
56465 m->op->stop(m, p);
56466 kfree(m->buf);
56467 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56468 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56469 if (!m->buf)
56470 goto Enomem;
56471 m->count = 0;
56472 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56473 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56474 void *data)
56475 {
56476 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56477 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56478 int res = -ENOMEM;
56479
56480 if (op) {
56481 diff --git a/fs/splice.c b/fs/splice.c
56482 index 6909d89..5b2e8f9 100644
56483 --- a/fs/splice.c
56484 +++ b/fs/splice.c
56485 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56486 pipe_lock(pipe);
56487
56488 for (;;) {
56489 - if (!pipe->readers) {
56490 + if (!atomic_read(&pipe->readers)) {
56491 send_sig(SIGPIPE, current, 0);
56492 if (!ret)
56493 ret = -EPIPE;
56494 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56495 do_wakeup = 0;
56496 }
56497
56498 - pipe->waiting_writers++;
56499 + atomic_inc(&pipe->waiting_writers);
56500 pipe_wait(pipe);
56501 - pipe->waiting_writers--;
56502 + atomic_dec(&pipe->waiting_writers);
56503 }
56504
56505 pipe_unlock(pipe);
56506 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56507 old_fs = get_fs();
56508 set_fs(get_ds());
56509 /* The cast to a user pointer is valid due to the set_fs() */
56510 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56511 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56512 set_fs(old_fs);
56513
56514 return res;
56515 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56516 old_fs = get_fs();
56517 set_fs(get_ds());
56518 /* The cast to a user pointer is valid due to the set_fs() */
56519 - res = vfs_write(file, (const char __user *)buf, count, &pos);
56520 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56521 set_fs(old_fs);
56522
56523 return res;
56524 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56525 goto err;
56526
56527 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56528 - vec[i].iov_base = (void __user *) page_address(page);
56529 + vec[i].iov_base = (void __force_user *) page_address(page);
56530 vec[i].iov_len = this_len;
56531 spd.pages[i] = page;
56532 spd.nr_pages++;
56533 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56534 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56535 {
56536 while (!pipe->nrbufs) {
56537 - if (!pipe->writers)
56538 + if (!atomic_read(&pipe->writers))
56539 return 0;
56540
56541 - if (!pipe->waiting_writers && sd->num_spliced)
56542 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56543 return 0;
56544
56545 if (sd->flags & SPLICE_F_NONBLOCK)
56546 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56547 * out of the pipe right after the splice_to_pipe(). So set
56548 * PIPE_READERS appropriately.
56549 */
56550 - pipe->readers = 1;
56551 + atomic_set(&pipe->readers, 1);
56552
56553 current->splice_pipe = pipe;
56554 }
56555 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56556 ret = -ERESTARTSYS;
56557 break;
56558 }
56559 - if (!pipe->writers)
56560 + if (!atomic_read(&pipe->writers))
56561 break;
56562 - if (!pipe->waiting_writers) {
56563 + if (!atomic_read(&pipe->waiting_writers)) {
56564 if (flags & SPLICE_F_NONBLOCK) {
56565 ret = -EAGAIN;
56566 break;
56567 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56568 pipe_lock(pipe);
56569
56570 while (pipe->nrbufs >= pipe->buffers) {
56571 - if (!pipe->readers) {
56572 + if (!atomic_read(&pipe->readers)) {
56573 send_sig(SIGPIPE, current, 0);
56574 ret = -EPIPE;
56575 break;
56576 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56577 ret = -ERESTARTSYS;
56578 break;
56579 }
56580 - pipe->waiting_writers++;
56581 + atomic_inc(&pipe->waiting_writers);
56582 pipe_wait(pipe);
56583 - pipe->waiting_writers--;
56584 + atomic_dec(&pipe->waiting_writers);
56585 }
56586
56587 pipe_unlock(pipe);
56588 @@ -1823,14 +1823,14 @@ retry:
56589 pipe_double_lock(ipipe, opipe);
56590
56591 do {
56592 - if (!opipe->readers) {
56593 + if (!atomic_read(&opipe->readers)) {
56594 send_sig(SIGPIPE, current, 0);
56595 if (!ret)
56596 ret = -EPIPE;
56597 break;
56598 }
56599
56600 - if (!ipipe->nrbufs && !ipipe->writers)
56601 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56602 break;
56603
56604 /*
56605 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56606 pipe_double_lock(ipipe, opipe);
56607
56608 do {
56609 - if (!opipe->readers) {
56610 + if (!atomic_read(&opipe->readers)) {
56611 send_sig(SIGPIPE, current, 0);
56612 if (!ret)
56613 ret = -EPIPE;
56614 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56615 * return EAGAIN if we have the potential of some data in the
56616 * future, otherwise just return 0
56617 */
56618 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56619 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56620 ret = -EAGAIN;
56621
56622 pipe_unlock(ipipe);
56623 diff --git a/fs/stat.c b/fs/stat.c
56624 index 14f4545..9b7f55b 100644
56625 --- a/fs/stat.c
56626 +++ b/fs/stat.c
56627 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56628 stat->gid = inode->i_gid;
56629 stat->rdev = inode->i_rdev;
56630 stat->size = i_size_read(inode);
56631 - stat->atime = inode->i_atime;
56632 - stat->mtime = inode->i_mtime;
56633 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56634 + stat->atime = inode->i_ctime;
56635 + stat->mtime = inode->i_ctime;
56636 + } else {
56637 + stat->atime = inode->i_atime;
56638 + stat->mtime = inode->i_mtime;
56639 + }
56640 stat->ctime = inode->i_ctime;
56641 stat->blksize = (1 << inode->i_blkbits);
56642 stat->blocks = inode->i_blocks;
56643 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
56644 if (retval)
56645 return retval;
56646
56647 - if (inode->i_op->getattr)
56648 - return inode->i_op->getattr(mnt, dentry, stat);
56649 + if (inode->i_op->getattr) {
56650 + retval = inode->i_op->getattr(mnt, dentry, stat);
56651 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56652 + stat->atime = stat->ctime;
56653 + stat->mtime = stat->ctime;
56654 + }
56655 + return retval;
56656 + }
56657
56658 generic_fillattr(inode, stat);
56659 return 0;
56660 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56661 index 614b2b5..4d321e6 100644
56662 --- a/fs/sysfs/bin.c
56663 +++ b/fs/sysfs/bin.c
56664 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56665 return ret;
56666 }
56667
56668 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56669 - void *buf, int len, int write)
56670 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56671 + void *buf, size_t len, int write)
56672 {
56673 struct file *file = vma->vm_file;
56674 struct bin_buffer *bb = file->private_data;
56675 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56676 - int ret;
56677 + ssize_t ret;
56678
56679 if (!bb->vm_ops)
56680 return -EINVAL;
56681 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56682 index 1f8c823..ed57cfe 100644
56683 --- a/fs/sysfs/dir.c
56684 +++ b/fs/sysfs/dir.c
56685 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56686 *
56687 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56688 */
56689 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56690 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56691 {
56692 unsigned long hash = init_name_hash();
56693 unsigned int len = strlen(name);
56694 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56695 struct sysfs_dirent *sd;
56696 int rc;
56697
56698 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56699 + const char *parent_name = parent_sd->s_name;
56700 +
56701 + mode = S_IFDIR | S_IRWXU;
56702 +
56703 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56704 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56705 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56706 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56707 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56708 +#endif
56709 +
56710 /* allocate */
56711 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56712 if (!sd)
56713 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56714 index 602f56d..6853db8 100644
56715 --- a/fs/sysfs/file.c
56716 +++ b/fs/sysfs/file.c
56717 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56718
56719 struct sysfs_open_dirent {
56720 atomic_t refcnt;
56721 - atomic_t event;
56722 + atomic_unchecked_t event;
56723 wait_queue_head_t poll;
56724 struct list_head buffers; /* goes through sysfs_buffer.list */
56725 };
56726 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56727 if (!sysfs_get_active(attr_sd))
56728 return -ENODEV;
56729
56730 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56731 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56732 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56733
56734 sysfs_put_active(attr_sd);
56735 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56736 return -ENOMEM;
56737
56738 atomic_set(&new_od->refcnt, 0);
56739 - atomic_set(&new_od->event, 1);
56740 + atomic_set_unchecked(&new_od->event, 1);
56741 init_waitqueue_head(&new_od->poll);
56742 INIT_LIST_HEAD(&new_od->buffers);
56743 goto retry;
56744 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56745
56746 sysfs_put_active(attr_sd);
56747
56748 - if (buffer->event != atomic_read(&od->event))
56749 + if (buffer->event != atomic_read_unchecked(&od->event))
56750 goto trigger;
56751
56752 return DEFAULT_POLLMASK;
56753 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56754
56755 od = sd->s_attr.open;
56756 if (od) {
56757 - atomic_inc(&od->event);
56758 + atomic_inc_unchecked(&od->event);
56759 wake_up_interruptible(&od->poll);
56760 }
56761
56762 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56763 index 3c9eb56..9dea5be 100644
56764 --- a/fs/sysfs/symlink.c
56765 +++ b/fs/sysfs/symlink.c
56766 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56767
56768 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56769 {
56770 - char *page = nd_get_link(nd);
56771 + const char *page = nd_get_link(nd);
56772 if (!IS_ERR(page))
56773 free_page((unsigned long)page);
56774 }
56775 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56776 index 69d4889..a810bd4 100644
56777 --- a/fs/sysv/sysv.h
56778 +++ b/fs/sysv/sysv.h
56779 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56780 #endif
56781 }
56782
56783 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56784 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56785 {
56786 if (sbi->s_bytesex == BYTESEX_PDP)
56787 return PDP_swab((__force __u32)n);
56788 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56789 index e18b988..f1d4ad0f 100644
56790 --- a/fs/ubifs/io.c
56791 +++ b/fs/ubifs/io.c
56792 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56793 return err;
56794 }
56795
56796 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56797 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56798 {
56799 int err;
56800
56801 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56802 index c175b4d..8f36a16 100644
56803 --- a/fs/udf/misc.c
56804 +++ b/fs/udf/misc.c
56805 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56806
56807 u8 udf_tag_checksum(const struct tag *t)
56808 {
56809 - u8 *data = (u8 *)t;
56810 + const u8 *data = (const u8 *)t;
56811 u8 checksum = 0;
56812 int i;
56813 for (i = 0; i < sizeof(struct tag); ++i)
56814 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56815 index 8d974c4..b82f6ec 100644
56816 --- a/fs/ufs/swab.h
56817 +++ b/fs/ufs/swab.h
56818 @@ -22,7 +22,7 @@ enum {
56819 BYTESEX_BE
56820 };
56821
56822 -static inline u64
56823 +static inline u64 __intentional_overflow(-1)
56824 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56825 {
56826 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56827 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56828 return (__force __fs64)cpu_to_be64(n);
56829 }
56830
56831 -static inline u32
56832 +static inline u32 __intentional_overflow(-1)
56833 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56834 {
56835 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56836 diff --git a/fs/utimes.c b/fs/utimes.c
56837 index f4fb7ec..3fe03c0 100644
56838 --- a/fs/utimes.c
56839 +++ b/fs/utimes.c
56840 @@ -1,6 +1,7 @@
56841 #include <linux/compiler.h>
56842 #include <linux/file.h>
56843 #include <linux/fs.h>
56844 +#include <linux/security.h>
56845 #include <linux/linkage.h>
56846 #include <linux/mount.h>
56847 #include <linux/namei.h>
56848 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56849 goto mnt_drop_write_and_out;
56850 }
56851 }
56852 +
56853 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56854 + error = -EACCES;
56855 + goto mnt_drop_write_and_out;
56856 + }
56857 +
56858 mutex_lock(&inode->i_mutex);
56859 error = notify_change(path->dentry, &newattrs);
56860 mutex_unlock(&inode->i_mutex);
56861 diff --git a/fs/xattr.c b/fs/xattr.c
56862 index 3377dff..4feded6 100644
56863 --- a/fs/xattr.c
56864 +++ b/fs/xattr.c
56865 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56866 * Extended attribute SET operations
56867 */
56868 static long
56869 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56870 +setxattr(struct path *path, const char __user *name, const void __user *value,
56871 size_t size, int flags)
56872 {
56873 int error;
56874 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56875 posix_acl_fix_xattr_from_user(kvalue, size);
56876 }
56877
56878 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56879 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56880 + error = -EACCES;
56881 + goto out;
56882 + }
56883 +
56884 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56885 out:
56886 if (vvalue)
56887 vfree(vvalue);
56888 @@ -377,7 +382,7 @@ retry:
56889 return error;
56890 error = mnt_want_write(path.mnt);
56891 if (!error) {
56892 - error = setxattr(path.dentry, name, value, size, flags);
56893 + error = setxattr(&path, name, value, size, flags);
56894 mnt_drop_write(path.mnt);
56895 }
56896 path_put(&path);
56897 @@ -401,7 +406,7 @@ retry:
56898 return error;
56899 error = mnt_want_write(path.mnt);
56900 if (!error) {
56901 - error = setxattr(path.dentry, name, value, size, flags);
56902 + error = setxattr(&path, name, value, size, flags);
56903 mnt_drop_write(path.mnt);
56904 }
56905 path_put(&path);
56906 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56907 const void __user *,value, size_t, size, int, flags)
56908 {
56909 struct fd f = fdget(fd);
56910 - struct dentry *dentry;
56911 int error = -EBADF;
56912
56913 if (!f.file)
56914 return error;
56915 - dentry = f.file->f_path.dentry;
56916 - audit_inode(NULL, dentry, 0);
56917 + audit_inode(NULL, f.file->f_path.dentry, 0);
56918 error = mnt_want_write_file(f.file);
56919 if (!error) {
56920 - error = setxattr(dentry, name, value, size, flags);
56921 + error = setxattr(&f.file->f_path, name, value, size, flags);
56922 mnt_drop_write_file(f.file);
56923 }
56924 fdput(f);
56925 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56926 index 9fbea87..6b19972 100644
56927 --- a/fs/xattr_acl.c
56928 +++ b/fs/xattr_acl.c
56929 @@ -76,8 +76,8 @@ struct posix_acl *
56930 posix_acl_from_xattr(struct user_namespace *user_ns,
56931 const void *value, size_t size)
56932 {
56933 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56934 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56935 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56936 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56937 int count;
56938 struct posix_acl *acl;
56939 struct posix_acl_entry *acl_e;
56940 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56941 index 572a858..12a9b0d 100644
56942 --- a/fs/xfs/xfs_bmap.c
56943 +++ b/fs/xfs/xfs_bmap.c
56944 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56945 int nmap,
56946 int ret_nmap);
56947 #else
56948 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56949 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56950 #endif /* DEBUG */
56951
56952 STATIC int
56953 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56954 index 1b9fc3e..e1bdde0 100644
56955 --- a/fs/xfs/xfs_dir2_sf.c
56956 +++ b/fs/xfs/xfs_dir2_sf.c
56957 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56958 }
56959
56960 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56961 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56962 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56963 + char name[sfep->namelen];
56964 + memcpy(name, sfep->name, sfep->namelen);
56965 + if (filldir(dirent, name, sfep->namelen,
56966 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56967 + *offset = off & 0x7fffffff;
56968 + return 0;
56969 + }
56970 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56971 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56972 *offset = off & 0x7fffffff;
56973 return 0;
56974 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56975 index c1c3ef8..0952438 100644
56976 --- a/fs/xfs/xfs_ioctl.c
56977 +++ b/fs/xfs/xfs_ioctl.c
56978 @@ -127,7 +127,7 @@ xfs_find_handle(
56979 }
56980
56981 error = -EFAULT;
56982 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56983 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56984 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56985 goto out_put;
56986
56987 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56988 index d82efaa..0904a8e 100644
56989 --- a/fs/xfs/xfs_iops.c
56990 +++ b/fs/xfs/xfs_iops.c
56991 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56992 struct nameidata *nd,
56993 void *p)
56994 {
56995 - char *s = nd_get_link(nd);
56996 + const char *s = nd_get_link(nd);
56997
56998 if (!IS_ERR(s))
56999 kfree(s);
57000 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57001 new file mode 100644
57002 index 0000000..92247e4
57003 --- /dev/null
57004 +++ b/grsecurity/Kconfig
57005 @@ -0,0 +1,1021 @@
57006 +#
57007 +# grecurity configuration
57008 +#
57009 +menu "Memory Protections"
57010 +depends on GRKERNSEC
57011 +
57012 +config GRKERNSEC_KMEM
57013 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57014 + default y if GRKERNSEC_CONFIG_AUTO
57015 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57016 + help
57017 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57018 + be written to or read from to modify or leak the contents of the running
57019 + kernel. /dev/port will also not be allowed to be opened and support
57020 + for /dev/cpu/*/msr will be removed. If you have module
57021 + support disabled, enabling this will close up five ways that are
57022 + currently used to insert malicious code into the running kernel.
57023 +
57024 + Even with all these features enabled, we still highly recommend that
57025 + you use the RBAC system, as it is still possible for an attacker to
57026 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57027 +
57028 + If you are not using XFree86, you may be able to stop this additional
57029 + case by enabling the 'Disable privileged I/O' option. Though nothing
57030 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57031 + but only to video memory, which is the only writing we allow in this
57032 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57033 + not be allowed to mprotect it with PROT_WRITE later.
57034 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57035 + from working.
57036 +
57037 + It is highly recommended that you say Y here if you meet all the
57038 + conditions above.
57039 +
57040 +config GRKERNSEC_VM86
57041 + bool "Restrict VM86 mode"
57042 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57043 + depends on X86_32
57044 +
57045 + help
57046 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57047 + make use of a special execution mode on 32bit x86 processors called
57048 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57049 + video cards and will still work with this option enabled. The purpose
57050 + of the option is to prevent exploitation of emulation errors in
57051 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57052 + Nearly all users should be able to enable this option.
57053 +
57054 +config GRKERNSEC_IO
57055 + bool "Disable privileged I/O"
57056 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57057 + depends on X86
57058 + select RTC_CLASS
57059 + select RTC_INTF_DEV
57060 + select RTC_DRV_CMOS
57061 +
57062 + help
57063 + If you say Y here, all ioperm and iopl calls will return an error.
57064 + Ioperm and iopl can be used to modify the running kernel.
57065 + Unfortunately, some programs need this access to operate properly,
57066 + the most notable of which are XFree86 and hwclock. hwclock can be
57067 + remedied by having RTC support in the kernel, so real-time
57068 + clock support is enabled if this option is enabled, to ensure
57069 + that hwclock operates correctly. XFree86 still will not
57070 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57071 + IF YOU USE XFree86. If you use XFree86 and you still want to
57072 + protect your kernel against modification, use the RBAC system.
57073 +
57074 +config GRKERNSEC_JIT_HARDEN
57075 + bool "Harden BPF JIT against spray attacks"
57076 + default y if GRKERNSEC_CONFIG_AUTO
57077 + depends on BPF_JIT
57078 + help
57079 + If you say Y here, the native code generated by the kernel's Berkeley
57080 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57081 + attacks that attempt to fit attacker-beneficial instructions in
57082 + 32bit immediate fields of JIT-generated native instructions. The
57083 + attacker will generally aim to cause an unintended instruction sequence
57084 + of JIT-generated native code to execute by jumping into the middle of
57085 + a generated instruction. This feature effectively randomizes the 32bit
57086 + immediate constants present in the generated code to thwart such attacks.
57087 +
57088 + If you're using KERNEXEC, it's recommended that you enable this option
57089 + to supplement the hardening of the kernel.
57090 +
57091 +config GRKERNSEC_RAND_THREADSTACK
57092 + bool "Insert random gaps between thread stacks"
57093 + default y if GRKERNSEC_CONFIG_AUTO
57094 + depends on PAX_RANDMMAP && !PPC
57095 + help
57096 + If you say Y here, a random-sized gap will be enforced between allocated
57097 + thread stacks. Glibc's NPTL and other threading libraries that
57098 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57099 + The implementation currently provides 8 bits of entropy for the gap.
57100 +
57101 + Many distributions do not compile threaded remote services with the
57102 + -fstack-check argument to GCC, causing the variable-sized stack-based
57103 + allocator, alloca(), to not probe the stack on allocation. This
57104 + permits an unbounded alloca() to skip over any guard page and potentially
57105 + modify another thread's stack reliably. An enforced random gap
57106 + reduces the reliability of such an attack and increases the chance
57107 + that such a read/write to another thread's stack instead lands in
57108 + an unmapped area, causing a crash and triggering grsecurity's
57109 + anti-bruteforcing logic.
57110 +
57111 +config GRKERNSEC_PROC_MEMMAP
57112 + bool "Harden ASLR against information leaks and entropy reduction"
57113 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57114 + depends on PAX_NOEXEC || PAX_ASLR
57115 + help
57116 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57117 + give no information about the addresses of its mappings if
57118 + PaX features that rely on random addresses are enabled on the task.
57119 + In addition to sanitizing this information and disabling other
57120 + dangerous sources of information, this option causes reads of sensitive
57121 + /proc/<pid> entries where the file descriptor was opened in a different
57122 + task than the one performing the read. Such attempts are logged.
57123 + This option also limits argv/env strings for suid/sgid binaries
57124 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57125 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57126 + binaries to prevent alternative mmap layouts from being abused.
57127 +
57128 + If you use PaX it is essential that you say Y here as it closes up
57129 + several holes that make full ASLR useless locally.
57130 +
57131 +config GRKERNSEC_BRUTE
57132 + bool "Deter exploit bruteforcing"
57133 + default y if GRKERNSEC_CONFIG_AUTO
57134 + help
57135 + If you say Y here, attempts to bruteforce exploits against forking
57136 + daemons such as apache or sshd, as well as against suid/sgid binaries
57137 + will be deterred. When a child of a forking daemon is killed by PaX
57138 + or crashes due to an illegal instruction or other suspicious signal,
57139 + the parent process will be delayed 30 seconds upon every subsequent
57140 + fork until the administrator is able to assess the situation and
57141 + restart the daemon.
57142 + In the suid/sgid case, the attempt is logged, the user has all their
57143 + processes terminated, and they are prevented from executing any further
57144 + processes for 15 minutes.
57145 + It is recommended that you also enable signal logging in the auditing
57146 + section so that logs are generated when a process triggers a suspicious
57147 + signal.
57148 + If the sysctl option is enabled, a sysctl option with name
57149 + "deter_bruteforce" is created.
57150 +
57151 +
57152 +config GRKERNSEC_MODHARDEN
57153 + bool "Harden module auto-loading"
57154 + default y if GRKERNSEC_CONFIG_AUTO
57155 + depends on MODULES
57156 + help
57157 + If you say Y here, module auto-loading in response to use of some
57158 + feature implemented by an unloaded module will be restricted to
57159 + root users. Enabling this option helps defend against attacks
57160 + by unprivileged users who abuse the auto-loading behavior to
57161 + cause a vulnerable module to load that is then exploited.
57162 +
57163 + If this option prevents a legitimate use of auto-loading for a
57164 + non-root user, the administrator can execute modprobe manually
57165 + with the exact name of the module mentioned in the alert log.
57166 + Alternatively, the administrator can add the module to the list
57167 + of modules loaded at boot by modifying init scripts.
57168 +
57169 + Modification of init scripts will most likely be needed on
57170 + Ubuntu servers with encrypted home directory support enabled,
57171 + as the first non-root user logging in will cause the ecb(aes),
57172 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57173 +
57174 +config GRKERNSEC_HIDESYM
57175 + bool "Hide kernel symbols"
57176 + default y if GRKERNSEC_CONFIG_AUTO
57177 + select PAX_USERCOPY_SLABS
57178 + help
57179 + If you say Y here, getting information on loaded modules, and
57180 + displaying all kernel symbols through a syscall will be restricted
57181 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57182 + /proc/kallsyms will be restricted to the root user. The RBAC
57183 + system can hide that entry even from root.
57184 +
57185 + This option also prevents leaking of kernel addresses through
57186 + several /proc entries.
57187 +
57188 + Note that this option is only effective provided the following
57189 + conditions are met:
57190 + 1) The kernel using grsecurity is not precompiled by some distribution
57191 + 2) You have also enabled GRKERNSEC_DMESG
57192 + 3) You are using the RBAC system and hiding other files such as your
57193 + kernel image and System.map. Alternatively, enabling this option
57194 + causes the permissions on /boot, /lib/modules, and the kernel
57195 + source directory to change at compile time to prevent
57196 + reading by non-root users.
57197 + If the above conditions are met, this option will aid in providing a
57198 + useful protection against local kernel exploitation of overflows
57199 + and arbitrary read/write vulnerabilities.
57200 +
57201 +config GRKERNSEC_KERN_LOCKOUT
57202 + bool "Active kernel exploit response"
57203 + default y if GRKERNSEC_CONFIG_AUTO
57204 + depends on X86 || ARM || PPC || SPARC
57205 + help
57206 + If you say Y here, when a PaX alert is triggered due to suspicious
57207 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57208 + or an OOPS occurs due to bad memory accesses, instead of just
57209 + terminating the offending process (and potentially allowing
57210 + a subsequent exploit from the same user), we will take one of two
57211 + actions:
57212 + If the user was root, we will panic the system
57213 + If the user was non-root, we will log the attempt, terminate
57214 + all processes owned by the user, then prevent them from creating
57215 + any new processes until the system is restarted
57216 + This deters repeated kernel exploitation/bruteforcing attempts
57217 + and is useful for later forensics.
57218 +
57219 +endmenu
57220 +menu "Role Based Access Control Options"
57221 +depends on GRKERNSEC
57222 +
57223 +config GRKERNSEC_RBAC_DEBUG
57224 + bool
57225 +
57226 +config GRKERNSEC_NO_RBAC
57227 + bool "Disable RBAC system"
57228 + help
57229 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57230 + preventing the RBAC system from being enabled. You should only say Y
57231 + here if you have no intention of using the RBAC system, so as to prevent
57232 + an attacker with root access from misusing the RBAC system to hide files
57233 + and processes when loadable module support and /dev/[k]mem have been
57234 + locked down.
57235 +
57236 +config GRKERNSEC_ACL_HIDEKERN
57237 + bool "Hide kernel processes"
57238 + help
57239 + If you say Y here, all kernel threads will be hidden to all
57240 + processes but those whose subject has the "view hidden processes"
57241 + flag.
57242 +
57243 +config GRKERNSEC_ACL_MAXTRIES
57244 + int "Maximum tries before password lockout"
57245 + default 3
57246 + help
57247 + This option enforces the maximum number of times a user can attempt
57248 + to authorize themselves with the grsecurity RBAC system before being
57249 + denied the ability to attempt authorization again for a specified time.
57250 + The lower the number, the harder it will be to brute-force a password.
57251 +
57252 +config GRKERNSEC_ACL_TIMEOUT
57253 + int "Time to wait after max password tries, in seconds"
57254 + default 30
57255 + help
57256 + This option specifies the time the user must wait after attempting to
57257 + authorize to the RBAC system with the maximum number of invalid
57258 + passwords. The higher the number, the harder it will be to brute-force
57259 + a password.
57260 +
57261 +endmenu
57262 +menu "Filesystem Protections"
57263 +depends on GRKERNSEC
57264 +
57265 +config GRKERNSEC_PROC
57266 + bool "Proc restrictions"
57267 + default y if GRKERNSEC_CONFIG_AUTO
57268 + help
57269 + If you say Y here, the permissions of the /proc filesystem
57270 + will be altered to enhance system security and privacy. You MUST
57271 + choose either a user only restriction or a user and group restriction.
57272 + Depending upon the option you choose, you can either restrict users to
57273 + see only the processes they themselves run, or choose a group that can
57274 + view all processes and files normally restricted to root if you choose
57275 + the "restrict to user only" option. NOTE: If you're running identd or
57276 + ntpd as a non-root user, you will have to run it as the group you
57277 + specify here.
57278 +
57279 +config GRKERNSEC_PROC_USER
57280 + bool "Restrict /proc to user only"
57281 + depends on GRKERNSEC_PROC
57282 + help
57283 + If you say Y here, non-root users will only be able to view their own
57284 + processes, and restricts them from viewing network-related information,
57285 + and viewing kernel symbol and module information.
57286 +
57287 +config GRKERNSEC_PROC_USERGROUP
57288 + bool "Allow special group"
57289 + default y if GRKERNSEC_CONFIG_AUTO
57290 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57291 + help
57292 + If you say Y here, you will be able to select a group that will be
57293 + able to view all processes and network-related information. If you've
57294 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57295 + remain hidden. This option is useful if you want to run identd as
57296 + a non-root user. The group you select may also be chosen at boot time
57297 + via "grsec_proc_gid=" on the kernel commandline.
57298 +
57299 +config GRKERNSEC_PROC_GID
57300 + int "GID for special group"
57301 + depends on GRKERNSEC_PROC_USERGROUP
57302 + default 1001
57303 +
57304 +config GRKERNSEC_PROC_ADD
57305 + bool "Additional restrictions"
57306 + default y if GRKERNSEC_CONFIG_AUTO
57307 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57308 + help
57309 + If you say Y here, additional restrictions will be placed on
57310 + /proc that keep normal users from viewing device information and
57311 + slabinfo information that could be useful for exploits.
57312 +
57313 +config GRKERNSEC_LINK
57314 + bool "Linking restrictions"
57315 + default y if GRKERNSEC_CONFIG_AUTO
57316 + help
57317 + If you say Y here, /tmp race exploits will be prevented, since users
57318 + will no longer be able to follow symlinks owned by other users in
57319 + world-writable +t directories (e.g. /tmp), unless the owner of the
57320 + symlink is the owner of the directory. users will also not be
57321 + able to hardlink to files they do not own. If the sysctl option is
57322 + enabled, a sysctl option with name "linking_restrictions" is created.
57323 +
57324 +config GRKERNSEC_SYMLINKOWN
57325 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57326 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57327 + help
57328 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57329 + that prevents it from being used as a security feature. As Apache
57330 + verifies the symlink by performing a stat() against the target of
57331 + the symlink before it is followed, an attacker can setup a symlink
57332 + to point to a same-owned file, then replace the symlink with one
57333 + that targets another user's file just after Apache "validates" the
57334 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57335 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57336 + will be in place for the group you specify. If the sysctl option
57337 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57338 + created.
57339 +
57340 +config GRKERNSEC_SYMLINKOWN_GID
57341 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57342 + depends on GRKERNSEC_SYMLINKOWN
57343 + default 1006
57344 + help
57345 + Setting this GID determines what group kernel-enforced
57346 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57347 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57348 +
57349 +config GRKERNSEC_FIFO
57350 + bool "FIFO restrictions"
57351 + default y if GRKERNSEC_CONFIG_AUTO
57352 + help
57353 + If you say Y here, users will not be able to write to FIFOs they don't
57354 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57355 + the FIFO is the same owner of the directory it's held in. If the sysctl
57356 + option is enabled, a sysctl option with name "fifo_restrictions" is
57357 + created.
57358 +
57359 +config GRKERNSEC_SYSFS_RESTRICT
57360 + bool "Sysfs/debugfs restriction"
57361 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57362 + depends on SYSFS
57363 + help
57364 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57365 + any filesystem normally mounted under it (e.g. debugfs) will be
57366 + mostly accessible only by root. These filesystems generally provide access
57367 + to hardware and debug information that isn't appropriate for unprivileged
57368 + users of the system. Sysfs and debugfs have also become a large source
57369 + of new vulnerabilities, ranging from infoleaks to local compromise.
57370 + There has been very little oversight with an eye toward security involved
57371 + in adding new exporters of information to these filesystems, so their
57372 + use is discouraged.
57373 + For reasons of compatibility, a few directories have been whitelisted
57374 + for access by non-root users:
57375 + /sys/fs/selinux
57376 + /sys/fs/fuse
57377 + /sys/devices/system/cpu
57378 +
57379 +config GRKERNSEC_ROFS
57380 + bool "Runtime read-only mount protection"
57381 + help
57382 + If you say Y here, a sysctl option with name "romount_protect" will
57383 + be created. By setting this option to 1 at runtime, filesystems
57384 + will be protected in the following ways:
57385 + * No new writable mounts will be allowed
57386 + * Existing read-only mounts won't be able to be remounted read/write
57387 + * Write operations will be denied on all block devices
57388 + This option acts independently of grsec_lock: once it is set to 1,
57389 + it cannot be turned off. Therefore, please be mindful of the resulting
57390 + behavior if this option is enabled in an init script on a read-only
57391 + filesystem. This feature is mainly intended for secure embedded systems.
57392 +
57393 +config GRKERNSEC_DEVICE_SIDECHANNEL
57394 + bool "Eliminate stat/notify-based device sidechannels"
57395 + default y if GRKERNSEC_CONFIG_AUTO
57396 + help
57397 + If you say Y here, timing analyses on block or character
57398 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57399 + will be thwarted for unprivileged users. If a process without
57400 + CAP_MKNOD stats such a device, the last access and last modify times
57401 + will match the device's create time. No access or modify events
57402 + will be triggered through inotify/dnotify/fanotify for such devices.
57403 + This feature will prevent attacks that may at a minimum
57404 + allow an attacker to determine the administrator's password length.
57405 +
57406 +config GRKERNSEC_CHROOT
57407 + bool "Chroot jail restrictions"
57408 + default y if GRKERNSEC_CONFIG_AUTO
57409 + help
57410 + If you say Y here, you will be able to choose several options that will
57411 + make breaking out of a chrooted jail much more difficult. If you
57412 + encounter no software incompatibilities with the following options, it
57413 + is recommended that you enable each one.
57414 +
57415 +config GRKERNSEC_CHROOT_MOUNT
57416 + bool "Deny mounts"
57417 + default y if GRKERNSEC_CONFIG_AUTO
57418 + depends on GRKERNSEC_CHROOT
57419 + help
57420 + If you say Y here, processes inside a chroot will not be able to
57421 + mount or remount filesystems. If the sysctl option is enabled, a
57422 + sysctl option with name "chroot_deny_mount" is created.
57423 +
57424 +config GRKERNSEC_CHROOT_DOUBLE
57425 + bool "Deny double-chroots"
57426 + default y if GRKERNSEC_CONFIG_AUTO
57427 + depends on GRKERNSEC_CHROOT
57428 + help
57429 + If you say Y here, processes inside a chroot will not be able to chroot
57430 + again outside the chroot. This is a widely used method of breaking
57431 + out of a chroot jail and should not be allowed. If the sysctl
57432 + option is enabled, a sysctl option with name
57433 + "chroot_deny_chroot" is created.
57434 +
57435 +config GRKERNSEC_CHROOT_PIVOT
57436 + bool "Deny pivot_root in chroot"
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 use
57441 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57442 + works similar to chroot in that it changes the root filesystem. This
57443 + function could be misused in a chrooted process to attempt to break out
57444 + of the chroot, and therefore should not be allowed. If the sysctl
57445 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57446 + created.
57447 +
57448 +config GRKERNSEC_CHROOT_CHDIR
57449 + bool "Enforce chdir(\"/\") on all chroots"
57450 + default y if GRKERNSEC_CONFIG_AUTO
57451 + depends on GRKERNSEC_CHROOT
57452 + help
57453 + If you say Y here, the current working directory of all newly-chrooted
57454 + applications will be set to the the root directory of the chroot.
57455 + The man page on chroot(2) states:
57456 + Note that this call does not change the current working
57457 + directory, so that `.' can be outside the tree rooted at
57458 + `/'. In particular, the super-user can escape from a
57459 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57460 +
57461 + It is recommended that you say Y here, since it's not known to break
57462 + any software. If the sysctl option is enabled, a sysctl option with
57463 + name "chroot_enforce_chdir" is created.
57464 +
57465 +config GRKERNSEC_CHROOT_CHMOD
57466 + bool "Deny (f)chmod +s"
57467 + default y if GRKERNSEC_CONFIG_AUTO
57468 + depends on GRKERNSEC_CHROOT
57469 + help
57470 + If you say Y here, processes inside a chroot will not be able to chmod
57471 + or fchmod files to make them have suid or sgid bits. This protects
57472 + against another published method of breaking a chroot. If the sysctl
57473 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57474 + created.
57475 +
57476 +config GRKERNSEC_CHROOT_FCHDIR
57477 + bool "Deny fchdir out of chroot"
57478 + default y if GRKERNSEC_CONFIG_AUTO
57479 + depends on GRKERNSEC_CHROOT
57480 + help
57481 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57482 + to a file descriptor of the chrooting process that points to a directory
57483 + outside the filesystem will be stopped. If the sysctl option
57484 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57485 +
57486 +config GRKERNSEC_CHROOT_MKNOD
57487 + bool "Deny mknod"
57488 + default y if GRKERNSEC_CONFIG_AUTO
57489 + depends on GRKERNSEC_CHROOT
57490 + help
57491 + If you say Y here, processes inside a chroot will not be allowed to
57492 + mknod. The problem with using mknod inside a chroot is that it
57493 + would allow an attacker to create a device entry that is the same
57494 + as one on the physical root of your system, which could range from
57495 + anything from the console device to a device for your harddrive (which
57496 + they could then use to wipe the drive or steal data). It is recommended
57497 + that you say Y here, unless you run into software incompatibilities.
57498 + If the sysctl option is enabled, a sysctl option with name
57499 + "chroot_deny_mknod" is created.
57500 +
57501 +config GRKERNSEC_CHROOT_SHMAT
57502 + bool "Deny shmat() out of chroot"
57503 + default y if GRKERNSEC_CONFIG_AUTO
57504 + depends on GRKERNSEC_CHROOT
57505 + help
57506 + If you say Y here, processes inside a chroot will not be able to attach
57507 + to shared memory segments that were created outside of the chroot jail.
57508 + It is recommended that you say Y here. If the sysctl option is enabled,
57509 + a sysctl option with name "chroot_deny_shmat" is created.
57510 +
57511 +config GRKERNSEC_CHROOT_UNIX
57512 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57513 + default y if GRKERNSEC_CONFIG_AUTO
57514 + depends on GRKERNSEC_CHROOT
57515 + help
57516 + If you say Y here, processes inside a chroot will not be able to
57517 + connect to abstract (meaning not belonging to a filesystem) Unix
57518 + domain sockets that were bound outside of a chroot. It is recommended
57519 + that you say Y here. If the sysctl option is enabled, a sysctl option
57520 + with name "chroot_deny_unix" is created.
57521 +
57522 +config GRKERNSEC_CHROOT_FINDTASK
57523 + bool "Protect outside processes"
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 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57529 + getsid, or view any process outside of the chroot. If the sysctl
57530 + option is enabled, a sysctl option with name "chroot_findtask" is
57531 + created.
57532 +
57533 +config GRKERNSEC_CHROOT_NICE
57534 + bool "Restrict priority changes"
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 raise
57539 + the priority of processes in the chroot, or alter the priority of
57540 + processes outside the chroot. This provides more security than simply
57541 + removing CAP_SYS_NICE from the process' capability set. If the
57542 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57543 + is created.
57544 +
57545 +config GRKERNSEC_CHROOT_SYSCTL
57546 + bool "Deny sysctl writes"
57547 + default y if GRKERNSEC_CONFIG_AUTO
57548 + depends on GRKERNSEC_CHROOT
57549 + help
57550 + If you say Y here, an attacker in a chroot will not be able to
57551 + write to sysctl entries, either by sysctl(2) or through a /proc
57552 + interface. It is strongly recommended that you say Y here. If the
57553 + sysctl option is enabled, a sysctl option with name
57554 + "chroot_deny_sysctl" is created.
57555 +
57556 +config GRKERNSEC_CHROOT_CAPS
57557 + bool "Capability restrictions"
57558 + default y if GRKERNSEC_CONFIG_AUTO
57559 + depends on GRKERNSEC_CHROOT
57560 + help
57561 + If you say Y here, the capabilities on all processes within a
57562 + chroot jail will be lowered to stop module insertion, raw i/o,
57563 + system and net admin tasks, rebooting the system, modifying immutable
57564 + files, modifying IPC owned by another, and changing the system time.
57565 + This is left an option because it can break some apps. Disable this
57566 + if your chrooted apps are having problems performing those kinds of
57567 + tasks. If the sysctl option is enabled, a sysctl option with
57568 + name "chroot_caps" is created.
57569 +
57570 +endmenu
57571 +menu "Kernel Auditing"
57572 +depends on GRKERNSEC
57573 +
57574 +config GRKERNSEC_AUDIT_GROUP
57575 + bool "Single group for auditing"
57576 + help
57577 + If you say Y here, the exec and chdir logging features will only operate
57578 + on a group you specify. This option is recommended if you only want to
57579 + watch certain users instead of having a large amount of logs from the
57580 + entire system. If the sysctl option is enabled, a sysctl option with
57581 + name "audit_group" is created.
57582 +
57583 +config GRKERNSEC_AUDIT_GID
57584 + int "GID for auditing"
57585 + depends on GRKERNSEC_AUDIT_GROUP
57586 + default 1007
57587 +
57588 +config GRKERNSEC_EXECLOG
57589 + bool "Exec logging"
57590 + help
57591 + If you say Y here, all execve() calls will be logged (since the
57592 + other exec*() calls are frontends to execve(), all execution
57593 + will be logged). Useful for shell-servers that like to keep track
57594 + of their users. If the sysctl option is enabled, a sysctl option with
57595 + name "exec_logging" is created.
57596 + WARNING: This option when enabled will produce a LOT of logs, especially
57597 + on an active system.
57598 +
57599 +config GRKERNSEC_RESLOG
57600 + bool "Resource logging"
57601 + default y if GRKERNSEC_CONFIG_AUTO
57602 + help
57603 + If you say Y here, all attempts to overstep resource limits will
57604 + be logged with the resource name, the requested size, and the current
57605 + limit. It is highly recommended that you say Y here. If the sysctl
57606 + option is enabled, a sysctl option with name "resource_logging" is
57607 + created. If the RBAC system is enabled, the sysctl value is ignored.
57608 +
57609 +config GRKERNSEC_CHROOT_EXECLOG
57610 + bool "Log execs within chroot"
57611 + help
57612 + If you say Y here, all executions inside a chroot jail will be logged
57613 + to syslog. This can cause a large amount of logs if certain
57614 + applications (eg. djb's daemontools) are installed on the system, and
57615 + is therefore left as an option. If the sysctl option is enabled, a
57616 + sysctl option with name "chroot_execlog" is created.
57617 +
57618 +config GRKERNSEC_AUDIT_PTRACE
57619 + bool "Ptrace logging"
57620 + help
57621 + If you say Y here, all attempts to attach to a process via ptrace
57622 + will be logged. If the sysctl option is enabled, a sysctl option
57623 + with name "audit_ptrace" is created.
57624 +
57625 +config GRKERNSEC_AUDIT_CHDIR
57626 + bool "Chdir logging"
57627 + help
57628 + If you say Y here, all chdir() calls will be logged. If the sysctl
57629 + option is enabled, a sysctl option with name "audit_chdir" is created.
57630 +
57631 +config GRKERNSEC_AUDIT_MOUNT
57632 + bool "(Un)Mount logging"
57633 + help
57634 + If you say Y here, all mounts and unmounts will be logged. If the
57635 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57636 + created.
57637 +
57638 +config GRKERNSEC_SIGNAL
57639 + bool "Signal logging"
57640 + default y if GRKERNSEC_CONFIG_AUTO
57641 + help
57642 + If you say Y here, certain important signals will be logged, such as
57643 + SIGSEGV, which will as a result inform you of when a error in a program
57644 + occurred, which in some cases could mean a possible exploit attempt.
57645 + If the sysctl option is enabled, a sysctl option with name
57646 + "signal_logging" is created.
57647 +
57648 +config GRKERNSEC_FORKFAIL
57649 + bool "Fork failure logging"
57650 + help
57651 + If you say Y here, all failed fork() attempts will be logged.
57652 + This could suggest a fork bomb, or someone attempting to overstep
57653 + their process limit. If the sysctl option is enabled, a sysctl option
57654 + with name "forkfail_logging" is created.
57655 +
57656 +config GRKERNSEC_TIME
57657 + bool "Time change logging"
57658 + default y if GRKERNSEC_CONFIG_AUTO
57659 + help
57660 + If you say Y here, any changes of the system clock will be logged.
57661 + If the sysctl option is enabled, a sysctl option with name
57662 + "timechange_logging" is created.
57663 +
57664 +config GRKERNSEC_PROC_IPADDR
57665 + bool "/proc/<pid>/ipaddr support"
57666 + default y if GRKERNSEC_CONFIG_AUTO
57667 + help
57668 + If you say Y here, a new entry will be added to each /proc/<pid>
57669 + directory that contains the IP address of the person using the task.
57670 + The IP is carried across local TCP and AF_UNIX stream sockets.
57671 + This information can be useful for IDS/IPSes to perform remote response
57672 + to a local attack. The entry is readable by only the owner of the
57673 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57674 + the RBAC system), and thus does not create privacy concerns.
57675 +
57676 +config GRKERNSEC_RWXMAP_LOG
57677 + bool 'Denied RWX mmap/mprotect logging'
57678 + default y if GRKERNSEC_CONFIG_AUTO
57679 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57680 + help
57681 + If you say Y here, calls to mmap() and mprotect() with explicit
57682 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57683 + denied by the PAX_MPROTECT feature. If the sysctl option is
57684 + enabled, a sysctl option with name "rwxmap_logging" is created.
57685 +
57686 +config GRKERNSEC_AUDIT_TEXTREL
57687 + bool 'ELF text relocations logging (READ HELP)'
57688 + depends on PAX_MPROTECT
57689 + help
57690 + If you say Y here, text relocations will be logged with the filename
57691 + of the offending library or binary. The purpose of the feature is
57692 + to help Linux distribution developers get rid of libraries and
57693 + binaries that need text relocations which hinder the future progress
57694 + of PaX. Only Linux distribution developers should say Y here, and
57695 + never on a production machine, as this option creates an information
57696 + leak that could aid an attacker in defeating the randomization of
57697 + a single memory region. If the sysctl option is enabled, a sysctl
57698 + option with name "audit_textrel" is created.
57699 +
57700 +endmenu
57701 +
57702 +menu "Executable Protections"
57703 +depends on GRKERNSEC
57704 +
57705 +config GRKERNSEC_DMESG
57706 + bool "Dmesg(8) restriction"
57707 + default y if GRKERNSEC_CONFIG_AUTO
57708 + help
57709 + If you say Y here, non-root users will not be able to use dmesg(8)
57710 + to view the contents of the kernel's circular log buffer.
57711 + The kernel's log buffer often contains kernel addresses and other
57712 + identifying information useful to an attacker in fingerprinting a
57713 + system for a targeted exploit.
57714 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57715 + created.
57716 +
57717 +config GRKERNSEC_HARDEN_PTRACE
57718 + bool "Deter ptrace-based process snooping"
57719 + default y if GRKERNSEC_CONFIG_AUTO
57720 + help
57721 + If you say Y here, TTY sniffers and other malicious monitoring
57722 + programs implemented through ptrace will be defeated. If you
57723 + have been using the RBAC system, this option has already been
57724 + enabled for several years for all users, with the ability to make
57725 + fine-grained exceptions.
57726 +
57727 + This option only affects the ability of non-root users to ptrace
57728 + processes that are not a descendent of the ptracing process.
57729 + This means that strace ./binary and gdb ./binary will still work,
57730 + but attaching to arbitrary processes will not. If the sysctl
57731 + option is enabled, a sysctl option with name "harden_ptrace" is
57732 + created.
57733 +
57734 +config GRKERNSEC_PTRACE_READEXEC
57735 + bool "Require read access to ptrace sensitive binaries"
57736 + default y if GRKERNSEC_CONFIG_AUTO
57737 + help
57738 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57739 + binaries. This option is useful in environments that
57740 + remove the read bits (e.g. file mode 4711) from suid binaries to
57741 + prevent infoleaking of their contents. This option adds
57742 + consistency to the use of that file mode, as the binary could normally
57743 + be read out when run without privileges while ptracing.
57744 +
57745 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57746 + is created.
57747 +
57748 +config GRKERNSEC_SETXID
57749 + bool "Enforce consistent multithreaded privileges"
57750 + default y if GRKERNSEC_CONFIG_AUTO
57751 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57752 + help
57753 + If you say Y here, a change from a root uid to a non-root uid
57754 + in a multithreaded application will cause the resulting uids,
57755 + gids, supplementary groups, and capabilities in that thread
57756 + to be propagated to the other threads of the process. In most
57757 + cases this is unnecessary, as glibc will emulate this behavior
57758 + on behalf of the application. Other libcs do not act in the
57759 + same way, allowing the other threads of the process to continue
57760 + running with root privileges. If the sysctl option is enabled,
57761 + a sysctl option with name "consistent_setxid" is created.
57762 +
57763 +config GRKERNSEC_TPE
57764 + bool "Trusted Path Execution (TPE)"
57765 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57766 + help
57767 + If you say Y here, you will be able to choose a gid to add to the
57768 + supplementary groups of users you want to mark as "untrusted."
57769 + These users will not be able to execute any files that are not in
57770 + root-owned directories writable only by root. If the sysctl option
57771 + is enabled, a sysctl option with name "tpe" is created.
57772 +
57773 +config GRKERNSEC_TPE_ALL
57774 + bool "Partially restrict all non-root users"
57775 + depends on GRKERNSEC_TPE
57776 + help
57777 + If you say Y here, all non-root users will be covered under
57778 + a weaker TPE restriction. This is separate from, and in addition to,
57779 + the main TPE options that you have selected elsewhere. Thus, if a
57780 + "trusted" GID is chosen, this restriction applies to even that GID.
57781 + Under this restriction, all non-root users will only be allowed to
57782 + execute files in directories they own that are not group or
57783 + world-writable, or in directories owned by root and writable only by
57784 + root. If the sysctl option is enabled, a sysctl option with name
57785 + "tpe_restrict_all" is created.
57786 +
57787 +config GRKERNSEC_TPE_INVERT
57788 + bool "Invert GID option"
57789 + depends on GRKERNSEC_TPE
57790 + help
57791 + If you say Y here, the group you specify in the TPE configuration will
57792 + decide what group TPE restrictions will be *disabled* for. This
57793 + option is useful if you want TPE restrictions to be applied to most
57794 + users on the system. If the sysctl option is enabled, a sysctl option
57795 + with name "tpe_invert" is created. Unlike other sysctl options, this
57796 + entry will default to on for backward-compatibility.
57797 +
57798 +config GRKERNSEC_TPE_GID
57799 + int
57800 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57801 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57802 +
57803 +config GRKERNSEC_TPE_UNTRUSTED_GID
57804 + int "GID for TPE-untrusted users"
57805 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57806 + default 1005
57807 + help
57808 + Setting this GID determines what group TPE restrictions will be
57809 + *enabled* for. If the sysctl option is enabled, a sysctl option
57810 + with name "tpe_gid" is created.
57811 +
57812 +config GRKERNSEC_TPE_TRUSTED_GID
57813 + int "GID for TPE-trusted users"
57814 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57815 + default 1005
57816 + help
57817 + Setting this GID determines what group TPE restrictions will be
57818 + *disabled* for. If the sysctl option is enabled, a sysctl option
57819 + with name "tpe_gid" is created.
57820 +
57821 +endmenu
57822 +menu "Network Protections"
57823 +depends on GRKERNSEC
57824 +
57825 +config GRKERNSEC_RANDNET
57826 + bool "Larger entropy pools"
57827 + default y if GRKERNSEC_CONFIG_AUTO
57828 + help
57829 + If you say Y here, the entropy pools used for many features of Linux
57830 + and grsecurity will be doubled in size. Since several grsecurity
57831 + features use additional randomness, it is recommended that you say Y
57832 + here. Saying Y here has a similar effect as modifying
57833 + /proc/sys/kernel/random/poolsize.
57834 +
57835 +config GRKERNSEC_BLACKHOLE
57836 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57837 + default y if GRKERNSEC_CONFIG_AUTO
57838 + depends on NET
57839 + help
57840 + If you say Y here, neither TCP resets nor ICMP
57841 + destination-unreachable packets will be sent in response to packets
57842 + sent to ports for which no associated listening process exists.
57843 + This feature supports both IPV4 and IPV6 and exempts the
57844 + loopback interface from blackholing. Enabling this feature
57845 + makes a host more resilient to DoS attacks and reduces network
57846 + visibility against scanners.
57847 +
57848 + The blackhole feature as-implemented is equivalent to the FreeBSD
57849 + blackhole feature, as it prevents RST responses to all packets, not
57850 + just SYNs. Under most application behavior this causes no
57851 + problems, but applications (like haproxy) may not close certain
57852 + connections in a way that cleanly terminates them on the remote
57853 + end, leaving the remote host in LAST_ACK state. Because of this
57854 + side-effect and to prevent intentional LAST_ACK DoSes, this
57855 + feature also adds automatic mitigation against such attacks.
57856 + The mitigation drastically reduces the amount of time a socket
57857 + can spend in LAST_ACK state. If you're using haproxy and not
57858 + all servers it connects to have this option enabled, consider
57859 + disabling this feature on the haproxy host.
57860 +
57861 + If the sysctl option is enabled, two sysctl options with names
57862 + "ip_blackhole" and "lastack_retries" will be created.
57863 + While "ip_blackhole" takes the standard zero/non-zero on/off
57864 + toggle, "lastack_retries" uses the same kinds of values as
57865 + "tcp_retries1" and "tcp_retries2". The default value of 4
57866 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57867 + state.
57868 +
57869 +config GRKERNSEC_NO_SIMULT_CONNECT
57870 + bool "Disable TCP Simultaneous Connect"
57871 + default y if GRKERNSEC_CONFIG_AUTO
57872 + depends on NET
57873 + help
57874 + If you say Y here, a feature by Willy Tarreau will be enabled that
57875 + removes a weakness in Linux's strict implementation of TCP that
57876 + allows two clients to connect to each other without either entering
57877 + a listening state. The weakness allows an attacker to easily prevent
57878 + a client from connecting to a known server provided the source port
57879 + for the connection is guessed correctly.
57880 +
57881 + As the weakness could be used to prevent an antivirus or IPS from
57882 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57883 + it should be eliminated by enabling this option. Though Linux is
57884 + one of few operating systems supporting simultaneous connect, it
57885 + has no legitimate use in practice and is rarely supported by firewalls.
57886 +
57887 +config GRKERNSEC_SOCKET
57888 + bool "Socket restrictions"
57889 + depends on NET
57890 + help
57891 + If you say Y here, you will be able to choose from several options.
57892 + If you assign a GID on your system and add it to the supplementary
57893 + groups of users you want to restrict socket access to, this patch
57894 + will perform up to three things, based on the option(s) you choose.
57895 +
57896 +config GRKERNSEC_SOCKET_ALL
57897 + bool "Deny any sockets to group"
57898 + depends on GRKERNSEC_SOCKET
57899 + help
57900 + If you say Y here, you will be able to choose a GID of whose users will
57901 + be unable to connect to other hosts from your machine or run server
57902 + applications from your machine. If the sysctl option is enabled, a
57903 + sysctl option with name "socket_all" is created.
57904 +
57905 +config GRKERNSEC_SOCKET_ALL_GID
57906 + int "GID to deny all sockets for"
57907 + depends on GRKERNSEC_SOCKET_ALL
57908 + default 1004
57909 + help
57910 + Here you can choose the GID to disable socket access for. Remember to
57911 + add the users you want socket access disabled for to the GID
57912 + specified here. If the sysctl option is enabled, a sysctl option
57913 + with name "socket_all_gid" is created.
57914 +
57915 +config GRKERNSEC_SOCKET_CLIENT
57916 + bool "Deny client sockets to group"
57917 + depends on GRKERNSEC_SOCKET
57918 + help
57919 + If you say Y here, you will be able to choose a GID of whose users will
57920 + be unable to connect to other hosts from your machine, but will be
57921 + able to run servers. If this option is enabled, all users in the group
57922 + you specify will have to use passive mode when initiating ftp transfers
57923 + from the shell on your machine. If the sysctl option is enabled, a
57924 + sysctl option with name "socket_client" is created.
57925 +
57926 +config GRKERNSEC_SOCKET_CLIENT_GID
57927 + int "GID to deny client sockets for"
57928 + depends on GRKERNSEC_SOCKET_CLIENT
57929 + default 1003
57930 + help
57931 + Here you can choose the GID to disable client socket access for.
57932 + Remember to add the users you want client socket access disabled for to
57933 + the GID specified here. If the sysctl option is enabled, a sysctl
57934 + option with name "socket_client_gid" is created.
57935 +
57936 +config GRKERNSEC_SOCKET_SERVER
57937 + bool "Deny server sockets to group"
57938 + depends on GRKERNSEC_SOCKET
57939 + help
57940 + If you say Y here, you will be able to choose a GID of whose users will
57941 + be unable to run server applications from your machine. If the sysctl
57942 + option is enabled, a sysctl option with name "socket_server" is created.
57943 +
57944 +config GRKERNSEC_SOCKET_SERVER_GID
57945 + int "GID to deny server sockets for"
57946 + depends on GRKERNSEC_SOCKET_SERVER
57947 + default 1002
57948 + help
57949 + Here you can choose the GID to disable server socket access for.
57950 + Remember to add the users you want server socket access disabled for to
57951 + the GID specified here. If the sysctl option is enabled, a sysctl
57952 + option with name "socket_server_gid" is created.
57953 +
57954 +endmenu
57955 +menu "Sysctl Support"
57956 +depends on GRKERNSEC && SYSCTL
57957 +
57958 +config GRKERNSEC_SYSCTL
57959 + bool "Sysctl support"
57960 + default y if GRKERNSEC_CONFIG_AUTO
57961 + help
57962 + If you say Y here, you will be able to change the options that
57963 + grsecurity runs with at bootup, without having to recompile your
57964 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57965 + to enable (1) or disable (0) various features. All the sysctl entries
57966 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57967 + All features enabled in the kernel configuration are disabled at boot
57968 + if you do not say Y to the "Turn on features by default" option.
57969 + All options should be set at startup, and the grsec_lock entry should
57970 + be set to a non-zero value after all the options are set.
57971 + *THIS IS EXTREMELY IMPORTANT*
57972 +
57973 +config GRKERNSEC_SYSCTL_DISTRO
57974 + bool "Extra sysctl support for distro makers (READ HELP)"
57975 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57976 + help
57977 + If you say Y here, additional sysctl options will be created
57978 + for features that affect processes running as root. Therefore,
57979 + it is critical when using this option that the grsec_lock entry be
57980 + enabled after boot. Only distros with prebuilt kernel packages
57981 + with this option enabled that can ensure grsec_lock is enabled
57982 + after boot should use this option.
57983 + *Failure to set grsec_lock after boot makes all grsec features
57984 + this option covers useless*
57985 +
57986 + Currently this option creates the following sysctl entries:
57987 + "Disable Privileged I/O": "disable_priv_io"
57988 +
57989 +config GRKERNSEC_SYSCTL_ON
57990 + bool "Turn on features by default"
57991 + default y if GRKERNSEC_CONFIG_AUTO
57992 + depends on GRKERNSEC_SYSCTL
57993 + help
57994 + If you say Y here, instead of having all features enabled in the
57995 + kernel configuration disabled at boot time, the features will be
57996 + enabled at boot time. It is recommended you say Y here unless
57997 + there is some reason you would want all sysctl-tunable features to
57998 + be disabled by default. As mentioned elsewhere, it is important
57999 + to enable the grsec_lock entry once you have finished modifying
58000 + the sysctl entries.
58001 +
58002 +endmenu
58003 +menu "Logging Options"
58004 +depends on GRKERNSEC
58005 +
58006 +config GRKERNSEC_FLOODTIME
58007 + int "Seconds in between log messages (minimum)"
58008 + default 10
58009 + help
58010 + This option allows you to enforce the number of seconds between
58011 + grsecurity log messages. The default should be suitable for most
58012 + people, however, if you choose to change it, choose a value small enough
58013 + to allow informative logs to be produced, but large enough to
58014 + prevent flooding.
58015 +
58016 +config GRKERNSEC_FLOODBURST
58017 + int "Number of messages in a burst (maximum)"
58018 + default 6
58019 + help
58020 + This option allows you to choose the maximum number of messages allowed
58021 + within the flood time interval you chose in a separate option. The
58022 + default should be suitable for most people, however if you find that
58023 + many of your logs are being interpreted as flooding, you may want to
58024 + raise this value.
58025 +
58026 +endmenu
58027 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58028 new file mode 100644
58029 index 0000000..1b9afa9
58030 --- /dev/null
58031 +++ b/grsecurity/Makefile
58032 @@ -0,0 +1,38 @@
58033 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58034 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58035 +# into an RBAC system
58036 +#
58037 +# All code in this directory and various hooks inserted throughout the kernel
58038 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58039 +# under the GPL v2 or higher
58040 +
58041 +KBUILD_CFLAGS += -Werror
58042 +
58043 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58044 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58045 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58046 +
58047 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58048 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58049 + gracl_learn.o grsec_log.o
58050 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58051 +
58052 +ifdef CONFIG_NET
58053 +obj-y += grsec_sock.o
58054 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58055 +endif
58056 +
58057 +ifndef CONFIG_GRKERNSEC
58058 +obj-y += grsec_disabled.o
58059 +endif
58060 +
58061 +ifdef CONFIG_GRKERNSEC_HIDESYM
58062 +extra-y := grsec_hidesym.o
58063 +$(obj)/grsec_hidesym.o:
58064 + @-chmod -f 500 /boot
58065 + @-chmod -f 500 /lib/modules
58066 + @-chmod -f 500 /lib64/modules
58067 + @-chmod -f 500 /lib32/modules
58068 + @-chmod -f 700 .
58069 + @echo ' grsec: protected kernel image paths'
58070 +endif
58071 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58072 new file mode 100644
58073 index 0000000..b306b36
58074 --- /dev/null
58075 +++ b/grsecurity/gracl.c
58076 @@ -0,0 +1,4071 @@
58077 +#include <linux/kernel.h>
58078 +#include <linux/module.h>
58079 +#include <linux/sched.h>
58080 +#include <linux/mm.h>
58081 +#include <linux/file.h>
58082 +#include <linux/fs.h>
58083 +#include <linux/namei.h>
58084 +#include <linux/mount.h>
58085 +#include <linux/tty.h>
58086 +#include <linux/proc_fs.h>
58087 +#include <linux/lglock.h>
58088 +#include <linux/slab.h>
58089 +#include <linux/vmalloc.h>
58090 +#include <linux/types.h>
58091 +#include <linux/sysctl.h>
58092 +#include <linux/netdevice.h>
58093 +#include <linux/ptrace.h>
58094 +#include <linux/gracl.h>
58095 +#include <linux/gralloc.h>
58096 +#include <linux/security.h>
58097 +#include <linux/grinternal.h>
58098 +#include <linux/pid_namespace.h>
58099 +#include <linux/stop_machine.h>
58100 +#include <linux/fdtable.h>
58101 +#include <linux/percpu.h>
58102 +#include <linux/lglock.h>
58103 +#include <linux/hugetlb.h>
58104 +#include <linux/posix-timers.h>
58105 +#include "../fs/mount.h"
58106 +
58107 +#include <asm/uaccess.h>
58108 +#include <asm/errno.h>
58109 +#include <asm/mman.h>
58110 +
58111 +extern struct lglock vfsmount_lock;
58112 +
58113 +static struct acl_role_db acl_role_set;
58114 +static struct name_db name_set;
58115 +static struct inodev_db inodev_set;
58116 +
58117 +/* for keeping track of userspace pointers used for subjects, so we
58118 + can share references in the kernel as well
58119 +*/
58120 +
58121 +static struct path real_root;
58122 +
58123 +static struct acl_subj_map_db subj_map_set;
58124 +
58125 +static struct acl_role_label *default_role;
58126 +
58127 +static struct acl_role_label *role_list;
58128 +
58129 +static u16 acl_sp_role_value;
58130 +
58131 +extern char *gr_shared_page[4];
58132 +static DEFINE_MUTEX(gr_dev_mutex);
58133 +DEFINE_RWLOCK(gr_inode_lock);
58134 +
58135 +struct gr_arg *gr_usermode;
58136 +
58137 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58138 +
58139 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58140 +extern void gr_clear_learn_entries(void);
58141 +
58142 +unsigned char *gr_system_salt;
58143 +unsigned char *gr_system_sum;
58144 +
58145 +static struct sprole_pw **acl_special_roles = NULL;
58146 +static __u16 num_sprole_pws = 0;
58147 +
58148 +static struct acl_role_label *kernel_role = NULL;
58149 +
58150 +static unsigned int gr_auth_attempts = 0;
58151 +static unsigned long gr_auth_expires = 0UL;
58152 +
58153 +#ifdef CONFIG_NET
58154 +extern struct vfsmount *sock_mnt;
58155 +#endif
58156 +
58157 +extern struct vfsmount *pipe_mnt;
58158 +extern struct vfsmount *shm_mnt;
58159 +
58160 +#ifdef CONFIG_HUGETLBFS
58161 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58162 +#endif
58163 +
58164 +static struct acl_object_label *fakefs_obj_rw;
58165 +static struct acl_object_label *fakefs_obj_rwx;
58166 +
58167 +extern int gr_init_uidset(void);
58168 +extern void gr_free_uidset(void);
58169 +extern void gr_remove_uid(uid_t uid);
58170 +extern int gr_find_uid(uid_t uid);
58171 +
58172 +__inline__ int
58173 +gr_acl_is_enabled(void)
58174 +{
58175 + return (gr_status & GR_READY);
58176 +}
58177 +
58178 +#ifdef CONFIG_BTRFS_FS
58179 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
58180 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
58181 +#endif
58182 +
58183 +static inline dev_t __get_dev(const struct dentry *dentry)
58184 +{
58185 +#ifdef CONFIG_BTRFS_FS
58186 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
58187 + return get_btrfs_dev_from_inode(dentry->d_inode);
58188 + else
58189 +#endif
58190 + return dentry->d_inode->i_sb->s_dev;
58191 +}
58192 +
58193 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58194 +{
58195 + return __get_dev(dentry);
58196 +}
58197 +
58198 +static char gr_task_roletype_to_char(struct task_struct *task)
58199 +{
58200 + switch (task->role->roletype &
58201 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58202 + GR_ROLE_SPECIAL)) {
58203 + case GR_ROLE_DEFAULT:
58204 + return 'D';
58205 + case GR_ROLE_USER:
58206 + return 'U';
58207 + case GR_ROLE_GROUP:
58208 + return 'G';
58209 + case GR_ROLE_SPECIAL:
58210 + return 'S';
58211 + }
58212 +
58213 + return 'X';
58214 +}
58215 +
58216 +char gr_roletype_to_char(void)
58217 +{
58218 + return gr_task_roletype_to_char(current);
58219 +}
58220 +
58221 +__inline__ int
58222 +gr_acl_tpe_check(void)
58223 +{
58224 + if (unlikely(!(gr_status & GR_READY)))
58225 + return 0;
58226 + if (current->role->roletype & GR_ROLE_TPE)
58227 + return 1;
58228 + else
58229 + return 0;
58230 +}
58231 +
58232 +int
58233 +gr_handle_rawio(const struct inode *inode)
58234 +{
58235 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58236 + if (inode && S_ISBLK(inode->i_mode) &&
58237 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58238 + !capable(CAP_SYS_RAWIO))
58239 + return 1;
58240 +#endif
58241 + return 0;
58242 +}
58243 +
58244 +static int
58245 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58246 +{
58247 + if (likely(lena != lenb))
58248 + return 0;
58249 +
58250 + return !memcmp(a, b, lena);
58251 +}
58252 +
58253 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58254 +{
58255 + *buflen -= namelen;
58256 + if (*buflen < 0)
58257 + return -ENAMETOOLONG;
58258 + *buffer -= namelen;
58259 + memcpy(*buffer, str, namelen);
58260 + return 0;
58261 +}
58262 +
58263 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58264 +{
58265 + return prepend(buffer, buflen, name->name, name->len);
58266 +}
58267 +
58268 +static int prepend_path(const struct path *path, struct path *root,
58269 + char **buffer, int *buflen)
58270 +{
58271 + struct dentry *dentry = path->dentry;
58272 + struct vfsmount *vfsmnt = path->mnt;
58273 + struct mount *mnt = real_mount(vfsmnt);
58274 + bool slash = false;
58275 + int error = 0;
58276 +
58277 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58278 + struct dentry * parent;
58279 +
58280 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58281 + /* Global root? */
58282 + if (!mnt_has_parent(mnt)) {
58283 + goto out;
58284 + }
58285 + dentry = mnt->mnt_mountpoint;
58286 + mnt = mnt->mnt_parent;
58287 + vfsmnt = &mnt->mnt;
58288 + continue;
58289 + }
58290 + parent = dentry->d_parent;
58291 + prefetch(parent);
58292 + spin_lock(&dentry->d_lock);
58293 + error = prepend_name(buffer, buflen, &dentry->d_name);
58294 + spin_unlock(&dentry->d_lock);
58295 + if (!error)
58296 + error = prepend(buffer, buflen, "/", 1);
58297 + if (error)
58298 + break;
58299 +
58300 + slash = true;
58301 + dentry = parent;
58302 + }
58303 +
58304 +out:
58305 + if (!error && !slash)
58306 + error = prepend(buffer, buflen, "/", 1);
58307 +
58308 + return error;
58309 +}
58310 +
58311 +/* this must be called with vfsmount_lock and rename_lock held */
58312 +
58313 +static char *__our_d_path(const struct path *path, struct path *root,
58314 + char *buf, int buflen)
58315 +{
58316 + char *res = buf + buflen;
58317 + int error;
58318 +
58319 + prepend(&res, &buflen, "\0", 1);
58320 + error = prepend_path(path, root, &res, &buflen);
58321 + if (error)
58322 + return ERR_PTR(error);
58323 +
58324 + return res;
58325 +}
58326 +
58327 +static char *
58328 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58329 +{
58330 + char *retval;
58331 +
58332 + retval = __our_d_path(path, root, buf, buflen);
58333 + if (unlikely(IS_ERR(retval)))
58334 + retval = strcpy(buf, "<path too long>");
58335 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58336 + retval[1] = '\0';
58337 +
58338 + return retval;
58339 +}
58340 +
58341 +static char *
58342 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58343 + char *buf, int buflen)
58344 +{
58345 + struct path path;
58346 + char *res;
58347 +
58348 + path.dentry = (struct dentry *)dentry;
58349 + path.mnt = (struct vfsmount *)vfsmnt;
58350 +
58351 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58352 + by the RBAC system */
58353 + res = gen_full_path(&path, &real_root, buf, buflen);
58354 +
58355 + return res;
58356 +}
58357 +
58358 +static char *
58359 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58360 + char *buf, int buflen)
58361 +{
58362 + char *res;
58363 + struct path path;
58364 + struct path root;
58365 + struct task_struct *reaper = init_pid_ns.child_reaper;
58366 +
58367 + path.dentry = (struct dentry *)dentry;
58368 + path.mnt = (struct vfsmount *)vfsmnt;
58369 +
58370 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58371 + get_fs_root(reaper->fs, &root);
58372 +
58373 + br_read_lock(&vfsmount_lock);
58374 + write_seqlock(&rename_lock);
58375 + res = gen_full_path(&path, &root, buf, buflen);
58376 + write_sequnlock(&rename_lock);
58377 + br_read_unlock(&vfsmount_lock);
58378 +
58379 + path_put(&root);
58380 + return res;
58381 +}
58382 +
58383 +static char *
58384 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58385 +{
58386 + char *ret;
58387 + br_read_lock(&vfsmount_lock);
58388 + write_seqlock(&rename_lock);
58389 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58390 + PAGE_SIZE);
58391 + write_sequnlock(&rename_lock);
58392 + br_read_unlock(&vfsmount_lock);
58393 + return ret;
58394 +}
58395 +
58396 +static char *
58397 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58398 +{
58399 + char *ret;
58400 + char *buf;
58401 + int buflen;
58402 +
58403 + br_read_lock(&vfsmount_lock);
58404 + write_seqlock(&rename_lock);
58405 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58406 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58407 + buflen = (int)(ret - buf);
58408 + if (buflen >= 5)
58409 + prepend(&ret, &buflen, "/proc", 5);
58410 + else
58411 + ret = strcpy(buf, "<path too long>");
58412 + write_sequnlock(&rename_lock);
58413 + br_read_unlock(&vfsmount_lock);
58414 + return ret;
58415 +}
58416 +
58417 +char *
58418 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58419 +{
58420 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58421 + PAGE_SIZE);
58422 +}
58423 +
58424 +char *
58425 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58426 +{
58427 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58428 + PAGE_SIZE);
58429 +}
58430 +
58431 +char *
58432 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58433 +{
58434 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58435 + PAGE_SIZE);
58436 +}
58437 +
58438 +char *
58439 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58440 +{
58441 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58442 + PAGE_SIZE);
58443 +}
58444 +
58445 +char *
58446 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58447 +{
58448 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58449 + PAGE_SIZE);
58450 +}
58451 +
58452 +__inline__ __u32
58453 +to_gr_audit(const __u32 reqmode)
58454 +{
58455 + /* masks off auditable permission flags, then shifts them to create
58456 + auditing flags, and adds the special case of append auditing if
58457 + we're requesting write */
58458 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58459 +}
58460 +
58461 +struct acl_subject_label *
58462 +lookup_subject_map(const struct acl_subject_label *userp)
58463 +{
58464 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58465 + struct subject_map *match;
58466 +
58467 + match = subj_map_set.s_hash[index];
58468 +
58469 + while (match && match->user != userp)
58470 + match = match->next;
58471 +
58472 + if (match != NULL)
58473 + return match->kernel;
58474 + else
58475 + return NULL;
58476 +}
58477 +
58478 +static void
58479 +insert_subj_map_entry(struct subject_map *subjmap)
58480 +{
58481 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58482 + struct subject_map **curr;
58483 +
58484 + subjmap->prev = NULL;
58485 +
58486 + curr = &subj_map_set.s_hash[index];
58487 + if (*curr != NULL)
58488 + (*curr)->prev = subjmap;
58489 +
58490 + subjmap->next = *curr;
58491 + *curr = subjmap;
58492 +
58493 + return;
58494 +}
58495 +
58496 +static struct acl_role_label *
58497 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58498 + const gid_t gid)
58499 +{
58500 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58501 + struct acl_role_label *match;
58502 + struct role_allowed_ip *ipp;
58503 + unsigned int x;
58504 + u32 curr_ip = task->signal->curr_ip;
58505 +
58506 + task->signal->saved_ip = curr_ip;
58507 +
58508 + match = acl_role_set.r_hash[index];
58509 +
58510 + while (match) {
58511 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58512 + for (x = 0; x < match->domain_child_num; x++) {
58513 + if (match->domain_children[x] == uid)
58514 + goto found;
58515 + }
58516 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58517 + break;
58518 + match = match->next;
58519 + }
58520 +found:
58521 + if (match == NULL) {
58522 + try_group:
58523 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58524 + match = acl_role_set.r_hash[index];
58525 +
58526 + while (match) {
58527 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58528 + for (x = 0; x < match->domain_child_num; x++) {
58529 + if (match->domain_children[x] == gid)
58530 + goto found2;
58531 + }
58532 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58533 + break;
58534 + match = match->next;
58535 + }
58536 +found2:
58537 + if (match == NULL)
58538 + match = default_role;
58539 + if (match->allowed_ips == NULL)
58540 + return match;
58541 + else {
58542 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58543 + if (likely
58544 + ((ntohl(curr_ip) & ipp->netmask) ==
58545 + (ntohl(ipp->addr) & ipp->netmask)))
58546 + return match;
58547 + }
58548 + match = default_role;
58549 + }
58550 + } else 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 + goto try_group;
58560 + }
58561 +
58562 + return match;
58563 +}
58564 +
58565 +struct acl_subject_label *
58566 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58567 + const struct acl_role_label *role)
58568 +{
58569 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58570 + struct acl_subject_label *match;
58571 +
58572 + match = role->subj_hash[index];
58573 +
58574 + while (match && (match->inode != ino || match->device != dev ||
58575 + (match->mode & GR_DELETED))) {
58576 + match = match->next;
58577 + }
58578 +
58579 + if (match && !(match->mode & GR_DELETED))
58580 + return match;
58581 + else
58582 + return NULL;
58583 +}
58584 +
58585 +struct acl_subject_label *
58586 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58587 + const struct acl_role_label *role)
58588 +{
58589 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58590 + struct acl_subject_label *match;
58591 +
58592 + match = role->subj_hash[index];
58593 +
58594 + while (match && (match->inode != ino || match->device != dev ||
58595 + !(match->mode & GR_DELETED))) {
58596 + match = match->next;
58597 + }
58598 +
58599 + if (match && (match->mode & GR_DELETED))
58600 + return match;
58601 + else
58602 + return NULL;
58603 +}
58604 +
58605 +static struct acl_object_label *
58606 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58607 + const struct acl_subject_label *subj)
58608 +{
58609 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58610 + struct acl_object_label *match;
58611 +
58612 + match = subj->obj_hash[index];
58613 +
58614 + while (match && (match->inode != ino || match->device != dev ||
58615 + (match->mode & GR_DELETED))) {
58616 + match = match->next;
58617 + }
58618 +
58619 + if (match && !(match->mode & GR_DELETED))
58620 + return match;
58621 + else
58622 + return NULL;
58623 +}
58624 +
58625 +static struct acl_object_label *
58626 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58627 + const struct acl_subject_label *subj)
58628 +{
58629 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58630 + struct acl_object_label *match;
58631 +
58632 + match = subj->obj_hash[index];
58633 +
58634 + while (match && (match->inode != ino || match->device != dev ||
58635 + !(match->mode & GR_DELETED))) {
58636 + match = match->next;
58637 + }
58638 +
58639 + if (match && (match->mode & GR_DELETED))
58640 + return match;
58641 +
58642 + match = subj->obj_hash[index];
58643 +
58644 + while (match && (match->inode != ino || match->device != dev ||
58645 + (match->mode & GR_DELETED))) {
58646 + match = match->next;
58647 + }
58648 +
58649 + if (match && !(match->mode & GR_DELETED))
58650 + return match;
58651 + else
58652 + return NULL;
58653 +}
58654 +
58655 +static struct name_entry *
58656 +lookup_name_entry(const char *name)
58657 +{
58658 + unsigned int len = strlen(name);
58659 + unsigned int key = full_name_hash(name, len);
58660 + unsigned int index = key % name_set.n_size;
58661 + struct name_entry *match;
58662 +
58663 + match = name_set.n_hash[index];
58664 +
58665 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58666 + match = match->next;
58667 +
58668 + return match;
58669 +}
58670 +
58671 +static struct name_entry *
58672 +lookup_name_entry_create(const char *name)
58673 +{
58674 + unsigned int len = strlen(name);
58675 + unsigned int key = full_name_hash(name, len);
58676 + unsigned int index = key % name_set.n_size;
58677 + struct name_entry *match;
58678 +
58679 + match = name_set.n_hash[index];
58680 +
58681 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58682 + !match->deleted))
58683 + match = match->next;
58684 +
58685 + if (match && match->deleted)
58686 + return match;
58687 +
58688 + match = name_set.n_hash[index];
58689 +
58690 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58691 + match->deleted))
58692 + match = match->next;
58693 +
58694 + if (match && !match->deleted)
58695 + return match;
58696 + else
58697 + return NULL;
58698 +}
58699 +
58700 +static struct inodev_entry *
58701 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58702 +{
58703 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58704 + struct inodev_entry *match;
58705 +
58706 + match = inodev_set.i_hash[index];
58707 +
58708 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58709 + match = match->next;
58710 +
58711 + return match;
58712 +}
58713 +
58714 +static void
58715 +insert_inodev_entry(struct inodev_entry *entry)
58716 +{
58717 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58718 + inodev_set.i_size);
58719 + struct inodev_entry **curr;
58720 +
58721 + entry->prev = NULL;
58722 +
58723 + curr = &inodev_set.i_hash[index];
58724 + if (*curr != NULL)
58725 + (*curr)->prev = entry;
58726 +
58727 + entry->next = *curr;
58728 + *curr = entry;
58729 +
58730 + return;
58731 +}
58732 +
58733 +static void
58734 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58735 +{
58736 + unsigned int index =
58737 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58738 + struct acl_role_label **curr;
58739 + struct acl_role_label *tmp, *tmp2;
58740 +
58741 + curr = &acl_role_set.r_hash[index];
58742 +
58743 + /* simple case, slot is empty, just set it to our role */
58744 + if (*curr == NULL) {
58745 + *curr = role;
58746 + } else {
58747 + /* example:
58748 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58749 + 2 -> 3
58750 + */
58751 + /* first check to see if we can already be reached via this slot */
58752 + tmp = *curr;
58753 + while (tmp && tmp != role)
58754 + tmp = tmp->next;
58755 + if (tmp == role) {
58756 + /* we don't need to add ourselves to this slot's chain */
58757 + return;
58758 + }
58759 + /* we need to add ourselves to this chain, two cases */
58760 + if (role->next == NULL) {
58761 + /* simple case, append the current chain to our role */
58762 + role->next = *curr;
58763 + *curr = role;
58764 + } else {
58765 + /* 1 -> 2 -> 3 -> 4
58766 + 2 -> 3 -> 4
58767 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58768 + */
58769 + /* trickier case: walk our role's chain until we find
58770 + the role for the start of the current slot's chain */
58771 + tmp = role;
58772 + tmp2 = *curr;
58773 + while (tmp->next && tmp->next != tmp2)
58774 + tmp = tmp->next;
58775 + if (tmp->next == tmp2) {
58776 + /* from example above, we found 3, so just
58777 + replace this slot's chain with ours */
58778 + *curr = role;
58779 + } else {
58780 + /* we didn't find a subset of our role's chain
58781 + in the current slot's chain, so append their
58782 + chain to ours, and set us as the first role in
58783 + the slot's chain
58784 +
58785 + we could fold this case with the case above,
58786 + but making it explicit for clarity
58787 + */
58788 + tmp->next = tmp2;
58789 + *curr = role;
58790 + }
58791 + }
58792 + }
58793 +
58794 + return;
58795 +}
58796 +
58797 +static void
58798 +insert_acl_role_label(struct acl_role_label *role)
58799 +{
58800 + int i;
58801 +
58802 + if (role_list == NULL) {
58803 + role_list = role;
58804 + role->prev = NULL;
58805 + } else {
58806 + role->prev = role_list;
58807 + role_list = role;
58808 + }
58809 +
58810 + /* used for hash chains */
58811 + role->next = NULL;
58812 +
58813 + if (role->roletype & GR_ROLE_DOMAIN) {
58814 + for (i = 0; i < role->domain_child_num; i++)
58815 + __insert_acl_role_label(role, role->domain_children[i]);
58816 + } else
58817 + __insert_acl_role_label(role, role->uidgid);
58818 +}
58819 +
58820 +static int
58821 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58822 +{
58823 + struct name_entry **curr, *nentry;
58824 + struct inodev_entry *ientry;
58825 + unsigned int len = strlen(name);
58826 + unsigned int key = full_name_hash(name, len);
58827 + unsigned int index = key % name_set.n_size;
58828 +
58829 + curr = &name_set.n_hash[index];
58830 +
58831 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58832 + curr = &((*curr)->next);
58833 +
58834 + if (*curr != NULL)
58835 + return 1;
58836 +
58837 + nentry = acl_alloc(sizeof (struct name_entry));
58838 + if (nentry == NULL)
58839 + return 0;
58840 + ientry = acl_alloc(sizeof (struct inodev_entry));
58841 + if (ientry == NULL)
58842 + return 0;
58843 + ientry->nentry = nentry;
58844 +
58845 + nentry->key = key;
58846 + nentry->name = name;
58847 + nentry->inode = inode;
58848 + nentry->device = device;
58849 + nentry->len = len;
58850 + nentry->deleted = deleted;
58851 +
58852 + nentry->prev = NULL;
58853 + curr = &name_set.n_hash[index];
58854 + if (*curr != NULL)
58855 + (*curr)->prev = nentry;
58856 + nentry->next = *curr;
58857 + *curr = nentry;
58858 +
58859 + /* insert us into the table searchable by inode/dev */
58860 + insert_inodev_entry(ientry);
58861 +
58862 + return 1;
58863 +}
58864 +
58865 +static void
58866 +insert_acl_obj_label(struct acl_object_label *obj,
58867 + struct acl_subject_label *subj)
58868 +{
58869 + unsigned int index =
58870 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58871 + struct acl_object_label **curr;
58872 +
58873 +
58874 + obj->prev = NULL;
58875 +
58876 + curr = &subj->obj_hash[index];
58877 + if (*curr != NULL)
58878 + (*curr)->prev = obj;
58879 +
58880 + obj->next = *curr;
58881 + *curr = obj;
58882 +
58883 + return;
58884 +}
58885 +
58886 +static void
58887 +insert_acl_subj_label(struct acl_subject_label *obj,
58888 + struct acl_role_label *role)
58889 +{
58890 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58891 + struct acl_subject_label **curr;
58892 +
58893 + obj->prev = NULL;
58894 +
58895 + curr = &role->subj_hash[index];
58896 + if (*curr != NULL)
58897 + (*curr)->prev = obj;
58898 +
58899 + obj->next = *curr;
58900 + *curr = obj;
58901 +
58902 + return;
58903 +}
58904 +
58905 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58906 +
58907 +static void *
58908 +create_table(__u32 * len, int elementsize)
58909 +{
58910 + unsigned int table_sizes[] = {
58911 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58912 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58913 + 4194301, 8388593, 16777213, 33554393, 67108859
58914 + };
58915 + void *newtable = NULL;
58916 + unsigned int pwr = 0;
58917 +
58918 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58919 + table_sizes[pwr] <= *len)
58920 + pwr++;
58921 +
58922 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58923 + return newtable;
58924 +
58925 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58926 + newtable =
58927 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58928 + else
58929 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58930 +
58931 + *len = table_sizes[pwr];
58932 +
58933 + return newtable;
58934 +}
58935 +
58936 +static int
58937 +init_variables(const struct gr_arg *arg)
58938 +{
58939 + struct task_struct *reaper = init_pid_ns.child_reaper;
58940 + unsigned int stacksize;
58941 +
58942 + subj_map_set.s_size = arg->role_db.num_subjects;
58943 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58944 + name_set.n_size = arg->role_db.num_objects;
58945 + inodev_set.i_size = arg->role_db.num_objects;
58946 +
58947 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58948 + !name_set.n_size || !inodev_set.i_size)
58949 + return 1;
58950 +
58951 + if (!gr_init_uidset())
58952 + return 1;
58953 +
58954 + /* set up the stack that holds allocation info */
58955 +
58956 + stacksize = arg->role_db.num_pointers + 5;
58957 +
58958 + if (!acl_alloc_stack_init(stacksize))
58959 + return 1;
58960 +
58961 + /* grab reference for the real root dentry and vfsmount */
58962 + get_fs_root(reaper->fs, &real_root);
58963 +
58964 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58965 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58966 +#endif
58967 +
58968 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58969 + if (fakefs_obj_rw == NULL)
58970 + return 1;
58971 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58972 +
58973 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58974 + if (fakefs_obj_rwx == NULL)
58975 + return 1;
58976 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58977 +
58978 + subj_map_set.s_hash =
58979 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58980 + acl_role_set.r_hash =
58981 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58982 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58983 + inodev_set.i_hash =
58984 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58985 +
58986 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58987 + !name_set.n_hash || !inodev_set.i_hash)
58988 + return 1;
58989 +
58990 + memset(subj_map_set.s_hash, 0,
58991 + sizeof(struct subject_map *) * subj_map_set.s_size);
58992 + memset(acl_role_set.r_hash, 0,
58993 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58994 + memset(name_set.n_hash, 0,
58995 + sizeof (struct name_entry *) * name_set.n_size);
58996 + memset(inodev_set.i_hash, 0,
58997 + sizeof (struct inodev_entry *) * inodev_set.i_size);
58998 +
58999 + return 0;
59000 +}
59001 +
59002 +/* free information not needed after startup
59003 + currently contains user->kernel pointer mappings for subjects
59004 +*/
59005 +
59006 +static void
59007 +free_init_variables(void)
59008 +{
59009 + __u32 i;
59010 +
59011 + if (subj_map_set.s_hash) {
59012 + for (i = 0; i < subj_map_set.s_size; i++) {
59013 + if (subj_map_set.s_hash[i]) {
59014 + kfree(subj_map_set.s_hash[i]);
59015 + subj_map_set.s_hash[i] = NULL;
59016 + }
59017 + }
59018 +
59019 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59020 + PAGE_SIZE)
59021 + kfree(subj_map_set.s_hash);
59022 + else
59023 + vfree(subj_map_set.s_hash);
59024 + }
59025 +
59026 + return;
59027 +}
59028 +
59029 +static void
59030 +free_variables(void)
59031 +{
59032 + struct acl_subject_label *s;
59033 + struct acl_role_label *r;
59034 + struct task_struct *task, *task2;
59035 + unsigned int x;
59036 +
59037 + gr_clear_learn_entries();
59038 +
59039 + read_lock(&tasklist_lock);
59040 + do_each_thread(task2, task) {
59041 + task->acl_sp_role = 0;
59042 + task->acl_role_id = 0;
59043 + task->acl = NULL;
59044 + task->role = NULL;
59045 + } while_each_thread(task2, task);
59046 + read_unlock(&tasklist_lock);
59047 +
59048 + /* release the reference to the real root dentry and vfsmount */
59049 + path_put(&real_root);
59050 + memset(&real_root, 0, sizeof(real_root));
59051 +
59052 + /* free all object hash tables */
59053 +
59054 + FOR_EACH_ROLE_START(r)
59055 + if (r->subj_hash == NULL)
59056 + goto next_role;
59057 + FOR_EACH_SUBJECT_START(r, s, x)
59058 + if (s->obj_hash == NULL)
59059 + break;
59060 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59061 + kfree(s->obj_hash);
59062 + else
59063 + vfree(s->obj_hash);
59064 + FOR_EACH_SUBJECT_END(s, x)
59065 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59066 + if (s->obj_hash == NULL)
59067 + break;
59068 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59069 + kfree(s->obj_hash);
59070 + else
59071 + vfree(s->obj_hash);
59072 + FOR_EACH_NESTED_SUBJECT_END(s)
59073 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59074 + kfree(r->subj_hash);
59075 + else
59076 + vfree(r->subj_hash);
59077 + r->subj_hash = NULL;
59078 +next_role:
59079 + FOR_EACH_ROLE_END(r)
59080 +
59081 + acl_free_all();
59082 +
59083 + if (acl_role_set.r_hash) {
59084 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59085 + PAGE_SIZE)
59086 + kfree(acl_role_set.r_hash);
59087 + else
59088 + vfree(acl_role_set.r_hash);
59089 + }
59090 + if (name_set.n_hash) {
59091 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59092 + PAGE_SIZE)
59093 + kfree(name_set.n_hash);
59094 + else
59095 + vfree(name_set.n_hash);
59096 + }
59097 +
59098 + if (inodev_set.i_hash) {
59099 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59100 + PAGE_SIZE)
59101 + kfree(inodev_set.i_hash);
59102 + else
59103 + vfree(inodev_set.i_hash);
59104 + }
59105 +
59106 + gr_free_uidset();
59107 +
59108 + memset(&name_set, 0, sizeof (struct name_db));
59109 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59110 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59111 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59112 +
59113 + default_role = NULL;
59114 + kernel_role = NULL;
59115 + role_list = NULL;
59116 +
59117 + return;
59118 +}
59119 +
59120 +static __u32
59121 +count_user_objs(struct acl_object_label *userp)
59122 +{
59123 + struct acl_object_label o_tmp;
59124 + __u32 num = 0;
59125 +
59126 + while (userp) {
59127 + if (copy_from_user(&o_tmp, userp,
59128 + sizeof (struct acl_object_label)))
59129 + break;
59130 +
59131 + userp = o_tmp.prev;
59132 + num++;
59133 + }
59134 +
59135 + return num;
59136 +}
59137 +
59138 +static struct acl_subject_label *
59139 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59140 +
59141 +static int
59142 +copy_user_glob(struct acl_object_label *obj)
59143 +{
59144 + struct acl_object_label *g_tmp, **guser;
59145 + unsigned int len;
59146 + char *tmp;
59147 +
59148 + if (obj->globbed == NULL)
59149 + return 0;
59150 +
59151 + guser = &obj->globbed;
59152 + while (*guser) {
59153 + g_tmp = (struct acl_object_label *)
59154 + acl_alloc(sizeof (struct acl_object_label));
59155 + if (g_tmp == NULL)
59156 + return -ENOMEM;
59157 +
59158 + if (copy_from_user(g_tmp, *guser,
59159 + sizeof (struct acl_object_label)))
59160 + return -EFAULT;
59161 +
59162 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59163 +
59164 + if (!len || len >= PATH_MAX)
59165 + return -EINVAL;
59166 +
59167 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59168 + return -ENOMEM;
59169 +
59170 + if (copy_from_user(tmp, g_tmp->filename, len))
59171 + return -EFAULT;
59172 + tmp[len-1] = '\0';
59173 + g_tmp->filename = tmp;
59174 +
59175 + *guser = g_tmp;
59176 + guser = &(g_tmp->next);
59177 + }
59178 +
59179 + return 0;
59180 +}
59181 +
59182 +static int
59183 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59184 + struct acl_role_label *role)
59185 +{
59186 + struct acl_object_label *o_tmp;
59187 + unsigned int len;
59188 + int ret;
59189 + char *tmp;
59190 +
59191 + while (userp) {
59192 + if ((o_tmp = (struct acl_object_label *)
59193 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59194 + return -ENOMEM;
59195 +
59196 + if (copy_from_user(o_tmp, userp,
59197 + sizeof (struct acl_object_label)))
59198 + return -EFAULT;
59199 +
59200 + userp = o_tmp->prev;
59201 +
59202 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59203 +
59204 + if (!len || len >= PATH_MAX)
59205 + return -EINVAL;
59206 +
59207 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59208 + return -ENOMEM;
59209 +
59210 + if (copy_from_user(tmp, o_tmp->filename, len))
59211 + return -EFAULT;
59212 + tmp[len-1] = '\0';
59213 + o_tmp->filename = tmp;
59214 +
59215 + insert_acl_obj_label(o_tmp, subj);
59216 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59217 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59218 + return -ENOMEM;
59219 +
59220 + ret = copy_user_glob(o_tmp);
59221 + if (ret)
59222 + return ret;
59223 +
59224 + if (o_tmp->nested) {
59225 + int already_copied;
59226 +
59227 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59228 + if (IS_ERR(o_tmp->nested))
59229 + return PTR_ERR(o_tmp->nested);
59230 +
59231 + /* insert into nested subject list if we haven't copied this one yet
59232 + to prevent duplicate entries */
59233 + if (!already_copied) {
59234 + o_tmp->nested->next = role->hash->first;
59235 + role->hash->first = o_tmp->nested;
59236 + }
59237 + }
59238 + }
59239 +
59240 + return 0;
59241 +}
59242 +
59243 +static __u32
59244 +count_user_subjs(struct acl_subject_label *userp)
59245 +{
59246 + struct acl_subject_label s_tmp;
59247 + __u32 num = 0;
59248 +
59249 + while (userp) {
59250 + if (copy_from_user(&s_tmp, userp,
59251 + sizeof (struct acl_subject_label)))
59252 + break;
59253 +
59254 + userp = s_tmp.prev;
59255 + }
59256 +
59257 + return num;
59258 +}
59259 +
59260 +static int
59261 +copy_user_allowedips(struct acl_role_label *rolep)
59262 +{
59263 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59264 +
59265 + ruserip = rolep->allowed_ips;
59266 +
59267 + while (ruserip) {
59268 + rlast = rtmp;
59269 +
59270 + if ((rtmp = (struct role_allowed_ip *)
59271 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59272 + return -ENOMEM;
59273 +
59274 + if (copy_from_user(rtmp, ruserip,
59275 + sizeof (struct role_allowed_ip)))
59276 + return -EFAULT;
59277 +
59278 + ruserip = rtmp->prev;
59279 +
59280 + if (!rlast) {
59281 + rtmp->prev = NULL;
59282 + rolep->allowed_ips = rtmp;
59283 + } else {
59284 + rlast->next = rtmp;
59285 + rtmp->prev = rlast;
59286 + }
59287 +
59288 + if (!ruserip)
59289 + rtmp->next = NULL;
59290 + }
59291 +
59292 + return 0;
59293 +}
59294 +
59295 +static int
59296 +copy_user_transitions(struct acl_role_label *rolep)
59297 +{
59298 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59299 +
59300 + unsigned int len;
59301 + char *tmp;
59302 +
59303 + rusertp = rolep->transitions;
59304 +
59305 + while (rusertp) {
59306 + rlast = rtmp;
59307 +
59308 + if ((rtmp = (struct role_transition *)
59309 + acl_alloc(sizeof (struct role_transition))) == NULL)
59310 + return -ENOMEM;
59311 +
59312 + if (copy_from_user(rtmp, rusertp,
59313 + sizeof (struct role_transition)))
59314 + return -EFAULT;
59315 +
59316 + rusertp = rtmp->prev;
59317 +
59318 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59319 +
59320 + if (!len || len >= GR_SPROLE_LEN)
59321 + return -EINVAL;
59322 +
59323 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59324 + return -ENOMEM;
59325 +
59326 + if (copy_from_user(tmp, rtmp->rolename, len))
59327 + return -EFAULT;
59328 + tmp[len-1] = '\0';
59329 + rtmp->rolename = tmp;
59330 +
59331 + if (!rlast) {
59332 + rtmp->prev = NULL;
59333 + rolep->transitions = rtmp;
59334 + } else {
59335 + rlast->next = rtmp;
59336 + rtmp->prev = rlast;
59337 + }
59338 +
59339 + if (!rusertp)
59340 + rtmp->next = NULL;
59341 + }
59342 +
59343 + return 0;
59344 +}
59345 +
59346 +static struct acl_subject_label *
59347 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59348 +{
59349 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59350 + unsigned int len;
59351 + char *tmp;
59352 + __u32 num_objs;
59353 + struct acl_ip_label **i_tmp, *i_utmp2;
59354 + struct gr_hash_struct ghash;
59355 + struct subject_map *subjmap;
59356 + unsigned int i_num;
59357 + int err;
59358 +
59359 + if (already_copied != NULL)
59360 + *already_copied = 0;
59361 +
59362 + s_tmp = lookup_subject_map(userp);
59363 +
59364 + /* we've already copied this subject into the kernel, just return
59365 + the reference to it, and don't copy it over again
59366 + */
59367 + if (s_tmp) {
59368 + if (already_copied != NULL)
59369 + *already_copied = 1;
59370 + return(s_tmp);
59371 + }
59372 +
59373 + if ((s_tmp = (struct acl_subject_label *)
59374 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59375 + return ERR_PTR(-ENOMEM);
59376 +
59377 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59378 + if (subjmap == NULL)
59379 + return ERR_PTR(-ENOMEM);
59380 +
59381 + subjmap->user = userp;
59382 + subjmap->kernel = s_tmp;
59383 + insert_subj_map_entry(subjmap);
59384 +
59385 + if (copy_from_user(s_tmp, userp,
59386 + sizeof (struct acl_subject_label)))
59387 + return ERR_PTR(-EFAULT);
59388 +
59389 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59390 +
59391 + if (!len || len >= PATH_MAX)
59392 + return ERR_PTR(-EINVAL);
59393 +
59394 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59395 + return ERR_PTR(-ENOMEM);
59396 +
59397 + if (copy_from_user(tmp, s_tmp->filename, len))
59398 + return ERR_PTR(-EFAULT);
59399 + tmp[len-1] = '\0';
59400 + s_tmp->filename = tmp;
59401 +
59402 + if (!strcmp(s_tmp->filename, "/"))
59403 + role->root_label = s_tmp;
59404 +
59405 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59406 + return ERR_PTR(-EFAULT);
59407 +
59408 + /* copy user and group transition tables */
59409 +
59410 + if (s_tmp->user_trans_num) {
59411 + uid_t *uidlist;
59412 +
59413 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59414 + if (uidlist == NULL)
59415 + return ERR_PTR(-ENOMEM);
59416 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59417 + return ERR_PTR(-EFAULT);
59418 +
59419 + s_tmp->user_transitions = uidlist;
59420 + }
59421 +
59422 + if (s_tmp->group_trans_num) {
59423 + gid_t *gidlist;
59424 +
59425 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59426 + if (gidlist == NULL)
59427 + return ERR_PTR(-ENOMEM);
59428 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59429 + return ERR_PTR(-EFAULT);
59430 +
59431 + s_tmp->group_transitions = gidlist;
59432 + }
59433 +
59434 + /* set up object hash table */
59435 + num_objs = count_user_objs(ghash.first);
59436 +
59437 + s_tmp->obj_hash_size = num_objs;
59438 + s_tmp->obj_hash =
59439 + (struct acl_object_label **)
59440 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59441 +
59442 + if (!s_tmp->obj_hash)
59443 + return ERR_PTR(-ENOMEM);
59444 +
59445 + memset(s_tmp->obj_hash, 0,
59446 + s_tmp->obj_hash_size *
59447 + sizeof (struct acl_object_label *));
59448 +
59449 + /* add in objects */
59450 + err = copy_user_objs(ghash.first, s_tmp, role);
59451 +
59452 + if (err)
59453 + return ERR_PTR(err);
59454 +
59455 + /* set pointer for parent subject */
59456 + if (s_tmp->parent_subject) {
59457 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59458 +
59459 + if (IS_ERR(s_tmp2))
59460 + return s_tmp2;
59461 +
59462 + s_tmp->parent_subject = s_tmp2;
59463 + }
59464 +
59465 + /* add in ip acls */
59466 +
59467 + if (!s_tmp->ip_num) {
59468 + s_tmp->ips = NULL;
59469 + goto insert;
59470 + }
59471 +
59472 + i_tmp =
59473 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59474 + sizeof (struct acl_ip_label *));
59475 +
59476 + if (!i_tmp)
59477 + return ERR_PTR(-ENOMEM);
59478 +
59479 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59480 + *(i_tmp + i_num) =
59481 + (struct acl_ip_label *)
59482 + acl_alloc(sizeof (struct acl_ip_label));
59483 + if (!*(i_tmp + i_num))
59484 + return ERR_PTR(-ENOMEM);
59485 +
59486 + if (copy_from_user
59487 + (&i_utmp2, s_tmp->ips + i_num,
59488 + sizeof (struct acl_ip_label *)))
59489 + return ERR_PTR(-EFAULT);
59490 +
59491 + if (copy_from_user
59492 + (*(i_tmp + i_num), i_utmp2,
59493 + sizeof (struct acl_ip_label)))
59494 + return ERR_PTR(-EFAULT);
59495 +
59496 + if ((*(i_tmp + i_num))->iface == NULL)
59497 + continue;
59498 +
59499 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59500 + if (!len || len >= IFNAMSIZ)
59501 + return ERR_PTR(-EINVAL);
59502 + tmp = acl_alloc(len);
59503 + if (tmp == NULL)
59504 + return ERR_PTR(-ENOMEM);
59505 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59506 + return ERR_PTR(-EFAULT);
59507 + (*(i_tmp + i_num))->iface = tmp;
59508 + }
59509 +
59510 + s_tmp->ips = i_tmp;
59511 +
59512 +insert:
59513 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59514 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59515 + return ERR_PTR(-ENOMEM);
59516 +
59517 + return s_tmp;
59518 +}
59519 +
59520 +static int
59521 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59522 +{
59523 + struct acl_subject_label s_pre;
59524 + struct acl_subject_label * ret;
59525 + int err;
59526 +
59527 + while (userp) {
59528 + if (copy_from_user(&s_pre, userp,
59529 + sizeof (struct acl_subject_label)))
59530 + return -EFAULT;
59531 +
59532 + ret = do_copy_user_subj(userp, role, NULL);
59533 +
59534 + err = PTR_ERR(ret);
59535 + if (IS_ERR(ret))
59536 + return err;
59537 +
59538 + insert_acl_subj_label(ret, role);
59539 +
59540 + userp = s_pre.prev;
59541 + }
59542 +
59543 + return 0;
59544 +}
59545 +
59546 +static int
59547 +copy_user_acl(struct gr_arg *arg)
59548 +{
59549 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59550 + struct acl_subject_label *subj_list;
59551 + struct sprole_pw *sptmp;
59552 + struct gr_hash_struct *ghash;
59553 + uid_t *domainlist;
59554 + unsigned int r_num;
59555 + unsigned int len;
59556 + char *tmp;
59557 + int err = 0;
59558 + __u16 i;
59559 + __u32 num_subjs;
59560 +
59561 + /* we need a default and kernel role */
59562 + if (arg->role_db.num_roles < 2)
59563 + return -EINVAL;
59564 +
59565 + /* copy special role authentication info from userspace */
59566 +
59567 + num_sprole_pws = arg->num_sprole_pws;
59568 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59569 +
59570 + if (!acl_special_roles && num_sprole_pws)
59571 + return -ENOMEM;
59572 +
59573 + for (i = 0; i < num_sprole_pws; i++) {
59574 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59575 + if (!sptmp)
59576 + return -ENOMEM;
59577 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59578 + sizeof (struct sprole_pw)))
59579 + return -EFAULT;
59580 +
59581 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59582 +
59583 + if (!len || len >= GR_SPROLE_LEN)
59584 + return -EINVAL;
59585 +
59586 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59587 + return -ENOMEM;
59588 +
59589 + if (copy_from_user(tmp, sptmp->rolename, len))
59590 + return -EFAULT;
59591 +
59592 + tmp[len-1] = '\0';
59593 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59594 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59595 +#endif
59596 + sptmp->rolename = tmp;
59597 + acl_special_roles[i] = sptmp;
59598 + }
59599 +
59600 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59601 +
59602 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59603 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59604 +
59605 + if (!r_tmp)
59606 + return -ENOMEM;
59607 +
59608 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59609 + sizeof (struct acl_role_label *)))
59610 + return -EFAULT;
59611 +
59612 + if (copy_from_user(r_tmp, r_utmp2,
59613 + sizeof (struct acl_role_label)))
59614 + return -EFAULT;
59615 +
59616 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59617 +
59618 + if (!len || len >= PATH_MAX)
59619 + return -EINVAL;
59620 +
59621 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59622 + return -ENOMEM;
59623 +
59624 + if (copy_from_user(tmp, r_tmp->rolename, len))
59625 + return -EFAULT;
59626 +
59627 + tmp[len-1] = '\0';
59628 + r_tmp->rolename = tmp;
59629 +
59630 + if (!strcmp(r_tmp->rolename, "default")
59631 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59632 + default_role = r_tmp;
59633 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59634 + kernel_role = r_tmp;
59635 + }
59636 +
59637 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59638 + return -ENOMEM;
59639 +
59640 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59641 + return -EFAULT;
59642 +
59643 + r_tmp->hash = ghash;
59644 +
59645 + num_subjs = count_user_subjs(r_tmp->hash->first);
59646 +
59647 + r_tmp->subj_hash_size = num_subjs;
59648 + r_tmp->subj_hash =
59649 + (struct acl_subject_label **)
59650 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59651 +
59652 + if (!r_tmp->subj_hash)
59653 + return -ENOMEM;
59654 +
59655 + err = copy_user_allowedips(r_tmp);
59656 + if (err)
59657 + return err;
59658 +
59659 + /* copy domain info */
59660 + if (r_tmp->domain_children != NULL) {
59661 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59662 + if (domainlist == NULL)
59663 + return -ENOMEM;
59664 +
59665 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59666 + return -EFAULT;
59667 +
59668 + r_tmp->domain_children = domainlist;
59669 + }
59670 +
59671 + err = copy_user_transitions(r_tmp);
59672 + if (err)
59673 + return err;
59674 +
59675 + memset(r_tmp->subj_hash, 0,
59676 + r_tmp->subj_hash_size *
59677 + sizeof (struct acl_subject_label *));
59678 +
59679 + /* acquire the list of subjects, then NULL out
59680 + the list prior to parsing the subjects for this role,
59681 + as during this parsing the list is replaced with a list
59682 + of *nested* subjects for the role
59683 + */
59684 + subj_list = r_tmp->hash->first;
59685 +
59686 + /* set nested subject list to null */
59687 + r_tmp->hash->first = NULL;
59688 +
59689 + err = copy_user_subjs(subj_list, r_tmp);
59690 +
59691 + if (err)
59692 + return err;
59693 +
59694 + insert_acl_role_label(r_tmp);
59695 + }
59696 +
59697 + if (default_role == NULL || kernel_role == NULL)
59698 + return -EINVAL;
59699 +
59700 + return err;
59701 +}
59702 +
59703 +static int
59704 +gracl_init(struct gr_arg *args)
59705 +{
59706 + int error = 0;
59707 +
59708 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59709 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59710 +
59711 + if (init_variables(args)) {
59712 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59713 + error = -ENOMEM;
59714 + free_variables();
59715 + goto out;
59716 + }
59717 +
59718 + error = copy_user_acl(args);
59719 + free_init_variables();
59720 + if (error) {
59721 + free_variables();
59722 + goto out;
59723 + }
59724 +
59725 + if ((error = gr_set_acls(0))) {
59726 + free_variables();
59727 + goto out;
59728 + }
59729 +
59730 + pax_open_kernel();
59731 + gr_status |= GR_READY;
59732 + pax_close_kernel();
59733 +
59734 + out:
59735 + return error;
59736 +}
59737 +
59738 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59739 +
59740 +static int
59741 +glob_match(const char *p, const char *n)
59742 +{
59743 + char c;
59744 +
59745 + while ((c = *p++) != '\0') {
59746 + switch (c) {
59747 + case '?':
59748 + if (*n == '\0')
59749 + return 1;
59750 + else if (*n == '/')
59751 + return 1;
59752 + break;
59753 + case '\\':
59754 + if (*n != c)
59755 + return 1;
59756 + break;
59757 + case '*':
59758 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59759 + if (*n == '/')
59760 + return 1;
59761 + else if (c == '?') {
59762 + if (*n == '\0')
59763 + return 1;
59764 + else
59765 + ++n;
59766 + }
59767 + }
59768 + if (c == '\0') {
59769 + return 0;
59770 + } else {
59771 + const char *endp;
59772 +
59773 + if ((endp = strchr(n, '/')) == NULL)
59774 + endp = n + strlen(n);
59775 +
59776 + if (c == '[') {
59777 + for (--p; n < endp; ++n)
59778 + if (!glob_match(p, n))
59779 + return 0;
59780 + } else if (c == '/') {
59781 + while (*n != '\0' && *n != '/')
59782 + ++n;
59783 + if (*n == '/' && !glob_match(p, n + 1))
59784 + return 0;
59785 + } else {
59786 + for (--p; n < endp; ++n)
59787 + if (*n == c && !glob_match(p, n))
59788 + return 0;
59789 + }
59790 +
59791 + return 1;
59792 + }
59793 + case '[':
59794 + {
59795 + int not;
59796 + char cold;
59797 +
59798 + if (*n == '\0' || *n == '/')
59799 + return 1;
59800 +
59801 + not = (*p == '!' || *p == '^');
59802 + if (not)
59803 + ++p;
59804 +
59805 + c = *p++;
59806 + for (;;) {
59807 + unsigned char fn = (unsigned char)*n;
59808 +
59809 + if (c == '\0')
59810 + return 1;
59811 + else {
59812 + if (c == fn)
59813 + goto matched;
59814 + cold = c;
59815 + c = *p++;
59816 +
59817 + if (c == '-' && *p != ']') {
59818 + unsigned char cend = *p++;
59819 +
59820 + if (cend == '\0')
59821 + return 1;
59822 +
59823 + if (cold <= fn && fn <= cend)
59824 + goto matched;
59825 +
59826 + c = *p++;
59827 + }
59828 + }
59829 +
59830 + if (c == ']')
59831 + break;
59832 + }
59833 + if (!not)
59834 + return 1;
59835 + break;
59836 + matched:
59837 + while (c != ']') {
59838 + if (c == '\0')
59839 + return 1;
59840 +
59841 + c = *p++;
59842 + }
59843 + if (not)
59844 + return 1;
59845 + }
59846 + break;
59847 + default:
59848 + if (c != *n)
59849 + return 1;
59850 + }
59851 +
59852 + ++n;
59853 + }
59854 +
59855 + if (*n == '\0')
59856 + return 0;
59857 +
59858 + if (*n == '/')
59859 + return 0;
59860 +
59861 + return 1;
59862 +}
59863 +
59864 +static struct acl_object_label *
59865 +chk_glob_label(struct acl_object_label *globbed,
59866 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59867 +{
59868 + struct acl_object_label *tmp;
59869 +
59870 + if (*path == NULL)
59871 + *path = gr_to_filename_nolock(dentry, mnt);
59872 +
59873 + tmp = globbed;
59874 +
59875 + while (tmp) {
59876 + if (!glob_match(tmp->filename, *path))
59877 + return tmp;
59878 + tmp = tmp->next;
59879 + }
59880 +
59881 + return NULL;
59882 +}
59883 +
59884 +static struct acl_object_label *
59885 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59886 + const ino_t curr_ino, const dev_t curr_dev,
59887 + const struct acl_subject_label *subj, char **path, const int checkglob)
59888 +{
59889 + struct acl_subject_label *tmpsubj;
59890 + struct acl_object_label *retval;
59891 + struct acl_object_label *retval2;
59892 +
59893 + tmpsubj = (struct acl_subject_label *) subj;
59894 + read_lock(&gr_inode_lock);
59895 + do {
59896 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59897 + if (retval) {
59898 + if (checkglob && retval->globbed) {
59899 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59900 + if (retval2)
59901 + retval = retval2;
59902 + }
59903 + break;
59904 + }
59905 + } while ((tmpsubj = tmpsubj->parent_subject));
59906 + read_unlock(&gr_inode_lock);
59907 +
59908 + return retval;
59909 +}
59910 +
59911 +static __inline__ struct acl_object_label *
59912 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59913 + struct dentry *curr_dentry,
59914 + const struct acl_subject_label *subj, char **path, const int checkglob)
59915 +{
59916 + int newglob = checkglob;
59917 + ino_t inode;
59918 + dev_t device;
59919 +
59920 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59921 + as we don't want a / * rule to match instead of the / object
59922 + don't do this for create lookups that call this function though, since they're looking up
59923 + on the parent and thus need globbing checks on all paths
59924 + */
59925 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59926 + newglob = GR_NO_GLOB;
59927 +
59928 + spin_lock(&curr_dentry->d_lock);
59929 + inode = curr_dentry->d_inode->i_ino;
59930 + device = __get_dev(curr_dentry);
59931 + spin_unlock(&curr_dentry->d_lock);
59932 +
59933 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59934 +}
59935 +
59936 +#ifdef CONFIG_HUGETLBFS
59937 +static inline bool
59938 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59939 +{
59940 + int i;
59941 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59942 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59943 + return true;
59944 + }
59945 +
59946 + return false;
59947 +}
59948 +#endif
59949 +
59950 +static struct acl_object_label *
59951 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59952 + const struct acl_subject_label *subj, char *path, const int checkglob)
59953 +{
59954 + struct dentry *dentry = (struct dentry *) l_dentry;
59955 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59956 + struct mount *real_mnt = real_mount(mnt);
59957 + struct acl_object_label *retval;
59958 + struct dentry *parent;
59959 +
59960 + br_read_lock(&vfsmount_lock);
59961 + write_seqlock(&rename_lock);
59962 +
59963 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59964 +#ifdef CONFIG_NET
59965 + mnt == sock_mnt ||
59966 +#endif
59967 +#ifdef CONFIG_HUGETLBFS
59968 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59969 +#endif
59970 + /* ignore Eric Biederman */
59971 + IS_PRIVATE(l_dentry->d_inode))) {
59972 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59973 + goto out;
59974 + }
59975 +
59976 + for (;;) {
59977 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59978 + break;
59979 +
59980 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59981 + if (!mnt_has_parent(real_mnt))
59982 + break;
59983 +
59984 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59985 + if (retval != NULL)
59986 + goto out;
59987 +
59988 + dentry = real_mnt->mnt_mountpoint;
59989 + real_mnt = real_mnt->mnt_parent;
59990 + mnt = &real_mnt->mnt;
59991 + continue;
59992 + }
59993 +
59994 + parent = dentry->d_parent;
59995 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59996 + if (retval != NULL)
59997 + goto out;
59998 +
59999 + dentry = parent;
60000 + }
60001 +
60002 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60003 +
60004 + /* real_root is pinned so we don't have to hold a reference */
60005 + if (retval == NULL)
60006 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60007 +out:
60008 + write_sequnlock(&rename_lock);
60009 + br_read_unlock(&vfsmount_lock);
60010 +
60011 + BUG_ON(retval == NULL);
60012 +
60013 + return retval;
60014 +}
60015 +
60016 +static __inline__ struct acl_object_label *
60017 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60018 + const struct acl_subject_label *subj)
60019 +{
60020 + char *path = NULL;
60021 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60022 +}
60023 +
60024 +static __inline__ struct acl_object_label *
60025 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60026 + const struct acl_subject_label *subj)
60027 +{
60028 + char *path = NULL;
60029 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60030 +}
60031 +
60032 +static __inline__ struct acl_object_label *
60033 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60034 + const struct acl_subject_label *subj, char *path)
60035 +{
60036 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60037 +}
60038 +
60039 +static struct acl_subject_label *
60040 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60041 + const struct acl_role_label *role)
60042 +{
60043 + struct dentry *dentry = (struct dentry *) l_dentry;
60044 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60045 + struct mount *real_mnt = real_mount(mnt);
60046 + struct acl_subject_label *retval;
60047 + struct dentry *parent;
60048 +
60049 + br_read_lock(&vfsmount_lock);
60050 + write_seqlock(&rename_lock);
60051 +
60052 + for (;;) {
60053 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60054 + break;
60055 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60056 + if (!mnt_has_parent(real_mnt))
60057 + break;
60058 +
60059 + spin_lock(&dentry->d_lock);
60060 + read_lock(&gr_inode_lock);
60061 + retval =
60062 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60063 + __get_dev(dentry), role);
60064 + read_unlock(&gr_inode_lock);
60065 + spin_unlock(&dentry->d_lock);
60066 + if (retval != NULL)
60067 + goto out;
60068 +
60069 + dentry = real_mnt->mnt_mountpoint;
60070 + real_mnt = real_mnt->mnt_parent;
60071 + mnt = &real_mnt->mnt;
60072 + continue;
60073 + }
60074 +
60075 + spin_lock(&dentry->d_lock);
60076 + read_lock(&gr_inode_lock);
60077 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60078 + __get_dev(dentry), role);
60079 + read_unlock(&gr_inode_lock);
60080 + parent = dentry->d_parent;
60081 + spin_unlock(&dentry->d_lock);
60082 +
60083 + if (retval != NULL)
60084 + goto out;
60085 +
60086 + dentry = parent;
60087 + }
60088 +
60089 + spin_lock(&dentry->d_lock);
60090 + read_lock(&gr_inode_lock);
60091 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60092 + __get_dev(dentry), role);
60093 + read_unlock(&gr_inode_lock);
60094 + spin_unlock(&dentry->d_lock);
60095 +
60096 + if (unlikely(retval == NULL)) {
60097 + /* real_root is pinned, we don't need to hold a reference */
60098 + read_lock(&gr_inode_lock);
60099 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60100 + __get_dev(real_root.dentry), role);
60101 + read_unlock(&gr_inode_lock);
60102 + }
60103 +out:
60104 + write_sequnlock(&rename_lock);
60105 + br_read_unlock(&vfsmount_lock);
60106 +
60107 + BUG_ON(retval == NULL);
60108 +
60109 + return retval;
60110 +}
60111 +
60112 +static void
60113 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60114 +{
60115 + struct task_struct *task = current;
60116 + const struct cred *cred = current_cred();
60117 +
60118 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60119 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60120 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60121 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60122 +
60123 + return;
60124 +}
60125 +
60126 +static void
60127 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60128 +{
60129 + struct task_struct *task = current;
60130 + const struct cred *cred = current_cred();
60131 +
60132 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60133 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60134 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60135 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60136 +
60137 + return;
60138 +}
60139 +
60140 +static void
60141 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60142 +{
60143 + struct task_struct *task = current;
60144 + const struct cred *cred = current_cred();
60145 +
60146 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60147 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60148 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60149 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60150 +
60151 + return;
60152 +}
60153 +
60154 +__u32
60155 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60156 + const struct vfsmount * mnt)
60157 +{
60158 + __u32 retval = mode;
60159 + struct acl_subject_label *curracl;
60160 + struct acl_object_label *currobj;
60161 +
60162 + if (unlikely(!(gr_status & GR_READY)))
60163 + return (mode & ~GR_AUDITS);
60164 +
60165 + curracl = current->acl;
60166 +
60167 + currobj = chk_obj_label(dentry, mnt, curracl);
60168 + retval = currobj->mode & mode;
60169 +
60170 + /* if we're opening a specified transfer file for writing
60171 + (e.g. /dev/initctl), then transfer our role to init
60172 + */
60173 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60174 + current->role->roletype & GR_ROLE_PERSIST)) {
60175 + struct task_struct *task = init_pid_ns.child_reaper;
60176 +
60177 + if (task->role != current->role) {
60178 + task->acl_sp_role = 0;
60179 + task->acl_role_id = current->acl_role_id;
60180 + task->role = current->role;
60181 + rcu_read_lock();
60182 + read_lock(&grsec_exec_file_lock);
60183 + gr_apply_subject_to_task(task);
60184 + read_unlock(&grsec_exec_file_lock);
60185 + rcu_read_unlock();
60186 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60187 + }
60188 + }
60189 +
60190 + if (unlikely
60191 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60192 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60193 + __u32 new_mode = mode;
60194 +
60195 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60196 +
60197 + retval = new_mode;
60198 +
60199 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60200 + new_mode |= GR_INHERIT;
60201 +
60202 + if (!(mode & GR_NOLEARN))
60203 + gr_log_learn(dentry, mnt, new_mode);
60204 + }
60205 +
60206 + return retval;
60207 +}
60208 +
60209 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60210 + const struct dentry *parent,
60211 + const struct vfsmount *mnt)
60212 +{
60213 + struct name_entry *match;
60214 + struct acl_object_label *matchpo;
60215 + struct acl_subject_label *curracl;
60216 + char *path;
60217 +
60218 + if (unlikely(!(gr_status & GR_READY)))
60219 + return NULL;
60220 +
60221 + preempt_disable();
60222 + path = gr_to_filename_rbac(new_dentry, mnt);
60223 + match = lookup_name_entry_create(path);
60224 +
60225 + curracl = current->acl;
60226 +
60227 + if (match) {
60228 + read_lock(&gr_inode_lock);
60229 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60230 + read_unlock(&gr_inode_lock);
60231 +
60232 + if (matchpo) {
60233 + preempt_enable();
60234 + return matchpo;
60235 + }
60236 + }
60237 +
60238 + // lookup parent
60239 +
60240 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60241 +
60242 + preempt_enable();
60243 + return matchpo;
60244 +}
60245 +
60246 +__u32
60247 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60248 + const struct vfsmount * mnt, const __u32 mode)
60249 +{
60250 + struct acl_object_label *matchpo;
60251 + __u32 retval;
60252 +
60253 + if (unlikely(!(gr_status & GR_READY)))
60254 + return (mode & ~GR_AUDITS);
60255 +
60256 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60257 +
60258 + retval = matchpo->mode & mode;
60259 +
60260 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60261 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60262 + __u32 new_mode = mode;
60263 +
60264 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60265 +
60266 + gr_log_learn(new_dentry, mnt, new_mode);
60267 + return new_mode;
60268 + }
60269 +
60270 + return retval;
60271 +}
60272 +
60273 +__u32
60274 +gr_check_link(const struct dentry * new_dentry,
60275 + const struct dentry * parent_dentry,
60276 + const struct vfsmount * parent_mnt,
60277 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60278 +{
60279 + struct acl_object_label *obj;
60280 + __u32 oldmode, newmode;
60281 + __u32 needmode;
60282 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60283 + GR_DELETE | GR_INHERIT;
60284 +
60285 + if (unlikely(!(gr_status & GR_READY)))
60286 + return (GR_CREATE | GR_LINK);
60287 +
60288 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60289 + oldmode = obj->mode;
60290 +
60291 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60292 + newmode = obj->mode;
60293 +
60294 + needmode = newmode & checkmodes;
60295 +
60296 + // old name for hardlink must have at least the permissions of the new name
60297 + if ((oldmode & needmode) != needmode)
60298 + goto bad;
60299 +
60300 + // if old name had restrictions/auditing, make sure the new name does as well
60301 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60302 +
60303 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60304 + if (is_privileged_binary(old_dentry))
60305 + needmode |= GR_SETID;
60306 +
60307 + if ((newmode & needmode) != needmode)
60308 + goto bad;
60309 +
60310 + // enforce minimum permissions
60311 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60312 + return newmode;
60313 +bad:
60314 + needmode = oldmode;
60315 + if (is_privileged_binary(old_dentry))
60316 + needmode |= GR_SETID;
60317 +
60318 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60319 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60320 + return (GR_CREATE | GR_LINK);
60321 + } else if (newmode & GR_SUPPRESS)
60322 + return GR_SUPPRESS;
60323 + else
60324 + return 0;
60325 +}
60326 +
60327 +int
60328 +gr_check_hidden_task(const struct task_struct *task)
60329 +{
60330 + if (unlikely(!(gr_status & GR_READY)))
60331 + return 0;
60332 +
60333 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60334 + return 1;
60335 +
60336 + return 0;
60337 +}
60338 +
60339 +int
60340 +gr_check_protected_task(const struct task_struct *task)
60341 +{
60342 + if (unlikely(!(gr_status & GR_READY) || !task))
60343 + return 0;
60344 +
60345 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60346 + task->acl != current->acl)
60347 + return 1;
60348 +
60349 + return 0;
60350 +}
60351 +
60352 +int
60353 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60354 +{
60355 + struct task_struct *p;
60356 + int ret = 0;
60357 +
60358 + if (unlikely(!(gr_status & GR_READY) || !pid))
60359 + return ret;
60360 +
60361 + read_lock(&tasklist_lock);
60362 + do_each_pid_task(pid, type, p) {
60363 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60364 + p->acl != current->acl) {
60365 + ret = 1;
60366 + goto out;
60367 + }
60368 + } while_each_pid_task(pid, type, p);
60369 +out:
60370 + read_unlock(&tasklist_lock);
60371 +
60372 + return ret;
60373 +}
60374 +
60375 +void
60376 +gr_copy_label(struct task_struct *tsk)
60377 +{
60378 + tsk->signal->used_accept = 0;
60379 + tsk->acl_sp_role = 0;
60380 + tsk->acl_role_id = current->acl_role_id;
60381 + tsk->acl = current->acl;
60382 + tsk->role = current->role;
60383 + tsk->signal->curr_ip = current->signal->curr_ip;
60384 + tsk->signal->saved_ip = current->signal->saved_ip;
60385 + if (current->exec_file)
60386 + get_file(current->exec_file);
60387 + tsk->exec_file = current->exec_file;
60388 + tsk->is_writable = current->is_writable;
60389 + if (unlikely(current->signal->used_accept)) {
60390 + current->signal->curr_ip = 0;
60391 + current->signal->saved_ip = 0;
60392 + }
60393 +
60394 + return;
60395 +}
60396 +
60397 +static void
60398 +gr_set_proc_res(struct task_struct *task)
60399 +{
60400 + struct acl_subject_label *proc;
60401 + unsigned short i;
60402 +
60403 + proc = task->acl;
60404 +
60405 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60406 + return;
60407 +
60408 + for (i = 0; i < RLIM_NLIMITS; i++) {
60409 + if (!(proc->resmask & (1U << i)))
60410 + continue;
60411 +
60412 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60413 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60414 +
60415 + if (i == RLIMIT_CPU)
60416 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60417 + }
60418 +
60419 + return;
60420 +}
60421 +
60422 +extern int __gr_process_user_ban(struct user_struct *user);
60423 +
60424 +int
60425 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60426 +{
60427 + unsigned int i;
60428 + __u16 num;
60429 + uid_t *uidlist;
60430 + uid_t curuid;
60431 + int realok = 0;
60432 + int effectiveok = 0;
60433 + int fsok = 0;
60434 + uid_t globalreal, globaleffective, globalfs;
60435 +
60436 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
60437 + struct user_struct *user;
60438 +
60439 + if (!uid_valid(real))
60440 + goto skipit;
60441 +
60442 + /* find user based on global namespace */
60443 +
60444 + globalreal = GR_GLOBAL_UID(real);
60445 +
60446 + user = find_user(make_kuid(&init_user_ns, globalreal));
60447 + if (user == NULL)
60448 + goto skipit;
60449 +
60450 + if (__gr_process_user_ban(user)) {
60451 + /* for find_user */
60452 + free_uid(user);
60453 + return 1;
60454 + }
60455 +
60456 + /* for find_user */
60457 + free_uid(user);
60458 +
60459 +skipit:
60460 +#endif
60461 +
60462 + if (unlikely(!(gr_status & GR_READY)))
60463 + return 0;
60464 +
60465 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60466 + gr_log_learn_uid_change(real, effective, fs);
60467 +
60468 + num = current->acl->user_trans_num;
60469 + uidlist = current->acl->user_transitions;
60470 +
60471 + if (uidlist == NULL)
60472 + return 0;
60473 +
60474 + if (!uid_valid(real)) {
60475 + realok = 1;
60476 + globalreal = (uid_t)-1;
60477 + } else {
60478 + globalreal = GR_GLOBAL_UID(real);
60479 + }
60480 + if (!uid_valid(effective)) {
60481 + effectiveok = 1;
60482 + globaleffective = (uid_t)-1;
60483 + } else {
60484 + globaleffective = GR_GLOBAL_UID(effective);
60485 + }
60486 + if (!uid_valid(fs)) {
60487 + fsok = 1;
60488 + globalfs = (uid_t)-1;
60489 + } else {
60490 + globalfs = GR_GLOBAL_UID(fs);
60491 + }
60492 +
60493 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60494 + for (i = 0; i < num; i++) {
60495 + curuid = uidlist[i];
60496 + if (globalreal == curuid)
60497 + realok = 1;
60498 + if (globaleffective == curuid)
60499 + effectiveok = 1;
60500 + if (globalfs == curuid)
60501 + fsok = 1;
60502 + }
60503 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60504 + for (i = 0; i < num; i++) {
60505 + curuid = uidlist[i];
60506 + if (globalreal == curuid)
60507 + break;
60508 + if (globaleffective == curuid)
60509 + break;
60510 + if (globalfs == curuid)
60511 + break;
60512 + }
60513 + /* not in deny list */
60514 + if (i == num) {
60515 + realok = 1;
60516 + effectiveok = 1;
60517 + fsok = 1;
60518 + }
60519 + }
60520 +
60521 + if (realok && effectiveok && fsok)
60522 + return 0;
60523 + else {
60524 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60525 + return 1;
60526 + }
60527 +}
60528 +
60529 +int
60530 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60531 +{
60532 + unsigned int i;
60533 + __u16 num;
60534 + gid_t *gidlist;
60535 + gid_t curgid;
60536 + int realok = 0;
60537 + int effectiveok = 0;
60538 + int fsok = 0;
60539 + gid_t globalreal, globaleffective, globalfs;
60540 +
60541 + if (unlikely(!(gr_status & GR_READY)))
60542 + return 0;
60543 +
60544 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60545 + gr_log_learn_gid_change(real, effective, fs);
60546 +
60547 + num = current->acl->group_trans_num;
60548 + gidlist = current->acl->group_transitions;
60549 +
60550 + if (gidlist == NULL)
60551 + return 0;
60552 +
60553 + if (!gid_valid(real)) {
60554 + realok = 1;
60555 + globalreal = (gid_t)-1;
60556 + } else {
60557 + globalreal = GR_GLOBAL_GID(real);
60558 + }
60559 + if (!gid_valid(effective)) {
60560 + effectiveok = 1;
60561 + globaleffective = (gid_t)-1;
60562 + } else {
60563 + globaleffective = GR_GLOBAL_GID(effective);
60564 + }
60565 + if (!gid_valid(fs)) {
60566 + fsok = 1;
60567 + globalfs = (gid_t)-1;
60568 + } else {
60569 + globalfs = GR_GLOBAL_GID(fs);
60570 + }
60571 +
60572 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60573 + for (i = 0; i < num; i++) {
60574 + curgid = gidlist[i];
60575 + if (globalreal == curgid)
60576 + realok = 1;
60577 + if (globaleffective == curgid)
60578 + effectiveok = 1;
60579 + if (globalfs == curgid)
60580 + fsok = 1;
60581 + }
60582 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60583 + for (i = 0; i < num; i++) {
60584 + curgid = gidlist[i];
60585 + if (globalreal == curgid)
60586 + break;
60587 + if (globaleffective == curgid)
60588 + break;
60589 + if (globalfs == curgid)
60590 + break;
60591 + }
60592 + /* not in deny list */
60593 + if (i == num) {
60594 + realok = 1;
60595 + effectiveok = 1;
60596 + fsok = 1;
60597 + }
60598 + }
60599 +
60600 + if (realok && effectiveok && fsok)
60601 + return 0;
60602 + else {
60603 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60604 + return 1;
60605 + }
60606 +}
60607 +
60608 +extern int gr_acl_is_capable(const int cap);
60609 +
60610 +void
60611 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60612 +{
60613 + struct acl_role_label *role = task->role;
60614 + struct acl_subject_label *subj = NULL;
60615 + struct acl_object_label *obj;
60616 + struct file *filp;
60617 + uid_t uid;
60618 + gid_t gid;
60619 +
60620 + if (unlikely(!(gr_status & GR_READY)))
60621 + return;
60622 +
60623 + uid = GR_GLOBAL_UID(kuid);
60624 + gid = GR_GLOBAL_GID(kgid);
60625 +
60626 + filp = task->exec_file;
60627 +
60628 + /* kernel process, we'll give them the kernel role */
60629 + if (unlikely(!filp)) {
60630 + task->role = kernel_role;
60631 + task->acl = kernel_role->root_label;
60632 + return;
60633 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60634 + role = lookup_acl_role_label(task, uid, gid);
60635 +
60636 + /* don't change the role if we're not a privileged process */
60637 + if (role && task->role != role &&
60638 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60639 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60640 + return;
60641 +
60642 + /* perform subject lookup in possibly new role
60643 + we can use this result below in the case where role == task->role
60644 + */
60645 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60646 +
60647 + /* if we changed uid/gid, but result in the same role
60648 + and are using inheritance, don't lose the inherited subject
60649 + if current subject is other than what normal lookup
60650 + would result in, we arrived via inheritance, don't
60651 + lose subject
60652 + */
60653 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60654 + (subj == task->acl)))
60655 + task->acl = subj;
60656 +
60657 + task->role = role;
60658 +
60659 + task->is_writable = 0;
60660 +
60661 + /* ignore additional mmap checks for processes that are writable
60662 + by the default ACL */
60663 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60664 + if (unlikely(obj->mode & GR_WRITE))
60665 + task->is_writable = 1;
60666 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60667 + if (unlikely(obj->mode & GR_WRITE))
60668 + task->is_writable = 1;
60669 +
60670 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60671 + 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);
60672 +#endif
60673 +
60674 + gr_set_proc_res(task);
60675 +
60676 + return;
60677 +}
60678 +
60679 +int
60680 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60681 + const int unsafe_flags)
60682 +{
60683 + struct task_struct *task = current;
60684 + struct acl_subject_label *newacl;
60685 + struct acl_object_label *obj;
60686 + __u32 retmode;
60687 +
60688 + if (unlikely(!(gr_status & GR_READY)))
60689 + return 0;
60690 +
60691 + newacl = chk_subj_label(dentry, mnt, task->role);
60692 +
60693 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60694 + did an exec
60695 + */
60696 + rcu_read_lock();
60697 + read_lock(&tasklist_lock);
60698 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60699 + (task->parent->acl->mode & GR_POVERRIDE))) {
60700 + read_unlock(&tasklist_lock);
60701 + rcu_read_unlock();
60702 + goto skip_check;
60703 + }
60704 + read_unlock(&tasklist_lock);
60705 + rcu_read_unlock();
60706 +
60707 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60708 + !(task->role->roletype & GR_ROLE_GOD) &&
60709 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60710 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60711 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60712 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60713 + else
60714 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60715 + return -EACCES;
60716 + }
60717 +
60718 +skip_check:
60719 +
60720 + obj = chk_obj_label(dentry, mnt, task->acl);
60721 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60722 +
60723 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60724 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60725 + if (obj->nested)
60726 + task->acl = obj->nested;
60727 + else
60728 + task->acl = newacl;
60729 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60730 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60731 +
60732 + task->is_writable = 0;
60733 +
60734 + /* ignore additional mmap checks for processes that are writable
60735 + by the default ACL */
60736 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60737 + if (unlikely(obj->mode & GR_WRITE))
60738 + task->is_writable = 1;
60739 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60740 + if (unlikely(obj->mode & GR_WRITE))
60741 + task->is_writable = 1;
60742 +
60743 + gr_set_proc_res(task);
60744 +
60745 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60746 + 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);
60747 +#endif
60748 + return 0;
60749 +}
60750 +
60751 +/* always called with valid inodev ptr */
60752 +static void
60753 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60754 +{
60755 + struct acl_object_label *matchpo;
60756 + struct acl_subject_label *matchps;
60757 + struct acl_subject_label *subj;
60758 + struct acl_role_label *role;
60759 + unsigned int x;
60760 +
60761 + FOR_EACH_ROLE_START(role)
60762 + FOR_EACH_SUBJECT_START(role, subj, x)
60763 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60764 + matchpo->mode |= GR_DELETED;
60765 + FOR_EACH_SUBJECT_END(subj,x)
60766 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60767 + /* nested subjects aren't in the role's subj_hash table */
60768 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60769 + matchpo->mode |= GR_DELETED;
60770 + FOR_EACH_NESTED_SUBJECT_END(subj)
60771 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60772 + matchps->mode |= GR_DELETED;
60773 + FOR_EACH_ROLE_END(role)
60774 +
60775 + inodev->nentry->deleted = 1;
60776 +
60777 + return;
60778 +}
60779 +
60780 +void
60781 +gr_handle_delete(const ino_t ino, const dev_t dev)
60782 +{
60783 + struct inodev_entry *inodev;
60784 +
60785 + if (unlikely(!(gr_status & GR_READY)))
60786 + return;
60787 +
60788 + write_lock(&gr_inode_lock);
60789 + inodev = lookup_inodev_entry(ino, dev);
60790 + if (inodev != NULL)
60791 + do_handle_delete(inodev, ino, dev);
60792 + write_unlock(&gr_inode_lock);
60793 +
60794 + return;
60795 +}
60796 +
60797 +static void
60798 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60799 + const ino_t newinode, const dev_t newdevice,
60800 + struct acl_subject_label *subj)
60801 +{
60802 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60803 + struct acl_object_label *match;
60804 +
60805 + match = subj->obj_hash[index];
60806 +
60807 + while (match && (match->inode != oldinode ||
60808 + match->device != olddevice ||
60809 + !(match->mode & GR_DELETED)))
60810 + match = match->next;
60811 +
60812 + if (match && (match->inode == oldinode)
60813 + && (match->device == olddevice)
60814 + && (match->mode & GR_DELETED)) {
60815 + if (match->prev == NULL) {
60816 + subj->obj_hash[index] = match->next;
60817 + if (match->next != NULL)
60818 + match->next->prev = NULL;
60819 + } else {
60820 + match->prev->next = match->next;
60821 + if (match->next != NULL)
60822 + match->next->prev = match->prev;
60823 + }
60824 + match->prev = NULL;
60825 + match->next = NULL;
60826 + match->inode = newinode;
60827 + match->device = newdevice;
60828 + match->mode &= ~GR_DELETED;
60829 +
60830 + insert_acl_obj_label(match, subj);
60831 + }
60832 +
60833 + return;
60834 +}
60835 +
60836 +static void
60837 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60838 + const ino_t newinode, const dev_t newdevice,
60839 + struct acl_role_label *role)
60840 +{
60841 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60842 + struct acl_subject_label *match;
60843 +
60844 + match = role->subj_hash[index];
60845 +
60846 + while (match && (match->inode != oldinode ||
60847 + match->device != olddevice ||
60848 + !(match->mode & GR_DELETED)))
60849 + match = match->next;
60850 +
60851 + if (match && (match->inode == oldinode)
60852 + && (match->device == olddevice)
60853 + && (match->mode & GR_DELETED)) {
60854 + if (match->prev == NULL) {
60855 + role->subj_hash[index] = match->next;
60856 + if (match->next != NULL)
60857 + match->next->prev = NULL;
60858 + } else {
60859 + match->prev->next = match->next;
60860 + if (match->next != NULL)
60861 + match->next->prev = match->prev;
60862 + }
60863 + match->prev = NULL;
60864 + match->next = NULL;
60865 + match->inode = newinode;
60866 + match->device = newdevice;
60867 + match->mode &= ~GR_DELETED;
60868 +
60869 + insert_acl_subj_label(match, role);
60870 + }
60871 +
60872 + return;
60873 +}
60874 +
60875 +static void
60876 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60877 + const ino_t newinode, const dev_t newdevice)
60878 +{
60879 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60880 + struct inodev_entry *match;
60881 +
60882 + match = inodev_set.i_hash[index];
60883 +
60884 + while (match && (match->nentry->inode != oldinode ||
60885 + match->nentry->device != olddevice || !match->nentry->deleted))
60886 + match = match->next;
60887 +
60888 + if (match && (match->nentry->inode == oldinode)
60889 + && (match->nentry->device == olddevice) &&
60890 + match->nentry->deleted) {
60891 + if (match->prev == NULL) {
60892 + inodev_set.i_hash[index] = match->next;
60893 + if (match->next != NULL)
60894 + match->next->prev = NULL;
60895 + } else {
60896 + match->prev->next = match->next;
60897 + if (match->next != NULL)
60898 + match->next->prev = match->prev;
60899 + }
60900 + match->prev = NULL;
60901 + match->next = NULL;
60902 + match->nentry->inode = newinode;
60903 + match->nentry->device = newdevice;
60904 + match->nentry->deleted = 0;
60905 +
60906 + insert_inodev_entry(match);
60907 + }
60908 +
60909 + return;
60910 +}
60911 +
60912 +static void
60913 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60914 +{
60915 + struct acl_subject_label *subj;
60916 + struct acl_role_label *role;
60917 + unsigned int x;
60918 +
60919 + FOR_EACH_ROLE_START(role)
60920 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60921 +
60922 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60923 + if ((subj->inode == ino) && (subj->device == dev)) {
60924 + subj->inode = ino;
60925 + subj->device = dev;
60926 + }
60927 + /* nested subjects aren't in the role's subj_hash table */
60928 + update_acl_obj_label(matchn->inode, matchn->device,
60929 + ino, dev, subj);
60930 + FOR_EACH_NESTED_SUBJECT_END(subj)
60931 + FOR_EACH_SUBJECT_START(role, subj, x)
60932 + update_acl_obj_label(matchn->inode, matchn->device,
60933 + ino, dev, subj);
60934 + FOR_EACH_SUBJECT_END(subj,x)
60935 + FOR_EACH_ROLE_END(role)
60936 +
60937 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60938 +
60939 + return;
60940 +}
60941 +
60942 +static void
60943 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60944 + const struct vfsmount *mnt)
60945 +{
60946 + ino_t ino = dentry->d_inode->i_ino;
60947 + dev_t dev = __get_dev(dentry);
60948 +
60949 + __do_handle_create(matchn, ino, dev);
60950 +
60951 + return;
60952 +}
60953 +
60954 +void
60955 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60956 +{
60957 + struct name_entry *matchn;
60958 +
60959 + if (unlikely(!(gr_status & GR_READY)))
60960 + return;
60961 +
60962 + preempt_disable();
60963 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60964 +
60965 + if (unlikely((unsigned long)matchn)) {
60966 + write_lock(&gr_inode_lock);
60967 + do_handle_create(matchn, dentry, mnt);
60968 + write_unlock(&gr_inode_lock);
60969 + }
60970 + preempt_enable();
60971 +
60972 + return;
60973 +}
60974 +
60975 +void
60976 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60977 +{
60978 + struct name_entry *matchn;
60979 +
60980 + if (unlikely(!(gr_status & GR_READY)))
60981 + return;
60982 +
60983 + preempt_disable();
60984 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60985 +
60986 + if (unlikely((unsigned long)matchn)) {
60987 + write_lock(&gr_inode_lock);
60988 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60989 + write_unlock(&gr_inode_lock);
60990 + }
60991 + preempt_enable();
60992 +
60993 + return;
60994 +}
60995 +
60996 +void
60997 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
60998 + struct dentry *old_dentry,
60999 + struct dentry *new_dentry,
61000 + struct vfsmount *mnt, const __u8 replace)
61001 +{
61002 + struct name_entry *matchn;
61003 + struct inodev_entry *inodev;
61004 + struct inode *inode = new_dentry->d_inode;
61005 + ino_t old_ino = old_dentry->d_inode->i_ino;
61006 + dev_t old_dev = __get_dev(old_dentry);
61007 +
61008 + /* vfs_rename swaps the name and parent link for old_dentry and
61009 + new_dentry
61010 + at this point, old_dentry has the new name, parent link, and inode
61011 + for the renamed file
61012 + if a file is being replaced by a rename, new_dentry has the inode
61013 + and name for the replaced file
61014 + */
61015 +
61016 + if (unlikely(!(gr_status & GR_READY)))
61017 + return;
61018 +
61019 + preempt_disable();
61020 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61021 +
61022 + /* we wouldn't have to check d_inode if it weren't for
61023 + NFS silly-renaming
61024 + */
61025 +
61026 + write_lock(&gr_inode_lock);
61027 + if (unlikely(replace && inode)) {
61028 + ino_t new_ino = inode->i_ino;
61029 + dev_t new_dev = __get_dev(new_dentry);
61030 +
61031 + inodev = lookup_inodev_entry(new_ino, new_dev);
61032 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61033 + do_handle_delete(inodev, new_ino, new_dev);
61034 + }
61035 +
61036 + inodev = lookup_inodev_entry(old_ino, old_dev);
61037 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61038 + do_handle_delete(inodev, old_ino, old_dev);
61039 +
61040 + if (unlikely((unsigned long)matchn))
61041 + do_handle_create(matchn, old_dentry, mnt);
61042 +
61043 + write_unlock(&gr_inode_lock);
61044 + preempt_enable();
61045 +
61046 + return;
61047 +}
61048 +
61049 +static int
61050 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61051 + unsigned char **sum)
61052 +{
61053 + struct acl_role_label *r;
61054 + struct role_allowed_ip *ipp;
61055 + struct role_transition *trans;
61056 + unsigned int i;
61057 + int found = 0;
61058 + u32 curr_ip = current->signal->curr_ip;
61059 +
61060 + current->signal->saved_ip = curr_ip;
61061 +
61062 + /* check transition table */
61063 +
61064 + for (trans = current->role->transitions; trans; trans = trans->next) {
61065 + if (!strcmp(rolename, trans->rolename)) {
61066 + found = 1;
61067 + break;
61068 + }
61069 + }
61070 +
61071 + if (!found)
61072 + return 0;
61073 +
61074 + /* handle special roles that do not require authentication
61075 + and check ip */
61076 +
61077 + FOR_EACH_ROLE_START(r)
61078 + if (!strcmp(rolename, r->rolename) &&
61079 + (r->roletype & GR_ROLE_SPECIAL)) {
61080 + found = 0;
61081 + if (r->allowed_ips != NULL) {
61082 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61083 + if ((ntohl(curr_ip) & ipp->netmask) ==
61084 + (ntohl(ipp->addr) & ipp->netmask))
61085 + found = 1;
61086 + }
61087 + } else
61088 + found = 2;
61089 + if (!found)
61090 + return 0;
61091 +
61092 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61093 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61094 + *salt = NULL;
61095 + *sum = NULL;
61096 + return 1;
61097 + }
61098 + }
61099 + FOR_EACH_ROLE_END(r)
61100 +
61101 + for (i = 0; i < num_sprole_pws; i++) {
61102 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61103 + *salt = acl_special_roles[i]->salt;
61104 + *sum = acl_special_roles[i]->sum;
61105 + return 1;
61106 + }
61107 + }
61108 +
61109 + return 0;
61110 +}
61111 +
61112 +static void
61113 +assign_special_role(char *rolename)
61114 +{
61115 + struct acl_object_label *obj;
61116 + struct acl_role_label *r;
61117 + struct acl_role_label *assigned = NULL;
61118 + struct task_struct *tsk;
61119 + struct file *filp;
61120 +
61121 + FOR_EACH_ROLE_START(r)
61122 + if (!strcmp(rolename, r->rolename) &&
61123 + (r->roletype & GR_ROLE_SPECIAL)) {
61124 + assigned = r;
61125 + break;
61126 + }
61127 + FOR_EACH_ROLE_END(r)
61128 +
61129 + if (!assigned)
61130 + return;
61131 +
61132 + read_lock(&tasklist_lock);
61133 + read_lock(&grsec_exec_file_lock);
61134 +
61135 + tsk = current->real_parent;
61136 + if (tsk == NULL)
61137 + goto out_unlock;
61138 +
61139 + filp = tsk->exec_file;
61140 + if (filp == NULL)
61141 + goto out_unlock;
61142 +
61143 + tsk->is_writable = 0;
61144 +
61145 + tsk->acl_sp_role = 1;
61146 + tsk->acl_role_id = ++acl_sp_role_value;
61147 + tsk->role = assigned;
61148 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61149 +
61150 + /* ignore additional mmap checks for processes that are writable
61151 + by the default ACL */
61152 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61153 + if (unlikely(obj->mode & GR_WRITE))
61154 + tsk->is_writable = 1;
61155 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61156 + if (unlikely(obj->mode & GR_WRITE))
61157 + tsk->is_writable = 1;
61158 +
61159 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61160 + 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));
61161 +#endif
61162 +
61163 +out_unlock:
61164 + read_unlock(&grsec_exec_file_lock);
61165 + read_unlock(&tasklist_lock);
61166 + return;
61167 +}
61168 +
61169 +int gr_check_secure_terminal(struct task_struct *task)
61170 +{
61171 + struct task_struct *p, *p2, *p3;
61172 + struct files_struct *files;
61173 + struct fdtable *fdt;
61174 + struct file *our_file = NULL, *file;
61175 + int i;
61176 +
61177 + if (task->signal->tty == NULL)
61178 + return 1;
61179 +
61180 + files = get_files_struct(task);
61181 + if (files != NULL) {
61182 + rcu_read_lock();
61183 + fdt = files_fdtable(files);
61184 + for (i=0; i < fdt->max_fds; i++) {
61185 + file = fcheck_files(files, i);
61186 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61187 + get_file(file);
61188 + our_file = file;
61189 + }
61190 + }
61191 + rcu_read_unlock();
61192 + put_files_struct(files);
61193 + }
61194 +
61195 + if (our_file == NULL)
61196 + return 1;
61197 +
61198 + read_lock(&tasklist_lock);
61199 + do_each_thread(p2, p) {
61200 + files = get_files_struct(p);
61201 + if (files == NULL ||
61202 + (p->signal && p->signal->tty == task->signal->tty)) {
61203 + if (files != NULL)
61204 + put_files_struct(files);
61205 + continue;
61206 + }
61207 + rcu_read_lock();
61208 + fdt = files_fdtable(files);
61209 + for (i=0; i < fdt->max_fds; i++) {
61210 + file = fcheck_files(files, i);
61211 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61212 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61213 + p3 = task;
61214 + while (task_pid_nr(p3) > 0) {
61215 + if (p3 == p)
61216 + break;
61217 + p3 = p3->real_parent;
61218 + }
61219 + if (p3 == p)
61220 + break;
61221 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61222 + gr_handle_alertkill(p);
61223 + rcu_read_unlock();
61224 + put_files_struct(files);
61225 + read_unlock(&tasklist_lock);
61226 + fput(our_file);
61227 + return 0;
61228 + }
61229 + }
61230 + rcu_read_unlock();
61231 + put_files_struct(files);
61232 + } while_each_thread(p2, p);
61233 + read_unlock(&tasklist_lock);
61234 +
61235 + fput(our_file);
61236 + return 1;
61237 +}
61238 +
61239 +static int gr_rbac_disable(void *unused)
61240 +{
61241 + pax_open_kernel();
61242 + gr_status &= ~GR_READY;
61243 + pax_close_kernel();
61244 +
61245 + return 0;
61246 +}
61247 +
61248 +ssize_t
61249 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61250 +{
61251 + struct gr_arg_wrapper uwrap;
61252 + unsigned char *sprole_salt = NULL;
61253 + unsigned char *sprole_sum = NULL;
61254 + int error = sizeof (struct gr_arg_wrapper);
61255 + int error2 = 0;
61256 +
61257 + mutex_lock(&gr_dev_mutex);
61258 +
61259 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61260 + error = -EPERM;
61261 + goto out;
61262 + }
61263 +
61264 + if (count != sizeof (struct gr_arg_wrapper)) {
61265 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61266 + error = -EINVAL;
61267 + goto out;
61268 + }
61269 +
61270 +
61271 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61272 + gr_auth_expires = 0;
61273 + gr_auth_attempts = 0;
61274 + }
61275 +
61276 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61277 + error = -EFAULT;
61278 + goto out;
61279 + }
61280 +
61281 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61282 + error = -EINVAL;
61283 + goto out;
61284 + }
61285 +
61286 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61287 + error = -EFAULT;
61288 + goto out;
61289 + }
61290 +
61291 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61292 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61293 + time_after(gr_auth_expires, get_seconds())) {
61294 + error = -EBUSY;
61295 + goto out;
61296 + }
61297 +
61298 + /* if non-root trying to do anything other than use a special role,
61299 + do not attempt authentication, do not count towards authentication
61300 + locking
61301 + */
61302 +
61303 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61304 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61305 + gr_is_global_nonroot(current_uid())) {
61306 + error = -EPERM;
61307 + goto out;
61308 + }
61309 +
61310 + /* ensure pw and special role name are null terminated */
61311 +
61312 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61313 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61314 +
61315 + /* Okay.
61316 + * We have our enough of the argument structure..(we have yet
61317 + * to copy_from_user the tables themselves) . Copy the tables
61318 + * only if we need them, i.e. for loading operations. */
61319 +
61320 + switch (gr_usermode->mode) {
61321 + case GR_STATUS:
61322 + if (gr_status & GR_READY) {
61323 + error = 1;
61324 + if (!gr_check_secure_terminal(current))
61325 + error = 3;
61326 + } else
61327 + error = 2;
61328 + goto out;
61329 + case GR_SHUTDOWN:
61330 + if ((gr_status & GR_READY)
61331 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61332 + stop_machine(gr_rbac_disable, NULL, NULL);
61333 + free_variables();
61334 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61335 + memset(gr_system_salt, 0, GR_SALT_LEN);
61336 + memset(gr_system_sum, 0, GR_SHA_LEN);
61337 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61338 + } else if (gr_status & GR_READY) {
61339 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61340 + error = -EPERM;
61341 + } else {
61342 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61343 + error = -EAGAIN;
61344 + }
61345 + break;
61346 + case GR_ENABLE:
61347 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61348 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61349 + else {
61350 + if (gr_status & GR_READY)
61351 + error = -EAGAIN;
61352 + else
61353 + error = error2;
61354 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61355 + }
61356 + break;
61357 + case GR_RELOAD:
61358 + if (!(gr_status & GR_READY)) {
61359 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61360 + error = -EAGAIN;
61361 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61362 + stop_machine(gr_rbac_disable, NULL, NULL);
61363 + free_variables();
61364 + error2 = gracl_init(gr_usermode);
61365 + if (!error2)
61366 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61367 + else {
61368 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61369 + error = error2;
61370 + }
61371 + } else {
61372 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61373 + error = -EPERM;
61374 + }
61375 + break;
61376 + case GR_SEGVMOD:
61377 + if (unlikely(!(gr_status & GR_READY))) {
61378 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61379 + error = -EAGAIN;
61380 + break;
61381 + }
61382 +
61383 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61384 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61385 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61386 + struct acl_subject_label *segvacl;
61387 + segvacl =
61388 + lookup_acl_subj_label(gr_usermode->segv_inode,
61389 + gr_usermode->segv_device,
61390 + current->role);
61391 + if (segvacl) {
61392 + segvacl->crashes = 0;
61393 + segvacl->expires = 0;
61394 + }
61395 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61396 + gr_remove_uid(gr_usermode->segv_uid);
61397 + }
61398 + } else {
61399 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61400 + error = -EPERM;
61401 + }
61402 + break;
61403 + case GR_SPROLE:
61404 + case GR_SPROLEPAM:
61405 + if (unlikely(!(gr_status & GR_READY))) {
61406 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61407 + error = -EAGAIN;
61408 + break;
61409 + }
61410 +
61411 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61412 + current->role->expires = 0;
61413 + current->role->auth_attempts = 0;
61414 + }
61415 +
61416 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61417 + time_after(current->role->expires, get_seconds())) {
61418 + error = -EBUSY;
61419 + goto out;
61420 + }
61421 +
61422 + if (lookup_special_role_auth
61423 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61424 + && ((!sprole_salt && !sprole_sum)
61425 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61426 + char *p = "";
61427 + assign_special_role(gr_usermode->sp_role);
61428 + read_lock(&tasklist_lock);
61429 + if (current->real_parent)
61430 + p = current->real_parent->role->rolename;
61431 + read_unlock(&tasklist_lock);
61432 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61433 + p, acl_sp_role_value);
61434 + } else {
61435 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61436 + error = -EPERM;
61437 + if(!(current->role->auth_attempts++))
61438 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61439 +
61440 + goto out;
61441 + }
61442 + break;
61443 + case GR_UNSPROLE:
61444 + if (unlikely(!(gr_status & GR_READY))) {
61445 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61446 + error = -EAGAIN;
61447 + break;
61448 + }
61449 +
61450 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61451 + char *p = "";
61452 + int i = 0;
61453 +
61454 + read_lock(&tasklist_lock);
61455 + if (current->real_parent) {
61456 + p = current->real_parent->role->rolename;
61457 + i = current->real_parent->acl_role_id;
61458 + }
61459 + read_unlock(&tasklist_lock);
61460 +
61461 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61462 + gr_set_acls(1);
61463 + } else {
61464 + error = -EPERM;
61465 + goto out;
61466 + }
61467 + break;
61468 + default:
61469 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61470 + error = -EINVAL;
61471 + break;
61472 + }
61473 +
61474 + if (error != -EPERM)
61475 + goto out;
61476 +
61477 + if(!(gr_auth_attempts++))
61478 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61479 +
61480 + out:
61481 + mutex_unlock(&gr_dev_mutex);
61482 + return error;
61483 +}
61484 +
61485 +/* must be called with
61486 + rcu_read_lock();
61487 + read_lock(&tasklist_lock);
61488 + read_lock(&grsec_exec_file_lock);
61489 +*/
61490 +int gr_apply_subject_to_task(struct task_struct *task)
61491 +{
61492 + struct acl_object_label *obj;
61493 + char *tmpname;
61494 + struct acl_subject_label *tmpsubj;
61495 + struct file *filp;
61496 + struct name_entry *nmatch;
61497 +
61498 + filp = task->exec_file;
61499 + if (filp == NULL)
61500 + return 0;
61501 +
61502 + /* the following is to apply the correct subject
61503 + on binaries running when the RBAC system
61504 + is enabled, when the binaries have been
61505 + replaced or deleted since their execution
61506 + -----
61507 + when the RBAC system starts, the inode/dev
61508 + from exec_file will be one the RBAC system
61509 + is unaware of. It only knows the inode/dev
61510 + of the present file on disk, or the absence
61511 + of it.
61512 + */
61513 + preempt_disable();
61514 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61515 +
61516 + nmatch = lookup_name_entry(tmpname);
61517 + preempt_enable();
61518 + tmpsubj = NULL;
61519 + if (nmatch) {
61520 + if (nmatch->deleted)
61521 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61522 + else
61523 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61524 + if (tmpsubj != NULL)
61525 + task->acl = tmpsubj;
61526 + }
61527 + if (tmpsubj == NULL)
61528 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61529 + task->role);
61530 + if (task->acl) {
61531 + task->is_writable = 0;
61532 + /* ignore additional mmap checks for processes that are writable
61533 + by the default ACL */
61534 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61535 + if (unlikely(obj->mode & GR_WRITE))
61536 + task->is_writable = 1;
61537 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61538 + if (unlikely(obj->mode & GR_WRITE))
61539 + task->is_writable = 1;
61540 +
61541 + gr_set_proc_res(task);
61542 +
61543 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61544 + 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);
61545 +#endif
61546 + } else {
61547 + return 1;
61548 + }
61549 +
61550 + return 0;
61551 +}
61552 +
61553 +int
61554 +gr_set_acls(const int type)
61555 +{
61556 + struct task_struct *task, *task2;
61557 + struct acl_role_label *role = current->role;
61558 + __u16 acl_role_id = current->acl_role_id;
61559 + const struct cred *cred;
61560 + int ret;
61561 +
61562 + rcu_read_lock();
61563 + read_lock(&tasklist_lock);
61564 + read_lock(&grsec_exec_file_lock);
61565 + do_each_thread(task2, task) {
61566 + /* check to see if we're called from the exit handler,
61567 + if so, only replace ACLs that have inherited the admin
61568 + ACL */
61569 +
61570 + if (type && (task->role != role ||
61571 + task->acl_role_id != acl_role_id))
61572 + continue;
61573 +
61574 + task->acl_role_id = 0;
61575 + task->acl_sp_role = 0;
61576 +
61577 + if (task->exec_file) {
61578 + cred = __task_cred(task);
61579 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61580 + ret = gr_apply_subject_to_task(task);
61581 + if (ret) {
61582 + read_unlock(&grsec_exec_file_lock);
61583 + read_unlock(&tasklist_lock);
61584 + rcu_read_unlock();
61585 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61586 + return ret;
61587 + }
61588 + } else {
61589 + // it's a kernel process
61590 + task->role = kernel_role;
61591 + task->acl = kernel_role->root_label;
61592 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61593 + task->acl->mode &= ~GR_PROCFIND;
61594 +#endif
61595 + }
61596 + } while_each_thread(task2, task);
61597 + read_unlock(&grsec_exec_file_lock);
61598 + read_unlock(&tasklist_lock);
61599 + rcu_read_unlock();
61600 +
61601 + return 0;
61602 +}
61603 +
61604 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61605 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61606 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61607 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61608 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61609 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61610 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61611 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61612 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61613 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61614 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61615 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61616 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61617 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61618 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61619 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61620 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61621 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61622 +};
61623 +
61624 +void
61625 +gr_learn_resource(const struct task_struct *task,
61626 + const int res, const unsigned long wanted, const int gt)
61627 +{
61628 + struct acl_subject_label *acl;
61629 + const struct cred *cred;
61630 +
61631 + if (unlikely((gr_status & GR_READY) &&
61632 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61633 + goto skip_reslog;
61634 +
61635 + gr_log_resource(task, res, wanted, gt);
61636 +skip_reslog:
61637 +
61638 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61639 + return;
61640 +
61641 + acl = task->acl;
61642 +
61643 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61644 + !(acl->resmask & (1U << (unsigned short) res))))
61645 + return;
61646 +
61647 + if (wanted >= acl->res[res].rlim_cur) {
61648 + unsigned long res_add;
61649 +
61650 + res_add = wanted + res_learn_bumps[res];
61651 +
61652 + acl->res[res].rlim_cur = res_add;
61653 +
61654 + if (wanted > acl->res[res].rlim_max)
61655 + acl->res[res].rlim_max = res_add;
61656 +
61657 + /* only log the subject filename, since resource logging is supported for
61658 + single-subject learning only */
61659 + rcu_read_lock();
61660 + cred = __task_cred(task);
61661 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61662 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61663 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61664 + "", (unsigned long) res, &task->signal->saved_ip);
61665 + rcu_read_unlock();
61666 + }
61667 +
61668 + return;
61669 +}
61670 +EXPORT_SYMBOL(gr_learn_resource);
61671 +#endif
61672 +
61673 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61674 +void
61675 +pax_set_initial_flags(struct linux_binprm *bprm)
61676 +{
61677 + struct task_struct *task = current;
61678 + struct acl_subject_label *proc;
61679 + unsigned long flags;
61680 +
61681 + if (unlikely(!(gr_status & GR_READY)))
61682 + return;
61683 +
61684 + flags = pax_get_flags(task);
61685 +
61686 + proc = task->acl;
61687 +
61688 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61689 + flags &= ~MF_PAX_PAGEEXEC;
61690 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61691 + flags &= ~MF_PAX_SEGMEXEC;
61692 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61693 + flags &= ~MF_PAX_RANDMMAP;
61694 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61695 + flags &= ~MF_PAX_EMUTRAMP;
61696 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61697 + flags &= ~MF_PAX_MPROTECT;
61698 +
61699 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61700 + flags |= MF_PAX_PAGEEXEC;
61701 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61702 + flags |= MF_PAX_SEGMEXEC;
61703 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61704 + flags |= MF_PAX_RANDMMAP;
61705 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61706 + flags |= MF_PAX_EMUTRAMP;
61707 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61708 + flags |= MF_PAX_MPROTECT;
61709 +
61710 + pax_set_flags(task, flags);
61711 +
61712 + return;
61713 +}
61714 +#endif
61715 +
61716 +int
61717 +gr_handle_proc_ptrace(struct task_struct *task)
61718 +{
61719 + struct file *filp;
61720 + struct task_struct *tmp = task;
61721 + struct task_struct *curtemp = current;
61722 + __u32 retmode;
61723 +
61724 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61725 + if (unlikely(!(gr_status & GR_READY)))
61726 + return 0;
61727 +#endif
61728 +
61729 + read_lock(&tasklist_lock);
61730 + read_lock(&grsec_exec_file_lock);
61731 + filp = task->exec_file;
61732 +
61733 + while (task_pid_nr(tmp) > 0) {
61734 + if (tmp == curtemp)
61735 + break;
61736 + tmp = tmp->real_parent;
61737 + }
61738 +
61739 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61740 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61741 + read_unlock(&grsec_exec_file_lock);
61742 + read_unlock(&tasklist_lock);
61743 + return 1;
61744 + }
61745 +
61746 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61747 + if (!(gr_status & GR_READY)) {
61748 + read_unlock(&grsec_exec_file_lock);
61749 + read_unlock(&tasklist_lock);
61750 + return 0;
61751 + }
61752 +#endif
61753 +
61754 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61755 + read_unlock(&grsec_exec_file_lock);
61756 + read_unlock(&tasklist_lock);
61757 +
61758 + if (retmode & GR_NOPTRACE)
61759 + return 1;
61760 +
61761 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61762 + && (current->acl != task->acl || (current->acl != current->role->root_label
61763 + && task_pid_nr(current) != task_pid_nr(task))))
61764 + return 1;
61765 +
61766 + return 0;
61767 +}
61768 +
61769 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61770 +{
61771 + if (unlikely(!(gr_status & GR_READY)))
61772 + return;
61773 +
61774 + if (!(current->role->roletype & GR_ROLE_GOD))
61775 + return;
61776 +
61777 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61778 + p->role->rolename, gr_task_roletype_to_char(p),
61779 + p->acl->filename);
61780 +}
61781 +
61782 +int
61783 +gr_handle_ptrace(struct task_struct *task, const long request)
61784 +{
61785 + struct task_struct *tmp = task;
61786 + struct task_struct *curtemp = current;
61787 + __u32 retmode;
61788 +
61789 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61790 + if (unlikely(!(gr_status & GR_READY)))
61791 + return 0;
61792 +#endif
61793 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61794 + read_lock(&tasklist_lock);
61795 + while (task_pid_nr(tmp) > 0) {
61796 + if (tmp == curtemp)
61797 + break;
61798 + tmp = tmp->real_parent;
61799 + }
61800 +
61801 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61802 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61803 + read_unlock(&tasklist_lock);
61804 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61805 + return 1;
61806 + }
61807 + read_unlock(&tasklist_lock);
61808 + }
61809 +
61810 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61811 + if (!(gr_status & GR_READY))
61812 + return 0;
61813 +#endif
61814 +
61815 + read_lock(&grsec_exec_file_lock);
61816 + if (unlikely(!task->exec_file)) {
61817 + read_unlock(&grsec_exec_file_lock);
61818 + return 0;
61819 + }
61820 +
61821 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61822 + read_unlock(&grsec_exec_file_lock);
61823 +
61824 + if (retmode & GR_NOPTRACE) {
61825 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61826 + return 1;
61827 + }
61828 +
61829 + if (retmode & GR_PTRACERD) {
61830 + switch (request) {
61831 + case PTRACE_SEIZE:
61832 + case PTRACE_POKETEXT:
61833 + case PTRACE_POKEDATA:
61834 + case PTRACE_POKEUSR:
61835 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61836 + case PTRACE_SETREGS:
61837 + case PTRACE_SETFPREGS:
61838 +#endif
61839 +#ifdef CONFIG_X86
61840 + case PTRACE_SETFPXREGS:
61841 +#endif
61842 +#ifdef CONFIG_ALTIVEC
61843 + case PTRACE_SETVRREGS:
61844 +#endif
61845 + return 1;
61846 + default:
61847 + return 0;
61848 + }
61849 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61850 + !(current->role->roletype & GR_ROLE_GOD) &&
61851 + (current->acl != task->acl)) {
61852 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61853 + return 1;
61854 + }
61855 +
61856 + return 0;
61857 +}
61858 +
61859 +static int is_writable_mmap(const struct file *filp)
61860 +{
61861 + struct task_struct *task = current;
61862 + struct acl_object_label *obj, *obj2;
61863 +
61864 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61865 + !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))) {
61866 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61867 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61868 + task->role->root_label);
61869 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61870 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61871 + return 1;
61872 + }
61873 + }
61874 + return 0;
61875 +}
61876 +
61877 +int
61878 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61879 +{
61880 + __u32 mode;
61881 +
61882 + if (unlikely(!file || !(prot & PROT_EXEC)))
61883 + return 1;
61884 +
61885 + if (is_writable_mmap(file))
61886 + return 0;
61887 +
61888 + mode =
61889 + gr_search_file(file->f_path.dentry,
61890 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61891 + file->f_path.mnt);
61892 +
61893 + if (!gr_tpe_allow(file))
61894 + return 0;
61895 +
61896 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61897 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61898 + return 0;
61899 + } else if (unlikely(!(mode & GR_EXEC))) {
61900 + return 0;
61901 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61902 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61903 + return 1;
61904 + }
61905 +
61906 + return 1;
61907 +}
61908 +
61909 +int
61910 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61911 +{
61912 + __u32 mode;
61913 +
61914 + if (unlikely(!file || !(prot & PROT_EXEC)))
61915 + return 1;
61916 +
61917 + if (is_writable_mmap(file))
61918 + return 0;
61919 +
61920 + mode =
61921 + gr_search_file(file->f_path.dentry,
61922 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61923 + file->f_path.mnt);
61924 +
61925 + if (!gr_tpe_allow(file))
61926 + return 0;
61927 +
61928 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61929 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61930 + return 0;
61931 + } else if (unlikely(!(mode & GR_EXEC))) {
61932 + return 0;
61933 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61934 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61935 + return 1;
61936 + }
61937 +
61938 + return 1;
61939 +}
61940 +
61941 +void
61942 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61943 +{
61944 + unsigned long runtime;
61945 + unsigned long cputime;
61946 + unsigned int wday, cday;
61947 + __u8 whr, chr;
61948 + __u8 wmin, cmin;
61949 + __u8 wsec, csec;
61950 + struct timespec timeval;
61951 +
61952 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61953 + !(task->acl->mode & GR_PROCACCT)))
61954 + return;
61955 +
61956 + do_posix_clock_monotonic_gettime(&timeval);
61957 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61958 + wday = runtime / (3600 * 24);
61959 + runtime -= wday * (3600 * 24);
61960 + whr = runtime / 3600;
61961 + runtime -= whr * 3600;
61962 + wmin = runtime / 60;
61963 + runtime -= wmin * 60;
61964 + wsec = runtime;
61965 +
61966 + cputime = (task->utime + task->stime) / HZ;
61967 + cday = cputime / (3600 * 24);
61968 + cputime -= cday * (3600 * 24);
61969 + chr = cputime / 3600;
61970 + cputime -= chr * 3600;
61971 + cmin = cputime / 60;
61972 + cputime -= cmin * 60;
61973 + csec = cputime;
61974 +
61975 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61976 +
61977 + return;
61978 +}
61979 +
61980 +void gr_set_kernel_label(struct task_struct *task)
61981 +{
61982 + if (gr_status & GR_READY) {
61983 + task->role = kernel_role;
61984 + task->acl = kernel_role->root_label;
61985 + }
61986 + return;
61987 +}
61988 +
61989 +#ifdef CONFIG_TASKSTATS
61990 +int gr_is_taskstats_denied(int pid)
61991 +{
61992 + struct task_struct *task;
61993 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61994 + const struct cred *cred;
61995 +#endif
61996 + int ret = 0;
61997 +
61998 + /* restrict taskstats viewing to un-chrooted root users
61999 + who have the 'view' subject flag if the RBAC system is enabled
62000 + */
62001 +
62002 + rcu_read_lock();
62003 + read_lock(&tasklist_lock);
62004 + task = find_task_by_vpid(pid);
62005 + if (task) {
62006 +#ifdef CONFIG_GRKERNSEC_CHROOT
62007 + if (proc_is_chrooted(task))
62008 + ret = -EACCES;
62009 +#endif
62010 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62011 + cred = __task_cred(task);
62012 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62013 + if (gr_is_global_nonroot(cred->uid))
62014 + ret = -EACCES;
62015 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62016 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62017 + ret = -EACCES;
62018 +#endif
62019 +#endif
62020 + if (gr_status & GR_READY) {
62021 + if (!(task->acl->mode & GR_VIEW))
62022 + ret = -EACCES;
62023 + }
62024 + } else
62025 + ret = -ENOENT;
62026 +
62027 + read_unlock(&tasklist_lock);
62028 + rcu_read_unlock();
62029 +
62030 + return ret;
62031 +}
62032 +#endif
62033 +
62034 +/* AUXV entries are filled via a descendant of search_binary_handler
62035 + after we've already applied the subject for the target
62036 +*/
62037 +int gr_acl_enable_at_secure(void)
62038 +{
62039 + if (unlikely(!(gr_status & GR_READY)))
62040 + return 0;
62041 +
62042 + if (current->acl->mode & GR_ATSECURE)
62043 + return 1;
62044 +
62045 + return 0;
62046 +}
62047 +
62048 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62049 +{
62050 + struct task_struct *task = current;
62051 + struct dentry *dentry = file->f_path.dentry;
62052 + struct vfsmount *mnt = file->f_path.mnt;
62053 + struct acl_object_label *obj, *tmp;
62054 + struct acl_subject_label *subj;
62055 + unsigned int bufsize;
62056 + int is_not_root;
62057 + char *path;
62058 + dev_t dev = __get_dev(dentry);
62059 +
62060 + if (unlikely(!(gr_status & GR_READY)))
62061 + return 1;
62062 +
62063 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62064 + return 1;
62065 +
62066 + /* ignore Eric Biederman */
62067 + if (IS_PRIVATE(dentry->d_inode))
62068 + return 1;
62069 +
62070 + subj = task->acl;
62071 + read_lock(&gr_inode_lock);
62072 + do {
62073 + obj = lookup_acl_obj_label(ino, dev, subj);
62074 + if (obj != NULL) {
62075 + read_unlock(&gr_inode_lock);
62076 + return (obj->mode & GR_FIND) ? 1 : 0;
62077 + }
62078 + } while ((subj = subj->parent_subject));
62079 + read_unlock(&gr_inode_lock);
62080 +
62081 + /* this is purely an optimization since we're looking for an object
62082 + for the directory we're doing a readdir on
62083 + if it's possible for any globbed object to match the entry we're
62084 + filling into the directory, then the object we find here will be
62085 + an anchor point with attached globbed objects
62086 + */
62087 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62088 + if (obj->globbed == NULL)
62089 + return (obj->mode & GR_FIND) ? 1 : 0;
62090 +
62091 + is_not_root = ((obj->filename[0] == '/') &&
62092 + (obj->filename[1] == '\0')) ? 0 : 1;
62093 + bufsize = PAGE_SIZE - namelen - is_not_root;
62094 +
62095 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62096 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62097 + return 1;
62098 +
62099 + preempt_disable();
62100 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62101 + bufsize);
62102 +
62103 + bufsize = strlen(path);
62104 +
62105 + /* if base is "/", don't append an additional slash */
62106 + if (is_not_root)
62107 + *(path + bufsize) = '/';
62108 + memcpy(path + bufsize + is_not_root, name, namelen);
62109 + *(path + bufsize + namelen + is_not_root) = '\0';
62110 +
62111 + tmp = obj->globbed;
62112 + while (tmp) {
62113 + if (!glob_match(tmp->filename, path)) {
62114 + preempt_enable();
62115 + return (tmp->mode & GR_FIND) ? 1 : 0;
62116 + }
62117 + tmp = tmp->next;
62118 + }
62119 + preempt_enable();
62120 + return (obj->mode & GR_FIND) ? 1 : 0;
62121 +}
62122 +
62123 +void gr_put_exec_file(struct task_struct *task)
62124 +{
62125 + struct file *filp;
62126 +
62127 + write_lock(&grsec_exec_file_lock);
62128 + filp = task->exec_file;
62129 + task->exec_file = NULL;
62130 + write_unlock(&grsec_exec_file_lock);
62131 +
62132 + if (filp)
62133 + fput(filp);
62134 +
62135 + return;
62136 +}
62137 +
62138 +
62139 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62140 +EXPORT_SYMBOL(gr_acl_is_enabled);
62141 +#endif
62142 +EXPORT_SYMBOL(gr_set_kernel_label);
62143 +#ifdef CONFIG_SECURITY
62144 +EXPORT_SYMBOL(gr_check_user_change);
62145 +EXPORT_SYMBOL(gr_check_group_change);
62146 +#endif
62147 +
62148 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62149 new file mode 100644
62150 index 0000000..34fefda
62151 --- /dev/null
62152 +++ b/grsecurity/gracl_alloc.c
62153 @@ -0,0 +1,105 @@
62154 +#include <linux/kernel.h>
62155 +#include <linux/mm.h>
62156 +#include <linux/slab.h>
62157 +#include <linux/vmalloc.h>
62158 +#include <linux/gracl.h>
62159 +#include <linux/grsecurity.h>
62160 +
62161 +static unsigned long alloc_stack_next = 1;
62162 +static unsigned long alloc_stack_size = 1;
62163 +static void **alloc_stack;
62164 +
62165 +static __inline__ int
62166 +alloc_pop(void)
62167 +{
62168 + if (alloc_stack_next == 1)
62169 + return 0;
62170 +
62171 + kfree(alloc_stack[alloc_stack_next - 2]);
62172 +
62173 + alloc_stack_next--;
62174 +
62175 + return 1;
62176 +}
62177 +
62178 +static __inline__ int
62179 +alloc_push(void *buf)
62180 +{
62181 + if (alloc_stack_next >= alloc_stack_size)
62182 + return 1;
62183 +
62184 + alloc_stack[alloc_stack_next - 1] = buf;
62185 +
62186 + alloc_stack_next++;
62187 +
62188 + return 0;
62189 +}
62190 +
62191 +void *
62192 +acl_alloc(unsigned long len)
62193 +{
62194 + void *ret = NULL;
62195 +
62196 + if (!len || len > PAGE_SIZE)
62197 + goto out;
62198 +
62199 + ret = kmalloc(len, GFP_KERNEL);
62200 +
62201 + if (ret) {
62202 + if (alloc_push(ret)) {
62203 + kfree(ret);
62204 + ret = NULL;
62205 + }
62206 + }
62207 +
62208 +out:
62209 + return ret;
62210 +}
62211 +
62212 +void *
62213 +acl_alloc_num(unsigned long num, unsigned long len)
62214 +{
62215 + if (!len || (num > (PAGE_SIZE / len)))
62216 + return NULL;
62217 +
62218 + return acl_alloc(num * len);
62219 +}
62220 +
62221 +void
62222 +acl_free_all(void)
62223 +{
62224 + if (gr_acl_is_enabled() || !alloc_stack)
62225 + return;
62226 +
62227 + while (alloc_pop()) ;
62228 +
62229 + if (alloc_stack) {
62230 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62231 + kfree(alloc_stack);
62232 + else
62233 + vfree(alloc_stack);
62234 + }
62235 +
62236 + alloc_stack = NULL;
62237 + alloc_stack_size = 1;
62238 + alloc_stack_next = 1;
62239 +
62240 + return;
62241 +}
62242 +
62243 +int
62244 +acl_alloc_stack_init(unsigned long size)
62245 +{
62246 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62247 + alloc_stack =
62248 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62249 + else
62250 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62251 +
62252 + alloc_stack_size = size;
62253 +
62254 + if (!alloc_stack)
62255 + return 0;
62256 + else
62257 + return 1;
62258 +}
62259 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62260 new file mode 100644
62261 index 0000000..bdd51ea
62262 --- /dev/null
62263 +++ b/grsecurity/gracl_cap.c
62264 @@ -0,0 +1,110 @@
62265 +#include <linux/kernel.h>
62266 +#include <linux/module.h>
62267 +#include <linux/sched.h>
62268 +#include <linux/gracl.h>
62269 +#include <linux/grsecurity.h>
62270 +#include <linux/grinternal.h>
62271 +
62272 +extern const char *captab_log[];
62273 +extern int captab_log_entries;
62274 +
62275 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62276 +{
62277 + struct acl_subject_label *curracl;
62278 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62279 + kernel_cap_t cap_audit = __cap_empty_set;
62280 +
62281 + if (!gr_acl_is_enabled())
62282 + return 1;
62283 +
62284 + curracl = task->acl;
62285 +
62286 + cap_drop = curracl->cap_lower;
62287 + cap_mask = curracl->cap_mask;
62288 + cap_audit = curracl->cap_invert_audit;
62289 +
62290 + while ((curracl = curracl->parent_subject)) {
62291 + /* if the cap isn't specified in the current computed mask but is specified in the
62292 + current level subject, and is lowered in the current level subject, then add
62293 + it to the set of dropped capabilities
62294 + otherwise, add the current level subject's mask to the current computed mask
62295 + */
62296 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62297 + cap_raise(cap_mask, cap);
62298 + if (cap_raised(curracl->cap_lower, cap))
62299 + cap_raise(cap_drop, cap);
62300 + if (cap_raised(curracl->cap_invert_audit, cap))
62301 + cap_raise(cap_audit, cap);
62302 + }
62303 + }
62304 +
62305 + if (!cap_raised(cap_drop, cap)) {
62306 + if (cap_raised(cap_audit, cap))
62307 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62308 + return 1;
62309 + }
62310 +
62311 + curracl = task->acl;
62312 +
62313 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62314 + && cap_raised(cred->cap_effective, cap)) {
62315 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62316 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62317 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62318 + gr_to_filename(task->exec_file->f_path.dentry,
62319 + task->exec_file->f_path.mnt) : curracl->filename,
62320 + curracl->filename, 0UL,
62321 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62322 + return 1;
62323 + }
62324 +
62325 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62326 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62327 +
62328 + return 0;
62329 +}
62330 +
62331 +int
62332 +gr_acl_is_capable(const int cap)
62333 +{
62334 + return gr_task_acl_is_capable(current, current_cred(), cap);
62335 +}
62336 +
62337 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62338 +{
62339 + struct acl_subject_label *curracl;
62340 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62341 +
62342 + if (!gr_acl_is_enabled())
62343 + return 1;
62344 +
62345 + curracl = task->acl;
62346 +
62347 + cap_drop = curracl->cap_lower;
62348 + cap_mask = curracl->cap_mask;
62349 +
62350 + while ((curracl = curracl->parent_subject)) {
62351 + /* if the cap isn't specified in the current computed mask but is specified in the
62352 + current level subject, and is lowered in the current level subject, then add
62353 + it to the set of dropped capabilities
62354 + otherwise, add the current level subject's mask to the current computed mask
62355 + */
62356 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62357 + cap_raise(cap_mask, cap);
62358 + if (cap_raised(curracl->cap_lower, cap))
62359 + cap_raise(cap_drop, cap);
62360 + }
62361 + }
62362 +
62363 + if (!cap_raised(cap_drop, cap))
62364 + return 1;
62365 +
62366 + return 0;
62367 +}
62368 +
62369 +int
62370 +gr_acl_is_capable_nolog(const int cap)
62371 +{
62372 + return gr_task_acl_is_capable_nolog(current, cap);
62373 +}
62374 +
62375 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62376 new file mode 100644
62377 index 0000000..a340c17
62378 --- /dev/null
62379 +++ b/grsecurity/gracl_fs.c
62380 @@ -0,0 +1,431 @@
62381 +#include <linux/kernel.h>
62382 +#include <linux/sched.h>
62383 +#include <linux/types.h>
62384 +#include <linux/fs.h>
62385 +#include <linux/file.h>
62386 +#include <linux/stat.h>
62387 +#include <linux/grsecurity.h>
62388 +#include <linux/grinternal.h>
62389 +#include <linux/gracl.h>
62390 +
62391 +umode_t
62392 +gr_acl_umask(void)
62393 +{
62394 + if (unlikely(!gr_acl_is_enabled()))
62395 + return 0;
62396 +
62397 + return current->role->umask;
62398 +}
62399 +
62400 +__u32
62401 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62402 + const struct vfsmount * mnt)
62403 +{
62404 + __u32 mode;
62405 +
62406 + if (unlikely(!dentry->d_inode))
62407 + return GR_FIND;
62408 +
62409 + mode =
62410 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62411 +
62412 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62413 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62414 + return mode;
62415 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62416 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62417 + return 0;
62418 + } else if (unlikely(!(mode & GR_FIND)))
62419 + return 0;
62420 +
62421 + return GR_FIND;
62422 +}
62423 +
62424 +__u32
62425 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62426 + int acc_mode)
62427 +{
62428 + __u32 reqmode = GR_FIND;
62429 + __u32 mode;
62430 +
62431 + if (unlikely(!dentry->d_inode))
62432 + return reqmode;
62433 +
62434 + if (acc_mode & MAY_APPEND)
62435 + reqmode |= GR_APPEND;
62436 + else if (acc_mode & MAY_WRITE)
62437 + reqmode |= GR_WRITE;
62438 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62439 + reqmode |= GR_READ;
62440 +
62441 + mode =
62442 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62443 + mnt);
62444 +
62445 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62446 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62447 + reqmode & GR_READ ? " reading" : "",
62448 + reqmode & GR_WRITE ? " writing" : reqmode &
62449 + GR_APPEND ? " appending" : "");
62450 + return reqmode;
62451 + } else
62452 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62453 + {
62454 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62455 + reqmode & GR_READ ? " reading" : "",
62456 + reqmode & GR_WRITE ? " writing" : reqmode &
62457 + GR_APPEND ? " appending" : "");
62458 + return 0;
62459 + } else if (unlikely((mode & reqmode) != reqmode))
62460 + return 0;
62461 +
62462 + return reqmode;
62463 +}
62464 +
62465 +__u32
62466 +gr_acl_handle_creat(const struct dentry * dentry,
62467 + const struct dentry * p_dentry,
62468 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62469 + const int imode)
62470 +{
62471 + __u32 reqmode = GR_WRITE | GR_CREATE;
62472 + __u32 mode;
62473 +
62474 + if (acc_mode & MAY_APPEND)
62475 + reqmode |= GR_APPEND;
62476 + // if a directory was required or the directory already exists, then
62477 + // don't count this open as a read
62478 + if ((acc_mode & MAY_READ) &&
62479 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62480 + reqmode |= GR_READ;
62481 + if ((open_flags & O_CREAT) &&
62482 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62483 + reqmode |= GR_SETID;
62484 +
62485 + mode =
62486 + gr_check_create(dentry, p_dentry, p_mnt,
62487 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62488 +
62489 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62490 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62491 + reqmode & GR_READ ? " reading" : "",
62492 + reqmode & GR_WRITE ? " writing" : reqmode &
62493 + GR_APPEND ? " appending" : "");
62494 + return reqmode;
62495 + } else
62496 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62497 + {
62498 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62499 + reqmode & GR_READ ? " reading" : "",
62500 + reqmode & GR_WRITE ? " writing" : reqmode &
62501 + GR_APPEND ? " appending" : "");
62502 + return 0;
62503 + } else if (unlikely((mode & reqmode) != reqmode))
62504 + return 0;
62505 +
62506 + return reqmode;
62507 +}
62508 +
62509 +__u32
62510 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62511 + const int fmode)
62512 +{
62513 + __u32 mode, reqmode = GR_FIND;
62514 +
62515 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62516 + reqmode |= GR_EXEC;
62517 + if (fmode & S_IWOTH)
62518 + reqmode |= GR_WRITE;
62519 + if (fmode & S_IROTH)
62520 + reqmode |= GR_READ;
62521 +
62522 + mode =
62523 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62524 + mnt);
62525 +
62526 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62527 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62528 + reqmode & GR_READ ? " reading" : "",
62529 + reqmode & GR_WRITE ? " writing" : "",
62530 + reqmode & GR_EXEC ? " executing" : "");
62531 + return reqmode;
62532 + } else
62533 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62534 + {
62535 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62536 + reqmode & GR_READ ? " reading" : "",
62537 + reqmode & GR_WRITE ? " writing" : "",
62538 + reqmode & GR_EXEC ? " executing" : "");
62539 + return 0;
62540 + } else if (unlikely((mode & reqmode) != reqmode))
62541 + return 0;
62542 +
62543 + return reqmode;
62544 +}
62545 +
62546 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62547 +{
62548 + __u32 mode;
62549 +
62550 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62551 +
62552 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62553 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62554 + return mode;
62555 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62556 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62557 + return 0;
62558 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62559 + return 0;
62560 +
62561 + return (reqmode);
62562 +}
62563 +
62564 +__u32
62565 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62566 +{
62567 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62568 +}
62569 +
62570 +__u32
62571 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62572 +{
62573 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62574 +}
62575 +
62576 +__u32
62577 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62578 +{
62579 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62580 +}
62581 +
62582 +__u32
62583 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62584 +{
62585 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62586 +}
62587 +
62588 +__u32
62589 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62590 + umode_t *modeptr)
62591 +{
62592 + umode_t mode;
62593 +
62594 + *modeptr &= ~gr_acl_umask();
62595 + mode = *modeptr;
62596 +
62597 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62598 + return 1;
62599 +
62600 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62601 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62602 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62603 + GR_CHMOD_ACL_MSG);
62604 + } else {
62605 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62606 + }
62607 +}
62608 +
62609 +__u32
62610 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62611 +{
62612 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62613 +}
62614 +
62615 +__u32
62616 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62617 +{
62618 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62619 +}
62620 +
62621 +__u32
62622 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62623 +{
62624 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62625 +}
62626 +
62627 +__u32
62628 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62629 +{
62630 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62631 + GR_UNIXCONNECT_ACL_MSG);
62632 +}
62633 +
62634 +/* hardlinks require at minimum create and link permission,
62635 + any additional privilege required is based on the
62636 + privilege of the file being linked to
62637 +*/
62638 +__u32
62639 +gr_acl_handle_link(const struct dentry * new_dentry,
62640 + const struct dentry * parent_dentry,
62641 + const struct vfsmount * parent_mnt,
62642 + const struct dentry * old_dentry,
62643 + const struct vfsmount * old_mnt, const struct filename *to)
62644 +{
62645 + __u32 mode;
62646 + __u32 needmode = GR_CREATE | GR_LINK;
62647 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62648 +
62649 + mode =
62650 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62651 + old_mnt);
62652 +
62653 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62654 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62655 + return mode;
62656 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62657 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62658 + return 0;
62659 + } else if (unlikely((mode & needmode) != needmode))
62660 + return 0;
62661 +
62662 + return 1;
62663 +}
62664 +
62665 +__u32
62666 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62667 + const struct dentry * parent_dentry,
62668 + const struct vfsmount * parent_mnt, const struct filename *from)
62669 +{
62670 + __u32 needmode = GR_WRITE | GR_CREATE;
62671 + __u32 mode;
62672 +
62673 + mode =
62674 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62675 + GR_CREATE | GR_AUDIT_CREATE |
62676 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62677 +
62678 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62679 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62680 + return mode;
62681 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62682 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62683 + return 0;
62684 + } else if (unlikely((mode & needmode) != needmode))
62685 + return 0;
62686 +
62687 + return (GR_WRITE | GR_CREATE);
62688 +}
62689 +
62690 +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)
62691 +{
62692 + __u32 mode;
62693 +
62694 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62695 +
62696 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62697 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62698 + return mode;
62699 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62700 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62701 + return 0;
62702 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62703 + return 0;
62704 +
62705 + return (reqmode);
62706 +}
62707 +
62708 +__u32
62709 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62710 + const struct dentry * parent_dentry,
62711 + const struct vfsmount * parent_mnt,
62712 + const int mode)
62713 +{
62714 + __u32 reqmode = GR_WRITE | GR_CREATE;
62715 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62716 + reqmode |= GR_SETID;
62717 +
62718 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62719 + reqmode, GR_MKNOD_ACL_MSG);
62720 +}
62721 +
62722 +__u32
62723 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62724 + const struct dentry *parent_dentry,
62725 + const struct vfsmount *parent_mnt)
62726 +{
62727 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62728 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62729 +}
62730 +
62731 +#define RENAME_CHECK_SUCCESS(old, new) \
62732 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62733 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62734 +
62735 +int
62736 +gr_acl_handle_rename(struct dentry *new_dentry,
62737 + struct dentry *parent_dentry,
62738 + const struct vfsmount *parent_mnt,
62739 + struct dentry *old_dentry,
62740 + struct inode *old_parent_inode,
62741 + struct vfsmount *old_mnt, const struct filename *newname)
62742 +{
62743 + __u32 comp1, comp2;
62744 + int error = 0;
62745 +
62746 + if (unlikely(!gr_acl_is_enabled()))
62747 + return 0;
62748 +
62749 + if (!new_dentry->d_inode) {
62750 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62751 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62752 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62753 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62754 + GR_DELETE | GR_AUDIT_DELETE |
62755 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62756 + GR_SUPPRESS, old_mnt);
62757 + } else {
62758 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62759 + GR_CREATE | GR_DELETE |
62760 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62761 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62762 + GR_SUPPRESS, parent_mnt);
62763 + comp2 =
62764 + gr_search_file(old_dentry,
62765 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62766 + GR_DELETE | GR_AUDIT_DELETE |
62767 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62768 + }
62769 +
62770 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62771 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62772 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62773 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62774 + && !(comp2 & GR_SUPPRESS)) {
62775 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62776 + error = -EACCES;
62777 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62778 + error = -EACCES;
62779 +
62780 + return error;
62781 +}
62782 +
62783 +void
62784 +gr_acl_handle_exit(void)
62785 +{
62786 + u16 id;
62787 + char *rolename;
62788 +
62789 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62790 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62791 + id = current->acl_role_id;
62792 + rolename = current->role->rolename;
62793 + gr_set_acls(1);
62794 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62795 + }
62796 +
62797 + gr_put_exec_file(current);
62798 + return;
62799 +}
62800 +
62801 +int
62802 +gr_acl_handle_procpidmem(const struct task_struct *task)
62803 +{
62804 + if (unlikely(!gr_acl_is_enabled()))
62805 + return 0;
62806 +
62807 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62808 + return -EACCES;
62809 +
62810 + return 0;
62811 +}
62812 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62813 new file mode 100644
62814 index 0000000..8132048
62815 --- /dev/null
62816 +++ b/grsecurity/gracl_ip.c
62817 @@ -0,0 +1,387 @@
62818 +#include <linux/kernel.h>
62819 +#include <asm/uaccess.h>
62820 +#include <asm/errno.h>
62821 +#include <net/sock.h>
62822 +#include <linux/file.h>
62823 +#include <linux/fs.h>
62824 +#include <linux/net.h>
62825 +#include <linux/in.h>
62826 +#include <linux/skbuff.h>
62827 +#include <linux/ip.h>
62828 +#include <linux/udp.h>
62829 +#include <linux/types.h>
62830 +#include <linux/sched.h>
62831 +#include <linux/netdevice.h>
62832 +#include <linux/inetdevice.h>
62833 +#include <linux/gracl.h>
62834 +#include <linux/grsecurity.h>
62835 +#include <linux/grinternal.h>
62836 +
62837 +#define GR_BIND 0x01
62838 +#define GR_CONNECT 0x02
62839 +#define GR_INVERT 0x04
62840 +#define GR_BINDOVERRIDE 0x08
62841 +#define GR_CONNECTOVERRIDE 0x10
62842 +#define GR_SOCK_FAMILY 0x20
62843 +
62844 +static const char * gr_protocols[IPPROTO_MAX] = {
62845 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62846 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62847 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62848 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62849 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62850 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62851 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62852 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62853 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62854 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62855 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62856 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62857 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62858 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62859 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62860 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62861 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62862 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62863 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62864 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62865 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62866 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62867 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62868 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62869 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62870 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62871 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62872 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62873 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62874 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62875 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62876 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62877 + };
62878 +
62879 +static const char * gr_socktypes[SOCK_MAX] = {
62880 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62881 + "unknown:7", "unknown:8", "unknown:9", "packet"
62882 + };
62883 +
62884 +static const char * gr_sockfamilies[AF_MAX+1] = {
62885 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62886 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62887 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62888 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62889 + };
62890 +
62891 +const char *
62892 +gr_proto_to_name(unsigned char proto)
62893 +{
62894 + return gr_protocols[proto];
62895 +}
62896 +
62897 +const char *
62898 +gr_socktype_to_name(unsigned char type)
62899 +{
62900 + return gr_socktypes[type];
62901 +}
62902 +
62903 +const char *
62904 +gr_sockfamily_to_name(unsigned char family)
62905 +{
62906 + return gr_sockfamilies[family];
62907 +}
62908 +
62909 +int
62910 +gr_search_socket(const int domain, const int type, const int protocol)
62911 +{
62912 + struct acl_subject_label *curr;
62913 + const struct cred *cred = current_cred();
62914 +
62915 + if (unlikely(!gr_acl_is_enabled()))
62916 + goto exit;
62917 +
62918 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62919 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62920 + goto exit; // let the kernel handle it
62921 +
62922 + curr = current->acl;
62923 +
62924 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
62925 + /* the family is allowed, if this is PF_INET allow it only if
62926 + the extra sock type/protocol checks pass */
62927 + if (domain == PF_INET)
62928 + goto inet_check;
62929 + goto exit;
62930 + } else {
62931 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62932 + __u32 fakeip = 0;
62933 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62934 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62935 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62936 + gr_to_filename(current->exec_file->f_path.dentry,
62937 + current->exec_file->f_path.mnt) :
62938 + curr->filename, curr->filename,
62939 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62940 + &current->signal->saved_ip);
62941 + goto exit;
62942 + }
62943 + goto exit_fail;
62944 + }
62945 +
62946 +inet_check:
62947 + /* the rest of this checking is for IPv4 only */
62948 + if (!curr->ips)
62949 + goto exit;
62950 +
62951 + if ((curr->ip_type & (1U << type)) &&
62952 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
62953 + goto exit;
62954 +
62955 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62956 + /* we don't place acls on raw sockets , and sometimes
62957 + dgram/ip sockets are opened for ioctl and not
62958 + bind/connect, so we'll fake a bind learn log */
62959 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62960 + __u32 fakeip = 0;
62961 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62962 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62963 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62964 + gr_to_filename(current->exec_file->f_path.dentry,
62965 + current->exec_file->f_path.mnt) :
62966 + curr->filename, curr->filename,
62967 + &fakeip, 0, type,
62968 + protocol, GR_CONNECT, &current->signal->saved_ip);
62969 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62970 + __u32 fakeip = 0;
62971 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62972 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62973 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62974 + gr_to_filename(current->exec_file->f_path.dentry,
62975 + current->exec_file->f_path.mnt) :
62976 + curr->filename, curr->filename,
62977 + &fakeip, 0, type,
62978 + protocol, GR_BIND, &current->signal->saved_ip);
62979 + }
62980 + /* we'll log when they use connect or bind */
62981 + goto exit;
62982 + }
62983 +
62984 +exit_fail:
62985 + if (domain == PF_INET)
62986 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62987 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62988 + else
62989 +#ifndef CONFIG_IPV6
62990 + if (domain != PF_INET6)
62991 +#endif
62992 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62993 + gr_socktype_to_name(type), protocol);
62994 +
62995 + return 0;
62996 +exit:
62997 + return 1;
62998 +}
62999 +
63000 +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)
63001 +{
63002 + if ((ip->mode & mode) &&
63003 + (ip_port >= ip->low) &&
63004 + (ip_port <= ip->high) &&
63005 + ((ntohl(ip_addr) & our_netmask) ==
63006 + (ntohl(our_addr) & our_netmask))
63007 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63008 + && (ip->type & (1U << type))) {
63009 + if (ip->mode & GR_INVERT)
63010 + return 2; // specifically denied
63011 + else
63012 + return 1; // allowed
63013 + }
63014 +
63015 + return 0; // not specifically allowed, may continue parsing
63016 +}
63017 +
63018 +static int
63019 +gr_search_connectbind(const int full_mode, struct sock *sk,
63020 + struct sockaddr_in *addr, const int type)
63021 +{
63022 + char iface[IFNAMSIZ] = {0};
63023 + struct acl_subject_label *curr;
63024 + struct acl_ip_label *ip;
63025 + struct inet_sock *isk;
63026 + struct net_device *dev;
63027 + struct in_device *idev;
63028 + unsigned long i;
63029 + int ret;
63030 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63031 + __u32 ip_addr = 0;
63032 + __u32 our_addr;
63033 + __u32 our_netmask;
63034 + char *p;
63035 + __u16 ip_port = 0;
63036 + const struct cred *cred = current_cred();
63037 +
63038 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63039 + return 0;
63040 +
63041 + curr = current->acl;
63042 + isk = inet_sk(sk);
63043 +
63044 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63045 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63046 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63047 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63048 + struct sockaddr_in saddr;
63049 + int err;
63050 +
63051 + saddr.sin_family = AF_INET;
63052 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63053 + saddr.sin_port = isk->inet_sport;
63054 +
63055 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63056 + if (err)
63057 + return err;
63058 +
63059 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63060 + if (err)
63061 + return err;
63062 + }
63063 +
63064 + if (!curr->ips)
63065 + return 0;
63066 +
63067 + ip_addr = addr->sin_addr.s_addr;
63068 + ip_port = ntohs(addr->sin_port);
63069 +
63070 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63071 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63072 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63073 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63074 + gr_to_filename(current->exec_file->f_path.dentry,
63075 + current->exec_file->f_path.mnt) :
63076 + curr->filename, curr->filename,
63077 + &ip_addr, ip_port, type,
63078 + sk->sk_protocol, mode, &current->signal->saved_ip);
63079 + return 0;
63080 + }
63081 +
63082 + for (i = 0; i < curr->ip_num; i++) {
63083 + ip = *(curr->ips + i);
63084 + if (ip->iface != NULL) {
63085 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63086 + p = strchr(iface, ':');
63087 + if (p != NULL)
63088 + *p = '\0';
63089 + dev = dev_get_by_name(sock_net(sk), iface);
63090 + if (dev == NULL)
63091 + continue;
63092 + idev = in_dev_get(dev);
63093 + if (idev == NULL) {
63094 + dev_put(dev);
63095 + continue;
63096 + }
63097 + rcu_read_lock();
63098 + for_ifa(idev) {
63099 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63100 + our_addr = ifa->ifa_address;
63101 + our_netmask = 0xffffffff;
63102 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63103 + if (ret == 1) {
63104 + rcu_read_unlock();
63105 + in_dev_put(idev);
63106 + dev_put(dev);
63107 + return 0;
63108 + } else if (ret == 2) {
63109 + rcu_read_unlock();
63110 + in_dev_put(idev);
63111 + dev_put(dev);
63112 + goto denied;
63113 + }
63114 + }
63115 + } endfor_ifa(idev);
63116 + rcu_read_unlock();
63117 + in_dev_put(idev);
63118 + dev_put(dev);
63119 + } else {
63120 + our_addr = ip->addr;
63121 + our_netmask = ip->netmask;
63122 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63123 + if (ret == 1)
63124 + return 0;
63125 + else if (ret == 2)
63126 + goto denied;
63127 + }
63128 + }
63129 +
63130 +denied:
63131 + if (mode == GR_BIND)
63132 + 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));
63133 + else if (mode == GR_CONNECT)
63134 + 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));
63135 +
63136 + return -EACCES;
63137 +}
63138 +
63139 +int
63140 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63141 +{
63142 + /* always allow disconnection of dgram sockets with connect */
63143 + if (addr->sin_family == AF_UNSPEC)
63144 + return 0;
63145 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63146 +}
63147 +
63148 +int
63149 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63150 +{
63151 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63152 +}
63153 +
63154 +int gr_search_listen(struct socket *sock)
63155 +{
63156 + struct sock *sk = sock->sk;
63157 + struct sockaddr_in addr;
63158 +
63159 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63160 + addr.sin_port = inet_sk(sk)->inet_sport;
63161 +
63162 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63163 +}
63164 +
63165 +int gr_search_accept(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
63177 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63178 +{
63179 + if (addr)
63180 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63181 + else {
63182 + struct sockaddr_in sin;
63183 + const struct inet_sock *inet = inet_sk(sk);
63184 +
63185 + sin.sin_addr.s_addr = inet->inet_daddr;
63186 + sin.sin_port = inet->inet_dport;
63187 +
63188 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63189 + }
63190 +}
63191 +
63192 +int
63193 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63194 +{
63195 + struct sockaddr_in sin;
63196 +
63197 + if (unlikely(skb->len < sizeof (struct udphdr)))
63198 + return 0; // skip this packet
63199 +
63200 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63201 + sin.sin_port = udp_hdr(skb)->source;
63202 +
63203 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63204 +}
63205 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63206 new file mode 100644
63207 index 0000000..25f54ef
63208 --- /dev/null
63209 +++ b/grsecurity/gracl_learn.c
63210 @@ -0,0 +1,207 @@
63211 +#include <linux/kernel.h>
63212 +#include <linux/mm.h>
63213 +#include <linux/sched.h>
63214 +#include <linux/poll.h>
63215 +#include <linux/string.h>
63216 +#include <linux/file.h>
63217 +#include <linux/types.h>
63218 +#include <linux/vmalloc.h>
63219 +#include <linux/grinternal.h>
63220 +
63221 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63222 + size_t count, loff_t *ppos);
63223 +extern int gr_acl_is_enabled(void);
63224 +
63225 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63226 +static int gr_learn_attached;
63227 +
63228 +/* use a 512k buffer */
63229 +#define LEARN_BUFFER_SIZE (512 * 1024)
63230 +
63231 +static DEFINE_SPINLOCK(gr_learn_lock);
63232 +static DEFINE_MUTEX(gr_learn_user_mutex);
63233 +
63234 +/* we need to maintain two buffers, so that the kernel context of grlearn
63235 + uses a semaphore around the userspace copying, and the other kernel contexts
63236 + use a spinlock when copying into the buffer, since they cannot sleep
63237 +*/
63238 +static char *learn_buffer;
63239 +static char *learn_buffer_user;
63240 +static int learn_buffer_len;
63241 +static int learn_buffer_user_len;
63242 +
63243 +static ssize_t
63244 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63245 +{
63246 + DECLARE_WAITQUEUE(wait, current);
63247 + ssize_t retval = 0;
63248 +
63249 + add_wait_queue(&learn_wait, &wait);
63250 + set_current_state(TASK_INTERRUPTIBLE);
63251 + do {
63252 + mutex_lock(&gr_learn_user_mutex);
63253 + spin_lock(&gr_learn_lock);
63254 + if (learn_buffer_len)
63255 + break;
63256 + spin_unlock(&gr_learn_lock);
63257 + mutex_unlock(&gr_learn_user_mutex);
63258 + if (file->f_flags & O_NONBLOCK) {
63259 + retval = -EAGAIN;
63260 + goto out;
63261 + }
63262 + if (signal_pending(current)) {
63263 + retval = -ERESTARTSYS;
63264 + goto out;
63265 + }
63266 +
63267 + schedule();
63268 + } while (1);
63269 +
63270 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63271 + learn_buffer_user_len = learn_buffer_len;
63272 + retval = learn_buffer_len;
63273 + learn_buffer_len = 0;
63274 +
63275 + spin_unlock(&gr_learn_lock);
63276 +
63277 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63278 + retval = -EFAULT;
63279 +
63280 + mutex_unlock(&gr_learn_user_mutex);
63281 +out:
63282 + set_current_state(TASK_RUNNING);
63283 + remove_wait_queue(&learn_wait, &wait);
63284 + return retval;
63285 +}
63286 +
63287 +static unsigned int
63288 +poll_learn(struct file * file, poll_table * wait)
63289 +{
63290 + poll_wait(file, &learn_wait, wait);
63291 +
63292 + if (learn_buffer_len)
63293 + return (POLLIN | POLLRDNORM);
63294 +
63295 + return 0;
63296 +}
63297 +
63298 +void
63299 +gr_clear_learn_entries(void)
63300 +{
63301 + char *tmp;
63302 +
63303 + mutex_lock(&gr_learn_user_mutex);
63304 + spin_lock(&gr_learn_lock);
63305 + tmp = learn_buffer;
63306 + learn_buffer = NULL;
63307 + spin_unlock(&gr_learn_lock);
63308 + if (tmp)
63309 + vfree(tmp);
63310 + if (learn_buffer_user != NULL) {
63311 + vfree(learn_buffer_user);
63312 + learn_buffer_user = NULL;
63313 + }
63314 + learn_buffer_len = 0;
63315 + mutex_unlock(&gr_learn_user_mutex);
63316 +
63317 + return;
63318 +}
63319 +
63320 +void
63321 +gr_add_learn_entry(const char *fmt, ...)
63322 +{
63323 + va_list args;
63324 + unsigned int len;
63325 +
63326 + if (!gr_learn_attached)
63327 + return;
63328 +
63329 + spin_lock(&gr_learn_lock);
63330 +
63331 + /* leave a gap at the end so we know when it's "full" but don't have to
63332 + compute the exact length of the string we're trying to append
63333 + */
63334 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63335 + spin_unlock(&gr_learn_lock);
63336 + wake_up_interruptible(&learn_wait);
63337 + return;
63338 + }
63339 + if (learn_buffer == NULL) {
63340 + spin_unlock(&gr_learn_lock);
63341 + return;
63342 + }
63343 +
63344 + va_start(args, fmt);
63345 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63346 + va_end(args);
63347 +
63348 + learn_buffer_len += len + 1;
63349 +
63350 + spin_unlock(&gr_learn_lock);
63351 + wake_up_interruptible(&learn_wait);
63352 +
63353 + return;
63354 +}
63355 +
63356 +static int
63357 +open_learn(struct inode *inode, struct file *file)
63358 +{
63359 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63360 + return -EBUSY;
63361 + if (file->f_mode & FMODE_READ) {
63362 + int retval = 0;
63363 + mutex_lock(&gr_learn_user_mutex);
63364 + if (learn_buffer == NULL)
63365 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63366 + if (learn_buffer_user == NULL)
63367 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63368 + if (learn_buffer == NULL) {
63369 + retval = -ENOMEM;
63370 + goto out_error;
63371 + }
63372 + if (learn_buffer_user == NULL) {
63373 + retval = -ENOMEM;
63374 + goto out_error;
63375 + }
63376 + learn_buffer_len = 0;
63377 + learn_buffer_user_len = 0;
63378 + gr_learn_attached = 1;
63379 +out_error:
63380 + mutex_unlock(&gr_learn_user_mutex);
63381 + return retval;
63382 + }
63383 + return 0;
63384 +}
63385 +
63386 +static int
63387 +close_learn(struct inode *inode, struct file *file)
63388 +{
63389 + if (file->f_mode & FMODE_READ) {
63390 + char *tmp = NULL;
63391 + mutex_lock(&gr_learn_user_mutex);
63392 + spin_lock(&gr_learn_lock);
63393 + tmp = learn_buffer;
63394 + learn_buffer = NULL;
63395 + spin_unlock(&gr_learn_lock);
63396 + if (tmp)
63397 + vfree(tmp);
63398 + if (learn_buffer_user != NULL) {
63399 + vfree(learn_buffer_user);
63400 + learn_buffer_user = NULL;
63401 + }
63402 + learn_buffer_len = 0;
63403 + learn_buffer_user_len = 0;
63404 + gr_learn_attached = 0;
63405 + mutex_unlock(&gr_learn_user_mutex);
63406 + }
63407 +
63408 + return 0;
63409 +}
63410 +
63411 +const struct file_operations grsec_fops = {
63412 + .read = read_learn,
63413 + .write = write_grsec_handler,
63414 + .open = open_learn,
63415 + .release = close_learn,
63416 + .poll = poll_learn,
63417 +};
63418 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63419 new file mode 100644
63420 index 0000000..39645c9
63421 --- /dev/null
63422 +++ b/grsecurity/gracl_res.c
63423 @@ -0,0 +1,68 @@
63424 +#include <linux/kernel.h>
63425 +#include <linux/sched.h>
63426 +#include <linux/gracl.h>
63427 +#include <linux/grinternal.h>
63428 +
63429 +static const char *restab_log[] = {
63430 + [RLIMIT_CPU] = "RLIMIT_CPU",
63431 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63432 + [RLIMIT_DATA] = "RLIMIT_DATA",
63433 + [RLIMIT_STACK] = "RLIMIT_STACK",
63434 + [RLIMIT_CORE] = "RLIMIT_CORE",
63435 + [RLIMIT_RSS] = "RLIMIT_RSS",
63436 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63437 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63438 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63439 + [RLIMIT_AS] = "RLIMIT_AS",
63440 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63441 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63442 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63443 + [RLIMIT_NICE] = "RLIMIT_NICE",
63444 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63445 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63446 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63447 +};
63448 +
63449 +void
63450 +gr_log_resource(const struct task_struct *task,
63451 + const int res, const unsigned long wanted, const int gt)
63452 +{
63453 + const struct cred *cred;
63454 + unsigned long rlim;
63455 +
63456 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63457 + return;
63458 +
63459 + // not yet supported resource
63460 + if (unlikely(!restab_log[res]))
63461 + return;
63462 +
63463 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63464 + rlim = task_rlimit_max(task, res);
63465 + else
63466 + rlim = task_rlimit(task, res);
63467 +
63468 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63469 + return;
63470 +
63471 + rcu_read_lock();
63472 + cred = __task_cred(task);
63473 +
63474 + if (res == RLIMIT_NPROC &&
63475 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63476 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63477 + goto out_rcu_unlock;
63478 + else if (res == RLIMIT_MEMLOCK &&
63479 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63480 + goto out_rcu_unlock;
63481 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63482 + goto out_rcu_unlock;
63483 + rcu_read_unlock();
63484 +
63485 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63486 +
63487 + return;
63488 +out_rcu_unlock:
63489 + rcu_read_unlock();
63490 + return;
63491 +}
63492 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63493 new file mode 100644
63494 index 0000000..cb1e5ab
63495 --- /dev/null
63496 +++ b/grsecurity/gracl_segv.c
63497 @@ -0,0 +1,303 @@
63498 +#include <linux/kernel.h>
63499 +#include <linux/mm.h>
63500 +#include <asm/uaccess.h>
63501 +#include <asm/errno.h>
63502 +#include <asm/mman.h>
63503 +#include <net/sock.h>
63504 +#include <linux/file.h>
63505 +#include <linux/fs.h>
63506 +#include <linux/net.h>
63507 +#include <linux/in.h>
63508 +#include <linux/slab.h>
63509 +#include <linux/types.h>
63510 +#include <linux/sched.h>
63511 +#include <linux/timer.h>
63512 +#include <linux/gracl.h>
63513 +#include <linux/grsecurity.h>
63514 +#include <linux/grinternal.h>
63515 +
63516 +static struct crash_uid *uid_set;
63517 +static unsigned short uid_used;
63518 +static DEFINE_SPINLOCK(gr_uid_lock);
63519 +extern rwlock_t gr_inode_lock;
63520 +extern struct acl_subject_label *
63521 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63522 + struct acl_role_label *role);
63523 +
63524 +#ifdef CONFIG_BTRFS_FS
63525 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
63526 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
63527 +#endif
63528 +
63529 +static inline dev_t __get_dev(const struct dentry *dentry)
63530 +{
63531 +#ifdef CONFIG_BTRFS_FS
63532 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
63533 + return get_btrfs_dev_from_inode(dentry->d_inode);
63534 + else
63535 +#endif
63536 + return dentry->d_inode->i_sb->s_dev;
63537 +}
63538 +
63539 +int
63540 +gr_init_uidset(void)
63541 +{
63542 + uid_set =
63543 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63544 + uid_used = 0;
63545 +
63546 + return uid_set ? 1 : 0;
63547 +}
63548 +
63549 +void
63550 +gr_free_uidset(void)
63551 +{
63552 + if (uid_set)
63553 + kfree(uid_set);
63554 +
63555 + return;
63556 +}
63557 +
63558 +int
63559 +gr_find_uid(const uid_t uid)
63560 +{
63561 + struct crash_uid *tmp = uid_set;
63562 + uid_t buid;
63563 + int low = 0, high = uid_used - 1, mid;
63564 +
63565 + while (high >= low) {
63566 + mid = (low + high) >> 1;
63567 + buid = tmp[mid].uid;
63568 + if (buid == uid)
63569 + return mid;
63570 + if (buid > uid)
63571 + high = mid - 1;
63572 + if (buid < uid)
63573 + low = mid + 1;
63574 + }
63575 +
63576 + return -1;
63577 +}
63578 +
63579 +static __inline__ void
63580 +gr_insertsort(void)
63581 +{
63582 + unsigned short i, j;
63583 + struct crash_uid index;
63584 +
63585 + for (i = 1; i < uid_used; i++) {
63586 + index = uid_set[i];
63587 + j = i;
63588 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63589 + uid_set[j] = uid_set[j - 1];
63590 + j--;
63591 + }
63592 + uid_set[j] = index;
63593 + }
63594 +
63595 + return;
63596 +}
63597 +
63598 +static __inline__ void
63599 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63600 +{
63601 + int loc;
63602 + uid_t uid = GR_GLOBAL_UID(kuid);
63603 +
63604 + if (uid_used == GR_UIDTABLE_MAX)
63605 + return;
63606 +
63607 + loc = gr_find_uid(uid);
63608 +
63609 + if (loc >= 0) {
63610 + uid_set[loc].expires = expires;
63611 + return;
63612 + }
63613 +
63614 + uid_set[uid_used].uid = uid;
63615 + uid_set[uid_used].expires = expires;
63616 + uid_used++;
63617 +
63618 + gr_insertsort();
63619 +
63620 + return;
63621 +}
63622 +
63623 +void
63624 +gr_remove_uid(const unsigned short loc)
63625 +{
63626 + unsigned short i;
63627 +
63628 + for (i = loc + 1; i < uid_used; i++)
63629 + uid_set[i - 1] = uid_set[i];
63630 +
63631 + uid_used--;
63632 +
63633 + return;
63634 +}
63635 +
63636 +int
63637 +gr_check_crash_uid(const kuid_t kuid)
63638 +{
63639 + int loc;
63640 + int ret = 0;
63641 + uid_t uid;
63642 +
63643 + if (unlikely(!gr_acl_is_enabled()))
63644 + return 0;
63645 +
63646 + uid = GR_GLOBAL_UID(kuid);
63647 +
63648 + spin_lock(&gr_uid_lock);
63649 + loc = gr_find_uid(uid);
63650 +
63651 + if (loc < 0)
63652 + goto out_unlock;
63653 +
63654 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63655 + gr_remove_uid(loc);
63656 + else
63657 + ret = 1;
63658 +
63659 +out_unlock:
63660 + spin_unlock(&gr_uid_lock);
63661 + return ret;
63662 +}
63663 +
63664 +static __inline__ int
63665 +proc_is_setxid(const struct cred *cred)
63666 +{
63667 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63668 + !uid_eq(cred->uid, cred->fsuid))
63669 + return 1;
63670 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63671 + !gid_eq(cred->gid, cred->fsgid))
63672 + return 1;
63673 +
63674 + return 0;
63675 +}
63676 +
63677 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63678 +
63679 +void
63680 +gr_handle_crash(struct task_struct *task, const int sig)
63681 +{
63682 + struct acl_subject_label *curr;
63683 + struct task_struct *tsk, *tsk2;
63684 + const struct cred *cred;
63685 + const struct cred *cred2;
63686 +
63687 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63688 + return;
63689 +
63690 + if (unlikely(!gr_acl_is_enabled()))
63691 + return;
63692 +
63693 + curr = task->acl;
63694 +
63695 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63696 + return;
63697 +
63698 + if (time_before_eq(curr->expires, get_seconds())) {
63699 + curr->expires = 0;
63700 + curr->crashes = 0;
63701 + }
63702 +
63703 + curr->crashes++;
63704 +
63705 + if (!curr->expires)
63706 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63707 +
63708 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63709 + time_after(curr->expires, get_seconds())) {
63710 + rcu_read_lock();
63711 + cred = __task_cred(task);
63712 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63713 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63714 + spin_lock(&gr_uid_lock);
63715 + gr_insert_uid(cred->uid, curr->expires);
63716 + spin_unlock(&gr_uid_lock);
63717 + curr->expires = 0;
63718 + curr->crashes = 0;
63719 + read_lock(&tasklist_lock);
63720 + do_each_thread(tsk2, tsk) {
63721 + cred2 = __task_cred(tsk);
63722 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63723 + gr_fake_force_sig(SIGKILL, tsk);
63724 + } while_each_thread(tsk2, tsk);
63725 + read_unlock(&tasklist_lock);
63726 + } else {
63727 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63728 + read_lock(&tasklist_lock);
63729 + read_lock(&grsec_exec_file_lock);
63730 + do_each_thread(tsk2, tsk) {
63731 + if (likely(tsk != task)) {
63732 + // if this thread has the same subject as the one that triggered
63733 + // RES_CRASH and it's the same binary, kill it
63734 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63735 + gr_fake_force_sig(SIGKILL, tsk);
63736 + }
63737 + } while_each_thread(tsk2, tsk);
63738 + read_unlock(&grsec_exec_file_lock);
63739 + read_unlock(&tasklist_lock);
63740 + }
63741 + rcu_read_unlock();
63742 + }
63743 +
63744 + return;
63745 +}
63746 +
63747 +int
63748 +gr_check_crash_exec(const struct file *filp)
63749 +{
63750 + struct acl_subject_label *curr;
63751 +
63752 + if (unlikely(!gr_acl_is_enabled()))
63753 + return 0;
63754 +
63755 + read_lock(&gr_inode_lock);
63756 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63757 + __get_dev(filp->f_path.dentry),
63758 + current->role);
63759 + read_unlock(&gr_inode_lock);
63760 +
63761 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63762 + (!curr->crashes && !curr->expires))
63763 + return 0;
63764 +
63765 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63766 + time_after(curr->expires, get_seconds()))
63767 + return 1;
63768 + else if (time_before_eq(curr->expires, get_seconds())) {
63769 + curr->crashes = 0;
63770 + curr->expires = 0;
63771 + }
63772 +
63773 + return 0;
63774 +}
63775 +
63776 +void
63777 +gr_handle_alertkill(struct task_struct *task)
63778 +{
63779 + struct acl_subject_label *curracl;
63780 + __u32 curr_ip;
63781 + struct task_struct *p, *p2;
63782 +
63783 + if (unlikely(!gr_acl_is_enabled()))
63784 + return;
63785 +
63786 + curracl = task->acl;
63787 + curr_ip = task->signal->curr_ip;
63788 +
63789 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63790 + read_lock(&tasklist_lock);
63791 + do_each_thread(p2, p) {
63792 + if (p->signal->curr_ip == curr_ip)
63793 + gr_fake_force_sig(SIGKILL, p);
63794 + } while_each_thread(p2, p);
63795 + read_unlock(&tasklist_lock);
63796 + } else if (curracl->mode & GR_KILLPROC)
63797 + gr_fake_force_sig(SIGKILL, task);
63798 +
63799 + return;
63800 +}
63801 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63802 new file mode 100644
63803 index 0000000..98011b0
63804 --- /dev/null
63805 +++ b/grsecurity/gracl_shm.c
63806 @@ -0,0 +1,40 @@
63807 +#include <linux/kernel.h>
63808 +#include <linux/mm.h>
63809 +#include <linux/sched.h>
63810 +#include <linux/file.h>
63811 +#include <linux/ipc.h>
63812 +#include <linux/gracl.h>
63813 +#include <linux/grsecurity.h>
63814 +#include <linux/grinternal.h>
63815 +
63816 +int
63817 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63818 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63819 +{
63820 + struct task_struct *task;
63821 +
63822 + if (!gr_acl_is_enabled())
63823 + return 1;
63824 +
63825 + rcu_read_lock();
63826 + read_lock(&tasklist_lock);
63827 +
63828 + task = find_task_by_vpid(shm_cprid);
63829 +
63830 + if (unlikely(!task))
63831 + task = find_task_by_vpid(shm_lapid);
63832 +
63833 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63834 + (task_pid_nr(task) == shm_lapid)) &&
63835 + (task->acl->mode & GR_PROTSHM) &&
63836 + (task->acl != current->acl))) {
63837 + read_unlock(&tasklist_lock);
63838 + rcu_read_unlock();
63839 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63840 + return 0;
63841 + }
63842 + read_unlock(&tasklist_lock);
63843 + rcu_read_unlock();
63844 +
63845 + return 1;
63846 +}
63847 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63848 new file mode 100644
63849 index 0000000..bc0be01
63850 --- /dev/null
63851 +++ b/grsecurity/grsec_chdir.c
63852 @@ -0,0 +1,19 @@
63853 +#include <linux/kernel.h>
63854 +#include <linux/sched.h>
63855 +#include <linux/fs.h>
63856 +#include <linux/file.h>
63857 +#include <linux/grsecurity.h>
63858 +#include <linux/grinternal.h>
63859 +
63860 +void
63861 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63862 +{
63863 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63864 + if ((grsec_enable_chdir && grsec_enable_group &&
63865 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63866 + !grsec_enable_group)) {
63867 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63868 + }
63869 +#endif
63870 + return;
63871 +}
63872 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63873 new file mode 100644
63874 index 0000000..6d2de57
63875 --- /dev/null
63876 +++ b/grsecurity/grsec_chroot.c
63877 @@ -0,0 +1,357 @@
63878 +#include <linux/kernel.h>
63879 +#include <linux/module.h>
63880 +#include <linux/sched.h>
63881 +#include <linux/file.h>
63882 +#include <linux/fs.h>
63883 +#include <linux/mount.h>
63884 +#include <linux/types.h>
63885 +#include "../fs/mount.h"
63886 +#include <linux/grsecurity.h>
63887 +#include <linux/grinternal.h>
63888 +
63889 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
63890 +{
63891 +#ifdef CONFIG_GRKERNSEC
63892 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63893 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
63894 + task->gr_is_chrooted = 1;
63895 + else
63896 + task->gr_is_chrooted = 0;
63897 +
63898 + task->gr_chroot_dentry = path->dentry;
63899 +#endif
63900 + return;
63901 +}
63902 +
63903 +void gr_clear_chroot_entries(struct task_struct *task)
63904 +{
63905 +#ifdef CONFIG_GRKERNSEC
63906 + task->gr_is_chrooted = 0;
63907 + task->gr_chroot_dentry = NULL;
63908 +#endif
63909 + return;
63910 +}
63911 +
63912 +int
63913 +gr_handle_chroot_unix(const pid_t pid)
63914 +{
63915 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63916 + struct task_struct *p;
63917 +
63918 + if (unlikely(!grsec_enable_chroot_unix))
63919 + return 1;
63920 +
63921 + if (likely(!proc_is_chrooted(current)))
63922 + return 1;
63923 +
63924 + rcu_read_lock();
63925 + read_lock(&tasklist_lock);
63926 + p = find_task_by_vpid_unrestricted(pid);
63927 + if (unlikely(p && !have_same_root(current, p))) {
63928 + read_unlock(&tasklist_lock);
63929 + rcu_read_unlock();
63930 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63931 + return 0;
63932 + }
63933 + read_unlock(&tasklist_lock);
63934 + rcu_read_unlock();
63935 +#endif
63936 + return 1;
63937 +}
63938 +
63939 +int
63940 +gr_handle_chroot_nice(void)
63941 +{
63942 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63943 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63944 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63945 + return -EPERM;
63946 + }
63947 +#endif
63948 + return 0;
63949 +}
63950 +
63951 +int
63952 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63953 +{
63954 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63955 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63956 + && proc_is_chrooted(current)) {
63957 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63958 + return -EACCES;
63959 + }
63960 +#endif
63961 + return 0;
63962 +}
63963 +
63964 +int
63965 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63966 +{
63967 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63968 + struct task_struct *p;
63969 + int ret = 0;
63970 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63971 + return ret;
63972 +
63973 + read_lock(&tasklist_lock);
63974 + do_each_pid_task(pid, type, p) {
63975 + if (!have_same_root(current, p)) {
63976 + ret = 1;
63977 + goto out;
63978 + }
63979 + } while_each_pid_task(pid, type, p);
63980 +out:
63981 + read_unlock(&tasklist_lock);
63982 + return ret;
63983 +#endif
63984 + return 0;
63985 +}
63986 +
63987 +int
63988 +gr_pid_is_chrooted(struct task_struct *p)
63989 +{
63990 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63991 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
63992 + return 0;
63993 +
63994 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
63995 + !have_same_root(current, p)) {
63996 + return 1;
63997 + }
63998 +#endif
63999 + return 0;
64000 +}
64001 +
64002 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64003 +
64004 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64005 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64006 +{
64007 + struct path path, currentroot;
64008 + int ret = 0;
64009 +
64010 + path.dentry = (struct dentry *)u_dentry;
64011 + path.mnt = (struct vfsmount *)u_mnt;
64012 + get_fs_root(current->fs, &currentroot);
64013 + if (path_is_under(&path, &currentroot))
64014 + ret = 1;
64015 + path_put(&currentroot);
64016 +
64017 + return ret;
64018 +}
64019 +#endif
64020 +
64021 +int
64022 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64023 +{
64024 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64025 + if (!grsec_enable_chroot_fchdir)
64026 + return 1;
64027 +
64028 + if (!proc_is_chrooted(current))
64029 + return 1;
64030 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64031 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64032 + return 0;
64033 + }
64034 +#endif
64035 + return 1;
64036 +}
64037 +
64038 +int
64039 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64040 + const time_t shm_createtime)
64041 +{
64042 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64043 + struct task_struct *p;
64044 + time_t starttime;
64045 +
64046 + if (unlikely(!grsec_enable_chroot_shmat))
64047 + return 1;
64048 +
64049 + if (likely(!proc_is_chrooted(current)))
64050 + return 1;
64051 +
64052 + rcu_read_lock();
64053 + read_lock(&tasklist_lock);
64054 +
64055 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64056 + starttime = p->start_time.tv_sec;
64057 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64058 + if (have_same_root(current, p)) {
64059 + goto allow;
64060 + } else {
64061 + read_unlock(&tasklist_lock);
64062 + rcu_read_unlock();
64063 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64064 + return 0;
64065 + }
64066 + }
64067 + /* creator exited, pid reuse, fall through to next check */
64068 + }
64069 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64070 + if (unlikely(!have_same_root(current, p))) {
64071 + read_unlock(&tasklist_lock);
64072 + rcu_read_unlock();
64073 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64074 + return 0;
64075 + }
64076 + }
64077 +
64078 +allow:
64079 + read_unlock(&tasklist_lock);
64080 + rcu_read_unlock();
64081 +#endif
64082 + return 1;
64083 +}
64084 +
64085 +void
64086 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64087 +{
64088 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64089 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64090 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64091 +#endif
64092 + return;
64093 +}
64094 +
64095 +int
64096 +gr_handle_chroot_mknod(const struct dentry *dentry,
64097 + const struct vfsmount *mnt, const int mode)
64098 +{
64099 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64100 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64101 + proc_is_chrooted(current)) {
64102 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64103 + return -EPERM;
64104 + }
64105 +#endif
64106 + return 0;
64107 +}
64108 +
64109 +int
64110 +gr_handle_chroot_mount(const struct dentry *dentry,
64111 + const struct vfsmount *mnt, const char *dev_name)
64112 +{
64113 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64114 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64115 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64116 + return -EPERM;
64117 + }
64118 +#endif
64119 + return 0;
64120 +}
64121 +
64122 +int
64123 +gr_handle_chroot_pivot(void)
64124 +{
64125 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64126 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64127 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64128 + return -EPERM;
64129 + }
64130 +#endif
64131 + return 0;
64132 +}
64133 +
64134 +int
64135 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64136 +{
64137 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64138 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64139 + !gr_is_outside_chroot(dentry, mnt)) {
64140 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64141 + return -EPERM;
64142 + }
64143 +#endif
64144 + return 0;
64145 +}
64146 +
64147 +extern const char *captab_log[];
64148 +extern int captab_log_entries;
64149 +
64150 +int
64151 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64152 +{
64153 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64154 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64155 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64156 + if (cap_raised(chroot_caps, cap)) {
64157 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64158 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64159 + }
64160 + return 0;
64161 + }
64162 + }
64163 +#endif
64164 + return 1;
64165 +}
64166 +
64167 +int
64168 +gr_chroot_is_capable(const int cap)
64169 +{
64170 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64171 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64172 +#endif
64173 + return 1;
64174 +}
64175 +
64176 +int
64177 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64178 +{
64179 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64180 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64181 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64182 + if (cap_raised(chroot_caps, cap)) {
64183 + return 0;
64184 + }
64185 + }
64186 +#endif
64187 + return 1;
64188 +}
64189 +
64190 +int
64191 +gr_chroot_is_capable_nolog(const int cap)
64192 +{
64193 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64194 + return gr_task_chroot_is_capable_nolog(current, cap);
64195 +#endif
64196 + return 1;
64197 +}
64198 +
64199 +int
64200 +gr_handle_chroot_sysctl(const int op)
64201 +{
64202 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64203 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64204 + proc_is_chrooted(current))
64205 + return -EACCES;
64206 +#endif
64207 + return 0;
64208 +}
64209 +
64210 +void
64211 +gr_handle_chroot_chdir(struct path *path)
64212 +{
64213 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64214 + if (grsec_enable_chroot_chdir)
64215 + set_fs_pwd(current->fs, path);
64216 +#endif
64217 + return;
64218 +}
64219 +
64220 +int
64221 +gr_handle_chroot_chmod(const struct dentry *dentry,
64222 + const struct vfsmount *mnt, const int mode)
64223 +{
64224 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64225 + /* allow chmod +s on directories, but not files */
64226 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64227 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64228 + proc_is_chrooted(current)) {
64229 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64230 + return -EPERM;
64231 + }
64232 +#endif
64233 + return 0;
64234 +}
64235 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64236 new file mode 100644
64237 index 0000000..207d409
64238 --- /dev/null
64239 +++ b/grsecurity/grsec_disabled.c
64240 @@ -0,0 +1,434 @@
64241 +#include <linux/kernel.h>
64242 +#include <linux/module.h>
64243 +#include <linux/sched.h>
64244 +#include <linux/file.h>
64245 +#include <linux/fs.h>
64246 +#include <linux/kdev_t.h>
64247 +#include <linux/net.h>
64248 +#include <linux/in.h>
64249 +#include <linux/ip.h>
64250 +#include <linux/skbuff.h>
64251 +#include <linux/sysctl.h>
64252 +
64253 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64254 +void
64255 +pax_set_initial_flags(struct linux_binprm *bprm)
64256 +{
64257 + return;
64258 +}
64259 +#endif
64260 +
64261 +#ifdef CONFIG_SYSCTL
64262 +__u32
64263 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64264 +{
64265 + return 0;
64266 +}
64267 +#endif
64268 +
64269 +#ifdef CONFIG_TASKSTATS
64270 +int gr_is_taskstats_denied(int pid)
64271 +{
64272 + return 0;
64273 +}
64274 +#endif
64275 +
64276 +int
64277 +gr_acl_is_enabled(void)
64278 +{
64279 + return 0;
64280 +}
64281 +
64282 +void
64283 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64284 +{
64285 + return;
64286 +}
64287 +
64288 +int
64289 +gr_handle_rawio(const struct inode *inode)
64290 +{
64291 + return 0;
64292 +}
64293 +
64294 +void
64295 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64296 +{
64297 + return;
64298 +}
64299 +
64300 +int
64301 +gr_handle_ptrace(struct task_struct *task, const long request)
64302 +{
64303 + return 0;
64304 +}
64305 +
64306 +int
64307 +gr_handle_proc_ptrace(struct task_struct *task)
64308 +{
64309 + return 0;
64310 +}
64311 +
64312 +int
64313 +gr_set_acls(const int type)
64314 +{
64315 + return 0;
64316 +}
64317 +
64318 +int
64319 +gr_check_hidden_task(const struct task_struct *tsk)
64320 +{
64321 + return 0;
64322 +}
64323 +
64324 +int
64325 +gr_check_protected_task(const struct task_struct *task)
64326 +{
64327 + return 0;
64328 +}
64329 +
64330 +int
64331 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64332 +{
64333 + return 0;
64334 +}
64335 +
64336 +void
64337 +gr_copy_label(struct task_struct *tsk)
64338 +{
64339 + return;
64340 +}
64341 +
64342 +void
64343 +gr_set_pax_flags(struct task_struct *task)
64344 +{
64345 + return;
64346 +}
64347 +
64348 +int
64349 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64350 + const int unsafe_share)
64351 +{
64352 + return 0;
64353 +}
64354 +
64355 +void
64356 +gr_handle_delete(const ino_t ino, const dev_t dev)
64357 +{
64358 + return;
64359 +}
64360 +
64361 +void
64362 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64363 +{
64364 + return;
64365 +}
64366 +
64367 +void
64368 +gr_handle_crash(struct task_struct *task, const int sig)
64369 +{
64370 + return;
64371 +}
64372 +
64373 +int
64374 +gr_check_crash_exec(const struct file *filp)
64375 +{
64376 + return 0;
64377 +}
64378 +
64379 +int
64380 +gr_check_crash_uid(const kuid_t uid)
64381 +{
64382 + return 0;
64383 +}
64384 +
64385 +void
64386 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64387 + struct dentry *old_dentry,
64388 + struct dentry *new_dentry,
64389 + struct vfsmount *mnt, const __u8 replace)
64390 +{
64391 + return;
64392 +}
64393 +
64394 +int
64395 +gr_search_socket(const int family, const int type, const int protocol)
64396 +{
64397 + return 1;
64398 +}
64399 +
64400 +int
64401 +gr_search_connectbind(const int mode, const struct socket *sock,
64402 + const struct sockaddr_in *addr)
64403 +{
64404 + return 0;
64405 +}
64406 +
64407 +void
64408 +gr_handle_alertkill(struct task_struct *task)
64409 +{
64410 + return;
64411 +}
64412 +
64413 +__u32
64414 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64415 +{
64416 + return 1;
64417 +}
64418 +
64419 +__u32
64420 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64421 + const struct vfsmount * mnt)
64422 +{
64423 + return 1;
64424 +}
64425 +
64426 +__u32
64427 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64428 + int acc_mode)
64429 +{
64430 + return 1;
64431 +}
64432 +
64433 +__u32
64434 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64435 +{
64436 + return 1;
64437 +}
64438 +
64439 +__u32
64440 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64441 +{
64442 + return 1;
64443 +}
64444 +
64445 +int
64446 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64447 + unsigned int *vm_flags)
64448 +{
64449 + return 1;
64450 +}
64451 +
64452 +__u32
64453 +gr_acl_handle_truncate(const struct dentry * dentry,
64454 + const struct vfsmount * mnt)
64455 +{
64456 + return 1;
64457 +}
64458 +
64459 +__u32
64460 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64461 +{
64462 + return 1;
64463 +}
64464 +
64465 +__u32
64466 +gr_acl_handle_access(const struct dentry * dentry,
64467 + const struct vfsmount * mnt, const int fmode)
64468 +{
64469 + return 1;
64470 +}
64471 +
64472 +__u32
64473 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64474 + umode_t *mode)
64475 +{
64476 + return 1;
64477 +}
64478 +
64479 +__u32
64480 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64481 +{
64482 + return 1;
64483 +}
64484 +
64485 +__u32
64486 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64487 +{
64488 + return 1;
64489 +}
64490 +
64491 +void
64492 +grsecurity_init(void)
64493 +{
64494 + return;
64495 +}
64496 +
64497 +umode_t gr_acl_umask(void)
64498 +{
64499 + return 0;
64500 +}
64501 +
64502 +__u32
64503 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64504 + const struct dentry * parent_dentry,
64505 + const struct vfsmount * parent_mnt,
64506 + const int mode)
64507 +{
64508 + return 1;
64509 +}
64510 +
64511 +__u32
64512 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64513 + const struct dentry * parent_dentry,
64514 + const struct vfsmount * parent_mnt)
64515 +{
64516 + return 1;
64517 +}
64518 +
64519 +__u32
64520 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64521 + const struct dentry * parent_dentry,
64522 + const struct vfsmount * parent_mnt, const struct filename *from)
64523 +{
64524 + return 1;
64525 +}
64526 +
64527 +__u32
64528 +gr_acl_handle_link(const struct dentry * new_dentry,
64529 + const struct dentry * parent_dentry,
64530 + const struct vfsmount * parent_mnt,
64531 + const struct dentry * old_dentry,
64532 + const struct vfsmount * old_mnt, const struct filename *to)
64533 +{
64534 + return 1;
64535 +}
64536 +
64537 +int
64538 +gr_acl_handle_rename(const struct dentry *new_dentry,
64539 + const struct dentry *parent_dentry,
64540 + const struct vfsmount *parent_mnt,
64541 + const struct dentry *old_dentry,
64542 + const struct inode *old_parent_inode,
64543 + const struct vfsmount *old_mnt, const struct filename *newname)
64544 +{
64545 + return 0;
64546 +}
64547 +
64548 +int
64549 +gr_acl_handle_filldir(const struct file *file, const char *name,
64550 + const int namelen, const ino_t ino)
64551 +{
64552 + return 1;
64553 +}
64554 +
64555 +int
64556 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64557 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64558 +{
64559 + return 1;
64560 +}
64561 +
64562 +int
64563 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64564 +{
64565 + return 0;
64566 +}
64567 +
64568 +int
64569 +gr_search_accept(const struct socket *sock)
64570 +{
64571 + return 0;
64572 +}
64573 +
64574 +int
64575 +gr_search_listen(const struct socket *sock)
64576 +{
64577 + return 0;
64578 +}
64579 +
64580 +int
64581 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64582 +{
64583 + return 0;
64584 +}
64585 +
64586 +__u32
64587 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64588 +{
64589 + return 1;
64590 +}
64591 +
64592 +__u32
64593 +gr_acl_handle_creat(const struct dentry * dentry,
64594 + const struct dentry * p_dentry,
64595 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64596 + const int imode)
64597 +{
64598 + return 1;
64599 +}
64600 +
64601 +void
64602 +gr_acl_handle_exit(void)
64603 +{
64604 + return;
64605 +}
64606 +
64607 +int
64608 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64609 +{
64610 + return 1;
64611 +}
64612 +
64613 +void
64614 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64615 +{
64616 + return;
64617 +}
64618 +
64619 +int
64620 +gr_acl_handle_procpidmem(const struct task_struct *task)
64621 +{
64622 + return 0;
64623 +}
64624 +
64625 +int
64626 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64627 +{
64628 + return 0;
64629 +}
64630 +
64631 +int
64632 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64633 +{
64634 + return 0;
64635 +}
64636 +
64637 +void
64638 +gr_set_kernel_label(struct task_struct *task)
64639 +{
64640 + return;
64641 +}
64642 +
64643 +int
64644 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64645 +{
64646 + return 0;
64647 +}
64648 +
64649 +int
64650 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64651 +{
64652 + return 0;
64653 +}
64654 +
64655 +int gr_acl_enable_at_secure(void)
64656 +{
64657 + return 0;
64658 +}
64659 +
64660 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64661 +{
64662 + return dentry->d_inode->i_sb->s_dev;
64663 +}
64664 +
64665 +void gr_put_exec_file(struct task_struct *task)
64666 +{
64667 + return;
64668 +}
64669 +
64670 +EXPORT_SYMBOL(gr_set_kernel_label);
64671 +#ifdef CONFIG_SECURITY
64672 +EXPORT_SYMBOL(gr_check_user_change);
64673 +EXPORT_SYMBOL(gr_check_group_change);
64674 +#endif
64675 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64676 new file mode 100644
64677 index 0000000..387032b
64678 --- /dev/null
64679 +++ b/grsecurity/grsec_exec.c
64680 @@ -0,0 +1,187 @@
64681 +#include <linux/kernel.h>
64682 +#include <linux/sched.h>
64683 +#include <linux/file.h>
64684 +#include <linux/binfmts.h>
64685 +#include <linux/fs.h>
64686 +#include <linux/types.h>
64687 +#include <linux/grdefs.h>
64688 +#include <linux/grsecurity.h>
64689 +#include <linux/grinternal.h>
64690 +#include <linux/capability.h>
64691 +#include <linux/module.h>
64692 +#include <linux/compat.h>
64693 +
64694 +#include <asm/uaccess.h>
64695 +
64696 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64697 +static char gr_exec_arg_buf[132];
64698 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64699 +#endif
64700 +
64701 +struct user_arg_ptr {
64702 +#ifdef CONFIG_COMPAT
64703 + bool is_compat;
64704 +#endif
64705 + union {
64706 + const char __user *const __user *native;
64707 +#ifdef CONFIG_COMPAT
64708 + const compat_uptr_t __user *compat;
64709 +#endif
64710 + } ptr;
64711 +};
64712 +
64713 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64714 +
64715 +void
64716 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64717 +{
64718 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64719 + char *grarg = gr_exec_arg_buf;
64720 + unsigned int i, x, execlen = 0;
64721 + char c;
64722 +
64723 + if (!((grsec_enable_execlog && grsec_enable_group &&
64724 + in_group_p(grsec_audit_gid))
64725 + || (grsec_enable_execlog && !grsec_enable_group)))
64726 + return;
64727 +
64728 + mutex_lock(&gr_exec_arg_mutex);
64729 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64730 +
64731 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64732 + const char __user *p;
64733 + unsigned int len;
64734 +
64735 + p = get_user_arg_ptr(argv, i);
64736 + if (IS_ERR(p))
64737 + goto log;
64738 +
64739 + len = strnlen_user(p, 128 - execlen);
64740 + if (len > 128 - execlen)
64741 + len = 128 - execlen;
64742 + else if (len > 0)
64743 + len--;
64744 + if (copy_from_user(grarg + execlen, p, len))
64745 + goto log;
64746 +
64747 + /* rewrite unprintable characters */
64748 + for (x = 0; x < len; x++) {
64749 + c = *(grarg + execlen + x);
64750 + if (c < 32 || c > 126)
64751 + *(grarg + execlen + x) = ' ';
64752 + }
64753 +
64754 + execlen += len;
64755 + *(grarg + execlen) = ' ';
64756 + *(grarg + execlen + 1) = '\0';
64757 + execlen++;
64758 + }
64759 +
64760 + log:
64761 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64762 + bprm->file->f_path.mnt, grarg);
64763 + mutex_unlock(&gr_exec_arg_mutex);
64764 +#endif
64765 + return;
64766 +}
64767 +
64768 +#ifdef CONFIG_GRKERNSEC
64769 +extern int gr_acl_is_capable(const int cap);
64770 +extern int gr_acl_is_capable_nolog(const int cap);
64771 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64772 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64773 +extern int gr_chroot_is_capable(const int cap);
64774 +extern int gr_chroot_is_capable_nolog(const int cap);
64775 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64776 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64777 +#endif
64778 +
64779 +const char *captab_log[] = {
64780 + "CAP_CHOWN",
64781 + "CAP_DAC_OVERRIDE",
64782 + "CAP_DAC_READ_SEARCH",
64783 + "CAP_FOWNER",
64784 + "CAP_FSETID",
64785 + "CAP_KILL",
64786 + "CAP_SETGID",
64787 + "CAP_SETUID",
64788 + "CAP_SETPCAP",
64789 + "CAP_LINUX_IMMUTABLE",
64790 + "CAP_NET_BIND_SERVICE",
64791 + "CAP_NET_BROADCAST",
64792 + "CAP_NET_ADMIN",
64793 + "CAP_NET_RAW",
64794 + "CAP_IPC_LOCK",
64795 + "CAP_IPC_OWNER",
64796 + "CAP_SYS_MODULE",
64797 + "CAP_SYS_RAWIO",
64798 + "CAP_SYS_CHROOT",
64799 + "CAP_SYS_PTRACE",
64800 + "CAP_SYS_PACCT",
64801 + "CAP_SYS_ADMIN",
64802 + "CAP_SYS_BOOT",
64803 + "CAP_SYS_NICE",
64804 + "CAP_SYS_RESOURCE",
64805 + "CAP_SYS_TIME",
64806 + "CAP_SYS_TTY_CONFIG",
64807 + "CAP_MKNOD",
64808 + "CAP_LEASE",
64809 + "CAP_AUDIT_WRITE",
64810 + "CAP_AUDIT_CONTROL",
64811 + "CAP_SETFCAP",
64812 + "CAP_MAC_OVERRIDE",
64813 + "CAP_MAC_ADMIN",
64814 + "CAP_SYSLOG",
64815 + "CAP_WAKE_ALARM"
64816 +};
64817 +
64818 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64819 +
64820 +int gr_is_capable(const int cap)
64821 +{
64822 +#ifdef CONFIG_GRKERNSEC
64823 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64824 + return 1;
64825 + return 0;
64826 +#else
64827 + return 1;
64828 +#endif
64829 +}
64830 +
64831 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64832 +{
64833 +#ifdef CONFIG_GRKERNSEC
64834 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64835 + return 1;
64836 + return 0;
64837 +#else
64838 + return 1;
64839 +#endif
64840 +}
64841 +
64842 +int gr_is_capable_nolog(const int cap)
64843 +{
64844 +#ifdef CONFIG_GRKERNSEC
64845 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64846 + return 1;
64847 + return 0;
64848 +#else
64849 + return 1;
64850 +#endif
64851 +}
64852 +
64853 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64854 +{
64855 +#ifdef CONFIG_GRKERNSEC
64856 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64857 + return 1;
64858 + return 0;
64859 +#else
64860 + return 1;
64861 +#endif
64862 +}
64863 +
64864 +EXPORT_SYMBOL(gr_is_capable);
64865 +EXPORT_SYMBOL(gr_is_capable_nolog);
64866 +EXPORT_SYMBOL(gr_task_is_capable);
64867 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64868 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64869 new file mode 100644
64870 index 0000000..06cc6ea
64871 --- /dev/null
64872 +++ b/grsecurity/grsec_fifo.c
64873 @@ -0,0 +1,24 @@
64874 +#include <linux/kernel.h>
64875 +#include <linux/sched.h>
64876 +#include <linux/fs.h>
64877 +#include <linux/file.h>
64878 +#include <linux/grinternal.h>
64879 +
64880 +int
64881 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64882 + const struct dentry *dir, const int flag, const int acc_mode)
64883 +{
64884 +#ifdef CONFIG_GRKERNSEC_FIFO
64885 + const struct cred *cred = current_cred();
64886 +
64887 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64888 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64889 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64890 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64891 + if (!inode_permission(dentry->d_inode, acc_mode))
64892 + 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));
64893 + return -EACCES;
64894 + }
64895 +#endif
64896 + return 0;
64897 +}
64898 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64899 new file mode 100644
64900 index 0000000..8ca18bf
64901 --- /dev/null
64902 +++ b/grsecurity/grsec_fork.c
64903 @@ -0,0 +1,23 @@
64904 +#include <linux/kernel.h>
64905 +#include <linux/sched.h>
64906 +#include <linux/grsecurity.h>
64907 +#include <linux/grinternal.h>
64908 +#include <linux/errno.h>
64909 +
64910 +void
64911 +gr_log_forkfail(const int retval)
64912 +{
64913 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64914 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64915 + switch (retval) {
64916 + case -EAGAIN:
64917 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64918 + break;
64919 + case -ENOMEM:
64920 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64921 + break;
64922 + }
64923 + }
64924 +#endif
64925 + return;
64926 +}
64927 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64928 new file mode 100644
64929 index 0000000..a862e9f
64930 --- /dev/null
64931 +++ b/grsecurity/grsec_init.c
64932 @@ -0,0 +1,283 @@
64933 +#include <linux/kernel.h>
64934 +#include <linux/sched.h>
64935 +#include <linux/mm.h>
64936 +#include <linux/gracl.h>
64937 +#include <linux/slab.h>
64938 +#include <linux/vmalloc.h>
64939 +#include <linux/percpu.h>
64940 +#include <linux/module.h>
64941 +
64942 +int grsec_enable_ptrace_readexec;
64943 +int grsec_enable_setxid;
64944 +int grsec_enable_symlinkown;
64945 +kgid_t grsec_symlinkown_gid;
64946 +int grsec_enable_brute;
64947 +int grsec_enable_link;
64948 +int grsec_enable_dmesg;
64949 +int grsec_enable_harden_ptrace;
64950 +int grsec_enable_fifo;
64951 +int grsec_enable_execlog;
64952 +int grsec_enable_signal;
64953 +int grsec_enable_forkfail;
64954 +int grsec_enable_audit_ptrace;
64955 +int grsec_enable_time;
64956 +int grsec_enable_audit_textrel;
64957 +int grsec_enable_group;
64958 +kgid_t grsec_audit_gid;
64959 +int grsec_enable_chdir;
64960 +int grsec_enable_mount;
64961 +int grsec_enable_rofs;
64962 +int grsec_enable_chroot_findtask;
64963 +int grsec_enable_chroot_mount;
64964 +int grsec_enable_chroot_shmat;
64965 +int grsec_enable_chroot_fchdir;
64966 +int grsec_enable_chroot_double;
64967 +int grsec_enable_chroot_pivot;
64968 +int grsec_enable_chroot_chdir;
64969 +int grsec_enable_chroot_chmod;
64970 +int grsec_enable_chroot_mknod;
64971 +int grsec_enable_chroot_nice;
64972 +int grsec_enable_chroot_execlog;
64973 +int grsec_enable_chroot_caps;
64974 +int grsec_enable_chroot_sysctl;
64975 +int grsec_enable_chroot_unix;
64976 +int grsec_enable_tpe;
64977 +kgid_t grsec_tpe_gid;
64978 +int grsec_enable_blackhole;
64979 +#ifdef CONFIG_IPV6_MODULE
64980 +EXPORT_SYMBOL(grsec_enable_blackhole);
64981 +#endif
64982 +int grsec_lastack_retries;
64983 +int grsec_enable_tpe_all;
64984 +int grsec_enable_tpe_invert;
64985 +int grsec_enable_socket_all;
64986 +kgid_t grsec_socket_all_gid;
64987 +int grsec_enable_socket_client;
64988 +kgid_t grsec_socket_client_gid;
64989 +int grsec_enable_socket_server;
64990 +kgid_t grsec_socket_server_gid;
64991 +int grsec_resource_logging;
64992 +int grsec_disable_privio;
64993 +int grsec_enable_log_rwxmaps;
64994 +int grsec_lock;
64995 +
64996 +DEFINE_SPINLOCK(grsec_alert_lock);
64997 +unsigned long grsec_alert_wtime = 0;
64998 +unsigned long grsec_alert_fyet = 0;
64999 +
65000 +DEFINE_SPINLOCK(grsec_audit_lock);
65001 +
65002 +DEFINE_RWLOCK(grsec_exec_file_lock);
65003 +
65004 +char *gr_shared_page[4];
65005 +
65006 +char *gr_alert_log_fmt;
65007 +char *gr_audit_log_fmt;
65008 +char *gr_alert_log_buf;
65009 +char *gr_audit_log_buf;
65010 +
65011 +extern struct gr_arg *gr_usermode;
65012 +extern unsigned char *gr_system_salt;
65013 +extern unsigned char *gr_system_sum;
65014 +
65015 +void __init
65016 +grsecurity_init(void)
65017 +{
65018 + int j;
65019 + /* create the per-cpu shared pages */
65020 +
65021 +#ifdef CONFIG_X86
65022 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65023 +#endif
65024 +
65025 + for (j = 0; j < 4; j++) {
65026 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65027 + if (gr_shared_page[j] == NULL) {
65028 + panic("Unable to allocate grsecurity shared page");
65029 + return;
65030 + }
65031 + }
65032 +
65033 + /* allocate log buffers */
65034 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65035 + if (!gr_alert_log_fmt) {
65036 + panic("Unable to allocate grsecurity alert log format buffer");
65037 + return;
65038 + }
65039 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65040 + if (!gr_audit_log_fmt) {
65041 + panic("Unable to allocate grsecurity audit log format buffer");
65042 + return;
65043 + }
65044 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65045 + if (!gr_alert_log_buf) {
65046 + panic("Unable to allocate grsecurity alert log buffer");
65047 + return;
65048 + }
65049 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65050 + if (!gr_audit_log_buf) {
65051 + panic("Unable to allocate grsecurity audit log buffer");
65052 + return;
65053 + }
65054 +
65055 + /* allocate memory for authentication structure */
65056 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65057 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65058 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65059 +
65060 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65061 + panic("Unable to allocate grsecurity authentication structure");
65062 + return;
65063 + }
65064 +
65065 +
65066 +#ifdef CONFIG_GRKERNSEC_IO
65067 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65068 + grsec_disable_privio = 1;
65069 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65070 + grsec_disable_privio = 1;
65071 +#else
65072 + grsec_disable_privio = 0;
65073 +#endif
65074 +#endif
65075 +
65076 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65077 + /* for backward compatibility, tpe_invert always defaults to on if
65078 + enabled in the kernel
65079 + */
65080 + grsec_enable_tpe_invert = 1;
65081 +#endif
65082 +
65083 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65084 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65085 + grsec_lock = 1;
65086 +#endif
65087 +
65088 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65089 + grsec_enable_audit_textrel = 1;
65090 +#endif
65091 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65092 + grsec_enable_log_rwxmaps = 1;
65093 +#endif
65094 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65095 + grsec_enable_group = 1;
65096 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65097 +#endif
65098 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65099 + grsec_enable_ptrace_readexec = 1;
65100 +#endif
65101 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65102 + grsec_enable_chdir = 1;
65103 +#endif
65104 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65105 + grsec_enable_harden_ptrace = 1;
65106 +#endif
65107 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65108 + grsec_enable_mount = 1;
65109 +#endif
65110 +#ifdef CONFIG_GRKERNSEC_LINK
65111 + grsec_enable_link = 1;
65112 +#endif
65113 +#ifdef CONFIG_GRKERNSEC_BRUTE
65114 + grsec_enable_brute = 1;
65115 +#endif
65116 +#ifdef CONFIG_GRKERNSEC_DMESG
65117 + grsec_enable_dmesg = 1;
65118 +#endif
65119 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65120 + grsec_enable_blackhole = 1;
65121 + grsec_lastack_retries = 4;
65122 +#endif
65123 +#ifdef CONFIG_GRKERNSEC_FIFO
65124 + grsec_enable_fifo = 1;
65125 +#endif
65126 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65127 + grsec_enable_execlog = 1;
65128 +#endif
65129 +#ifdef CONFIG_GRKERNSEC_SETXID
65130 + grsec_enable_setxid = 1;
65131 +#endif
65132 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65133 + grsec_enable_signal = 1;
65134 +#endif
65135 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65136 + grsec_enable_forkfail = 1;
65137 +#endif
65138 +#ifdef CONFIG_GRKERNSEC_TIME
65139 + grsec_enable_time = 1;
65140 +#endif
65141 +#ifdef CONFIG_GRKERNSEC_RESLOG
65142 + grsec_resource_logging = 1;
65143 +#endif
65144 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65145 + grsec_enable_chroot_findtask = 1;
65146 +#endif
65147 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65148 + grsec_enable_chroot_unix = 1;
65149 +#endif
65150 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65151 + grsec_enable_chroot_mount = 1;
65152 +#endif
65153 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65154 + grsec_enable_chroot_fchdir = 1;
65155 +#endif
65156 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65157 + grsec_enable_chroot_shmat = 1;
65158 +#endif
65159 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65160 + grsec_enable_audit_ptrace = 1;
65161 +#endif
65162 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65163 + grsec_enable_chroot_double = 1;
65164 +#endif
65165 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65166 + grsec_enable_chroot_pivot = 1;
65167 +#endif
65168 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65169 + grsec_enable_chroot_chdir = 1;
65170 +#endif
65171 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65172 + grsec_enable_chroot_chmod = 1;
65173 +#endif
65174 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65175 + grsec_enable_chroot_mknod = 1;
65176 +#endif
65177 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65178 + grsec_enable_chroot_nice = 1;
65179 +#endif
65180 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65181 + grsec_enable_chroot_execlog = 1;
65182 +#endif
65183 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65184 + grsec_enable_chroot_caps = 1;
65185 +#endif
65186 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65187 + grsec_enable_chroot_sysctl = 1;
65188 +#endif
65189 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65190 + grsec_enable_symlinkown = 1;
65191 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65192 +#endif
65193 +#ifdef CONFIG_GRKERNSEC_TPE
65194 + grsec_enable_tpe = 1;
65195 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65196 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65197 + grsec_enable_tpe_all = 1;
65198 +#endif
65199 +#endif
65200 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65201 + grsec_enable_socket_all = 1;
65202 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65203 +#endif
65204 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65205 + grsec_enable_socket_client = 1;
65206 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65207 +#endif
65208 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65209 + grsec_enable_socket_server = 1;
65210 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65211 +#endif
65212 +#endif
65213 +
65214 + return;
65215 +}
65216 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65217 new file mode 100644
65218 index 0000000..5e05e20
65219 --- /dev/null
65220 +++ b/grsecurity/grsec_link.c
65221 @@ -0,0 +1,58 @@
65222 +#include <linux/kernel.h>
65223 +#include <linux/sched.h>
65224 +#include <linux/fs.h>
65225 +#include <linux/file.h>
65226 +#include <linux/grinternal.h>
65227 +
65228 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65229 +{
65230 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65231 + const struct inode *link_inode = link->dentry->d_inode;
65232 +
65233 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65234 + /* ignore root-owned links, e.g. /proc/self */
65235 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65236 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65237 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65238 + return 1;
65239 + }
65240 +#endif
65241 + return 0;
65242 +}
65243 +
65244 +int
65245 +gr_handle_follow_link(const struct inode *parent,
65246 + const struct inode *inode,
65247 + const struct dentry *dentry, const struct vfsmount *mnt)
65248 +{
65249 +#ifdef CONFIG_GRKERNSEC_LINK
65250 + const struct cred *cred = current_cred();
65251 +
65252 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65253 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65254 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65255 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65256 + return -EACCES;
65257 + }
65258 +#endif
65259 + return 0;
65260 +}
65261 +
65262 +int
65263 +gr_handle_hardlink(const struct dentry *dentry,
65264 + const struct vfsmount *mnt,
65265 + struct inode *inode, const int mode, const struct filename *to)
65266 +{
65267 +#ifdef CONFIG_GRKERNSEC_LINK
65268 + const struct cred *cred = current_cred();
65269 +
65270 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65271 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65272 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65273 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65274 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65275 + return -EPERM;
65276 + }
65277 +#endif
65278 + return 0;
65279 +}
65280 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65281 new file mode 100644
65282 index 0000000..7c06085
65283 --- /dev/null
65284 +++ b/grsecurity/grsec_log.c
65285 @@ -0,0 +1,326 @@
65286 +#include <linux/kernel.h>
65287 +#include <linux/sched.h>
65288 +#include <linux/file.h>
65289 +#include <linux/tty.h>
65290 +#include <linux/fs.h>
65291 +#include <linux/grinternal.h>
65292 +
65293 +#ifdef CONFIG_TREE_PREEMPT_RCU
65294 +#define DISABLE_PREEMPT() preempt_disable()
65295 +#define ENABLE_PREEMPT() preempt_enable()
65296 +#else
65297 +#define DISABLE_PREEMPT()
65298 +#define ENABLE_PREEMPT()
65299 +#endif
65300 +
65301 +#define BEGIN_LOCKS(x) \
65302 + DISABLE_PREEMPT(); \
65303 + rcu_read_lock(); \
65304 + read_lock(&tasklist_lock); \
65305 + read_lock(&grsec_exec_file_lock); \
65306 + if (x != GR_DO_AUDIT) \
65307 + spin_lock(&grsec_alert_lock); \
65308 + else \
65309 + spin_lock(&grsec_audit_lock)
65310 +
65311 +#define END_LOCKS(x) \
65312 + if (x != GR_DO_AUDIT) \
65313 + spin_unlock(&grsec_alert_lock); \
65314 + else \
65315 + spin_unlock(&grsec_audit_lock); \
65316 + read_unlock(&grsec_exec_file_lock); \
65317 + read_unlock(&tasklist_lock); \
65318 + rcu_read_unlock(); \
65319 + ENABLE_PREEMPT(); \
65320 + if (x == GR_DONT_AUDIT) \
65321 + gr_handle_alertkill(current)
65322 +
65323 +enum {
65324 + FLOODING,
65325 + NO_FLOODING
65326 +};
65327 +
65328 +extern char *gr_alert_log_fmt;
65329 +extern char *gr_audit_log_fmt;
65330 +extern char *gr_alert_log_buf;
65331 +extern char *gr_audit_log_buf;
65332 +
65333 +static int gr_log_start(int audit)
65334 +{
65335 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65336 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65337 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65338 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65339 + unsigned long curr_secs = get_seconds();
65340 +
65341 + if (audit == GR_DO_AUDIT)
65342 + goto set_fmt;
65343 +
65344 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65345 + grsec_alert_wtime = curr_secs;
65346 + grsec_alert_fyet = 0;
65347 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65348 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65349 + grsec_alert_fyet++;
65350 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65351 + grsec_alert_wtime = curr_secs;
65352 + grsec_alert_fyet++;
65353 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65354 + return FLOODING;
65355 + }
65356 + else return FLOODING;
65357 +
65358 +set_fmt:
65359 +#endif
65360 + memset(buf, 0, PAGE_SIZE);
65361 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65362 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65363 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65364 + } else if (current->signal->curr_ip) {
65365 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65366 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65367 + } else if (gr_acl_is_enabled()) {
65368 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65369 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65370 + } else {
65371 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65372 + strcpy(buf, fmt);
65373 + }
65374 +
65375 + return NO_FLOODING;
65376 +}
65377 +
65378 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65379 + __attribute__ ((format (printf, 2, 0)));
65380 +
65381 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65382 +{
65383 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65384 + unsigned int len = strlen(buf);
65385 +
65386 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65387 +
65388 + return;
65389 +}
65390 +
65391 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65392 + __attribute__ ((format (printf, 2, 3)));
65393 +
65394 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65395 +{
65396 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65397 + unsigned int len = strlen(buf);
65398 + va_list ap;
65399 +
65400 + va_start(ap, msg);
65401 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65402 + va_end(ap);
65403 +
65404 + return;
65405 +}
65406 +
65407 +static void gr_log_end(int audit, int append_default)
65408 +{
65409 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65410 + if (append_default) {
65411 + struct task_struct *task = current;
65412 + struct task_struct *parent = task->real_parent;
65413 + const struct cred *cred = __task_cred(task);
65414 + const struct cred *pcred = __task_cred(parent);
65415 + unsigned int len = strlen(buf);
65416 +
65417 + 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));
65418 + }
65419 +
65420 + printk("%s\n", buf);
65421 +
65422 + return;
65423 +}
65424 +
65425 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65426 +{
65427 + int logtype;
65428 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65429 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65430 + void *voidptr = NULL;
65431 + int num1 = 0, num2 = 0;
65432 + unsigned long ulong1 = 0, ulong2 = 0;
65433 + struct dentry *dentry = NULL;
65434 + struct vfsmount *mnt = NULL;
65435 + struct file *file = NULL;
65436 + struct task_struct *task = NULL;
65437 + const struct cred *cred, *pcred;
65438 + va_list ap;
65439 +
65440 + BEGIN_LOCKS(audit);
65441 + logtype = gr_log_start(audit);
65442 + if (logtype == FLOODING) {
65443 + END_LOCKS(audit);
65444 + return;
65445 + }
65446 + va_start(ap, argtypes);
65447 + switch (argtypes) {
65448 + case GR_TTYSNIFF:
65449 + task = va_arg(ap, struct task_struct *);
65450 + 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));
65451 + break;
65452 + case GR_SYSCTL_HIDDEN:
65453 + str1 = va_arg(ap, char *);
65454 + gr_log_middle_varargs(audit, msg, result, str1);
65455 + break;
65456 + case GR_RBAC:
65457 + dentry = va_arg(ap, struct dentry *);
65458 + mnt = va_arg(ap, struct vfsmount *);
65459 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65460 + break;
65461 + case GR_RBAC_STR:
65462 + dentry = va_arg(ap, struct dentry *);
65463 + mnt = va_arg(ap, struct vfsmount *);
65464 + str1 = va_arg(ap, char *);
65465 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65466 + break;
65467 + case GR_STR_RBAC:
65468 + str1 = va_arg(ap, char *);
65469 + dentry = va_arg(ap, struct dentry *);
65470 + mnt = va_arg(ap, struct vfsmount *);
65471 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65472 + break;
65473 + case GR_RBAC_MODE2:
65474 + dentry = va_arg(ap, struct dentry *);
65475 + mnt = va_arg(ap, struct vfsmount *);
65476 + str1 = va_arg(ap, char *);
65477 + str2 = va_arg(ap, char *);
65478 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65479 + break;
65480 + case GR_RBAC_MODE3:
65481 + dentry = va_arg(ap, struct dentry *);
65482 + mnt = va_arg(ap, struct vfsmount *);
65483 + str1 = va_arg(ap, char *);
65484 + str2 = va_arg(ap, char *);
65485 + str3 = va_arg(ap, char *);
65486 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65487 + break;
65488 + case GR_FILENAME:
65489 + dentry = va_arg(ap, struct dentry *);
65490 + mnt = va_arg(ap, struct vfsmount *);
65491 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65492 + break;
65493 + case GR_STR_FILENAME:
65494 + str1 = va_arg(ap, char *);
65495 + dentry = va_arg(ap, struct dentry *);
65496 + mnt = va_arg(ap, struct vfsmount *);
65497 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65498 + break;
65499 + case GR_FILENAME_STR:
65500 + dentry = va_arg(ap, struct dentry *);
65501 + mnt = va_arg(ap, struct vfsmount *);
65502 + str1 = va_arg(ap, char *);
65503 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65504 + break;
65505 + case GR_FILENAME_TWO_INT:
65506 + dentry = va_arg(ap, struct dentry *);
65507 + mnt = va_arg(ap, struct vfsmount *);
65508 + num1 = va_arg(ap, int);
65509 + num2 = va_arg(ap, int);
65510 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65511 + break;
65512 + case GR_FILENAME_TWO_INT_STR:
65513 + dentry = va_arg(ap, struct dentry *);
65514 + mnt = va_arg(ap, struct vfsmount *);
65515 + num1 = va_arg(ap, int);
65516 + num2 = va_arg(ap, int);
65517 + str1 = va_arg(ap, char *);
65518 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65519 + break;
65520 + case GR_TEXTREL:
65521 + file = va_arg(ap, struct file *);
65522 + ulong1 = va_arg(ap, unsigned long);
65523 + ulong2 = va_arg(ap, unsigned long);
65524 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65525 + break;
65526 + case GR_PTRACE:
65527 + task = va_arg(ap, struct task_struct *);
65528 + 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));
65529 + break;
65530 + case GR_RESOURCE:
65531 + task = va_arg(ap, struct task_struct *);
65532 + cred = __task_cred(task);
65533 + pcred = __task_cred(task->real_parent);
65534 + ulong1 = va_arg(ap, unsigned long);
65535 + str1 = va_arg(ap, char *);
65536 + ulong2 = va_arg(ap, unsigned long);
65537 + 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));
65538 + break;
65539 + case GR_CAP:
65540 + task = va_arg(ap, struct task_struct *);
65541 + cred = __task_cred(task);
65542 + pcred = __task_cred(task->real_parent);
65543 + str1 = va_arg(ap, char *);
65544 + 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));
65545 + break;
65546 + case GR_SIG:
65547 + str1 = va_arg(ap, char *);
65548 + voidptr = va_arg(ap, void *);
65549 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65550 + break;
65551 + case GR_SIG2:
65552 + task = va_arg(ap, struct task_struct *);
65553 + cred = __task_cred(task);
65554 + pcred = __task_cred(task->real_parent);
65555 + num1 = va_arg(ap, int);
65556 + 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));
65557 + break;
65558 + case GR_CRASH1:
65559 + task = va_arg(ap, struct task_struct *);
65560 + cred = __task_cred(task);
65561 + pcred = __task_cred(task->real_parent);
65562 + ulong1 = va_arg(ap, unsigned long);
65563 + 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);
65564 + break;
65565 + case GR_CRASH2:
65566 + task = va_arg(ap, struct task_struct *);
65567 + cred = __task_cred(task);
65568 + pcred = __task_cred(task->real_parent);
65569 + ulong1 = va_arg(ap, unsigned long);
65570 + 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);
65571 + break;
65572 + case GR_RWXMAP:
65573 + file = va_arg(ap, struct file *);
65574 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65575 + break;
65576 + case GR_PSACCT:
65577 + {
65578 + unsigned int wday, cday;
65579 + __u8 whr, chr;
65580 + __u8 wmin, cmin;
65581 + __u8 wsec, csec;
65582 + char cur_tty[64] = { 0 };
65583 + char parent_tty[64] = { 0 };
65584 +
65585 + task = va_arg(ap, struct task_struct *);
65586 + wday = va_arg(ap, unsigned int);
65587 + cday = va_arg(ap, unsigned int);
65588 + whr = va_arg(ap, int);
65589 + chr = va_arg(ap, int);
65590 + wmin = va_arg(ap, int);
65591 + cmin = va_arg(ap, int);
65592 + wsec = va_arg(ap, int);
65593 + csec = va_arg(ap, int);
65594 + ulong1 = va_arg(ap, unsigned long);
65595 + cred = __task_cred(task);
65596 + pcred = __task_cred(task->real_parent);
65597 +
65598 + 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));
65599 + }
65600 + break;
65601 + default:
65602 + gr_log_middle(audit, msg, ap);
65603 + }
65604 + va_end(ap);
65605 + // these don't need DEFAULTSECARGS printed on the end
65606 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65607 + gr_log_end(audit, 0);
65608 + else
65609 + gr_log_end(audit, 1);
65610 + END_LOCKS(audit);
65611 +}
65612 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65613 new file mode 100644
65614 index 0000000..f536303
65615 --- /dev/null
65616 +++ b/grsecurity/grsec_mem.c
65617 @@ -0,0 +1,40 @@
65618 +#include <linux/kernel.h>
65619 +#include <linux/sched.h>
65620 +#include <linux/mm.h>
65621 +#include <linux/mman.h>
65622 +#include <linux/grinternal.h>
65623 +
65624 +void
65625 +gr_handle_ioperm(void)
65626 +{
65627 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65628 + return;
65629 +}
65630 +
65631 +void
65632 +gr_handle_iopl(void)
65633 +{
65634 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65635 + return;
65636 +}
65637 +
65638 +void
65639 +gr_handle_mem_readwrite(u64 from, u64 to)
65640 +{
65641 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65642 + return;
65643 +}
65644 +
65645 +void
65646 +gr_handle_vm86(void)
65647 +{
65648 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65649 + return;
65650 +}
65651 +
65652 +void
65653 +gr_log_badprocpid(const char *entry)
65654 +{
65655 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65656 + return;
65657 +}
65658 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65659 new file mode 100644
65660 index 0000000..2131422
65661 --- /dev/null
65662 +++ b/grsecurity/grsec_mount.c
65663 @@ -0,0 +1,62 @@
65664 +#include <linux/kernel.h>
65665 +#include <linux/sched.h>
65666 +#include <linux/mount.h>
65667 +#include <linux/grsecurity.h>
65668 +#include <linux/grinternal.h>
65669 +
65670 +void
65671 +gr_log_remount(const char *devname, const int retval)
65672 +{
65673 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65674 + if (grsec_enable_mount && (retval >= 0))
65675 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65676 +#endif
65677 + return;
65678 +}
65679 +
65680 +void
65681 +gr_log_unmount(const char *devname, const int retval)
65682 +{
65683 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65684 + if (grsec_enable_mount && (retval >= 0))
65685 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65686 +#endif
65687 + return;
65688 +}
65689 +
65690 +void
65691 +gr_log_mount(const char *from, const char *to, const int retval)
65692 +{
65693 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65694 + if (grsec_enable_mount && (retval >= 0))
65695 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65696 +#endif
65697 + return;
65698 +}
65699 +
65700 +int
65701 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65702 +{
65703 +#ifdef CONFIG_GRKERNSEC_ROFS
65704 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65705 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65706 + return -EPERM;
65707 + } else
65708 + return 0;
65709 +#endif
65710 + return 0;
65711 +}
65712 +
65713 +int
65714 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65715 +{
65716 +#ifdef CONFIG_GRKERNSEC_ROFS
65717 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65718 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65719 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65720 + return -EPERM;
65721 + } else
65722 + return 0;
65723 +#endif
65724 + return 0;
65725 +}
65726 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65727 new file mode 100644
65728 index 0000000..a3b12a0
65729 --- /dev/null
65730 +++ b/grsecurity/grsec_pax.c
65731 @@ -0,0 +1,36 @@
65732 +#include <linux/kernel.h>
65733 +#include <linux/sched.h>
65734 +#include <linux/mm.h>
65735 +#include <linux/file.h>
65736 +#include <linux/grinternal.h>
65737 +#include <linux/grsecurity.h>
65738 +
65739 +void
65740 +gr_log_textrel(struct vm_area_struct * vma)
65741 +{
65742 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65743 + if (grsec_enable_audit_textrel)
65744 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65745 +#endif
65746 + return;
65747 +}
65748 +
65749 +void
65750 +gr_log_rwxmmap(struct file *file)
65751 +{
65752 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65753 + if (grsec_enable_log_rwxmaps)
65754 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65755 +#endif
65756 + return;
65757 +}
65758 +
65759 +void
65760 +gr_log_rwxmprotect(struct file *file)
65761 +{
65762 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65763 + if (grsec_enable_log_rwxmaps)
65764 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65765 +#endif
65766 + return;
65767 +}
65768 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65769 new file mode 100644
65770 index 0000000..f7f29aa
65771 --- /dev/null
65772 +++ b/grsecurity/grsec_ptrace.c
65773 @@ -0,0 +1,30 @@
65774 +#include <linux/kernel.h>
65775 +#include <linux/sched.h>
65776 +#include <linux/grinternal.h>
65777 +#include <linux/security.h>
65778 +
65779 +void
65780 +gr_audit_ptrace(struct task_struct *task)
65781 +{
65782 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65783 + if (grsec_enable_audit_ptrace)
65784 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65785 +#endif
65786 + return;
65787 +}
65788 +
65789 +int
65790 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65791 +{
65792 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65793 + const struct dentry *dentry = file->f_path.dentry;
65794 + const struct vfsmount *mnt = file->f_path.mnt;
65795 +
65796 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65797 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65798 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65799 + return -EACCES;
65800 + }
65801 +#endif
65802 + return 0;
65803 +}
65804 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65805 new file mode 100644
65806 index 0000000..e09715a
65807 --- /dev/null
65808 +++ b/grsecurity/grsec_sig.c
65809 @@ -0,0 +1,222 @@
65810 +#include <linux/kernel.h>
65811 +#include <linux/sched.h>
65812 +#include <linux/delay.h>
65813 +#include <linux/grsecurity.h>
65814 +#include <linux/grinternal.h>
65815 +#include <linux/hardirq.h>
65816 +
65817 +char *signames[] = {
65818 + [SIGSEGV] = "Segmentation fault",
65819 + [SIGILL] = "Illegal instruction",
65820 + [SIGABRT] = "Abort",
65821 + [SIGBUS] = "Invalid alignment/Bus error"
65822 +};
65823 +
65824 +void
65825 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65826 +{
65827 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65828 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65829 + (sig == SIGABRT) || (sig == SIGBUS))) {
65830 + if (task_pid_nr(t) == task_pid_nr(current)) {
65831 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65832 + } else {
65833 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65834 + }
65835 + }
65836 +#endif
65837 + return;
65838 +}
65839 +
65840 +int
65841 +gr_handle_signal(const struct task_struct *p, const int sig)
65842 +{
65843 +#ifdef CONFIG_GRKERNSEC
65844 + /* ignore the 0 signal for protected task checks */
65845 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65846 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65847 + return -EPERM;
65848 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65849 + return -EPERM;
65850 + }
65851 +#endif
65852 + return 0;
65853 +}
65854 +
65855 +#ifdef CONFIG_GRKERNSEC
65856 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65857 +
65858 +int gr_fake_force_sig(int sig, struct task_struct *t)
65859 +{
65860 + unsigned long int flags;
65861 + int ret, blocked, ignored;
65862 + struct k_sigaction *action;
65863 +
65864 + spin_lock_irqsave(&t->sighand->siglock, flags);
65865 + action = &t->sighand->action[sig-1];
65866 + ignored = action->sa.sa_handler == SIG_IGN;
65867 + blocked = sigismember(&t->blocked, sig);
65868 + if (blocked || ignored) {
65869 + action->sa.sa_handler = SIG_DFL;
65870 + if (blocked) {
65871 + sigdelset(&t->blocked, sig);
65872 + recalc_sigpending_and_wake(t);
65873 + }
65874 + }
65875 + if (action->sa.sa_handler == SIG_DFL)
65876 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65877 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65878 +
65879 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65880 +
65881 + return ret;
65882 +}
65883 +#endif
65884 +
65885 +#ifdef CONFIG_GRKERNSEC_BRUTE
65886 +#define GR_USER_BAN_TIME (15 * 60)
65887 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65888 +
65889 +static int __get_dumpable(unsigned long mm_flags)
65890 +{
65891 + int ret;
65892 +
65893 + ret = mm_flags & MMF_DUMPABLE_MASK;
65894 + return (ret >= 2) ? 2 : ret;
65895 +}
65896 +#endif
65897 +
65898 +void gr_handle_brute_attach(unsigned long mm_flags)
65899 +{
65900 +#ifdef CONFIG_GRKERNSEC_BRUTE
65901 + struct task_struct *p = current;
65902 + kuid_t uid = GLOBAL_ROOT_UID;
65903 + int daemon = 0;
65904 +
65905 + if (!grsec_enable_brute)
65906 + return;
65907 +
65908 + rcu_read_lock();
65909 + read_lock(&tasklist_lock);
65910 + read_lock(&grsec_exec_file_lock);
65911 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65912 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65913 + p->real_parent->brute = 1;
65914 + daemon = 1;
65915 + } else {
65916 + const struct cred *cred = __task_cred(p), *cred2;
65917 + struct task_struct *tsk, *tsk2;
65918 +
65919 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65920 + struct user_struct *user;
65921 +
65922 + uid = cred->uid;
65923 +
65924 + /* this is put upon execution past expiration */
65925 + user = find_user(uid);
65926 + if (user == NULL)
65927 + goto unlock;
65928 + user->banned = 1;
65929 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65930 + if (user->ban_expires == ~0UL)
65931 + user->ban_expires--;
65932 +
65933 + do_each_thread(tsk2, tsk) {
65934 + cred2 = __task_cred(tsk);
65935 + if (tsk != p && uid_eq(cred2->uid, uid))
65936 + gr_fake_force_sig(SIGKILL, tsk);
65937 + } while_each_thread(tsk2, tsk);
65938 + }
65939 + }
65940 +unlock:
65941 + read_unlock(&grsec_exec_file_lock);
65942 + read_unlock(&tasklist_lock);
65943 + rcu_read_unlock();
65944 +
65945 + if (gr_is_global_nonroot(uid))
65946 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65947 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65948 + else if (daemon)
65949 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65950 +
65951 +#endif
65952 + return;
65953 +}
65954 +
65955 +void gr_handle_brute_check(void)
65956 +{
65957 +#ifdef CONFIG_GRKERNSEC_BRUTE
65958 + struct task_struct *p = current;
65959 +
65960 + if (unlikely(p->brute)) {
65961 + if (!grsec_enable_brute)
65962 + p->brute = 0;
65963 + else if (time_before(get_seconds(), p->brute_expires))
65964 + msleep(30 * 1000);
65965 + }
65966 +#endif
65967 + return;
65968 +}
65969 +
65970 +void gr_handle_kernel_exploit(void)
65971 +{
65972 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65973 + const struct cred *cred;
65974 + struct task_struct *tsk, *tsk2;
65975 + struct user_struct *user;
65976 + kuid_t uid;
65977 +
65978 + if (in_irq() || in_serving_softirq() || in_nmi())
65979 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65980 +
65981 + uid = current_uid();
65982 +
65983 + if (gr_is_global_root(uid))
65984 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65985 + else {
65986 + /* kill all the processes of this user, hold a reference
65987 + to their creds struct, and prevent them from creating
65988 + another process until system reset
65989 + */
65990 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
65991 + GR_GLOBAL_UID(uid));
65992 + /* we intentionally leak this ref */
65993 + user = get_uid(current->cred->user);
65994 + if (user) {
65995 + user->banned = 1;
65996 + user->ban_expires = ~0UL;
65997 + }
65998 +
65999 + read_lock(&tasklist_lock);
66000 + do_each_thread(tsk2, tsk) {
66001 + cred = __task_cred(tsk);
66002 + if (uid_eq(cred->uid, uid))
66003 + gr_fake_force_sig(SIGKILL, tsk);
66004 + } while_each_thread(tsk2, tsk);
66005 + read_unlock(&tasklist_lock);
66006 + }
66007 +#endif
66008 +}
66009 +
66010 +int __gr_process_user_ban(struct user_struct *user)
66011 +{
66012 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66013 + if (unlikely(user->banned)) {
66014 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
66015 + user->banned = 0;
66016 + user->ban_expires = 0;
66017 + free_uid(user);
66018 + } else
66019 + return -EPERM;
66020 + }
66021 +#endif
66022 + return 0;
66023 +}
66024 +
66025 +int gr_process_user_ban(void)
66026 +{
66027 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66028 + return __gr_process_user_ban(current->cred->user);
66029 +#endif
66030 + return 0;
66031 +}
66032 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66033 new file mode 100644
66034 index 0000000..4030d57
66035 --- /dev/null
66036 +++ b/grsecurity/grsec_sock.c
66037 @@ -0,0 +1,244 @@
66038 +#include <linux/kernel.h>
66039 +#include <linux/module.h>
66040 +#include <linux/sched.h>
66041 +#include <linux/file.h>
66042 +#include <linux/net.h>
66043 +#include <linux/in.h>
66044 +#include <linux/ip.h>
66045 +#include <net/sock.h>
66046 +#include <net/inet_sock.h>
66047 +#include <linux/grsecurity.h>
66048 +#include <linux/grinternal.h>
66049 +#include <linux/gracl.h>
66050 +
66051 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66052 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66053 +
66054 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66055 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66056 +
66057 +#ifdef CONFIG_UNIX_MODULE
66058 +EXPORT_SYMBOL(gr_acl_handle_unix);
66059 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66060 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66061 +EXPORT_SYMBOL(gr_handle_create);
66062 +#endif
66063 +
66064 +#ifdef CONFIG_GRKERNSEC
66065 +#define gr_conn_table_size 32749
66066 +struct conn_table_entry {
66067 + struct conn_table_entry *next;
66068 + struct signal_struct *sig;
66069 +};
66070 +
66071 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66072 +DEFINE_SPINLOCK(gr_conn_table_lock);
66073 +
66074 +extern const char * gr_socktype_to_name(unsigned char type);
66075 +extern const char * gr_proto_to_name(unsigned char proto);
66076 +extern const char * gr_sockfamily_to_name(unsigned char family);
66077 +
66078 +static __inline__ int
66079 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66080 +{
66081 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66082 +}
66083 +
66084 +static __inline__ int
66085 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66086 + __u16 sport, __u16 dport)
66087 +{
66088 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66089 + sig->gr_sport == sport && sig->gr_dport == dport))
66090 + return 1;
66091 + else
66092 + return 0;
66093 +}
66094 +
66095 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66096 +{
66097 + struct conn_table_entry **match;
66098 + unsigned int index;
66099 +
66100 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66101 + sig->gr_sport, sig->gr_dport,
66102 + gr_conn_table_size);
66103 +
66104 + newent->sig = sig;
66105 +
66106 + match = &gr_conn_table[index];
66107 + newent->next = *match;
66108 + *match = newent;
66109 +
66110 + return;
66111 +}
66112 +
66113 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66114 +{
66115 + struct conn_table_entry *match, *last = NULL;
66116 + unsigned int index;
66117 +
66118 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66119 + sig->gr_sport, sig->gr_dport,
66120 + gr_conn_table_size);
66121 +
66122 + match = gr_conn_table[index];
66123 + while (match && !conn_match(match->sig,
66124 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66125 + sig->gr_dport)) {
66126 + last = match;
66127 + match = match->next;
66128 + }
66129 +
66130 + if (match) {
66131 + if (last)
66132 + last->next = match->next;
66133 + else
66134 + gr_conn_table[index] = NULL;
66135 + kfree(match);
66136 + }
66137 +
66138 + return;
66139 +}
66140 +
66141 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66142 + __u16 sport, __u16 dport)
66143 +{
66144 + struct conn_table_entry *match;
66145 + unsigned int index;
66146 +
66147 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66148 +
66149 + match = gr_conn_table[index];
66150 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66151 + match = match->next;
66152 +
66153 + if (match)
66154 + return match->sig;
66155 + else
66156 + return NULL;
66157 +}
66158 +
66159 +#endif
66160 +
66161 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66162 +{
66163 +#ifdef CONFIG_GRKERNSEC
66164 + struct signal_struct *sig = task->signal;
66165 + struct conn_table_entry *newent;
66166 +
66167 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66168 + if (newent == NULL)
66169 + return;
66170 + /* no bh lock needed since we are called with bh disabled */
66171 + spin_lock(&gr_conn_table_lock);
66172 + gr_del_task_from_ip_table_nolock(sig);
66173 + sig->gr_saddr = inet->inet_rcv_saddr;
66174 + sig->gr_daddr = inet->inet_daddr;
66175 + sig->gr_sport = inet->inet_sport;
66176 + sig->gr_dport = inet->inet_dport;
66177 + gr_add_to_task_ip_table_nolock(sig, newent);
66178 + spin_unlock(&gr_conn_table_lock);
66179 +#endif
66180 + return;
66181 +}
66182 +
66183 +void gr_del_task_from_ip_table(struct task_struct *task)
66184 +{
66185 +#ifdef CONFIG_GRKERNSEC
66186 + spin_lock_bh(&gr_conn_table_lock);
66187 + gr_del_task_from_ip_table_nolock(task->signal);
66188 + spin_unlock_bh(&gr_conn_table_lock);
66189 +#endif
66190 + return;
66191 +}
66192 +
66193 +void
66194 +gr_attach_curr_ip(const struct sock *sk)
66195 +{
66196 +#ifdef CONFIG_GRKERNSEC
66197 + struct signal_struct *p, *set;
66198 + const struct inet_sock *inet = inet_sk(sk);
66199 +
66200 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66201 + return;
66202 +
66203 + set = current->signal;
66204 +
66205 + spin_lock_bh(&gr_conn_table_lock);
66206 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66207 + inet->inet_dport, inet->inet_sport);
66208 + if (unlikely(p != NULL)) {
66209 + set->curr_ip = p->curr_ip;
66210 + set->used_accept = 1;
66211 + gr_del_task_from_ip_table_nolock(p);
66212 + spin_unlock_bh(&gr_conn_table_lock);
66213 + return;
66214 + }
66215 + spin_unlock_bh(&gr_conn_table_lock);
66216 +
66217 + set->curr_ip = inet->inet_daddr;
66218 + set->used_accept = 1;
66219 +#endif
66220 + return;
66221 +}
66222 +
66223 +int
66224 +gr_handle_sock_all(const int family, const int type, const int protocol)
66225 +{
66226 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66227 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66228 + (family != AF_UNIX)) {
66229 + if (family == AF_INET)
66230 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66231 + else
66232 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66233 + return -EACCES;
66234 + }
66235 +#endif
66236 + return 0;
66237 +}
66238 +
66239 +int
66240 +gr_handle_sock_server(const struct sockaddr *sck)
66241 +{
66242 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66243 + if (grsec_enable_socket_server &&
66244 + in_group_p(grsec_socket_server_gid) &&
66245 + sck && (sck->sa_family != AF_UNIX) &&
66246 + (sck->sa_family != AF_LOCAL)) {
66247 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66248 + return -EACCES;
66249 + }
66250 +#endif
66251 + return 0;
66252 +}
66253 +
66254 +int
66255 +gr_handle_sock_server_other(const struct sock *sck)
66256 +{
66257 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66258 + if (grsec_enable_socket_server &&
66259 + in_group_p(grsec_socket_server_gid) &&
66260 + sck && (sck->sk_family != AF_UNIX) &&
66261 + (sck->sk_family != AF_LOCAL)) {
66262 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66263 + return -EACCES;
66264 + }
66265 +#endif
66266 + return 0;
66267 +}
66268 +
66269 +int
66270 +gr_handle_sock_client(const struct sockaddr *sck)
66271 +{
66272 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66273 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66274 + sck && (sck->sa_family != AF_UNIX) &&
66275 + (sck->sa_family != AF_LOCAL)) {
66276 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66277 + return -EACCES;
66278 + }
66279 +#endif
66280 + return 0;
66281 +}
66282 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66283 new file mode 100644
66284 index 0000000..f55ef0f
66285 --- /dev/null
66286 +++ b/grsecurity/grsec_sysctl.c
66287 @@ -0,0 +1,469 @@
66288 +#include <linux/kernel.h>
66289 +#include <linux/sched.h>
66290 +#include <linux/sysctl.h>
66291 +#include <linux/grsecurity.h>
66292 +#include <linux/grinternal.h>
66293 +
66294 +int
66295 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66296 +{
66297 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66298 + if (dirname == NULL || name == NULL)
66299 + return 0;
66300 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66301 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66302 + return -EACCES;
66303 + }
66304 +#endif
66305 + return 0;
66306 +}
66307 +
66308 +#ifdef CONFIG_GRKERNSEC_ROFS
66309 +static int __maybe_unused one = 1;
66310 +#endif
66311 +
66312 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66313 +struct ctl_table grsecurity_table[] = {
66314 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66315 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66316 +#ifdef CONFIG_GRKERNSEC_IO
66317 + {
66318 + .procname = "disable_priv_io",
66319 + .data = &grsec_disable_privio,
66320 + .maxlen = sizeof(int),
66321 + .mode = 0600,
66322 + .proc_handler = &proc_dointvec,
66323 + },
66324 +#endif
66325 +#endif
66326 +#ifdef CONFIG_GRKERNSEC_LINK
66327 + {
66328 + .procname = "linking_restrictions",
66329 + .data = &grsec_enable_link,
66330 + .maxlen = sizeof(int),
66331 + .mode = 0600,
66332 + .proc_handler = &proc_dointvec,
66333 + },
66334 +#endif
66335 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66336 + {
66337 + .procname = "enforce_symlinksifowner",
66338 + .data = &grsec_enable_symlinkown,
66339 + .maxlen = sizeof(int),
66340 + .mode = 0600,
66341 + .proc_handler = &proc_dointvec,
66342 + },
66343 + {
66344 + .procname = "symlinkown_gid",
66345 + .data = &grsec_symlinkown_gid,
66346 + .maxlen = sizeof(int),
66347 + .mode = 0600,
66348 + .proc_handler = &proc_dointvec,
66349 + },
66350 +#endif
66351 +#ifdef CONFIG_GRKERNSEC_BRUTE
66352 + {
66353 + .procname = "deter_bruteforce",
66354 + .data = &grsec_enable_brute,
66355 + .maxlen = sizeof(int),
66356 + .mode = 0600,
66357 + .proc_handler = &proc_dointvec,
66358 + },
66359 +#endif
66360 +#ifdef CONFIG_GRKERNSEC_FIFO
66361 + {
66362 + .procname = "fifo_restrictions",
66363 + .data = &grsec_enable_fifo,
66364 + .maxlen = sizeof(int),
66365 + .mode = 0600,
66366 + .proc_handler = &proc_dointvec,
66367 + },
66368 +#endif
66369 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66370 + {
66371 + .procname = "ptrace_readexec",
66372 + .data = &grsec_enable_ptrace_readexec,
66373 + .maxlen = sizeof(int),
66374 + .mode = 0600,
66375 + .proc_handler = &proc_dointvec,
66376 + },
66377 +#endif
66378 +#ifdef CONFIG_GRKERNSEC_SETXID
66379 + {
66380 + .procname = "consistent_setxid",
66381 + .data = &grsec_enable_setxid,
66382 + .maxlen = sizeof(int),
66383 + .mode = 0600,
66384 + .proc_handler = &proc_dointvec,
66385 + },
66386 +#endif
66387 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66388 + {
66389 + .procname = "ip_blackhole",
66390 + .data = &grsec_enable_blackhole,
66391 + .maxlen = sizeof(int),
66392 + .mode = 0600,
66393 + .proc_handler = &proc_dointvec,
66394 + },
66395 + {
66396 + .procname = "lastack_retries",
66397 + .data = &grsec_lastack_retries,
66398 + .maxlen = sizeof(int),
66399 + .mode = 0600,
66400 + .proc_handler = &proc_dointvec,
66401 + },
66402 +#endif
66403 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66404 + {
66405 + .procname = "exec_logging",
66406 + .data = &grsec_enable_execlog,
66407 + .maxlen = sizeof(int),
66408 + .mode = 0600,
66409 + .proc_handler = &proc_dointvec,
66410 + },
66411 +#endif
66412 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66413 + {
66414 + .procname = "rwxmap_logging",
66415 + .data = &grsec_enable_log_rwxmaps,
66416 + .maxlen = sizeof(int),
66417 + .mode = 0600,
66418 + .proc_handler = &proc_dointvec,
66419 + },
66420 +#endif
66421 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66422 + {
66423 + .procname = "signal_logging",
66424 + .data = &grsec_enable_signal,
66425 + .maxlen = sizeof(int),
66426 + .mode = 0600,
66427 + .proc_handler = &proc_dointvec,
66428 + },
66429 +#endif
66430 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66431 + {
66432 + .procname = "forkfail_logging",
66433 + .data = &grsec_enable_forkfail,
66434 + .maxlen = sizeof(int),
66435 + .mode = 0600,
66436 + .proc_handler = &proc_dointvec,
66437 + },
66438 +#endif
66439 +#ifdef CONFIG_GRKERNSEC_TIME
66440 + {
66441 + .procname = "timechange_logging",
66442 + .data = &grsec_enable_time,
66443 + .maxlen = sizeof(int),
66444 + .mode = 0600,
66445 + .proc_handler = &proc_dointvec,
66446 + },
66447 +#endif
66448 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66449 + {
66450 + .procname = "chroot_deny_shmat",
66451 + .data = &grsec_enable_chroot_shmat,
66452 + .maxlen = sizeof(int),
66453 + .mode = 0600,
66454 + .proc_handler = &proc_dointvec,
66455 + },
66456 +#endif
66457 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66458 + {
66459 + .procname = "chroot_deny_unix",
66460 + .data = &grsec_enable_chroot_unix,
66461 + .maxlen = sizeof(int),
66462 + .mode = 0600,
66463 + .proc_handler = &proc_dointvec,
66464 + },
66465 +#endif
66466 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66467 + {
66468 + .procname = "chroot_deny_mount",
66469 + .data = &grsec_enable_chroot_mount,
66470 + .maxlen = sizeof(int),
66471 + .mode = 0600,
66472 + .proc_handler = &proc_dointvec,
66473 + },
66474 +#endif
66475 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66476 + {
66477 + .procname = "chroot_deny_fchdir",
66478 + .data = &grsec_enable_chroot_fchdir,
66479 + .maxlen = sizeof(int),
66480 + .mode = 0600,
66481 + .proc_handler = &proc_dointvec,
66482 + },
66483 +#endif
66484 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66485 + {
66486 + .procname = "chroot_deny_chroot",
66487 + .data = &grsec_enable_chroot_double,
66488 + .maxlen = sizeof(int),
66489 + .mode = 0600,
66490 + .proc_handler = &proc_dointvec,
66491 + },
66492 +#endif
66493 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66494 + {
66495 + .procname = "chroot_deny_pivot",
66496 + .data = &grsec_enable_chroot_pivot,
66497 + .maxlen = sizeof(int),
66498 + .mode = 0600,
66499 + .proc_handler = &proc_dointvec,
66500 + },
66501 +#endif
66502 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66503 + {
66504 + .procname = "chroot_enforce_chdir",
66505 + .data = &grsec_enable_chroot_chdir,
66506 + .maxlen = sizeof(int),
66507 + .mode = 0600,
66508 + .proc_handler = &proc_dointvec,
66509 + },
66510 +#endif
66511 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66512 + {
66513 + .procname = "chroot_deny_chmod",
66514 + .data = &grsec_enable_chroot_chmod,
66515 + .maxlen = sizeof(int),
66516 + .mode = 0600,
66517 + .proc_handler = &proc_dointvec,
66518 + },
66519 +#endif
66520 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66521 + {
66522 + .procname = "chroot_deny_mknod",
66523 + .data = &grsec_enable_chroot_mknod,
66524 + .maxlen = sizeof(int),
66525 + .mode = 0600,
66526 + .proc_handler = &proc_dointvec,
66527 + },
66528 +#endif
66529 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66530 + {
66531 + .procname = "chroot_restrict_nice",
66532 + .data = &grsec_enable_chroot_nice,
66533 + .maxlen = sizeof(int),
66534 + .mode = 0600,
66535 + .proc_handler = &proc_dointvec,
66536 + },
66537 +#endif
66538 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66539 + {
66540 + .procname = "chroot_execlog",
66541 + .data = &grsec_enable_chroot_execlog,
66542 + .maxlen = sizeof(int),
66543 + .mode = 0600,
66544 + .proc_handler = &proc_dointvec,
66545 + },
66546 +#endif
66547 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66548 + {
66549 + .procname = "chroot_caps",
66550 + .data = &grsec_enable_chroot_caps,
66551 + .maxlen = sizeof(int),
66552 + .mode = 0600,
66553 + .proc_handler = &proc_dointvec,
66554 + },
66555 +#endif
66556 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66557 + {
66558 + .procname = "chroot_deny_sysctl",
66559 + .data = &grsec_enable_chroot_sysctl,
66560 + .maxlen = sizeof(int),
66561 + .mode = 0600,
66562 + .proc_handler = &proc_dointvec,
66563 + },
66564 +#endif
66565 +#ifdef CONFIG_GRKERNSEC_TPE
66566 + {
66567 + .procname = "tpe",
66568 + .data = &grsec_enable_tpe,
66569 + .maxlen = sizeof(int),
66570 + .mode = 0600,
66571 + .proc_handler = &proc_dointvec,
66572 + },
66573 + {
66574 + .procname = "tpe_gid",
66575 + .data = &grsec_tpe_gid,
66576 + .maxlen = sizeof(int),
66577 + .mode = 0600,
66578 + .proc_handler = &proc_dointvec,
66579 + },
66580 +#endif
66581 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66582 + {
66583 + .procname = "tpe_invert",
66584 + .data = &grsec_enable_tpe_invert,
66585 + .maxlen = sizeof(int),
66586 + .mode = 0600,
66587 + .proc_handler = &proc_dointvec,
66588 + },
66589 +#endif
66590 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66591 + {
66592 + .procname = "tpe_restrict_all",
66593 + .data = &grsec_enable_tpe_all,
66594 + .maxlen = sizeof(int),
66595 + .mode = 0600,
66596 + .proc_handler = &proc_dointvec,
66597 + },
66598 +#endif
66599 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66600 + {
66601 + .procname = "socket_all",
66602 + .data = &grsec_enable_socket_all,
66603 + .maxlen = sizeof(int),
66604 + .mode = 0600,
66605 + .proc_handler = &proc_dointvec,
66606 + },
66607 + {
66608 + .procname = "socket_all_gid",
66609 + .data = &grsec_socket_all_gid,
66610 + .maxlen = sizeof(int),
66611 + .mode = 0600,
66612 + .proc_handler = &proc_dointvec,
66613 + },
66614 +#endif
66615 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66616 + {
66617 + .procname = "socket_client",
66618 + .data = &grsec_enable_socket_client,
66619 + .maxlen = sizeof(int),
66620 + .mode = 0600,
66621 + .proc_handler = &proc_dointvec,
66622 + },
66623 + {
66624 + .procname = "socket_client_gid",
66625 + .data = &grsec_socket_client_gid,
66626 + .maxlen = sizeof(int),
66627 + .mode = 0600,
66628 + .proc_handler = &proc_dointvec,
66629 + },
66630 +#endif
66631 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66632 + {
66633 + .procname = "socket_server",
66634 + .data = &grsec_enable_socket_server,
66635 + .maxlen = sizeof(int),
66636 + .mode = 0600,
66637 + .proc_handler = &proc_dointvec,
66638 + },
66639 + {
66640 + .procname = "socket_server_gid",
66641 + .data = &grsec_socket_server_gid,
66642 + .maxlen = sizeof(int),
66643 + .mode = 0600,
66644 + .proc_handler = &proc_dointvec,
66645 + },
66646 +#endif
66647 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66648 + {
66649 + .procname = "audit_group",
66650 + .data = &grsec_enable_group,
66651 + .maxlen = sizeof(int),
66652 + .mode = 0600,
66653 + .proc_handler = &proc_dointvec,
66654 + },
66655 + {
66656 + .procname = "audit_gid",
66657 + .data = &grsec_audit_gid,
66658 + .maxlen = sizeof(int),
66659 + .mode = 0600,
66660 + .proc_handler = &proc_dointvec,
66661 + },
66662 +#endif
66663 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66664 + {
66665 + .procname = "audit_chdir",
66666 + .data = &grsec_enable_chdir,
66667 + .maxlen = sizeof(int),
66668 + .mode = 0600,
66669 + .proc_handler = &proc_dointvec,
66670 + },
66671 +#endif
66672 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66673 + {
66674 + .procname = "audit_mount",
66675 + .data = &grsec_enable_mount,
66676 + .maxlen = sizeof(int),
66677 + .mode = 0600,
66678 + .proc_handler = &proc_dointvec,
66679 + },
66680 +#endif
66681 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66682 + {
66683 + .procname = "audit_textrel",
66684 + .data = &grsec_enable_audit_textrel,
66685 + .maxlen = sizeof(int),
66686 + .mode = 0600,
66687 + .proc_handler = &proc_dointvec,
66688 + },
66689 +#endif
66690 +#ifdef CONFIG_GRKERNSEC_DMESG
66691 + {
66692 + .procname = "dmesg",
66693 + .data = &grsec_enable_dmesg,
66694 + .maxlen = sizeof(int),
66695 + .mode = 0600,
66696 + .proc_handler = &proc_dointvec,
66697 + },
66698 +#endif
66699 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66700 + {
66701 + .procname = "chroot_findtask",
66702 + .data = &grsec_enable_chroot_findtask,
66703 + .maxlen = sizeof(int),
66704 + .mode = 0600,
66705 + .proc_handler = &proc_dointvec,
66706 + },
66707 +#endif
66708 +#ifdef CONFIG_GRKERNSEC_RESLOG
66709 + {
66710 + .procname = "resource_logging",
66711 + .data = &grsec_resource_logging,
66712 + .maxlen = sizeof(int),
66713 + .mode = 0600,
66714 + .proc_handler = &proc_dointvec,
66715 + },
66716 +#endif
66717 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66718 + {
66719 + .procname = "audit_ptrace",
66720 + .data = &grsec_enable_audit_ptrace,
66721 + .maxlen = sizeof(int),
66722 + .mode = 0600,
66723 + .proc_handler = &proc_dointvec,
66724 + },
66725 +#endif
66726 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66727 + {
66728 + .procname = "harden_ptrace",
66729 + .data = &grsec_enable_harden_ptrace,
66730 + .maxlen = sizeof(int),
66731 + .mode = 0600,
66732 + .proc_handler = &proc_dointvec,
66733 + },
66734 +#endif
66735 + {
66736 + .procname = "grsec_lock",
66737 + .data = &grsec_lock,
66738 + .maxlen = sizeof(int),
66739 + .mode = 0600,
66740 + .proc_handler = &proc_dointvec,
66741 + },
66742 +#endif
66743 +#ifdef CONFIG_GRKERNSEC_ROFS
66744 + {
66745 + .procname = "romount_protect",
66746 + .data = &grsec_enable_rofs,
66747 + .maxlen = sizeof(int),
66748 + .mode = 0600,
66749 + .proc_handler = &proc_dointvec_minmax,
66750 + .extra1 = &one,
66751 + .extra2 = &one,
66752 + },
66753 +#endif
66754 + { }
66755 +};
66756 +#endif
66757 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66758 new file mode 100644
66759 index 0000000..0dc13c3
66760 --- /dev/null
66761 +++ b/grsecurity/grsec_time.c
66762 @@ -0,0 +1,16 @@
66763 +#include <linux/kernel.h>
66764 +#include <linux/sched.h>
66765 +#include <linux/grinternal.h>
66766 +#include <linux/module.h>
66767 +
66768 +void
66769 +gr_log_timechange(void)
66770 +{
66771 +#ifdef CONFIG_GRKERNSEC_TIME
66772 + if (grsec_enable_time)
66773 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66774 +#endif
66775 + return;
66776 +}
66777 +
66778 +EXPORT_SYMBOL(gr_log_timechange);
66779 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66780 new file mode 100644
66781 index 0000000..ee57dcf
66782 --- /dev/null
66783 +++ b/grsecurity/grsec_tpe.c
66784 @@ -0,0 +1,73 @@
66785 +#include <linux/kernel.h>
66786 +#include <linux/sched.h>
66787 +#include <linux/file.h>
66788 +#include <linux/fs.h>
66789 +#include <linux/grinternal.h>
66790 +
66791 +extern int gr_acl_tpe_check(void);
66792 +
66793 +int
66794 +gr_tpe_allow(const struct file *file)
66795 +{
66796 +#ifdef CONFIG_GRKERNSEC
66797 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66798 + const struct cred *cred = current_cred();
66799 + char *msg = NULL;
66800 + char *msg2 = NULL;
66801 +
66802 + // never restrict root
66803 + if (gr_is_global_root(cred->uid))
66804 + return 1;
66805 +
66806 + if (grsec_enable_tpe) {
66807 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66808 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66809 + msg = "not being in trusted group";
66810 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66811 + msg = "being in untrusted group";
66812 +#else
66813 + if (in_group_p(grsec_tpe_gid))
66814 + msg = "being in untrusted group";
66815 +#endif
66816 + }
66817 + if (!msg && gr_acl_tpe_check())
66818 + msg = "being in untrusted role";
66819 +
66820 + // not in any affected group/role
66821 + if (!msg)
66822 + goto next_check;
66823 +
66824 + if (gr_is_global_nonroot(inode->i_uid))
66825 + msg2 = "file in non-root-owned directory";
66826 + else if (inode->i_mode & S_IWOTH)
66827 + msg2 = "file in world-writable directory";
66828 + else if (inode->i_mode & S_IWGRP)
66829 + msg2 = "file in group-writable directory";
66830 +
66831 + if (msg && msg2) {
66832 + char fullmsg[70] = {0};
66833 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66834 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66835 + return 0;
66836 + }
66837 + msg = NULL;
66838 +next_check:
66839 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66840 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66841 + return 1;
66842 +
66843 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66844 + msg = "directory not owned by user";
66845 + else if (inode->i_mode & S_IWOTH)
66846 + msg = "file in world-writable directory";
66847 + else if (inode->i_mode & S_IWGRP)
66848 + msg = "file in group-writable directory";
66849 +
66850 + if (msg) {
66851 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66852 + return 0;
66853 + }
66854 +#endif
66855 +#endif
66856 + return 1;
66857 +}
66858 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66859 new file mode 100644
66860 index 0000000..9f7b1ac
66861 --- /dev/null
66862 +++ b/grsecurity/grsum.c
66863 @@ -0,0 +1,61 @@
66864 +#include <linux/err.h>
66865 +#include <linux/kernel.h>
66866 +#include <linux/sched.h>
66867 +#include <linux/mm.h>
66868 +#include <linux/scatterlist.h>
66869 +#include <linux/crypto.h>
66870 +#include <linux/gracl.h>
66871 +
66872 +
66873 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66874 +#error "crypto and sha256 must be built into the kernel"
66875 +#endif
66876 +
66877 +int
66878 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66879 +{
66880 + char *p;
66881 + struct crypto_hash *tfm;
66882 + struct hash_desc desc;
66883 + struct scatterlist sg;
66884 + unsigned char temp_sum[GR_SHA_LEN];
66885 + volatile int retval = 0;
66886 + volatile int dummy = 0;
66887 + unsigned int i;
66888 +
66889 + sg_init_table(&sg, 1);
66890 +
66891 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66892 + if (IS_ERR(tfm)) {
66893 + /* should never happen, since sha256 should be built in */
66894 + return 1;
66895 + }
66896 +
66897 + desc.tfm = tfm;
66898 + desc.flags = 0;
66899 +
66900 + crypto_hash_init(&desc);
66901 +
66902 + p = salt;
66903 + sg_set_buf(&sg, p, GR_SALT_LEN);
66904 + crypto_hash_update(&desc, &sg, sg.length);
66905 +
66906 + p = entry->pw;
66907 + sg_set_buf(&sg, p, strlen(p));
66908 +
66909 + crypto_hash_update(&desc, &sg, sg.length);
66910 +
66911 + crypto_hash_final(&desc, temp_sum);
66912 +
66913 + memset(entry->pw, 0, GR_PW_LEN);
66914 +
66915 + for (i = 0; i < GR_SHA_LEN; i++)
66916 + if (sum[i] != temp_sum[i])
66917 + retval = 1;
66918 + else
66919 + dummy = 1; // waste a cycle
66920 +
66921 + crypto_free_hash(tfm);
66922 +
66923 + return retval;
66924 +}
66925 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66926 index 77ff547..181834f 100644
66927 --- a/include/asm-generic/4level-fixup.h
66928 +++ b/include/asm-generic/4level-fixup.h
66929 @@ -13,8 +13,10 @@
66930 #define pmd_alloc(mm, pud, address) \
66931 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66932 NULL: pmd_offset(pud, address))
66933 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66934
66935 #define pud_alloc(mm, pgd, address) (pgd)
66936 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66937 #define pud_offset(pgd, start) (pgd)
66938 #define pud_none(pud) 0
66939 #define pud_bad(pud) 0
66940 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66941 index b7babf0..04ad282 100644
66942 --- a/include/asm-generic/atomic-long.h
66943 +++ b/include/asm-generic/atomic-long.h
66944 @@ -22,6 +22,12 @@
66945
66946 typedef atomic64_t atomic_long_t;
66947
66948 +#ifdef CONFIG_PAX_REFCOUNT
66949 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66950 +#else
66951 +typedef atomic64_t atomic_long_unchecked_t;
66952 +#endif
66953 +
66954 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66955
66956 static inline long atomic_long_read(atomic_long_t *l)
66957 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66958 return (long)atomic64_read(v);
66959 }
66960
66961 +#ifdef CONFIG_PAX_REFCOUNT
66962 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66963 +{
66964 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66965 +
66966 + return (long)atomic64_read_unchecked(v);
66967 +}
66968 +#endif
66969 +
66970 static inline void atomic_long_set(atomic_long_t *l, long i)
66971 {
66972 atomic64_t *v = (atomic64_t *)l;
66973 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66974 atomic64_set(v, i);
66975 }
66976
66977 +#ifdef CONFIG_PAX_REFCOUNT
66978 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66979 +{
66980 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66981 +
66982 + atomic64_set_unchecked(v, i);
66983 +}
66984 +#endif
66985 +
66986 static inline void atomic_long_inc(atomic_long_t *l)
66987 {
66988 atomic64_t *v = (atomic64_t *)l;
66989 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66990 atomic64_inc(v);
66991 }
66992
66993 +#ifdef CONFIG_PAX_REFCOUNT
66994 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66995 +{
66996 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66997 +
66998 + atomic64_inc_unchecked(v);
66999 +}
67000 +#endif
67001 +
67002 static inline void atomic_long_dec(atomic_long_t *l)
67003 {
67004 atomic64_t *v = (atomic64_t *)l;
67005 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67006 atomic64_dec(v);
67007 }
67008
67009 +#ifdef CONFIG_PAX_REFCOUNT
67010 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67011 +{
67012 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67013 +
67014 + atomic64_dec_unchecked(v);
67015 +}
67016 +#endif
67017 +
67018 static inline void atomic_long_add(long i, atomic_long_t *l)
67019 {
67020 atomic64_t *v = (atomic64_t *)l;
67021 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67022 atomic64_add(i, v);
67023 }
67024
67025 +#ifdef CONFIG_PAX_REFCOUNT
67026 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67027 +{
67028 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67029 +
67030 + atomic64_add_unchecked(i, v);
67031 +}
67032 +#endif
67033 +
67034 static inline void atomic_long_sub(long i, atomic_long_t *l)
67035 {
67036 atomic64_t *v = (atomic64_t *)l;
67037 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67038 atomic64_sub(i, v);
67039 }
67040
67041 +#ifdef CONFIG_PAX_REFCOUNT
67042 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67043 +{
67044 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67045 +
67046 + atomic64_sub_unchecked(i, v);
67047 +}
67048 +#endif
67049 +
67050 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67051 {
67052 atomic64_t *v = (atomic64_t *)l;
67053 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67054 return (long)atomic64_add_return(i, v);
67055 }
67056
67057 +#ifdef CONFIG_PAX_REFCOUNT
67058 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67059 +{
67060 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67061 +
67062 + return (long)atomic64_add_return_unchecked(i, v);
67063 +}
67064 +#endif
67065 +
67066 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67067 {
67068 atomic64_t *v = (atomic64_t *)l;
67069 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67070 return (long)atomic64_inc_return(v);
67071 }
67072
67073 +#ifdef CONFIG_PAX_REFCOUNT
67074 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67075 +{
67076 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67077 +
67078 + return (long)atomic64_inc_return_unchecked(v);
67079 +}
67080 +#endif
67081 +
67082 static inline long atomic_long_dec_return(atomic_long_t *l)
67083 {
67084 atomic64_t *v = (atomic64_t *)l;
67085 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67086
67087 typedef atomic_t atomic_long_t;
67088
67089 +#ifdef CONFIG_PAX_REFCOUNT
67090 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67091 +#else
67092 +typedef atomic_t atomic_long_unchecked_t;
67093 +#endif
67094 +
67095 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67096 static inline long atomic_long_read(atomic_long_t *l)
67097 {
67098 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67099 return (long)atomic_read(v);
67100 }
67101
67102 +#ifdef CONFIG_PAX_REFCOUNT
67103 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67104 +{
67105 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67106 +
67107 + return (long)atomic_read_unchecked(v);
67108 +}
67109 +#endif
67110 +
67111 static inline void atomic_long_set(atomic_long_t *l, long i)
67112 {
67113 atomic_t *v = (atomic_t *)l;
67114 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67115 atomic_set(v, i);
67116 }
67117
67118 +#ifdef CONFIG_PAX_REFCOUNT
67119 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67120 +{
67121 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67122 +
67123 + atomic_set_unchecked(v, i);
67124 +}
67125 +#endif
67126 +
67127 static inline void atomic_long_inc(atomic_long_t *l)
67128 {
67129 atomic_t *v = (atomic_t *)l;
67130 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67131 atomic_inc(v);
67132 }
67133
67134 +#ifdef CONFIG_PAX_REFCOUNT
67135 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67136 +{
67137 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67138 +
67139 + atomic_inc_unchecked(v);
67140 +}
67141 +#endif
67142 +
67143 static inline void atomic_long_dec(atomic_long_t *l)
67144 {
67145 atomic_t *v = (atomic_t *)l;
67146 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67147 atomic_dec(v);
67148 }
67149
67150 +#ifdef CONFIG_PAX_REFCOUNT
67151 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67152 +{
67153 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67154 +
67155 + atomic_dec_unchecked(v);
67156 +}
67157 +#endif
67158 +
67159 static inline void atomic_long_add(long i, atomic_long_t *l)
67160 {
67161 atomic_t *v = (atomic_t *)l;
67162 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67163 atomic_add(i, v);
67164 }
67165
67166 +#ifdef CONFIG_PAX_REFCOUNT
67167 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67168 +{
67169 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67170 +
67171 + atomic_add_unchecked(i, v);
67172 +}
67173 +#endif
67174 +
67175 static inline void atomic_long_sub(long i, atomic_long_t *l)
67176 {
67177 atomic_t *v = (atomic_t *)l;
67178 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67179 atomic_sub(i, v);
67180 }
67181
67182 +#ifdef CONFIG_PAX_REFCOUNT
67183 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67184 +{
67185 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67186 +
67187 + atomic_sub_unchecked(i, v);
67188 +}
67189 +#endif
67190 +
67191 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67192 {
67193 atomic_t *v = (atomic_t *)l;
67194 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67195 return (long)atomic_add_return(i, v);
67196 }
67197
67198 +#ifdef CONFIG_PAX_REFCOUNT
67199 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67200 +{
67201 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67202 +
67203 + return (long)atomic_add_return_unchecked(i, v);
67204 +}
67205 +
67206 +#endif
67207 +
67208 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67209 {
67210 atomic_t *v = (atomic_t *)l;
67211 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67212 return (long)atomic_inc_return(v);
67213 }
67214
67215 +#ifdef CONFIG_PAX_REFCOUNT
67216 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67217 +{
67218 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67219 +
67220 + return (long)atomic_inc_return_unchecked(v);
67221 +}
67222 +#endif
67223 +
67224 static inline long atomic_long_dec_return(atomic_long_t *l)
67225 {
67226 atomic_t *v = (atomic_t *)l;
67227 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67228
67229 #endif /* BITS_PER_LONG == 64 */
67230
67231 +#ifdef CONFIG_PAX_REFCOUNT
67232 +static inline void pax_refcount_needs_these_functions(void)
67233 +{
67234 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67235 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67236 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67237 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67238 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67239 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67240 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67241 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67242 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67243 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67244 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67245 +#ifdef CONFIG_X86
67246 + atomic_clear_mask_unchecked(0, NULL);
67247 + atomic_set_mask_unchecked(0, NULL);
67248 +#endif
67249 +
67250 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67251 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67252 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67253 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67254 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67255 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67256 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67257 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67258 +}
67259 +#else
67260 +#define atomic_read_unchecked(v) atomic_read(v)
67261 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67262 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67263 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67264 +#define atomic_inc_unchecked(v) atomic_inc(v)
67265 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67266 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67267 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67268 +#define atomic_dec_unchecked(v) atomic_dec(v)
67269 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67270 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67271 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67272 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67273 +
67274 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67275 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67276 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67277 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67278 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67279 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67280 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67281 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67282 +#endif
67283 +
67284 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67285 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67286 index 1ced641..c896ee8 100644
67287 --- a/include/asm-generic/atomic.h
67288 +++ b/include/asm-generic/atomic.h
67289 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67290 * Atomically clears the bits set in @mask from @v
67291 */
67292 #ifndef atomic_clear_mask
67293 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67294 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67295 {
67296 unsigned long flags;
67297
67298 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67299 index b18ce4f..2ee2843 100644
67300 --- a/include/asm-generic/atomic64.h
67301 +++ b/include/asm-generic/atomic64.h
67302 @@ -16,6 +16,8 @@ typedef struct {
67303 long long counter;
67304 } atomic64_t;
67305
67306 +typedef atomic64_t atomic64_unchecked_t;
67307 +
67308 #define ATOMIC64_INIT(i) { (i) }
67309
67310 extern long long atomic64_read(const atomic64_t *v);
67311 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67312 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67313 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67314
67315 +#define atomic64_read_unchecked(v) atomic64_read(v)
67316 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67317 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67318 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67319 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67320 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67321 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67322 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67323 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67324 +
67325 #endif /* _ASM_GENERIC_ATOMIC64_H */
67326 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67327 index 1bfcfe5..e04c5c9 100644
67328 --- a/include/asm-generic/cache.h
67329 +++ b/include/asm-generic/cache.h
67330 @@ -6,7 +6,7 @@
67331 * cache lines need to provide their own cache.h.
67332 */
67333
67334 -#define L1_CACHE_SHIFT 5
67335 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67336 +#define L1_CACHE_SHIFT 5UL
67337 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67338
67339 #endif /* __ASM_GENERIC_CACHE_H */
67340 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67341 index 0d68a1e..b74a761 100644
67342 --- a/include/asm-generic/emergency-restart.h
67343 +++ b/include/asm-generic/emergency-restart.h
67344 @@ -1,7 +1,7 @@
67345 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67346 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67347
67348 -static inline void machine_emergency_restart(void)
67349 +static inline __noreturn void machine_emergency_restart(void)
67350 {
67351 machine_restart(NULL);
67352 }
67353 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67354 index 90f99c7..00ce236 100644
67355 --- a/include/asm-generic/kmap_types.h
67356 +++ b/include/asm-generic/kmap_types.h
67357 @@ -2,9 +2,9 @@
67358 #define _ASM_GENERIC_KMAP_TYPES_H
67359
67360 #ifdef __WITH_KM_FENCE
67361 -# define KM_TYPE_NR 41
67362 +# define KM_TYPE_NR 42
67363 #else
67364 -# define KM_TYPE_NR 20
67365 +# define KM_TYPE_NR 21
67366 #endif
67367
67368 #endif
67369 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67370 index 9ceb03b..62b0b8f 100644
67371 --- a/include/asm-generic/local.h
67372 +++ b/include/asm-generic/local.h
67373 @@ -23,24 +23,37 @@ typedef struct
67374 atomic_long_t a;
67375 } local_t;
67376
67377 +typedef struct {
67378 + atomic_long_unchecked_t a;
67379 +} local_unchecked_t;
67380 +
67381 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67382
67383 #define local_read(l) atomic_long_read(&(l)->a)
67384 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67385 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67386 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67387 #define local_inc(l) atomic_long_inc(&(l)->a)
67388 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67389 #define local_dec(l) atomic_long_dec(&(l)->a)
67390 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67391 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67392 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67393 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67394 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67395
67396 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67397 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67398 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67399 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67400 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67401 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67402 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67403 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67404 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67405
67406 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67407 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67408 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67409 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67410 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67411 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67412 index 725612b..9cc513a 100644
67413 --- a/include/asm-generic/pgtable-nopmd.h
67414 +++ b/include/asm-generic/pgtable-nopmd.h
67415 @@ -1,14 +1,19 @@
67416 #ifndef _PGTABLE_NOPMD_H
67417 #define _PGTABLE_NOPMD_H
67418
67419 -#ifndef __ASSEMBLY__
67420 -
67421 #include <asm-generic/pgtable-nopud.h>
67422
67423 -struct mm_struct;
67424 -
67425 #define __PAGETABLE_PMD_FOLDED
67426
67427 +#define PMD_SHIFT PUD_SHIFT
67428 +#define PTRS_PER_PMD 1
67429 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67430 +#define PMD_MASK (~(PMD_SIZE-1))
67431 +
67432 +#ifndef __ASSEMBLY__
67433 +
67434 +struct mm_struct;
67435 +
67436 /*
67437 * Having the pmd type consist of a pud gets the size right, and allows
67438 * us to conceptually access the pud entry that this pmd is folded into
67439 @@ -16,11 +21,6 @@ struct mm_struct;
67440 */
67441 typedef struct { pud_t pud; } pmd_t;
67442
67443 -#define PMD_SHIFT PUD_SHIFT
67444 -#define PTRS_PER_PMD 1
67445 -#define PMD_SIZE (1UL << PMD_SHIFT)
67446 -#define PMD_MASK (~(PMD_SIZE-1))
67447 -
67448 /*
67449 * The "pud_xxx()" functions here are trivial for a folded two-level
67450 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67451 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67452 index 810431d..0ec4804f 100644
67453 --- a/include/asm-generic/pgtable-nopud.h
67454 +++ b/include/asm-generic/pgtable-nopud.h
67455 @@ -1,10 +1,15 @@
67456 #ifndef _PGTABLE_NOPUD_H
67457 #define _PGTABLE_NOPUD_H
67458
67459 -#ifndef __ASSEMBLY__
67460 -
67461 #define __PAGETABLE_PUD_FOLDED
67462
67463 +#define PUD_SHIFT PGDIR_SHIFT
67464 +#define PTRS_PER_PUD 1
67465 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67466 +#define PUD_MASK (~(PUD_SIZE-1))
67467 +
67468 +#ifndef __ASSEMBLY__
67469 +
67470 /*
67471 * Having the pud type consist of a pgd gets the size right, and allows
67472 * us to conceptually access the pgd entry that this pud is folded into
67473 @@ -12,11 +17,6 @@
67474 */
67475 typedef struct { pgd_t pgd; } pud_t;
67476
67477 -#define PUD_SHIFT PGDIR_SHIFT
67478 -#define PTRS_PER_PUD 1
67479 -#define PUD_SIZE (1UL << PUD_SHIFT)
67480 -#define PUD_MASK (~(PUD_SIZE-1))
67481 -
67482 /*
67483 * The "pgd_xxx()" functions here are trivial for a folded two-level
67484 * setup: the pud is never bad, and a pud always exists (as it's folded
67485 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67486 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67487
67488 #define pgd_populate(mm, pgd, pud) do { } while (0)
67489 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67490 /*
67491 * (puds are folded into pgds so this doesn't get actually called,
67492 * but the define is needed for a generic inline function.)
67493 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67494 index 5cf680a..4b74d62 100644
67495 --- a/include/asm-generic/pgtable.h
67496 +++ b/include/asm-generic/pgtable.h
67497 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67498 }
67499 #endif /* CONFIG_NUMA_BALANCING */
67500
67501 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67502 +static inline unsigned long pax_open_kernel(void) { return 0; }
67503 +#endif
67504 +
67505 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67506 +static inline unsigned long pax_close_kernel(void) { return 0; }
67507 +#endif
67508 +
67509 #endif /* CONFIG_MMU */
67510
67511 #endif /* !__ASSEMBLY__ */
67512 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67513 index d1ea7ce..b1ebf2a 100644
67514 --- a/include/asm-generic/vmlinux.lds.h
67515 +++ b/include/asm-generic/vmlinux.lds.h
67516 @@ -218,6 +218,7 @@
67517 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67518 VMLINUX_SYMBOL(__start_rodata) = .; \
67519 *(.rodata) *(.rodata.*) \
67520 + *(.data..read_only) \
67521 *(__vermagic) /* Kernel version magic */ \
67522 . = ALIGN(8); \
67523 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67524 @@ -725,17 +726,18 @@
67525 * section in the linker script will go there too. @phdr should have
67526 * a leading colon.
67527 *
67528 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67529 + * Note that this macros defines per_cpu_load as an absolute symbol.
67530 * If there is no need to put the percpu section at a predetermined
67531 * address, use PERCPU_SECTION.
67532 */
67533 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67534 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67535 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67536 + per_cpu_load = .; \
67537 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67538 - LOAD_OFFSET) { \
67539 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67540 PERCPU_INPUT(cacheline) \
67541 } phdr \
67542 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67543 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67544
67545 /**
67546 * PERCPU_SECTION - define output section for percpu area, simple version
67547 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67548 index 418d270..bfd2794 100644
67549 --- a/include/crypto/algapi.h
67550 +++ b/include/crypto/algapi.h
67551 @@ -34,7 +34,7 @@ struct crypto_type {
67552 unsigned int maskclear;
67553 unsigned int maskset;
67554 unsigned int tfmsize;
67555 -};
67556 +} __do_const;
67557
67558 struct crypto_instance {
67559 struct crypto_alg alg;
67560 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67561 index fad21c9..ab858bc 100644
67562 --- a/include/drm/drmP.h
67563 +++ b/include/drm/drmP.h
67564 @@ -72,6 +72,7 @@
67565 #include <linux/workqueue.h>
67566 #include <linux/poll.h>
67567 #include <asm/pgalloc.h>
67568 +#include <asm/local.h>
67569 #include <drm/drm.h>
67570 #include <drm/drm_sarea.h>
67571
67572 @@ -293,10 +294,12 @@ do { \
67573 * \param cmd command.
67574 * \param arg argument.
67575 */
67576 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67577 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67578 + struct drm_file *file_priv);
67579 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67580 struct drm_file *file_priv);
67581
67582 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67583 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67584 unsigned long arg);
67585
67586 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67587 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67588 struct drm_ioctl_desc {
67589 unsigned int cmd;
67590 int flags;
67591 - drm_ioctl_t *func;
67592 + drm_ioctl_t func;
67593 unsigned int cmd_drv;
67594 -};
67595 +} __do_const;
67596
67597 /**
67598 * Creates a driver or general drm_ioctl_desc array entry for the given
67599 @@ -995,7 +998,7 @@ struct drm_info_list {
67600 int (*show)(struct seq_file*, void*); /** show callback */
67601 u32 driver_features; /**< Required driver features for this entry */
67602 void *data;
67603 -};
67604 +} __do_const;
67605
67606 /**
67607 * debugfs node structure. This structure represents a debugfs file.
67608 @@ -1068,7 +1071,7 @@ struct drm_device {
67609
67610 /** \name Usage Counters */
67611 /*@{ */
67612 - int open_count; /**< Outstanding files open */
67613 + local_t open_count; /**< Outstanding files open */
67614 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67615 atomic_t vma_count; /**< Outstanding vma areas open */
67616 int buf_use; /**< Buffers in use -- cannot alloc */
67617 @@ -1079,7 +1082,7 @@ struct drm_device {
67618 /*@{ */
67619 unsigned long counters;
67620 enum drm_stat_type types[15];
67621 - atomic_t counts[15];
67622 + atomic_unchecked_t counts[15];
67623 /*@} */
67624
67625 struct list_head filelist;
67626 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67627 index f43d556..94d9343 100644
67628 --- a/include/drm/drm_crtc_helper.h
67629 +++ b/include/drm/drm_crtc_helper.h
67630 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67631 struct drm_connector *connector);
67632 /* disable encoder when not in use - more explicit than dpms off */
67633 void (*disable)(struct drm_encoder *encoder);
67634 -};
67635 +} __no_const;
67636
67637 /**
67638 * drm_connector_helper_funcs - helper operations for connectors
67639 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67640 index 72dcbe8..8db58d7 100644
67641 --- a/include/drm/ttm/ttm_memory.h
67642 +++ b/include/drm/ttm/ttm_memory.h
67643 @@ -48,7 +48,7 @@
67644
67645 struct ttm_mem_shrink {
67646 int (*do_shrink) (struct ttm_mem_shrink *);
67647 -};
67648 +} __no_const;
67649
67650 /**
67651 * struct ttm_mem_global - Global memory accounting structure.
67652 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67653 index 4b840e8..155d235 100644
67654 --- a/include/keys/asymmetric-subtype.h
67655 +++ b/include/keys/asymmetric-subtype.h
67656 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67657 /* Verify the signature on a key of this subtype (optional) */
67658 int (*verify_signature)(const struct key *key,
67659 const struct public_key_signature *sig);
67660 -};
67661 +} __do_const;
67662
67663 /**
67664 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67665 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67666 index c1da539..1dcec55 100644
67667 --- a/include/linux/atmdev.h
67668 +++ b/include/linux/atmdev.h
67669 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67670 #endif
67671
67672 struct k_atm_aal_stats {
67673 -#define __HANDLE_ITEM(i) atomic_t i
67674 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67675 __AAL_STAT_ITEMS
67676 #undef __HANDLE_ITEM
67677 };
67678 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67679 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67680 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67681 struct module *owner;
67682 -};
67683 +} __do_const ;
67684
67685 struct atmphy_ops {
67686 int (*start)(struct atm_dev *dev);
67687 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67688 index 0530b98..96a8ac0 100644
67689 --- a/include/linux/binfmts.h
67690 +++ b/include/linux/binfmts.h
67691 @@ -73,8 +73,9 @@ struct linux_binfmt {
67692 int (*load_binary)(struct linux_binprm *);
67693 int (*load_shlib)(struct file *);
67694 int (*core_dump)(struct coredump_params *cprm);
67695 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67696 unsigned long min_coredump; /* minimal dump size */
67697 -};
67698 +} __do_const;
67699
67700 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67701
67702 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67703 index f94bc83..62b9cfe 100644
67704 --- a/include/linux/blkdev.h
67705 +++ b/include/linux/blkdev.h
67706 @@ -1498,7 +1498,7 @@ struct block_device_operations {
67707 /* this callback is with swap_lock and sometimes page table lock held */
67708 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67709 struct module *owner;
67710 -};
67711 +} __do_const;
67712
67713 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67714 unsigned long);
67715 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67716 index 7c2e030..b72475d 100644
67717 --- a/include/linux/blktrace_api.h
67718 +++ b/include/linux/blktrace_api.h
67719 @@ -23,7 +23,7 @@ struct blk_trace {
67720 struct dentry *dir;
67721 struct dentry *dropped_file;
67722 struct dentry *msg_file;
67723 - atomic_t dropped;
67724 + atomic_unchecked_t dropped;
67725 };
67726
67727 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67728 diff --git a/include/linux/cache.h b/include/linux/cache.h
67729 index 4c57065..4307975 100644
67730 --- a/include/linux/cache.h
67731 +++ b/include/linux/cache.h
67732 @@ -16,6 +16,10 @@
67733 #define __read_mostly
67734 #endif
67735
67736 +#ifndef __read_only
67737 +#define __read_only __read_mostly
67738 +#endif
67739 +
67740 #ifndef ____cacheline_aligned
67741 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67742 #endif
67743 diff --git a/include/linux/capability.h b/include/linux/capability.h
67744 index 98503b7..cc36d18 100644
67745 --- a/include/linux/capability.h
67746 +++ b/include/linux/capability.h
67747 @@ -211,8 +211,13 @@ extern bool capable(int cap);
67748 extern bool ns_capable(struct user_namespace *ns, int cap);
67749 extern bool nsown_capable(int cap);
67750 extern bool inode_capable(const struct inode *inode, int cap);
67751 +extern bool capable_nolog(int cap);
67752 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67753 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67754
67755 /* audit system wants to get cap info from files as well */
67756 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67757
67758 +extern int is_privileged_binary(const struct dentry *dentry);
67759 +
67760 #endif /* !_LINUX_CAPABILITY_H */
67761 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67762 index 8609d57..86e4d79 100644
67763 --- a/include/linux/cdrom.h
67764 +++ b/include/linux/cdrom.h
67765 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67766
67767 /* driver specifications */
67768 const int capability; /* capability flags */
67769 - int n_minors; /* number of active minor devices */
67770 /* handle uniform packets for scsi type devices (scsi,atapi) */
67771 int (*generic_packet) (struct cdrom_device_info *,
67772 struct packet_command *);
67773 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67774 index 42e55de..1cd0e66 100644
67775 --- a/include/linux/cleancache.h
67776 +++ b/include/linux/cleancache.h
67777 @@ -31,7 +31,7 @@ struct cleancache_ops {
67778 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67779 void (*invalidate_inode)(int, struct cleancache_filekey);
67780 void (*invalidate_fs)(int);
67781 -};
67782 +} __no_const;
67783
67784 extern struct cleancache_ops
67785 cleancache_register_ops(struct cleancache_ops *ops);
67786 diff --git a/include/linux/compat.h b/include/linux/compat.h
67787 index dec7e2d..45db13f 100644
67788 --- a/include/linux/compat.h
67789 +++ b/include/linux/compat.h
67790 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67791 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67792 int version, void __user *uptr);
67793 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67794 - void __user *uptr);
67795 + void __user *uptr) __intentional_overflow(0);
67796 #else
67797 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67798 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67799 compat_ssize_t msgsz, int msgflg);
67800 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67801 compat_ssize_t msgsz, long msgtyp, int msgflg);
67802 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67803 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67804 #endif
67805 long compat_sys_msgctl(int first, int second, void __user *uptr);
67806 long compat_sys_shmctl(int first, int second, void __user *uptr);
67807 @@ -414,7 +414,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67808 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67809 compat_ulong_t addr, compat_ulong_t data);
67810 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67811 - compat_long_t addr, compat_long_t data);
67812 + compat_ulong_t addr, compat_ulong_t data);
67813
67814 /*
67815 * epoll (fs/eventpoll.c) compat bits follow ...
67816 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67817 index 662fd1b..e801992 100644
67818 --- a/include/linux/compiler-gcc4.h
67819 +++ b/include/linux/compiler-gcc4.h
67820 @@ -34,6 +34,21 @@
67821 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
67822
67823 #if __GNUC_MINOR__ >= 5
67824 +
67825 +#ifdef CONSTIFY_PLUGIN
67826 +#define __no_const __attribute__((no_const))
67827 +#define __do_const __attribute__((do_const))
67828 +#endif
67829 +
67830 +#ifdef SIZE_OVERFLOW_PLUGIN
67831 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67832 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67833 +#endif
67834 +
67835 +#ifdef LATENT_ENTROPY_PLUGIN
67836 +#define __latent_entropy __attribute__((latent_entropy))
67837 +#endif
67838 +
67839 /*
67840 * Mark a position in code as unreachable. This can be used to
67841 * suppress control flow warnings after asm blocks that transfer
67842 @@ -49,6 +64,11 @@
67843 #define __noclone __attribute__((__noclone__))
67844
67845 #endif
67846 +
67847 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67848 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67849 +#define __bos0(ptr) __bos((ptr), 0)
67850 +#define __bos1(ptr) __bos((ptr), 1)
67851 #endif
67852
67853 #if __GNUC_MINOR__ >= 6
67854 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67855 index dd852b7..1ad5fba 100644
67856 --- a/include/linux/compiler.h
67857 +++ b/include/linux/compiler.h
67858 @@ -5,11 +5,14 @@
67859
67860 #ifdef __CHECKER__
67861 # define __user __attribute__((noderef, address_space(1)))
67862 +# define __force_user __force __user
67863 # define __kernel __attribute__((address_space(0)))
67864 +# define __force_kernel __force __kernel
67865 # define __safe __attribute__((safe))
67866 # define __force __attribute__((force))
67867 # define __nocast __attribute__((nocast))
67868 # define __iomem __attribute__((noderef, address_space(2)))
67869 +# define __force_iomem __force __iomem
67870 # define __must_hold(x) __attribute__((context(x,1,1)))
67871 # define __acquires(x) __attribute__((context(x,0,1)))
67872 # define __releases(x) __attribute__((context(x,1,0)))
67873 @@ -17,20 +20,37 @@
67874 # define __release(x) __context__(x,-1)
67875 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67876 # define __percpu __attribute__((noderef, address_space(3)))
67877 +# define __force_percpu __force __percpu
67878 #ifdef CONFIG_SPARSE_RCU_POINTER
67879 # define __rcu __attribute__((noderef, address_space(4)))
67880 +# define __force_rcu __force __rcu
67881 #else
67882 # define __rcu
67883 +# define __force_rcu
67884 #endif
67885 extern void __chk_user_ptr(const volatile void __user *);
67886 extern void __chk_io_ptr(const volatile void __iomem *);
67887 #else
67888 -# define __user
67889 -# define __kernel
67890 +# ifdef CHECKER_PLUGIN
67891 +//# define __user
67892 +//# define __force_user
67893 +//# define __kernel
67894 +//# define __force_kernel
67895 +# else
67896 +# ifdef STRUCTLEAK_PLUGIN
67897 +# define __user __attribute__((user))
67898 +# else
67899 +# define __user
67900 +# endif
67901 +# define __force_user
67902 +# define __kernel
67903 +# define __force_kernel
67904 +# endif
67905 # define __safe
67906 # define __force
67907 # define __nocast
67908 # define __iomem
67909 +# define __force_iomem
67910 # define __chk_user_ptr(x) (void)0
67911 # define __chk_io_ptr(x) (void)0
67912 # define __builtin_warning(x, y...) (1)
67913 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67914 # define __release(x) (void)0
67915 # define __cond_lock(x,c) (c)
67916 # define __percpu
67917 +# define __force_percpu
67918 # define __rcu
67919 +# define __force_rcu
67920 #endif
67921
67922 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67923 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67924 # define __attribute_const__ /* unimplemented */
67925 #endif
67926
67927 +#ifndef __no_const
67928 +# define __no_const
67929 +#endif
67930 +
67931 +#ifndef __do_const
67932 +# define __do_const
67933 +#endif
67934 +
67935 +#ifndef __size_overflow
67936 +# define __size_overflow(...)
67937 +#endif
67938 +
67939 +#ifndef __intentional_overflow
67940 +# define __intentional_overflow(...)
67941 +#endif
67942 +
67943 +#ifndef __latent_entropy
67944 +# define __latent_entropy
67945 +#endif
67946 +
67947 /*
67948 * Tell gcc if a function is cold. The compiler will assume any path
67949 * directly leading to the call is unlikely.
67950 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67951 #define __cold
67952 #endif
67953
67954 +#ifndef __alloc_size
67955 +#define __alloc_size(...)
67956 +#endif
67957 +
67958 +#ifndef __bos
67959 +#define __bos(ptr, arg)
67960 +#endif
67961 +
67962 +#ifndef __bos0
67963 +#define __bos0(ptr)
67964 +#endif
67965 +
67966 +#ifndef __bos1
67967 +#define __bos1(ptr)
67968 +#endif
67969 +
67970 /* Simple shorthand for a section definition */
67971 #ifndef __section
67972 # define __section(S) __attribute__ ((__section__(#S)))
67973 @@ -323,6 +381,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67974 * use is to mediate communication between process-level code and irq/NMI
67975 * handlers, all running on the same CPU.
67976 */
67977 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67978 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67979 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67980
67981 #endif /* __LINUX_COMPILER_H */
67982 diff --git a/include/linux/completion.h b/include/linux/completion.h
67983 index 51494e6..0fd1b61 100644
67984 --- a/include/linux/completion.h
67985 +++ b/include/linux/completion.h
67986 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
67987
67988 extern void wait_for_completion(struct completion *);
67989 extern int wait_for_completion_interruptible(struct completion *x);
67990 -extern int wait_for_completion_killable(struct completion *x);
67991 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
67992 extern unsigned long wait_for_completion_timeout(struct completion *x,
67993 unsigned long timeout);
67994 extern long wait_for_completion_interruptible_timeout(
67995 - struct completion *x, unsigned long timeout);
67996 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67997 extern long wait_for_completion_killable_timeout(
67998 - struct completion *x, unsigned long timeout);
67999 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68000 extern bool try_wait_for_completion(struct completion *x);
68001 extern bool completion_done(struct completion *x);
68002
68003 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68004 index 34025df..d94bbbc 100644
68005 --- a/include/linux/configfs.h
68006 +++ b/include/linux/configfs.h
68007 @@ -125,7 +125,7 @@ struct configfs_attribute {
68008 const char *ca_name;
68009 struct module *ca_owner;
68010 umode_t ca_mode;
68011 -};
68012 +} __do_const;
68013
68014 /*
68015 * Users often need to create attribute structures for their configurable
68016 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68017 index ce7a074..01ab8ac 100644
68018 --- a/include/linux/cpu.h
68019 +++ b/include/linux/cpu.h
68020 @@ -115,7 +115,7 @@ enum {
68021 /* Need to know about CPUs going up/down? */
68022 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68023 #define cpu_notifier(fn, pri) { \
68024 - static struct notifier_block fn##_nb __cpuinitdata = \
68025 + static struct notifier_block fn##_nb = \
68026 { .notifier_call = fn, .priority = pri }; \
68027 register_cpu_notifier(&fn##_nb); \
68028 }
68029 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68030 index a55b88e..fba90c5 100644
68031 --- a/include/linux/cpufreq.h
68032 +++ b/include/linux/cpufreq.h
68033 @@ -240,7 +240,7 @@ struct cpufreq_driver {
68034 int (*suspend) (struct cpufreq_policy *policy);
68035 int (*resume) (struct cpufreq_policy *policy);
68036 struct freq_attr **attr;
68037 -};
68038 +} __do_const;
68039
68040 /* flags */
68041
68042 @@ -299,6 +299,7 @@ struct global_attr {
68043 ssize_t (*store)(struct kobject *a, struct attribute *b,
68044 const char *c, size_t count);
68045 };
68046 +typedef struct global_attr __no_const global_attr_no_const;
68047
68048 #define define_one_global_ro(_name) \
68049 static struct global_attr _name = \
68050 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68051 index 24cd1037..20a63aae 100644
68052 --- a/include/linux/cpuidle.h
68053 +++ b/include/linux/cpuidle.h
68054 @@ -54,7 +54,8 @@ struct cpuidle_state {
68055 int index);
68056
68057 int (*enter_dead) (struct cpuidle_device *dev, int index);
68058 -};
68059 +} __do_const;
68060 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68061
68062 /* Idle State Flags */
68063 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68064 @@ -216,7 +217,7 @@ struct cpuidle_governor {
68065 void (*reflect) (struct cpuidle_device *dev, int index);
68066
68067 struct module *owner;
68068 -};
68069 +} __do_const;
68070
68071 #ifdef CONFIG_CPU_IDLE
68072
68073 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68074 index 0325602..5e9feff 100644
68075 --- a/include/linux/cpumask.h
68076 +++ b/include/linux/cpumask.h
68077 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68078 }
68079
68080 /* Valid inputs for n are -1 and 0. */
68081 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68082 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68083 {
68084 return n+1;
68085 }
68086
68087 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68088 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68089 {
68090 return n+1;
68091 }
68092
68093 -static inline unsigned int cpumask_next_and(int n,
68094 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68095 const struct cpumask *srcp,
68096 const struct cpumask *andp)
68097 {
68098 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68099 *
68100 * Returns >= nr_cpu_ids if no further cpus set.
68101 */
68102 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68103 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68104 {
68105 /* -1 is a legal arg here. */
68106 if (n != -1)
68107 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68108 *
68109 * Returns >= nr_cpu_ids if no further cpus unset.
68110 */
68111 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68112 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68113 {
68114 /* -1 is a legal arg here. */
68115 if (n != -1)
68116 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68117 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68118 }
68119
68120 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68121 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68122 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68123
68124 /**
68125 diff --git a/include/linux/cred.h b/include/linux/cred.h
68126 index 04421e8..6bce4ef 100644
68127 --- a/include/linux/cred.h
68128 +++ b/include/linux/cred.h
68129 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68130 static inline void validate_process_creds(void)
68131 {
68132 }
68133 +static inline void validate_task_creds(struct task_struct *task)
68134 +{
68135 +}
68136 #endif
68137
68138 /**
68139 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68140 index b92eadf..b4ecdc1 100644
68141 --- a/include/linux/crypto.h
68142 +++ b/include/linux/crypto.h
68143 @@ -373,7 +373,7 @@ struct cipher_tfm {
68144 const u8 *key, unsigned int keylen);
68145 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68146 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68147 -};
68148 +} __no_const;
68149
68150 struct hash_tfm {
68151 int (*init)(struct hash_desc *desc);
68152 @@ -394,13 +394,13 @@ struct compress_tfm {
68153 int (*cot_decompress)(struct crypto_tfm *tfm,
68154 const u8 *src, unsigned int slen,
68155 u8 *dst, unsigned int *dlen);
68156 -};
68157 +} __no_const;
68158
68159 struct rng_tfm {
68160 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68161 unsigned int dlen);
68162 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68163 -};
68164 +} __no_const;
68165
68166 #define crt_ablkcipher crt_u.ablkcipher
68167 #define crt_aead crt_u.aead
68168 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68169 index 8acfe31..6ffccd63 100644
68170 --- a/include/linux/ctype.h
68171 +++ b/include/linux/ctype.h
68172 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68173 * Fast implementation of tolower() for internal usage. Do not use in your
68174 * code.
68175 */
68176 -static inline char _tolower(const char c)
68177 +static inline unsigned char _tolower(const unsigned char c)
68178 {
68179 return c | 0x20;
68180 }
68181 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68182 index 7925bf0..d5143d2 100644
68183 --- a/include/linux/decompress/mm.h
68184 +++ b/include/linux/decompress/mm.h
68185 @@ -77,7 +77,7 @@ static void free(void *where)
68186 * warnings when not needed (indeed large_malloc / large_free are not
68187 * needed by inflate */
68188
68189 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68190 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68191 #define free(a) kfree(a)
68192
68193 #define large_malloc(a) vmalloc(a)
68194 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68195 index e83ef39..33e0eb3 100644
68196 --- a/include/linux/devfreq.h
68197 +++ b/include/linux/devfreq.h
68198 @@ -114,7 +114,7 @@ struct devfreq_governor {
68199 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68200 int (*event_handler)(struct devfreq *devfreq,
68201 unsigned int event, void *data);
68202 -};
68203 +} __do_const;
68204
68205 /**
68206 * struct devfreq - Device devfreq structure
68207 diff --git a/include/linux/device.h b/include/linux/device.h
68208 index 43dcda9..7a1fb65 100644
68209 --- a/include/linux/device.h
68210 +++ b/include/linux/device.h
68211 @@ -294,7 +294,7 @@ struct subsys_interface {
68212 struct list_head node;
68213 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68214 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68215 -};
68216 +} __do_const;
68217
68218 int subsys_interface_register(struct subsys_interface *sif);
68219 void subsys_interface_unregister(struct subsys_interface *sif);
68220 @@ -474,7 +474,7 @@ struct device_type {
68221 void (*release)(struct device *dev);
68222
68223 const struct dev_pm_ops *pm;
68224 -};
68225 +} __do_const;
68226
68227 /* interface for exporting device attributes */
68228 struct device_attribute {
68229 @@ -484,11 +484,12 @@ struct device_attribute {
68230 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68231 const char *buf, size_t count);
68232 };
68233 +typedef struct device_attribute __no_const device_attribute_no_const;
68234
68235 struct dev_ext_attribute {
68236 struct device_attribute attr;
68237 void *var;
68238 -};
68239 +} __do_const;
68240
68241 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68242 char *buf);
68243 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68244 index 94af418..b1ca7a2 100644
68245 --- a/include/linux/dma-mapping.h
68246 +++ b/include/linux/dma-mapping.h
68247 @@ -54,7 +54,7 @@ struct dma_map_ops {
68248 u64 (*get_required_mask)(struct device *dev);
68249 #endif
68250 int is_phys;
68251 -};
68252 +} __do_const;
68253
68254 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68255
68256 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68257 index d3201e4..8281e63 100644
68258 --- a/include/linux/dmaengine.h
68259 +++ b/include/linux/dmaengine.h
68260 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
68261 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68262 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68263
68264 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68265 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68266 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68267 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68268 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68269 struct dma_pinned_list *pinned_list, struct page *page,
68270 unsigned int offset, size_t len);
68271
68272 diff --git a/include/linux/efi.h b/include/linux/efi.h
68273 index 7a9498a..155713d 100644
68274 --- a/include/linux/efi.h
68275 +++ b/include/linux/efi.h
68276 @@ -733,6 +733,7 @@ struct efivar_operations {
68277 efi_set_variable_t *set_variable;
68278 efi_query_variable_info_t *query_variable_info;
68279 };
68280 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68281
68282 struct efivars {
68283 /*
68284 diff --git a/include/linux/elf.h b/include/linux/elf.h
68285 index 8c9048e..16a4665 100644
68286 --- a/include/linux/elf.h
68287 +++ b/include/linux/elf.h
68288 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
68289 #define elf_note elf32_note
68290 #define elf_addr_t Elf32_Off
68291 #define Elf_Half Elf32_Half
68292 +#define elf_dyn Elf32_Dyn
68293
68294 #else
68295
68296 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
68297 #define elf_note elf64_note
68298 #define elf_addr_t Elf64_Off
68299 #define Elf_Half Elf64_Half
68300 +#define elf_dyn Elf64_Dyn
68301
68302 #endif
68303
68304 diff --git a/include/linux/err.h b/include/linux/err.h
68305 index f2edce2..cc2082c 100644
68306 --- a/include/linux/err.h
68307 +++ b/include/linux/err.h
68308 @@ -19,12 +19,12 @@
68309
68310 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68311
68312 -static inline void * __must_check ERR_PTR(long error)
68313 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68314 {
68315 return (void *) error;
68316 }
68317
68318 -static inline long __must_check PTR_ERR(const void *ptr)
68319 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68320 {
68321 return (long) ptr;
68322 }
68323 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68324 index fcb51c8..bdafcf6 100644
68325 --- a/include/linux/extcon.h
68326 +++ b/include/linux/extcon.h
68327 @@ -134,7 +134,7 @@ struct extcon_dev {
68328 /* /sys/class/extcon/.../mutually_exclusive/... */
68329 struct attribute_group attr_g_muex;
68330 struct attribute **attrs_muex;
68331 - struct device_attribute *d_attrs_muex;
68332 + device_attribute_no_const *d_attrs_muex;
68333 };
68334
68335 /**
68336 diff --git a/include/linux/fb.h b/include/linux/fb.h
68337 index c7a9571..02eeffe 100644
68338 --- a/include/linux/fb.h
68339 +++ b/include/linux/fb.h
68340 @@ -302,7 +302,7 @@ struct fb_ops {
68341 /* called at KDB enter and leave time to prepare the console */
68342 int (*fb_debug_enter)(struct fb_info *info);
68343 int (*fb_debug_leave)(struct fb_info *info);
68344 -};
68345 +} __do_const;
68346
68347 #ifdef CONFIG_FB_TILEBLITTING
68348 #define FB_TILE_CURSOR_NONE 0
68349 diff --git a/include/linux/filter.h b/include/linux/filter.h
68350 index c45eabc..baa0be5 100644
68351 --- a/include/linux/filter.h
68352 +++ b/include/linux/filter.h
68353 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68354
68355 struct sk_buff;
68356 struct sock;
68357 +struct bpf_jit_work;
68358
68359 struct sk_filter
68360 {
68361 @@ -27,6 +28,9 @@ struct sk_filter
68362 unsigned int len; /* Number of filter blocks */
68363 unsigned int (*bpf_func)(const struct sk_buff *skb,
68364 const struct sock_filter *filter);
68365 +#ifdef CONFIG_BPF_JIT
68366 + struct bpf_jit_work *work;
68367 +#endif
68368 struct rcu_head rcu;
68369 struct sock_filter insns[0];
68370 };
68371 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68372 index 3044254..9767f41 100644
68373 --- a/include/linux/frontswap.h
68374 +++ b/include/linux/frontswap.h
68375 @@ -11,7 +11,7 @@ struct frontswap_ops {
68376 int (*load)(unsigned, pgoff_t, struct page *);
68377 void (*invalidate_page)(unsigned, pgoff_t);
68378 void (*invalidate_area)(unsigned);
68379 -};
68380 +} __no_const;
68381
68382 extern bool frontswap_enabled;
68383 extern struct frontswap_ops
68384 diff --git a/include/linux/fs.h b/include/linux/fs.h
68385 index 7617ee0..b575199 100644
68386 --- a/include/linux/fs.h
68387 +++ b/include/linux/fs.h
68388 @@ -1541,7 +1541,8 @@ struct file_operations {
68389 long (*fallocate)(struct file *file, int mode, loff_t offset,
68390 loff_t len);
68391 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68392 -};
68393 +} __do_const;
68394 +typedef struct file_operations __no_const file_operations_no_const;
68395
68396 struct inode_operations {
68397 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68398 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68399 inode->i_flags |= S_NOSEC;
68400 }
68401
68402 +static inline bool is_sidechannel_device(const struct inode *inode)
68403 +{
68404 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68405 + umode_t mode = inode->i_mode;
68406 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68407 +#else
68408 + return false;
68409 +#endif
68410 +}
68411 +
68412 #endif /* _LINUX_FS_H */
68413 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68414 index 324f931..f292b65 100644
68415 --- a/include/linux/fs_struct.h
68416 +++ b/include/linux/fs_struct.h
68417 @@ -6,7 +6,7 @@
68418 #include <linux/seqlock.h>
68419
68420 struct fs_struct {
68421 - int users;
68422 + atomic_t users;
68423 spinlock_t lock;
68424 seqcount_t seq;
68425 int umask;
68426 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68427 index 5dfa0aa..6acf322 100644
68428 --- a/include/linux/fscache-cache.h
68429 +++ b/include/linux/fscache-cache.h
68430 @@ -112,7 +112,7 @@ struct fscache_operation {
68431 fscache_operation_release_t release;
68432 };
68433
68434 -extern atomic_t fscache_op_debug_id;
68435 +extern atomic_unchecked_t fscache_op_debug_id;
68436 extern void fscache_op_work_func(struct work_struct *work);
68437
68438 extern void fscache_enqueue_operation(struct fscache_operation *);
68439 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68440 INIT_WORK(&op->work, fscache_op_work_func);
68441 atomic_set(&op->usage, 1);
68442 op->state = FSCACHE_OP_ST_INITIALISED;
68443 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68444 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68445 op->processor = processor;
68446 op->release = release;
68447 INIT_LIST_HEAD(&op->pend_link);
68448 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68449 index 7a08623..4c07b0f 100644
68450 --- a/include/linux/fscache.h
68451 +++ b/include/linux/fscache.h
68452 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68453 * - this is mandatory for any object that may have data
68454 */
68455 void (*now_uncached)(void *cookie_netfs_data);
68456 -};
68457 +} __do_const;
68458
68459 /*
68460 * fscache cached network filesystem type
68461 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68462 index 0fbfb46..508eb0d 100644
68463 --- a/include/linux/fsnotify.h
68464 +++ b/include/linux/fsnotify.h
68465 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68466 struct inode *inode = path->dentry->d_inode;
68467 __u32 mask = FS_ACCESS;
68468
68469 + if (is_sidechannel_device(inode))
68470 + return;
68471 +
68472 if (S_ISDIR(inode->i_mode))
68473 mask |= FS_ISDIR;
68474
68475 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68476 struct inode *inode = path->dentry->d_inode;
68477 __u32 mask = FS_MODIFY;
68478
68479 + if (is_sidechannel_device(inode))
68480 + return;
68481 +
68482 if (S_ISDIR(inode->i_mode))
68483 mask |= FS_ISDIR;
68484
68485 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68486 */
68487 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68488 {
68489 - return kstrdup(name, GFP_KERNEL);
68490 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68491 }
68492
68493 /*
68494 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68495 index a3d4895..ddd2a50 100644
68496 --- a/include/linux/ftrace_event.h
68497 +++ b/include/linux/ftrace_event.h
68498 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68499 extern int trace_add_event_call(struct ftrace_event_call *call);
68500 extern void trace_remove_event_call(struct ftrace_event_call *call);
68501
68502 -#define is_signed_type(type) (((type)(-1)) < 0)
68503 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68504
68505 int trace_set_clr_event(const char *system, const char *event, int set);
68506
68507 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68508 index 79b8bba..86b539e 100644
68509 --- a/include/linux/genhd.h
68510 +++ b/include/linux/genhd.h
68511 @@ -194,7 +194,7 @@ struct gendisk {
68512 struct kobject *slave_dir;
68513
68514 struct timer_rand_state *random;
68515 - atomic_t sync_io; /* RAID */
68516 + atomic_unchecked_t sync_io; /* RAID */
68517 struct disk_events *ev;
68518 #ifdef CONFIG_BLK_DEV_INTEGRITY
68519 struct blk_integrity *integrity;
68520 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68521 index 023bc34..b02b46a 100644
68522 --- a/include/linux/genl_magic_func.h
68523 +++ b/include/linux/genl_magic_func.h
68524 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68525 },
68526
68527 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68528 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68529 +static struct genl_ops ZZZ_genl_ops[] = {
68530 #include GENL_MAGIC_INCLUDE_FILE
68531 };
68532
68533 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68534 index 0f615eb..5c3832f 100644
68535 --- a/include/linux/gfp.h
68536 +++ b/include/linux/gfp.h
68537 @@ -35,6 +35,13 @@ struct vm_area_struct;
68538 #define ___GFP_NO_KSWAPD 0x400000u
68539 #define ___GFP_OTHER_NODE 0x800000u
68540 #define ___GFP_WRITE 0x1000000u
68541 +
68542 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68543 +#define ___GFP_USERCOPY 0x2000000u
68544 +#else
68545 +#define ___GFP_USERCOPY 0
68546 +#endif
68547 +
68548 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68549
68550 /*
68551 @@ -92,6 +99,7 @@ struct vm_area_struct;
68552 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68553 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68554 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68555 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68556
68557 /*
68558 * This may seem redundant, but it's a way of annotating false positives vs.
68559 @@ -99,7 +107,7 @@ struct vm_area_struct;
68560 */
68561 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68562
68563 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68564 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68565 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68566
68567 /* This equals 0, but use constants in case they ever change */
68568 @@ -153,6 +161,8 @@ struct vm_area_struct;
68569 /* 4GB DMA on some platforms */
68570 #define GFP_DMA32 __GFP_DMA32
68571
68572 +#define GFP_USERCOPY __GFP_USERCOPY
68573 +
68574 /* Convert GFP flags to their corresponding migrate type */
68575 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68576 {
68577 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68578 new file mode 100644
68579 index 0000000..ebe6d72
68580 --- /dev/null
68581 +++ b/include/linux/gracl.h
68582 @@ -0,0 +1,319 @@
68583 +#ifndef GR_ACL_H
68584 +#define GR_ACL_H
68585 +
68586 +#include <linux/grdefs.h>
68587 +#include <linux/resource.h>
68588 +#include <linux/capability.h>
68589 +#include <linux/dcache.h>
68590 +#include <asm/resource.h>
68591 +
68592 +/* Major status information */
68593 +
68594 +#define GR_VERSION "grsecurity 2.9.1"
68595 +#define GRSECURITY_VERSION 0x2901
68596 +
68597 +enum {
68598 + GR_SHUTDOWN = 0,
68599 + GR_ENABLE = 1,
68600 + GR_SPROLE = 2,
68601 + GR_RELOAD = 3,
68602 + GR_SEGVMOD = 4,
68603 + GR_STATUS = 5,
68604 + GR_UNSPROLE = 6,
68605 + GR_PASSSET = 7,
68606 + GR_SPROLEPAM = 8,
68607 +};
68608 +
68609 +/* Password setup definitions
68610 + * kernel/grhash.c */
68611 +enum {
68612 + GR_PW_LEN = 128,
68613 + GR_SALT_LEN = 16,
68614 + GR_SHA_LEN = 32,
68615 +};
68616 +
68617 +enum {
68618 + GR_SPROLE_LEN = 64,
68619 +};
68620 +
68621 +enum {
68622 + GR_NO_GLOB = 0,
68623 + GR_REG_GLOB,
68624 + GR_CREATE_GLOB
68625 +};
68626 +
68627 +#define GR_NLIMITS 32
68628 +
68629 +/* Begin Data Structures */
68630 +
68631 +struct sprole_pw {
68632 + unsigned char *rolename;
68633 + unsigned char salt[GR_SALT_LEN];
68634 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68635 +};
68636 +
68637 +struct name_entry {
68638 + __u32 key;
68639 + ino_t inode;
68640 + dev_t device;
68641 + char *name;
68642 + __u16 len;
68643 + __u8 deleted;
68644 + struct name_entry *prev;
68645 + struct name_entry *next;
68646 +};
68647 +
68648 +struct inodev_entry {
68649 + struct name_entry *nentry;
68650 + struct inodev_entry *prev;
68651 + struct inodev_entry *next;
68652 +};
68653 +
68654 +struct acl_role_db {
68655 + struct acl_role_label **r_hash;
68656 + __u32 r_size;
68657 +};
68658 +
68659 +struct inodev_db {
68660 + struct inodev_entry **i_hash;
68661 + __u32 i_size;
68662 +};
68663 +
68664 +struct name_db {
68665 + struct name_entry **n_hash;
68666 + __u32 n_size;
68667 +};
68668 +
68669 +struct crash_uid {
68670 + uid_t uid;
68671 + unsigned long expires;
68672 +};
68673 +
68674 +struct gr_hash_struct {
68675 + void **table;
68676 + void **nametable;
68677 + void *first;
68678 + __u32 table_size;
68679 + __u32 used_size;
68680 + int type;
68681 +};
68682 +
68683 +/* Userspace Grsecurity ACL data structures */
68684 +
68685 +struct acl_subject_label {
68686 + char *filename;
68687 + ino_t inode;
68688 + dev_t device;
68689 + __u32 mode;
68690 + kernel_cap_t cap_mask;
68691 + kernel_cap_t cap_lower;
68692 + kernel_cap_t cap_invert_audit;
68693 +
68694 + struct rlimit res[GR_NLIMITS];
68695 + __u32 resmask;
68696 +
68697 + __u8 user_trans_type;
68698 + __u8 group_trans_type;
68699 + uid_t *user_transitions;
68700 + gid_t *group_transitions;
68701 + __u16 user_trans_num;
68702 + __u16 group_trans_num;
68703 +
68704 + __u32 sock_families[2];
68705 + __u32 ip_proto[8];
68706 + __u32 ip_type;
68707 + struct acl_ip_label **ips;
68708 + __u32 ip_num;
68709 + __u32 inaddr_any_override;
68710 +
68711 + __u32 crashes;
68712 + unsigned long expires;
68713 +
68714 + struct acl_subject_label *parent_subject;
68715 + struct gr_hash_struct *hash;
68716 + struct acl_subject_label *prev;
68717 + struct acl_subject_label *next;
68718 +
68719 + struct acl_object_label **obj_hash;
68720 + __u32 obj_hash_size;
68721 + __u16 pax_flags;
68722 +};
68723 +
68724 +struct role_allowed_ip {
68725 + __u32 addr;
68726 + __u32 netmask;
68727 +
68728 + struct role_allowed_ip *prev;
68729 + struct role_allowed_ip *next;
68730 +};
68731 +
68732 +struct role_transition {
68733 + char *rolename;
68734 +
68735 + struct role_transition *prev;
68736 + struct role_transition *next;
68737 +};
68738 +
68739 +struct acl_role_label {
68740 + char *rolename;
68741 + uid_t uidgid;
68742 + __u16 roletype;
68743 +
68744 + __u16 auth_attempts;
68745 + unsigned long expires;
68746 +
68747 + struct acl_subject_label *root_label;
68748 + struct gr_hash_struct *hash;
68749 +
68750 + struct acl_role_label *prev;
68751 + struct acl_role_label *next;
68752 +
68753 + struct role_transition *transitions;
68754 + struct role_allowed_ip *allowed_ips;
68755 + uid_t *domain_children;
68756 + __u16 domain_child_num;
68757 +
68758 + umode_t umask;
68759 +
68760 + struct acl_subject_label **subj_hash;
68761 + __u32 subj_hash_size;
68762 +};
68763 +
68764 +struct user_acl_role_db {
68765 + struct acl_role_label **r_table;
68766 + __u32 num_pointers; /* Number of allocations to track */
68767 + __u32 num_roles; /* Number of roles */
68768 + __u32 num_domain_children; /* Number of domain children */
68769 + __u32 num_subjects; /* Number of subjects */
68770 + __u32 num_objects; /* Number of objects */
68771 +};
68772 +
68773 +struct acl_object_label {
68774 + char *filename;
68775 + ino_t inode;
68776 + dev_t device;
68777 + __u32 mode;
68778 +
68779 + struct acl_subject_label *nested;
68780 + struct acl_object_label *globbed;
68781 +
68782 + /* next two structures not used */
68783 +
68784 + struct acl_object_label *prev;
68785 + struct acl_object_label *next;
68786 +};
68787 +
68788 +struct acl_ip_label {
68789 + char *iface;
68790 + __u32 addr;
68791 + __u32 netmask;
68792 + __u16 low, high;
68793 + __u8 mode;
68794 + __u32 type;
68795 + __u32 proto[8];
68796 +
68797 + /* next two structures not used */
68798 +
68799 + struct acl_ip_label *prev;
68800 + struct acl_ip_label *next;
68801 +};
68802 +
68803 +struct gr_arg {
68804 + struct user_acl_role_db role_db;
68805 + unsigned char pw[GR_PW_LEN];
68806 + unsigned char salt[GR_SALT_LEN];
68807 + unsigned char sum[GR_SHA_LEN];
68808 + unsigned char sp_role[GR_SPROLE_LEN];
68809 + struct sprole_pw *sprole_pws;
68810 + dev_t segv_device;
68811 + ino_t segv_inode;
68812 + uid_t segv_uid;
68813 + __u16 num_sprole_pws;
68814 + __u16 mode;
68815 +};
68816 +
68817 +struct gr_arg_wrapper {
68818 + struct gr_arg *arg;
68819 + __u32 version;
68820 + __u32 size;
68821 +};
68822 +
68823 +struct subject_map {
68824 + struct acl_subject_label *user;
68825 + struct acl_subject_label *kernel;
68826 + struct subject_map *prev;
68827 + struct subject_map *next;
68828 +};
68829 +
68830 +struct acl_subj_map_db {
68831 + struct subject_map **s_hash;
68832 + __u32 s_size;
68833 +};
68834 +
68835 +/* End Data Structures Section */
68836 +
68837 +/* Hash functions generated by empirical testing by Brad Spengler
68838 + Makes good use of the low bits of the inode. Generally 0-1 times
68839 + in loop for successful match. 0-3 for unsuccessful match.
68840 + Shift/add algorithm with modulus of table size and an XOR*/
68841 +
68842 +static __inline__ unsigned int
68843 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68844 +{
68845 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68846 +}
68847 +
68848 + static __inline__ unsigned int
68849 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68850 +{
68851 + return ((const unsigned long)userp % sz);
68852 +}
68853 +
68854 +static __inline__ unsigned int
68855 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68856 +{
68857 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68858 +}
68859 +
68860 +static __inline__ unsigned int
68861 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68862 +{
68863 + return full_name_hash((const unsigned char *)name, len) % sz;
68864 +}
68865 +
68866 +#define FOR_EACH_ROLE_START(role) \
68867 + role = role_list; \
68868 + while (role) {
68869 +
68870 +#define FOR_EACH_ROLE_END(role) \
68871 + role = role->prev; \
68872 + }
68873 +
68874 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68875 + subj = NULL; \
68876 + iter = 0; \
68877 + while (iter < role->subj_hash_size) { \
68878 + if (subj == NULL) \
68879 + subj = role->subj_hash[iter]; \
68880 + if (subj == NULL) { \
68881 + iter++; \
68882 + continue; \
68883 + }
68884 +
68885 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68886 + subj = subj->next; \
68887 + if (subj == NULL) \
68888 + iter++; \
68889 + }
68890 +
68891 +
68892 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68893 + subj = role->hash->first; \
68894 + while (subj != NULL) {
68895 +
68896 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68897 + subj = subj->next; \
68898 + }
68899 +
68900 +#endif
68901 +
68902 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68903 new file mode 100644
68904 index 0000000..323ecf2
68905 --- /dev/null
68906 +++ b/include/linux/gralloc.h
68907 @@ -0,0 +1,9 @@
68908 +#ifndef __GRALLOC_H
68909 +#define __GRALLOC_H
68910 +
68911 +void acl_free_all(void);
68912 +int acl_alloc_stack_init(unsigned long size);
68913 +void *acl_alloc(unsigned long len);
68914 +void *acl_alloc_num(unsigned long num, unsigned long len);
68915 +
68916 +#endif
68917 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68918 new file mode 100644
68919 index 0000000..be66033
68920 --- /dev/null
68921 +++ b/include/linux/grdefs.h
68922 @@ -0,0 +1,140 @@
68923 +#ifndef GRDEFS_H
68924 +#define GRDEFS_H
68925 +
68926 +/* Begin grsecurity status declarations */
68927 +
68928 +enum {
68929 + GR_READY = 0x01,
68930 + GR_STATUS_INIT = 0x00 // disabled state
68931 +};
68932 +
68933 +/* Begin ACL declarations */
68934 +
68935 +/* Role flags */
68936 +
68937 +enum {
68938 + GR_ROLE_USER = 0x0001,
68939 + GR_ROLE_GROUP = 0x0002,
68940 + GR_ROLE_DEFAULT = 0x0004,
68941 + GR_ROLE_SPECIAL = 0x0008,
68942 + GR_ROLE_AUTH = 0x0010,
68943 + GR_ROLE_NOPW = 0x0020,
68944 + GR_ROLE_GOD = 0x0040,
68945 + GR_ROLE_LEARN = 0x0080,
68946 + GR_ROLE_TPE = 0x0100,
68947 + GR_ROLE_DOMAIN = 0x0200,
68948 + GR_ROLE_PAM = 0x0400,
68949 + GR_ROLE_PERSIST = 0x0800
68950 +};
68951 +
68952 +/* ACL Subject and Object mode flags */
68953 +enum {
68954 + GR_DELETED = 0x80000000
68955 +};
68956 +
68957 +/* ACL Object-only mode flags */
68958 +enum {
68959 + GR_READ = 0x00000001,
68960 + GR_APPEND = 0x00000002,
68961 + GR_WRITE = 0x00000004,
68962 + GR_EXEC = 0x00000008,
68963 + GR_FIND = 0x00000010,
68964 + GR_INHERIT = 0x00000020,
68965 + GR_SETID = 0x00000040,
68966 + GR_CREATE = 0x00000080,
68967 + GR_DELETE = 0x00000100,
68968 + GR_LINK = 0x00000200,
68969 + GR_AUDIT_READ = 0x00000400,
68970 + GR_AUDIT_APPEND = 0x00000800,
68971 + GR_AUDIT_WRITE = 0x00001000,
68972 + GR_AUDIT_EXEC = 0x00002000,
68973 + GR_AUDIT_FIND = 0x00004000,
68974 + GR_AUDIT_INHERIT= 0x00008000,
68975 + GR_AUDIT_SETID = 0x00010000,
68976 + GR_AUDIT_CREATE = 0x00020000,
68977 + GR_AUDIT_DELETE = 0x00040000,
68978 + GR_AUDIT_LINK = 0x00080000,
68979 + GR_PTRACERD = 0x00100000,
68980 + GR_NOPTRACE = 0x00200000,
68981 + GR_SUPPRESS = 0x00400000,
68982 + GR_NOLEARN = 0x00800000,
68983 + GR_INIT_TRANSFER= 0x01000000
68984 +};
68985 +
68986 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
68987 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
68988 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
68989 +
68990 +/* ACL subject-only mode flags */
68991 +enum {
68992 + GR_KILL = 0x00000001,
68993 + GR_VIEW = 0x00000002,
68994 + GR_PROTECTED = 0x00000004,
68995 + GR_LEARN = 0x00000008,
68996 + GR_OVERRIDE = 0x00000010,
68997 + /* just a placeholder, this mode is only used in userspace */
68998 + GR_DUMMY = 0x00000020,
68999 + GR_PROTSHM = 0x00000040,
69000 + GR_KILLPROC = 0x00000080,
69001 + GR_KILLIPPROC = 0x00000100,
69002 + /* just a placeholder, this mode is only used in userspace */
69003 + GR_NOTROJAN = 0x00000200,
69004 + GR_PROTPROCFD = 0x00000400,
69005 + GR_PROCACCT = 0x00000800,
69006 + GR_RELAXPTRACE = 0x00001000,
69007 + //GR_NESTED = 0x00002000,
69008 + GR_INHERITLEARN = 0x00004000,
69009 + GR_PROCFIND = 0x00008000,
69010 + GR_POVERRIDE = 0x00010000,
69011 + GR_KERNELAUTH = 0x00020000,
69012 + GR_ATSECURE = 0x00040000,
69013 + GR_SHMEXEC = 0x00080000
69014 +};
69015 +
69016 +enum {
69017 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69018 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69019 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69020 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69021 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69022 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69023 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69024 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69025 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69026 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69027 +};
69028 +
69029 +enum {
69030 + GR_ID_USER = 0x01,
69031 + GR_ID_GROUP = 0x02,
69032 +};
69033 +
69034 +enum {
69035 + GR_ID_ALLOW = 0x01,
69036 + GR_ID_DENY = 0x02,
69037 +};
69038 +
69039 +#define GR_CRASH_RES 31
69040 +#define GR_UIDTABLE_MAX 500
69041 +
69042 +/* begin resource learning section */
69043 +enum {
69044 + GR_RLIM_CPU_BUMP = 60,
69045 + GR_RLIM_FSIZE_BUMP = 50000,
69046 + GR_RLIM_DATA_BUMP = 10000,
69047 + GR_RLIM_STACK_BUMP = 1000,
69048 + GR_RLIM_CORE_BUMP = 10000,
69049 + GR_RLIM_RSS_BUMP = 500000,
69050 + GR_RLIM_NPROC_BUMP = 1,
69051 + GR_RLIM_NOFILE_BUMP = 5,
69052 + GR_RLIM_MEMLOCK_BUMP = 50000,
69053 + GR_RLIM_AS_BUMP = 500000,
69054 + GR_RLIM_LOCKS_BUMP = 2,
69055 + GR_RLIM_SIGPENDING_BUMP = 5,
69056 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69057 + GR_RLIM_NICE_BUMP = 1,
69058 + GR_RLIM_RTPRIO_BUMP = 1,
69059 + GR_RLIM_RTTIME_BUMP = 1000000
69060 +};
69061 +
69062 +#endif
69063 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69064 new file mode 100644
69065 index 0000000..9bb6662
69066 --- /dev/null
69067 +++ b/include/linux/grinternal.h
69068 @@ -0,0 +1,215 @@
69069 +#ifndef __GRINTERNAL_H
69070 +#define __GRINTERNAL_H
69071 +
69072 +#ifdef CONFIG_GRKERNSEC
69073 +
69074 +#include <linux/fs.h>
69075 +#include <linux/mnt_namespace.h>
69076 +#include <linux/nsproxy.h>
69077 +#include <linux/gracl.h>
69078 +#include <linux/grdefs.h>
69079 +#include <linux/grmsg.h>
69080 +
69081 +void gr_add_learn_entry(const char *fmt, ...)
69082 + __attribute__ ((format (printf, 1, 2)));
69083 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69084 + const struct vfsmount *mnt);
69085 +__u32 gr_check_create(const struct dentry *new_dentry,
69086 + const struct dentry *parent,
69087 + const struct vfsmount *mnt, const __u32 mode);
69088 +int gr_check_protected_task(const struct task_struct *task);
69089 +__u32 to_gr_audit(const __u32 reqmode);
69090 +int gr_set_acls(const int type);
69091 +int gr_apply_subject_to_task(struct task_struct *task);
69092 +int gr_acl_is_enabled(void);
69093 +char gr_roletype_to_char(void);
69094 +
69095 +void gr_handle_alertkill(struct task_struct *task);
69096 +char *gr_to_filename(const struct dentry *dentry,
69097 + const struct vfsmount *mnt);
69098 +char *gr_to_filename1(const struct dentry *dentry,
69099 + const struct vfsmount *mnt);
69100 +char *gr_to_filename2(const struct dentry *dentry,
69101 + const struct vfsmount *mnt);
69102 +char *gr_to_filename3(const struct dentry *dentry,
69103 + const struct vfsmount *mnt);
69104 +
69105 +extern int grsec_enable_ptrace_readexec;
69106 +extern int grsec_enable_harden_ptrace;
69107 +extern int grsec_enable_link;
69108 +extern int grsec_enable_fifo;
69109 +extern int grsec_enable_execve;
69110 +extern int grsec_enable_shm;
69111 +extern int grsec_enable_execlog;
69112 +extern int grsec_enable_signal;
69113 +extern int grsec_enable_audit_ptrace;
69114 +extern int grsec_enable_forkfail;
69115 +extern int grsec_enable_time;
69116 +extern int grsec_enable_rofs;
69117 +extern int grsec_enable_chroot_shmat;
69118 +extern int grsec_enable_chroot_mount;
69119 +extern int grsec_enable_chroot_double;
69120 +extern int grsec_enable_chroot_pivot;
69121 +extern int grsec_enable_chroot_chdir;
69122 +extern int grsec_enable_chroot_chmod;
69123 +extern int grsec_enable_chroot_mknod;
69124 +extern int grsec_enable_chroot_fchdir;
69125 +extern int grsec_enable_chroot_nice;
69126 +extern int grsec_enable_chroot_execlog;
69127 +extern int grsec_enable_chroot_caps;
69128 +extern int grsec_enable_chroot_sysctl;
69129 +extern int grsec_enable_chroot_unix;
69130 +extern int grsec_enable_symlinkown;
69131 +extern kgid_t grsec_symlinkown_gid;
69132 +extern int grsec_enable_tpe;
69133 +extern kgid_t grsec_tpe_gid;
69134 +extern int grsec_enable_tpe_all;
69135 +extern int grsec_enable_tpe_invert;
69136 +extern int grsec_enable_socket_all;
69137 +extern kgid_t grsec_socket_all_gid;
69138 +extern int grsec_enable_socket_client;
69139 +extern kgid_t grsec_socket_client_gid;
69140 +extern int grsec_enable_socket_server;
69141 +extern kgid_t grsec_socket_server_gid;
69142 +extern kgid_t grsec_audit_gid;
69143 +extern int grsec_enable_group;
69144 +extern int grsec_enable_audit_textrel;
69145 +extern int grsec_enable_log_rwxmaps;
69146 +extern int grsec_enable_mount;
69147 +extern int grsec_enable_chdir;
69148 +extern int grsec_resource_logging;
69149 +extern int grsec_enable_blackhole;
69150 +extern int grsec_lastack_retries;
69151 +extern int grsec_enable_brute;
69152 +extern int grsec_lock;
69153 +
69154 +extern spinlock_t grsec_alert_lock;
69155 +extern unsigned long grsec_alert_wtime;
69156 +extern unsigned long grsec_alert_fyet;
69157 +
69158 +extern spinlock_t grsec_audit_lock;
69159 +
69160 +extern rwlock_t grsec_exec_file_lock;
69161 +
69162 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69163 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69164 + (tsk)->exec_file->f_vfsmnt) : "/")
69165 +
69166 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69167 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69168 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69169 +
69170 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69171 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69172 + (tsk)->exec_file->f_vfsmnt) : "/")
69173 +
69174 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69175 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69176 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69177 +
69178 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69179 +
69180 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69181 +
69182 +#define GR_CHROOT_CAPS {{ \
69183 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69184 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69185 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69186 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69187 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69188 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69189 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69190 +
69191 +#define security_learn(normal_msg,args...) \
69192 +({ \
69193 + read_lock(&grsec_exec_file_lock); \
69194 + gr_add_learn_entry(normal_msg "\n", ## args); \
69195 + read_unlock(&grsec_exec_file_lock); \
69196 +})
69197 +
69198 +enum {
69199 + GR_DO_AUDIT,
69200 + GR_DONT_AUDIT,
69201 + /* used for non-audit messages that we shouldn't kill the task on */
69202 + GR_DONT_AUDIT_GOOD
69203 +};
69204 +
69205 +enum {
69206 + GR_TTYSNIFF,
69207 + GR_RBAC,
69208 + GR_RBAC_STR,
69209 + GR_STR_RBAC,
69210 + GR_RBAC_MODE2,
69211 + GR_RBAC_MODE3,
69212 + GR_FILENAME,
69213 + GR_SYSCTL_HIDDEN,
69214 + GR_NOARGS,
69215 + GR_ONE_INT,
69216 + GR_ONE_INT_TWO_STR,
69217 + GR_ONE_STR,
69218 + GR_STR_INT,
69219 + GR_TWO_STR_INT,
69220 + GR_TWO_INT,
69221 + GR_TWO_U64,
69222 + GR_THREE_INT,
69223 + GR_FIVE_INT_TWO_STR,
69224 + GR_TWO_STR,
69225 + GR_THREE_STR,
69226 + GR_FOUR_STR,
69227 + GR_STR_FILENAME,
69228 + GR_FILENAME_STR,
69229 + GR_FILENAME_TWO_INT,
69230 + GR_FILENAME_TWO_INT_STR,
69231 + GR_TEXTREL,
69232 + GR_PTRACE,
69233 + GR_RESOURCE,
69234 + GR_CAP,
69235 + GR_SIG,
69236 + GR_SIG2,
69237 + GR_CRASH1,
69238 + GR_CRASH2,
69239 + GR_PSACCT,
69240 + GR_RWXMAP
69241 +};
69242 +
69243 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69244 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69245 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69246 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69247 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69248 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69249 +#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)
69250 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69251 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69252 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69253 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69254 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69255 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69256 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69257 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69258 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69259 +#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)
69260 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69261 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69262 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69263 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69264 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69265 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69266 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69267 +#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)
69268 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69269 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69270 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69271 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69272 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69273 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69274 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69275 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69276 +#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)
69277 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69278 +
69279 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69280 +
69281 +#endif
69282 +
69283 +#endif
69284 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69285 new file mode 100644
69286 index 0000000..2bd4c8d
69287 --- /dev/null
69288 +++ b/include/linux/grmsg.h
69289 @@ -0,0 +1,111 @@
69290 +#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"
69291 +#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"
69292 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69293 +#define GR_STOPMOD_MSG "denied modification of module state by "
69294 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69295 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69296 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69297 +#define GR_IOPL_MSG "denied use of iopl() by "
69298 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69299 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69300 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69301 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69302 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69303 +#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"
69304 +#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"
69305 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69306 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69307 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69308 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69309 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69310 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69311 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69312 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69313 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69314 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69315 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69316 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69317 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69318 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69319 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69320 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69321 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69322 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69323 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69324 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69325 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69326 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69327 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69328 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69329 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69330 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69331 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69332 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69333 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69334 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69335 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69336 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69337 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69338 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69339 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69340 +#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"
69341 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69342 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69343 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69344 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69345 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69346 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69347 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69348 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69349 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69350 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69351 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69352 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69353 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69354 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69355 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69356 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69357 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69358 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69359 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69360 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69361 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69362 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69363 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69364 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69365 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69366 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69367 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69368 +#define GR_TIME_MSG "time set by "
69369 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69370 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69371 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69372 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69373 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69374 +#define GR_BIND_MSG "denied bind() by "
69375 +#define GR_CONNECT_MSG "denied connect() by "
69376 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69377 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69378 +#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"
69379 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69380 +#define GR_CAP_ACL_MSG "use of %s denied for "
69381 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69382 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69383 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69384 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69385 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69386 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69387 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69388 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69389 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69390 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69391 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69392 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69393 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69394 +#define GR_VM86_MSG "denied use of vm86 by "
69395 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69396 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69397 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69398 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69399 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69400 +#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 "
69401 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69402 new file mode 100644
69403 index 0000000..8da63a4
69404 --- /dev/null
69405 +++ b/include/linux/grsecurity.h
69406 @@ -0,0 +1,242 @@
69407 +#ifndef GR_SECURITY_H
69408 +#define GR_SECURITY_H
69409 +#include <linux/fs.h>
69410 +#include <linux/fs_struct.h>
69411 +#include <linux/binfmts.h>
69412 +#include <linux/gracl.h>
69413 +
69414 +/* notify of brain-dead configs */
69415 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69416 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69417 +#endif
69418 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69419 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69420 +#endif
69421 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69422 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69423 +#endif
69424 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69425 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69426 +#endif
69427 +
69428 +void gr_handle_brute_attach(unsigned long mm_flags);
69429 +void gr_handle_brute_check(void);
69430 +void gr_handle_kernel_exploit(void);
69431 +int gr_process_user_ban(void);
69432 +
69433 +char gr_roletype_to_char(void);
69434 +
69435 +int gr_acl_enable_at_secure(void);
69436 +
69437 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69438 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69439 +
69440 +void gr_del_task_from_ip_table(struct task_struct *p);
69441 +
69442 +int gr_pid_is_chrooted(struct task_struct *p);
69443 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69444 +int gr_handle_chroot_nice(void);
69445 +int gr_handle_chroot_sysctl(const int op);
69446 +int gr_handle_chroot_setpriority(struct task_struct *p,
69447 + const int niceval);
69448 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69449 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69450 + const struct vfsmount *mnt);
69451 +void gr_handle_chroot_chdir(struct path *path);
69452 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69453 + const struct vfsmount *mnt, const int mode);
69454 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69455 + const struct vfsmount *mnt, const int mode);
69456 +int gr_handle_chroot_mount(const struct dentry *dentry,
69457 + const struct vfsmount *mnt,
69458 + const char *dev_name);
69459 +int gr_handle_chroot_pivot(void);
69460 +int gr_handle_chroot_unix(const pid_t pid);
69461 +
69462 +int gr_handle_rawio(const struct inode *inode);
69463 +
69464 +void gr_handle_ioperm(void);
69465 +void gr_handle_iopl(void);
69466 +
69467 +umode_t gr_acl_umask(void);
69468 +
69469 +int gr_tpe_allow(const struct file *file);
69470 +
69471 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
69472 +void gr_clear_chroot_entries(struct task_struct *task);
69473 +
69474 +void gr_log_forkfail(const int retval);
69475 +void gr_log_timechange(void);
69476 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69477 +void gr_log_chdir(const struct dentry *dentry,
69478 + const struct vfsmount *mnt);
69479 +void gr_log_chroot_exec(const struct dentry *dentry,
69480 + const struct vfsmount *mnt);
69481 +void gr_log_remount(const char *devname, const int retval);
69482 +void gr_log_unmount(const char *devname, const int retval);
69483 +void gr_log_mount(const char *from, const char *to, const int retval);
69484 +void gr_log_textrel(struct vm_area_struct *vma);
69485 +void gr_log_rwxmmap(struct file *file);
69486 +void gr_log_rwxmprotect(struct file *file);
69487 +
69488 +int gr_handle_follow_link(const struct inode *parent,
69489 + const struct inode *inode,
69490 + const struct dentry *dentry,
69491 + const struct vfsmount *mnt);
69492 +int gr_handle_fifo(const struct dentry *dentry,
69493 + const struct vfsmount *mnt,
69494 + const struct dentry *dir, const int flag,
69495 + const int acc_mode);
69496 +int gr_handle_hardlink(const struct dentry *dentry,
69497 + const struct vfsmount *mnt,
69498 + struct inode *inode,
69499 + const int mode, const struct filename *to);
69500 +
69501 +int gr_is_capable(const int cap);
69502 +int gr_is_capable_nolog(const int cap);
69503 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69504 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69505 +
69506 +void gr_copy_label(struct task_struct *tsk);
69507 +void gr_handle_crash(struct task_struct *task, const int sig);
69508 +int gr_handle_signal(const struct task_struct *p, const int sig);
69509 +int gr_check_crash_uid(const kuid_t uid);
69510 +int gr_check_protected_task(const struct task_struct *task);
69511 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69512 +int gr_acl_handle_mmap(const struct file *file,
69513 + const unsigned long prot);
69514 +int gr_acl_handle_mprotect(const struct file *file,
69515 + const unsigned long prot);
69516 +int gr_check_hidden_task(const struct task_struct *tsk);
69517 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69518 + const struct vfsmount *mnt);
69519 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69520 + const struct vfsmount *mnt);
69521 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69522 + const struct vfsmount *mnt, const int fmode);
69523 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69524 + const struct vfsmount *mnt, umode_t *mode);
69525 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69526 + const struct vfsmount *mnt);
69527 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69528 + const struct vfsmount *mnt);
69529 +int gr_handle_ptrace(struct task_struct *task, const long request);
69530 +int gr_handle_proc_ptrace(struct task_struct *task);
69531 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69532 + const struct vfsmount *mnt);
69533 +int gr_check_crash_exec(const struct file *filp);
69534 +int gr_acl_is_enabled(void);
69535 +void gr_set_kernel_label(struct task_struct *task);
69536 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69537 + const kgid_t gid);
69538 +int gr_set_proc_label(const struct dentry *dentry,
69539 + const struct vfsmount *mnt,
69540 + const int unsafe_flags);
69541 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69542 + const struct vfsmount *mnt);
69543 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69544 + const struct vfsmount *mnt, int acc_mode);
69545 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69546 + const struct dentry *p_dentry,
69547 + const struct vfsmount *p_mnt,
69548 + int open_flags, int acc_mode, const int imode);
69549 +void gr_handle_create(const struct dentry *dentry,
69550 + const struct vfsmount *mnt);
69551 +void gr_handle_proc_create(const struct dentry *dentry,
69552 + const struct inode *inode);
69553 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69554 + const struct dentry *parent_dentry,
69555 + const struct vfsmount *parent_mnt,
69556 + const int mode);
69557 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69558 + const struct dentry *parent_dentry,
69559 + const struct vfsmount *parent_mnt);
69560 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69561 + const struct vfsmount *mnt);
69562 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69563 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69564 + const struct vfsmount *mnt);
69565 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69566 + const struct dentry *parent_dentry,
69567 + const struct vfsmount *parent_mnt,
69568 + const struct filename *from);
69569 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69570 + const struct dentry *parent_dentry,
69571 + const struct vfsmount *parent_mnt,
69572 + const struct dentry *old_dentry,
69573 + const struct vfsmount *old_mnt, const struct filename *to);
69574 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69575 +int gr_acl_handle_rename(struct dentry *new_dentry,
69576 + struct dentry *parent_dentry,
69577 + const struct vfsmount *parent_mnt,
69578 + struct dentry *old_dentry,
69579 + struct inode *old_parent_inode,
69580 + struct vfsmount *old_mnt, const struct filename *newname);
69581 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69582 + struct dentry *old_dentry,
69583 + struct dentry *new_dentry,
69584 + struct vfsmount *mnt, const __u8 replace);
69585 +__u32 gr_check_link(const struct dentry *new_dentry,
69586 + const struct dentry *parent_dentry,
69587 + const struct vfsmount *parent_mnt,
69588 + const struct dentry *old_dentry,
69589 + const struct vfsmount *old_mnt);
69590 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69591 + const unsigned int namelen, const ino_t ino);
69592 +
69593 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69594 + const struct vfsmount *mnt);
69595 +void gr_acl_handle_exit(void);
69596 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69597 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69598 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69599 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69600 +void gr_audit_ptrace(struct task_struct *task);
69601 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69602 +void gr_put_exec_file(struct task_struct *task);
69603 +
69604 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69605 +
69606 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69607 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69608 + const unsigned long wanted, const int gt);
69609 +#else
69610 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69611 + const unsigned long wanted, const int gt)
69612 +{
69613 +}
69614 +#endif
69615 +
69616 +#ifdef CONFIG_GRKERNSEC_RESLOG
69617 +extern void gr_log_resource(const struct task_struct *task, const int res,
69618 + const unsigned long wanted, const int gt);
69619 +#else
69620 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69621 + const unsigned long wanted, const int gt)
69622 +{
69623 +}
69624 +#endif
69625 +
69626 +#ifdef CONFIG_GRKERNSEC
69627 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69628 +void gr_handle_vm86(void);
69629 +void gr_handle_mem_readwrite(u64 from, u64 to);
69630 +
69631 +void gr_log_badprocpid(const char *entry);
69632 +
69633 +extern int grsec_enable_dmesg;
69634 +extern int grsec_disable_privio;
69635 +
69636 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69637 +extern kgid_t grsec_proc_gid;
69638 +#endif
69639 +
69640 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69641 +extern int grsec_enable_chroot_findtask;
69642 +#endif
69643 +#ifdef CONFIG_GRKERNSEC_SETXID
69644 +extern int grsec_enable_setxid;
69645 +#endif
69646 +#endif
69647 +
69648 +#endif
69649 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69650 new file mode 100644
69651 index 0000000..e7ffaaf
69652 --- /dev/null
69653 +++ b/include/linux/grsock.h
69654 @@ -0,0 +1,19 @@
69655 +#ifndef __GRSOCK_H
69656 +#define __GRSOCK_H
69657 +
69658 +extern void gr_attach_curr_ip(const struct sock *sk);
69659 +extern int gr_handle_sock_all(const int family, const int type,
69660 + const int protocol);
69661 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69662 +extern int gr_handle_sock_server_other(const struct sock *sck);
69663 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69664 +extern int gr_search_connect(struct socket * sock,
69665 + struct sockaddr_in * addr);
69666 +extern int gr_search_bind(struct socket * sock,
69667 + struct sockaddr_in * addr);
69668 +extern int gr_search_listen(struct socket * sock);
69669 +extern int gr_search_accept(struct socket * sock);
69670 +extern int gr_search_socket(const int domain, const int type,
69671 + const int protocol);
69672 +
69673 +#endif
69674 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69675 index ef788b5..ac41b7b 100644
69676 --- a/include/linux/highmem.h
69677 +++ b/include/linux/highmem.h
69678 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69679 kunmap_atomic(kaddr);
69680 }
69681
69682 +static inline void sanitize_highpage(struct page *page)
69683 +{
69684 + void *kaddr;
69685 + unsigned long flags;
69686 +
69687 + local_irq_save(flags);
69688 + kaddr = kmap_atomic(page);
69689 + clear_page(kaddr);
69690 + kunmap_atomic(kaddr);
69691 + local_irq_restore(flags);
69692 +}
69693 +
69694 static inline void zero_user_segments(struct page *page,
69695 unsigned start1, unsigned end1,
69696 unsigned start2, unsigned end2)
69697 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69698 index 1c7b89a..7f52502 100644
69699 --- a/include/linux/hwmon-sysfs.h
69700 +++ b/include/linux/hwmon-sysfs.h
69701 @@ -25,7 +25,8 @@
69702 struct sensor_device_attribute{
69703 struct device_attribute dev_attr;
69704 int index;
69705 -};
69706 +} __do_const;
69707 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69708 #define to_sensor_dev_attr(_dev_attr) \
69709 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69710
69711 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69712 struct device_attribute dev_attr;
69713 u8 index;
69714 u8 nr;
69715 -};
69716 +} __do_const;
69717 #define to_sensor_dev_attr_2(_dev_attr) \
69718 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69719
69720 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69721 index d0c4db7..61b3577 100644
69722 --- a/include/linux/i2c.h
69723 +++ b/include/linux/i2c.h
69724 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69725 /* To determine what the adapter supports */
69726 u32 (*functionality) (struct i2c_adapter *);
69727 };
69728 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69729
69730 /*
69731 * i2c_adapter is the structure used to identify a physical i2c bus along
69732 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69733 index d23c3c2..eb63c81 100644
69734 --- a/include/linux/i2o.h
69735 +++ b/include/linux/i2o.h
69736 @@ -565,7 +565,7 @@ struct i2o_controller {
69737 struct i2o_device *exec; /* Executive */
69738 #if BITS_PER_LONG == 64
69739 spinlock_t context_list_lock; /* lock for context_list */
69740 - atomic_t context_list_counter; /* needed for unique contexts */
69741 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69742 struct list_head context_list; /* list of context id's
69743 and pointers */
69744 #endif
69745 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69746 index aff7ad8..3942bbd 100644
69747 --- a/include/linux/if_pppox.h
69748 +++ b/include/linux/if_pppox.h
69749 @@ -76,7 +76,7 @@ struct pppox_proto {
69750 int (*ioctl)(struct socket *sock, unsigned int cmd,
69751 unsigned long arg);
69752 struct module *owner;
69753 -};
69754 +} __do_const;
69755
69756 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69757 extern void unregister_pppox_proto(int proto_num);
69758 diff --git a/include/linux/init.h b/include/linux/init.h
69759 index 10ed4f4..8e8490d 100644
69760 --- a/include/linux/init.h
69761 +++ b/include/linux/init.h
69762 @@ -39,9 +39,36 @@
69763 * Also note, that this data cannot be "const".
69764 */
69765
69766 +#ifdef MODULE
69767 +#define add_init_latent_entropy
69768 +#define add_devinit_latent_entropy
69769 +#define add_cpuinit_latent_entropy
69770 +#define add_meminit_latent_entropy
69771 +#else
69772 +#define add_init_latent_entropy __latent_entropy
69773 +
69774 +#ifdef CONFIG_HOTPLUG
69775 +#define add_devinit_latent_entropy
69776 +#else
69777 +#define add_devinit_latent_entropy __latent_entropy
69778 +#endif
69779 +
69780 +#ifdef CONFIG_HOTPLUG_CPU
69781 +#define add_cpuinit_latent_entropy
69782 +#else
69783 +#define add_cpuinit_latent_entropy __latent_entropy
69784 +#endif
69785 +
69786 +#ifdef CONFIG_MEMORY_HOTPLUG
69787 +#define add_meminit_latent_entropy
69788 +#else
69789 +#define add_meminit_latent_entropy __latent_entropy
69790 +#endif
69791 +#endif
69792 +
69793 /* These are for everybody (although not all archs will actually
69794 discard it in modules) */
69795 -#define __init __section(.init.text) __cold notrace
69796 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69797 #define __initdata __section(.init.data)
69798 #define __initconst __constsection(.init.rodata)
69799 #define __exitdata __section(.exit.data)
69800 @@ -94,7 +121,7 @@
69801 #define __exit __section(.exit.text) __exitused __cold notrace
69802
69803 /* Used for HOTPLUG_CPU */
69804 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69805 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69806 #define __cpuinitdata __section(.cpuinit.data)
69807 #define __cpuinitconst __constsection(.cpuinit.rodata)
69808 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69809 @@ -102,7 +129,7 @@
69810 #define __cpuexitconst __constsection(.cpuexit.rodata)
69811
69812 /* Used for MEMORY_HOTPLUG */
69813 -#define __meminit __section(.meminit.text) __cold notrace
69814 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69815 #define __meminitdata __section(.meminit.data)
69816 #define __meminitconst __constsection(.meminit.rodata)
69817 #define __memexit __section(.memexit.text) __exitused __cold notrace
69818 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69819 index 6d087c5..401cab8 100644
69820 --- a/include/linux/init_task.h
69821 +++ b/include/linux/init_task.h
69822 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
69823
69824 #define INIT_TASK_COMM "swapper"
69825
69826 +#ifdef CONFIG_X86
69827 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69828 +#else
69829 +#define INIT_TASK_THREAD_INFO
69830 +#endif
69831 +
69832 /*
69833 * INIT_TASK is used to set up the first task table, touch at
69834 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69835 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
69836 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69837 .comm = INIT_TASK_COMM, \
69838 .thread = INIT_THREAD, \
69839 + INIT_TASK_THREAD_INFO \
69840 .fs = &init_fs, \
69841 .files = &init_files, \
69842 .signal = &init_signals, \
69843 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69844 index 5fa5afe..ac55b25 100644
69845 --- a/include/linux/interrupt.h
69846 +++ b/include/linux/interrupt.h
69847 @@ -430,7 +430,7 @@ enum
69848 /* map softirq index to softirq name. update 'softirq_to_name' in
69849 * kernel/softirq.c when adding a new softirq.
69850 */
69851 -extern char *softirq_to_name[NR_SOFTIRQS];
69852 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69853
69854 /* softirq mask and active fields moved to irq_cpustat_t in
69855 * asm/hardirq.h to get better cache usage. KAO
69856 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69857
69858 struct softirq_action
69859 {
69860 - void (*action)(struct softirq_action *);
69861 -};
69862 + void (*action)(void);
69863 +} __no_const;
69864
69865 asmlinkage void do_softirq(void);
69866 asmlinkage void __do_softirq(void);
69867 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69868 +extern void open_softirq(int nr, void (*action)(void));
69869 extern void softirq_init(void);
69870 extern void __raise_softirq_irqoff(unsigned int nr);
69871
69872 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69873 index f3b99e1..9b73cee 100644
69874 --- a/include/linux/iommu.h
69875 +++ b/include/linux/iommu.h
69876 @@ -101,7 +101,7 @@ struct iommu_ops {
69877 int (*domain_set_attr)(struct iommu_domain *domain,
69878 enum iommu_attr attr, void *data);
69879 unsigned long pgsize_bitmap;
69880 -};
69881 +} __do_const;
69882
69883 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69884 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69885 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
69886 index 85ac9b9b..e5759ab 100644
69887 --- a/include/linux/ioport.h
69888 +++ b/include/linux/ioport.h
69889 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
69890 int adjust_resource(struct resource *res, resource_size_t start,
69891 resource_size_t size);
69892 resource_size_t resource_alignment(struct resource *res);
69893 -static inline resource_size_t resource_size(const struct resource *res)
69894 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
69895 {
69896 return res->end - res->start + 1;
69897 }
69898 diff --git a/include/linux/irq.h b/include/linux/irq.h
69899 index fdf2c4a..5332486 100644
69900 --- a/include/linux/irq.h
69901 +++ b/include/linux/irq.h
69902 @@ -328,7 +328,8 @@ struct irq_chip {
69903 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69904
69905 unsigned long flags;
69906 -};
69907 +} __do_const;
69908 +typedef struct irq_chip __no_const irq_chip_no_const;
69909
69910 /*
69911 * irq_chip specific flags
69912 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69913 index 6883e19..06992b1 100644
69914 --- a/include/linux/kallsyms.h
69915 +++ b/include/linux/kallsyms.h
69916 @@ -15,7 +15,8 @@
69917
69918 struct module;
69919
69920 -#ifdef CONFIG_KALLSYMS
69921 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69922 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69923 /* Lookup the address for a symbol. Returns 0 if not found. */
69924 unsigned long kallsyms_lookup_name(const char *name);
69925
69926 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69927 /* Stupid that this does nothing, but I didn't create this mess. */
69928 #define __print_symbol(fmt, addr)
69929 #endif /*CONFIG_KALLSYMS*/
69930 +#else /* when included by kallsyms.c, vsnprintf.c, or
69931 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69932 +extern void __print_symbol(const char *fmt, unsigned long address);
69933 +extern int sprint_backtrace(char *buffer, unsigned long address);
69934 +extern int sprint_symbol(char *buffer, unsigned long address);
69935 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69936 +const char *kallsyms_lookup(unsigned long addr,
69937 + unsigned long *symbolsize,
69938 + unsigned long *offset,
69939 + char **modname, char *namebuf);
69940 +#endif
69941
69942 /* This macro allows us to keep printk typechecking */
69943 static __printf(1, 2)
69944 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69945 index 518a53a..5e28358 100644
69946 --- a/include/linux/key-type.h
69947 +++ b/include/linux/key-type.h
69948 @@ -125,7 +125,7 @@ struct key_type {
69949 /* internal fields */
69950 struct list_head link; /* link in types list */
69951 struct lock_class_key lock_class; /* key->sem lock class */
69952 -};
69953 +} __do_const;
69954
69955 extern struct key_type key_type_keyring;
69956
69957 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69958 index 4dff0c6..1ca9b72 100644
69959 --- a/include/linux/kgdb.h
69960 +++ b/include/linux/kgdb.h
69961 @@ -53,7 +53,7 @@ extern int kgdb_connected;
69962 extern int kgdb_io_module_registered;
69963
69964 extern atomic_t kgdb_setting_breakpoint;
69965 -extern atomic_t kgdb_cpu_doing_single_step;
69966 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69967
69968 extern struct task_struct *kgdb_usethread;
69969 extern struct task_struct *kgdb_contthread;
69970 @@ -255,7 +255,7 @@ struct kgdb_arch {
69971 void (*correct_hw_break)(void);
69972
69973 void (*enable_nmi)(bool on);
69974 -};
69975 +} __do_const;
69976
69977 /**
69978 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69979 @@ -280,7 +280,7 @@ struct kgdb_io {
69980 void (*pre_exception) (void);
69981 void (*post_exception) (void);
69982 int is_console;
69983 -};
69984 +} __do_const;
69985
69986 extern struct kgdb_arch arch_kgdb_ops;
69987
69988 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
69989 index 5398d58..5883a34 100644
69990 --- a/include/linux/kmod.h
69991 +++ b/include/linux/kmod.h
69992 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
69993 * usually useless though. */
69994 extern __printf(2, 3)
69995 int __request_module(bool wait, const char *name, ...);
69996 +extern __printf(3, 4)
69997 +int ___request_module(bool wait, char *param_name, const char *name, ...);
69998 #define request_module(mod...) __request_module(true, mod)
69999 #define request_module_nowait(mod...) __request_module(false, mod)
70000 #define try_then_request_module(x, mod...) \
70001 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70002 index 939b112..ed6ed51 100644
70003 --- a/include/linux/kobject.h
70004 +++ b/include/linux/kobject.h
70005 @@ -111,7 +111,7 @@ struct kobj_type {
70006 struct attribute **default_attrs;
70007 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70008 const void *(*namespace)(struct kobject *kobj);
70009 -};
70010 +} __do_const;
70011
70012 struct kobj_uevent_env {
70013 char *envp[UEVENT_NUM_ENVP];
70014 @@ -134,6 +134,7 @@ struct kobj_attribute {
70015 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70016 const char *buf, size_t count);
70017 };
70018 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70019
70020 extern const struct sysfs_ops kobj_sysfs_ops;
70021
70022 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70023 index f66b065..c2c29b4 100644
70024 --- a/include/linux/kobject_ns.h
70025 +++ b/include/linux/kobject_ns.h
70026 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70027 const void *(*netlink_ns)(struct sock *sk);
70028 const void *(*initial_ns)(void);
70029 void (*drop_ns)(void *);
70030 -};
70031 +} __do_const;
70032
70033 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70034 int kobj_ns_type_registered(enum kobj_ns_type type);
70035 diff --git a/include/linux/kref.h b/include/linux/kref.h
70036 index 4972e6e..de4d19b 100644
70037 --- a/include/linux/kref.h
70038 +++ b/include/linux/kref.h
70039 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
70040 static inline int kref_sub(struct kref *kref, unsigned int count,
70041 void (*release)(struct kref *kref))
70042 {
70043 - WARN_ON(release == NULL);
70044 + BUG_ON(release == NULL);
70045
70046 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70047 release(kref);
70048 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70049 index 2c497ab..afe32f5 100644
70050 --- a/include/linux/kvm_host.h
70051 +++ b/include/linux/kvm_host.h
70052 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
70053 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
70054 void vcpu_put(struct kvm_vcpu *vcpu);
70055
70056 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70057 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70058 struct module *module);
70059 void kvm_exit(void);
70060
70061 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70062 struct kvm_guest_debug *dbg);
70063 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70064
70065 -int kvm_arch_init(void *opaque);
70066 +int kvm_arch_init(const void *opaque);
70067 void kvm_arch_exit(void);
70068
70069 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70070 diff --git a/include/linux/libata.h b/include/linux/libata.h
70071 index 0621bca..24d6851 100644
70072 --- a/include/linux/libata.h
70073 +++ b/include/linux/libata.h
70074 @@ -916,7 +916,7 @@ struct ata_port_operations {
70075 * fields must be pointers.
70076 */
70077 const struct ata_port_operations *inherits;
70078 -};
70079 +} __do_const;
70080
70081 struct ata_port_info {
70082 unsigned long flags;
70083 diff --git a/include/linux/list.h b/include/linux/list.h
70084 index cc6d2aa..c10ee83 100644
70085 --- a/include/linux/list.h
70086 +++ b/include/linux/list.h
70087 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70088 extern void list_del(struct list_head *entry);
70089 #endif
70090
70091 +extern void __pax_list_add(struct list_head *new,
70092 + struct list_head *prev,
70093 + struct list_head *next);
70094 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70095 +{
70096 + __pax_list_add(new, head, head->next);
70097 +}
70098 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70099 +{
70100 + __pax_list_add(new, head->prev, head);
70101 +}
70102 +extern void pax_list_del(struct list_head *entry);
70103 +
70104 /**
70105 * list_replace - replace old entry by new one
70106 * @old : the element to be replaced
70107 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70108 INIT_LIST_HEAD(entry);
70109 }
70110
70111 +extern void pax_list_del_init(struct list_head *entry);
70112 +
70113 /**
70114 * list_move - delete from one list and add as another's head
70115 * @list: the entry to move
70116 diff --git a/include/linux/math64.h b/include/linux/math64.h
70117 index b8ba855..0148090 100644
70118 --- a/include/linux/math64.h
70119 +++ b/include/linux/math64.h
70120 @@ -14,7 +14,7 @@
70121 * This is commonly provided by 32bit archs to provide an optimized 64bit
70122 * divide.
70123 */
70124 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70125 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70126 {
70127 *remainder = dividend % divisor;
70128 return dividend / divisor;
70129 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70130 #define div64_long(x,y) div_s64((x),(y))
70131
70132 #ifndef div_u64_rem
70133 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70134 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70135 {
70136 *remainder = do_div(dividend, divisor);
70137 return dividend;
70138 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70139 * divide.
70140 */
70141 #ifndef div_u64
70142 -static inline u64 div_u64(u64 dividend, u32 divisor)
70143 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70144 {
70145 u32 remainder;
70146 return div_u64_rem(dividend, divisor, &remainder);
70147 diff --git a/include/linux/mm.h b/include/linux/mm.h
70148 index 66e2f7c..b916b9a 100644
70149 --- a/include/linux/mm.h
70150 +++ b/include/linux/mm.h
70151 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
70152 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70153 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70154 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70155 +
70156 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70157 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70158 +#endif
70159 +
70160 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70161
70162 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70163 @@ -200,8 +205,8 @@ struct vm_operations_struct {
70164 /* called by access_process_vm when get_user_pages() fails, typically
70165 * for use by special VMAs that can switch between memory and hardware
70166 */
70167 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70168 - void *buf, int len, int write);
70169 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70170 + void *buf, size_t len, int write);
70171 #ifdef CONFIG_NUMA
70172 /*
70173 * set_policy() op must add a reference to any non-NULL @new mempolicy
70174 @@ -231,6 +236,7 @@ struct vm_operations_struct {
70175 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70176 unsigned long size, pgoff_t pgoff);
70177 };
70178 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70179
70180 struct mmu_gather;
70181 struct inode;
70182 @@ -995,8 +1001,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70183 unsigned long *pfn);
70184 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70185 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70186 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70187 - void *buf, int len, int write);
70188 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70189 + void *buf, size_t len, int write);
70190
70191 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70192 loff_t const holebegin, loff_t const holelen)
70193 @@ -1035,10 +1041,10 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70194 }
70195 #endif
70196
70197 -extern int make_pages_present(unsigned long addr, unsigned long end);
70198 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70199 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70200 - void *buf, int len, int write);
70201 +extern ssize_t make_pages_present(unsigned long addr, unsigned long end);
70202 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70203 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70204 + void *buf, size_t len, int write);
70205
70206 int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70207 unsigned long start, int len, unsigned int foll_flags,
70208 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
70209 int set_page_dirty_lock(struct page *page);
70210 int clear_page_dirty_for_io(struct page *page);
70211
70212 -/* Is the vma a continuation of the stack vma above it? */
70213 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70214 -{
70215 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70216 -}
70217 -
70218 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70219 - unsigned long addr)
70220 -{
70221 - return (vma->vm_flags & VM_GROWSDOWN) &&
70222 - (vma->vm_start == addr) &&
70223 - !vma_growsdown(vma->vm_prev, addr);
70224 -}
70225 -
70226 -/* Is the vma a continuation of the stack vma below it? */
70227 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70228 -{
70229 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70230 -}
70231 -
70232 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70233 - unsigned long addr)
70234 -{
70235 - return (vma->vm_flags & VM_GROWSUP) &&
70236 - (vma->vm_end == addr) &&
70237 - !vma_growsup(vma->vm_next, addr);
70238 -}
70239 -
70240 extern pid_t
70241 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70242
70243 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70244 }
70245 #endif
70246
70247 +#ifdef CONFIG_MMU
70248 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70249 +#else
70250 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70251 +{
70252 + return __pgprot(0);
70253 +}
70254 +#endif
70255 +
70256 int vma_wants_writenotify(struct vm_area_struct *vma);
70257
70258 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70259 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70260 {
70261 return 0;
70262 }
70263 +
70264 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70265 + unsigned long address)
70266 +{
70267 + return 0;
70268 +}
70269 #else
70270 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70271 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70272 #endif
70273
70274 #ifdef __PAGETABLE_PMD_FOLDED
70275 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70276 {
70277 return 0;
70278 }
70279 +
70280 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70281 + unsigned long address)
70282 +{
70283 + return 0;
70284 +}
70285 #else
70286 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70287 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70288 #endif
70289
70290 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70291 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70292 NULL: pud_offset(pgd, address);
70293 }
70294
70295 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70296 +{
70297 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70298 + NULL: pud_offset(pgd, address);
70299 +}
70300 +
70301 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70302 {
70303 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70304 NULL: pmd_offset(pud, address);
70305 }
70306 +
70307 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70308 +{
70309 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70310 + NULL: pmd_offset(pud, address);
70311 +}
70312 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70313
70314 #if USE_SPLIT_PTLOCKS
70315 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
70316 unsigned long, unsigned long,
70317 unsigned long, unsigned long);
70318 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70319 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70320
70321 /* These take the mm semaphore themselves */
70322 extern unsigned long vm_brk(unsigned long, unsigned long);
70323 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70324 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70325 struct vm_area_struct **pprev);
70326
70327 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70328 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70329 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70330 +
70331 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70332 NULL if none. Assume start_addr < end_addr. */
70333 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70334 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70335 return vma;
70336 }
70337
70338 -#ifdef CONFIG_MMU
70339 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70340 -#else
70341 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70342 -{
70343 - return __pgprot(0);
70344 -}
70345 -#endif
70346 -
70347 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70348 unsigned long change_prot_numa(struct vm_area_struct *vma,
70349 unsigned long start, unsigned long end);
70350 @@ -1649,6 +1658,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70351 static inline void vm_stat_account(struct mm_struct *mm,
70352 unsigned long flags, struct file *file, long pages)
70353 {
70354 +
70355 +#ifdef CONFIG_PAX_RANDMMAP
70356 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70357 +#endif
70358 +
70359 mm->total_vm += pages;
70360 }
70361 #endif /* CONFIG_PROC_FS */
70362 @@ -1721,7 +1735,7 @@ extern int unpoison_memory(unsigned long pfn);
70363 extern int sysctl_memory_failure_early_kill;
70364 extern int sysctl_memory_failure_recovery;
70365 extern void shake_page(struct page *p, int access);
70366 -extern atomic_long_t mce_bad_pages;
70367 +extern atomic_long_unchecked_t mce_bad_pages;
70368 extern int soft_offline_page(struct page *page, int flags);
70369
70370 extern void dump_page(struct page *page);
70371 @@ -1752,5 +1766,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
70372 static inline bool page_is_guard(struct page *page) { return false; }
70373 #endif /* CONFIG_DEBUG_PAGEALLOC */
70374
70375 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70376 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70377 +#else
70378 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70379 +#endif
70380 +
70381 #endif /* __KERNEL__ */
70382 #endif /* _LINUX_MM_H */
70383 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70384 index f8f5162..3aaf20f 100644
70385 --- a/include/linux/mm_types.h
70386 +++ b/include/linux/mm_types.h
70387 @@ -288,6 +288,8 @@ struct vm_area_struct {
70388 #ifdef CONFIG_NUMA
70389 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70390 #endif
70391 +
70392 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70393 };
70394
70395 struct core_thread {
70396 @@ -436,6 +438,24 @@ struct mm_struct {
70397 int first_nid;
70398 #endif
70399 struct uprobes_state uprobes_state;
70400 +
70401 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70402 + unsigned long pax_flags;
70403 +#endif
70404 +
70405 +#ifdef CONFIG_PAX_DLRESOLVE
70406 + unsigned long call_dl_resolve;
70407 +#endif
70408 +
70409 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70410 + unsigned long call_syscall;
70411 +#endif
70412 +
70413 +#ifdef CONFIG_PAX_ASLR
70414 + unsigned long delta_mmap; /* randomized offset */
70415 + unsigned long delta_stack; /* randomized offset */
70416 +#endif
70417 +
70418 };
70419
70420 /* first nid will either be a valid NID or one of these values */
70421 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70422 index c5d5278..f0b68c8 100644
70423 --- a/include/linux/mmiotrace.h
70424 +++ b/include/linux/mmiotrace.h
70425 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70426 /* Called from ioremap.c */
70427 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70428 void __iomem *addr);
70429 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70430 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70431
70432 /* For anyone to insert markers. Remember trailing newline. */
70433 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70434 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70435 {
70436 }
70437
70438 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70439 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70440 {
70441 }
70442
70443 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70444 index 73b64a3..6562925 100644
70445 --- a/include/linux/mmzone.h
70446 +++ b/include/linux/mmzone.h
70447 @@ -412,7 +412,7 @@ struct zone {
70448 unsigned long flags; /* zone flags, see below */
70449
70450 /* Zone statistics */
70451 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70452 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70453
70454 /*
70455 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70456 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70457 index fed3def..c933f99 100644
70458 --- a/include/linux/mod_devicetable.h
70459 +++ b/include/linux/mod_devicetable.h
70460 @@ -12,7 +12,7 @@
70461 typedef unsigned long kernel_ulong_t;
70462 #endif
70463
70464 -#define PCI_ANY_ID (~0)
70465 +#define PCI_ANY_ID ((__u16)~0)
70466
70467 struct pci_device_id {
70468 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70469 @@ -139,7 +139,7 @@ struct usb_device_id {
70470 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70471 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70472
70473 -#define HID_ANY_ID (~0)
70474 +#define HID_ANY_ID (~0U)
70475 #define HID_BUS_ANY 0xffff
70476 #define HID_GROUP_ANY 0x0000
70477
70478 @@ -498,7 +498,7 @@ struct dmi_system_id {
70479 const char *ident;
70480 struct dmi_strmatch matches[4];
70481 void *driver_data;
70482 -};
70483 +} __do_const;
70484 /*
70485 * struct dmi_device_id appears during expansion of
70486 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70487 diff --git a/include/linux/module.h b/include/linux/module.h
70488 index 1375ee3..ced8177 100644
70489 --- a/include/linux/module.h
70490 +++ b/include/linux/module.h
70491 @@ -17,9 +17,11 @@
70492 #include <linux/moduleparam.h>
70493 #include <linux/tracepoint.h>
70494 #include <linux/export.h>
70495 +#include <linux/fs.h>
70496
70497 #include <linux/percpu.h>
70498 #include <asm/module.h>
70499 +#include <asm/pgtable.h>
70500
70501 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70502 #define MODULE_SIG_STRING "~Module signature appended~\n"
70503 @@ -54,12 +56,13 @@ struct module_attribute {
70504 int (*test)(struct module *);
70505 void (*free)(struct module *);
70506 };
70507 +typedef struct module_attribute __no_const module_attribute_no_const;
70508
70509 struct module_version_attribute {
70510 struct module_attribute mattr;
70511 const char *module_name;
70512 const char *version;
70513 -} __attribute__ ((__aligned__(sizeof(void *))));
70514 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70515
70516 extern ssize_t __modver_version_show(struct module_attribute *,
70517 struct module_kobject *, char *);
70518 @@ -232,7 +235,7 @@ struct module
70519
70520 /* Sysfs stuff. */
70521 struct module_kobject mkobj;
70522 - struct module_attribute *modinfo_attrs;
70523 + module_attribute_no_const *modinfo_attrs;
70524 const char *version;
70525 const char *srcversion;
70526 struct kobject *holders_dir;
70527 @@ -281,19 +284,16 @@ struct module
70528 int (*init)(void);
70529
70530 /* If this is non-NULL, vfree after init() returns */
70531 - void *module_init;
70532 + void *module_init_rx, *module_init_rw;
70533
70534 /* Here is the actual code + data, vfree'd on unload. */
70535 - void *module_core;
70536 + void *module_core_rx, *module_core_rw;
70537
70538 /* Here are the sizes of the init and core sections */
70539 - unsigned int init_size, core_size;
70540 + unsigned int init_size_rw, core_size_rw;
70541
70542 /* The size of the executable code in each section. */
70543 - unsigned int init_text_size, core_text_size;
70544 -
70545 - /* Size of RO sections of the module (text+rodata) */
70546 - unsigned int init_ro_size, core_ro_size;
70547 + unsigned int init_size_rx, core_size_rx;
70548
70549 /* Arch-specific module values */
70550 struct mod_arch_specific arch;
70551 @@ -349,6 +349,10 @@ struct module
70552 #ifdef CONFIG_EVENT_TRACING
70553 struct ftrace_event_call **trace_events;
70554 unsigned int num_trace_events;
70555 + struct file_operations trace_id;
70556 + struct file_operations trace_enable;
70557 + struct file_operations trace_format;
70558 + struct file_operations trace_filter;
70559 #endif
70560 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70561 unsigned int num_ftrace_callsites;
70562 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70563 bool is_module_percpu_address(unsigned long addr);
70564 bool is_module_text_address(unsigned long addr);
70565
70566 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70567 +{
70568 +
70569 +#ifdef CONFIG_PAX_KERNEXEC
70570 + if (ktla_ktva(addr) >= (unsigned long)start &&
70571 + ktla_ktva(addr) < (unsigned long)start + size)
70572 + return 1;
70573 +#endif
70574 +
70575 + return ((void *)addr >= start && (void *)addr < start + size);
70576 +}
70577 +
70578 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
70579 +{
70580 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70581 +}
70582 +
70583 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
70584 +{
70585 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70586 +}
70587 +
70588 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
70589 +{
70590 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70591 +}
70592 +
70593 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
70594 +{
70595 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70596 +}
70597 +
70598 static inline int within_module_core(unsigned long addr, struct module *mod)
70599 {
70600 - return (unsigned long)mod->module_core <= addr &&
70601 - addr < (unsigned long)mod->module_core + mod->core_size;
70602 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70603 }
70604
70605 static inline int within_module_init(unsigned long addr, struct module *mod)
70606 {
70607 - return (unsigned long)mod->module_init <= addr &&
70608 - addr < (unsigned long)mod->module_init + mod->init_size;
70609 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70610 }
70611
70612 /* Search for module by name: must hold module_mutex. */
70613 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70614 index 560ca53..ef621ef 100644
70615 --- a/include/linux/moduleloader.h
70616 +++ b/include/linux/moduleloader.h
70617 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70618 sections. Returns NULL on failure. */
70619 void *module_alloc(unsigned long size);
70620
70621 +#ifdef CONFIG_PAX_KERNEXEC
70622 +void *module_alloc_exec(unsigned long size);
70623 +#else
70624 +#define module_alloc_exec(x) module_alloc(x)
70625 +#endif
70626 +
70627 /* Free memory returned from module_alloc. */
70628 void module_free(struct module *mod, void *module_region);
70629
70630 +#ifdef CONFIG_PAX_KERNEXEC
70631 +void module_free_exec(struct module *mod, void *module_region);
70632 +#else
70633 +#define module_free_exec(x, y) module_free((x), (y))
70634 +#endif
70635 +
70636 /*
70637 * Apply the given relocation to the (simplified) ELF. Return -error
70638 * or 0.
70639 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70640 unsigned int relsec,
70641 struct module *me)
70642 {
70643 +#ifdef CONFIG_MODULES
70644 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70645 +#endif
70646 return -ENOEXEC;
70647 }
70648 #endif
70649 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70650 unsigned int relsec,
70651 struct module *me)
70652 {
70653 +#ifdef CONFIG_MODULES
70654 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70655 +#endif
70656 return -ENOEXEC;
70657 }
70658 #endif
70659 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70660 index 137b419..fe663ec 100644
70661 --- a/include/linux/moduleparam.h
70662 +++ b/include/linux/moduleparam.h
70663 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70664 * @len is usually just sizeof(string).
70665 */
70666 #define module_param_string(name, string, len, perm) \
70667 - static const struct kparam_string __param_string_##name \
70668 + static const struct kparam_string __param_string_##name __used \
70669 = { len, string }; \
70670 __module_param_call(MODULE_PARAM_PREFIX, name, \
70671 &param_ops_string, \
70672 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70673 */
70674 #define module_param_array_named(name, array, type, nump, perm) \
70675 param_check_##type(name, &(array)[0]); \
70676 - static const struct kparam_array __param_arr_##name \
70677 + static const struct kparam_array __param_arr_##name __used \
70678 = { .max = ARRAY_SIZE(array), .num = nump, \
70679 .ops = &param_ops_##type, \
70680 .elemsize = sizeof(array[0]), .elem = array }; \
70681 diff --git a/include/linux/namei.h b/include/linux/namei.h
70682 index 5a5ff57..5ae5070 100644
70683 --- a/include/linux/namei.h
70684 +++ b/include/linux/namei.h
70685 @@ -19,7 +19,7 @@ struct nameidata {
70686 unsigned seq;
70687 int last_type;
70688 unsigned depth;
70689 - char *saved_names[MAX_NESTED_LINKS + 1];
70690 + const char *saved_names[MAX_NESTED_LINKS + 1];
70691 };
70692
70693 /*
70694 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70695
70696 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70697
70698 -static inline void nd_set_link(struct nameidata *nd, char *path)
70699 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70700 {
70701 nd->saved_names[nd->depth] = path;
70702 }
70703
70704 -static inline char *nd_get_link(struct nameidata *nd)
70705 +static inline const char *nd_get_link(const struct nameidata *nd)
70706 {
70707 return nd->saved_names[nd->depth];
70708 }
70709 diff --git a/include/linux/net.h b/include/linux/net.h
70710 index aa16731..514b875 100644
70711 --- a/include/linux/net.h
70712 +++ b/include/linux/net.h
70713 @@ -183,7 +183,7 @@ struct net_proto_family {
70714 int (*create)(struct net *net, struct socket *sock,
70715 int protocol, int kern);
70716 struct module *owner;
70717 -};
70718 +} __do_const;
70719
70720 struct iovec;
70721 struct kvec;
70722 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70723 index 9ef07d0..130a5d9 100644
70724 --- a/include/linux/netdevice.h
70725 +++ b/include/linux/netdevice.h
70726 @@ -1012,6 +1012,7 @@ struct net_device_ops {
70727 u32 pid, u32 seq,
70728 struct net_device *dev);
70729 };
70730 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70731
70732 /*
70733 * The DEVICE structure.
70734 @@ -1078,7 +1079,7 @@ struct net_device {
70735 int iflink;
70736
70737 struct net_device_stats stats;
70738 - atomic_long_t rx_dropped; /* dropped packets by core network
70739 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70740 * Do not use this in drivers.
70741 */
70742
70743 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70744 index ee14284..bc65d63 100644
70745 --- a/include/linux/netfilter.h
70746 +++ b/include/linux/netfilter.h
70747 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70748 #endif
70749 /* Use the module struct to lock set/get code in place */
70750 struct module *owner;
70751 -};
70752 +} __do_const;
70753
70754 /* Function to register/unregister hook points. */
70755 int nf_register_hook(struct nf_hook_ops *reg);
70756 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70757 index 7958e84..ed74d7a 100644
70758 --- a/include/linux/netfilter/ipset/ip_set.h
70759 +++ b/include/linux/netfilter/ipset/ip_set.h
70760 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70761 /* Return true if "b" set is the same as "a"
70762 * according to the create set parameters */
70763 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70764 -};
70765 +} __do_const;
70766
70767 /* The core set type structure */
70768 struct ip_set_type {
70769 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70770 index 4966dde..7d8ce06 100644
70771 --- a/include/linux/netfilter/nfnetlink.h
70772 +++ b/include/linux/netfilter/nfnetlink.h
70773 @@ -16,7 +16,7 @@ struct nfnl_callback {
70774 const struct nlattr * const cda[]);
70775 const struct nla_policy *policy; /* netlink attribute policy */
70776 const u_int16_t attr_count; /* number of nlattr's */
70777 -};
70778 +} __do_const;
70779
70780 struct nfnetlink_subsystem {
70781 const char *name;
70782 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70783 new file mode 100644
70784 index 0000000..33f4af8
70785 --- /dev/null
70786 +++ b/include/linux/netfilter/xt_gradm.h
70787 @@ -0,0 +1,9 @@
70788 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70789 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70790 +
70791 +struct xt_gradm_mtinfo {
70792 + __u16 flags;
70793 + __u16 invflags;
70794 +};
70795 +
70796 +#endif
70797 diff --git a/include/linux/nls.h b/include/linux/nls.h
70798 index 5dc635f..35f5e11 100644
70799 --- a/include/linux/nls.h
70800 +++ b/include/linux/nls.h
70801 @@ -31,7 +31,7 @@ struct nls_table {
70802 const unsigned char *charset2upper;
70803 struct module *owner;
70804 struct nls_table *next;
70805 -};
70806 +} __do_const;
70807
70808 /* this value hold the maximum octet of charset */
70809 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70810 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70811 index d65746e..62e72c2 100644
70812 --- a/include/linux/notifier.h
70813 +++ b/include/linux/notifier.h
70814 @@ -51,7 +51,8 @@ struct notifier_block {
70815 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70816 struct notifier_block __rcu *next;
70817 int priority;
70818 -};
70819 +} __do_const;
70820 +typedef struct notifier_block __no_const notifier_block_no_const;
70821
70822 struct atomic_notifier_head {
70823 spinlock_t lock;
70824 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70825 index a4c5624..79d6d88 100644
70826 --- a/include/linux/oprofile.h
70827 +++ b/include/linux/oprofile.h
70828 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70829 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70830 char const * name, ulong * val);
70831
70832 -/** Create a file for read-only access to an atomic_t. */
70833 +/** Create a file for read-only access to an atomic_unchecked_t. */
70834 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70835 - char const * name, atomic_t * val);
70836 + char const * name, atomic_unchecked_t * val);
70837
70838 /** create a directory */
70839 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70840 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70841 index 45fc162..01a4068 100644
70842 --- a/include/linux/pci_hotplug.h
70843 +++ b/include/linux/pci_hotplug.h
70844 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70845 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70846 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70847 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70848 -};
70849 +} __do_const;
70850 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70851
70852 /**
70853 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70854 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70855 index a280650..2b67b91 100644
70856 --- a/include/linux/perf_event.h
70857 +++ b/include/linux/perf_event.h
70858 @@ -328,8 +328,8 @@ struct perf_event {
70859
70860 enum perf_event_active_state state;
70861 unsigned int attach_state;
70862 - local64_t count;
70863 - atomic64_t child_count;
70864 + local64_t count; /* PaX: fix it one day */
70865 + atomic64_unchecked_t child_count;
70866
70867 /*
70868 * These are the total time in nanoseconds that the event
70869 @@ -380,8 +380,8 @@ struct perf_event {
70870 * These accumulate total time (in nanoseconds) that children
70871 * events have been enabled and running, respectively.
70872 */
70873 - atomic64_t child_total_time_enabled;
70874 - atomic64_t child_total_time_running;
70875 + atomic64_unchecked_t child_total_time_enabled;
70876 + atomic64_unchecked_t child_total_time_running;
70877
70878 /*
70879 * Protect attach/detach and child_list:
70880 @@ -807,7 +807,7 @@ static inline void perf_restore_debug_store(void) { }
70881 */
70882 #define perf_cpu_notifier(fn) \
70883 do { \
70884 - static struct notifier_block fn##_nb __cpuinitdata = \
70885 + static struct notifier_block fn##_nb = \
70886 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70887 unsigned long cpu = smp_processor_id(); \
70888 unsigned long flags; \
70889 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70890 index ad1a427..6419649 100644
70891 --- a/include/linux/pipe_fs_i.h
70892 +++ b/include/linux/pipe_fs_i.h
70893 @@ -45,9 +45,9 @@ struct pipe_buffer {
70894 struct pipe_inode_info {
70895 wait_queue_head_t wait;
70896 unsigned int nrbufs, curbuf, buffers;
70897 - unsigned int readers;
70898 - unsigned int writers;
70899 - unsigned int waiting_writers;
70900 + atomic_t readers;
70901 + atomic_t writers;
70902 + atomic_t waiting_writers;
70903 unsigned int r_counter;
70904 unsigned int w_counter;
70905 struct page *tmp_page;
70906 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
70907 index 5f28cae..3d23723 100644
70908 --- a/include/linux/platform_data/usb-ehci-s5p.h
70909 +++ b/include/linux/platform_data/usb-ehci-s5p.h
70910 @@ -14,7 +14,7 @@
70911 struct s5p_ehci_platdata {
70912 int (*phy_init)(struct platform_device *pdev, int type);
70913 int (*phy_exit)(struct platform_device *pdev, int type);
70914 -};
70915 +} __no_const;
70916
70917 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
70918
70919 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
70920 index c256c59..8ea94c7 100644
70921 --- a/include/linux/platform_data/usb-exynos.h
70922 +++ b/include/linux/platform_data/usb-exynos.h
70923 @@ -14,7 +14,7 @@
70924 struct exynos4_ohci_platdata {
70925 int (*phy_init)(struct platform_device *pdev, int type);
70926 int (*phy_exit)(struct platform_device *pdev, int type);
70927 -};
70928 +} __no_const;
70929
70930 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70931
70932 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70933 index 7c1d252..c5c773e 100644
70934 --- a/include/linux/pm_domain.h
70935 +++ b/include/linux/pm_domain.h
70936 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70937
70938 struct gpd_cpu_data {
70939 unsigned int saved_exit_latency;
70940 - struct cpuidle_state *idle_state;
70941 + cpuidle_state_no_const *idle_state;
70942 };
70943
70944 struct generic_pm_domain {
70945 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
70946 index f271860..6b3bec5 100644
70947 --- a/include/linux/pm_runtime.h
70948 +++ b/include/linux/pm_runtime.h
70949 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
70950
70951 static inline void pm_runtime_mark_last_busy(struct device *dev)
70952 {
70953 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
70954 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
70955 }
70956
70957 #else /* !CONFIG_PM_RUNTIME */
70958 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
70959 index 195aafc..49a7bc2 100644
70960 --- a/include/linux/pnp.h
70961 +++ b/include/linux/pnp.h
70962 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
70963 struct pnp_fixup {
70964 char id[7];
70965 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
70966 -};
70967 +} __do_const;
70968
70969 /* config parameters */
70970 #define PNP_CONFIG_NORMAL 0x0001
70971 diff --git a/include/linux/poison.h b/include/linux/poison.h
70972 index 2110a81..13a11bb 100644
70973 --- a/include/linux/poison.h
70974 +++ b/include/linux/poison.h
70975 @@ -19,8 +19,8 @@
70976 * under normal circumstances, used to verify that nobody uses
70977 * non-initialized list entries.
70978 */
70979 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70980 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70981 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70982 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70983
70984 /********** include/linux/timer.h **********/
70985 /*
70986 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
70987 index c0f44c2..1572583 100644
70988 --- a/include/linux/power/smartreflex.h
70989 +++ b/include/linux/power/smartreflex.h
70990 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
70991 int (*notify)(struct omap_sr *sr, u32 status);
70992 u8 notify_flags;
70993 u8 class_type;
70994 -};
70995 +} __do_const;
70996
70997 /**
70998 * struct omap_sr_nvalue_table - Smartreflex n-target value info
70999 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71000 index 4ea1d37..80f4b33 100644
71001 --- a/include/linux/ppp-comp.h
71002 +++ b/include/linux/ppp-comp.h
71003 @@ -84,7 +84,7 @@ struct compressor {
71004 struct module *owner;
71005 /* Extra skb space needed by the compressor algorithm */
71006 unsigned int comp_extra;
71007 -};
71008 +} __do_const;
71009
71010 /*
71011 * The return value from decompress routine is the length of the
71012 diff --git a/include/linux/printk.h b/include/linux/printk.h
71013 index 9afc01e..92c32e8 100644
71014 --- a/include/linux/printk.h
71015 +++ b/include/linux/printk.h
71016 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
71017 extern int printk_needs_cpu(int cpu);
71018 extern void printk_tick(void);
71019
71020 +extern int kptr_restrict;
71021 +
71022 #ifdef CONFIG_PRINTK
71023 asmlinkage __printf(5, 0)
71024 int vprintk_emit(int facility, int level,
71025 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71026
71027 extern int printk_delay_msec;
71028 extern int dmesg_restrict;
71029 -extern int kptr_restrict;
71030
71031 void log_buf_kexec_setup(void);
71032 void __init setup_log_buf(int early);
71033 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71034 index 32676b3..e46f2c0 100644
71035 --- a/include/linux/proc_fs.h
71036 +++ b/include/linux/proc_fs.h
71037 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
71038 return proc_create_data(name, mode, parent, proc_fops, NULL);
71039 }
71040
71041 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71042 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71043 +{
71044 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71045 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71046 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71047 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71048 +#else
71049 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71050 +#endif
71051 +}
71052 +
71053 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
71054 umode_t mode, struct proc_dir_entry *base,
71055 read_proc_t *read_proc, void * data)
71056 @@ -268,7 +280,7 @@ struct proc_ns_operations {
71057 void (*put)(void *ns);
71058 int (*install)(struct nsproxy *nsproxy, void *ns);
71059 unsigned int (*inum)(void *ns);
71060 -};
71061 +} __do_const;
71062 extern const struct proc_ns_operations netns_operations;
71063 extern const struct proc_ns_operations utsns_operations;
71064 extern const struct proc_ns_operations ipcns_operations;
71065 diff --git a/include/linux/random.h b/include/linux/random.h
71066 index d984608..d6f0042 100644
71067 --- a/include/linux/random.h
71068 +++ b/include/linux/random.h
71069 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
71070 u32 prandom_u32_state(struct rnd_state *);
71071 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71072
71073 +static inline unsigned long pax_get_random_long(void)
71074 +{
71075 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71076 +}
71077 +
71078 /*
71079 * Handle minimum values for seeds
71080 */
71081 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71082 index c92dd28..08f4eab 100644
71083 --- a/include/linux/rculist.h
71084 +++ b/include/linux/rculist.h
71085 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71086 struct list_head *prev, struct list_head *next);
71087 #endif
71088
71089 +extern void __pax_list_add_rcu(struct list_head *new,
71090 + struct list_head *prev, struct list_head *next);
71091 +
71092 /**
71093 * list_add_rcu - add a new entry to rcu-protected list
71094 * @new: new entry to be added
71095 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71096 __list_add_rcu(new, head, head->next);
71097 }
71098
71099 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71100 +{
71101 + __pax_list_add_rcu(new, head, head->next);
71102 +}
71103 +
71104 /**
71105 * list_add_tail_rcu - add a new entry to rcu-protected list
71106 * @new: new entry to be added
71107 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71108 __list_add_rcu(new, head->prev, head);
71109 }
71110
71111 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71112 + struct list_head *head)
71113 +{
71114 + __pax_list_add_rcu(new, head->prev, head);
71115 +}
71116 +
71117 /**
71118 * list_del_rcu - deletes entry from list without re-initialization
71119 * @entry: the element to delete from the list.
71120 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71121 entry->prev = LIST_POISON2;
71122 }
71123
71124 +extern void pax_list_del_rcu(struct list_head *entry);
71125 +
71126 /**
71127 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71128 * @n: the element to delete from the hash list.
71129 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71130 index 23b3630..e1bc12b 100644
71131 --- a/include/linux/reboot.h
71132 +++ b/include/linux/reboot.h
71133 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71134 * Architecture-specific implementations of sys_reboot commands.
71135 */
71136
71137 -extern void machine_restart(char *cmd);
71138 -extern void machine_halt(void);
71139 -extern void machine_power_off(void);
71140 +extern void machine_restart(char *cmd) __noreturn;
71141 +extern void machine_halt(void) __noreturn;
71142 +extern void machine_power_off(void) __noreturn;
71143
71144 extern void machine_shutdown(void);
71145 struct pt_regs;
71146 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71147 */
71148
71149 extern void kernel_restart_prepare(char *cmd);
71150 -extern void kernel_restart(char *cmd);
71151 -extern void kernel_halt(void);
71152 -extern void kernel_power_off(void);
71153 +extern void kernel_restart(char *cmd) __noreturn;
71154 +extern void kernel_halt(void) __noreturn;
71155 +extern void kernel_power_off(void) __noreturn;
71156
71157 extern int C_A_D; /* for sysctl */
71158 void ctrl_alt_del(void);
71159 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71160 * Emergency restart, callable from an interrupt handler.
71161 */
71162
71163 -extern void emergency_restart(void);
71164 +extern void emergency_restart(void) __noreturn;
71165 #include <asm/emergency-restart.h>
71166
71167 #endif /* _LINUX_REBOOT_H */
71168 diff --git a/include/linux/regset.h b/include/linux/regset.h
71169 index 8e0c9fe..ac4d221 100644
71170 --- a/include/linux/regset.h
71171 +++ b/include/linux/regset.h
71172 @@ -161,7 +161,8 @@ struct user_regset {
71173 unsigned int align;
71174 unsigned int bias;
71175 unsigned int core_note_type;
71176 -};
71177 +} __do_const;
71178 +typedef struct user_regset __no_const user_regset_no_const;
71179
71180 /**
71181 * struct user_regset_view - available regsets
71182 diff --git a/include/linux/relay.h b/include/linux/relay.h
71183 index 91cacc3..b55ff74 100644
71184 --- a/include/linux/relay.h
71185 +++ b/include/linux/relay.h
71186 @@ -160,7 +160,7 @@ struct rchan_callbacks
71187 * The callback should return 0 if successful, negative if not.
71188 */
71189 int (*remove_buf_file)(struct dentry *dentry);
71190 -};
71191 +} __no_const;
71192
71193 /*
71194 * CONFIG_RELAY kernel API, kernel/relay.c
71195 diff --git a/include/linux/rio.h b/include/linux/rio.h
71196 index a3e7842..d973ca6 100644
71197 --- a/include/linux/rio.h
71198 +++ b/include/linux/rio.h
71199 @@ -339,7 +339,7 @@ struct rio_ops {
71200 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71201 u64 rstart, u32 size, u32 flags);
71202 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71203 -};
71204 +} __no_const;
71205
71206 #define RIO_RESOURCE_MEM 0x00000100
71207 #define RIO_RESOURCE_DOORBELL 0x00000200
71208 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71209 index c20635c..2f5def4 100644
71210 --- a/include/linux/rmap.h
71211 +++ b/include/linux/rmap.h
71212 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71213 void anon_vma_init(void); /* create anon_vma_cachep */
71214 int anon_vma_prepare(struct vm_area_struct *);
71215 void unlink_anon_vmas(struct vm_area_struct *);
71216 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71217 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71218 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71219 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71220
71221 static inline void anon_vma_merge(struct vm_area_struct *vma,
71222 struct vm_area_struct *next)
71223 diff --git a/include/linux/sched.h b/include/linux/sched.h
71224 index d211247..eac6c2c 100644
71225 --- a/include/linux/sched.h
71226 +++ b/include/linux/sched.h
71227 @@ -61,6 +61,7 @@ struct bio_list;
71228 struct fs_struct;
71229 struct perf_event_context;
71230 struct blk_plug;
71231 +struct linux_binprm;
71232
71233 /*
71234 * List of flags we want to share for kernel threads,
71235 @@ -327,7 +328,7 @@ extern char __sched_text_start[], __sched_text_end[];
71236 extern int in_sched_functions(unsigned long addr);
71237
71238 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71239 -extern signed long schedule_timeout(signed long timeout);
71240 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71241 extern signed long schedule_timeout_interruptible(signed long timeout);
71242 extern signed long schedule_timeout_killable(signed long timeout);
71243 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71244 @@ -354,10 +355,23 @@ struct user_namespace;
71245 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71246
71247 extern int sysctl_max_map_count;
71248 +extern unsigned long sysctl_heap_stack_gap;
71249
71250 #include <linux/aio.h>
71251
71252 #ifdef CONFIG_MMU
71253 +
71254 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71255 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71256 +#else
71257 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71258 +{
71259 + return 0;
71260 +}
71261 +#endif
71262 +
71263 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71264 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71265 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71266 extern unsigned long
71267 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71268 @@ -639,6 +653,17 @@ struct signal_struct {
71269 #ifdef CONFIG_TASKSTATS
71270 struct taskstats *stats;
71271 #endif
71272 +
71273 +#ifdef CONFIG_GRKERNSEC
71274 + u32 curr_ip;
71275 + u32 saved_ip;
71276 + u32 gr_saddr;
71277 + u32 gr_daddr;
71278 + u16 gr_sport;
71279 + u16 gr_dport;
71280 + u8 used_accept:1;
71281 +#endif
71282 +
71283 #ifdef CONFIG_AUDIT
71284 unsigned audit_tty;
71285 struct tty_audit_buf *tty_audit_buf;
71286 @@ -717,6 +742,11 @@ struct user_struct {
71287 struct key *session_keyring; /* UID's default session keyring */
71288 #endif
71289
71290 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
71291 + unsigned int banned;
71292 + unsigned long ban_expires;
71293 +#endif
71294 +
71295 /* Hash table maintenance information */
71296 struct hlist_node uidhash_node;
71297 kuid_t uid;
71298 @@ -1116,7 +1146,7 @@ struct sched_class {
71299 #ifdef CONFIG_FAIR_GROUP_SCHED
71300 void (*task_move_group) (struct task_struct *p, int on_rq);
71301 #endif
71302 -};
71303 +} __do_const;
71304
71305 struct load_weight {
71306 unsigned long weight, inv_weight;
71307 @@ -1360,8 +1390,8 @@ struct task_struct {
71308 struct list_head thread_group;
71309
71310 struct completion *vfork_done; /* for vfork() */
71311 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71312 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71313 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71314 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71315
71316 cputime_t utime, stime, utimescaled, stimescaled;
71317 cputime_t gtime;
71318 @@ -1377,11 +1407,6 @@ struct task_struct {
71319 struct task_cputime cputime_expires;
71320 struct list_head cpu_timers[3];
71321
71322 -/* process credentials */
71323 - const struct cred __rcu *real_cred; /* objective and real subjective task
71324 - * credentials (COW) */
71325 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71326 - * credentials (COW) */
71327 char comm[TASK_COMM_LEN]; /* executable name excluding path
71328 - access with [gs]et_task_comm (which lock
71329 it with task_lock())
71330 @@ -1398,6 +1423,10 @@ struct task_struct {
71331 #endif
71332 /* CPU-specific state of this task */
71333 struct thread_struct thread;
71334 +/* thread_info moved to task_struct */
71335 +#ifdef CONFIG_X86
71336 + struct thread_info tinfo;
71337 +#endif
71338 /* filesystem information */
71339 struct fs_struct *fs;
71340 /* open file information */
71341 @@ -1471,6 +1500,10 @@ struct task_struct {
71342 gfp_t lockdep_reclaim_gfp;
71343 #endif
71344
71345 +/* process credentials */
71346 + const struct cred __rcu *real_cred; /* objective and real subjective task
71347 + * credentials (COW) */
71348 +
71349 /* journalling filesystem info */
71350 void *journal_info;
71351
71352 @@ -1509,6 +1542,10 @@ struct task_struct {
71353 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71354 struct list_head cg_list;
71355 #endif
71356 +
71357 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71358 + * credentials (COW) */
71359 +
71360 #ifdef CONFIG_FUTEX
71361 struct robust_list_head __user *robust_list;
71362 #ifdef CONFIG_COMPAT
71363 @@ -1605,8 +1642,74 @@ struct task_struct {
71364 #ifdef CONFIG_UPROBES
71365 struct uprobe_task *utask;
71366 #endif
71367 +
71368 +#ifdef CONFIG_GRKERNSEC
71369 + /* grsecurity */
71370 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71371 + u64 exec_id;
71372 +#endif
71373 +#ifdef CONFIG_GRKERNSEC_SETXID
71374 + const struct cred *delayed_cred;
71375 +#endif
71376 + struct dentry *gr_chroot_dentry;
71377 + struct acl_subject_label *acl;
71378 + struct acl_role_label *role;
71379 + struct file *exec_file;
71380 + unsigned long brute_expires;
71381 + u16 acl_role_id;
71382 + /* is this the task that authenticated to the special role */
71383 + u8 acl_sp_role;
71384 + u8 is_writable;
71385 + u8 brute;
71386 + u8 gr_is_chrooted;
71387 +#endif
71388 +
71389 };
71390
71391 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71392 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71393 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71394 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71395 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71396 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71397 +
71398 +#ifdef CONFIG_PAX_SOFTMODE
71399 +extern int pax_softmode;
71400 +#endif
71401 +
71402 +extern int pax_check_flags(unsigned long *);
71403 +
71404 +/* if tsk != current then task_lock must be held on it */
71405 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71406 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71407 +{
71408 + if (likely(tsk->mm))
71409 + return tsk->mm->pax_flags;
71410 + else
71411 + return 0UL;
71412 +}
71413 +
71414 +/* if tsk != current then task_lock must be held on it */
71415 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71416 +{
71417 + if (likely(tsk->mm)) {
71418 + tsk->mm->pax_flags = flags;
71419 + return 0;
71420 + }
71421 + return -EINVAL;
71422 +}
71423 +#endif
71424 +
71425 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71426 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71427 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71428 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71429 +#endif
71430 +
71431 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71432 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71433 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71434 +
71435 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71436 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71437
71438 @@ -1696,7 +1799,7 @@ struct pid_namespace;
71439 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71440 struct pid_namespace *ns);
71441
71442 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71443 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71444 {
71445 return tsk->pid;
71446 }
71447 @@ -2155,7 +2258,9 @@ void yield(void);
71448 extern struct exec_domain default_exec_domain;
71449
71450 union thread_union {
71451 +#ifndef CONFIG_X86
71452 struct thread_info thread_info;
71453 +#endif
71454 unsigned long stack[THREAD_SIZE/sizeof(long)];
71455 };
71456
71457 @@ -2188,6 +2293,7 @@ extern struct pid_namespace init_pid_ns;
71458 */
71459
71460 extern struct task_struct *find_task_by_vpid(pid_t nr);
71461 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71462 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71463 struct pid_namespace *ns);
71464
71465 @@ -2344,7 +2450,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71466 extern void exit_itimers(struct signal_struct *);
71467 extern void flush_itimer_signals(void);
71468
71469 -extern void do_group_exit(int);
71470 +extern __noreturn void do_group_exit(int);
71471
71472 extern int allow_signal(int);
71473 extern int disallow_signal(int);
71474 @@ -2545,9 +2651,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71475
71476 #endif
71477
71478 -static inline int object_is_on_stack(void *obj)
71479 +static inline int object_starts_on_stack(void *obj)
71480 {
71481 - void *stack = task_stack_page(current);
71482 + const void *stack = task_stack_page(current);
71483
71484 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71485 }
71486 diff --git a/include/linux/security.h b/include/linux/security.h
71487 index eee7478..290f7ba 100644
71488 --- a/include/linux/security.h
71489 +++ b/include/linux/security.h
71490 @@ -26,6 +26,7 @@
71491 #include <linux/capability.h>
71492 #include <linux/slab.h>
71493 #include <linux/err.h>
71494 +#include <linux/grsecurity.h>
71495
71496 struct linux_binprm;
71497 struct cred;
71498 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71499 index 68a04a3..866e6a1 100644
71500 --- a/include/linux/seq_file.h
71501 +++ b/include/linux/seq_file.h
71502 @@ -26,6 +26,9 @@ struct seq_file {
71503 struct mutex lock;
71504 const struct seq_operations *op;
71505 int poll_event;
71506 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71507 + u64 exec_id;
71508 +#endif
71509 #ifdef CONFIG_USER_NS
71510 struct user_namespace *user_ns;
71511 #endif
71512 @@ -38,6 +41,7 @@ struct seq_operations {
71513 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71514 int (*show) (struct seq_file *m, void *v);
71515 };
71516 +typedef struct seq_operations __no_const seq_operations_no_const;
71517
71518 #define SEQ_SKIP 1
71519
71520 diff --git a/include/linux/shm.h b/include/linux/shm.h
71521 index 429c199..4d42e38 100644
71522 --- a/include/linux/shm.h
71523 +++ b/include/linux/shm.h
71524 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71525
71526 /* The task created the shm object. NULL if the task is dead. */
71527 struct task_struct *shm_creator;
71528 +#ifdef CONFIG_GRKERNSEC
71529 + time_t shm_createtime;
71530 + pid_t shm_lapid;
71531 +#endif
71532 };
71533
71534 /* shm_mode upper byte flags */
71535 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71536 index 98399e2..7c74c41 100644
71537 --- a/include/linux/skbuff.h
71538 +++ b/include/linux/skbuff.h
71539 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71540 extern struct sk_buff *__alloc_skb(unsigned int size,
71541 gfp_t priority, int flags, int node);
71542 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71543 -static inline struct sk_buff *alloc_skb(unsigned int size,
71544 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71545 gfp_t priority)
71546 {
71547 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71548 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71549 */
71550 static inline int skb_queue_empty(const struct sk_buff_head *list)
71551 {
71552 - return list->next == (struct sk_buff *)list;
71553 + return list->next == (const struct sk_buff *)list;
71554 }
71555
71556 /**
71557 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71558 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71559 const struct sk_buff *skb)
71560 {
71561 - return skb->next == (struct sk_buff *)list;
71562 + return skb->next == (const struct sk_buff *)list;
71563 }
71564
71565 /**
71566 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71567 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71568 const struct sk_buff *skb)
71569 {
71570 - return skb->prev == (struct sk_buff *)list;
71571 + return skb->prev == (const struct sk_buff *)list;
71572 }
71573
71574 /**
71575 @@ -1727,7 +1727,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71576 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71577 */
71578 #ifndef NET_SKB_PAD
71579 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71580 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71581 #endif
71582
71583 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71584 @@ -2305,7 +2305,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71585 int noblock, int *err);
71586 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71587 struct poll_table_struct *wait);
71588 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71589 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71590 int offset, struct iovec *to,
71591 int size);
71592 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71593 @@ -2595,6 +2595,9 @@ static inline void nf_reset(struct sk_buff *skb)
71594 nf_bridge_put(skb->nf_bridge);
71595 skb->nf_bridge = NULL;
71596 #endif
71597 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71598 + skb->nf_trace = 0;
71599 +#endif
71600 }
71601
71602 /* Note: This doesn't put any conntrack and bridge info in dst. */
71603 diff --git a/include/linux/slab.h b/include/linux/slab.h
71604 index 5d168d7..720bff3 100644
71605 --- a/include/linux/slab.h
71606 +++ b/include/linux/slab.h
71607 @@ -12,13 +12,20 @@
71608 #include <linux/gfp.h>
71609 #include <linux/types.h>
71610 #include <linux/workqueue.h>
71611 -
71612 +#include <linux/err.h>
71613
71614 /*
71615 * Flags to pass to kmem_cache_create().
71616 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71617 */
71618 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71619 +
71620 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71621 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71622 +#else
71623 +#define SLAB_USERCOPY 0x00000000UL
71624 +#endif
71625 +
71626 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71627 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71628 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71629 @@ -89,10 +96,13 @@
71630 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71631 * Both make kfree a no-op.
71632 */
71633 -#define ZERO_SIZE_PTR ((void *)16)
71634 +#define ZERO_SIZE_PTR \
71635 +({ \
71636 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71637 + (void *)(-MAX_ERRNO-1L); \
71638 +})
71639
71640 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71641 - (unsigned long)ZERO_SIZE_PTR)
71642 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71643
71644 /*
71645 * Common fields provided in kmem_cache by all slab allocators
71646 @@ -112,7 +122,7 @@ struct kmem_cache {
71647 unsigned int align; /* Alignment as calculated */
71648 unsigned long flags; /* Active flags on the slab */
71649 const char *name; /* Slab name for sysfs */
71650 - int refcount; /* Use counter */
71651 + atomic_t refcount; /* Use counter */
71652 void (*ctor)(void *); /* Called on object slot creation */
71653 struct list_head list; /* List of all slab caches on the system */
71654 };
71655 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71656 void kfree(const void *);
71657 void kzfree(const void *);
71658 size_t ksize(const void *);
71659 +const char *check_heap_object(const void *ptr, unsigned long n);
71660 +bool is_usercopy_object(const void *ptr);
71661
71662 /*
71663 * Allocator specific definitions. These are mainly used to establish optimized
71664 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71665 * for general use, and so are not documented here. For a full list of
71666 * potential flags, always refer to linux/gfp.h.
71667 */
71668 +
71669 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71670 {
71671 if (size != 0 && n > SIZE_MAX / size)
71672 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71673 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71674 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71675 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71676 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71677 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71678 #define kmalloc_track_caller(size, flags) \
71679 __kmalloc_track_caller(size, flags, _RET_IP_)
71680 #else
71681 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71682 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71683 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71684 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71685 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71686 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71687 #define kmalloc_node_track_caller(size, flags, node) \
71688 __kmalloc_node_track_caller(size, flags, node, \
71689 _RET_IP_)
71690 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71691 index 8bb6e0e..8eb0dbe 100644
71692 --- a/include/linux/slab_def.h
71693 +++ b/include/linux/slab_def.h
71694 @@ -52,7 +52,7 @@ struct kmem_cache {
71695 /* 4) cache creation/removal */
71696 const char *name;
71697 struct list_head list;
71698 - int refcount;
71699 + atomic_t refcount;
71700 int object_size;
71701 int align;
71702
71703 @@ -68,10 +68,10 @@ struct kmem_cache {
71704 unsigned long node_allocs;
71705 unsigned long node_frees;
71706 unsigned long node_overflow;
71707 - atomic_t allochit;
71708 - atomic_t allocmiss;
71709 - atomic_t freehit;
71710 - atomic_t freemiss;
71711 + atomic_unchecked_t allochit;
71712 + atomic_unchecked_t allocmiss;
71713 + atomic_unchecked_t freehit;
71714 + atomic_unchecked_t freemiss;
71715
71716 /*
71717 * If debugging is enabled, then the allocator can add additional
71718 @@ -111,11 +111,16 @@ struct cache_sizes {
71719 #ifdef CONFIG_ZONE_DMA
71720 struct kmem_cache *cs_dmacachep;
71721 #endif
71722 +
71723 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71724 + struct kmem_cache *cs_usercopycachep;
71725 +#endif
71726 +
71727 };
71728 extern struct cache_sizes malloc_sizes[];
71729
71730 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71731 -void *__kmalloc(size_t size, gfp_t flags);
71732 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71733
71734 #ifdef CONFIG_TRACING
71735 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71736 @@ -152,6 +157,13 @@ found:
71737 cachep = malloc_sizes[i].cs_dmacachep;
71738 else
71739 #endif
71740 +
71741 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71742 + if (flags & GFP_USERCOPY)
71743 + cachep = malloc_sizes[i].cs_usercopycachep;
71744 + else
71745 +#endif
71746 +
71747 cachep = malloc_sizes[i].cs_cachep;
71748
71749 ret = kmem_cache_alloc_trace(cachep, flags, size);
71750 @@ -162,7 +174,7 @@ found:
71751 }
71752
71753 #ifdef CONFIG_NUMA
71754 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71755 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71756 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71757
71758 #ifdef CONFIG_TRACING
71759 @@ -205,6 +217,13 @@ found:
71760 cachep = malloc_sizes[i].cs_dmacachep;
71761 else
71762 #endif
71763 +
71764 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71765 + if (flags & GFP_USERCOPY)
71766 + cachep = malloc_sizes[i].cs_usercopycachep;
71767 + else
71768 +#endif
71769 +
71770 cachep = malloc_sizes[i].cs_cachep;
71771
71772 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71773 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71774 index f28e14a..7831211 100644
71775 --- a/include/linux/slob_def.h
71776 +++ b/include/linux/slob_def.h
71777 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71778 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71779 }
71780
71781 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71782 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71783
71784 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71785 {
71786 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71787 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71788 }
71789
71790 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71791 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71792 {
71793 return kmalloc(size, flags);
71794 }
71795 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71796 index 9db4825..ed42fb5 100644
71797 --- a/include/linux/slub_def.h
71798 +++ b/include/linux/slub_def.h
71799 @@ -91,7 +91,7 @@ struct kmem_cache {
71800 struct kmem_cache_order_objects max;
71801 struct kmem_cache_order_objects min;
71802 gfp_t allocflags; /* gfp flags to use on each alloc */
71803 - int refcount; /* Refcount for slab cache destroy */
71804 + atomic_t refcount; /* Refcount for slab cache destroy */
71805 void (*ctor)(void *);
71806 int inuse; /* Offset to metadata */
71807 int align; /* Alignment */
71808 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71809 * Sorry that the following has to be that ugly but some versions of GCC
71810 * have trouble with constant propagation and loops.
71811 */
71812 -static __always_inline int kmalloc_index(size_t size)
71813 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71814 {
71815 if (!size)
71816 return 0;
71817 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71818 }
71819
71820 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71821 -void *__kmalloc(size_t size, gfp_t flags);
71822 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71823
71824 static __always_inline void *
71825 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71826 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71827 }
71828 #endif
71829
71830 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71831 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71832 {
71833 unsigned int order = get_order(size);
71834 return kmalloc_order_trace(size, flags, order);
71835 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71836 }
71837
71838 #ifdef CONFIG_NUMA
71839 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71840 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71841 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71842
71843 #ifdef CONFIG_TRACING
71844 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71845 index e8d702e..0a56eb4 100644
71846 --- a/include/linux/sock_diag.h
71847 +++ b/include/linux/sock_diag.h
71848 @@ -10,7 +10,7 @@ struct sock;
71849 struct sock_diag_handler {
71850 __u8 family;
71851 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71852 -};
71853 +} __do_const;
71854
71855 int sock_diag_register(const struct sock_diag_handler *h);
71856 void sock_diag_unregister(const struct sock_diag_handler *h);
71857 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71858 index 680f9a3..f13aeb0 100644
71859 --- a/include/linux/sonet.h
71860 +++ b/include/linux/sonet.h
71861 @@ -7,7 +7,7 @@
71862 #include <uapi/linux/sonet.h>
71863
71864 struct k_sonet_stats {
71865 -#define __HANDLE_ITEM(i) atomic_t i
71866 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71867 __SONET_ITEMS
71868 #undef __HANDLE_ITEM
71869 };
71870 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71871 index 34206b8..3db7f1c 100644
71872 --- a/include/linux/sunrpc/clnt.h
71873 +++ b/include/linux/sunrpc/clnt.h
71874 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71875 unsigned int p_timer; /* Which RTT timer to use */
71876 u32 p_statidx; /* Which procedure to account */
71877 const char * p_name; /* name of procedure */
71878 -};
71879 +} __do_const;
71880
71881 #ifdef __KERNEL__
71882
71883 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71884 {
71885 switch (sap->sa_family) {
71886 case AF_INET:
71887 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
71888 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
71889 case AF_INET6:
71890 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
71891 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
71892 }
71893 return 0;
71894 }
71895 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
71896 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
71897 const struct sockaddr *src)
71898 {
71899 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
71900 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
71901 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
71902
71903 dsin->sin_family = ssin->sin_family;
71904 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
71905 if (sa->sa_family != AF_INET6)
71906 return 0;
71907
71908 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
71909 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
71910 }
71911
71912 #endif /* __KERNEL__ */
71913 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
71914 index 676ddf5..4c519a1 100644
71915 --- a/include/linux/sunrpc/svc.h
71916 +++ b/include/linux/sunrpc/svc.h
71917 @@ -410,7 +410,7 @@ struct svc_procedure {
71918 unsigned int pc_count; /* call count */
71919 unsigned int pc_cachetype; /* cache info (NFS) */
71920 unsigned int pc_xdrressize; /* maximum size of XDR reply */
71921 -};
71922 +} __do_const;
71923
71924 /*
71925 * Function prototypes.
71926 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
71927 index 0b8e3e6..33e0a01 100644
71928 --- a/include/linux/sunrpc/svc_rdma.h
71929 +++ b/include/linux/sunrpc/svc_rdma.h
71930 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
71931 extern unsigned int svcrdma_max_requests;
71932 extern unsigned int svcrdma_max_req_size;
71933
71934 -extern atomic_t rdma_stat_recv;
71935 -extern atomic_t rdma_stat_read;
71936 -extern atomic_t rdma_stat_write;
71937 -extern atomic_t rdma_stat_sq_starve;
71938 -extern atomic_t rdma_stat_rq_starve;
71939 -extern atomic_t rdma_stat_rq_poll;
71940 -extern atomic_t rdma_stat_rq_prod;
71941 -extern atomic_t rdma_stat_sq_poll;
71942 -extern atomic_t rdma_stat_sq_prod;
71943 +extern atomic_unchecked_t rdma_stat_recv;
71944 +extern atomic_unchecked_t rdma_stat_read;
71945 +extern atomic_unchecked_t rdma_stat_write;
71946 +extern atomic_unchecked_t rdma_stat_sq_starve;
71947 +extern atomic_unchecked_t rdma_stat_rq_starve;
71948 +extern atomic_unchecked_t rdma_stat_rq_poll;
71949 +extern atomic_unchecked_t rdma_stat_rq_prod;
71950 +extern atomic_unchecked_t rdma_stat_sq_poll;
71951 +extern atomic_unchecked_t rdma_stat_sq_prod;
71952
71953 #define RPCRDMA_VERSION 1
71954
71955 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
71956 index dd74084a..7f509d5 100644
71957 --- a/include/linux/sunrpc/svcauth.h
71958 +++ b/include/linux/sunrpc/svcauth.h
71959 @@ -109,7 +109,7 @@ struct auth_ops {
71960 int (*release)(struct svc_rqst *rq);
71961 void (*domain_release)(struct auth_domain *);
71962 int (*set_client)(struct svc_rqst *rq);
71963 -};
71964 +} __do_const;
71965
71966 #define SVC_GARBAGE 1
71967 #define SVC_SYSERR 2
71968 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
71969 index 071d62c..4ccc7ac 100644
71970 --- a/include/linux/swiotlb.h
71971 +++ b/include/linux/swiotlb.h
71972 @@ -59,7 +59,8 @@ extern void
71973
71974 extern void
71975 swiotlb_free_coherent(struct device *hwdev, size_t size,
71976 - void *vaddr, dma_addr_t dma_handle);
71977 + void *vaddr, dma_addr_t dma_handle,
71978 + struct dma_attrs *attrs);
71979
71980 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
71981 unsigned long offset, size_t size,
71982 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
71983 index 45e2db2..1635156a 100644
71984 --- a/include/linux/syscalls.h
71985 +++ b/include/linux/syscalls.h
71986 @@ -615,7 +615,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
71987 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
71988 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
71989 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
71990 - struct sockaddr __user *, int);
71991 + struct sockaddr __user *, int) __intentional_overflow(0);
71992 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
71993 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
71994 unsigned int vlen, unsigned flags);
71995 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
71996 index 27b3b0b..e093dd9 100644
71997 --- a/include/linux/syscore_ops.h
71998 +++ b/include/linux/syscore_ops.h
71999 @@ -16,7 +16,7 @@ struct syscore_ops {
72000 int (*suspend)(void);
72001 void (*resume)(void);
72002 void (*shutdown)(void);
72003 -};
72004 +} __do_const;
72005
72006 extern void register_syscore_ops(struct syscore_ops *ops);
72007 extern void unregister_syscore_ops(struct syscore_ops *ops);
72008 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72009 index 14a8ff2..af52bad 100644
72010 --- a/include/linux/sysctl.h
72011 +++ b/include/linux/sysctl.h
72012 @@ -34,13 +34,13 @@ struct ctl_table_root;
72013 struct ctl_table_header;
72014 struct ctl_dir;
72015
72016 -typedef struct ctl_table ctl_table;
72017 -
72018 typedef int proc_handler (struct ctl_table *ctl, int write,
72019 void __user *buffer, size_t *lenp, loff_t *ppos);
72020
72021 extern int proc_dostring(struct ctl_table *, int,
72022 void __user *, size_t *, loff_t *);
72023 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72024 + void __user *, size_t *, loff_t *);
72025 extern int proc_dointvec(struct ctl_table *, int,
72026 void __user *, size_t *, loff_t *);
72027 extern int proc_dointvec_minmax(struct ctl_table *, int,
72028 @@ -115,7 +115,9 @@ struct ctl_table
72029 struct ctl_table_poll *poll;
72030 void *extra1;
72031 void *extra2;
72032 -};
72033 +} __do_const;
72034 +typedef struct ctl_table __no_const ctl_table_no_const;
72035 +typedef struct ctl_table ctl_table;
72036
72037 struct ctl_node {
72038 struct rb_node node;
72039 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72040 index 381f06d..dc16cc7 100644
72041 --- a/include/linux/sysfs.h
72042 +++ b/include/linux/sysfs.h
72043 @@ -31,7 +31,8 @@ struct attribute {
72044 struct lock_class_key *key;
72045 struct lock_class_key skey;
72046 #endif
72047 -};
72048 +} __do_const;
72049 +typedef struct attribute __no_const attribute_no_const;
72050
72051 /**
72052 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72053 @@ -59,8 +60,8 @@ struct attribute_group {
72054 umode_t (*is_visible)(struct kobject *,
72055 struct attribute *, int);
72056 struct attribute **attrs;
72057 -};
72058 -
72059 +} __do_const;
72060 +typedef struct attribute_group __no_const attribute_group_no_const;
72061
72062
72063 /**
72064 @@ -107,7 +108,8 @@ struct bin_attribute {
72065 char *, loff_t, size_t);
72066 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72067 struct vm_area_struct *vma);
72068 -};
72069 +} __do_const;
72070 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72071
72072 /**
72073 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72074 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72075 index 7faf933..9b85a0c 100644
72076 --- a/include/linux/sysrq.h
72077 +++ b/include/linux/sysrq.h
72078 @@ -16,6 +16,7 @@
72079
72080 #include <linux/errno.h>
72081 #include <linux/types.h>
72082 +#include <linux/compiler.h>
72083
72084 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72085 #define SYSRQ_DEFAULT_ENABLE 1
72086 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72087 char *help_msg;
72088 char *action_msg;
72089 int enable_mask;
72090 -};
72091 +} __do_const;
72092
72093 #ifdef CONFIG_MAGIC_SYSRQ
72094
72095 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72096 index e7e0473..7989295 100644
72097 --- a/include/linux/thread_info.h
72098 +++ b/include/linux/thread_info.h
72099 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72100 #error "no set_restore_sigmask() provided and default one won't work"
72101 #endif
72102
72103 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72104 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72105 +{
72106 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72107 + if (!__builtin_constant_p(n))
72108 +#endif
72109 + __check_object_size(ptr, n, to_user);
72110 +}
72111 +
72112 #endif /* __KERNEL__ */
72113
72114 #endif /* _LINUX_THREAD_INFO_H */
72115 diff --git a/include/linux/tty.h b/include/linux/tty.h
72116 index 8db1b56..c16a040 100644
72117 --- a/include/linux/tty.h
72118 +++ b/include/linux/tty.h
72119 @@ -194,7 +194,7 @@ struct tty_port {
72120 const struct tty_port_operations *ops; /* Port operations */
72121 spinlock_t lock; /* Lock protecting tty field */
72122 int blocked_open; /* Waiting to open */
72123 - int count; /* Usage count */
72124 + atomic_t count; /* Usage count */
72125 wait_queue_head_t open_wait; /* Open waiters */
72126 wait_queue_head_t close_wait; /* Close waiters */
72127 wait_queue_head_t delta_msr_wait; /* Modem status change */
72128 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
72129 struct tty_struct *tty, struct file *filp);
72130 static inline int tty_port_users(struct tty_port *port)
72131 {
72132 - return port->count + port->blocked_open;
72133 + return atomic_read(&port->count) + port->blocked_open;
72134 }
72135
72136 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72137 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72138 index dd976cf..e272742 100644
72139 --- a/include/linux/tty_driver.h
72140 +++ b/include/linux/tty_driver.h
72141 @@ -284,7 +284,7 @@ struct tty_operations {
72142 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72143 #endif
72144 const struct file_operations *proc_fops;
72145 -};
72146 +} __do_const;
72147
72148 struct tty_driver {
72149 int magic; /* magic number for this structure */
72150 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72151 index fb79dd8d..07d4773 100644
72152 --- a/include/linux/tty_ldisc.h
72153 +++ b/include/linux/tty_ldisc.h
72154 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
72155
72156 struct module *owner;
72157
72158 - int refcount;
72159 + atomic_t refcount;
72160 };
72161
72162 struct tty_ldisc {
72163 diff --git a/include/linux/types.h b/include/linux/types.h
72164 index 4d118ba..c3ee9bf 100644
72165 --- a/include/linux/types.h
72166 +++ b/include/linux/types.h
72167 @@ -176,10 +176,26 @@ typedef struct {
72168 int counter;
72169 } atomic_t;
72170
72171 +#ifdef CONFIG_PAX_REFCOUNT
72172 +typedef struct {
72173 + int counter;
72174 +} atomic_unchecked_t;
72175 +#else
72176 +typedef atomic_t atomic_unchecked_t;
72177 +#endif
72178 +
72179 #ifdef CONFIG_64BIT
72180 typedef struct {
72181 long counter;
72182 } atomic64_t;
72183 +
72184 +#ifdef CONFIG_PAX_REFCOUNT
72185 +typedef struct {
72186 + long counter;
72187 +} atomic64_unchecked_t;
72188 +#else
72189 +typedef atomic64_t atomic64_unchecked_t;
72190 +#endif
72191 #endif
72192
72193 struct list_head {
72194 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72195 index 5ca0951..ab496a5 100644
72196 --- a/include/linux/uaccess.h
72197 +++ b/include/linux/uaccess.h
72198 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72199 long ret; \
72200 mm_segment_t old_fs = get_fs(); \
72201 \
72202 - set_fs(KERNEL_DS); \
72203 pagefault_disable(); \
72204 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72205 - pagefault_enable(); \
72206 + set_fs(KERNEL_DS); \
72207 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72208 set_fs(old_fs); \
72209 + pagefault_enable(); \
72210 ret; \
72211 })
72212
72213 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72214 index 8e522cbc..aa8572d 100644
72215 --- a/include/linux/uidgid.h
72216 +++ b/include/linux/uidgid.h
72217 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72218
72219 #endif /* CONFIG_USER_NS */
72220
72221 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72222 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72223 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72224 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72225 +
72226 #endif /* _LINUX_UIDGID_H */
72227 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72228 index 99c1b4d..562e6f3 100644
72229 --- a/include/linux/unaligned/access_ok.h
72230 +++ b/include/linux/unaligned/access_ok.h
72231 @@ -4,34 +4,34 @@
72232 #include <linux/kernel.h>
72233 #include <asm/byteorder.h>
72234
72235 -static inline u16 get_unaligned_le16(const void *p)
72236 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72237 {
72238 - return le16_to_cpup((__le16 *)p);
72239 + return le16_to_cpup((const __le16 *)p);
72240 }
72241
72242 -static inline u32 get_unaligned_le32(const void *p)
72243 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72244 {
72245 - return le32_to_cpup((__le32 *)p);
72246 + return le32_to_cpup((const __le32 *)p);
72247 }
72248
72249 -static inline u64 get_unaligned_le64(const void *p)
72250 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72251 {
72252 - return le64_to_cpup((__le64 *)p);
72253 + return le64_to_cpup((const __le64 *)p);
72254 }
72255
72256 -static inline u16 get_unaligned_be16(const void *p)
72257 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72258 {
72259 - return be16_to_cpup((__be16 *)p);
72260 + return be16_to_cpup((const __be16 *)p);
72261 }
72262
72263 -static inline u32 get_unaligned_be32(const void *p)
72264 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72265 {
72266 - return be32_to_cpup((__be32 *)p);
72267 + return be32_to_cpup((const __be32 *)p);
72268 }
72269
72270 -static inline u64 get_unaligned_be64(const void *p)
72271 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72272 {
72273 - return be64_to_cpup((__be64 *)p);
72274 + return be64_to_cpup((const __be64 *)p);
72275 }
72276
72277 static inline void put_unaligned_le16(u16 val, void *p)
72278 diff --git a/include/linux/usb.h b/include/linux/usb.h
72279 index 4d22d0f..8d0e8f8 100644
72280 --- a/include/linux/usb.h
72281 +++ b/include/linux/usb.h
72282 @@ -554,7 +554,7 @@ struct usb_device {
72283 int maxchild;
72284
72285 u32 quirks;
72286 - atomic_t urbnum;
72287 + atomic_unchecked_t urbnum;
72288
72289 unsigned long active_duration;
72290
72291 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72292
72293 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72294 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72295 - void *data, __u16 size, int timeout);
72296 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72297 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72298 void *data, int len, int *actual_length, int timeout);
72299 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72300 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72301 index c5d36c6..108f4f9 100644
72302 --- a/include/linux/usb/renesas_usbhs.h
72303 +++ b/include/linux/usb/renesas_usbhs.h
72304 @@ -39,7 +39,7 @@ enum {
72305 */
72306 struct renesas_usbhs_driver_callback {
72307 int (*notify_hotplug)(struct platform_device *pdev);
72308 -};
72309 +} __no_const;
72310
72311 /*
72312 * callback functions for platform
72313 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
72314 index 5209cfe..b6b215f 100644
72315 --- a/include/linux/user_namespace.h
72316 +++ b/include/linux/user_namespace.h
72317 @@ -21,7 +21,7 @@ struct user_namespace {
72318 struct uid_gid_map uid_map;
72319 struct uid_gid_map gid_map;
72320 struct uid_gid_map projid_map;
72321 - struct kref kref;
72322 + atomic_t count;
72323 struct user_namespace *parent;
72324 kuid_t owner;
72325 kgid_t group;
72326 @@ -37,18 +37,18 @@ extern struct user_namespace init_user_ns;
72327 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
72328 {
72329 if (ns)
72330 - kref_get(&ns->kref);
72331 + atomic_inc(&ns->count);
72332 return ns;
72333 }
72334
72335 extern int create_user_ns(struct cred *new);
72336 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
72337 -extern void free_user_ns(struct kref *kref);
72338 +extern void free_user_ns(struct user_namespace *ns);
72339
72340 static inline void put_user_ns(struct user_namespace *ns)
72341 {
72342 - if (ns)
72343 - kref_put(&ns->kref, free_user_ns);
72344 + if (ns && atomic_dec_and_test(&ns->count))
72345 + free_user_ns(ns);
72346 }
72347
72348 struct seq_operations;
72349 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72350 index 6f8fbcf..8259001 100644
72351 --- a/include/linux/vermagic.h
72352 +++ b/include/linux/vermagic.h
72353 @@ -25,9 +25,35 @@
72354 #define MODULE_ARCH_VERMAGIC ""
72355 #endif
72356
72357 +#ifdef CONFIG_PAX_REFCOUNT
72358 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72359 +#else
72360 +#define MODULE_PAX_REFCOUNT ""
72361 +#endif
72362 +
72363 +#ifdef CONSTIFY_PLUGIN
72364 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72365 +#else
72366 +#define MODULE_CONSTIFY_PLUGIN ""
72367 +#endif
72368 +
72369 +#ifdef STACKLEAK_PLUGIN
72370 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72371 +#else
72372 +#define MODULE_STACKLEAK_PLUGIN ""
72373 +#endif
72374 +
72375 +#ifdef CONFIG_GRKERNSEC
72376 +#define MODULE_GRSEC "GRSEC "
72377 +#else
72378 +#define MODULE_GRSEC ""
72379 +#endif
72380 +
72381 #define VERMAGIC_STRING \
72382 UTS_RELEASE " " \
72383 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72384 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72385 - MODULE_ARCH_VERMAGIC
72386 + MODULE_ARCH_VERMAGIC \
72387 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72388 + MODULE_GRSEC
72389
72390 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72391 index 6071e91..ca6a489 100644
72392 --- a/include/linux/vmalloc.h
72393 +++ b/include/linux/vmalloc.h
72394 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72395 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72396 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72397 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72398 +
72399 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72400 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72401 +#endif
72402 +
72403 /* bits [20..32] reserved for arch specific ioremap internals */
72404
72405 /*
72406 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72407 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72408 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72409 unsigned long start, unsigned long end, gfp_t gfp_mask,
72410 - pgprot_t prot, int node, const void *caller);
72411 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72412 extern void vfree(const void *addr);
72413
72414 extern void *vmap(struct page **pages, unsigned int count,
72415 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72416 extern void free_vm_area(struct vm_struct *area);
72417
72418 /* for /dev/kmem */
72419 -extern long vread(char *buf, char *addr, unsigned long count);
72420 -extern long vwrite(char *buf, char *addr, unsigned long count);
72421 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72422 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72423
72424 /*
72425 * Internals. Dont't use..
72426 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72427 index a13291f..af51fa3 100644
72428 --- a/include/linux/vmstat.h
72429 +++ b/include/linux/vmstat.h
72430 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72431 /*
72432 * Zone based page accounting with per cpu differentials.
72433 */
72434 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72435 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72436
72437 static inline void zone_page_state_add(long x, struct zone *zone,
72438 enum zone_stat_item item)
72439 {
72440 - atomic_long_add(x, &zone->vm_stat[item]);
72441 - atomic_long_add(x, &vm_stat[item]);
72442 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72443 + atomic_long_add_unchecked(x, &vm_stat[item]);
72444 }
72445
72446 static inline unsigned long global_page_state(enum zone_stat_item item)
72447 {
72448 - long x = atomic_long_read(&vm_stat[item]);
72449 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72450 #ifdef CONFIG_SMP
72451 if (x < 0)
72452 x = 0;
72453 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72454 static inline unsigned long zone_page_state(struct zone *zone,
72455 enum zone_stat_item item)
72456 {
72457 - long x = atomic_long_read(&zone->vm_stat[item]);
72458 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72459 #ifdef CONFIG_SMP
72460 if (x < 0)
72461 x = 0;
72462 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72463 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72464 enum zone_stat_item item)
72465 {
72466 - long x = atomic_long_read(&zone->vm_stat[item]);
72467 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72468
72469 #ifdef CONFIG_SMP
72470 int cpu;
72471 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72472
72473 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72474 {
72475 - atomic_long_inc(&zone->vm_stat[item]);
72476 - atomic_long_inc(&vm_stat[item]);
72477 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72478 + atomic_long_inc_unchecked(&vm_stat[item]);
72479 }
72480
72481 static inline void __inc_zone_page_state(struct page *page,
72482 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72483
72484 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72485 {
72486 - atomic_long_dec(&zone->vm_stat[item]);
72487 - atomic_long_dec(&vm_stat[item]);
72488 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72489 + atomic_long_dec_unchecked(&vm_stat[item]);
72490 }
72491
72492 static inline void __dec_zone_page_state(struct page *page,
72493 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72494 index fdbafc6..b7ffd47 100644
72495 --- a/include/linux/xattr.h
72496 +++ b/include/linux/xattr.h
72497 @@ -28,7 +28,7 @@ struct xattr_handler {
72498 size_t size, int handler_flags);
72499 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72500 size_t size, int flags, int handler_flags);
72501 -};
72502 +} __do_const;
72503
72504 struct xattr {
72505 char *name;
72506 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72507 index 9c5a6b4..09c9438 100644
72508 --- a/include/linux/zlib.h
72509 +++ b/include/linux/zlib.h
72510 @@ -31,6 +31,7 @@
72511 #define _ZLIB_H
72512
72513 #include <linux/zconf.h>
72514 +#include <linux/compiler.h>
72515
72516 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72517 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72518 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72519
72520 /* basic functions */
72521
72522 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72523 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72524 /*
72525 Returns the number of bytes that needs to be allocated for a per-
72526 stream workspace with the specified parameters. A pointer to this
72527 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72528 index 95d1c91..6798cca 100644
72529 --- a/include/media/v4l2-dev.h
72530 +++ b/include/media/v4l2-dev.h
72531 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72532 int (*mmap) (struct file *, struct vm_area_struct *);
72533 int (*open) (struct file *);
72534 int (*release) (struct file *);
72535 -};
72536 +} __do_const;
72537
72538 /*
72539 * Newer version of video_device, handled by videodev2.c
72540 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72541 index 4118ad1..cb7e25f 100644
72542 --- a/include/media/v4l2-ioctl.h
72543 +++ b/include/media/v4l2-ioctl.h
72544 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72545 bool valid_prio, int cmd, void *arg);
72546 };
72547
72548 -
72549 /* v4l debugging and diagnostics */
72550
72551 /* Debug bitmask flags to be used on V4L2 */
72552 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72553 index adcbb20..62c2559 100644
72554 --- a/include/net/9p/transport.h
72555 +++ b/include/net/9p/transport.h
72556 @@ -57,7 +57,7 @@ struct p9_trans_module {
72557 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72558 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72559 char *, char *, int , int, int, int);
72560 -};
72561 +} __do_const;
72562
72563 void v9fs_register_trans(struct p9_trans_module *m);
72564 void v9fs_unregister_trans(struct p9_trans_module *m);
72565 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72566 index 7588ef4..e62d35f 100644
72567 --- a/include/net/bluetooth/l2cap.h
72568 +++ b/include/net/bluetooth/l2cap.h
72569 @@ -552,7 +552,7 @@ struct l2cap_ops {
72570 void (*defer) (struct l2cap_chan *chan);
72571 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72572 unsigned long len, int nb);
72573 -};
72574 +} __do_const;
72575
72576 struct l2cap_conn {
72577 struct hci_conn *hcon;
72578 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72579 index 9e5425b..8136ffc 100644
72580 --- a/include/net/caif/cfctrl.h
72581 +++ b/include/net/caif/cfctrl.h
72582 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72583 void (*radioset_rsp)(void);
72584 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72585 struct cflayer *client_layer);
72586 -};
72587 +} __no_const;
72588
72589 /* Link Setup Parameters for CAIF-Links. */
72590 struct cfctrl_link_param {
72591 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72592 struct cfctrl {
72593 struct cfsrvl serv;
72594 struct cfctrl_rsp res;
72595 - atomic_t req_seq_no;
72596 - atomic_t rsp_seq_no;
72597 + atomic_unchecked_t req_seq_no;
72598 + atomic_unchecked_t rsp_seq_no;
72599 struct list_head list;
72600 /* Protects from simultaneous access to first_req list */
72601 spinlock_t info_list_lock;
72602 diff --git a/include/net/flow.h b/include/net/flow.h
72603 index 628e11b..4c475df 100644
72604 --- a/include/net/flow.h
72605 +++ b/include/net/flow.h
72606 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72607
72608 extern void flow_cache_flush(void);
72609 extern void flow_cache_flush_deferred(void);
72610 -extern atomic_t flow_cache_genid;
72611 +extern atomic_unchecked_t flow_cache_genid;
72612
72613 #endif
72614 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72615 index bdfbe68..4402ebe 100644
72616 --- a/include/net/genetlink.h
72617 +++ b/include/net/genetlink.h
72618 @@ -118,7 +118,7 @@ struct genl_ops {
72619 struct netlink_callback *cb);
72620 int (*done)(struct netlink_callback *cb);
72621 struct list_head ops_list;
72622 -};
72623 +} __do_const;
72624
72625 extern int genl_register_family(struct genl_family *family);
72626 extern int genl_register_family_with_ops(struct genl_family *family,
72627 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72628 index e5062c9..48a9a4b 100644
72629 --- a/include/net/gro_cells.h
72630 +++ b/include/net/gro_cells.h
72631 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72632 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72633
72634 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72635 - atomic_long_inc(&dev->rx_dropped);
72636 + atomic_long_inc_unchecked(&dev->rx_dropped);
72637 kfree_skb(skb);
72638 return;
72639 }
72640 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
72641 int i;
72642
72643 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
72644 - gcells->cells = kcalloc(sizeof(struct gro_cell),
72645 - gcells->gro_cells_mask + 1,
72646 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
72647 + sizeof(struct gro_cell),
72648 GFP_KERNEL);
72649 if (!gcells->cells)
72650 return -ENOMEM;
72651 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72652 index 1832927..ce39aea 100644
72653 --- a/include/net/inet_connection_sock.h
72654 +++ b/include/net/inet_connection_sock.h
72655 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72656 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72657 int (*bind_conflict)(const struct sock *sk,
72658 const struct inet_bind_bucket *tb, bool relax);
72659 -};
72660 +} __do_const;
72661
72662 /** inet_connection_sock - INET connection oriented sock
72663 *
72664 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72665 index 53f464d..ba76aaa 100644
72666 --- a/include/net/inetpeer.h
72667 +++ b/include/net/inetpeer.h
72668 @@ -47,8 +47,8 @@ struct inet_peer {
72669 */
72670 union {
72671 struct {
72672 - atomic_t rid; /* Frag reception counter */
72673 - atomic_t ip_id_count; /* IP ID for the next packet */
72674 + atomic_unchecked_t rid; /* Frag reception counter */
72675 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72676 };
72677 struct rcu_head rcu;
72678 struct inet_peer *gc_next;
72679 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72680 more++;
72681 inet_peer_refcheck(p);
72682 do {
72683 - old = atomic_read(&p->ip_id_count);
72684 + old = atomic_read_unchecked(&p->ip_id_count);
72685 new = old + more;
72686 if (!new)
72687 new = 1;
72688 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72689 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72690 return new;
72691 }
72692
72693 diff --git a/include/net/ip.h b/include/net/ip.h
72694 index a68f838..74518ab 100644
72695 --- a/include/net/ip.h
72696 +++ b/include/net/ip.h
72697 @@ -202,7 +202,7 @@ extern struct local_ports {
72698 } sysctl_local_ports;
72699 extern void inet_get_local_port_range(int *low, int *high);
72700
72701 -extern unsigned long *sysctl_local_reserved_ports;
72702 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72703 static inline int inet_is_reserved_local_port(int port)
72704 {
72705 return test_bit(port, sysctl_local_reserved_ports);
72706 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72707 index e49db91..76a81de 100644
72708 --- a/include/net/ip_fib.h
72709 +++ b/include/net/ip_fib.h
72710 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72711
72712 #define FIB_RES_SADDR(net, res) \
72713 ((FIB_RES_NH(res).nh_saddr_genid == \
72714 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72715 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72716 FIB_RES_NH(res).nh_saddr : \
72717 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72718 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72719 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72720 index 68c69d5..bdab192 100644
72721 --- a/include/net/ip_vs.h
72722 +++ b/include/net/ip_vs.h
72723 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72724 struct ip_vs_conn *control; /* Master control connection */
72725 atomic_t n_control; /* Number of controlled ones */
72726 struct ip_vs_dest *dest; /* real server */
72727 - atomic_t in_pkts; /* incoming packet counter */
72728 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72729
72730 /* packet transmitter for different forwarding methods. If it
72731 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72732 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72733 __be16 port; /* port number of the server */
72734 union nf_inet_addr addr; /* IP address of the server */
72735 volatile unsigned int flags; /* dest status flags */
72736 - atomic_t conn_flags; /* flags to copy to conn */
72737 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72738 atomic_t weight; /* server weight */
72739
72740 atomic_t refcnt; /* reference counter */
72741 @@ -980,11 +980,11 @@ struct netns_ipvs {
72742 /* ip_vs_lblc */
72743 int sysctl_lblc_expiration;
72744 struct ctl_table_header *lblc_ctl_header;
72745 - struct ctl_table *lblc_ctl_table;
72746 + ctl_table_no_const *lblc_ctl_table;
72747 /* ip_vs_lblcr */
72748 int sysctl_lblcr_expiration;
72749 struct ctl_table_header *lblcr_ctl_header;
72750 - struct ctl_table *lblcr_ctl_table;
72751 + ctl_table_no_const *lblcr_ctl_table;
72752 /* ip_vs_est */
72753 struct list_head est_list; /* estimator list */
72754 spinlock_t est_lock;
72755 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72756 index 80ffde3..968b0f4 100644
72757 --- a/include/net/irda/ircomm_tty.h
72758 +++ b/include/net/irda/ircomm_tty.h
72759 @@ -35,6 +35,7 @@
72760 #include <linux/termios.h>
72761 #include <linux/timer.h>
72762 #include <linux/tty.h> /* struct tty_struct */
72763 +#include <asm/local.h>
72764
72765 #include <net/irda/irias_object.h>
72766 #include <net/irda/ircomm_core.h>
72767 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72768 index cc7c197..9f2da2a 100644
72769 --- a/include/net/iucv/af_iucv.h
72770 +++ b/include/net/iucv/af_iucv.h
72771 @@ -141,7 +141,7 @@ struct iucv_sock {
72772 struct iucv_sock_list {
72773 struct hlist_head head;
72774 rwlock_t lock;
72775 - atomic_t autobind_name;
72776 + atomic_unchecked_t autobind_name;
72777 };
72778
72779 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72780 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72781 index df83f69..9b640b8 100644
72782 --- a/include/net/llc_c_ac.h
72783 +++ b/include/net/llc_c_ac.h
72784 @@ -87,7 +87,7 @@
72785 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72786 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72787
72788 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72789 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72790
72791 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72792 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72793 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72794 index 6ca3113..f8026dd 100644
72795 --- a/include/net/llc_c_ev.h
72796 +++ b/include/net/llc_c_ev.h
72797 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72798 return (struct llc_conn_state_ev *)skb->cb;
72799 }
72800
72801 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72802 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72803 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72804 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72805
72806 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72807 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72808 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72809 index 0e79cfb..f46db31 100644
72810 --- a/include/net/llc_c_st.h
72811 +++ b/include/net/llc_c_st.h
72812 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72813 u8 next_state;
72814 llc_conn_ev_qfyr_t *ev_qualifiers;
72815 llc_conn_action_t *ev_actions;
72816 -};
72817 +} __do_const;
72818
72819 struct llc_conn_state {
72820 u8 current_state;
72821 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72822 index 37a3bbd..55a4241 100644
72823 --- a/include/net/llc_s_ac.h
72824 +++ b/include/net/llc_s_ac.h
72825 @@ -23,7 +23,7 @@
72826 #define SAP_ACT_TEST_IND 9
72827
72828 /* All action functions must look like this */
72829 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72830 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72831
72832 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72833 struct sk_buff *skb);
72834 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72835 index 567c681..cd73ac0 100644
72836 --- a/include/net/llc_s_st.h
72837 +++ b/include/net/llc_s_st.h
72838 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72839 llc_sap_ev_t ev;
72840 u8 next_state;
72841 llc_sap_action_t *ev_actions;
72842 -};
72843 +} __do_const;
72844
72845 struct llc_sap_state {
72846 u8 curr_state;
72847 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72848 index ee50c5e..1bc3b1a 100644
72849 --- a/include/net/mac80211.h
72850 +++ b/include/net/mac80211.h
72851 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
72852 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72853 struct dentry *dir);
72854 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72855 -};
72856 +} __do_const;
72857
72858 static inline int rate_supported(struct ieee80211_sta *sta,
72859 enum ieee80211_band band,
72860 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72861 index 0dab173..1b76af0 100644
72862 --- a/include/net/neighbour.h
72863 +++ b/include/net/neighbour.h
72864 @@ -123,7 +123,7 @@ struct neigh_ops {
72865 void (*error_report)(struct neighbour *, struct sk_buff *);
72866 int (*output)(struct neighbour *, struct sk_buff *);
72867 int (*connected_output)(struct neighbour *, struct sk_buff *);
72868 -};
72869 +} __do_const;
72870
72871 struct pneigh_entry {
72872 struct pneigh_entry *next;
72873 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72874 index de644bc..dfbcc4c 100644
72875 --- a/include/net/net_namespace.h
72876 +++ b/include/net/net_namespace.h
72877 @@ -115,7 +115,7 @@ struct net {
72878 #endif
72879 struct netns_ipvs *ipvs;
72880 struct sock *diag_nlsk;
72881 - atomic_t rt_genid;
72882 + atomic_unchecked_t rt_genid;
72883 };
72884
72885 /*
72886 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72887 #define __net_init __init
72888 #define __net_exit __exit_refok
72889 #define __net_initdata __initdata
72890 +#ifdef CONSTIFY_PLUGIN
72891 #define __net_initconst __initconst
72892 +#else
72893 +#define __net_initconst __initdata
72894 +#endif
72895 #endif
72896
72897 struct pernet_operations {
72898 @@ -282,7 +286,7 @@ struct pernet_operations {
72899 void (*exit_batch)(struct list_head *net_exit_list);
72900 int *id;
72901 size_t size;
72902 -};
72903 +} __do_const;
72904
72905 /*
72906 * Use these carefully. If you implement a network device and it
72907 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
72908
72909 static inline int rt_genid(struct net *net)
72910 {
72911 - return atomic_read(&net->rt_genid);
72912 + return atomic_read_unchecked(&net->rt_genid);
72913 }
72914
72915 static inline void rt_genid_bump(struct net *net)
72916 {
72917 - atomic_inc(&net->rt_genid);
72918 + atomic_inc_unchecked(&net->rt_genid);
72919 }
72920
72921 #endif /* __NET_NET_NAMESPACE_H */
72922 diff --git a/include/net/netdma.h b/include/net/netdma.h
72923 index 8ba8ce2..99b7fff 100644
72924 --- a/include/net/netdma.h
72925 +++ b/include/net/netdma.h
72926 @@ -24,7 +24,7 @@
72927 #include <linux/dmaengine.h>
72928 #include <linux/skbuff.h>
72929
72930 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72931 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72932 struct sk_buff *skb, int offset, struct iovec *to,
72933 size_t len, struct dma_pinned_list *pinned_list);
72934
72935 diff --git a/include/net/netlink.h b/include/net/netlink.h
72936 index 9690b0f..87aded7 100644
72937 --- a/include/net/netlink.h
72938 +++ b/include/net/netlink.h
72939 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
72940 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
72941 {
72942 if (mark)
72943 - skb_trim(skb, (unsigned char *) mark - skb->data);
72944 + skb_trim(skb, (const unsigned char *) mark - skb->data);
72945 }
72946
72947 /**
72948 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
72949 index 923cb20..deae816 100644
72950 --- a/include/net/netns/conntrack.h
72951 +++ b/include/net/netns/conntrack.h
72952 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
72953 struct nf_proto_net {
72954 #ifdef CONFIG_SYSCTL
72955 struct ctl_table_header *ctl_table_header;
72956 - struct ctl_table *ctl_table;
72957 + ctl_table_no_const *ctl_table;
72958 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
72959 struct ctl_table_header *ctl_compat_header;
72960 - struct ctl_table *ctl_compat_table;
72961 + ctl_table_no_const *ctl_compat_table;
72962 #endif
72963 #endif
72964 unsigned int users;
72965 @@ -58,7 +58,7 @@ struct nf_ip_net {
72966 struct nf_icmp_net icmpv6;
72967 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
72968 struct ctl_table_header *ctl_table_header;
72969 - struct ctl_table *ctl_table;
72970 + ctl_table_no_const *ctl_table;
72971 #endif
72972 };
72973
72974 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
72975 index 2ae2b83..dbdc85e 100644
72976 --- a/include/net/netns/ipv4.h
72977 +++ b/include/net/netns/ipv4.h
72978 @@ -64,7 +64,7 @@ struct netns_ipv4 {
72979 kgid_t sysctl_ping_group_range[2];
72980 long sysctl_tcp_mem[3];
72981
72982 - atomic_t dev_addr_genid;
72983 + atomic_unchecked_t dev_addr_genid;
72984
72985 #ifdef CONFIG_IP_MROUTE
72986 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
72987 diff --git a/include/net/protocol.h b/include/net/protocol.h
72988 index 047c047..b9dad15 100644
72989 --- a/include/net/protocol.h
72990 +++ b/include/net/protocol.h
72991 @@ -44,7 +44,7 @@ struct net_protocol {
72992 void (*err_handler)(struct sk_buff *skb, u32 info);
72993 unsigned int no_policy:1,
72994 netns_ok:1;
72995 -};
72996 +} __do_const;
72997
72998 #if IS_ENABLED(CONFIG_IPV6)
72999 struct inet6_protocol {
73000 @@ -57,7 +57,7 @@ struct inet6_protocol {
73001 u8 type, u8 code, int offset,
73002 __be32 info);
73003 unsigned int flags; /* INET6_PROTO_xxx */
73004 -};
73005 +} __do_const;
73006
73007 #define INET6_PROTO_NOPOLICY 0x1
73008 #define INET6_PROTO_FINAL 0x2
73009 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73010 index 5a15fab..d799ea7 100644
73011 --- a/include/net/rtnetlink.h
73012 +++ b/include/net/rtnetlink.h
73013 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73014 const struct net_device *dev);
73015 unsigned int (*get_num_tx_queues)(void);
73016 unsigned int (*get_num_rx_queues)(void);
73017 -};
73018 +} __do_const;
73019
73020 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73021 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73022 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73023 index 7fdf298..197e9f7 100644
73024 --- a/include/net/sctp/sctp.h
73025 +++ b/include/net/sctp/sctp.h
73026 @@ -330,9 +330,9 @@ do { \
73027
73028 #else /* SCTP_DEBUG */
73029
73030 -#define SCTP_DEBUG_PRINTK(whatever...)
73031 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73032 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73033 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73034 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73035 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73036 #define SCTP_ENABLE_DEBUG
73037 #define SCTP_DISABLE_DEBUG
73038 #define SCTP_ASSERT(expr, str, func)
73039 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73040 index 2a82d13..62a31c2 100644
73041 --- a/include/net/sctp/sm.h
73042 +++ b/include/net/sctp/sm.h
73043 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73044 typedef struct {
73045 sctp_state_fn_t *fn;
73046 const char *name;
73047 -} sctp_sm_table_entry_t;
73048 +} __do_const sctp_sm_table_entry_t;
73049
73050 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73051 * currently in use.
73052 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73053 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73054
73055 /* Extern declarations for major data structures. */
73056 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73057 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73058
73059
73060 /* Get the size of a DATA chunk payload. */
73061 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73062 index fdeb85a..1329d95 100644
73063 --- a/include/net/sctp/structs.h
73064 +++ b/include/net/sctp/structs.h
73065 @@ -517,7 +517,7 @@ struct sctp_pf {
73066 struct sctp_association *asoc);
73067 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73068 struct sctp_af *af;
73069 -};
73070 +} __do_const;
73071
73072
73073 /* Structure to track chunk fragments that have been acked, but peer
73074 diff --git a/include/net/sock.h b/include/net/sock.h
73075 index 25afaa0..8bb0070 100644
73076 --- a/include/net/sock.h
73077 +++ b/include/net/sock.h
73078 @@ -322,7 +322,7 @@ struct sock {
73079 #ifdef CONFIG_RPS
73080 __u32 sk_rxhash;
73081 #endif
73082 - atomic_t sk_drops;
73083 + atomic_unchecked_t sk_drops;
73084 int sk_rcvbuf;
73085
73086 struct sk_filter __rcu *sk_filter;
73087 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73088 }
73089
73090 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73091 - char __user *from, char *to,
73092 + char __user *from, unsigned char *to,
73093 int copy, int offset)
73094 {
73095 if (skb->ip_summed == CHECKSUM_NONE) {
73096 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73097 }
73098 }
73099
73100 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73101 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73102
73103 /**
73104 * sk_page_frag - return an appropriate page_frag
73105 diff --git a/include/net/tcp.h b/include/net/tcp.h
73106 index aed42c7..43890c6 100644
73107 --- a/include/net/tcp.h
73108 +++ b/include/net/tcp.h
73109 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73110 extern void tcp_xmit_retransmit_queue(struct sock *);
73111 extern void tcp_simple_retransmit(struct sock *);
73112 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73113 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73114 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73115
73116 extern void tcp_send_probe0(struct sock *);
73117 extern void tcp_send_partial(struct sock *);
73118 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
73119 struct inet6_skb_parm h6;
73120 #endif
73121 } header; /* For incoming frames */
73122 - __u32 seq; /* Starting sequence number */
73123 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73124 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73125 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73126 __u32 when; /* used to compute rtt's */
73127 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73128
73129 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
73130
73131 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73132 /* 1 byte hole */
73133 - __u32 ack_seq; /* Sequence number ACK'd */
73134 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73135 };
73136
73137 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73138 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73139 index 63445ed..d6fc34f 100644
73140 --- a/include/net/xfrm.h
73141 +++ b/include/net/xfrm.h
73142 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
73143 struct net_device *dev,
73144 const struct flowi *fl);
73145 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73146 -};
73147 +} __do_const;
73148
73149 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73150 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73151 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
73152 struct sk_buff *skb);
73153 int (*transport_finish)(struct sk_buff *skb,
73154 int async);
73155 -};
73156 +} __do_const;
73157
73158 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73159 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73160 @@ -423,7 +423,7 @@ struct xfrm_mode {
73161 struct module *owner;
73162 unsigned int encap;
73163 int flags;
73164 -};
73165 +} __do_const;
73166
73167 /* Flags for xfrm_mode. */
73168 enum {
73169 @@ -514,7 +514,7 @@ struct xfrm_policy {
73170 struct timer_list timer;
73171
73172 struct flow_cache_object flo;
73173 - atomic_t genid;
73174 + atomic_unchecked_t genid;
73175 u32 priority;
73176 u32 index;
73177 struct xfrm_mark mark;
73178 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73179 index 1a046b1..ee0bef0 100644
73180 --- a/include/rdma/iw_cm.h
73181 +++ b/include/rdma/iw_cm.h
73182 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73183 int backlog);
73184
73185 int (*destroy_listen)(struct iw_cm_id *cm_id);
73186 -};
73187 +} __no_const;
73188
73189 /**
73190 * iw_create_cm_id - Create an IW CM identifier.
73191 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73192 index 399162b..b337f1a 100644
73193 --- a/include/scsi/libfc.h
73194 +++ b/include/scsi/libfc.h
73195 @@ -762,6 +762,7 @@ struct libfc_function_template {
73196 */
73197 void (*disc_stop_final) (struct fc_lport *);
73198 };
73199 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73200
73201 /**
73202 * struct fc_disc - Discovery context
73203 @@ -866,7 +867,7 @@ struct fc_lport {
73204 struct fc_vport *vport;
73205
73206 /* Operational Information */
73207 - struct libfc_function_template tt;
73208 + libfc_function_template_no_const tt;
73209 u8 link_up;
73210 u8 qfull;
73211 enum fc_lport_state state;
73212 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73213 index e65c62e..aa2e5a2 100644
73214 --- a/include/scsi/scsi_device.h
73215 +++ b/include/scsi/scsi_device.h
73216 @@ -170,9 +170,9 @@ struct scsi_device {
73217 unsigned int max_device_blocked; /* what device_blocked counts down from */
73218 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73219
73220 - atomic_t iorequest_cnt;
73221 - atomic_t iodone_cnt;
73222 - atomic_t ioerr_cnt;
73223 + atomic_unchecked_t iorequest_cnt;
73224 + atomic_unchecked_t iodone_cnt;
73225 + atomic_unchecked_t ioerr_cnt;
73226
73227 struct device sdev_gendev,
73228 sdev_dev;
73229 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73230 index b797e8f..8e2c3aa 100644
73231 --- a/include/scsi/scsi_transport_fc.h
73232 +++ b/include/scsi/scsi_transport_fc.h
73233 @@ -751,7 +751,8 @@ struct fc_function_template {
73234 unsigned long show_host_system_hostname:1;
73235
73236 unsigned long disable_target_scan:1;
73237 -};
73238 +} __do_const;
73239 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73240
73241
73242 /**
73243 diff --git a/include/sound/soc.h b/include/sound/soc.h
73244 index bc56738..a4be132 100644
73245 --- a/include/sound/soc.h
73246 +++ b/include/sound/soc.h
73247 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
73248 /* probe ordering - for components with runtime dependencies */
73249 int probe_order;
73250 int remove_order;
73251 -};
73252 +} __do_const;
73253
73254 /* SoC platform interface */
73255 struct snd_soc_platform_driver {
73256 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
73257 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73258 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73259 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73260 -};
73261 +} __do_const;
73262
73263 struct snd_soc_platform {
73264 const char *name;
73265 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73266 index 663e34a..91b306a 100644
73267 --- a/include/target/target_core_base.h
73268 +++ b/include/target/target_core_base.h
73269 @@ -654,7 +654,7 @@ struct se_device {
73270 spinlock_t stats_lock;
73271 /* Active commands on this virtual SE device */
73272 atomic_t simple_cmds;
73273 - atomic_t dev_ordered_id;
73274 + atomic_unchecked_t dev_ordered_id;
73275 atomic_t dev_ordered_sync;
73276 atomic_t dev_qf_count;
73277 int export_count;
73278 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73279 new file mode 100644
73280 index 0000000..fb634b7
73281 --- /dev/null
73282 +++ b/include/trace/events/fs.h
73283 @@ -0,0 +1,53 @@
73284 +#undef TRACE_SYSTEM
73285 +#define TRACE_SYSTEM fs
73286 +
73287 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73288 +#define _TRACE_FS_H
73289 +
73290 +#include <linux/fs.h>
73291 +#include <linux/tracepoint.h>
73292 +
73293 +TRACE_EVENT(do_sys_open,
73294 +
73295 + TP_PROTO(const char *filename, int flags, int mode),
73296 +
73297 + TP_ARGS(filename, flags, mode),
73298 +
73299 + TP_STRUCT__entry(
73300 + __string( filename, filename )
73301 + __field( int, flags )
73302 + __field( int, mode )
73303 + ),
73304 +
73305 + TP_fast_assign(
73306 + __assign_str(filename, filename);
73307 + __entry->flags = flags;
73308 + __entry->mode = mode;
73309 + ),
73310 +
73311 + TP_printk("\"%s\" %x %o",
73312 + __get_str(filename), __entry->flags, __entry->mode)
73313 +);
73314 +
73315 +TRACE_EVENT(open_exec,
73316 +
73317 + TP_PROTO(const char *filename),
73318 +
73319 + TP_ARGS(filename),
73320 +
73321 + TP_STRUCT__entry(
73322 + __string( filename, filename )
73323 + ),
73324 +
73325 + TP_fast_assign(
73326 + __assign_str(filename, filename);
73327 + ),
73328 +
73329 + TP_printk("\"%s\"",
73330 + __get_str(filename))
73331 +);
73332 +
73333 +#endif /* _TRACE_FS_H */
73334 +
73335 +/* This part must be outside protection */
73336 +#include <trace/define_trace.h>
73337 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73338 index 1c09820..7f5ec79 100644
73339 --- a/include/trace/events/irq.h
73340 +++ b/include/trace/events/irq.h
73341 @@ -36,7 +36,7 @@ struct softirq_action;
73342 */
73343 TRACE_EVENT(irq_handler_entry,
73344
73345 - TP_PROTO(int irq, struct irqaction *action),
73346 + TP_PROTO(int irq, const struct irqaction *action),
73347
73348 TP_ARGS(irq, action),
73349
73350 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73351 */
73352 TRACE_EVENT(irq_handler_exit,
73353
73354 - TP_PROTO(int irq, struct irqaction *action, int ret),
73355 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73356
73357 TP_ARGS(irq, action, ret),
73358
73359 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73360 index 7caf44c..23c6f27 100644
73361 --- a/include/uapi/linux/a.out.h
73362 +++ b/include/uapi/linux/a.out.h
73363 @@ -39,6 +39,14 @@ enum machine_type {
73364 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73365 };
73366
73367 +/* Constants for the N_FLAGS field */
73368 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73369 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73370 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73371 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73372 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73373 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73374 +
73375 #if !defined (N_MAGIC)
73376 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73377 #endif
73378 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73379 index d876736..ccce5c0 100644
73380 --- a/include/uapi/linux/byteorder/little_endian.h
73381 +++ b/include/uapi/linux/byteorder/little_endian.h
73382 @@ -42,51 +42,51 @@
73383
73384 static inline __le64 __cpu_to_le64p(const __u64 *p)
73385 {
73386 - return (__force __le64)*p;
73387 + return (__force const __le64)*p;
73388 }
73389 -static inline __u64 __le64_to_cpup(const __le64 *p)
73390 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73391 {
73392 - return (__force __u64)*p;
73393 + return (__force const __u64)*p;
73394 }
73395 static inline __le32 __cpu_to_le32p(const __u32 *p)
73396 {
73397 - return (__force __le32)*p;
73398 + return (__force const __le32)*p;
73399 }
73400 static inline __u32 __le32_to_cpup(const __le32 *p)
73401 {
73402 - return (__force __u32)*p;
73403 + return (__force const __u32)*p;
73404 }
73405 static inline __le16 __cpu_to_le16p(const __u16 *p)
73406 {
73407 - return (__force __le16)*p;
73408 + return (__force const __le16)*p;
73409 }
73410 static inline __u16 __le16_to_cpup(const __le16 *p)
73411 {
73412 - return (__force __u16)*p;
73413 + return (__force const __u16)*p;
73414 }
73415 static inline __be64 __cpu_to_be64p(const __u64 *p)
73416 {
73417 - return (__force __be64)__swab64p(p);
73418 + return (__force const __be64)__swab64p(p);
73419 }
73420 static inline __u64 __be64_to_cpup(const __be64 *p)
73421 {
73422 - return __swab64p((__u64 *)p);
73423 + return __swab64p((const __u64 *)p);
73424 }
73425 static inline __be32 __cpu_to_be32p(const __u32 *p)
73426 {
73427 - return (__force __be32)__swab32p(p);
73428 + return (__force const __be32)__swab32p(p);
73429 }
73430 -static inline __u32 __be32_to_cpup(const __be32 *p)
73431 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73432 {
73433 - return __swab32p((__u32 *)p);
73434 + return __swab32p((const __u32 *)p);
73435 }
73436 static inline __be16 __cpu_to_be16p(const __u16 *p)
73437 {
73438 - return (__force __be16)__swab16p(p);
73439 + return (__force const __be16)__swab16p(p);
73440 }
73441 static inline __u16 __be16_to_cpup(const __be16 *p)
73442 {
73443 - return __swab16p((__u16 *)p);
73444 + return __swab16p((const __u16 *)p);
73445 }
73446 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73447 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73448 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73449 index 126a817..d522bd1 100644
73450 --- a/include/uapi/linux/elf.h
73451 +++ b/include/uapi/linux/elf.h
73452 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73453 #define PT_GNU_EH_FRAME 0x6474e550
73454
73455 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73456 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73457 +
73458 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73459 +
73460 +/* Constants for the e_flags field */
73461 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73462 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73463 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73464 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73465 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73466 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73467
73468 /*
73469 * Extended Numbering
73470 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73471 #define DT_DEBUG 21
73472 #define DT_TEXTREL 22
73473 #define DT_JMPREL 23
73474 +#define DT_FLAGS 30
73475 + #define DF_TEXTREL 0x00000004
73476 #define DT_ENCODING 32
73477 #define OLD_DT_LOOS 0x60000000
73478 #define DT_LOOS 0x6000000d
73479 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73480 #define PF_W 0x2
73481 #define PF_X 0x1
73482
73483 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73484 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73485 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73486 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73487 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73488 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73489 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73490 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73491 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73492 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73493 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73494 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73495 +
73496 typedef struct elf32_phdr{
73497 Elf32_Word p_type;
73498 Elf32_Off p_offset;
73499 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73500 #define EI_OSABI 7
73501 #define EI_PAD 8
73502
73503 +#define EI_PAX 14
73504 +
73505 #define ELFMAG0 0x7f /* EI_MAG */
73506 #define ELFMAG1 'E'
73507 #define ELFMAG2 'L'
73508 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73509 index aa169c4..6a2771d 100644
73510 --- a/include/uapi/linux/personality.h
73511 +++ b/include/uapi/linux/personality.h
73512 @@ -30,6 +30,7 @@ enum {
73513 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73514 ADDR_NO_RANDOMIZE | \
73515 ADDR_COMPAT_LAYOUT | \
73516 + ADDR_LIMIT_3GB | \
73517 MMAP_PAGE_ZERO)
73518
73519 /*
73520 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73521 index 7530e74..e714828 100644
73522 --- a/include/uapi/linux/screen_info.h
73523 +++ b/include/uapi/linux/screen_info.h
73524 @@ -43,7 +43,8 @@ struct screen_info {
73525 __u16 pages; /* 0x32 */
73526 __u16 vesa_attributes; /* 0x34 */
73527 __u32 capabilities; /* 0x36 */
73528 - __u8 _reserved[6]; /* 0x3a */
73529 + __u16 vesapm_size; /* 0x3a */
73530 + __u8 _reserved[4]; /* 0x3c */
73531 } __attribute__((packed));
73532
73533 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73534 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73535 index 0e011eb..82681b1 100644
73536 --- a/include/uapi/linux/swab.h
73537 +++ b/include/uapi/linux/swab.h
73538 @@ -43,7 +43,7 @@
73539 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73540 */
73541
73542 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73543 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73544 {
73545 #ifdef __HAVE_BUILTIN_BSWAP16__
73546 return __builtin_bswap16(val);
73547 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73548 #endif
73549 }
73550
73551 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73552 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73553 {
73554 #ifdef __HAVE_BUILTIN_BSWAP32__
73555 return __builtin_bswap32(val);
73556 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73557 #endif
73558 }
73559
73560 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73561 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73562 {
73563 #ifdef __HAVE_BUILTIN_BSWAP64__
73564 return __builtin_bswap64(val);
73565 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73566 index 6d67213..8dab561 100644
73567 --- a/include/uapi/linux/sysctl.h
73568 +++ b/include/uapi/linux/sysctl.h
73569 @@ -155,7 +155,11 @@ enum
73570 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73571 };
73572
73573 -
73574 +#ifdef CONFIG_PAX_SOFTMODE
73575 +enum {
73576 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73577 +};
73578 +#endif
73579
73580 /* CTL_VM names: */
73581 enum
73582 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73583 index 26607bd..588b65f 100644
73584 --- a/include/uapi/linux/xattr.h
73585 +++ b/include/uapi/linux/xattr.h
73586 @@ -60,5 +60,9 @@
73587 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73588 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73589
73590 +/* User namespace */
73591 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73592 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73593 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73594
73595 #endif /* _UAPI_LINUX_XATTR_H */
73596 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73597 index f9466fa..f4e2b81 100644
73598 --- a/include/video/udlfb.h
73599 +++ b/include/video/udlfb.h
73600 @@ -53,10 +53,10 @@ struct dlfb_data {
73601 u32 pseudo_palette[256];
73602 int blank_mode; /*one of FB_BLANK_ */
73603 /* blit-only rendering path metrics, exposed through sysfs */
73604 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73605 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73606 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73607 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73608 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73609 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73610 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73611 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73612 };
73613
73614 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73615 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73616 index 0993a22..32ba2fe 100644
73617 --- a/include/video/uvesafb.h
73618 +++ b/include/video/uvesafb.h
73619 @@ -177,6 +177,7 @@ struct uvesafb_par {
73620 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73621 u8 pmi_setpal; /* PMI for palette changes */
73622 u16 *pmi_base; /* protected mode interface location */
73623 + u8 *pmi_code; /* protected mode code location */
73624 void *pmi_start;
73625 void *pmi_pal;
73626 u8 *vbe_state_orig; /*
73627 diff --git a/init/Kconfig b/init/Kconfig
73628 index be8b7f5..1eeca9b 100644
73629 --- a/init/Kconfig
73630 +++ b/init/Kconfig
73631 @@ -990,6 +990,7 @@ endif # CGROUPS
73632
73633 config CHECKPOINT_RESTORE
73634 bool "Checkpoint/restore support" if EXPERT
73635 + depends on !GRKERNSEC
73636 default n
73637 help
73638 Enables additional kernel features in a sake of checkpoint/restore.
73639 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
73640
73641 config COMPAT_BRK
73642 bool "Disable heap randomization"
73643 - default y
73644 + default n
73645 help
73646 Randomizing heap placement makes heap exploits harder, but it
73647 also breaks ancient binaries (including anything libc5 based).
73648 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
73649 config STOP_MACHINE
73650 bool
73651 default y
73652 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73653 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73654 help
73655 Need stop_machine() primitive.
73656
73657 diff --git a/init/Makefile b/init/Makefile
73658 index 7bc47ee..6da2dc7 100644
73659 --- a/init/Makefile
73660 +++ b/init/Makefile
73661 @@ -2,6 +2,9 @@
73662 # Makefile for the linux kernel.
73663 #
73664
73665 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73666 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73667 +
73668 obj-y := main.o version.o mounts.o
73669 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73670 obj-y += noinitramfs.o
73671 diff --git a/init/do_mounts.c b/init/do_mounts.c
73672 index 1d1b634..a1c810f 100644
73673 --- a/init/do_mounts.c
73674 +++ b/init/do_mounts.c
73675 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73676 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73677 {
73678 struct super_block *s;
73679 - int err = sys_mount(name, "/root", fs, flags, data);
73680 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73681 if (err)
73682 return err;
73683
73684 - sys_chdir("/root");
73685 + sys_chdir((const char __force_user *)"/root");
73686 s = current->fs->pwd.dentry->d_sb;
73687 ROOT_DEV = s->s_dev;
73688 printk(KERN_INFO
73689 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73690 va_start(args, fmt);
73691 vsprintf(buf, fmt, args);
73692 va_end(args);
73693 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73694 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73695 if (fd >= 0) {
73696 sys_ioctl(fd, FDEJECT, 0);
73697 sys_close(fd);
73698 }
73699 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73700 - fd = sys_open("/dev/console", O_RDWR, 0);
73701 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73702 if (fd >= 0) {
73703 sys_ioctl(fd, TCGETS, (long)&termios);
73704 termios.c_lflag &= ~ICANON;
73705 sys_ioctl(fd, TCSETSF, (long)&termios);
73706 - sys_read(fd, &c, 1);
73707 + sys_read(fd, (char __user *)&c, 1);
73708 termios.c_lflag |= ICANON;
73709 sys_ioctl(fd, TCSETSF, (long)&termios);
73710 sys_close(fd);
73711 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73712 mount_root();
73713 out:
73714 devtmpfs_mount("dev");
73715 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73716 - sys_chroot(".");
73717 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73718 + sys_chroot((const char __force_user *)".");
73719 }
73720 diff --git a/init/do_mounts.h b/init/do_mounts.h
73721 index f5b978a..69dbfe8 100644
73722 --- a/init/do_mounts.h
73723 +++ b/init/do_mounts.h
73724 @@ -15,15 +15,15 @@ extern int root_mountflags;
73725
73726 static inline int create_dev(char *name, dev_t dev)
73727 {
73728 - sys_unlink(name);
73729 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73730 + sys_unlink((char __force_user *)name);
73731 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73732 }
73733
73734 #if BITS_PER_LONG == 32
73735 static inline u32 bstat(char *name)
73736 {
73737 struct stat64 stat;
73738 - if (sys_stat64(name, &stat) != 0)
73739 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73740 return 0;
73741 if (!S_ISBLK(stat.st_mode))
73742 return 0;
73743 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73744 static inline u32 bstat(char *name)
73745 {
73746 struct stat stat;
73747 - if (sys_newstat(name, &stat) != 0)
73748 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73749 return 0;
73750 if (!S_ISBLK(stat.st_mode))
73751 return 0;
73752 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73753 index f9acf71..1e19144 100644
73754 --- a/init/do_mounts_initrd.c
73755 +++ b/init/do_mounts_initrd.c
73756 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73757 create_dev("/dev/root.old", Root_RAM0);
73758 /* mount initrd on rootfs' /root */
73759 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73760 - sys_mkdir("/old", 0700);
73761 - sys_chdir("/old");
73762 + sys_mkdir((const char __force_user *)"/old", 0700);
73763 + sys_chdir((const char __force_user *)"/old");
73764
73765 /*
73766 * In case that a resume from disk is carried out by linuxrc or one of
73767 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
73768 current->flags &= ~PF_FREEZER_SKIP;
73769
73770 /* move initrd to rootfs' /old */
73771 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73772 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73773 /* switch root and cwd back to / of rootfs */
73774 - sys_chroot("..");
73775 + sys_chroot((const char __force_user *)"..");
73776
73777 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73778 - sys_chdir("/old");
73779 + sys_chdir((const char __force_user *)"/old");
73780 return;
73781 }
73782
73783 - sys_chdir("/");
73784 + sys_chdir((const char __force_user *)"/");
73785 ROOT_DEV = new_decode_dev(real_root_dev);
73786 mount_root();
73787
73788 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73789 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73790 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73791 if (!error)
73792 printk("okay\n");
73793 else {
73794 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73795 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73796 if (error == -ENOENT)
73797 printk("/initrd does not exist. Ignored.\n");
73798 else
73799 printk("failed\n");
73800 printk(KERN_NOTICE "Unmounting old root\n");
73801 - sys_umount("/old", MNT_DETACH);
73802 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73803 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73804 if (fd < 0) {
73805 error = fd;
73806 @@ -120,11 +120,11 @@ int __init initrd_load(void)
73807 * mounted in the normal path.
73808 */
73809 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73810 - sys_unlink("/initrd.image");
73811 + sys_unlink((const char __force_user *)"/initrd.image");
73812 handle_initrd();
73813 return 1;
73814 }
73815 }
73816 - sys_unlink("/initrd.image");
73817 + sys_unlink((const char __force_user *)"/initrd.image");
73818 return 0;
73819 }
73820 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73821 index 8cb6db5..d729f50 100644
73822 --- a/init/do_mounts_md.c
73823 +++ b/init/do_mounts_md.c
73824 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73825 partitioned ? "_d" : "", minor,
73826 md_setup_args[ent].device_names);
73827
73828 - fd = sys_open(name, 0, 0);
73829 + fd = sys_open((char __force_user *)name, 0, 0);
73830 if (fd < 0) {
73831 printk(KERN_ERR "md: open failed - cannot start "
73832 "array %s\n", name);
73833 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73834 * array without it
73835 */
73836 sys_close(fd);
73837 - fd = sys_open(name, 0, 0);
73838 + fd = sys_open((char __force_user *)name, 0, 0);
73839 sys_ioctl(fd, BLKRRPART, 0);
73840 }
73841 sys_close(fd);
73842 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73843
73844 wait_for_device_probe();
73845
73846 - fd = sys_open("/dev/md0", 0, 0);
73847 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73848 if (fd >= 0) {
73849 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73850 sys_close(fd);
73851 diff --git a/init/init_task.c b/init/init_task.c
73852 index 8b2f399..f0797c9 100644
73853 --- a/init/init_task.c
73854 +++ b/init/init_task.c
73855 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
73856 * Initial thread structure. Alignment of this is handled by a special
73857 * linker map entry.
73858 */
73859 +#ifdef CONFIG_X86
73860 +union thread_union init_thread_union __init_task_data;
73861 +#else
73862 union thread_union init_thread_union __init_task_data =
73863 { INIT_THREAD_INFO(init_task) };
73864 +#endif
73865 diff --git a/init/initramfs.c b/init/initramfs.c
73866 index 84c6bf1..8899338 100644
73867 --- a/init/initramfs.c
73868 +++ b/init/initramfs.c
73869 @@ -84,7 +84,7 @@ static void __init free_hash(void)
73870 }
73871 }
73872
73873 -static long __init do_utime(char *filename, time_t mtime)
73874 +static long __init do_utime(char __force_user *filename, time_t mtime)
73875 {
73876 struct timespec t[2];
73877
73878 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
73879 struct dir_entry *de, *tmp;
73880 list_for_each_entry_safe(de, tmp, &dir_list, list) {
73881 list_del(&de->list);
73882 - do_utime(de->name, de->mtime);
73883 + do_utime((char __force_user *)de->name, de->mtime);
73884 kfree(de->name);
73885 kfree(de);
73886 }
73887 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
73888 if (nlink >= 2) {
73889 char *old = find_link(major, minor, ino, mode, collected);
73890 if (old)
73891 - return (sys_link(old, collected) < 0) ? -1 : 1;
73892 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
73893 }
73894 return 0;
73895 }
73896 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
73897 {
73898 struct stat st;
73899
73900 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
73901 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
73902 if (S_ISDIR(st.st_mode))
73903 - sys_rmdir(path);
73904 + sys_rmdir((char __force_user *)path);
73905 else
73906 - sys_unlink(path);
73907 + sys_unlink((char __force_user *)path);
73908 }
73909 }
73910
73911 @@ -315,7 +315,7 @@ static int __init do_name(void)
73912 int openflags = O_WRONLY|O_CREAT;
73913 if (ml != 1)
73914 openflags |= O_TRUNC;
73915 - wfd = sys_open(collected, openflags, mode);
73916 + wfd = sys_open((char __force_user *)collected, openflags, mode);
73917
73918 if (wfd >= 0) {
73919 sys_fchown(wfd, uid, gid);
73920 @@ -327,17 +327,17 @@ static int __init do_name(void)
73921 }
73922 }
73923 } else if (S_ISDIR(mode)) {
73924 - sys_mkdir(collected, mode);
73925 - sys_chown(collected, uid, gid);
73926 - sys_chmod(collected, mode);
73927 + sys_mkdir((char __force_user *)collected, mode);
73928 + sys_chown((char __force_user *)collected, uid, gid);
73929 + sys_chmod((char __force_user *)collected, mode);
73930 dir_add(collected, mtime);
73931 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
73932 S_ISFIFO(mode) || S_ISSOCK(mode)) {
73933 if (maybe_link() == 0) {
73934 - sys_mknod(collected, mode, rdev);
73935 - sys_chown(collected, uid, gid);
73936 - sys_chmod(collected, mode);
73937 - do_utime(collected, mtime);
73938 + sys_mknod((char __force_user *)collected, mode, rdev);
73939 + sys_chown((char __force_user *)collected, uid, gid);
73940 + sys_chmod((char __force_user *)collected, mode);
73941 + do_utime((char __force_user *)collected, mtime);
73942 }
73943 }
73944 return 0;
73945 @@ -346,15 +346,15 @@ static int __init do_name(void)
73946 static int __init do_copy(void)
73947 {
73948 if (count >= body_len) {
73949 - sys_write(wfd, victim, body_len);
73950 + sys_write(wfd, (char __force_user *)victim, body_len);
73951 sys_close(wfd);
73952 - do_utime(vcollected, mtime);
73953 + do_utime((char __force_user *)vcollected, mtime);
73954 kfree(vcollected);
73955 eat(body_len);
73956 state = SkipIt;
73957 return 0;
73958 } else {
73959 - sys_write(wfd, victim, count);
73960 + sys_write(wfd, (char __force_user *)victim, count);
73961 body_len -= count;
73962 eat(count);
73963 return 1;
73964 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
73965 {
73966 collected[N_ALIGN(name_len) + body_len] = '\0';
73967 clean_path(collected, 0);
73968 - sys_symlink(collected + N_ALIGN(name_len), collected);
73969 - sys_lchown(collected, uid, gid);
73970 - do_utime(collected, mtime);
73971 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
73972 + sys_lchown((char __force_user *)collected, uid, gid);
73973 + do_utime((char __force_user *)collected, mtime);
73974 state = SkipIt;
73975 next_state = Reset;
73976 return 0;
73977 diff --git a/init/main.c b/init/main.c
73978 index cee4b5c..360e10a 100644
73979 --- a/init/main.c
73980 +++ b/init/main.c
73981 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
73982 extern void tc_init(void);
73983 #endif
73984
73985 +extern void grsecurity_init(void);
73986 +
73987 /*
73988 * Debug helper: via this flag we know that we are in 'early bootup code'
73989 * where only the boot processor is running with IRQ disabled. This means
73990 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
73991
73992 __setup("reset_devices", set_reset_devices);
73993
73994 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
73995 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
73996 +static int __init setup_grsec_proc_gid(char *str)
73997 +{
73998 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
73999 + return 1;
74000 +}
74001 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74002 +#endif
74003 +
74004 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74005 +extern char pax_enter_kernel_user[];
74006 +extern char pax_exit_kernel_user[];
74007 +extern pgdval_t clone_pgd_mask;
74008 +#endif
74009 +
74010 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74011 +static int __init setup_pax_nouderef(char *str)
74012 +{
74013 +#ifdef CONFIG_X86_32
74014 + unsigned int cpu;
74015 + struct desc_struct *gdt;
74016 +
74017 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74018 + gdt = get_cpu_gdt_table(cpu);
74019 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74020 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74021 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74022 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74023 + }
74024 + loadsegment(ds, __KERNEL_DS);
74025 + loadsegment(es, __KERNEL_DS);
74026 + loadsegment(ss, __KERNEL_DS);
74027 +#else
74028 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74029 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74030 + clone_pgd_mask = ~(pgdval_t)0UL;
74031 +#endif
74032 +
74033 + return 0;
74034 +}
74035 +early_param("pax_nouderef", setup_pax_nouderef);
74036 +#endif
74037 +
74038 +#ifdef CONFIG_PAX_SOFTMODE
74039 +int pax_softmode;
74040 +
74041 +static int __init setup_pax_softmode(char *str)
74042 +{
74043 + get_option(&str, &pax_softmode);
74044 + return 1;
74045 +}
74046 +__setup("pax_softmode=", setup_pax_softmode);
74047 +#endif
74048 +
74049 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74050 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74051 static const char *panic_later, *panic_param;
74052 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
74053 {
74054 int count = preempt_count();
74055 int ret;
74056 + const char *msg1 = "", *msg2 = "";
74057
74058 if (initcall_debug)
74059 ret = do_one_initcall_debug(fn);
74060 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
74061 sprintf(msgbuf, "error code %d ", ret);
74062
74063 if (preempt_count() != count) {
74064 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
74065 + msg1 = " preemption imbalance";
74066 preempt_count() = count;
74067 }
74068 if (irqs_disabled()) {
74069 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74070 + msg2 = " disabled interrupts";
74071 local_irq_enable();
74072 }
74073 - if (msgbuf[0]) {
74074 - printk("initcall %pF returned with %s\n", fn, msgbuf);
74075 + if (msgbuf[0] || *msg1 || *msg2) {
74076 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
74077 }
74078
74079 return ret;
74080 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
74081 level, level,
74082 &repair_env_string);
74083
74084 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74085 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74086 do_one_initcall(*fn);
74087 +
74088 +#ifdef LATENT_ENTROPY_PLUGIN
74089 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74090 +#endif
74091 +
74092 + }
74093 }
74094
74095 static void __init do_initcalls(void)
74096 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
74097 {
74098 initcall_t *fn;
74099
74100 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74101 + for (fn = __initcall_start; fn < __initcall0_start; 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 int run_init_process(const char *init_filename)
74112 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
74113 do_basic_setup();
74114
74115 /* Open the /dev/console on the rootfs, this should never fail */
74116 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74117 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74118 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
74119
74120 (void) sys_dup(0);
74121 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
74122 if (!ramdisk_execute_command)
74123 ramdisk_execute_command = "/init";
74124
74125 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74126 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74127 ramdisk_execute_command = NULL;
74128 prepare_namespace();
74129 }
74130
74131 + grsecurity_init();
74132 +
74133 /*
74134 * Ok, we have completed the initial bootup, and
74135 * we're essentially up and running. Get rid of the
74136 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74137 index 130dfec..cc88451 100644
74138 --- a/ipc/ipc_sysctl.c
74139 +++ b/ipc/ipc_sysctl.c
74140 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74141 static int proc_ipc_dointvec(ctl_table *table, int write,
74142 void __user *buffer, size_t *lenp, loff_t *ppos)
74143 {
74144 - struct ctl_table ipc_table;
74145 + ctl_table_no_const ipc_table;
74146
74147 memcpy(&ipc_table, table, sizeof(ipc_table));
74148 ipc_table.data = get_ipc(table);
74149 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74150 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74151 void __user *buffer, size_t *lenp, loff_t *ppos)
74152 {
74153 - struct ctl_table ipc_table;
74154 + ctl_table_no_const ipc_table;
74155
74156 memcpy(&ipc_table, table, sizeof(ipc_table));
74157 ipc_table.data = get_ipc(table);
74158 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74159 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74160 void __user *buffer, size_t *lenp, loff_t *ppos)
74161 {
74162 - struct ctl_table ipc_table;
74163 + ctl_table_no_const ipc_table;
74164 size_t lenp_bef = *lenp;
74165 int rc;
74166
74167 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74168 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74169 void __user *buffer, size_t *lenp, loff_t *ppos)
74170 {
74171 - struct ctl_table ipc_table;
74172 + ctl_table_no_const ipc_table;
74173 memcpy(&ipc_table, table, sizeof(ipc_table));
74174 ipc_table.data = get_ipc(table);
74175
74176 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74177 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74178 void __user *buffer, size_t *lenp, loff_t *ppos)
74179 {
74180 - struct ctl_table ipc_table;
74181 + ctl_table_no_const ipc_table;
74182 size_t lenp_bef = *lenp;
74183 int oldval;
74184 int rc;
74185 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74186 index 383d638..943fdbb 100644
74187 --- a/ipc/mq_sysctl.c
74188 +++ b/ipc/mq_sysctl.c
74189 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74190 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74191 void __user *buffer, size_t *lenp, loff_t *ppos)
74192 {
74193 - struct ctl_table mq_table;
74194 + ctl_table_no_const mq_table;
74195 memcpy(&mq_table, table, sizeof(mq_table));
74196 mq_table.data = get_mq(table);
74197
74198 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74199 index f3f40dc..ffe5a3a 100644
74200 --- a/ipc/mqueue.c
74201 +++ b/ipc/mqueue.c
74202 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74203 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74204 info->attr.mq_msgsize);
74205
74206 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74207 spin_lock(&mq_lock);
74208 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74209 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74210 diff --git a/ipc/msg.c b/ipc/msg.c
74211 index fede1d0..9778e0f8 100644
74212 --- a/ipc/msg.c
74213 +++ b/ipc/msg.c
74214 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74215 return security_msg_queue_associate(msq, msgflg);
74216 }
74217
74218 +static struct ipc_ops msg_ops = {
74219 + .getnew = newque,
74220 + .associate = msg_security,
74221 + .more_checks = NULL
74222 +};
74223 +
74224 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74225 {
74226 struct ipc_namespace *ns;
74227 - struct ipc_ops msg_ops;
74228 struct ipc_params msg_params;
74229
74230 ns = current->nsproxy->ipc_ns;
74231
74232 - msg_ops.getnew = newque;
74233 - msg_ops.associate = msg_security;
74234 - msg_ops.more_checks = NULL;
74235 -
74236 msg_params.key = key;
74237 msg_params.flg = msgflg;
74238
74239 diff --git a/ipc/sem.c b/ipc/sem.c
74240 index 58d31f1..cce7a55 100644
74241 --- a/ipc/sem.c
74242 +++ b/ipc/sem.c
74243 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74244 return 0;
74245 }
74246
74247 +static struct ipc_ops sem_ops = {
74248 + .getnew = newary,
74249 + .associate = sem_security,
74250 + .more_checks = sem_more_checks
74251 +};
74252 +
74253 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74254 {
74255 struct ipc_namespace *ns;
74256 - struct ipc_ops sem_ops;
74257 struct ipc_params sem_params;
74258
74259 ns = current->nsproxy->ipc_ns;
74260 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74261 if (nsems < 0 || nsems > ns->sc_semmsl)
74262 return -EINVAL;
74263
74264 - sem_ops.getnew = newary;
74265 - sem_ops.associate = sem_security;
74266 - sem_ops.more_checks = sem_more_checks;
74267 -
74268 sem_params.key = key;
74269 sem_params.flg = semflg;
74270 sem_params.u.nsems = nsems;
74271 diff --git a/ipc/shm.c b/ipc/shm.c
74272 index 4fa6d8f..55cff14 100644
74273 --- a/ipc/shm.c
74274 +++ b/ipc/shm.c
74275 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74276 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74277 #endif
74278
74279 +#ifdef CONFIG_GRKERNSEC
74280 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74281 + const time_t shm_createtime, const kuid_t cuid,
74282 + const int shmid);
74283 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74284 + const time_t shm_createtime);
74285 +#endif
74286 +
74287 void shm_init_ns(struct ipc_namespace *ns)
74288 {
74289 ns->shm_ctlmax = SHMMAX;
74290 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74291 shp->shm_lprid = 0;
74292 shp->shm_atim = shp->shm_dtim = 0;
74293 shp->shm_ctim = get_seconds();
74294 +#ifdef CONFIG_GRKERNSEC
74295 + {
74296 + struct timespec timeval;
74297 + do_posix_clock_monotonic_gettime(&timeval);
74298 +
74299 + shp->shm_createtime = timeval.tv_sec;
74300 + }
74301 +#endif
74302 shp->shm_segsz = size;
74303 shp->shm_nattch = 0;
74304 shp->shm_file = file;
74305 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74306 return 0;
74307 }
74308
74309 +static struct ipc_ops shm_ops = {
74310 + .getnew = newseg,
74311 + .associate = shm_security,
74312 + .more_checks = shm_more_checks
74313 +};
74314 +
74315 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74316 {
74317 struct ipc_namespace *ns;
74318 - struct ipc_ops shm_ops;
74319 struct ipc_params shm_params;
74320
74321 ns = current->nsproxy->ipc_ns;
74322
74323 - shm_ops.getnew = newseg;
74324 - shm_ops.associate = shm_security;
74325 - shm_ops.more_checks = shm_more_checks;
74326 -
74327 shm_params.key = key;
74328 shm_params.flg = shmflg;
74329 shm_params.u.size = size;
74330 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74331 f_mode = FMODE_READ | FMODE_WRITE;
74332 }
74333 if (shmflg & SHM_EXEC) {
74334 +
74335 +#ifdef CONFIG_PAX_MPROTECT
74336 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74337 + goto out;
74338 +#endif
74339 +
74340 prot |= PROT_EXEC;
74341 acc_mode |= S_IXUGO;
74342 }
74343 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74344 if (err)
74345 goto out_unlock;
74346
74347 +#ifdef CONFIG_GRKERNSEC
74348 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74349 + shp->shm_perm.cuid, shmid) ||
74350 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74351 + err = -EACCES;
74352 + goto out_unlock;
74353 + }
74354 +#endif
74355 +
74356 path = shp->shm_file->f_path;
74357 path_get(&path);
74358 shp->shm_nattch++;
74359 +#ifdef CONFIG_GRKERNSEC
74360 + shp->shm_lapid = current->pid;
74361 +#endif
74362 size = i_size_read(path.dentry->d_inode);
74363 shm_unlock(shp);
74364
74365 diff --git a/kernel/acct.c b/kernel/acct.c
74366 index 051e071..15e0920 100644
74367 --- a/kernel/acct.c
74368 +++ b/kernel/acct.c
74369 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74370 */
74371 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74372 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74373 - file->f_op->write(file, (char *)&ac,
74374 + file->f_op->write(file, (char __force_user *)&ac,
74375 sizeof(acct_t), &file->f_pos);
74376 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74377 set_fs(fs);
74378 diff --git a/kernel/audit.c b/kernel/audit.c
74379 index d596e53..dbef3c3 100644
74380 --- a/kernel/audit.c
74381 +++ b/kernel/audit.c
74382 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74383 3) suppressed due to audit_rate_limit
74384 4) suppressed due to audit_backlog_limit
74385 */
74386 -static atomic_t audit_lost = ATOMIC_INIT(0);
74387 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74388
74389 /* The netlink socket. */
74390 static struct sock *audit_sock;
74391 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74392 unsigned long now;
74393 int print;
74394
74395 - atomic_inc(&audit_lost);
74396 + atomic_inc_unchecked(&audit_lost);
74397
74398 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74399
74400 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74401 printk(KERN_WARNING
74402 "audit: audit_lost=%d audit_rate_limit=%d "
74403 "audit_backlog_limit=%d\n",
74404 - atomic_read(&audit_lost),
74405 + atomic_read_unchecked(&audit_lost),
74406 audit_rate_limit,
74407 audit_backlog_limit);
74408 audit_panic(message);
74409 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74410 status_set.pid = audit_pid;
74411 status_set.rate_limit = audit_rate_limit;
74412 status_set.backlog_limit = audit_backlog_limit;
74413 - status_set.lost = atomic_read(&audit_lost);
74414 + status_set.lost = atomic_read_unchecked(&audit_lost);
74415 status_set.backlog = skb_queue_len(&audit_skb_queue);
74416 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74417 &status_set, sizeof(status_set));
74418 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74419 index a371f85..da826c1 100644
74420 --- a/kernel/auditsc.c
74421 +++ b/kernel/auditsc.c
74422 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74423 }
74424
74425 /* global counter which is incremented every time something logs in */
74426 -static atomic_t session_id = ATOMIC_INIT(0);
74427 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74428
74429 /**
74430 * audit_set_loginuid - set current task's audit_context loginuid
74431 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
74432 return -EPERM;
74433 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74434
74435 - sessionid = atomic_inc_return(&session_id);
74436 + sessionid = atomic_inc_return_unchecked(&session_id);
74437 if (context && context->in_syscall) {
74438 struct audit_buffer *ab;
74439
74440 diff --git a/kernel/capability.c b/kernel/capability.c
74441 index 493d972..f87dfbd 100644
74442 --- a/kernel/capability.c
74443 +++ b/kernel/capability.c
74444 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74445 * before modification is attempted and the application
74446 * fails.
74447 */
74448 + if (tocopy > ARRAY_SIZE(kdata))
74449 + return -EFAULT;
74450 +
74451 if (copy_to_user(dataptr, kdata, tocopy
74452 * sizeof(struct __user_cap_data_struct))) {
74453 return -EFAULT;
74454 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74455 int ret;
74456
74457 rcu_read_lock();
74458 - ret = security_capable(__task_cred(t), ns, cap);
74459 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74460 + gr_task_is_capable(t, __task_cred(t), cap);
74461 rcu_read_unlock();
74462
74463 - return (ret == 0);
74464 + return ret;
74465 }
74466
74467 /**
74468 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74469 int ret;
74470
74471 rcu_read_lock();
74472 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74473 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74474 rcu_read_unlock();
74475
74476 - return (ret == 0);
74477 + return ret;
74478 }
74479
74480 /**
74481 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74482 BUG();
74483 }
74484
74485 - if (security_capable(current_cred(), ns, cap) == 0) {
74486 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74487 current->flags |= PF_SUPERPRIV;
74488 return true;
74489 }
74490 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74491 }
74492 EXPORT_SYMBOL(ns_capable);
74493
74494 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74495 +{
74496 + if (unlikely(!cap_valid(cap))) {
74497 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74498 + BUG();
74499 + }
74500 +
74501 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74502 + current->flags |= PF_SUPERPRIV;
74503 + return true;
74504 + }
74505 + return false;
74506 +}
74507 +EXPORT_SYMBOL(ns_capable_nolog);
74508 +
74509 /**
74510 * capable - Determine if the current task has a superior capability in effect
74511 * @cap: The capability to be tested for
74512 @@ -408,6 +427,12 @@ bool capable(int cap)
74513 }
74514 EXPORT_SYMBOL(capable);
74515
74516 +bool capable_nolog(int cap)
74517 +{
74518 + return ns_capable_nolog(&init_user_ns, cap);
74519 +}
74520 +EXPORT_SYMBOL(capable_nolog);
74521 +
74522 /**
74523 * nsown_capable - Check superior capability to one's own user_ns
74524 * @cap: The capability in question
74525 @@ -440,3 +465,10 @@ bool inode_capable(const struct inode *inode, int cap)
74526
74527 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74528 }
74529 +
74530 +bool inode_capable_nolog(const struct inode *inode, int cap)
74531 +{
74532 + struct user_namespace *ns = current_user_ns();
74533 +
74534 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74535 +}
74536 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74537 index 1e23664..570a83d 100644
74538 --- a/kernel/cgroup.c
74539 +++ b/kernel/cgroup.c
74540 @@ -5543,7 +5543,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74541 struct css_set *cg = link->cg;
74542 struct task_struct *task;
74543 int count = 0;
74544 - seq_printf(seq, "css_set %p\n", cg);
74545 + seq_printf(seq, "css_set %pK\n", cg);
74546 list_for_each_entry(task, &cg->tasks, cg_list) {
74547 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74548 seq_puts(seq, " ...\n");
74549 diff --git a/kernel/compat.c b/kernel/compat.c
74550 index 36700e9..73d770c 100644
74551 --- a/kernel/compat.c
74552 +++ b/kernel/compat.c
74553 @@ -13,6 +13,7 @@
74554
74555 #include <linux/linkage.h>
74556 #include <linux/compat.h>
74557 +#include <linux/module.h>
74558 #include <linux/errno.h>
74559 #include <linux/time.h>
74560 #include <linux/signal.h>
74561 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74562 mm_segment_t oldfs;
74563 long ret;
74564
74565 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74566 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74567 oldfs = get_fs();
74568 set_fs(KERNEL_DS);
74569 ret = hrtimer_nanosleep_restart(restart);
74570 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74571 oldfs = get_fs();
74572 set_fs(KERNEL_DS);
74573 ret = hrtimer_nanosleep(&tu,
74574 - rmtp ? (struct timespec __user *)&rmt : NULL,
74575 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74576 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74577 set_fs(oldfs);
74578
74579 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74580 mm_segment_t old_fs = get_fs();
74581
74582 set_fs(KERNEL_DS);
74583 - ret = sys_sigpending((old_sigset_t __user *) &s);
74584 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74585 set_fs(old_fs);
74586 if (ret == 0)
74587 ret = put_user(s, set);
74588 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74589 mm_segment_t old_fs = get_fs();
74590
74591 set_fs(KERNEL_DS);
74592 - ret = sys_old_getrlimit(resource, &r);
74593 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74594 set_fs(old_fs);
74595
74596 if (!ret) {
74597 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74598 mm_segment_t old_fs = get_fs();
74599
74600 set_fs(KERNEL_DS);
74601 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74602 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74603 set_fs(old_fs);
74604
74605 if (ret)
74606 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74607 set_fs (KERNEL_DS);
74608 ret = sys_wait4(pid,
74609 (stat_addr ?
74610 - (unsigned int __user *) &status : NULL),
74611 - options, (struct rusage __user *) &r);
74612 + (unsigned int __force_user *) &status : NULL),
74613 + options, (struct rusage __force_user *) &r);
74614 set_fs (old_fs);
74615
74616 if (ret > 0) {
74617 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74618 memset(&info, 0, sizeof(info));
74619
74620 set_fs(KERNEL_DS);
74621 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74622 - uru ? (struct rusage __user *)&ru : NULL);
74623 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74624 + uru ? (struct rusage __force_user *)&ru : NULL);
74625 set_fs(old_fs);
74626
74627 if ((ret < 0) || (info.si_signo == 0))
74628 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74629 oldfs = get_fs();
74630 set_fs(KERNEL_DS);
74631 err = sys_timer_settime(timer_id, flags,
74632 - (struct itimerspec __user *) &newts,
74633 - (struct itimerspec __user *) &oldts);
74634 + (struct itimerspec __force_user *) &newts,
74635 + (struct itimerspec __force_user *) &oldts);
74636 set_fs(oldfs);
74637 if (!err && old && put_compat_itimerspec(old, &oldts))
74638 return -EFAULT;
74639 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74640 oldfs = get_fs();
74641 set_fs(KERNEL_DS);
74642 err = sys_timer_gettime(timer_id,
74643 - (struct itimerspec __user *) &ts);
74644 + (struct itimerspec __force_user *) &ts);
74645 set_fs(oldfs);
74646 if (!err && put_compat_itimerspec(setting, &ts))
74647 return -EFAULT;
74648 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74649 oldfs = get_fs();
74650 set_fs(KERNEL_DS);
74651 err = sys_clock_settime(which_clock,
74652 - (struct timespec __user *) &ts);
74653 + (struct timespec __force_user *) &ts);
74654 set_fs(oldfs);
74655 return err;
74656 }
74657 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74658 oldfs = get_fs();
74659 set_fs(KERNEL_DS);
74660 err = sys_clock_gettime(which_clock,
74661 - (struct timespec __user *) &ts);
74662 + (struct timespec __force_user *) &ts);
74663 set_fs(oldfs);
74664 if (!err && put_compat_timespec(&ts, tp))
74665 return -EFAULT;
74666 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74667
74668 oldfs = get_fs();
74669 set_fs(KERNEL_DS);
74670 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74671 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74672 set_fs(oldfs);
74673
74674 err = compat_put_timex(utp, &txc);
74675 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74676 oldfs = get_fs();
74677 set_fs(KERNEL_DS);
74678 err = sys_clock_getres(which_clock,
74679 - (struct timespec __user *) &ts);
74680 + (struct timespec __force_user *) &ts);
74681 set_fs(oldfs);
74682 if (!err && tp && put_compat_timespec(&ts, tp))
74683 return -EFAULT;
74684 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74685 long err;
74686 mm_segment_t oldfs;
74687 struct timespec tu;
74688 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74689 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74690
74691 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74692 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74693 oldfs = get_fs();
74694 set_fs(KERNEL_DS);
74695 err = clock_nanosleep_restart(restart);
74696 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74697 oldfs = get_fs();
74698 set_fs(KERNEL_DS);
74699 err = sys_clock_nanosleep(which_clock, flags,
74700 - (struct timespec __user *) &in,
74701 - (struct timespec __user *) &out);
74702 + (struct timespec __force_user *) &in,
74703 + (struct timespec __force_user *) &out);
74704 set_fs(oldfs);
74705
74706 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74707 diff --git a/kernel/configs.c b/kernel/configs.c
74708 index 42e8fa0..9e7406b 100644
74709 --- a/kernel/configs.c
74710 +++ b/kernel/configs.c
74711 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74712 struct proc_dir_entry *entry;
74713
74714 /* create the current config file */
74715 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74716 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74717 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74718 + &ikconfig_file_ops);
74719 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74720 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74721 + &ikconfig_file_ops);
74722 +#endif
74723 +#else
74724 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74725 &ikconfig_file_ops);
74726 +#endif
74727 +
74728 if (!entry)
74729 return -ENOMEM;
74730
74731 diff --git a/kernel/cred.c b/kernel/cred.c
74732 index e0573a4..3874e41 100644
74733 --- a/kernel/cred.c
74734 +++ b/kernel/cred.c
74735 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74736 validate_creds(cred);
74737 alter_cred_subscribers(cred, -1);
74738 put_cred(cred);
74739 +
74740 +#ifdef CONFIG_GRKERNSEC_SETXID
74741 + cred = (struct cred *) tsk->delayed_cred;
74742 + if (cred != NULL) {
74743 + tsk->delayed_cred = NULL;
74744 + validate_creds(cred);
74745 + alter_cred_subscribers(cred, -1);
74746 + put_cred(cred);
74747 + }
74748 +#endif
74749 }
74750
74751 /**
74752 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74753 * Always returns 0 thus allowing this function to be tail-called at the end
74754 * of, say, sys_setgid().
74755 */
74756 -int commit_creds(struct cred *new)
74757 +static int __commit_creds(struct cred *new)
74758 {
74759 struct task_struct *task = current;
74760 const struct cred *old = task->real_cred;
74761 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74762
74763 get_cred(new); /* we will require a ref for the subj creds too */
74764
74765 + gr_set_role_label(task, new->uid, new->gid);
74766 +
74767 /* dumpability changes */
74768 if (!uid_eq(old->euid, new->euid) ||
74769 !gid_eq(old->egid, new->egid) ||
74770 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74771 put_cred(old);
74772 return 0;
74773 }
74774 +#ifdef CONFIG_GRKERNSEC_SETXID
74775 +extern int set_user(struct cred *new);
74776 +
74777 +void gr_delayed_cred_worker(void)
74778 +{
74779 + const struct cred *new = current->delayed_cred;
74780 + struct cred *ncred;
74781 +
74782 + current->delayed_cred = NULL;
74783 +
74784 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74785 + // from doing get_cred on it when queueing this
74786 + put_cred(new);
74787 + return;
74788 + } else if (new == NULL)
74789 + return;
74790 +
74791 + ncred = prepare_creds();
74792 + if (!ncred)
74793 + goto die;
74794 + // uids
74795 + ncred->uid = new->uid;
74796 + ncred->euid = new->euid;
74797 + ncred->suid = new->suid;
74798 + ncred->fsuid = new->fsuid;
74799 + // gids
74800 + ncred->gid = new->gid;
74801 + ncred->egid = new->egid;
74802 + ncred->sgid = new->sgid;
74803 + ncred->fsgid = new->fsgid;
74804 + // groups
74805 + if (set_groups(ncred, new->group_info) < 0) {
74806 + abort_creds(ncred);
74807 + goto die;
74808 + }
74809 + // caps
74810 + ncred->securebits = new->securebits;
74811 + ncred->cap_inheritable = new->cap_inheritable;
74812 + ncred->cap_permitted = new->cap_permitted;
74813 + ncred->cap_effective = new->cap_effective;
74814 + ncred->cap_bset = new->cap_bset;
74815 +
74816 + if (set_user(ncred)) {
74817 + abort_creds(ncred);
74818 + goto die;
74819 + }
74820 +
74821 + // from doing get_cred on it when queueing this
74822 + put_cred(new);
74823 +
74824 + __commit_creds(ncred);
74825 + return;
74826 +die:
74827 + // from doing get_cred on it when queueing this
74828 + put_cred(new);
74829 + do_group_exit(SIGKILL);
74830 +}
74831 +#endif
74832 +
74833 +int commit_creds(struct cred *new)
74834 +{
74835 +#ifdef CONFIG_GRKERNSEC_SETXID
74836 + int ret;
74837 + int schedule_it = 0;
74838 + struct task_struct *t;
74839 +
74840 + /* we won't get called with tasklist_lock held for writing
74841 + and interrupts disabled as the cred struct in that case is
74842 + init_cred
74843 + */
74844 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74845 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74846 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74847 + schedule_it = 1;
74848 + }
74849 + ret = __commit_creds(new);
74850 + if (schedule_it) {
74851 + rcu_read_lock();
74852 + read_lock(&tasklist_lock);
74853 + for (t = next_thread(current); t != current;
74854 + t = next_thread(t)) {
74855 + if (t->delayed_cred == NULL) {
74856 + t->delayed_cred = get_cred(new);
74857 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74858 + set_tsk_need_resched(t);
74859 + }
74860 + }
74861 + read_unlock(&tasklist_lock);
74862 + rcu_read_unlock();
74863 + }
74864 + return ret;
74865 +#else
74866 + return __commit_creds(new);
74867 +#endif
74868 +}
74869 +
74870 EXPORT_SYMBOL(commit_creds);
74871
74872 /**
74873 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
74874 index 9a61738..c5c8f3a 100644
74875 --- a/kernel/debug/debug_core.c
74876 +++ b/kernel/debug/debug_core.c
74877 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
74878 */
74879 static atomic_t masters_in_kgdb;
74880 static atomic_t slaves_in_kgdb;
74881 -static atomic_t kgdb_break_tasklet_var;
74882 +static atomic_unchecked_t kgdb_break_tasklet_var;
74883 atomic_t kgdb_setting_breakpoint;
74884
74885 struct task_struct *kgdb_usethread;
74886 @@ -132,7 +132,7 @@ int kgdb_single_step;
74887 static pid_t kgdb_sstep_pid;
74888
74889 /* to keep track of the CPU which is doing the single stepping*/
74890 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74891 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74892
74893 /*
74894 * If you are debugging a problem where roundup (the collection of
74895 @@ -540,7 +540,7 @@ return_normal:
74896 * kernel will only try for the value of sstep_tries before
74897 * giving up and continuing on.
74898 */
74899 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
74900 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
74901 (kgdb_info[cpu].task &&
74902 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
74903 atomic_set(&kgdb_active, -1);
74904 @@ -634,8 +634,8 @@ cpu_master_loop:
74905 }
74906
74907 kgdb_restore:
74908 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
74909 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
74910 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
74911 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
74912 if (kgdb_info[sstep_cpu].task)
74913 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
74914 else
74915 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
74916 static void kgdb_tasklet_bpt(unsigned long ing)
74917 {
74918 kgdb_breakpoint();
74919 - atomic_set(&kgdb_break_tasklet_var, 0);
74920 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
74921 }
74922
74923 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
74924
74925 void kgdb_schedule_breakpoint(void)
74926 {
74927 - if (atomic_read(&kgdb_break_tasklet_var) ||
74928 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
74929 atomic_read(&kgdb_active) != -1 ||
74930 atomic_read(&kgdb_setting_breakpoint))
74931 return;
74932 - atomic_inc(&kgdb_break_tasklet_var);
74933 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
74934 tasklet_schedule(&kgdb_tasklet_breakpoint);
74935 }
74936 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
74937 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
74938 index 8875254..7cf4928 100644
74939 --- a/kernel/debug/kdb/kdb_main.c
74940 +++ b/kernel/debug/kdb/kdb_main.c
74941 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
74942 continue;
74943
74944 kdb_printf("%-20s%8u 0x%p ", mod->name,
74945 - mod->core_size, (void *)mod);
74946 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
74947 #ifdef CONFIG_MODULE_UNLOAD
74948 kdb_printf("%4ld ", module_refcount(mod));
74949 #endif
74950 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
74951 kdb_printf(" (Loading)");
74952 else
74953 kdb_printf(" (Live)");
74954 - kdb_printf(" 0x%p", mod->module_core);
74955 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
74956
74957 #ifdef CONFIG_MODULE_UNLOAD
74958 {
74959 diff --git a/kernel/events/core.c b/kernel/events/core.c
74960 index 7b6646a..3cb1135 100644
74961 --- a/kernel/events/core.c
74962 +++ b/kernel/events/core.c
74963 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
74964 return 0;
74965 }
74966
74967 -static atomic64_t perf_event_id;
74968 +static atomic64_unchecked_t perf_event_id;
74969
74970 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
74971 enum event_type_t event_type);
74972 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
74973
74974 static inline u64 perf_event_count(struct perf_event *event)
74975 {
74976 - return local64_read(&event->count) + atomic64_read(&event->child_count);
74977 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
74978 }
74979
74980 static u64 perf_event_read(struct perf_event *event)
74981 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
74982 mutex_lock(&event->child_mutex);
74983 total += perf_event_read(event);
74984 *enabled += event->total_time_enabled +
74985 - atomic64_read(&event->child_total_time_enabled);
74986 + atomic64_read_unchecked(&event->child_total_time_enabled);
74987 *running += event->total_time_running +
74988 - atomic64_read(&event->child_total_time_running);
74989 + atomic64_read_unchecked(&event->child_total_time_running);
74990
74991 list_for_each_entry(child, &event->child_list, child_list) {
74992 total += perf_event_read(child);
74993 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
74994 userpg->offset -= local64_read(&event->hw.prev_count);
74995
74996 userpg->time_enabled = enabled +
74997 - atomic64_read(&event->child_total_time_enabled);
74998 + atomic64_read_unchecked(&event->child_total_time_enabled);
74999
75000 userpg->time_running = running +
75001 - atomic64_read(&event->child_total_time_running);
75002 + atomic64_read_unchecked(&event->child_total_time_running);
75003
75004 arch_perf_update_userpage(userpg, now);
75005
75006 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75007 values[n++] = perf_event_count(event);
75008 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75009 values[n++] = enabled +
75010 - atomic64_read(&event->child_total_time_enabled);
75011 + atomic64_read_unchecked(&event->child_total_time_enabled);
75012 }
75013 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75014 values[n++] = running +
75015 - atomic64_read(&event->child_total_time_running);
75016 + atomic64_read_unchecked(&event->child_total_time_running);
75017 }
75018 if (read_format & PERF_FORMAT_ID)
75019 values[n++] = primary_event_id(event);
75020 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75021 * need to add enough zero bytes after the string to handle
75022 * the 64bit alignment we do later.
75023 */
75024 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75025 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75026 if (!buf) {
75027 name = strncpy(tmp, "//enomem", sizeof(tmp));
75028 goto got_name;
75029 }
75030 - name = d_path(&file->f_path, buf, PATH_MAX);
75031 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75032 if (IS_ERR(name)) {
75033 name = strncpy(tmp, "//toolong", sizeof(tmp));
75034 goto got_name;
75035 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75036 event->parent = parent_event;
75037
75038 event->ns = get_pid_ns(task_active_pid_ns(current));
75039 - event->id = atomic64_inc_return(&perf_event_id);
75040 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75041
75042 event->state = PERF_EVENT_STATE_INACTIVE;
75043
75044 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
75045 /*
75046 * Add back the child's count to the parent's count:
75047 */
75048 - atomic64_add(child_val, &parent_event->child_count);
75049 - atomic64_add(child_event->total_time_enabled,
75050 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75051 + atomic64_add_unchecked(child_event->total_time_enabled,
75052 &parent_event->child_total_time_enabled);
75053 - atomic64_add(child_event->total_time_running,
75054 + atomic64_add_unchecked(child_event->total_time_running,
75055 &parent_event->child_total_time_running);
75056
75057 /*
75058 diff --git a/kernel/exit.c b/kernel/exit.c
75059 index b4df219..f13c02d 100644
75060 --- a/kernel/exit.c
75061 +++ b/kernel/exit.c
75062 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
75063 struct task_struct *leader;
75064 int zap_leader;
75065 repeat:
75066 +#ifdef CONFIG_NET
75067 + gr_del_task_from_ip_table(p);
75068 +#endif
75069 +
75070 /* don't need to get the RCU readlock here - the process is dead and
75071 * can't be modifying its own credentials. But shut RCU-lockdep up */
75072 rcu_read_lock();
75073 @@ -338,7 +342,7 @@ int allow_signal(int sig)
75074 * know it'll be handled, so that they don't get converted to
75075 * SIGKILL or just silently dropped.
75076 */
75077 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75078 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75079 recalc_sigpending();
75080 spin_unlock_irq(&current->sighand->siglock);
75081 return 0;
75082 @@ -708,6 +712,8 @@ void do_exit(long code)
75083 struct task_struct *tsk = current;
75084 int group_dead;
75085
75086 + set_fs(USER_DS);
75087 +
75088 profile_task_exit(tsk);
75089
75090 WARN_ON(blk_needs_flush_plug(tsk));
75091 @@ -724,7 +730,6 @@ void do_exit(long code)
75092 * mm_release()->clear_child_tid() from writing to a user-controlled
75093 * kernel address.
75094 */
75095 - set_fs(USER_DS);
75096
75097 ptrace_event(PTRACE_EVENT_EXIT, code);
75098
75099 @@ -783,6 +788,9 @@ void do_exit(long code)
75100 tsk->exit_code = code;
75101 taskstats_exit(tsk, group_dead);
75102
75103 + gr_acl_handle_psacct(tsk, code);
75104 + gr_acl_handle_exit();
75105 +
75106 exit_mm(tsk);
75107
75108 if (group_dead)
75109 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75110 * Take down every thread in the group. This is called by fatal signals
75111 * as well as by sys_exit_group (below).
75112 */
75113 -void
75114 +__noreturn void
75115 do_group_exit(int exit_code)
75116 {
75117 struct signal_struct *sig = current->signal;
75118 diff --git a/kernel/fork.c b/kernel/fork.c
75119 index 5630e52..0cee608 100644
75120 --- a/kernel/fork.c
75121 +++ b/kernel/fork.c
75122 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75123 *stackend = STACK_END_MAGIC; /* for overflow detection */
75124
75125 #ifdef CONFIG_CC_STACKPROTECTOR
75126 - tsk->stack_canary = get_random_int();
75127 + tsk->stack_canary = pax_get_random_long();
75128 #endif
75129
75130 /*
75131 @@ -344,13 +344,81 @@ free_tsk:
75132 }
75133
75134 #ifdef CONFIG_MMU
75135 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75136 +{
75137 + struct vm_area_struct *tmp;
75138 + unsigned long charge;
75139 + struct mempolicy *pol;
75140 + struct file *file;
75141 +
75142 + charge = 0;
75143 + if (mpnt->vm_flags & VM_ACCOUNT) {
75144 + unsigned long len = vma_pages(mpnt);
75145 +
75146 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75147 + goto fail_nomem;
75148 + charge = len;
75149 + }
75150 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75151 + if (!tmp)
75152 + goto fail_nomem;
75153 + *tmp = *mpnt;
75154 + tmp->vm_mm = mm;
75155 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75156 + pol = mpol_dup(vma_policy(mpnt));
75157 + if (IS_ERR(pol))
75158 + goto fail_nomem_policy;
75159 + vma_set_policy(tmp, pol);
75160 + if (anon_vma_fork(tmp, mpnt))
75161 + goto fail_nomem_anon_vma_fork;
75162 + tmp->vm_flags &= ~VM_LOCKED;
75163 + tmp->vm_next = tmp->vm_prev = NULL;
75164 + tmp->vm_mirror = NULL;
75165 + file = tmp->vm_file;
75166 + if (file) {
75167 + struct inode *inode = file->f_path.dentry->d_inode;
75168 + struct address_space *mapping = file->f_mapping;
75169 +
75170 + get_file(file);
75171 + if (tmp->vm_flags & VM_DENYWRITE)
75172 + atomic_dec(&inode->i_writecount);
75173 + mutex_lock(&mapping->i_mmap_mutex);
75174 + if (tmp->vm_flags & VM_SHARED)
75175 + mapping->i_mmap_writable++;
75176 + flush_dcache_mmap_lock(mapping);
75177 + /* insert tmp into the share list, just after mpnt */
75178 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75179 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75180 + else
75181 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75182 + flush_dcache_mmap_unlock(mapping);
75183 + mutex_unlock(&mapping->i_mmap_mutex);
75184 + }
75185 +
75186 + /*
75187 + * Clear hugetlb-related page reserves for children. This only
75188 + * affects MAP_PRIVATE mappings. Faults generated by the child
75189 + * are not guaranteed to succeed, even if read-only
75190 + */
75191 + if (is_vm_hugetlb_page(tmp))
75192 + reset_vma_resv_huge_pages(tmp);
75193 +
75194 + return tmp;
75195 +
75196 +fail_nomem_anon_vma_fork:
75197 + mpol_put(pol);
75198 +fail_nomem_policy:
75199 + kmem_cache_free(vm_area_cachep, tmp);
75200 +fail_nomem:
75201 + vm_unacct_memory(charge);
75202 + return NULL;
75203 +}
75204 +
75205 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75206 {
75207 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75208 struct rb_node **rb_link, *rb_parent;
75209 int retval;
75210 - unsigned long charge;
75211 - struct mempolicy *pol;
75212
75213 uprobe_start_dup_mmap();
75214 down_write(&oldmm->mmap_sem);
75215 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75216 mm->locked_vm = 0;
75217 mm->mmap = NULL;
75218 mm->mmap_cache = NULL;
75219 - mm->free_area_cache = oldmm->mmap_base;
75220 - mm->cached_hole_size = ~0UL;
75221 + mm->free_area_cache = oldmm->free_area_cache;
75222 + mm->cached_hole_size = oldmm->cached_hole_size;
75223 mm->map_count = 0;
75224 cpumask_clear(mm_cpumask(mm));
75225 mm->mm_rb = RB_ROOT;
75226 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75227
75228 prev = NULL;
75229 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75230 - struct file *file;
75231 -
75232 if (mpnt->vm_flags & VM_DONTCOPY) {
75233 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75234 -vma_pages(mpnt));
75235 continue;
75236 }
75237 - charge = 0;
75238 - if (mpnt->vm_flags & VM_ACCOUNT) {
75239 - unsigned long len = vma_pages(mpnt);
75240 -
75241 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75242 - goto fail_nomem;
75243 - charge = len;
75244 - }
75245 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75246 - if (!tmp)
75247 - goto fail_nomem;
75248 - *tmp = *mpnt;
75249 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75250 - pol = mpol_dup(vma_policy(mpnt));
75251 - retval = PTR_ERR(pol);
75252 - if (IS_ERR(pol))
75253 - goto fail_nomem_policy;
75254 - vma_set_policy(tmp, pol);
75255 - tmp->vm_mm = mm;
75256 - if (anon_vma_fork(tmp, mpnt))
75257 - goto fail_nomem_anon_vma_fork;
75258 - tmp->vm_flags &= ~VM_LOCKED;
75259 - tmp->vm_next = tmp->vm_prev = NULL;
75260 - file = tmp->vm_file;
75261 - if (file) {
75262 - struct inode *inode = file->f_path.dentry->d_inode;
75263 - struct address_space *mapping = file->f_mapping;
75264 -
75265 - get_file(file);
75266 - if (tmp->vm_flags & VM_DENYWRITE)
75267 - atomic_dec(&inode->i_writecount);
75268 - mutex_lock(&mapping->i_mmap_mutex);
75269 - if (tmp->vm_flags & VM_SHARED)
75270 - mapping->i_mmap_writable++;
75271 - flush_dcache_mmap_lock(mapping);
75272 - /* insert tmp into the share list, just after mpnt */
75273 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75274 - vma_nonlinear_insert(tmp,
75275 - &mapping->i_mmap_nonlinear);
75276 - else
75277 - vma_interval_tree_insert_after(tmp, mpnt,
75278 - &mapping->i_mmap);
75279 - flush_dcache_mmap_unlock(mapping);
75280 - mutex_unlock(&mapping->i_mmap_mutex);
75281 + tmp = dup_vma(mm, oldmm, mpnt);
75282 + if (!tmp) {
75283 + retval = -ENOMEM;
75284 + goto out;
75285 }
75286
75287 /*
75288 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75289 if (retval)
75290 goto out;
75291 }
75292 +
75293 +#ifdef CONFIG_PAX_SEGMEXEC
75294 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75295 + struct vm_area_struct *mpnt_m;
75296 +
75297 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75298 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75299 +
75300 + if (!mpnt->vm_mirror)
75301 + continue;
75302 +
75303 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75304 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75305 + mpnt->vm_mirror = mpnt_m;
75306 + } else {
75307 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75308 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75309 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75310 + mpnt->vm_mirror->vm_mirror = mpnt;
75311 + }
75312 + }
75313 + BUG_ON(mpnt_m);
75314 + }
75315 +#endif
75316 +
75317 /* a new mm has just been created */
75318 arch_dup_mmap(oldmm, mm);
75319 retval = 0;
75320 @@ -472,14 +523,6 @@ out:
75321 up_write(&oldmm->mmap_sem);
75322 uprobe_end_dup_mmap();
75323 return retval;
75324 -fail_nomem_anon_vma_fork:
75325 - mpol_put(pol);
75326 -fail_nomem_policy:
75327 - kmem_cache_free(vm_area_cachep, tmp);
75328 -fail_nomem:
75329 - retval = -ENOMEM;
75330 - vm_unacct_memory(charge);
75331 - goto out;
75332 }
75333
75334 static inline int mm_alloc_pgd(struct mm_struct *mm)
75335 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75336 return ERR_PTR(err);
75337
75338 mm = get_task_mm(task);
75339 - if (mm && mm != current->mm &&
75340 - !ptrace_may_access(task, mode)) {
75341 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75342 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75343 mmput(mm);
75344 mm = ERR_PTR(-EACCES);
75345 }
75346 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75347 spin_unlock(&fs->lock);
75348 return -EAGAIN;
75349 }
75350 - fs->users++;
75351 + atomic_inc(&fs->users);
75352 spin_unlock(&fs->lock);
75353 return 0;
75354 }
75355 tsk->fs = copy_fs_struct(fs);
75356 if (!tsk->fs)
75357 return -ENOMEM;
75358 + /* Carry through gr_chroot_dentry and is_chrooted instead
75359 + of recomputing it here. Already copied when the task struct
75360 + is duplicated. This allows pivot_root to not be treated as
75361 + a chroot
75362 + */
75363 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75364 +
75365 return 0;
75366 }
75367
75368 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75369 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75370 #endif
75371 retval = -EAGAIN;
75372 +
75373 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75374 +
75375 if (atomic_read(&p->real_cred->user->processes) >=
75376 task_rlimit(p, RLIMIT_NPROC)) {
75377 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75378 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75379 goto bad_fork_free_pid;
75380 }
75381
75382 + /* synchronizes with gr_set_acls()
75383 + we need to call this past the point of no return for fork()
75384 + */
75385 + gr_copy_label(p);
75386 +
75387 if (clone_flags & CLONE_THREAD) {
75388 current->signal->nr_threads++;
75389 atomic_inc(&current->signal->live);
75390 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
75391 bad_fork_free:
75392 free_task(p);
75393 fork_out:
75394 + gr_log_forkfail(retval);
75395 +
75396 return ERR_PTR(retval);
75397 }
75398
75399 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
75400 return -EINVAL;
75401 }
75402
75403 +#ifdef CONFIG_GRKERNSEC
75404 + if (clone_flags & CLONE_NEWUSER) {
75405 + /*
75406 + * This doesn't really inspire confidence:
75407 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75408 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75409 + * Increases kernel attack surface in areas developers
75410 + * previously cared little about ("low importance due
75411 + * to requiring "root" capability")
75412 + * To be removed when this code receives *proper* review
75413 + */
75414 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75415 + !capable(CAP_SETGID))
75416 + return -EPERM;
75417 + }
75418 +#endif
75419 +
75420 /*
75421 * Determine whether and which event to report to ptracer. When
75422 * called from kernel_thread or CLONE_UNTRACED is explicitly
75423 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
75424 if (clone_flags & CLONE_PARENT_SETTID)
75425 put_user(nr, parent_tidptr);
75426
75427 + gr_handle_brute_check();
75428 +
75429 if (clone_flags & CLONE_VFORK) {
75430 p->vfork_done = &vfork;
75431 init_completion(&vfork);
75432 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75433 return 0;
75434
75435 /* don't need lock here; in the worst case we'll do useless copy */
75436 - if (fs->users == 1)
75437 + if (atomic_read(&fs->users) == 1)
75438 return 0;
75439
75440 *new_fsp = copy_fs_struct(fs);
75441 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75442 fs = current->fs;
75443 spin_lock(&fs->lock);
75444 current->fs = new_fs;
75445 - if (--fs->users)
75446 + gr_set_chroot_entries(current, &current->fs->root);
75447 + if (atomic_dec_return(&fs->users))
75448 new_fs = NULL;
75449 else
75450 new_fs = fs;
75451 diff --git a/kernel/futex.c b/kernel/futex.c
75452 index 8879430..31696f1 100644
75453 --- a/kernel/futex.c
75454 +++ b/kernel/futex.c
75455 @@ -54,6 +54,7 @@
75456 #include <linux/mount.h>
75457 #include <linux/pagemap.h>
75458 #include <linux/syscalls.h>
75459 +#include <linux/ptrace.h>
75460 #include <linux/signal.h>
75461 #include <linux/export.h>
75462 #include <linux/magic.h>
75463 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75464 struct page *page, *page_head;
75465 int err, ro = 0;
75466
75467 +#ifdef CONFIG_PAX_SEGMEXEC
75468 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75469 + return -EFAULT;
75470 +#endif
75471 +
75472 /*
75473 * The futex address must be "naturally" aligned.
75474 */
75475 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
75476 {
75477 u32 curval;
75478 int i;
75479 + mm_segment_t oldfs;
75480
75481 /*
75482 * This will fail and we want it. Some arch implementations do
75483 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
75484 * implementation, the non-functional ones will return
75485 * -ENOSYS.
75486 */
75487 + oldfs = get_fs();
75488 + set_fs(USER_DS);
75489 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75490 futex_cmpxchg_enabled = 1;
75491 + set_fs(oldfs);
75492
75493 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75494 plist_head_init(&futex_queues[i].chain);
75495 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75496 index a9642d5..51eb98c 100644
75497 --- a/kernel/futex_compat.c
75498 +++ b/kernel/futex_compat.c
75499 @@ -31,7 +31,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75500 return 0;
75501 }
75502
75503 -static void __user *futex_uaddr(struct robust_list __user *entry,
75504 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75505 compat_long_t futex_offset)
75506 {
75507 compat_uptr_t base = ptr_to_compat(entry);
75508 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75509 index 9b22d03..6295b62 100644
75510 --- a/kernel/gcov/base.c
75511 +++ b/kernel/gcov/base.c
75512 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75513 }
75514
75515 #ifdef CONFIG_MODULES
75516 -static inline int within(void *addr, void *start, unsigned long size)
75517 -{
75518 - return ((addr >= start) && (addr < start + size));
75519 -}
75520 -
75521 /* Update list and generate events when modules are unloaded. */
75522 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75523 void *data)
75524 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75525 prev = NULL;
75526 /* Remove entries located in module from linked list. */
75527 for (info = gcov_info_head; info; info = info->next) {
75528 - if (within(info, mod->module_core, mod->core_size)) {
75529 + if (within_module_core_rw((unsigned long)info, mod)) {
75530 if (prev)
75531 prev->next = info->next;
75532 else
75533 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75534 index cdd5607..c3fc919 100644
75535 --- a/kernel/hrtimer.c
75536 +++ b/kernel/hrtimer.c
75537 @@ -1407,7 +1407,7 @@ void hrtimer_peek_ahead_timers(void)
75538 local_irq_restore(flags);
75539 }
75540
75541 -static void run_hrtimer_softirq(struct softirq_action *h)
75542 +static void run_hrtimer_softirq(void)
75543 {
75544 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75545
75546 @@ -1751,7 +1751,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75547 return NOTIFY_OK;
75548 }
75549
75550 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75551 +static struct notifier_block hrtimers_nb = {
75552 .notifier_call = hrtimer_cpu_notify,
75553 };
75554
75555 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75556 index 60f48fa..7f3a770 100644
75557 --- a/kernel/jump_label.c
75558 +++ b/kernel/jump_label.c
75559 @@ -13,6 +13,7 @@
75560 #include <linux/sort.h>
75561 #include <linux/err.h>
75562 #include <linux/static_key.h>
75563 +#include <linux/mm.h>
75564
75565 #ifdef HAVE_JUMP_LABEL
75566
75567 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75568
75569 size = (((unsigned long)stop - (unsigned long)start)
75570 / sizeof(struct jump_entry));
75571 + pax_open_kernel();
75572 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75573 + pax_close_kernel();
75574 }
75575
75576 static void jump_label_update(struct static_key *key, int enable);
75577 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75578 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75579 struct jump_entry *iter;
75580
75581 + pax_open_kernel();
75582 for (iter = iter_start; iter < iter_stop; iter++) {
75583 if (within_module_init(iter->code, mod))
75584 iter->code = 0;
75585 }
75586 + pax_close_kernel();
75587 }
75588
75589 static int
75590 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75591 index 2169fee..706ccca 100644
75592 --- a/kernel/kallsyms.c
75593 +++ b/kernel/kallsyms.c
75594 @@ -11,6 +11,9 @@
75595 * Changed the compression method from stem compression to "table lookup"
75596 * compression (see scripts/kallsyms.c for a more complete description)
75597 */
75598 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75599 +#define __INCLUDED_BY_HIDESYM 1
75600 +#endif
75601 #include <linux/kallsyms.h>
75602 #include <linux/module.h>
75603 #include <linux/init.h>
75604 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75605
75606 static inline int is_kernel_inittext(unsigned long addr)
75607 {
75608 + if (system_state != SYSTEM_BOOTING)
75609 + return 0;
75610 +
75611 if (addr >= (unsigned long)_sinittext
75612 && addr <= (unsigned long)_einittext)
75613 return 1;
75614 return 0;
75615 }
75616
75617 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75618 +#ifdef CONFIG_MODULES
75619 +static inline int is_module_text(unsigned long addr)
75620 +{
75621 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75622 + return 1;
75623 +
75624 + addr = ktla_ktva(addr);
75625 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75626 +}
75627 +#else
75628 +static inline int is_module_text(unsigned long addr)
75629 +{
75630 + return 0;
75631 +}
75632 +#endif
75633 +#endif
75634 +
75635 static inline int is_kernel_text(unsigned long addr)
75636 {
75637 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75638 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75639
75640 static inline int is_kernel(unsigned long addr)
75641 {
75642 +
75643 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75644 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75645 + return 1;
75646 +
75647 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75648 +#else
75649 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75650 +#endif
75651 +
75652 return 1;
75653 return in_gate_area_no_mm(addr);
75654 }
75655
75656 static int is_ksym_addr(unsigned long addr)
75657 {
75658 +
75659 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75660 + if (is_module_text(addr))
75661 + return 0;
75662 +#endif
75663 +
75664 if (all_var)
75665 return is_kernel(addr);
75666
75667 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75668
75669 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75670 {
75671 - iter->name[0] = '\0';
75672 iter->nameoff = get_symbol_offset(new_pos);
75673 iter->pos = new_pos;
75674 }
75675 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75676 {
75677 struct kallsym_iter *iter = m->private;
75678
75679 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75680 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75681 + return 0;
75682 +#endif
75683 +
75684 /* Some debugging symbols have no name. Ignore them. */
75685 if (!iter->name[0])
75686 return 0;
75687 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75688 */
75689 type = iter->exported ? toupper(iter->type) :
75690 tolower(iter->type);
75691 +
75692 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75693 type, iter->name, iter->module_name);
75694 } else
75695 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75696 struct kallsym_iter *iter;
75697 int ret;
75698
75699 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75700 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75701 if (!iter)
75702 return -ENOMEM;
75703 reset_iter(iter, 0);
75704 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75705 index e30ac0f..3528cac 100644
75706 --- a/kernel/kcmp.c
75707 +++ b/kernel/kcmp.c
75708 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75709 struct task_struct *task1, *task2;
75710 int ret;
75711
75712 +#ifdef CONFIG_GRKERNSEC
75713 + return -ENOSYS;
75714 +#endif
75715 +
75716 rcu_read_lock();
75717
75718 /*
75719 diff --git a/kernel/kexec.c b/kernel/kexec.c
75720 index 5e4bd78..00c5b91 100644
75721 --- a/kernel/kexec.c
75722 +++ b/kernel/kexec.c
75723 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75724 unsigned long flags)
75725 {
75726 struct compat_kexec_segment in;
75727 - struct kexec_segment out, __user *ksegments;
75728 + struct kexec_segment out;
75729 + struct kexec_segment __user *ksegments;
75730 unsigned long i, result;
75731
75732 /* Don't allow clients that don't understand the native
75733 diff --git a/kernel/kmod.c b/kernel/kmod.c
75734 index 0023a87..9c0c068 100644
75735 --- a/kernel/kmod.c
75736 +++ b/kernel/kmod.c
75737 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75738 kfree(info->argv);
75739 }
75740
75741 -static int call_modprobe(char *module_name, int wait)
75742 +static int call_modprobe(char *module_name, char *module_param, int wait)
75743 {
75744 static char *envp[] = {
75745 "HOME=/",
75746 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
75747 NULL
75748 };
75749
75750 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75751 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75752 if (!argv)
75753 goto out;
75754
75755 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
75756 argv[1] = "-q";
75757 argv[2] = "--";
75758 argv[3] = module_name; /* check free_modprobe_argv() */
75759 - argv[4] = NULL;
75760 + argv[4] = module_param;
75761 + argv[5] = NULL;
75762
75763 return call_usermodehelper_fns(modprobe_path, argv, envp,
75764 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75765 @@ -120,9 +121,8 @@ out:
75766 * If module auto-loading support is disabled then this function
75767 * becomes a no-operation.
75768 */
75769 -int __request_module(bool wait, const char *fmt, ...)
75770 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75771 {
75772 - va_list args;
75773 char module_name[MODULE_NAME_LEN];
75774 unsigned int max_modprobes;
75775 int ret;
75776 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
75777 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
75778 static int kmod_loop_msg;
75779
75780 - va_start(args, fmt);
75781 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75782 - va_end(args);
75783 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75784 if (ret >= MODULE_NAME_LEN)
75785 return -ENAMETOOLONG;
75786
75787 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
75788 if (ret)
75789 return ret;
75790
75791 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75792 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75793 + /* hack to workaround consolekit/udisks stupidity */
75794 + read_lock(&tasklist_lock);
75795 + if (!strcmp(current->comm, "mount") &&
75796 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75797 + read_unlock(&tasklist_lock);
75798 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75799 + return -EPERM;
75800 + }
75801 + read_unlock(&tasklist_lock);
75802 + }
75803 +#endif
75804 +
75805 /* If modprobe needs a service that is in a module, we get a recursive
75806 * loop. Limit the number of running kmod threads to max_threads/2 or
75807 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75808 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
75809
75810 trace_module_request(module_name, wait, _RET_IP_);
75811
75812 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75813 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75814
75815 atomic_dec(&kmod_concurrent);
75816 return ret;
75817 }
75818 +
75819 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75820 +{
75821 + va_list args;
75822 + int ret;
75823 +
75824 + va_start(args, fmt);
75825 + ret = ____request_module(wait, module_param, fmt, args);
75826 + va_end(args);
75827 +
75828 + return ret;
75829 +}
75830 +
75831 +int __request_module(bool wait, const char *fmt, ...)
75832 +{
75833 + va_list args;
75834 + int ret;
75835 +
75836 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75837 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75838 + char module_param[MODULE_NAME_LEN];
75839 +
75840 + memset(module_param, 0, sizeof(module_param));
75841 +
75842 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75843 +
75844 + va_start(args, fmt);
75845 + ret = ____request_module(wait, module_param, fmt, args);
75846 + va_end(args);
75847 +
75848 + return ret;
75849 + }
75850 +#endif
75851 +
75852 + va_start(args, fmt);
75853 + ret = ____request_module(wait, NULL, fmt, args);
75854 + va_end(args);
75855 +
75856 + return ret;
75857 +}
75858 +
75859 EXPORT_SYMBOL(__request_module);
75860 #endif /* CONFIG_MODULES */
75861
75862 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
75863 *
75864 * Thus the __user pointer cast is valid here.
75865 */
75866 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75867 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75868
75869 /*
75870 * If ret is 0, either ____call_usermodehelper failed and the
75871 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
75872 static int proc_cap_handler(struct ctl_table *table, int write,
75873 void __user *buffer, size_t *lenp, loff_t *ppos)
75874 {
75875 - struct ctl_table t;
75876 + ctl_table_no_const t;
75877 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
75878 kernel_cap_t new_cap;
75879 int err, i;
75880 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
75881 index 098f396..fe85ff1 100644
75882 --- a/kernel/kprobes.c
75883 +++ b/kernel/kprobes.c
75884 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
75885 * kernel image and loaded module images reside. This is required
75886 * so x86_64 can correctly handle the %rip-relative fixups.
75887 */
75888 - kip->insns = module_alloc(PAGE_SIZE);
75889 + kip->insns = module_alloc_exec(PAGE_SIZE);
75890 if (!kip->insns) {
75891 kfree(kip);
75892 return NULL;
75893 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
75894 */
75895 if (!list_is_singular(&kip->list)) {
75896 list_del(&kip->list);
75897 - module_free(NULL, kip->insns);
75898 + module_free_exec(NULL, kip->insns);
75899 kfree(kip);
75900 }
75901 return 1;
75902 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
75903 {
75904 int i, err = 0;
75905 unsigned long offset = 0, size = 0;
75906 - char *modname, namebuf[128];
75907 + char *modname, namebuf[KSYM_NAME_LEN];
75908 const char *symbol_name;
75909 void *addr;
75910 struct kprobe_blackpoint *kb;
75911 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
75912 kprobe_type = "k";
75913
75914 if (sym)
75915 - seq_printf(pi, "%p %s %s+0x%x %s ",
75916 + seq_printf(pi, "%pK %s %s+0x%x %s ",
75917 p->addr, kprobe_type, sym, offset,
75918 (modname ? modname : " "));
75919 else
75920 - seq_printf(pi, "%p %s %p ",
75921 + seq_printf(pi, "%pK %s %pK ",
75922 p->addr, kprobe_type, p->addr);
75923
75924 if (!pp)
75925 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
75926 const char *sym = NULL;
75927 unsigned int i = *(loff_t *) v;
75928 unsigned long offset = 0;
75929 - char *modname, namebuf[128];
75930 + char *modname, namebuf[KSYM_NAME_LEN];
75931
75932 head = &kprobe_table[i];
75933 preempt_disable();
75934 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
75935 index 6ada93c..dce7d5d 100644
75936 --- a/kernel/ksysfs.c
75937 +++ b/kernel/ksysfs.c
75938 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
75939 {
75940 if (count+1 > UEVENT_HELPER_PATH_LEN)
75941 return -ENOENT;
75942 + if (!capable(CAP_SYS_ADMIN))
75943 + return -EPERM;
75944 memcpy(uevent_helper, buf, count);
75945 uevent_helper[count] = '\0';
75946 if (count && uevent_helper[count-1] == '\n')
75947 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
75948 return count;
75949 }
75950
75951 -static struct bin_attribute notes_attr = {
75952 +static bin_attribute_no_const notes_attr __read_only = {
75953 .attr = {
75954 .name = "notes",
75955 .mode = S_IRUGO,
75956 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
75957 index 7981e5b..7f2105c 100644
75958 --- a/kernel/lockdep.c
75959 +++ b/kernel/lockdep.c
75960 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
75961 end = (unsigned long) &_end,
75962 addr = (unsigned long) obj;
75963
75964 +#ifdef CONFIG_PAX_KERNEXEC
75965 + start = ktla_ktva(start);
75966 +#endif
75967 +
75968 /*
75969 * static variable?
75970 */
75971 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
75972 if (!static_obj(lock->key)) {
75973 debug_locks_off();
75974 printk("INFO: trying to register non-static key.\n");
75975 + printk("lock:%pS key:%pS.\n", lock, lock->key);
75976 printk("the code is fine but needs lockdep annotation.\n");
75977 printk("turning off the locking correctness validator.\n");
75978 dump_stack();
75979 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
75980 if (!class)
75981 return 0;
75982 }
75983 - atomic_inc((atomic_t *)&class->ops);
75984 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
75985 if (very_verbose(class)) {
75986 printk("\nacquire class [%p] %s", class->key, class->name);
75987 if (class->name_version > 1)
75988 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
75989 index b2c71c5..7b88d63 100644
75990 --- a/kernel/lockdep_proc.c
75991 +++ b/kernel/lockdep_proc.c
75992 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
75993 return 0;
75994 }
75995
75996 - seq_printf(m, "%p", class->key);
75997 + seq_printf(m, "%pK", class->key);
75998 #ifdef CONFIG_DEBUG_LOCKDEP
75999 seq_printf(m, " OPS:%8ld", class->ops);
76000 #endif
76001 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76002
76003 list_for_each_entry(entry, &class->locks_after, entry) {
76004 if (entry->distance == 1) {
76005 - seq_printf(m, " -> [%p] ", entry->class->key);
76006 + seq_printf(m, " -> [%pK] ", entry->class->key);
76007 print_name(m, entry->class);
76008 seq_puts(m, "\n");
76009 }
76010 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76011 if (!class->key)
76012 continue;
76013
76014 - seq_printf(m, "[%p] ", class->key);
76015 + seq_printf(m, "[%pK] ", class->key);
76016 print_name(m, class);
76017 seq_puts(m, "\n");
76018 }
76019 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76020 if (!i)
76021 seq_line(m, '-', 40-namelen, namelen);
76022
76023 - snprintf(ip, sizeof(ip), "[<%p>]",
76024 + snprintf(ip, sizeof(ip), "[<%pK>]",
76025 (void *)class->contention_point[i]);
76026 seq_printf(m, "%40s %14lu %29s %pS\n",
76027 name, stats->contention_point[i],
76028 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76029 if (!i)
76030 seq_line(m, '-', 40-namelen, namelen);
76031
76032 - snprintf(ip, sizeof(ip), "[<%p>]",
76033 + snprintf(ip, sizeof(ip), "[<%pK>]",
76034 (void *)class->contending_point[i]);
76035 seq_printf(m, "%40s %14lu %29s %pS\n",
76036 name, stats->contending_point[i],
76037 diff --git a/kernel/module.c b/kernel/module.c
76038 index eab0827..f488603 100644
76039 --- a/kernel/module.c
76040 +++ b/kernel/module.c
76041 @@ -61,6 +61,7 @@
76042 #include <linux/pfn.h>
76043 #include <linux/bsearch.h>
76044 #include <linux/fips.h>
76045 +#include <linux/grsecurity.h>
76046 #include <uapi/linux/module.h>
76047 #include "module-internal.h"
76048
76049 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76050
76051 /* Bounds of module allocation, for speeding __module_address.
76052 * Protected by module_mutex. */
76053 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76054 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76055 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76056
76057 int register_module_notifier(struct notifier_block * nb)
76058 {
76059 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76060 return true;
76061
76062 list_for_each_entry_rcu(mod, &modules, list) {
76063 - struct symsearch arr[] = {
76064 + struct symsearch modarr[] = {
76065 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76066 NOT_GPL_ONLY, false },
76067 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76068 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76069 if (mod->state == MODULE_STATE_UNFORMED)
76070 continue;
76071
76072 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76073 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76074 return true;
76075 }
76076 return false;
76077 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76078 static int percpu_modalloc(struct module *mod,
76079 unsigned long size, unsigned long align)
76080 {
76081 - if (align > PAGE_SIZE) {
76082 + if (align-1 >= PAGE_SIZE) {
76083 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76084 mod->name, align, PAGE_SIZE);
76085 align = PAGE_SIZE;
76086 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
76087 static ssize_t show_coresize(struct module_attribute *mattr,
76088 struct module_kobject *mk, char *buffer)
76089 {
76090 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76091 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76092 }
76093
76094 static struct module_attribute modinfo_coresize =
76095 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
76096 static ssize_t show_initsize(struct module_attribute *mattr,
76097 struct module_kobject *mk, char *buffer)
76098 {
76099 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76100 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76101 }
76102
76103 static struct module_attribute modinfo_initsize =
76104 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
76105 */
76106 #ifdef CONFIG_SYSFS
76107
76108 -#ifdef CONFIG_KALLSYMS
76109 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76110 static inline bool sect_empty(const Elf_Shdr *sect)
76111 {
76112 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76113 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76114 {
76115 unsigned int notes, loaded, i;
76116 struct module_notes_attrs *notes_attrs;
76117 - struct bin_attribute *nattr;
76118 + bin_attribute_no_const *nattr;
76119
76120 /* failed to create section attributes, so can't create notes */
76121 if (!mod->sect_attrs)
76122 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
76123 static int module_add_modinfo_attrs(struct module *mod)
76124 {
76125 struct module_attribute *attr;
76126 - struct module_attribute *temp_attr;
76127 + module_attribute_no_const *temp_attr;
76128 int error = 0;
76129 int i;
76130
76131 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
76132
76133 static void unset_module_core_ro_nx(struct module *mod)
76134 {
76135 - set_page_attributes(mod->module_core + mod->core_text_size,
76136 - mod->module_core + mod->core_size,
76137 + set_page_attributes(mod->module_core_rw,
76138 + mod->module_core_rw + mod->core_size_rw,
76139 set_memory_x);
76140 - set_page_attributes(mod->module_core,
76141 - mod->module_core + mod->core_ro_size,
76142 + set_page_attributes(mod->module_core_rx,
76143 + mod->module_core_rx + mod->core_size_rx,
76144 set_memory_rw);
76145 }
76146
76147 static void unset_module_init_ro_nx(struct module *mod)
76148 {
76149 - set_page_attributes(mod->module_init + mod->init_text_size,
76150 - mod->module_init + mod->init_size,
76151 + set_page_attributes(mod->module_init_rw,
76152 + mod->module_init_rw + mod->init_size_rw,
76153 set_memory_x);
76154 - set_page_attributes(mod->module_init,
76155 - mod->module_init + mod->init_ro_size,
76156 + set_page_attributes(mod->module_init_rx,
76157 + mod->module_init_rx + mod->init_size_rx,
76158 set_memory_rw);
76159 }
76160
76161 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
76162 list_for_each_entry_rcu(mod, &modules, list) {
76163 if (mod->state == MODULE_STATE_UNFORMED)
76164 continue;
76165 - if ((mod->module_core) && (mod->core_text_size)) {
76166 - set_page_attributes(mod->module_core,
76167 - mod->module_core + mod->core_text_size,
76168 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76169 + set_page_attributes(mod->module_core_rx,
76170 + mod->module_core_rx + mod->core_size_rx,
76171 set_memory_rw);
76172 }
76173 - if ((mod->module_init) && (mod->init_text_size)) {
76174 - set_page_attributes(mod->module_init,
76175 - mod->module_init + mod->init_text_size,
76176 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76177 + set_page_attributes(mod->module_init_rx,
76178 + mod->module_init_rx + mod->init_size_rx,
76179 set_memory_rw);
76180 }
76181 }
76182 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
76183 list_for_each_entry_rcu(mod, &modules, list) {
76184 if (mod->state == MODULE_STATE_UNFORMED)
76185 continue;
76186 - if ((mod->module_core) && (mod->core_text_size)) {
76187 - set_page_attributes(mod->module_core,
76188 - mod->module_core + mod->core_text_size,
76189 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76190 + set_page_attributes(mod->module_core_rx,
76191 + mod->module_core_rx + mod->core_size_rx,
76192 set_memory_ro);
76193 }
76194 - if ((mod->module_init) && (mod->init_text_size)) {
76195 - set_page_attributes(mod->module_init,
76196 - mod->module_init + mod->init_text_size,
76197 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76198 + set_page_attributes(mod->module_init_rx,
76199 + mod->module_init_rx + mod->init_size_rx,
76200 set_memory_ro);
76201 }
76202 }
76203 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
76204
76205 /* This may be NULL, but that's OK */
76206 unset_module_init_ro_nx(mod);
76207 - module_free(mod, mod->module_init);
76208 + module_free(mod, mod->module_init_rw);
76209 + module_free_exec(mod, mod->module_init_rx);
76210 kfree(mod->args);
76211 percpu_modfree(mod);
76212
76213 /* Free lock-classes: */
76214 - lockdep_free_key_range(mod->module_core, mod->core_size);
76215 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76216 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76217
76218 /* Finally, free the core (containing the module structure) */
76219 unset_module_core_ro_nx(mod);
76220 - module_free(mod, mod->module_core);
76221 + module_free_exec(mod, mod->module_core_rx);
76222 + module_free(mod, mod->module_core_rw);
76223
76224 #ifdef CONFIG_MPU
76225 update_protections(current->mm);
76226 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76227 int ret = 0;
76228 const struct kernel_symbol *ksym;
76229
76230 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76231 + int is_fs_load = 0;
76232 + int register_filesystem_found = 0;
76233 + char *p;
76234 +
76235 + p = strstr(mod->args, "grsec_modharden_fs");
76236 + if (p) {
76237 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76238 + /* copy \0 as well */
76239 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76240 + is_fs_load = 1;
76241 + }
76242 +#endif
76243 +
76244 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76245 const char *name = info->strtab + sym[i].st_name;
76246
76247 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76248 + /* it's a real shame this will never get ripped and copied
76249 + upstream! ;(
76250 + */
76251 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76252 + register_filesystem_found = 1;
76253 +#endif
76254 +
76255 switch (sym[i].st_shndx) {
76256 case SHN_COMMON:
76257 /* We compiled with -fno-common. These are not
76258 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76259 ksym = resolve_symbol_wait(mod, info, name);
76260 /* Ok if resolved. */
76261 if (ksym && !IS_ERR(ksym)) {
76262 + pax_open_kernel();
76263 sym[i].st_value = ksym->value;
76264 + pax_close_kernel();
76265 break;
76266 }
76267
76268 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76269 secbase = (unsigned long)mod_percpu(mod);
76270 else
76271 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76272 + pax_open_kernel();
76273 sym[i].st_value += secbase;
76274 + pax_close_kernel();
76275 break;
76276 }
76277 }
76278
76279 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76280 + if (is_fs_load && !register_filesystem_found) {
76281 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76282 + ret = -EPERM;
76283 + }
76284 +#endif
76285 +
76286 return ret;
76287 }
76288
76289 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76290 || s->sh_entsize != ~0UL
76291 || strstarts(sname, ".init"))
76292 continue;
76293 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76294 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76295 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76296 + else
76297 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76298 pr_debug("\t%s\n", sname);
76299 }
76300 - switch (m) {
76301 - case 0: /* executable */
76302 - mod->core_size = debug_align(mod->core_size);
76303 - mod->core_text_size = mod->core_size;
76304 - break;
76305 - case 1: /* RO: text and ro-data */
76306 - mod->core_size = debug_align(mod->core_size);
76307 - mod->core_ro_size = mod->core_size;
76308 - break;
76309 - case 3: /* whole core */
76310 - mod->core_size = debug_align(mod->core_size);
76311 - break;
76312 - }
76313 }
76314
76315 pr_debug("Init section allocation order:\n");
76316 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76317 || s->sh_entsize != ~0UL
76318 || !strstarts(sname, ".init"))
76319 continue;
76320 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76321 - | INIT_OFFSET_MASK);
76322 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76323 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76324 + else
76325 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76326 + s->sh_entsize |= INIT_OFFSET_MASK;
76327 pr_debug("\t%s\n", sname);
76328 }
76329 - switch (m) {
76330 - case 0: /* executable */
76331 - mod->init_size = debug_align(mod->init_size);
76332 - mod->init_text_size = mod->init_size;
76333 - break;
76334 - case 1: /* RO: text and ro-data */
76335 - mod->init_size = debug_align(mod->init_size);
76336 - mod->init_ro_size = mod->init_size;
76337 - break;
76338 - case 3: /* whole init */
76339 - mod->init_size = debug_align(mod->init_size);
76340 - break;
76341 - }
76342 }
76343 }
76344
76345 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76346
76347 /* Put symbol section at end of init part of module. */
76348 symsect->sh_flags |= SHF_ALLOC;
76349 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76350 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76351 info->index.sym) | INIT_OFFSET_MASK;
76352 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76353
76354 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76355 }
76356
76357 /* Append room for core symbols at end of core part. */
76358 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76359 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76360 - mod->core_size += strtab_size;
76361 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76362 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76363 + mod->core_size_rx += strtab_size;
76364
76365 /* Put string table section at end of init part of module. */
76366 strsect->sh_flags |= SHF_ALLOC;
76367 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76368 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76369 info->index.str) | INIT_OFFSET_MASK;
76370 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76371 }
76372 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76373 /* Make sure we get permanent strtab: don't use info->strtab. */
76374 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76375
76376 + pax_open_kernel();
76377 +
76378 /* Set types up while we still have access to sections. */
76379 for (i = 0; i < mod->num_symtab; i++)
76380 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76381
76382 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76383 - mod->core_strtab = s = mod->module_core + info->stroffs;
76384 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76385 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76386 src = mod->symtab;
76387 for (ndst = i = 0; i < mod->num_symtab; i++) {
76388 if (i == 0 ||
76389 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76390 }
76391 }
76392 mod->core_num_syms = ndst;
76393 +
76394 + pax_close_kernel();
76395 }
76396 #else
76397 static inline void layout_symtab(struct module *mod, struct load_info *info)
76398 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
76399 return vmalloc_exec(size);
76400 }
76401
76402 -static void *module_alloc_update_bounds(unsigned long size)
76403 +static void *module_alloc_update_bounds_rw(unsigned long size)
76404 {
76405 void *ret = module_alloc(size);
76406
76407 if (ret) {
76408 mutex_lock(&module_mutex);
76409 /* Update module bounds. */
76410 - if ((unsigned long)ret < module_addr_min)
76411 - module_addr_min = (unsigned long)ret;
76412 - if ((unsigned long)ret + size > module_addr_max)
76413 - module_addr_max = (unsigned long)ret + size;
76414 + if ((unsigned long)ret < module_addr_min_rw)
76415 + module_addr_min_rw = (unsigned long)ret;
76416 + if ((unsigned long)ret + size > module_addr_max_rw)
76417 + module_addr_max_rw = (unsigned long)ret + size;
76418 + mutex_unlock(&module_mutex);
76419 + }
76420 + return ret;
76421 +}
76422 +
76423 +static void *module_alloc_update_bounds_rx(unsigned long size)
76424 +{
76425 + void *ret = module_alloc_exec(size);
76426 +
76427 + if (ret) {
76428 + mutex_lock(&module_mutex);
76429 + /* Update module bounds. */
76430 + if ((unsigned long)ret < module_addr_min_rx)
76431 + module_addr_min_rx = (unsigned long)ret;
76432 + if ((unsigned long)ret + size > module_addr_max_rx)
76433 + module_addr_max_rx = (unsigned long)ret + size;
76434 mutex_unlock(&module_mutex);
76435 }
76436 return ret;
76437 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76438 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76439 {
76440 const char *modmagic = get_modinfo(info, "vermagic");
76441 + const char *license = get_modinfo(info, "license");
76442 int err;
76443
76444 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76445 + if (!license || !license_is_gpl_compatible(license))
76446 + return -ENOEXEC;
76447 +#endif
76448 +
76449 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76450 modmagic = NULL;
76451
76452 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76453 }
76454
76455 /* Set up license info based on the info section */
76456 - set_license(mod, get_modinfo(info, "license"));
76457 + set_license(mod, license);
76458
76459 return 0;
76460 }
76461 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
76462 void *ptr;
76463
76464 /* Do the allocs. */
76465 - ptr = module_alloc_update_bounds(mod->core_size);
76466 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76467 /*
76468 * The pointer to this block is stored in the module structure
76469 * which is inside the block. Just mark it as not being a
76470 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
76471 if (!ptr)
76472 return -ENOMEM;
76473
76474 - memset(ptr, 0, mod->core_size);
76475 - mod->module_core = ptr;
76476 + memset(ptr, 0, mod->core_size_rw);
76477 + mod->module_core_rw = ptr;
76478
76479 - if (mod->init_size) {
76480 - ptr = module_alloc_update_bounds(mod->init_size);
76481 + if (mod->init_size_rw) {
76482 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76483 /*
76484 * The pointer to this block is stored in the module structure
76485 * which is inside the block. This block doesn't need to be
76486 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
76487 */
76488 kmemleak_ignore(ptr);
76489 if (!ptr) {
76490 - module_free(mod, mod->module_core);
76491 + module_free(mod, mod->module_core_rw);
76492 return -ENOMEM;
76493 }
76494 - memset(ptr, 0, mod->init_size);
76495 - mod->module_init = ptr;
76496 + memset(ptr, 0, mod->init_size_rw);
76497 + mod->module_init_rw = ptr;
76498 } else
76499 - mod->module_init = NULL;
76500 + mod->module_init_rw = NULL;
76501 +
76502 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76503 + kmemleak_not_leak(ptr);
76504 + if (!ptr) {
76505 + if (mod->module_init_rw)
76506 + module_free(mod, mod->module_init_rw);
76507 + module_free(mod, mod->module_core_rw);
76508 + return -ENOMEM;
76509 + }
76510 +
76511 + pax_open_kernel();
76512 + memset(ptr, 0, mod->core_size_rx);
76513 + pax_close_kernel();
76514 + mod->module_core_rx = ptr;
76515 +
76516 + if (mod->init_size_rx) {
76517 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76518 + kmemleak_ignore(ptr);
76519 + if (!ptr && mod->init_size_rx) {
76520 + module_free_exec(mod, mod->module_core_rx);
76521 + if (mod->module_init_rw)
76522 + module_free(mod, mod->module_init_rw);
76523 + module_free(mod, mod->module_core_rw);
76524 + return -ENOMEM;
76525 + }
76526 +
76527 + pax_open_kernel();
76528 + memset(ptr, 0, mod->init_size_rx);
76529 + pax_close_kernel();
76530 + mod->module_init_rx = ptr;
76531 + } else
76532 + mod->module_init_rx = NULL;
76533
76534 /* Transfer each section which specifies SHF_ALLOC */
76535 pr_debug("final section addresses:\n");
76536 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
76537 if (!(shdr->sh_flags & SHF_ALLOC))
76538 continue;
76539
76540 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76541 - dest = mod->module_init
76542 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76543 - else
76544 - dest = mod->module_core + shdr->sh_entsize;
76545 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76546 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76547 + dest = mod->module_init_rw
76548 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76549 + else
76550 + dest = mod->module_init_rx
76551 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76552 + } else {
76553 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76554 + dest = mod->module_core_rw + shdr->sh_entsize;
76555 + else
76556 + dest = mod->module_core_rx + shdr->sh_entsize;
76557 + }
76558 +
76559 + if (shdr->sh_type != SHT_NOBITS) {
76560 +
76561 +#ifdef CONFIG_PAX_KERNEXEC
76562 +#ifdef CONFIG_X86_64
76563 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76564 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76565 +#endif
76566 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76567 + pax_open_kernel();
76568 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76569 + pax_close_kernel();
76570 + } else
76571 +#endif
76572
76573 - if (shdr->sh_type != SHT_NOBITS)
76574 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76575 + }
76576 /* Update sh_addr to point to copy in image. */
76577 - shdr->sh_addr = (unsigned long)dest;
76578 +
76579 +#ifdef CONFIG_PAX_KERNEXEC
76580 + if (shdr->sh_flags & SHF_EXECINSTR)
76581 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76582 + else
76583 +#endif
76584 +
76585 + shdr->sh_addr = (unsigned long)dest;
76586 pr_debug("\t0x%lx %s\n",
76587 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76588 }
76589 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
76590 * Do it before processing of module parameters, so the module
76591 * can provide parameter accessor functions of its own.
76592 */
76593 - if (mod->module_init)
76594 - flush_icache_range((unsigned long)mod->module_init,
76595 - (unsigned long)mod->module_init
76596 - + mod->init_size);
76597 - flush_icache_range((unsigned long)mod->module_core,
76598 - (unsigned long)mod->module_core + mod->core_size);
76599 + if (mod->module_init_rx)
76600 + flush_icache_range((unsigned long)mod->module_init_rx,
76601 + (unsigned long)mod->module_init_rx
76602 + + mod->init_size_rx);
76603 + flush_icache_range((unsigned long)mod->module_core_rx,
76604 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76605
76606 set_fs(old_fs);
76607 }
76608 @@ -2983,8 +3088,10 @@ out:
76609 static void module_deallocate(struct module *mod, struct load_info *info)
76610 {
76611 percpu_modfree(mod);
76612 - module_free(mod, mod->module_init);
76613 - module_free(mod, mod->module_core);
76614 + module_free_exec(mod, mod->module_init_rx);
76615 + module_free_exec(mod, mod->module_core_rx);
76616 + module_free(mod, mod->module_init_rw);
76617 + module_free(mod, mod->module_core_rw);
76618 }
76619
76620 int __weak module_finalize(const Elf_Ehdr *hdr,
76621 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76622 static int post_relocation(struct module *mod, const struct load_info *info)
76623 {
76624 /* Sort exception table now relocations are done. */
76625 + pax_open_kernel();
76626 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76627 + pax_close_kernel();
76628
76629 /* Copy relocated percpu area over. */
76630 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76631 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
76632 MODULE_STATE_COMING, mod);
76633
76634 /* Set RO and NX regions for core */
76635 - set_section_ro_nx(mod->module_core,
76636 - mod->core_text_size,
76637 - mod->core_ro_size,
76638 - mod->core_size);
76639 + set_section_ro_nx(mod->module_core_rx,
76640 + mod->core_size_rx,
76641 + mod->core_size_rx,
76642 + mod->core_size_rx);
76643
76644 /* Set RO and NX regions for init */
76645 - set_section_ro_nx(mod->module_init,
76646 - mod->init_text_size,
76647 - mod->init_ro_size,
76648 - mod->init_size);
76649 + set_section_ro_nx(mod->module_init_rx,
76650 + mod->init_size_rx,
76651 + mod->init_size_rx,
76652 + mod->init_size_rx);
76653
76654 do_mod_ctors(mod);
76655 /* Start the module */
76656 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
76657 mod->strtab = mod->core_strtab;
76658 #endif
76659 unset_module_init_ro_nx(mod);
76660 - module_free(mod, mod->module_init);
76661 - mod->module_init = NULL;
76662 - mod->init_size = 0;
76663 - mod->init_ro_size = 0;
76664 - mod->init_text_size = 0;
76665 + module_free(mod, mod->module_init_rw);
76666 + module_free_exec(mod, mod->module_init_rx);
76667 + mod->module_init_rw = NULL;
76668 + mod->module_init_rx = NULL;
76669 + mod->init_size_rw = 0;
76670 + mod->init_size_rx = 0;
76671 mutex_unlock(&module_mutex);
76672 wake_up_all(&module_wq);
76673
76674 @@ -3209,9 +3319,38 @@ again:
76675 if (err)
76676 goto free_unload;
76677
76678 + /* Now copy in args */
76679 + mod->args = strndup_user(uargs, ~0UL >> 1);
76680 + if (IS_ERR(mod->args)) {
76681 + err = PTR_ERR(mod->args);
76682 + goto free_unload;
76683 + }
76684 +
76685 /* Set up MODINFO_ATTR fields */
76686 setup_modinfo(mod, info);
76687
76688 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76689 + {
76690 + char *p, *p2;
76691 +
76692 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76693 + 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);
76694 + err = -EPERM;
76695 + goto free_modinfo;
76696 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76697 + p += sizeof("grsec_modharden_normal") - 1;
76698 + p2 = strstr(p, "_");
76699 + if (p2) {
76700 + *p2 = '\0';
76701 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76702 + *p2 = '_';
76703 + }
76704 + err = -EPERM;
76705 + goto free_modinfo;
76706 + }
76707 + }
76708 +#endif
76709 +
76710 /* Fix up syms, so that st_value is a pointer to location. */
76711 err = simplify_symbols(mod, info);
76712 if (err < 0)
76713 @@ -3227,13 +3366,6 @@ again:
76714
76715 flush_module_icache(mod);
76716
76717 - /* Now copy in args */
76718 - mod->args = strndup_user(uargs, ~0UL >> 1);
76719 - if (IS_ERR(mod->args)) {
76720 - err = PTR_ERR(mod->args);
76721 - goto free_arch_cleanup;
76722 - }
76723 -
76724 dynamic_debug_setup(info->debug, info->num_debug);
76725
76726 mutex_lock(&module_mutex);
76727 @@ -3278,11 +3410,10 @@ again:
76728 mutex_unlock(&module_mutex);
76729 dynamic_debug_remove(info->debug);
76730 synchronize_sched();
76731 - kfree(mod->args);
76732 - free_arch_cleanup:
76733 module_arch_cleanup(mod);
76734 free_modinfo:
76735 free_modinfo(mod);
76736 + kfree(mod->args);
76737 free_unload:
76738 module_unload_free(mod);
76739 unlink_mod:
76740 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
76741 unsigned long nextval;
76742
76743 /* At worse, next value is at end of module */
76744 - if (within_module_init(addr, mod))
76745 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76746 + if (within_module_init_rx(addr, mod))
76747 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76748 + else if (within_module_init_rw(addr, mod))
76749 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76750 + else if (within_module_core_rx(addr, mod))
76751 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76752 + else if (within_module_core_rw(addr, mod))
76753 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76754 else
76755 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76756 + return NULL;
76757
76758 /* Scan for closest preceding symbol, and next symbol. (ELF
76759 starts real symbols at 1). */
76760 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
76761 return 0;
76762
76763 seq_printf(m, "%s %u",
76764 - mod->name, mod->init_size + mod->core_size);
76765 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76766 print_unload_info(m, mod);
76767
76768 /* Informative for users. */
76769 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
76770 mod->state == MODULE_STATE_COMING ? "Loading":
76771 "Live");
76772 /* Used by oprofile and other similar tools. */
76773 - seq_printf(m, " 0x%pK", mod->module_core);
76774 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76775
76776 /* Taints info */
76777 if (mod->taints)
76778 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
76779
76780 static int __init proc_modules_init(void)
76781 {
76782 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76783 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76784 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76785 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76786 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76787 +#else
76788 proc_create("modules", 0, NULL, &proc_modules_operations);
76789 +#endif
76790 +#else
76791 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76792 +#endif
76793 return 0;
76794 }
76795 module_init(proc_modules_init);
76796 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
76797 {
76798 struct module *mod;
76799
76800 - if (addr < module_addr_min || addr > module_addr_max)
76801 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76802 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76803 return NULL;
76804
76805 list_for_each_entry_rcu(mod, &modules, list) {
76806 if (mod->state == MODULE_STATE_UNFORMED)
76807 continue;
76808 - if (within_module_core(addr, mod)
76809 - || within_module_init(addr, mod))
76810 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76811 return mod;
76812 }
76813 return NULL;
76814 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
76815 */
76816 struct module *__module_text_address(unsigned long addr)
76817 {
76818 - struct module *mod = __module_address(addr);
76819 + struct module *mod;
76820 +
76821 +#ifdef CONFIG_X86_32
76822 + addr = ktla_ktva(addr);
76823 +#endif
76824 +
76825 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76826 + return NULL;
76827 +
76828 + mod = __module_address(addr);
76829 +
76830 if (mod) {
76831 /* Make sure it's within the text section. */
76832 - if (!within(addr, mod->module_init, mod->init_text_size)
76833 - && !within(addr, mod->module_core, mod->core_text_size))
76834 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76835 mod = NULL;
76836 }
76837 return mod;
76838 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76839 index 7e3443f..b2a1e6b 100644
76840 --- a/kernel/mutex-debug.c
76841 +++ b/kernel/mutex-debug.c
76842 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76843 }
76844
76845 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76846 - struct thread_info *ti)
76847 + struct task_struct *task)
76848 {
76849 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76850
76851 /* Mark the current thread as blocked on the lock: */
76852 - ti->task->blocked_on = waiter;
76853 + task->blocked_on = waiter;
76854 }
76855
76856 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76857 - struct thread_info *ti)
76858 + struct task_struct *task)
76859 {
76860 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76861 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76862 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76863 - ti->task->blocked_on = NULL;
76864 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76865 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76866 + task->blocked_on = NULL;
76867
76868 list_del_init(&waiter->list);
76869 waiter->task = NULL;
76870 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
76871 index 0799fd3..d06ae3b 100644
76872 --- a/kernel/mutex-debug.h
76873 +++ b/kernel/mutex-debug.h
76874 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
76875 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
76876 extern void debug_mutex_add_waiter(struct mutex *lock,
76877 struct mutex_waiter *waiter,
76878 - struct thread_info *ti);
76879 + struct task_struct *task);
76880 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76881 - struct thread_info *ti);
76882 + struct task_struct *task);
76883 extern void debug_mutex_unlock(struct mutex *lock);
76884 extern void debug_mutex_init(struct mutex *lock, const char *name,
76885 struct lock_class_key *key);
76886 diff --git a/kernel/mutex.c b/kernel/mutex.c
76887 index a307cc9..27fd2e9 100644
76888 --- a/kernel/mutex.c
76889 +++ b/kernel/mutex.c
76890 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76891 spin_lock_mutex(&lock->wait_lock, flags);
76892
76893 debug_mutex_lock_common(lock, &waiter);
76894 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
76895 + debug_mutex_add_waiter(lock, &waiter, task);
76896
76897 /* add waiting tasks to the end of the waitqueue (FIFO): */
76898 list_add_tail(&waiter.list, &lock->wait_list);
76899 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76900 * TASK_UNINTERRUPTIBLE case.)
76901 */
76902 if (unlikely(signal_pending_state(state, task))) {
76903 - mutex_remove_waiter(lock, &waiter,
76904 - task_thread_info(task));
76905 + mutex_remove_waiter(lock, &waiter, task);
76906 mutex_release(&lock->dep_map, 1, ip);
76907 spin_unlock_mutex(&lock->wait_lock, flags);
76908
76909 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76910 done:
76911 lock_acquired(&lock->dep_map, ip);
76912 /* got the lock - rejoice! */
76913 - mutex_remove_waiter(lock, &waiter, current_thread_info());
76914 + mutex_remove_waiter(lock, &waiter, task);
76915 mutex_set_owner(lock);
76916
76917 /* set it to 0 if there are no waiters left: */
76918 diff --git a/kernel/notifier.c b/kernel/notifier.c
76919 index 2d5cc4c..d9ea600 100644
76920 --- a/kernel/notifier.c
76921 +++ b/kernel/notifier.c
76922 @@ -5,6 +5,7 @@
76923 #include <linux/rcupdate.h>
76924 #include <linux/vmalloc.h>
76925 #include <linux/reboot.h>
76926 +#include <linux/mm.h>
76927
76928 /*
76929 * Notifier list for kernel code which wants to be called
76930 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
76931 while ((*nl) != NULL) {
76932 if (n->priority > (*nl)->priority)
76933 break;
76934 - nl = &((*nl)->next);
76935 + nl = (struct notifier_block **)&((*nl)->next);
76936 }
76937 - n->next = *nl;
76938 + pax_open_kernel();
76939 + *(const void **)&n->next = *nl;
76940 rcu_assign_pointer(*nl, n);
76941 + pax_close_kernel();
76942 return 0;
76943 }
76944
76945 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
76946 return 0;
76947 if (n->priority > (*nl)->priority)
76948 break;
76949 - nl = &((*nl)->next);
76950 + nl = (struct notifier_block **)&((*nl)->next);
76951 }
76952 - n->next = *nl;
76953 + pax_open_kernel();
76954 + *(const void **)&n->next = *nl;
76955 rcu_assign_pointer(*nl, n);
76956 + pax_close_kernel();
76957 return 0;
76958 }
76959
76960 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
76961 {
76962 while ((*nl) != NULL) {
76963 if ((*nl) == n) {
76964 + pax_open_kernel();
76965 rcu_assign_pointer(*nl, n->next);
76966 + pax_close_kernel();
76967 return 0;
76968 }
76969 - nl = &((*nl)->next);
76970 + nl = (struct notifier_block **)&((*nl)->next);
76971 }
76972 return -ENOENT;
76973 }
76974 diff --git a/kernel/panic.c b/kernel/panic.c
76975 index e1b2822..5edc1d9 100644
76976 --- a/kernel/panic.c
76977 +++ b/kernel/panic.c
76978 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
76979 const char *board;
76980
76981 printk(KERN_WARNING "------------[ cut here ]------------\n");
76982 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
76983 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
76984 board = dmi_get_system_info(DMI_PRODUCT_NAME);
76985 if (board)
76986 printk(KERN_WARNING "Hardware name: %s\n", board);
76987 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
76988 */
76989 void __stack_chk_fail(void)
76990 {
76991 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
76992 + dump_stack();
76993 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
76994 __builtin_return_address(0));
76995 }
76996 EXPORT_SYMBOL(__stack_chk_fail);
76997 diff --git a/kernel/pid.c b/kernel/pid.c
76998 index f2c6a68..4922d97 100644
76999 --- a/kernel/pid.c
77000 +++ b/kernel/pid.c
77001 @@ -33,6 +33,7 @@
77002 #include <linux/rculist.h>
77003 #include <linux/bootmem.h>
77004 #include <linux/hash.h>
77005 +#include <linux/security.h>
77006 #include <linux/pid_namespace.h>
77007 #include <linux/init_task.h>
77008 #include <linux/syscalls.h>
77009 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77010
77011 int pid_max = PID_MAX_DEFAULT;
77012
77013 -#define RESERVED_PIDS 300
77014 +#define RESERVED_PIDS 500
77015
77016 int pid_max_min = RESERVED_PIDS + 1;
77017 int pid_max_max = PID_MAX_LIMIT;
77018 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
77019 */
77020 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77021 {
77022 + struct task_struct *task;
77023 +
77024 rcu_lockdep_assert(rcu_read_lock_held(),
77025 "find_task_by_pid_ns() needs rcu_read_lock()"
77026 " protection");
77027 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77028 +
77029 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77030 +
77031 + if (gr_pid_is_chrooted(task))
77032 + return NULL;
77033 +
77034 + return task;
77035 }
77036
77037 struct task_struct *find_task_by_vpid(pid_t vnr)
77038 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77039 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77040 }
77041
77042 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77043 +{
77044 + rcu_lockdep_assert(rcu_read_lock_held(),
77045 + "find_task_by_pid_ns() needs rcu_read_lock()"
77046 + " protection");
77047 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77048 +}
77049 +
77050 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77051 {
77052 struct pid *pid;
77053 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77054 index bea15bd..789f3d0 100644
77055 --- a/kernel/pid_namespace.c
77056 +++ b/kernel/pid_namespace.c
77057 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77058 void __user *buffer, size_t *lenp, loff_t *ppos)
77059 {
77060 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77061 - struct ctl_table tmp = *table;
77062 + ctl_table_no_const tmp = *table;
77063
77064 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77065 return -EPERM;
77066 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77067 index 942ca27..111e609 100644
77068 --- a/kernel/posix-cpu-timers.c
77069 +++ b/kernel/posix-cpu-timers.c
77070 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
77071
77072 static __init int init_posix_cpu_timers(void)
77073 {
77074 - struct k_clock process = {
77075 + static struct k_clock process = {
77076 .clock_getres = process_cpu_clock_getres,
77077 .clock_get = process_cpu_clock_get,
77078 .timer_create = process_cpu_timer_create,
77079 .nsleep = process_cpu_nsleep,
77080 .nsleep_restart = process_cpu_nsleep_restart,
77081 };
77082 - struct k_clock thread = {
77083 + static struct k_clock thread = {
77084 .clock_getres = thread_cpu_clock_getres,
77085 .clock_get = thread_cpu_clock_get,
77086 .timer_create = thread_cpu_timer_create,
77087 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77088 index e885be1..380fe76 100644
77089 --- a/kernel/posix-timers.c
77090 +++ b/kernel/posix-timers.c
77091 @@ -43,6 +43,7 @@
77092 #include <linux/idr.h>
77093 #include <linux/posix-clock.h>
77094 #include <linux/posix-timers.h>
77095 +#include <linux/grsecurity.h>
77096 #include <linux/syscalls.h>
77097 #include <linux/wait.h>
77098 #include <linux/workqueue.h>
77099 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
77100 * which we beg off on and pass to do_sys_settimeofday().
77101 */
77102
77103 -static struct k_clock posix_clocks[MAX_CLOCKS];
77104 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77105
77106 /*
77107 * These ones are defined below.
77108 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
77109 */
77110 static __init int init_posix_timers(void)
77111 {
77112 - struct k_clock clock_realtime = {
77113 + static struct k_clock clock_realtime = {
77114 .clock_getres = hrtimer_get_res,
77115 .clock_get = posix_clock_realtime_get,
77116 .clock_set = posix_clock_realtime_set,
77117 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
77118 .timer_get = common_timer_get,
77119 .timer_del = common_timer_del,
77120 };
77121 - struct k_clock clock_monotonic = {
77122 + static struct k_clock clock_monotonic = {
77123 .clock_getres = hrtimer_get_res,
77124 .clock_get = posix_ktime_get_ts,
77125 .nsleep = common_nsleep,
77126 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
77127 .timer_get = common_timer_get,
77128 .timer_del = common_timer_del,
77129 };
77130 - struct k_clock clock_monotonic_raw = {
77131 + static struct k_clock clock_monotonic_raw = {
77132 .clock_getres = hrtimer_get_res,
77133 .clock_get = posix_get_monotonic_raw,
77134 };
77135 - struct k_clock clock_realtime_coarse = {
77136 + static struct k_clock clock_realtime_coarse = {
77137 .clock_getres = posix_get_coarse_res,
77138 .clock_get = posix_get_realtime_coarse,
77139 };
77140 - struct k_clock clock_monotonic_coarse = {
77141 + static struct k_clock clock_monotonic_coarse = {
77142 .clock_getres = posix_get_coarse_res,
77143 .clock_get = posix_get_monotonic_coarse,
77144 };
77145 - struct k_clock clock_boottime = {
77146 + static struct k_clock clock_boottime = {
77147 .clock_getres = hrtimer_get_res,
77148 .clock_get = posix_get_boottime,
77149 .nsleep = common_nsleep,
77150 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77151 return;
77152 }
77153
77154 - posix_clocks[clock_id] = *new_clock;
77155 + posix_clocks[clock_id] = new_clock;
77156 }
77157 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77158
77159 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77160 return (id & CLOCKFD_MASK) == CLOCKFD ?
77161 &clock_posix_dynamic : &clock_posix_cpu;
77162
77163 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77164 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77165 return NULL;
77166 - return &posix_clocks[id];
77167 + return posix_clocks[id];
77168 }
77169
77170 static int common_timer_create(struct k_itimer *new_timer)
77171 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77172 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77173 return -EFAULT;
77174
77175 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77176 + have their clock_set fptr set to a nosettime dummy function
77177 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77178 + call common_clock_set, which calls do_sys_settimeofday, which
77179 + we hook
77180 + */
77181 +
77182 return kc->clock_set(which_clock, &new_tp);
77183 }
77184
77185 diff --git a/kernel/power/process.c b/kernel/power/process.c
77186 index d5a258b..4271191 100644
77187 --- a/kernel/power/process.c
77188 +++ b/kernel/power/process.c
77189 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77190 u64 elapsed_csecs64;
77191 unsigned int elapsed_csecs;
77192 bool wakeup = false;
77193 + bool timedout = false;
77194
77195 do_gettimeofday(&start);
77196
77197 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77198
77199 while (true) {
77200 todo = 0;
77201 + if (time_after(jiffies, end_time))
77202 + timedout = true;
77203 read_lock(&tasklist_lock);
77204 do_each_thread(g, p) {
77205 if (p == current || !freeze_task(p))
77206 continue;
77207
77208 - if (!freezer_should_skip(p))
77209 + if (!freezer_should_skip(p)) {
77210 todo++;
77211 + if (timedout) {
77212 + printk(KERN_ERR "Task refusing to freeze:\n");
77213 + sched_show_task(p);
77214 + }
77215 + }
77216 } while_each_thread(g, p);
77217 read_unlock(&tasklist_lock);
77218
77219 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77220 todo += wq_busy;
77221 }
77222
77223 - if (!todo || time_after(jiffies, end_time))
77224 + if (!todo || timedout)
77225 break;
77226
77227 if (pm_wakeup_pending()) {
77228 diff --git a/kernel/printk.c b/kernel/printk.c
77229 index 267ce78..2487112 100644
77230 --- a/kernel/printk.c
77231 +++ b/kernel/printk.c
77232 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
77233 return ret;
77234 }
77235
77236 +static int check_syslog_permissions(int type, bool from_file);
77237 +
77238 static int devkmsg_open(struct inode *inode, struct file *file)
77239 {
77240 struct devkmsg_user *user;
77241 int err;
77242
77243 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
77244 + if (err)
77245 + return err;
77246 +
77247 /* write-only does not need any file context */
77248 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
77249 return 0;
77250 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
77251 if (dmesg_restrict)
77252 return 1;
77253 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
77254 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77255 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77256 }
77257
77258 static int check_syslog_permissions(int type, bool from_file)
77259 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
77260 if (from_file && type != SYSLOG_ACTION_OPEN)
77261 return 0;
77262
77263 +#ifdef CONFIG_GRKERNSEC_DMESG
77264 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77265 + return -EPERM;
77266 +#endif
77267 +
77268 if (syslog_action_restricted(type)) {
77269 if (capable(CAP_SYSLOG))
77270 return 0;
77271 diff --git a/kernel/profile.c b/kernel/profile.c
77272 index 1f39181..86093471 100644
77273 --- a/kernel/profile.c
77274 +++ b/kernel/profile.c
77275 @@ -40,7 +40,7 @@ struct profile_hit {
77276 /* Oprofile timer tick hook */
77277 static int (*timer_hook)(struct pt_regs *) __read_mostly;
77278
77279 -static atomic_t *prof_buffer;
77280 +static atomic_unchecked_t *prof_buffer;
77281 static unsigned long prof_len, prof_shift;
77282
77283 int prof_on __read_mostly;
77284 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
77285 hits[i].pc = 0;
77286 continue;
77287 }
77288 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77289 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77290 hits[i].hits = hits[i].pc = 0;
77291 }
77292 }
77293 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77294 * Add the current hit(s) and flush the write-queue out
77295 * to the global buffer:
77296 */
77297 - atomic_add(nr_hits, &prof_buffer[pc]);
77298 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77299 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77300 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77301 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77302 hits[i].pc = hits[i].hits = 0;
77303 }
77304 out:
77305 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77306 {
77307 unsigned long pc;
77308 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77309 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77310 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77311 }
77312 #endif /* !CONFIG_SMP */
77313
77314 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77315 return -EFAULT;
77316 buf++; p++; count--; read++;
77317 }
77318 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77319 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77320 if (copy_to_user(buf, (void *)pnt, count))
77321 return -EFAULT;
77322 read += count;
77323 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77324 }
77325 #endif
77326 profile_discard_flip_buffers();
77327 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77328 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77329 return count;
77330 }
77331
77332 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77333 index 6cbeaae..cfe7ff0 100644
77334 --- a/kernel/ptrace.c
77335 +++ b/kernel/ptrace.c
77336 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77337 if (seize)
77338 flags |= PT_SEIZED;
77339 rcu_read_lock();
77340 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77341 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77342 flags |= PT_PTRACE_CAP;
77343 rcu_read_unlock();
77344 task->ptrace = flags;
77345 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77346 break;
77347 return -EIO;
77348 }
77349 - if (copy_to_user(dst, buf, retval))
77350 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77351 return -EFAULT;
77352 copied += retval;
77353 src += retval;
77354 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
77355 bool seized = child->ptrace & PT_SEIZED;
77356 int ret = -EIO;
77357 siginfo_t siginfo, *si;
77358 - void __user *datavp = (void __user *) data;
77359 + void __user *datavp = (__force void __user *) data;
77360 unsigned long __user *datalp = datavp;
77361 unsigned long flags;
77362
77363 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77364 goto out;
77365 }
77366
77367 + if (gr_handle_ptrace(child, request)) {
77368 + ret = -EPERM;
77369 + goto out_put_task_struct;
77370 + }
77371 +
77372 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77373 ret = ptrace_attach(child, request, addr, data);
77374 /*
77375 * Some architectures need to do book-keeping after
77376 * a ptrace attach.
77377 */
77378 - if (!ret)
77379 + if (!ret) {
77380 arch_ptrace_attach(child);
77381 + gr_audit_ptrace(child);
77382 + }
77383 goto out_put_task_struct;
77384 }
77385
77386 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77387 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77388 if (copied != sizeof(tmp))
77389 return -EIO;
77390 - return put_user(tmp, (unsigned long __user *)data);
77391 + return put_user(tmp, (__force unsigned long __user *)data);
77392 }
77393
77394 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77395 @@ -1051,7 +1058,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77396 }
77397
77398 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77399 - compat_long_t addr, compat_long_t data)
77400 + compat_ulong_t addr, compat_ulong_t data)
77401 {
77402 struct task_struct *child;
77403 long ret;
77404 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77405 goto out;
77406 }
77407
77408 + if (gr_handle_ptrace(child, request)) {
77409 + ret = -EPERM;
77410 + goto out_put_task_struct;
77411 + }
77412 +
77413 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77414 ret = ptrace_attach(child, request, addr, data);
77415 /*
77416 * Some architectures need to do book-keeping after
77417 * a ptrace attach.
77418 */
77419 - if (!ret)
77420 + if (!ret) {
77421 arch_ptrace_attach(child);
77422 + gr_audit_ptrace(child);
77423 + }
77424 goto out_put_task_struct;
77425 }
77426
77427 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77428 index e7dce58..ad0d7b7 100644
77429 --- a/kernel/rcutiny.c
77430 +++ b/kernel/rcutiny.c
77431 @@ -46,7 +46,7 @@
77432 struct rcu_ctrlblk;
77433 static void invoke_rcu_callbacks(void);
77434 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77435 -static void rcu_process_callbacks(struct softirq_action *unused);
77436 +static void rcu_process_callbacks(void);
77437 static void __call_rcu(struct rcu_head *head,
77438 void (*func)(struct rcu_head *rcu),
77439 struct rcu_ctrlblk *rcp);
77440 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77441 rcu_is_callbacks_kthread()));
77442 }
77443
77444 -static void rcu_process_callbacks(struct softirq_action *unused)
77445 +static void rcu_process_callbacks(void)
77446 {
77447 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77448 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77449 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77450 index f85016a..91cb03b 100644
77451 --- a/kernel/rcutiny_plugin.h
77452 +++ b/kernel/rcutiny_plugin.h
77453 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
77454 have_rcu_kthread_work = morework;
77455 local_irq_restore(flags);
77456 if (work)
77457 - rcu_process_callbacks(NULL);
77458 + rcu_process_callbacks();
77459 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77460 }
77461
77462 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77463 index 31dea01..ad91ffb 100644
77464 --- a/kernel/rcutorture.c
77465 +++ b/kernel/rcutorture.c
77466 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77467 { 0 };
77468 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77469 { 0 };
77470 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77471 -static atomic_t n_rcu_torture_alloc;
77472 -static atomic_t n_rcu_torture_alloc_fail;
77473 -static atomic_t n_rcu_torture_free;
77474 -static atomic_t n_rcu_torture_mberror;
77475 -static atomic_t n_rcu_torture_error;
77476 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77477 +static atomic_unchecked_t n_rcu_torture_alloc;
77478 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77479 +static atomic_unchecked_t n_rcu_torture_free;
77480 +static atomic_unchecked_t n_rcu_torture_mberror;
77481 +static atomic_unchecked_t n_rcu_torture_error;
77482 static long n_rcu_torture_barrier_error;
77483 static long n_rcu_torture_boost_ktrerror;
77484 static long n_rcu_torture_boost_rterror;
77485 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
77486
77487 spin_lock_bh(&rcu_torture_lock);
77488 if (list_empty(&rcu_torture_freelist)) {
77489 - atomic_inc(&n_rcu_torture_alloc_fail);
77490 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77491 spin_unlock_bh(&rcu_torture_lock);
77492 return NULL;
77493 }
77494 - atomic_inc(&n_rcu_torture_alloc);
77495 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77496 p = rcu_torture_freelist.next;
77497 list_del_init(p);
77498 spin_unlock_bh(&rcu_torture_lock);
77499 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
77500 static void
77501 rcu_torture_free(struct rcu_torture *p)
77502 {
77503 - atomic_inc(&n_rcu_torture_free);
77504 + atomic_inc_unchecked(&n_rcu_torture_free);
77505 spin_lock_bh(&rcu_torture_lock);
77506 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77507 spin_unlock_bh(&rcu_torture_lock);
77508 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *p)
77509 i = rp->rtort_pipe_count;
77510 if (i > RCU_TORTURE_PIPE_LEN)
77511 i = RCU_TORTURE_PIPE_LEN;
77512 - atomic_inc(&rcu_torture_wcount[i]);
77513 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77514 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77515 rp->rtort_mbtest = 0;
77516 rcu_torture_free(rp);
77517 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77518 i = rp->rtort_pipe_count;
77519 if (i > RCU_TORTURE_PIPE_LEN)
77520 i = RCU_TORTURE_PIPE_LEN;
77521 - atomic_inc(&rcu_torture_wcount[i]);
77522 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77523 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77524 rp->rtort_mbtest = 0;
77525 list_del(&rp->rtort_free);
77526 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
77527 i = old_rp->rtort_pipe_count;
77528 if (i > RCU_TORTURE_PIPE_LEN)
77529 i = RCU_TORTURE_PIPE_LEN;
77530 - atomic_inc(&rcu_torture_wcount[i]);
77531 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77532 old_rp->rtort_pipe_count++;
77533 cur_ops->deferred_free(old_rp);
77534 }
77535 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
77536 }
77537 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77538 if (p->rtort_mbtest == 0)
77539 - atomic_inc(&n_rcu_torture_mberror);
77540 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77541 spin_lock(&rand_lock);
77542 cur_ops->read_delay(&rand);
77543 n_rcu_torture_timers++;
77544 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
77545 }
77546 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77547 if (p->rtort_mbtest == 0)
77548 - atomic_inc(&n_rcu_torture_mberror);
77549 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77550 cur_ops->read_delay(&rand);
77551 preempt_disable();
77552 pipe_count = p->rtort_pipe_count;
77553 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
77554 rcu_torture_current,
77555 rcu_torture_current_version,
77556 list_empty(&rcu_torture_freelist),
77557 - atomic_read(&n_rcu_torture_alloc),
77558 - atomic_read(&n_rcu_torture_alloc_fail),
77559 - atomic_read(&n_rcu_torture_free));
77560 + atomic_read_unchecked(&n_rcu_torture_alloc),
77561 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77562 + atomic_read_unchecked(&n_rcu_torture_free));
77563 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77564 - atomic_read(&n_rcu_torture_mberror),
77565 + atomic_read_unchecked(&n_rcu_torture_mberror),
77566 n_rcu_torture_boost_ktrerror,
77567 n_rcu_torture_boost_rterror);
77568 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77569 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
77570 n_barrier_attempts,
77571 n_rcu_torture_barrier_error);
77572 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77573 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77574 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77575 n_rcu_torture_barrier_error != 0 ||
77576 n_rcu_torture_boost_ktrerror != 0 ||
77577 n_rcu_torture_boost_rterror != 0 ||
77578 n_rcu_torture_boost_failure != 0 ||
77579 i > 1) {
77580 cnt += sprintf(&page[cnt], "!!! ");
77581 - atomic_inc(&n_rcu_torture_error);
77582 + atomic_inc_unchecked(&n_rcu_torture_error);
77583 WARN_ON_ONCE(1);
77584 }
77585 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77586 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
77587 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77588 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77589 cnt += sprintf(&page[cnt], " %d",
77590 - atomic_read(&rcu_torture_wcount[i]));
77591 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77592 }
77593 cnt += sprintf(&page[cnt], "\n");
77594 if (cur_ops->stats)
77595 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
77596
77597 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77598
77599 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77600 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77601 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77602 else if (n_online_successes != n_online_attempts ||
77603 n_offline_successes != n_offline_attempts)
77604 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
77605
77606 rcu_torture_current = NULL;
77607 rcu_torture_current_version = 0;
77608 - atomic_set(&n_rcu_torture_alloc, 0);
77609 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77610 - atomic_set(&n_rcu_torture_free, 0);
77611 - atomic_set(&n_rcu_torture_mberror, 0);
77612 - atomic_set(&n_rcu_torture_error, 0);
77613 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77614 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77615 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77616 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77617 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77618 n_rcu_torture_barrier_error = 0;
77619 n_rcu_torture_boost_ktrerror = 0;
77620 n_rcu_torture_boost_rterror = 0;
77621 n_rcu_torture_boost_failure = 0;
77622 n_rcu_torture_boosts = 0;
77623 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77624 - atomic_set(&rcu_torture_wcount[i], 0);
77625 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77626 for_each_possible_cpu(cpu) {
77627 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77628 per_cpu(rcu_torture_count, cpu)[i] = 0;
77629 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77630 index e441b77..dd54f17 100644
77631 --- a/kernel/rcutree.c
77632 +++ b/kernel/rcutree.c
77633 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77634 rcu_prepare_for_idle(smp_processor_id());
77635 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77636 smp_mb__before_atomic_inc(); /* See above. */
77637 - atomic_inc(&rdtp->dynticks);
77638 + atomic_inc_unchecked(&rdtp->dynticks);
77639 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77640 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77641 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77642
77643 /*
77644 * It is illegal to enter an extended quiescent state while
77645 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77646 int user)
77647 {
77648 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77649 - atomic_inc(&rdtp->dynticks);
77650 + atomic_inc_unchecked(&rdtp->dynticks);
77651 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77652 smp_mb__after_atomic_inc(); /* See above. */
77653 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77654 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77655 rcu_cleanup_after_idle(smp_processor_id());
77656 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77657 if (!user && !is_idle_task(current)) {
77658 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
77659 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77660
77661 if (rdtp->dynticks_nmi_nesting == 0 &&
77662 - (atomic_read(&rdtp->dynticks) & 0x1))
77663 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77664 return;
77665 rdtp->dynticks_nmi_nesting++;
77666 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77667 - atomic_inc(&rdtp->dynticks);
77668 + atomic_inc_unchecked(&rdtp->dynticks);
77669 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77670 smp_mb__after_atomic_inc(); /* See above. */
77671 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77672 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77673 }
77674
77675 /**
77676 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
77677 return;
77678 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77679 smp_mb__before_atomic_inc(); /* See above. */
77680 - atomic_inc(&rdtp->dynticks);
77681 + atomic_inc_unchecked(&rdtp->dynticks);
77682 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77683 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77684 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77685 }
77686
77687 /**
77688 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
77689 int ret;
77690
77691 preempt_disable();
77692 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77693 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77694 preempt_enable();
77695 return ret;
77696 }
77697 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
77698 */
77699 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77700 {
77701 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77702 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77703 return (rdp->dynticks_snap & 0x1) == 0;
77704 }
77705
77706 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77707 unsigned int curr;
77708 unsigned int snap;
77709
77710 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77711 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77712 snap = (unsigned int)rdp->dynticks_snap;
77713
77714 /*
77715 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
77716 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77717 */
77718 if (till_stall_check < 3) {
77719 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77720 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77721 till_stall_check = 3;
77722 } else if (till_stall_check > 300) {
77723 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77724 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77725 till_stall_check = 300;
77726 }
77727 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77728 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77729 rsp->qlen += rdp->qlen;
77730 rdp->n_cbs_orphaned += rdp->qlen;
77731 rdp->qlen_lazy = 0;
77732 - ACCESS_ONCE(rdp->qlen) = 0;
77733 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77734 }
77735
77736 /*
77737 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77738 }
77739 smp_mb(); /* List handling before counting for rcu_barrier(). */
77740 rdp->qlen_lazy -= count_lazy;
77741 - ACCESS_ONCE(rdp->qlen) -= count;
77742 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77743 rdp->n_cbs_invoked += count;
77744
77745 /* Reinstate batch limit if we have worked down the excess. */
77746 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77747 /*
77748 * Do RCU core processing for the current CPU.
77749 */
77750 -static void rcu_process_callbacks(struct softirq_action *unused)
77751 +static void rcu_process_callbacks(void)
77752 {
77753 struct rcu_state *rsp;
77754
77755 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77756 local_irq_restore(flags);
77757 return;
77758 }
77759 - ACCESS_ONCE(rdp->qlen)++;
77760 + ACCESS_ONCE_RW(rdp->qlen)++;
77761 if (lazy)
77762 rdp->qlen_lazy++;
77763 else
77764 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
77765 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77766 * course be required on a 64-bit system.
77767 */
77768 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77769 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77770 (ulong)atomic_long_read(&rsp->expedited_done) +
77771 ULONG_MAX / 8)) {
77772 synchronize_sched();
77773 - atomic_long_inc(&rsp->expedited_wrap);
77774 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77775 return;
77776 }
77777
77778 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
77779 * Take a ticket. Note that atomic_inc_return() implies a
77780 * full memory barrier.
77781 */
77782 - snap = atomic_long_inc_return(&rsp->expedited_start);
77783 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77784 firstsnap = snap;
77785 get_online_cpus();
77786 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77787 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
77788 synchronize_sched_expedited_cpu_stop,
77789 NULL) == -EAGAIN) {
77790 put_online_cpus();
77791 - atomic_long_inc(&rsp->expedited_tryfail);
77792 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77793
77794 /* Check to see if someone else did our work for us. */
77795 s = atomic_long_read(&rsp->expedited_done);
77796 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77797 /* ensure test happens before caller kfree */
77798 smp_mb__before_atomic_inc(); /* ^^^ */
77799 - atomic_long_inc(&rsp->expedited_workdone1);
77800 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77801 return;
77802 }
77803
77804 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
77805 udelay(trycount * num_online_cpus());
77806 } else {
77807 wait_rcu_gp(call_rcu_sched);
77808 - atomic_long_inc(&rsp->expedited_normal);
77809 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77810 return;
77811 }
77812
77813 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
77814 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77815 /* ensure test happens before caller kfree */
77816 smp_mb__before_atomic_inc(); /* ^^^ */
77817 - atomic_long_inc(&rsp->expedited_workdone2);
77818 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77819 return;
77820 }
77821
77822 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
77823 * period works for us.
77824 */
77825 get_online_cpus();
77826 - snap = atomic_long_read(&rsp->expedited_start);
77827 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77828 smp_mb(); /* ensure read is before try_stop_cpus(). */
77829 }
77830 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77831 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77832
77833 /*
77834 * Everyone up to our most recent fetch is covered by our grace
77835 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
77836 * than we did already did their update.
77837 */
77838 do {
77839 - atomic_long_inc(&rsp->expedited_done_tries);
77840 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77841 s = atomic_long_read(&rsp->expedited_done);
77842 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77843 /* ensure test happens before caller kfree */
77844 smp_mb__before_atomic_inc(); /* ^^^ */
77845 - atomic_long_inc(&rsp->expedited_done_lost);
77846 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77847 break;
77848 }
77849 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77850 - atomic_long_inc(&rsp->expedited_done_exit);
77851 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77852
77853 put_online_cpus();
77854 }
77855 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77856 * ACCESS_ONCE() to prevent the compiler from speculating
77857 * the increment to precede the early-exit check.
77858 */
77859 - ACCESS_ONCE(rsp->n_barrier_done)++;
77860 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77861 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77862 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77863 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77864 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77865
77866 /* Increment ->n_barrier_done to prevent duplicate work. */
77867 smp_mb(); /* Keep increment after above mechanism. */
77868 - ACCESS_ONCE(rsp->n_barrier_done)++;
77869 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77870 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
77871 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
77872 smp_mb(); /* Keep increment before caller's subsequent code. */
77873 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
77874 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
77875 init_callback_list(rdp);
77876 rdp->qlen_lazy = 0;
77877 - ACCESS_ONCE(rdp->qlen) = 0;
77878 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77879 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
77880 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
77881 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
77882 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
77883 #ifdef CONFIG_RCU_USER_QS
77884 WARN_ON_ONCE(rdp->dynticks->in_user);
77885 #endif
77886 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
77887 rdp->blimit = blimit;
77888 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
77889 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
77890 - atomic_set(&rdp->dynticks->dynticks,
77891 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
77892 + atomic_set_unchecked(&rdp->dynticks->dynticks,
77893 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
77894 rcu_prepare_for_idle_init(cpu);
77895 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
77896
77897 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
77898 index 4b69291..704c92e 100644
77899 --- a/kernel/rcutree.h
77900 +++ b/kernel/rcutree.h
77901 @@ -86,7 +86,7 @@ struct rcu_dynticks {
77902 long long dynticks_nesting; /* Track irq/process nesting level. */
77903 /* Process level is worth LLONG_MAX/2. */
77904 int dynticks_nmi_nesting; /* Track NMI nesting level. */
77905 - atomic_t dynticks; /* Even value for idle, else odd. */
77906 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
77907 #ifdef CONFIG_RCU_FAST_NO_HZ
77908 int dyntick_drain; /* Prepare-for-idle state variable. */
77909 unsigned long dyntick_holdoff;
77910 @@ -423,17 +423,17 @@ struct rcu_state {
77911 /* _rcu_barrier(). */
77912 /* End of fields guarded by barrier_mutex. */
77913
77914 - atomic_long_t expedited_start; /* Starting ticket. */
77915 - atomic_long_t expedited_done; /* Done ticket. */
77916 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
77917 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
77918 - atomic_long_t expedited_workdone1; /* # done by others #1. */
77919 - atomic_long_t expedited_workdone2; /* # done by others #2. */
77920 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
77921 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
77922 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
77923 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
77924 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
77925 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
77926 + atomic_long_t expedited_done; /* Done ticket. */
77927 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
77928 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
77929 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
77930 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
77931 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
77932 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
77933 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
77934 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
77935 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
77936
77937 unsigned long jiffies_force_qs; /* Time at which to invoke */
77938 /* force_quiescent_state(). */
77939 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
77940 index c1cc7e1..f62e436 100644
77941 --- a/kernel/rcutree_plugin.h
77942 +++ b/kernel/rcutree_plugin.h
77943 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
77944
77945 /* Clean up and exit. */
77946 smp_mb(); /* ensure expedited GP seen before counter increment. */
77947 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
77948 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
77949 unlock_mb_ret:
77950 mutex_unlock(&sync_rcu_preempt_exp_mutex);
77951 mb_ret:
77952 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
77953 free_cpumask_var(cm);
77954 }
77955
77956 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
77957 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
77958 .store = &rcu_cpu_kthread_task,
77959 .thread_should_run = rcu_cpu_kthread_should_run,
77960 .thread_fn = rcu_cpu_kthread,
77961 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
77962 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
77963 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
77964 cpu, ticks_value, ticks_title,
77965 - atomic_read(&rdtp->dynticks) & 0xfff,
77966 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
77967 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
77968 fast_no_hz);
77969 }
77970 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
77971
77972 /* Enqueue the callback on the nocb list and update counts. */
77973 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
77974 - ACCESS_ONCE(*old_rhpp) = rhp;
77975 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
77976 atomic_long_add(rhcount, &rdp->nocb_q_count);
77977 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
77978
77979 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
77980 * Extract queued callbacks, update counts, and wait
77981 * for a grace period to elapse.
77982 */
77983 - ACCESS_ONCE(rdp->nocb_head) = NULL;
77984 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
77985 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
77986 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
77987 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
77988 - ACCESS_ONCE(rdp->nocb_p_count) += c;
77989 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
77990 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
77991 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
77992 wait_rcu_gp(rdp->rsp->call_remote);
77993
77994 /* Each pass through the following loop invokes a callback. */
77995 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
77996 list = next;
77997 }
77998 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
77999 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78000 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78001 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78002 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78003 rdp->n_nocbs_invoked += c;
78004 }
78005 return 0;
78006 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78007 rdp = per_cpu_ptr(rsp->rda, cpu);
78008 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
78009 BUG_ON(IS_ERR(t));
78010 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78011 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78012 }
78013 }
78014
78015 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78016 index 0d095dc..1985b19 100644
78017 --- a/kernel/rcutree_trace.c
78018 +++ b/kernel/rcutree_trace.c
78019 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78020 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78021 rdp->passed_quiesce, rdp->qs_pending);
78022 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78023 - atomic_read(&rdp->dynticks->dynticks),
78024 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78025 rdp->dynticks->dynticks_nesting,
78026 rdp->dynticks->dynticks_nmi_nesting,
78027 rdp->dynticks_fqs);
78028 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78029 struct rcu_state *rsp = (struct rcu_state *)m->private;
78030
78031 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",
78032 - atomic_long_read(&rsp->expedited_start),
78033 + atomic_long_read_unchecked(&rsp->expedited_start),
78034 atomic_long_read(&rsp->expedited_done),
78035 - atomic_long_read(&rsp->expedited_wrap),
78036 - atomic_long_read(&rsp->expedited_tryfail),
78037 - atomic_long_read(&rsp->expedited_workdone1),
78038 - atomic_long_read(&rsp->expedited_workdone2),
78039 - atomic_long_read(&rsp->expedited_normal),
78040 - atomic_long_read(&rsp->expedited_stoppedcpus),
78041 - atomic_long_read(&rsp->expedited_done_tries),
78042 - atomic_long_read(&rsp->expedited_done_lost),
78043 - atomic_long_read(&rsp->expedited_done_exit));
78044 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78045 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78046 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78047 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78048 + atomic_long_read_unchecked(&rsp->expedited_normal),
78049 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78050 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78051 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78052 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78053 return 0;
78054 }
78055
78056 diff --git a/kernel/resource.c b/kernel/resource.c
78057 index 73f35d4..4684fc4 100644
78058 --- a/kernel/resource.c
78059 +++ b/kernel/resource.c
78060 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
78061
78062 static int __init ioresources_init(void)
78063 {
78064 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78065 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78066 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78067 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78068 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78069 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78070 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78071 +#endif
78072 +#else
78073 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78074 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78075 +#endif
78076 return 0;
78077 }
78078 __initcall(ioresources_init);
78079 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78080 index 98ec494..4241d6d 100644
78081 --- a/kernel/rtmutex-tester.c
78082 +++ b/kernel/rtmutex-tester.c
78083 @@ -20,7 +20,7 @@
78084 #define MAX_RT_TEST_MUTEXES 8
78085
78086 static spinlock_t rttest_lock;
78087 -static atomic_t rttest_event;
78088 +static atomic_unchecked_t rttest_event;
78089
78090 struct test_thread_data {
78091 int opcode;
78092 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78093
78094 case RTTEST_LOCKCONT:
78095 td->mutexes[td->opdata] = 1;
78096 - td->event = atomic_add_return(1, &rttest_event);
78097 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78098 return 0;
78099
78100 case RTTEST_RESET:
78101 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78102 return 0;
78103
78104 case RTTEST_RESETEVENT:
78105 - atomic_set(&rttest_event, 0);
78106 + atomic_set_unchecked(&rttest_event, 0);
78107 return 0;
78108
78109 default:
78110 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78111 return ret;
78112
78113 td->mutexes[id] = 1;
78114 - td->event = atomic_add_return(1, &rttest_event);
78115 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78116 rt_mutex_lock(&mutexes[id]);
78117 - td->event = atomic_add_return(1, &rttest_event);
78118 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78119 td->mutexes[id] = 4;
78120 return 0;
78121
78122 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78123 return ret;
78124
78125 td->mutexes[id] = 1;
78126 - td->event = atomic_add_return(1, &rttest_event);
78127 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78128 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78129 - td->event = atomic_add_return(1, &rttest_event);
78130 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78131 td->mutexes[id] = ret ? 0 : 4;
78132 return ret ? -EINTR : 0;
78133
78134 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78135 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78136 return ret;
78137
78138 - td->event = atomic_add_return(1, &rttest_event);
78139 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78140 rt_mutex_unlock(&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] = 0;
78144 return 0;
78145
78146 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78147 break;
78148
78149 td->mutexes[dat] = 2;
78150 - td->event = atomic_add_return(1, &rttest_event);
78151 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78152 break;
78153
78154 default:
78155 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78156 return;
78157
78158 td->mutexes[dat] = 3;
78159 - td->event = atomic_add_return(1, &rttest_event);
78160 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78161 break;
78162
78163 case RTTEST_LOCKNOWAIT:
78164 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78165 return;
78166
78167 td->mutexes[dat] = 1;
78168 - td->event = atomic_add_return(1, &rttest_event);
78169 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78170 return;
78171
78172 default:
78173 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78174 index 0984a21..939f183 100644
78175 --- a/kernel/sched/auto_group.c
78176 +++ b/kernel/sched/auto_group.c
78177 @@ -11,7 +11,7 @@
78178
78179 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78180 static struct autogroup autogroup_default;
78181 -static atomic_t autogroup_seq_nr;
78182 +static atomic_unchecked_t autogroup_seq_nr;
78183
78184 void __init autogroup_init(struct task_struct *init_task)
78185 {
78186 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
78187
78188 kref_init(&ag->kref);
78189 init_rwsem(&ag->lock);
78190 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78191 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78192 ag->tg = tg;
78193 #ifdef CONFIG_RT_GROUP_SCHED
78194 /*
78195 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78196 index 26058d0..e315889 100644
78197 --- a/kernel/sched/core.c
78198 +++ b/kernel/sched/core.c
78199 @@ -3367,7 +3367,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78200 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78201 * positive (at least 1, or number of jiffies left till timeout) if completed.
78202 */
78203 -long __sched
78204 +long __sched __intentional_overflow(-1)
78205 wait_for_completion_interruptible_timeout(struct completion *x,
78206 unsigned long timeout)
78207 {
78208 @@ -3384,7 +3384,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78209 *
78210 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78211 */
78212 -int __sched wait_for_completion_killable(struct completion *x)
78213 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78214 {
78215 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78216 if (t == -ERESTARTSYS)
78217 @@ -3405,7 +3405,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78218 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78219 * positive (at least 1, or number of jiffies left till timeout) if completed.
78220 */
78221 -long __sched
78222 +long __sched __intentional_overflow(-1)
78223 wait_for_completion_killable_timeout(struct completion *x,
78224 unsigned long timeout)
78225 {
78226 @@ -3631,6 +3631,8 @@ int can_nice(const struct task_struct *p, const int nice)
78227 /* convert nice value [19,-20] to rlimit style value [1,40] */
78228 int nice_rlim = 20 - nice;
78229
78230 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78231 +
78232 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78233 capable(CAP_SYS_NICE));
78234 }
78235 @@ -3664,7 +3666,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78236 if (nice > 19)
78237 nice = 19;
78238
78239 - if (increment < 0 && !can_nice(current, nice))
78240 + if (increment < 0 && (!can_nice(current, nice) ||
78241 + gr_handle_chroot_nice()))
78242 return -EPERM;
78243
78244 retval = security_task_setnice(current, nice);
78245 @@ -3818,6 +3821,7 @@ recheck:
78246 unsigned long rlim_rtprio =
78247 task_rlimit(p, RLIMIT_RTPRIO);
78248
78249 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78250 /* can't set/change the rt policy */
78251 if (policy != p->policy && !rlim_rtprio)
78252 return -EPERM;
78253 @@ -4901,7 +4905,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78254
78255 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78256
78257 -static struct ctl_table sd_ctl_dir[] = {
78258 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78259 {
78260 .procname = "sched_domain",
78261 .mode = 0555,
78262 @@ -4918,17 +4922,17 @@ static struct ctl_table sd_ctl_root[] = {
78263 {}
78264 };
78265
78266 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78267 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78268 {
78269 - struct ctl_table *entry =
78270 + ctl_table_no_const *entry =
78271 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78272
78273 return entry;
78274 }
78275
78276 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78277 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78278 {
78279 - struct ctl_table *entry;
78280 + ctl_table_no_const *entry;
78281
78282 /*
78283 * In the intermediate directories, both the child directory and
78284 @@ -4936,22 +4940,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78285 * will always be set. In the lowest directory the names are
78286 * static strings and all have proc handlers.
78287 */
78288 - for (entry = *tablep; entry->mode; entry++) {
78289 - if (entry->child)
78290 - sd_free_ctl_entry(&entry->child);
78291 + for (entry = tablep; entry->mode; entry++) {
78292 + if (entry->child) {
78293 + sd_free_ctl_entry(entry->child);
78294 + pax_open_kernel();
78295 + entry->child = NULL;
78296 + pax_close_kernel();
78297 + }
78298 if (entry->proc_handler == NULL)
78299 kfree(entry->procname);
78300 }
78301
78302 - kfree(*tablep);
78303 - *tablep = NULL;
78304 + kfree(tablep);
78305 }
78306
78307 static int min_load_idx = 0;
78308 static int max_load_idx = CPU_LOAD_IDX_MAX;
78309
78310 static void
78311 -set_table_entry(struct ctl_table *entry,
78312 +set_table_entry(ctl_table_no_const *entry,
78313 const char *procname, void *data, int maxlen,
78314 umode_t mode, proc_handler *proc_handler,
78315 bool load_idx)
78316 @@ -4971,7 +4978,7 @@ set_table_entry(struct ctl_table *entry,
78317 static struct ctl_table *
78318 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78319 {
78320 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78321 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78322
78323 if (table == NULL)
78324 return NULL;
78325 @@ -5006,9 +5013,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78326 return table;
78327 }
78328
78329 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78330 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78331 {
78332 - struct ctl_table *entry, *table;
78333 + ctl_table_no_const *entry, *table;
78334 struct sched_domain *sd;
78335 int domain_num = 0, i;
78336 char buf[32];
78337 @@ -5035,11 +5042,13 @@ static struct ctl_table_header *sd_sysctl_header;
78338 static void register_sched_domain_sysctl(void)
78339 {
78340 int i, cpu_num = num_possible_cpus();
78341 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78342 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78343 char buf[32];
78344
78345 WARN_ON(sd_ctl_dir[0].child);
78346 + pax_open_kernel();
78347 sd_ctl_dir[0].child = entry;
78348 + pax_close_kernel();
78349
78350 if (entry == NULL)
78351 return;
78352 @@ -5062,8 +5071,12 @@ static void unregister_sched_domain_sysctl(void)
78353 if (sd_sysctl_header)
78354 unregister_sysctl_table(sd_sysctl_header);
78355 sd_sysctl_header = NULL;
78356 - if (sd_ctl_dir[0].child)
78357 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78358 + if (sd_ctl_dir[0].child) {
78359 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78360 + pax_open_kernel();
78361 + sd_ctl_dir[0].child = NULL;
78362 + pax_close_kernel();
78363 + }
78364 }
78365 #else
78366 static void register_sched_domain_sysctl(void)
78367 @@ -5162,7 +5175,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78368 * happens before everything else. This has to be lower priority than
78369 * the notifier in the perf_event subsystem, though.
78370 */
78371 -static struct notifier_block __cpuinitdata migration_notifier = {
78372 +static struct notifier_block migration_notifier = {
78373 .notifier_call = migration_call,
78374 .priority = CPU_PRI_MIGRATION,
78375 };
78376 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78377 index 81fa536..6ccf96a 100644
78378 --- a/kernel/sched/fair.c
78379 +++ b/kernel/sched/fair.c
78380 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78381
78382 static void reset_ptenuma_scan(struct task_struct *p)
78383 {
78384 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78385 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78386 p->mm->numa_scan_offset = 0;
78387 }
78388
78389 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
78390 */
78391 static int select_idle_sibling(struct task_struct *p, int target)
78392 {
78393 - int cpu = smp_processor_id();
78394 - int prev_cpu = task_cpu(p);
78395 struct sched_domain *sd;
78396 struct sched_group *sg;
78397 - int i;
78398 + int i = task_cpu(p);
78399
78400 - /*
78401 - * If the task is going to be woken-up on this cpu and if it is
78402 - * already idle, then it is the right target.
78403 - */
78404 - if (target == cpu && idle_cpu(cpu))
78405 - return cpu;
78406 + if (idle_cpu(target))
78407 + return target;
78408
78409 /*
78410 - * If the task is going to be woken-up on the cpu where it previously
78411 - * ran and if it is currently idle, then it the right target.
78412 + * If the prevous cpu is cache affine and idle, don't be stupid.
78413 */
78414 - if (target == prev_cpu && idle_cpu(prev_cpu))
78415 - return prev_cpu;
78416 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
78417 + return i;
78418
78419 /*
78420 * Otherwise, iterate the domains and find an elegible idle cpu.
78421 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
78422 goto next;
78423
78424 for_each_cpu(i, sched_group_cpus(sg)) {
78425 - if (!idle_cpu(i))
78426 + if (i == target || !idle_cpu(i))
78427 goto next;
78428 }
78429
78430 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78431 * run_rebalance_domains is triggered when needed from the scheduler tick.
78432 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78433 */
78434 -static void run_rebalance_domains(struct softirq_action *h)
78435 +static void run_rebalance_domains(void)
78436 {
78437 int this_cpu = smp_processor_id();
78438 struct rq *this_rq = cpu_rq(this_cpu);
78439 diff --git a/kernel/signal.c b/kernel/signal.c
78440 index dec9c30..d1da15b 100644
78441 --- a/kernel/signal.c
78442 +++ b/kernel/signal.c
78443 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78444
78445 int print_fatal_signals __read_mostly;
78446
78447 -static void __user *sig_handler(struct task_struct *t, int sig)
78448 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78449 {
78450 return t->sighand->action[sig - 1].sa.sa_handler;
78451 }
78452
78453 -static int sig_handler_ignored(void __user *handler, int sig)
78454 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78455 {
78456 /* Is it explicitly or implicitly ignored? */
78457 return handler == SIG_IGN ||
78458 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78459
78460 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78461 {
78462 - void __user *handler;
78463 + __sighandler_t handler;
78464
78465 handler = sig_handler(t, sig);
78466
78467 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78468 atomic_inc(&user->sigpending);
78469 rcu_read_unlock();
78470
78471 + if (!override_rlimit)
78472 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78473 +
78474 if (override_rlimit ||
78475 atomic_read(&user->sigpending) <=
78476 task_rlimit(t, RLIMIT_SIGPENDING)) {
78477 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78478
78479 int unhandled_signal(struct task_struct *tsk, int sig)
78480 {
78481 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78482 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78483 if (is_global_init(tsk))
78484 return 1;
78485 if (handler != SIG_IGN && handler != SIG_DFL)
78486 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78487 }
78488 }
78489
78490 + /* allow glibc communication via tgkill to other threads in our
78491 + thread group */
78492 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78493 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78494 + && gr_handle_signal(t, sig))
78495 + return -EPERM;
78496 +
78497 return security_task_kill(t, info, sig, 0);
78498 }
78499
78500 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78501 return send_signal(sig, info, p, 1);
78502 }
78503
78504 -static int
78505 +int
78506 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78507 {
78508 return send_signal(sig, info, t, 0);
78509 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78510 unsigned long int flags;
78511 int ret, blocked, ignored;
78512 struct k_sigaction *action;
78513 + int is_unhandled = 0;
78514
78515 spin_lock_irqsave(&t->sighand->siglock, flags);
78516 action = &t->sighand->action[sig-1];
78517 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78518 }
78519 if (action->sa.sa_handler == SIG_DFL)
78520 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78521 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78522 + is_unhandled = 1;
78523 ret = specific_send_sig_info(sig, info, t);
78524 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78525
78526 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78527 + normal operation */
78528 + if (is_unhandled) {
78529 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78530 + gr_handle_crash(t, sig);
78531 + }
78532 +
78533 return ret;
78534 }
78535
78536 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78537 ret = check_kill_permission(sig, info, p);
78538 rcu_read_unlock();
78539
78540 - if (!ret && sig)
78541 + if (!ret && sig) {
78542 ret = do_send_sig_info(sig, info, p, true);
78543 + if (!ret)
78544 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78545 + }
78546
78547 return ret;
78548 }
78549 @@ -2855,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78550 int error = -ESRCH;
78551
78552 rcu_read_lock();
78553 - p = find_task_by_vpid(pid);
78554 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78555 + /* allow glibc communication via tgkill to other threads in our
78556 + thread group */
78557 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78558 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78559 + p = find_task_by_vpid_unrestricted(pid);
78560 + else
78561 +#endif
78562 + p = find_task_by_vpid(pid);
78563 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78564 error = check_kill_permission(sig, info, p);
78565 /*
78566 @@ -3138,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78567 }
78568 seg = get_fs();
78569 set_fs(KERNEL_DS);
78570 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78571 - (stack_t __force __user *) &uoss,
78572 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78573 + (stack_t __force_user *) &uoss,
78574 compat_user_stack_pointer());
78575 set_fs(seg);
78576 if (ret >= 0 && uoss_ptr) {
78577 diff --git a/kernel/smp.c b/kernel/smp.c
78578 index 69f38bd..77bbf12 100644
78579 --- a/kernel/smp.c
78580 +++ b/kernel/smp.c
78581 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78582 return NOTIFY_OK;
78583 }
78584
78585 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78586 +static struct notifier_block hotplug_cfd_notifier = {
78587 .notifier_call = hotplug_cfd,
78588 };
78589
78590 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78591 index d6c5fc0..530560c 100644
78592 --- a/kernel/smpboot.c
78593 +++ b/kernel/smpboot.c
78594 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78595 }
78596 smpboot_unpark_thread(plug_thread, cpu);
78597 }
78598 - list_add(&plug_thread->list, &hotplug_threads);
78599 + pax_list_add(&plug_thread->list, &hotplug_threads);
78600 out:
78601 mutex_unlock(&smpboot_threads_lock);
78602 return ret;
78603 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78604 {
78605 get_online_cpus();
78606 mutex_lock(&smpboot_threads_lock);
78607 - list_del(&plug_thread->list);
78608 + pax_list_del(&plug_thread->list);
78609 smpboot_destroy_threads(plug_thread);
78610 mutex_unlock(&smpboot_threads_lock);
78611 put_online_cpus();
78612 diff --git a/kernel/softirq.c b/kernel/softirq.c
78613 index ed567ba..e71dabf 100644
78614 --- a/kernel/softirq.c
78615 +++ b/kernel/softirq.c
78616 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78617 EXPORT_SYMBOL(irq_stat);
78618 #endif
78619
78620 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78621 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78622
78623 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78624
78625 -char *softirq_to_name[NR_SOFTIRQS] = {
78626 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78627 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78628 "TASKLET", "SCHED", "HRTIMER", "RCU"
78629 };
78630 @@ -244,7 +244,7 @@ restart:
78631 kstat_incr_softirqs_this_cpu(vec_nr);
78632
78633 trace_softirq_entry(vec_nr);
78634 - h->action(h);
78635 + h->action();
78636 trace_softirq_exit(vec_nr);
78637 if (unlikely(prev_count != preempt_count())) {
78638 printk(KERN_ERR "huh, entered softirq %u %s %p"
78639 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78640 or_softirq_pending(1UL << nr);
78641 }
78642
78643 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78644 +void __init open_softirq(int nr, void (*action)(void))
78645 {
78646 softirq_vec[nr].action = action;
78647 }
78648 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78649
78650 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78651
78652 -static void tasklet_action(struct softirq_action *a)
78653 +static void tasklet_action(void)
78654 {
78655 struct tasklet_struct *list;
78656
78657 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
78658 }
78659 }
78660
78661 -static void tasklet_hi_action(struct softirq_action *a)
78662 +static void tasklet_hi_action(void)
78663 {
78664 struct tasklet_struct *list;
78665
78666 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78667 return NOTIFY_OK;
78668 }
78669
78670 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78671 +static struct notifier_block remote_softirq_cpu_notifier = {
78672 .notifier_call = remote_softirq_cpu_notify,
78673 };
78674
78675 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78676 return NOTIFY_OK;
78677 }
78678
78679 -static struct notifier_block __cpuinitdata cpu_nfb = {
78680 +static struct notifier_block cpu_nfb = {
78681 .notifier_call = cpu_callback
78682 };
78683
78684 -static struct smp_hotplug_thread softirq_threads = {
78685 +static struct smp_hotplug_thread softirq_threads __read_only = {
78686 .store = &ksoftirqd,
78687 .thread_should_run = ksoftirqd_should_run,
78688 .thread_fn = run_ksoftirqd,
78689 diff --git a/kernel/srcu.c b/kernel/srcu.c
78690 index 2b85982..d52ab26 100644
78691 --- a/kernel/srcu.c
78692 +++ b/kernel/srcu.c
78693 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78694 preempt_disable();
78695 idx = rcu_dereference_index_check(sp->completed,
78696 rcu_read_lock_sched_held()) & 0x1;
78697 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78698 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78699 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78700 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78701 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78702 preempt_enable();
78703 return idx;
78704 }
78705 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
78706 {
78707 preempt_disable();
78708 smp_mb(); /* C */ /* Avoid leaking the critical section. */
78709 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78710 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78711 preempt_enable();
78712 }
78713 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
78714 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
78715 index 2f194e9..2c05ea9 100644
78716 --- a/kernel/stop_machine.c
78717 +++ b/kernel/stop_machine.c
78718 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
78719 * cpu notifiers. It currently shares the same priority as sched
78720 * migration_notifier.
78721 */
78722 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
78723 +static struct notifier_block cpu_stop_cpu_notifier = {
78724 .notifier_call = cpu_stop_cpu_callback,
78725 .priority = 10,
78726 };
78727 diff --git a/kernel/sys.c b/kernel/sys.c
78728 index 47f1d1b..04c769e 100644
78729 --- a/kernel/sys.c
78730 +++ b/kernel/sys.c
78731 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78732 error = -EACCES;
78733 goto out;
78734 }
78735 +
78736 + if (gr_handle_chroot_setpriority(p, niceval)) {
78737 + error = -EACCES;
78738 + goto out;
78739 + }
78740 +
78741 no_nice = security_task_setnice(p, niceval);
78742 if (no_nice) {
78743 error = no_nice;
78744 @@ -596,6 +602,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78745 goto error;
78746 }
78747
78748 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78749 + goto error;
78750 +
78751 if (rgid != (gid_t) -1 ||
78752 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78753 new->sgid = new->egid;
78754 @@ -631,6 +640,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78755 old = current_cred();
78756
78757 retval = -EPERM;
78758 +
78759 + if (gr_check_group_change(kgid, kgid, kgid))
78760 + goto error;
78761 +
78762 if (nsown_capable(CAP_SETGID))
78763 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78764 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78765 @@ -648,7 +661,7 @@ error:
78766 /*
78767 * change the user struct in a credentials set to match the new UID
78768 */
78769 -static int set_user(struct cred *new)
78770 +int set_user(struct cred *new)
78771 {
78772 struct user_struct *new_user;
78773
78774 @@ -728,6 +741,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78775 goto error;
78776 }
78777
78778 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78779 + goto error;
78780 +
78781 if (!uid_eq(new->uid, old->uid)) {
78782 retval = set_user(new);
78783 if (retval < 0)
78784 @@ -778,6 +794,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78785 old = current_cred();
78786
78787 retval = -EPERM;
78788 +
78789 + if (gr_check_crash_uid(kuid))
78790 + goto error;
78791 + if (gr_check_user_change(kuid, kuid, kuid))
78792 + goto error;
78793 +
78794 if (nsown_capable(CAP_SETUID)) {
78795 new->suid = new->uid = kuid;
78796 if (!uid_eq(kuid, old->uid)) {
78797 @@ -847,6 +869,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78798 goto error;
78799 }
78800
78801 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78802 + goto error;
78803 +
78804 if (ruid != (uid_t) -1) {
78805 new->uid = kruid;
78806 if (!uid_eq(kruid, old->uid)) {
78807 @@ -929,6 +954,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78808 goto error;
78809 }
78810
78811 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78812 + goto error;
78813 +
78814 if (rgid != (gid_t) -1)
78815 new->gid = krgid;
78816 if (egid != (gid_t) -1)
78817 @@ -990,12 +1018,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78818 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
78819 nsown_capable(CAP_SETUID)) {
78820 if (!uid_eq(kuid, old->fsuid)) {
78821 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78822 + goto error;
78823 +
78824 new->fsuid = kuid;
78825 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
78826 goto change_okay;
78827 }
78828 }
78829
78830 +error:
78831 abort_creds(new);
78832 return old_fsuid;
78833
78834 @@ -1028,12 +1060,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78835 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78836 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78837 nsown_capable(CAP_SETGID)) {
78838 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78839 + goto error;
78840 +
78841 if (!gid_eq(kgid, old->fsgid)) {
78842 new->fsgid = kgid;
78843 goto change_okay;
78844 }
78845 }
78846
78847 +error:
78848 abort_creds(new);
78849 return old_fsgid;
78850
78851 @@ -1341,19 +1377,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78852 return -EFAULT;
78853
78854 down_read(&uts_sem);
78855 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78856 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78857 __OLD_UTS_LEN);
78858 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78859 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78860 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78861 __OLD_UTS_LEN);
78862 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78863 - error |= __copy_to_user(&name->release, &utsname()->release,
78864 + error |= __copy_to_user(name->release, &utsname()->release,
78865 __OLD_UTS_LEN);
78866 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78867 - error |= __copy_to_user(&name->version, &utsname()->version,
78868 + error |= __copy_to_user(name->version, &utsname()->version,
78869 __OLD_UTS_LEN);
78870 error |= __put_user(0, name->version + __OLD_UTS_LEN);
78871 - error |= __copy_to_user(&name->machine, &utsname()->machine,
78872 + error |= __copy_to_user(name->machine, &utsname()->machine,
78873 __OLD_UTS_LEN);
78874 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
78875 up_read(&uts_sem);
78876 @@ -2027,7 +2063,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
78877 error = get_dumpable(me->mm);
78878 break;
78879 case PR_SET_DUMPABLE:
78880 - if (arg2 < 0 || arg2 > 1) {
78881 + if (arg2 > 1) {
78882 error = -EINVAL;
78883 break;
78884 }
78885 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
78886 index c88878d..e4fa5d1 100644
78887 --- a/kernel/sysctl.c
78888 +++ b/kernel/sysctl.c
78889 @@ -92,7 +92,6 @@
78890
78891
78892 #if defined(CONFIG_SYSCTL)
78893 -
78894 /* External variables not in a header file. */
78895 extern int sysctl_overcommit_memory;
78896 extern int sysctl_overcommit_ratio;
78897 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
78898 void __user *buffer, size_t *lenp, loff_t *ppos);
78899 #endif
78900
78901 -#ifdef CONFIG_PRINTK
78902 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78903 void __user *buffer, size_t *lenp, loff_t *ppos);
78904 -#endif
78905
78906 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
78907 void __user *buffer, size_t *lenp, loff_t *ppos);
78908 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
78909
78910 #endif
78911
78912 +extern struct ctl_table grsecurity_table[];
78913 +
78914 static struct ctl_table kern_table[];
78915 static struct ctl_table vm_table[];
78916 static struct ctl_table fs_table[];
78917 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
78918 int sysctl_legacy_va_layout;
78919 #endif
78920
78921 +#ifdef CONFIG_PAX_SOFTMODE
78922 +static ctl_table pax_table[] = {
78923 + {
78924 + .procname = "softmode",
78925 + .data = &pax_softmode,
78926 + .maxlen = sizeof(unsigned int),
78927 + .mode = 0600,
78928 + .proc_handler = &proc_dointvec,
78929 + },
78930 +
78931 + { }
78932 +};
78933 +#endif
78934 +
78935 /* The default sysctl tables: */
78936
78937 static struct ctl_table sysctl_base_table[] = {
78938 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
78939 #endif
78940
78941 static struct ctl_table kern_table[] = {
78942 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
78943 + {
78944 + .procname = "grsecurity",
78945 + .mode = 0500,
78946 + .child = grsecurity_table,
78947 + },
78948 +#endif
78949 +
78950 +#ifdef CONFIG_PAX_SOFTMODE
78951 + {
78952 + .procname = "pax",
78953 + .mode = 0500,
78954 + .child = pax_table,
78955 + },
78956 +#endif
78957 +
78958 {
78959 .procname = "sched_child_runs_first",
78960 .data = &sysctl_sched_child_runs_first,
78961 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
78962 .data = &modprobe_path,
78963 .maxlen = KMOD_PATH_LEN,
78964 .mode = 0644,
78965 - .proc_handler = proc_dostring,
78966 + .proc_handler = proc_dostring_modpriv,
78967 },
78968 {
78969 .procname = "modules_disabled",
78970 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
78971 .extra1 = &zero,
78972 .extra2 = &one,
78973 },
78974 +#endif
78975 {
78976 .procname = "kptr_restrict",
78977 .data = &kptr_restrict,
78978 .maxlen = sizeof(int),
78979 .mode = 0644,
78980 .proc_handler = proc_dointvec_minmax_sysadmin,
78981 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78982 + .extra1 = &two,
78983 +#else
78984 .extra1 = &zero,
78985 +#endif
78986 .extra2 = &two,
78987 },
78988 -#endif
78989 {
78990 .procname = "ngroups_max",
78991 .data = &ngroups_max,
78992 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
78993 .proc_handler = proc_dointvec_minmax,
78994 .extra1 = &zero,
78995 },
78996 + {
78997 + .procname = "heap_stack_gap",
78998 + .data = &sysctl_heap_stack_gap,
78999 + .maxlen = sizeof(sysctl_heap_stack_gap),
79000 + .mode = 0644,
79001 + .proc_handler = proc_doulongvec_minmax,
79002 + },
79003 #else
79004 {
79005 .procname = "nr_trim_pages",
79006 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
79007 buffer, lenp, ppos);
79008 }
79009
79010 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79011 + void __user *buffer, size_t *lenp, loff_t *ppos)
79012 +{
79013 + if (write && !capable(CAP_SYS_MODULE))
79014 + return -EPERM;
79015 +
79016 + return _proc_do_string(table->data, table->maxlen, write,
79017 + buffer, lenp, ppos);
79018 +}
79019 +
79020 static size_t proc_skip_spaces(char **buf)
79021 {
79022 size_t ret;
79023 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79024 len = strlen(tmp);
79025 if (len > *size)
79026 len = *size;
79027 + if (len > sizeof(tmp))
79028 + len = sizeof(tmp);
79029 if (copy_to_user(*buf, tmp, len))
79030 return -EFAULT;
79031 *size -= len;
79032 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79033 static int proc_taint(struct ctl_table *table, int write,
79034 void __user *buffer, size_t *lenp, loff_t *ppos)
79035 {
79036 - struct ctl_table t;
79037 + ctl_table_no_const t;
79038 unsigned long tmptaint = get_taint();
79039 int err;
79040
79041 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
79042 return err;
79043 }
79044
79045 -#ifdef CONFIG_PRINTK
79046 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79047 void __user *buffer, size_t *lenp, loff_t *ppos)
79048 {
79049 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79050
79051 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79052 }
79053 -#endif
79054
79055 struct do_proc_dointvec_minmax_conv_param {
79056 int *min;
79057 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79058 *i = val;
79059 } else {
79060 val = convdiv * (*i) / convmul;
79061 - if (!first)
79062 + if (!first) {
79063 err = proc_put_char(&buffer, &left, '\t');
79064 + if (err)
79065 + break;
79066 + }
79067 err = proc_put_long(&buffer, &left, val, false);
79068 if (err)
79069 break;
79070 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
79071 return -ENOSYS;
79072 }
79073
79074 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79075 + void __user *buffer, size_t *lenp, loff_t *ppos)
79076 +{
79077 + return -ENOSYS;
79078 +}
79079 +
79080 int proc_dointvec(struct ctl_table *table, int write,
79081 void __user *buffer, size_t *lenp, loff_t *ppos)
79082 {
79083 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79084 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79085 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79086 EXPORT_SYMBOL(proc_dostring);
79087 +EXPORT_SYMBOL(proc_dostring_modpriv);
79088 EXPORT_SYMBOL(proc_doulongvec_minmax);
79089 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79090 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
79091 index 0ddf3a0..a199f50 100644
79092 --- a/kernel/sysctl_binary.c
79093 +++ b/kernel/sysctl_binary.c
79094 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
79095 int i;
79096
79097 set_fs(KERNEL_DS);
79098 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79099 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79100 set_fs(old_fs);
79101 if (result < 0)
79102 goto out_kfree;
79103 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
79104 }
79105
79106 set_fs(KERNEL_DS);
79107 - result = vfs_write(file, buffer, str - buffer, &pos);
79108 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79109 set_fs(old_fs);
79110 if (result < 0)
79111 goto out_kfree;
79112 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
79113 int i;
79114
79115 set_fs(KERNEL_DS);
79116 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79117 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79118 set_fs(old_fs);
79119 if (result < 0)
79120 goto out_kfree;
79121 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
79122 }
79123
79124 set_fs(KERNEL_DS);
79125 - result = vfs_write(file, buffer, str - buffer, &pos);
79126 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79127 set_fs(old_fs);
79128 if (result < 0)
79129 goto out_kfree;
79130 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
79131 int i;
79132
79133 set_fs(KERNEL_DS);
79134 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79135 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79136 set_fs(old_fs);
79137 if (result < 0)
79138 goto out;
79139 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79140 __le16 dnaddr;
79141
79142 set_fs(KERNEL_DS);
79143 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79144 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79145 set_fs(old_fs);
79146 if (result < 0)
79147 goto out;
79148 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79149 le16_to_cpu(dnaddr) & 0x3ff);
79150
79151 set_fs(KERNEL_DS);
79152 - result = vfs_write(file, buf, len, &pos);
79153 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
79154 set_fs(old_fs);
79155 if (result < 0)
79156 goto out;
79157 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79158 index 145bb4d..b2aa969 100644
79159 --- a/kernel/taskstats.c
79160 +++ b/kernel/taskstats.c
79161 @@ -28,9 +28,12 @@
79162 #include <linux/fs.h>
79163 #include <linux/file.h>
79164 #include <linux/pid_namespace.h>
79165 +#include <linux/grsecurity.h>
79166 #include <net/genetlink.h>
79167 #include <linux/atomic.h>
79168
79169 +extern int gr_is_taskstats_denied(int pid);
79170 +
79171 /*
79172 * Maximum length of a cpumask that can be specified in
79173 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79174 @@ -570,6 +573,9 @@ err:
79175
79176 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79177 {
79178 + if (gr_is_taskstats_denied(current->pid))
79179 + return -EACCES;
79180 +
79181 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79182 return cmd_attr_register_cpumask(info);
79183 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79184 diff --git a/kernel/time.c b/kernel/time.c
79185 index d226c6a..2f0d217 100644
79186 --- a/kernel/time.c
79187 +++ b/kernel/time.c
79188 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79189 return error;
79190
79191 if (tz) {
79192 + /* we log in do_settimeofday called below, so don't log twice
79193 + */
79194 + if (!tv)
79195 + gr_log_timechange();
79196 +
79197 sys_tz = *tz;
79198 update_vsyscall_tz();
79199 if (firsttime) {
79200 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79201 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79202 * value to a scaled second value.
79203 */
79204 -unsigned long
79205 +unsigned long __intentional_overflow(-1)
79206 timespec_to_jiffies(const struct timespec *value)
79207 {
79208 unsigned long sec = value->tv_sec;
79209 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79210 index f11d83b..d016d91 100644
79211 --- a/kernel/time/alarmtimer.c
79212 +++ b/kernel/time/alarmtimer.c
79213 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79214 struct platform_device *pdev;
79215 int error = 0;
79216 int i;
79217 - struct k_clock alarm_clock = {
79218 + static struct k_clock alarm_clock = {
79219 .clock_getres = alarm_clock_getres,
79220 .clock_get = alarm_clock_get,
79221 .timer_create = alarm_timer_create,
79222 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79223 index a13987a..36cd791 100644
79224 --- a/kernel/time/tick-broadcast.c
79225 +++ b/kernel/time/tick-broadcast.c
79226 @@ -116,7 +116,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79227 * then clear the broadcast bit.
79228 */
79229 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79230 - int cpu = smp_processor_id();
79231 + cpu = smp_processor_id();
79232
79233 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
79234 tick_broadcast_clear_oneshot(cpu);
79235 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79236 index cbc6acb..3a77191 100644
79237 --- a/kernel/time/timekeeping.c
79238 +++ b/kernel/time/timekeeping.c
79239 @@ -15,6 +15,7 @@
79240 #include <linux/init.h>
79241 #include <linux/mm.h>
79242 #include <linux/sched.h>
79243 +#include <linux/grsecurity.h>
79244 #include <linux/syscore_ops.h>
79245 #include <linux/clocksource.h>
79246 #include <linux/jiffies.h>
79247 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
79248 if (!timespec_valid_strict(tv))
79249 return -EINVAL;
79250
79251 + gr_log_timechange();
79252 +
79253 write_seqlock_irqsave(&tk->lock, flags);
79254
79255 timekeeping_forward_now(tk);
79256 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79257 index af5a7e9..715611a 100644
79258 --- a/kernel/time/timer_list.c
79259 +++ b/kernel/time/timer_list.c
79260 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79261
79262 static void print_name_offset(struct seq_file *m, void *sym)
79263 {
79264 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79265 + SEQ_printf(m, "<%p>", NULL);
79266 +#else
79267 char symname[KSYM_NAME_LEN];
79268
79269 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79270 SEQ_printf(m, "<%pK>", sym);
79271 else
79272 SEQ_printf(m, "%s", symname);
79273 +#endif
79274 }
79275
79276 static void
79277 @@ -112,7 +116,11 @@ next_one:
79278 static void
79279 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79280 {
79281 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79282 + SEQ_printf(m, " .base: %p\n", NULL);
79283 +#else
79284 SEQ_printf(m, " .base: %pK\n", base);
79285 +#endif
79286 SEQ_printf(m, " .index: %d\n",
79287 base->index);
79288 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79289 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
79290 {
79291 struct proc_dir_entry *pe;
79292
79293 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79294 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79295 +#else
79296 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79297 +#endif
79298 if (!pe)
79299 return -ENOMEM;
79300 return 0;
79301 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79302 index 0b537f2..40d6c20 100644
79303 --- a/kernel/time/timer_stats.c
79304 +++ b/kernel/time/timer_stats.c
79305 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79306 static unsigned long nr_entries;
79307 static struct entry entries[MAX_ENTRIES];
79308
79309 -static atomic_t overflow_count;
79310 +static atomic_unchecked_t overflow_count;
79311
79312 /*
79313 * The entries are in a hash-table, for fast lookup:
79314 @@ -140,7 +140,7 @@ static void reset_entries(void)
79315 nr_entries = 0;
79316 memset(entries, 0, sizeof(entries));
79317 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79318 - atomic_set(&overflow_count, 0);
79319 + atomic_set_unchecked(&overflow_count, 0);
79320 }
79321
79322 static struct entry *alloc_entry(void)
79323 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79324 if (likely(entry))
79325 entry->count++;
79326 else
79327 - atomic_inc(&overflow_count);
79328 + atomic_inc_unchecked(&overflow_count);
79329
79330 out_unlock:
79331 raw_spin_unlock_irqrestore(lock, flags);
79332 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79333
79334 static void print_name_offset(struct seq_file *m, unsigned long addr)
79335 {
79336 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79337 + seq_printf(m, "<%p>", NULL);
79338 +#else
79339 char symname[KSYM_NAME_LEN];
79340
79341 if (lookup_symbol_name(addr, symname) < 0)
79342 - seq_printf(m, "<%p>", (void *)addr);
79343 + seq_printf(m, "<%pK>", (void *)addr);
79344 else
79345 seq_printf(m, "%s", symname);
79346 +#endif
79347 }
79348
79349 static int tstats_show(struct seq_file *m, void *v)
79350 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79351
79352 seq_puts(m, "Timer Stats Version: v0.2\n");
79353 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79354 - if (atomic_read(&overflow_count))
79355 + if (atomic_read_unchecked(&overflow_count))
79356 seq_printf(m, "Overflow: %d entries\n",
79357 - atomic_read(&overflow_count));
79358 + atomic_read_unchecked(&overflow_count));
79359
79360 for (i = 0; i < nr_entries; i++) {
79361 entry = entries + i;
79362 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79363 {
79364 struct proc_dir_entry *pe;
79365
79366 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79367 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79368 +#else
79369 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79370 +#endif
79371 if (!pe)
79372 return -ENOMEM;
79373 return 0;
79374 diff --git a/kernel/timer.c b/kernel/timer.c
79375 index 367d008..5dee98f 100644
79376 --- a/kernel/timer.c
79377 +++ b/kernel/timer.c
79378 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79379 /*
79380 * This function runs timers and the timer-tq in bottom half context.
79381 */
79382 -static void run_timer_softirq(struct softirq_action *h)
79383 +static void run_timer_softirq(void)
79384 {
79385 struct tvec_base *base = __this_cpu_read(tvec_bases);
79386
79387 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79388 *
79389 * In all cases the return value is guaranteed to be non-negative.
79390 */
79391 -signed long __sched schedule_timeout(signed long timeout)
79392 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79393 {
79394 struct timer_list timer;
79395 unsigned long expire;
79396 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79397 return NOTIFY_OK;
79398 }
79399
79400 -static struct notifier_block __cpuinitdata timers_nb = {
79401 +static struct notifier_block timers_nb = {
79402 .notifier_call = timer_cpu_notify,
79403 };
79404
79405 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79406 index c0bd030..62a1927 100644
79407 --- a/kernel/trace/blktrace.c
79408 +++ b/kernel/trace/blktrace.c
79409 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79410 struct blk_trace *bt = filp->private_data;
79411 char buf[16];
79412
79413 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79414 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79415
79416 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79417 }
79418 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79419 return 1;
79420
79421 bt = buf->chan->private_data;
79422 - atomic_inc(&bt->dropped);
79423 + atomic_inc_unchecked(&bt->dropped);
79424 return 0;
79425 }
79426
79427 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79428
79429 bt->dir = dir;
79430 bt->dev = dev;
79431 - atomic_set(&bt->dropped, 0);
79432 + atomic_set_unchecked(&bt->dropped, 0);
79433
79434 ret = -EIO;
79435 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79436 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79437 index 35cc3a8..2a47da3 100644
79438 --- a/kernel/trace/ftrace.c
79439 +++ b/kernel/trace/ftrace.c
79440 @@ -1886,12 +1886,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79441 if (unlikely(ftrace_disabled))
79442 return 0;
79443
79444 + ret = ftrace_arch_code_modify_prepare();
79445 + FTRACE_WARN_ON(ret);
79446 + if (ret)
79447 + return 0;
79448 +
79449 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79450 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79451 if (ret) {
79452 ftrace_bug(ret, ip);
79453 - return 0;
79454 }
79455 - return 1;
79456 + return ret ? 0 : 1;
79457 }
79458
79459 /*
79460 @@ -2964,7 +2969,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79461
79462 int
79463 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79464 - void *data)
79465 + void *data)
79466 {
79467 struct ftrace_func_probe *entry;
79468 struct ftrace_page *pg;
79469 @@ -3831,8 +3836,10 @@ static int ftrace_process_locs(struct module *mod,
79470 if (!count)
79471 return 0;
79472
79473 + pax_open_kernel();
79474 sort(start, count, sizeof(*start),
79475 ftrace_cmp_ips, ftrace_swap_ips);
79476 + pax_close_kernel();
79477
79478 start_pg = ftrace_allocate_pages(count);
79479 if (!start_pg)
79480 @@ -4554,8 +4561,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79481 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79482
79483 static int ftrace_graph_active;
79484 -static struct notifier_block ftrace_suspend_notifier;
79485 -
79486 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79487 {
79488 return 0;
79489 @@ -4699,6 +4704,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79490 return NOTIFY_DONE;
79491 }
79492
79493 +static struct notifier_block ftrace_suspend_notifier = {
79494 + .notifier_call = ftrace_suspend_notifier_call
79495 +};
79496 +
79497 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79498 trace_func_graph_ent_t entryfunc)
79499 {
79500 @@ -4712,7 +4721,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79501 goto out;
79502 }
79503
79504 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79505 register_pm_notifier(&ftrace_suspend_notifier);
79506
79507 ftrace_graph_active++;
79508 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79509 index ce8514f..8233573 100644
79510 --- a/kernel/trace/ring_buffer.c
79511 +++ b/kernel/trace/ring_buffer.c
79512 @@ -346,9 +346,9 @@ struct buffer_data_page {
79513 */
79514 struct buffer_page {
79515 struct list_head list; /* list of buffer pages */
79516 - local_t write; /* index for next write */
79517 + local_unchecked_t write; /* index for next write */
79518 unsigned read; /* index for next read */
79519 - local_t entries; /* entries on this page */
79520 + local_unchecked_t entries; /* entries on this page */
79521 unsigned long real_end; /* real end of data */
79522 struct buffer_data_page *page; /* Actual data page */
79523 };
79524 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
79525 unsigned long last_overrun;
79526 local_t entries_bytes;
79527 local_t entries;
79528 - local_t overrun;
79529 - local_t commit_overrun;
79530 + local_unchecked_t overrun;
79531 + local_unchecked_t commit_overrun;
79532 local_t dropped_events;
79533 local_t committing;
79534 local_t commits;
79535 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79536 *
79537 * We add a counter to the write field to denote this.
79538 */
79539 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79540 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79541 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79542 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79543
79544 /*
79545 * Just make sure we have seen our old_write and synchronize
79546 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79547 * cmpxchg to only update if an interrupt did not already
79548 * do it for us. If the cmpxchg fails, we don't care.
79549 */
79550 - (void)local_cmpxchg(&next_page->write, old_write, val);
79551 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79552 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79553 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79554
79555 /*
79556 * No need to worry about races with clearing out the commit.
79557 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79558
79559 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79560 {
79561 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79562 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79563 }
79564
79565 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79566 {
79567 - return local_read(&bpage->write) & RB_WRITE_MASK;
79568 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79569 }
79570
79571 static int
79572 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79573 * bytes consumed in ring buffer from here.
79574 * Increment overrun to account for the lost events.
79575 */
79576 - local_add(page_entries, &cpu_buffer->overrun);
79577 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79578 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79579 }
79580
79581 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79582 * it is our responsibility to update
79583 * the counters.
79584 */
79585 - local_add(entries, &cpu_buffer->overrun);
79586 + local_add_unchecked(entries, &cpu_buffer->overrun);
79587 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79588
79589 /*
79590 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79591 if (tail == BUF_PAGE_SIZE)
79592 tail_page->real_end = 0;
79593
79594 - local_sub(length, &tail_page->write);
79595 + local_sub_unchecked(length, &tail_page->write);
79596 return;
79597 }
79598
79599 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79600 rb_event_set_padding(event);
79601
79602 /* Set the write back to the previous setting */
79603 - local_sub(length, &tail_page->write);
79604 + local_sub_unchecked(length, &tail_page->write);
79605 return;
79606 }
79607
79608 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79609
79610 /* Set write to end of buffer */
79611 length = (tail + length) - BUF_PAGE_SIZE;
79612 - local_sub(length, &tail_page->write);
79613 + local_sub_unchecked(length, &tail_page->write);
79614 }
79615
79616 /*
79617 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79618 * about it.
79619 */
79620 if (unlikely(next_page == commit_page)) {
79621 - local_inc(&cpu_buffer->commit_overrun);
79622 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79623 goto out_reset;
79624 }
79625
79626 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79627 cpu_buffer->tail_page) &&
79628 (cpu_buffer->commit_page ==
79629 cpu_buffer->reader_page))) {
79630 - local_inc(&cpu_buffer->commit_overrun);
79631 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79632 goto out_reset;
79633 }
79634 }
79635 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79636 length += RB_LEN_TIME_EXTEND;
79637
79638 tail_page = cpu_buffer->tail_page;
79639 - write = local_add_return(length, &tail_page->write);
79640 + write = local_add_return_unchecked(length, &tail_page->write);
79641
79642 /* set write to only the index of the write */
79643 write &= RB_WRITE_MASK;
79644 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79645 kmemcheck_annotate_bitfield(event, bitfield);
79646 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79647
79648 - local_inc(&tail_page->entries);
79649 + local_inc_unchecked(&tail_page->entries);
79650
79651 /*
79652 * If this is the first commit on the page, then update
79653 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79654
79655 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79656 unsigned long write_mask =
79657 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79658 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79659 unsigned long event_length = rb_event_length(event);
79660 /*
79661 * This is on the tail page. It is possible that
79662 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79663 */
79664 old_index += write_mask;
79665 new_index += write_mask;
79666 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79667 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79668 if (index == old_index) {
79669 /* update counters */
79670 local_sub(event_length, &cpu_buffer->entries_bytes);
79671 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79672
79673 /* Do the likely case first */
79674 if (likely(bpage->page == (void *)addr)) {
79675 - local_dec(&bpage->entries);
79676 + local_dec_unchecked(&bpage->entries);
79677 return;
79678 }
79679
79680 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79681 start = bpage;
79682 do {
79683 if (bpage->page == (void *)addr) {
79684 - local_dec(&bpage->entries);
79685 + local_dec_unchecked(&bpage->entries);
79686 return;
79687 }
79688 rb_inc_page(cpu_buffer, &bpage);
79689 @@ -2926,7 +2926,7 @@ static inline unsigned long
79690 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79691 {
79692 return local_read(&cpu_buffer->entries) -
79693 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79694 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79695 }
79696
79697 /**
79698 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79699 return 0;
79700
79701 cpu_buffer = buffer->buffers[cpu];
79702 - ret = local_read(&cpu_buffer->overrun);
79703 + ret = local_read_unchecked(&cpu_buffer->overrun);
79704
79705 return ret;
79706 }
79707 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79708 return 0;
79709
79710 cpu_buffer = buffer->buffers[cpu];
79711 - ret = local_read(&cpu_buffer->commit_overrun);
79712 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79713
79714 return ret;
79715 }
79716 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79717 /* if you care about this being correct, lock the buffer */
79718 for_each_buffer_cpu(buffer, cpu) {
79719 cpu_buffer = buffer->buffers[cpu];
79720 - overruns += local_read(&cpu_buffer->overrun);
79721 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79722 }
79723
79724 return overruns;
79725 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79726 /*
79727 * Reset the reader page to size zero.
79728 */
79729 - local_set(&cpu_buffer->reader_page->write, 0);
79730 - local_set(&cpu_buffer->reader_page->entries, 0);
79731 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79732 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79733 local_set(&cpu_buffer->reader_page->page->commit, 0);
79734 cpu_buffer->reader_page->real_end = 0;
79735
79736 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79737 * want to compare with the last_overrun.
79738 */
79739 smp_mb();
79740 - overwrite = local_read(&(cpu_buffer->overrun));
79741 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79742
79743 /*
79744 * Here's the tricky part.
79745 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79746
79747 cpu_buffer->head_page
79748 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79749 - local_set(&cpu_buffer->head_page->write, 0);
79750 - local_set(&cpu_buffer->head_page->entries, 0);
79751 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79752 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79753 local_set(&cpu_buffer->head_page->page->commit, 0);
79754
79755 cpu_buffer->head_page->read = 0;
79756 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79757
79758 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79759 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79760 - local_set(&cpu_buffer->reader_page->write, 0);
79761 - local_set(&cpu_buffer->reader_page->entries, 0);
79762 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79763 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79764 local_set(&cpu_buffer->reader_page->page->commit, 0);
79765 cpu_buffer->reader_page->read = 0;
79766
79767 local_set(&cpu_buffer->entries_bytes, 0);
79768 - local_set(&cpu_buffer->overrun, 0);
79769 - local_set(&cpu_buffer->commit_overrun, 0);
79770 + local_set_unchecked(&cpu_buffer->overrun, 0);
79771 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79772 local_set(&cpu_buffer->dropped_events, 0);
79773 local_set(&cpu_buffer->entries, 0);
79774 local_set(&cpu_buffer->committing, 0);
79775 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79776 rb_init_page(bpage);
79777 bpage = reader->page;
79778 reader->page = *data_page;
79779 - local_set(&reader->write, 0);
79780 - local_set(&reader->entries, 0);
79781 + local_set_unchecked(&reader->write, 0);
79782 + local_set_unchecked(&reader->entries, 0);
79783 reader->read = 0;
79784 *data_page = bpage;
79785
79786 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79787 index fe1d581..43a0f38 100644
79788 --- a/kernel/trace/trace.c
79789 +++ b/kernel/trace/trace.c
79790 @@ -4494,10 +4494,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79791 };
79792 #endif
79793
79794 -static struct dentry *d_tracer;
79795 -
79796 struct dentry *tracing_init_dentry(void)
79797 {
79798 + static struct dentry *d_tracer;
79799 static int once;
79800
79801 if (d_tracer)
79802 @@ -4517,10 +4516,9 @@ struct dentry *tracing_init_dentry(void)
79803 return d_tracer;
79804 }
79805
79806 -static struct dentry *d_percpu;
79807 -
79808 struct dentry *tracing_dentry_percpu(void)
79809 {
79810 + static struct dentry *d_percpu;
79811 static int once;
79812 struct dentry *d_tracer;
79813
79814 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79815 index 880073d..42db7c3 100644
79816 --- a/kernel/trace/trace_events.c
79817 +++ b/kernel/trace/trace_events.c
79818 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
79819 struct ftrace_module_file_ops {
79820 struct list_head list;
79821 struct module *mod;
79822 - struct file_operations id;
79823 - struct file_operations enable;
79824 - struct file_operations format;
79825 - struct file_operations filter;
79826 };
79827
79828 static struct ftrace_module_file_ops *
79829 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
79830
79831 file_ops->mod = mod;
79832
79833 - file_ops->id = ftrace_event_id_fops;
79834 - file_ops->id.owner = mod;
79835 -
79836 - file_ops->enable = ftrace_enable_fops;
79837 - file_ops->enable.owner = mod;
79838 -
79839 - file_ops->filter = ftrace_event_filter_fops;
79840 - file_ops->filter.owner = mod;
79841 -
79842 - file_ops->format = ftrace_event_format_fops;
79843 - file_ops->format.owner = mod;
79844 + pax_open_kernel();
79845 + mod->trace_id.owner = mod;
79846 + mod->trace_enable.owner = mod;
79847 + mod->trace_filter.owner = mod;
79848 + mod->trace_format.owner = mod;
79849 + pax_close_kernel();
79850
79851 list_add(&file_ops->list, &ftrace_module_file_list);
79852
79853 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
79854
79855 for_each_event(call, start, end) {
79856 __trace_add_event_call(*call, mod,
79857 - &file_ops->id, &file_ops->enable,
79858 - &file_ops->filter, &file_ops->format);
79859 + &mod->trace_id, &mod->trace_enable,
79860 + &mod->trace_filter, &mod->trace_format);
79861 }
79862 }
79863
79864 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
79865 index fd3c8aa..5f324a6 100644
79866 --- a/kernel/trace/trace_mmiotrace.c
79867 +++ b/kernel/trace/trace_mmiotrace.c
79868 @@ -24,7 +24,7 @@ struct header_iter {
79869 static struct trace_array *mmio_trace_array;
79870 static bool overrun_detected;
79871 static unsigned long prev_overruns;
79872 -static atomic_t dropped_count;
79873 +static atomic_unchecked_t dropped_count;
79874
79875 static void mmio_reset_data(struct trace_array *tr)
79876 {
79877 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
79878
79879 static unsigned long count_overruns(struct trace_iterator *iter)
79880 {
79881 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
79882 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
79883 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
79884
79885 if (over > prev_overruns)
79886 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
79887 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
79888 sizeof(*entry), 0, pc);
79889 if (!event) {
79890 - atomic_inc(&dropped_count);
79891 + atomic_inc_unchecked(&dropped_count);
79892 return;
79893 }
79894 entry = ring_buffer_event_data(event);
79895 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
79896 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
79897 sizeof(*entry), 0, pc);
79898 if (!event) {
79899 - atomic_inc(&dropped_count);
79900 + atomic_inc_unchecked(&dropped_count);
79901 return;
79902 }
79903 entry = ring_buffer_event_data(event);
79904 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
79905 index 194d796..76edb8f 100644
79906 --- a/kernel/trace/trace_output.c
79907 +++ b/kernel/trace/trace_output.c
79908 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
79909
79910 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
79911 if (!IS_ERR(p)) {
79912 - p = mangle_path(s->buffer + s->len, p, "\n");
79913 + p = mangle_path(s->buffer + s->len, p, "\n\\");
79914 if (p) {
79915 s->len = p - s->buffer;
79916 return 1;
79917 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
79918 goto out;
79919 }
79920
79921 + pax_open_kernel();
79922 if (event->funcs->trace == NULL)
79923 - event->funcs->trace = trace_nop_print;
79924 + *(void **)&event->funcs->trace = trace_nop_print;
79925 if (event->funcs->raw == NULL)
79926 - event->funcs->raw = trace_nop_print;
79927 + *(void **)&event->funcs->raw = trace_nop_print;
79928 if (event->funcs->hex == NULL)
79929 - event->funcs->hex = trace_nop_print;
79930 + *(void **)&event->funcs->hex = trace_nop_print;
79931 if (event->funcs->binary == NULL)
79932 - event->funcs->binary = trace_nop_print;
79933 + *(void **)&event->funcs->binary = trace_nop_print;
79934 + pax_close_kernel();
79935
79936 key = event->type & (EVENT_HASHSIZE - 1);
79937
79938 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
79939 index 83a8b5b..0bf39a9 100644
79940 --- a/kernel/trace/trace_stack.c
79941 +++ b/kernel/trace/trace_stack.c
79942 @@ -52,7 +52,7 @@ static inline void check_stack(void)
79943 return;
79944
79945 /* we do not handle interrupt stacks yet */
79946 - if (!object_is_on_stack(&this_size))
79947 + if (!object_starts_on_stack(&this_size))
79948 return;
79949
79950 local_irq_save(flags);
79951 diff --git a/kernel/user.c b/kernel/user.c
79952 index 7f6ff2b..1ac8f18 100644
79953 --- a/kernel/user.c
79954 +++ b/kernel/user.c
79955 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
79956 .count = 4294967295U,
79957 },
79958 },
79959 - .kref = {
79960 - .refcount = ATOMIC_INIT(3),
79961 - },
79962 + .count = ATOMIC_INIT(3),
79963 .owner = GLOBAL_ROOT_UID,
79964 .group = GLOBAL_ROOT_GID,
79965 .proc_inum = PROC_USER_INIT_INO,
79966 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
79967 index f45e128..a5a5fb6 100644
79968 --- a/kernel/user_namespace.c
79969 +++ b/kernel/user_namespace.c
79970 @@ -88,7 +88,7 @@ int create_user_ns(struct cred *new)
79971 return ret;
79972 }
79973
79974 - kref_init(&ns->kref);
79975 + atomic_set(&ns->count, 1);
79976 /* Leave the new->user_ns reference with the new user namespace. */
79977 ns->parent = parent_ns;
79978 ns->owner = owner;
79979 @@ -116,15 +116,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
79980 return create_user_ns(cred);
79981 }
79982
79983 -void free_user_ns(struct kref *kref)
79984 +void free_user_ns(struct user_namespace *ns)
79985 {
79986 - struct user_namespace *parent, *ns =
79987 - container_of(kref, struct user_namespace, kref);
79988 + struct user_namespace *parent;
79989
79990 - parent = ns->parent;
79991 - proc_free_inum(ns->proc_inum);
79992 - kmem_cache_free(user_ns_cachep, ns);
79993 - put_user_ns(parent);
79994 + do {
79995 + parent = ns->parent;
79996 + proc_free_inum(ns->proc_inum);
79997 + kmem_cache_free(user_ns_cachep, ns);
79998 + ns = parent;
79999 + } while (atomic_dec_and_test(&parent->count));
80000 }
80001 EXPORT_SYMBOL(free_user_ns);
80002
80003 @@ -815,7 +816,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80004 if (atomic_read(&current->mm->mm_users) > 1)
80005 return -EINVAL;
80006
80007 - if (current->fs->users != 1)
80008 + if (atomic_read(&current->fs->users) != 1)
80009 return -EINVAL;
80010
80011 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80012 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80013 index 63da38c..639904e 100644
80014 --- a/kernel/utsname_sysctl.c
80015 +++ b/kernel/utsname_sysctl.c
80016 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80017 static int proc_do_uts_string(ctl_table *table, int write,
80018 void __user *buffer, size_t *lenp, loff_t *ppos)
80019 {
80020 - struct ctl_table uts_table;
80021 + ctl_table_no_const uts_table;
80022 int r;
80023 memcpy(&uts_table, table, sizeof(uts_table));
80024 uts_table.data = get_uts(table, write);
80025 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80026 index 75a2ab3..5961da7 100644
80027 --- a/kernel/watchdog.c
80028 +++ b/kernel/watchdog.c
80029 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80030 }
80031 #endif /* CONFIG_SYSCTL */
80032
80033 -static struct smp_hotplug_thread watchdog_threads = {
80034 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80035 .store = &softlockup_watchdog,
80036 .thread_should_run = watchdog_should_run,
80037 .thread_fn = watchdog,
80038 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80039 index 67604e5..fe94fb1 100644
80040 --- a/lib/Kconfig.debug
80041 +++ b/lib/Kconfig.debug
80042 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
80043
80044 config DEBUG_LOCK_ALLOC
80045 bool "Lock debugging: detect incorrect freeing of live locks"
80046 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80047 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80048 select DEBUG_SPINLOCK
80049 select DEBUG_MUTEXES
80050 select LOCKDEP
80051 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
80052
80053 config PROVE_LOCKING
80054 bool "Lock debugging: prove locking correctness"
80055 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80056 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80057 select LOCKDEP
80058 select DEBUG_SPINLOCK
80059 select DEBUG_MUTEXES
80060 @@ -670,7 +670,7 @@ config LOCKDEP
80061
80062 config LOCK_STAT
80063 bool "Lock usage statistics"
80064 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80065 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80066 select LOCKDEP
80067 select DEBUG_SPINLOCK
80068 select DEBUG_MUTEXES
80069 @@ -1278,6 +1278,7 @@ config LATENCYTOP
80070 depends on DEBUG_KERNEL
80071 depends on STACKTRACE_SUPPORT
80072 depends on PROC_FS
80073 + depends on !GRKERNSEC_HIDESYM
80074 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80075 select KALLSYMS
80076 select KALLSYMS_ALL
80077 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
80078
80079 config PROVIDE_OHCI1394_DMA_INIT
80080 bool "Remote debugging over FireWire early on boot"
80081 - depends on PCI && X86
80082 + depends on PCI && X86 && !GRKERNSEC
80083 help
80084 If you want to debug problems which hang or crash the kernel early
80085 on boot and the crashing machine has a FireWire port, you can use
80086 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80087
80088 config FIREWIRE_OHCI_REMOTE_DMA
80089 bool "Remote debugging over FireWire with firewire-ohci"
80090 - depends on FIREWIRE_OHCI
80091 + depends on FIREWIRE_OHCI && !GRKERNSEC
80092 help
80093 This option lets you use the FireWire bus for remote debugging
80094 with help of the firewire-ohci driver. It enables unfiltered
80095 diff --git a/lib/Makefile b/lib/Makefile
80096 index 02ed6c0..bd243da 100644
80097 --- a/lib/Makefile
80098 +++ b/lib/Makefile
80099 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80100
80101 obj-$(CONFIG_BTREE) += btree.o
80102 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80103 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80104 +obj-y += list_debug.o
80105 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80106
80107 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80108 diff --git a/lib/bitmap.c b/lib/bitmap.c
80109 index 06f7e4f..f3cf2b0 100644
80110 --- a/lib/bitmap.c
80111 +++ b/lib/bitmap.c
80112 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80113 {
80114 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80115 u32 chunk;
80116 - const char __user __force *ubuf = (const char __user __force *)buf;
80117 + const char __user *ubuf = (const char __force_user *)buf;
80118
80119 bitmap_zero(maskp, nmaskbits);
80120
80121 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80122 {
80123 if (!access_ok(VERIFY_READ, ubuf, ulen))
80124 return -EFAULT;
80125 - return __bitmap_parse((const char __force *)ubuf,
80126 + return __bitmap_parse((const char __force_kernel *)ubuf,
80127 ulen, 1, maskp, nmaskbits);
80128
80129 }
80130 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80131 {
80132 unsigned a, b;
80133 int c, old_c, totaldigits;
80134 - const char __user __force *ubuf = (const char __user __force *)buf;
80135 + const char __user *ubuf = (const char __force_user *)buf;
80136 int exp_digit, in_range;
80137
80138 totaldigits = c = 0;
80139 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80140 {
80141 if (!access_ok(VERIFY_READ, ubuf, ulen))
80142 return -EFAULT;
80143 - return __bitmap_parselist((const char __force *)ubuf,
80144 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80145 ulen, 1, maskp, nmaskbits);
80146 }
80147 EXPORT_SYMBOL(bitmap_parselist_user);
80148 diff --git a/lib/bug.c b/lib/bug.c
80149 index d0cdf14..4d07bd2 100644
80150 --- a/lib/bug.c
80151 +++ b/lib/bug.c
80152 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80153 return BUG_TRAP_TYPE_NONE;
80154
80155 bug = find_bug(bugaddr);
80156 + if (!bug)
80157 + return BUG_TRAP_TYPE_NONE;
80158
80159 file = NULL;
80160 line = 0;
80161 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80162 index d11808c..dc2d6f8 100644
80163 --- a/lib/debugobjects.c
80164 +++ b/lib/debugobjects.c
80165 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80166 if (limit > 4)
80167 return;
80168
80169 - is_on_stack = object_is_on_stack(addr);
80170 + is_on_stack = object_starts_on_stack(addr);
80171 if (is_on_stack == onstack)
80172 return;
80173
80174 diff --git a/lib/devres.c b/lib/devres.c
80175 index 80b9c76..9e32279 100644
80176 --- a/lib/devres.c
80177 +++ b/lib/devres.c
80178 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80179 void devm_iounmap(struct device *dev, void __iomem *addr)
80180 {
80181 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80182 - (void *)addr));
80183 + (void __force *)addr));
80184 iounmap(addr);
80185 }
80186 EXPORT_SYMBOL(devm_iounmap);
80187 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80188 {
80189 ioport_unmap(addr);
80190 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80191 - devm_ioport_map_match, (void *)addr));
80192 + devm_ioport_map_match, (void __force *)addr));
80193 }
80194 EXPORT_SYMBOL(devm_ioport_unmap);
80195
80196 diff --git a/lib/div64.c b/lib/div64.c
80197 index a163b6c..9618fa5 100644
80198 --- a/lib/div64.c
80199 +++ b/lib/div64.c
80200 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80201 EXPORT_SYMBOL(__div64_32);
80202
80203 #ifndef div_s64_rem
80204 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80205 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80206 {
80207 u64 quotient;
80208
80209 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80210 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80211 */
80212 #ifndef div64_u64
80213 -u64 div64_u64(u64 dividend, u64 divisor)
80214 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80215 {
80216 u32 high = divisor >> 32;
80217 u64 quot;
80218 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80219 index 5e396ac..58d5de1 100644
80220 --- a/lib/dma-debug.c
80221 +++ b/lib/dma-debug.c
80222 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80223
80224 void dma_debug_add_bus(struct bus_type *bus)
80225 {
80226 - struct notifier_block *nb;
80227 + notifier_block_no_const *nb;
80228
80229 if (global_disable)
80230 return;
80231 @@ -942,7 +942,7 @@ out:
80232
80233 static void check_for_stack(struct device *dev, void *addr)
80234 {
80235 - if (object_is_on_stack(addr))
80236 + if (object_starts_on_stack(addr))
80237 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80238 "stack [addr=%p]\n", addr);
80239 }
80240 diff --git a/lib/inflate.c b/lib/inflate.c
80241 index 013a761..c28f3fc 100644
80242 --- a/lib/inflate.c
80243 +++ b/lib/inflate.c
80244 @@ -269,7 +269,7 @@ static void free(void *where)
80245 malloc_ptr = free_mem_ptr;
80246 }
80247 #else
80248 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80249 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80250 #define free(a) kfree(a)
80251 #endif
80252
80253 diff --git a/lib/ioremap.c b/lib/ioremap.c
80254 index 0c9216c..863bd89 100644
80255 --- a/lib/ioremap.c
80256 +++ b/lib/ioremap.c
80257 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80258 unsigned long next;
80259
80260 phys_addr -= addr;
80261 - pmd = pmd_alloc(&init_mm, pud, addr);
80262 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80263 if (!pmd)
80264 return -ENOMEM;
80265 do {
80266 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80267 unsigned long next;
80268
80269 phys_addr -= addr;
80270 - pud = pud_alloc(&init_mm, pgd, addr);
80271 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80272 if (!pud)
80273 return -ENOMEM;
80274 do {
80275 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80276 index bd2bea9..6b3c95e 100644
80277 --- a/lib/is_single_threaded.c
80278 +++ b/lib/is_single_threaded.c
80279 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80280 struct task_struct *p, *t;
80281 bool ret;
80282
80283 + if (!mm)
80284 + return true;
80285 +
80286 if (atomic_read(&task->signal->live) != 1)
80287 return false;
80288
80289 diff --git a/lib/kobject.c b/lib/kobject.c
80290 index a654866..a4fd13d 100644
80291 --- a/lib/kobject.c
80292 +++ b/lib/kobject.c
80293 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80294
80295
80296 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80297 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80298 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80299
80300 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80301 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80302 {
80303 enum kobj_ns_type type = ops->type;
80304 int error;
80305 diff --git a/lib/list_debug.c b/lib/list_debug.c
80306 index c24c2f7..06e070b 100644
80307 --- a/lib/list_debug.c
80308 +++ b/lib/list_debug.c
80309 @@ -11,7 +11,9 @@
80310 #include <linux/bug.h>
80311 #include <linux/kernel.h>
80312 #include <linux/rculist.h>
80313 +#include <linux/mm.h>
80314
80315 +#ifdef CONFIG_DEBUG_LIST
80316 /*
80317 * Insert a new entry between two known consecutive entries.
80318 *
80319 @@ -19,21 +21,32 @@
80320 * the prev/next entries already!
80321 */
80322
80323 -void __list_add(struct list_head *new,
80324 - struct list_head *prev,
80325 - struct list_head *next)
80326 +static bool __list_add_debug(struct list_head *new,
80327 + struct list_head *prev,
80328 + struct list_head *next)
80329 {
80330 - WARN(next->prev != prev,
80331 + if (WARN(next->prev != prev,
80332 "list_add corruption. next->prev should be "
80333 "prev (%p), but was %p. (next=%p).\n",
80334 - prev, next->prev, next);
80335 - WARN(prev->next != next,
80336 + prev, next->prev, next) ||
80337 + WARN(prev->next != next,
80338 "list_add corruption. prev->next should be "
80339 "next (%p), but was %p. (prev=%p).\n",
80340 - next, prev->next, prev);
80341 - WARN(new == prev || new == next,
80342 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80343 - new, prev, next);
80344 + next, prev->next, prev) ||
80345 + WARN(new == prev || new == next,
80346 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80347 + new, prev, next))
80348 + return false;
80349 + return true;
80350 +}
80351 +
80352 +void __list_add(struct list_head *new,
80353 + struct list_head *prev,
80354 + struct list_head *next)
80355 +{
80356 + if (!__list_add_debug(new, prev, next))
80357 + return;
80358 +
80359 next->prev = new;
80360 new->next = next;
80361 new->prev = prev;
80362 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80363 }
80364 EXPORT_SYMBOL(__list_add);
80365
80366 -void __list_del_entry(struct list_head *entry)
80367 +static bool __list_del_entry_debug(struct list_head *entry)
80368 {
80369 struct list_head *prev, *next;
80370
80371 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80372 WARN(next->prev != entry,
80373 "list_del corruption. next->prev should be %p, "
80374 "but was %p\n", entry, next->prev))
80375 + return false;
80376 + return true;
80377 +}
80378 +
80379 +void __list_del_entry(struct list_head *entry)
80380 +{
80381 + if (!__list_del_entry_debug(entry))
80382 return;
80383
80384 - __list_del(prev, next);
80385 + __list_del(entry->prev, entry->next);
80386 }
80387 EXPORT_SYMBOL(__list_del_entry);
80388
80389 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80390 void __list_add_rcu(struct list_head *new,
80391 struct list_head *prev, struct list_head *next)
80392 {
80393 - WARN(next->prev != prev,
80394 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80395 - prev, next->prev, next);
80396 - WARN(prev->next != next,
80397 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80398 - next, prev->next, prev);
80399 + if (!__list_add_debug(new, prev, next))
80400 + return;
80401 +
80402 new->next = next;
80403 new->prev = prev;
80404 rcu_assign_pointer(list_next_rcu(prev), new);
80405 next->prev = new;
80406 }
80407 EXPORT_SYMBOL(__list_add_rcu);
80408 +#endif
80409 +
80410 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80411 +{
80412 +#ifdef CONFIG_DEBUG_LIST
80413 + if (!__list_add_debug(new, prev, next))
80414 + return;
80415 +#endif
80416 +
80417 + pax_open_kernel();
80418 + next->prev = new;
80419 + new->next = next;
80420 + new->prev = prev;
80421 + prev->next = new;
80422 + pax_close_kernel();
80423 +}
80424 +EXPORT_SYMBOL(__pax_list_add);
80425 +
80426 +void pax_list_del(struct list_head *entry)
80427 +{
80428 +#ifdef CONFIG_DEBUG_LIST
80429 + if (!__list_del_entry_debug(entry))
80430 + return;
80431 +#endif
80432 +
80433 + pax_open_kernel();
80434 + __list_del(entry->prev, entry->next);
80435 + entry->next = LIST_POISON1;
80436 + entry->prev = LIST_POISON2;
80437 + pax_close_kernel();
80438 +}
80439 +EXPORT_SYMBOL(pax_list_del);
80440 +
80441 +void pax_list_del_init(struct list_head *entry)
80442 +{
80443 + pax_open_kernel();
80444 + __list_del(entry->prev, entry->next);
80445 + INIT_LIST_HEAD(entry);
80446 + pax_close_kernel();
80447 +}
80448 +EXPORT_SYMBOL(pax_list_del_init);
80449 +
80450 +void __pax_list_add_rcu(struct list_head *new,
80451 + struct list_head *prev, struct list_head *next)
80452 +{
80453 +#ifdef CONFIG_DEBUG_LIST
80454 + if (!__list_add_debug(new, prev, next))
80455 + return;
80456 +#endif
80457 +
80458 + pax_open_kernel();
80459 + new->next = next;
80460 + new->prev = prev;
80461 + rcu_assign_pointer(list_next_rcu(prev), new);
80462 + next->prev = new;
80463 + pax_close_kernel();
80464 +}
80465 +EXPORT_SYMBOL(__pax_list_add_rcu);
80466 +
80467 +void pax_list_del_rcu(struct list_head *entry)
80468 +{
80469 +#ifdef CONFIG_DEBUG_LIST
80470 + if (!__list_del_entry_debug(entry))
80471 + return;
80472 +#endif
80473 +
80474 + pax_open_kernel();
80475 + __list_del(entry->prev, entry->next);
80476 + entry->next = LIST_POISON1;
80477 + entry->prev = LIST_POISON2;
80478 + pax_close_kernel();
80479 +}
80480 +EXPORT_SYMBOL(pax_list_del_rcu);
80481 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80482 index e796429..6e38f9f 100644
80483 --- a/lib/radix-tree.c
80484 +++ b/lib/radix-tree.c
80485 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80486 int nr;
80487 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80488 };
80489 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80490 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80491
80492 static inline void *ptr_to_indirect(void *ptr)
80493 {
80494 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80495 index bb2b201..46abaf9 100644
80496 --- a/lib/strncpy_from_user.c
80497 +++ b/lib/strncpy_from_user.c
80498 @@ -21,7 +21,7 @@
80499 */
80500 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80501 {
80502 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80503 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80504 long res = 0;
80505
80506 /*
80507 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80508 index a28df52..3d55877 100644
80509 --- a/lib/strnlen_user.c
80510 +++ b/lib/strnlen_user.c
80511 @@ -26,7 +26,7 @@
80512 */
80513 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80514 {
80515 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80516 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80517 long align, res = 0;
80518 unsigned long c;
80519
80520 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80521 index 196b069..358f342 100644
80522 --- a/lib/swiotlb.c
80523 +++ b/lib/swiotlb.c
80524 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80525
80526 void
80527 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80528 - dma_addr_t dev_addr)
80529 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80530 {
80531 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80532
80533 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80534 index fab33a9..3b5fe68 100644
80535 --- a/lib/vsprintf.c
80536 +++ b/lib/vsprintf.c
80537 @@ -16,6 +16,9 @@
80538 * - scnprintf and vscnprintf
80539 */
80540
80541 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80542 +#define __INCLUDED_BY_HIDESYM 1
80543 +#endif
80544 #include <stdarg.h>
80545 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80546 #include <linux/types.h>
80547 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
80548 char sym[KSYM_SYMBOL_LEN];
80549 if (ext == 'B')
80550 sprint_backtrace(sym, value);
80551 - else if (ext != 'f' && ext != 's')
80552 + else if (ext != 'f' && ext != 's' && ext != 'a')
80553 sprint_symbol(sym, value);
80554 else
80555 sprint_symbol_no_offset(sym, value);
80556 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80557 return number(buf, end, *(const netdev_features_t *)addr, spec);
80558 }
80559
80560 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80561 +int kptr_restrict __read_mostly = 2;
80562 +#else
80563 int kptr_restrict __read_mostly;
80564 +#endif
80565
80566 /*
80567 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80568 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80569 * - 'S' For symbolic direct pointers with offset
80570 * - 's' For symbolic direct pointers without offset
80571 * - 'B' For backtraced symbolic direct pointers with offset
80572 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80573 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80574 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80575 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80576 * - 'M' For a 6-byte MAC address, it prints the address in the
80577 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80578
80579 if (!ptr && *fmt != 'K') {
80580 /*
80581 - * Print (null) with the same width as a pointer so it makes
80582 + * Print (nil) with the same width as a pointer so it makes
80583 * tabular output look nice.
80584 */
80585 if (spec.field_width == -1)
80586 spec.field_width = default_width;
80587 - return string(buf, end, "(null)", spec);
80588 + return string(buf, end, "(nil)", spec);
80589 }
80590
80591 switch (*fmt) {
80592 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80593 /* Fallthrough */
80594 case 'S':
80595 case 's':
80596 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80597 + break;
80598 +#else
80599 + return symbol_string(buf, end, ptr, spec, *fmt);
80600 +#endif
80601 + case 'A':
80602 + case 'a':
80603 case 'B':
80604 return symbol_string(buf, end, ptr, spec, *fmt);
80605 case 'R':
80606 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80607 va_end(va);
80608 return buf;
80609 }
80610 + case 'P':
80611 + break;
80612 case 'K':
80613 /*
80614 * %pK cannot be used in IRQ context because its test
80615 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80616 }
80617 break;
80618 }
80619 +
80620 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80621 + /* 'P' = approved pointers to copy to userland,
80622 + as in the /proc/kallsyms case, as we make it display nothing
80623 + for non-root users, and the real contents for root users
80624 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80625 + above
80626 + */
80627 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80628 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80629 + dump_stack();
80630 + ptr = NULL;
80631 + }
80632 +#endif
80633 +
80634 spec.flags |= SMALL;
80635 if (spec.field_width == -1) {
80636 spec.field_width = default_width;
80637 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80638 typeof(type) value; \
80639 if (sizeof(type) == 8) { \
80640 args = PTR_ALIGN(args, sizeof(u32)); \
80641 - *(u32 *)&value = *(u32 *)args; \
80642 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80643 + *(u32 *)&value = *(const u32 *)args; \
80644 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80645 } else { \
80646 args = PTR_ALIGN(args, sizeof(type)); \
80647 - value = *(typeof(type) *)args; \
80648 + value = *(const typeof(type) *)args; \
80649 } \
80650 args += sizeof(type); \
80651 value; \
80652 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80653 case FORMAT_TYPE_STR: {
80654 const char *str_arg = args;
80655 args += strlen(str_arg) + 1;
80656 - str = string(str, end, (char *)str_arg, spec);
80657 + str = string(str, end, str_arg, spec);
80658 break;
80659 }
80660
80661 diff --git a/localversion-grsec b/localversion-grsec
80662 new file mode 100644
80663 index 0000000..7cd6065
80664 --- /dev/null
80665 +++ b/localversion-grsec
80666 @@ -0,0 +1 @@
80667 +-grsec
80668 diff --git a/mm/Kconfig b/mm/Kconfig
80669 index 278e3ab..87c384d 100644
80670 --- a/mm/Kconfig
80671 +++ b/mm/Kconfig
80672 @@ -286,10 +286,10 @@ config KSM
80673 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80674
80675 config DEFAULT_MMAP_MIN_ADDR
80676 - int "Low address space to protect from user allocation"
80677 + int "Low address space to protect from user allocation"
80678 depends on MMU
80679 - default 4096
80680 - help
80681 + default 65536
80682 + help
80683 This is the portion of low virtual memory which should be protected
80684 from userspace allocation. Keeping a user from writing to low pages
80685 can help reduce the impact of kernel NULL pointer bugs.
80686 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
80687
80688 config HWPOISON_INJECT
80689 tristate "HWPoison pages injector"
80690 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80691 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80692 select PROC_PAGE_MONITOR
80693
80694 config NOMMU_INITIAL_TRIM_EXCESS
80695 diff --git a/mm/filemap.c b/mm/filemap.c
80696 index 83efee7..3f99381 100644
80697 --- a/mm/filemap.c
80698 +++ b/mm/filemap.c
80699 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80700 struct address_space *mapping = file->f_mapping;
80701
80702 if (!mapping->a_ops->readpage)
80703 - return -ENOEXEC;
80704 + return -ENODEV;
80705 file_accessed(file);
80706 vma->vm_ops = &generic_file_vm_ops;
80707 return 0;
80708 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80709 *pos = i_size_read(inode);
80710
80711 if (limit != RLIM_INFINITY) {
80712 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80713 if (*pos >= limit) {
80714 send_sig(SIGXFSZ, current, 0);
80715 return -EFBIG;
80716 diff --git a/mm/fremap.c b/mm/fremap.c
80717 index a0aaf0e..20325c3 100644
80718 --- a/mm/fremap.c
80719 +++ b/mm/fremap.c
80720 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80721 retry:
80722 vma = find_vma(mm, start);
80723
80724 +#ifdef CONFIG_PAX_SEGMEXEC
80725 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80726 + goto out;
80727 +#endif
80728 +
80729 /*
80730 * Make sure the vma is shared, that it supports prefaulting,
80731 * and that the remapped range is valid and fully within
80732 diff --git a/mm/highmem.c b/mm/highmem.c
80733 index b32b70c..e512eb0 100644
80734 --- a/mm/highmem.c
80735 +++ b/mm/highmem.c
80736 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80737 * So no dangers, even with speculative execution.
80738 */
80739 page = pte_page(pkmap_page_table[i]);
80740 + pax_open_kernel();
80741 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80742 -
80743 + pax_close_kernel();
80744 set_page_address(page, NULL);
80745 need_flush = 1;
80746 }
80747 @@ -198,9 +199,11 @@ start:
80748 }
80749 }
80750 vaddr = PKMAP_ADDR(last_pkmap_nr);
80751 +
80752 + pax_open_kernel();
80753 set_pte_at(&init_mm, vaddr,
80754 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80755 -
80756 + pax_close_kernel();
80757 pkmap_count[last_pkmap_nr] = 1;
80758 set_page_address(page, (void *)vaddr);
80759
80760 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80761 index d7cec92..b05cc33 100644
80762 --- a/mm/hugetlb.c
80763 +++ b/mm/hugetlb.c
80764 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80765 struct hstate *h = &default_hstate;
80766 unsigned long tmp;
80767 int ret;
80768 + ctl_table_no_const hugetlb_table;
80769
80770 tmp = h->max_huge_pages;
80771
80772 if (write && h->order >= MAX_ORDER)
80773 return -EINVAL;
80774
80775 - table->data = &tmp;
80776 - table->maxlen = sizeof(unsigned long);
80777 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80778 + hugetlb_table = *table;
80779 + hugetlb_table.data = &tmp;
80780 + hugetlb_table.maxlen = sizeof(unsigned long);
80781 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80782 if (ret)
80783 goto out;
80784
80785 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80786 struct hstate *h = &default_hstate;
80787 unsigned long tmp;
80788 int ret;
80789 + ctl_table_no_const hugetlb_table;
80790
80791 tmp = h->nr_overcommit_huge_pages;
80792
80793 if (write && h->order >= MAX_ORDER)
80794 return -EINVAL;
80795
80796 - table->data = &tmp;
80797 - table->maxlen = sizeof(unsigned long);
80798 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80799 + hugetlb_table = *table;
80800 + hugetlb_table.data = &tmp;
80801 + hugetlb_table.maxlen = sizeof(unsigned long);
80802 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80803 if (ret)
80804 goto out;
80805
80806 @@ -2515,6 +2519,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80807 return 1;
80808 }
80809
80810 +#ifdef CONFIG_PAX_SEGMEXEC
80811 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80812 +{
80813 + struct mm_struct *mm = vma->vm_mm;
80814 + struct vm_area_struct *vma_m;
80815 + unsigned long address_m;
80816 + pte_t *ptep_m;
80817 +
80818 + vma_m = pax_find_mirror_vma(vma);
80819 + if (!vma_m)
80820 + return;
80821 +
80822 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80823 + address_m = address + SEGMEXEC_TASK_SIZE;
80824 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80825 + get_page(page_m);
80826 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80827 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80828 +}
80829 +#endif
80830 +
80831 /*
80832 * Hugetlb_cow() should be called with page lock of the original hugepage held.
80833 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
80834 @@ -2633,6 +2658,11 @@ retry_avoidcopy:
80835 make_huge_pte(vma, new_page, 1));
80836 page_remove_rmap(old_page);
80837 hugepage_add_new_anon_rmap(new_page, vma, address);
80838 +
80839 +#ifdef CONFIG_PAX_SEGMEXEC
80840 + pax_mirror_huge_pte(vma, address, new_page);
80841 +#endif
80842 +
80843 /* Make the old page be freed below */
80844 new_page = old_page;
80845 }
80846 @@ -2792,6 +2822,10 @@ retry:
80847 && (vma->vm_flags & VM_SHARED)));
80848 set_huge_pte_at(mm, address, ptep, new_pte);
80849
80850 +#ifdef CONFIG_PAX_SEGMEXEC
80851 + pax_mirror_huge_pte(vma, address, page);
80852 +#endif
80853 +
80854 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
80855 /* Optimization, do the COW without a second fault */
80856 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
80857 @@ -2821,6 +2855,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80858 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
80859 struct hstate *h = hstate_vma(vma);
80860
80861 +#ifdef CONFIG_PAX_SEGMEXEC
80862 + struct vm_area_struct *vma_m;
80863 +#endif
80864 +
80865 address &= huge_page_mask(h);
80866
80867 ptep = huge_pte_offset(mm, address);
80868 @@ -2834,6 +2872,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80869 VM_FAULT_SET_HINDEX(hstate_index(h));
80870 }
80871
80872 +#ifdef CONFIG_PAX_SEGMEXEC
80873 + vma_m = pax_find_mirror_vma(vma);
80874 + if (vma_m) {
80875 + unsigned long address_m;
80876 +
80877 + if (vma->vm_start > vma_m->vm_start) {
80878 + address_m = address;
80879 + address -= SEGMEXEC_TASK_SIZE;
80880 + vma = vma_m;
80881 + h = hstate_vma(vma);
80882 + } else
80883 + address_m = address + SEGMEXEC_TASK_SIZE;
80884 +
80885 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
80886 + return VM_FAULT_OOM;
80887 + address_m &= HPAGE_MASK;
80888 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
80889 + }
80890 +#endif
80891 +
80892 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
80893 if (!ptep)
80894 return VM_FAULT_OOM;
80895 diff --git a/mm/internal.h b/mm/internal.h
80896 index 9ba2110..eaf0674 100644
80897 --- a/mm/internal.h
80898 +++ b/mm/internal.h
80899 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
80900 * in mm/page_alloc.c
80901 */
80902 extern void __free_pages_bootmem(struct page *page, unsigned int order);
80903 +extern void free_compound_page(struct page *page);
80904 extern void prep_compound_page(struct page *page, unsigned long order);
80905 #ifdef CONFIG_MEMORY_FAILURE
80906 extern bool is_free_buddy_page(struct page *page);
80907 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
80908 index 752a705..6c3102e 100644
80909 --- a/mm/kmemleak.c
80910 +++ b/mm/kmemleak.c
80911 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
80912
80913 for (i = 0; i < object->trace_len; i++) {
80914 void *ptr = (void *)object->trace[i];
80915 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
80916 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
80917 }
80918 }
80919
80920 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
80921 return -ENOMEM;
80922 }
80923
80924 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
80925 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
80926 &kmemleak_fops);
80927 if (!dentry)
80928 pr_warning("Failed to create the debugfs kmemleak file\n");
80929 diff --git a/mm/maccess.c b/mm/maccess.c
80930 index d53adf9..03a24bf 100644
80931 --- a/mm/maccess.c
80932 +++ b/mm/maccess.c
80933 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
80934 set_fs(KERNEL_DS);
80935 pagefault_disable();
80936 ret = __copy_from_user_inatomic(dst,
80937 - (__force const void __user *)src, size);
80938 + (const void __force_user *)src, size);
80939 pagefault_enable();
80940 set_fs(old_fs);
80941
80942 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
80943
80944 set_fs(KERNEL_DS);
80945 pagefault_disable();
80946 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
80947 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
80948 pagefault_enable();
80949 set_fs(old_fs);
80950
80951 diff --git a/mm/madvise.c b/mm/madvise.c
80952 index 03dfa5c..b032917 100644
80953 --- a/mm/madvise.c
80954 +++ b/mm/madvise.c
80955 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
80956 pgoff_t pgoff;
80957 unsigned long new_flags = vma->vm_flags;
80958
80959 +#ifdef CONFIG_PAX_SEGMEXEC
80960 + struct vm_area_struct *vma_m;
80961 +#endif
80962 +
80963 switch (behavior) {
80964 case MADV_NORMAL:
80965 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
80966 @@ -123,6 +127,13 @@ success:
80967 /*
80968 * vm_flags is protected by the mmap_sem held in write mode.
80969 */
80970 +
80971 +#ifdef CONFIG_PAX_SEGMEXEC
80972 + vma_m = pax_find_mirror_vma(vma);
80973 + if (vma_m)
80974 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
80975 +#endif
80976 +
80977 vma->vm_flags = new_flags;
80978
80979 out:
80980 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80981 struct vm_area_struct ** prev,
80982 unsigned long start, unsigned long end)
80983 {
80984 +
80985 +#ifdef CONFIG_PAX_SEGMEXEC
80986 + struct vm_area_struct *vma_m;
80987 +#endif
80988 +
80989 *prev = vma;
80990 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
80991 return -EINVAL;
80992 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80993 zap_page_range(vma, start, end - start, &details);
80994 } else
80995 zap_page_range(vma, start, end - start, NULL);
80996 +
80997 +#ifdef CONFIG_PAX_SEGMEXEC
80998 + vma_m = pax_find_mirror_vma(vma);
80999 + if (vma_m) {
81000 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81001 + struct zap_details details = {
81002 + .nonlinear_vma = vma_m,
81003 + .last_index = ULONG_MAX,
81004 + };
81005 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81006 + } else
81007 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81008 + }
81009 +#endif
81010 +
81011 return 0;
81012 }
81013
81014 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81015 if (end < start)
81016 goto out;
81017
81018 +#ifdef CONFIG_PAX_SEGMEXEC
81019 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81020 + if (end > SEGMEXEC_TASK_SIZE)
81021 + goto out;
81022 + } else
81023 +#endif
81024 +
81025 + if (end > TASK_SIZE)
81026 + goto out;
81027 +
81028 error = 0;
81029 if (end == start)
81030 goto out;
81031 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81032 index c6e4dd3..1f41988 100644
81033 --- a/mm/memory-failure.c
81034 +++ b/mm/memory-failure.c
81035 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81036
81037 int sysctl_memory_failure_recovery __read_mostly = 1;
81038
81039 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81040 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81041
81042 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81043
81044 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81045 pfn, t->comm, t->pid);
81046 si.si_signo = SIGBUS;
81047 si.si_errno = 0;
81048 - si.si_addr = (void *)addr;
81049 + si.si_addr = (void __user *)addr;
81050 #ifdef __ARCH_SI_TRAPNO
81051 si.si_trapno = trapno;
81052 #endif
81053 @@ -760,7 +760,7 @@ static struct page_state {
81054 unsigned long res;
81055 char *msg;
81056 int (*action)(struct page *p, unsigned long pfn);
81057 -} error_states[] = {
81058 +} __do_const error_states[] = {
81059 { reserved, reserved, "reserved kernel", me_kernel },
81060 /*
81061 * free pages are specially detected outside this table:
81062 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81063 }
81064
81065 nr_pages = 1 << compound_trans_order(hpage);
81066 - atomic_long_add(nr_pages, &mce_bad_pages);
81067 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
81068
81069 /*
81070 * We need/can do nothing about count=0 pages.
81071 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81072 if (!PageHWPoison(hpage)
81073 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81074 || (p != hpage && TestSetPageHWPoison(hpage))) {
81075 - atomic_long_sub(nr_pages, &mce_bad_pages);
81076 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81077 return 0;
81078 }
81079 set_page_hwpoison_huge_page(hpage);
81080 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81081 }
81082 if (hwpoison_filter(p)) {
81083 if (TestClearPageHWPoison(p))
81084 - atomic_long_sub(nr_pages, &mce_bad_pages);
81085 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81086 unlock_page(hpage);
81087 put_page(hpage);
81088 return 0;
81089 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
81090 return 0;
81091 }
81092 if (TestClearPageHWPoison(p))
81093 - atomic_long_sub(nr_pages, &mce_bad_pages);
81094 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81095 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81096 return 0;
81097 }
81098 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
81099 */
81100 if (TestClearPageHWPoison(page)) {
81101 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81102 - atomic_long_sub(nr_pages, &mce_bad_pages);
81103 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81104 freeit = 1;
81105 if (PageHuge(page))
81106 clear_page_hwpoison_huge_page(page);
81107 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81108 }
81109 done:
81110 if (!PageHWPoison(hpage))
81111 - atomic_long_add(1 << compound_trans_order(hpage),
81112 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81113 &mce_bad_pages);
81114 set_page_hwpoison_huge_page(hpage);
81115 dequeue_hwpoisoned_huge_page(hpage);
81116 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
81117 return ret;
81118
81119 done:
81120 - atomic_long_add(1, &mce_bad_pages);
81121 + atomic_long_add_unchecked(1, &mce_bad_pages);
81122 SetPageHWPoison(page);
81123 /* keep elevated page count for bad page */
81124 return ret;
81125 diff --git a/mm/memory.c b/mm/memory.c
81126 index f8b734a..38014f5 100644
81127 --- a/mm/memory.c
81128 +++ b/mm/memory.c
81129 @@ -434,6 +434,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81130 free_pte_range(tlb, pmd, addr);
81131 } while (pmd++, addr = next, addr != end);
81132
81133 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81134 start &= PUD_MASK;
81135 if (start < floor)
81136 return;
81137 @@ -448,6 +449,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81138 pmd = pmd_offset(pud, start);
81139 pud_clear(pud);
81140 pmd_free_tlb(tlb, pmd, start);
81141 +#endif
81142 +
81143 }
81144
81145 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81146 @@ -467,6 +470,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81147 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81148 } while (pud++, addr = next, addr != end);
81149
81150 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81151 start &= PGDIR_MASK;
81152 if (start < floor)
81153 return;
81154 @@ -481,6 +485,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81155 pud = pud_offset(pgd, start);
81156 pgd_clear(pgd);
81157 pud_free_tlb(tlb, pud, start);
81158 +#endif
81159 +
81160 }
81161
81162 /*
81163 @@ -1619,12 +1625,6 @@ no_page_table:
81164 return page;
81165 }
81166
81167 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81168 -{
81169 - return stack_guard_page_start(vma, addr) ||
81170 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81171 -}
81172 -
81173 /**
81174 * __get_user_pages() - pin user pages in memory
81175 * @tsk: task_struct of target task
81176 @@ -1710,10 +1710,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81177
81178 i = 0;
81179
81180 - do {
81181 + while (nr_pages) {
81182 struct vm_area_struct *vma;
81183
81184 - vma = find_extend_vma(mm, start);
81185 + vma = find_vma(mm, start);
81186 if (!vma && in_gate_area(mm, start)) {
81187 unsigned long pg = start & PAGE_MASK;
81188 pgd_t *pgd;
81189 @@ -1761,7 +1761,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81190 goto next_page;
81191 }
81192
81193 - if (!vma ||
81194 + if (!vma || start < vma->vm_start ||
81195 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81196 !(vm_flags & vma->vm_flags))
81197 return i ? : -EFAULT;
81198 @@ -1788,11 +1788,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81199 int ret;
81200 unsigned int fault_flags = 0;
81201
81202 - /* For mlock, just skip the stack guard page. */
81203 - if (foll_flags & FOLL_MLOCK) {
81204 - if (stack_guard_page(vma, start))
81205 - goto next_page;
81206 - }
81207 if (foll_flags & FOLL_WRITE)
81208 fault_flags |= FAULT_FLAG_WRITE;
81209 if (nonblocking)
81210 @@ -1866,7 +1861,7 @@ next_page:
81211 start += PAGE_SIZE;
81212 nr_pages--;
81213 } while (nr_pages && start < vma->vm_end);
81214 - } while (nr_pages);
81215 + }
81216 return i;
81217 }
81218 EXPORT_SYMBOL(__get_user_pages);
81219 @@ -2073,6 +2068,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81220 page_add_file_rmap(page);
81221 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81222
81223 +#ifdef CONFIG_PAX_SEGMEXEC
81224 + pax_mirror_file_pte(vma, addr, page, ptl);
81225 +#endif
81226 +
81227 retval = 0;
81228 pte_unmap_unlock(pte, ptl);
81229 return retval;
81230 @@ -2117,9 +2116,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81231 if (!page_count(page))
81232 return -EINVAL;
81233 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81234 +
81235 +#ifdef CONFIG_PAX_SEGMEXEC
81236 + struct vm_area_struct *vma_m;
81237 +#endif
81238 +
81239 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81240 BUG_ON(vma->vm_flags & VM_PFNMAP);
81241 vma->vm_flags |= VM_MIXEDMAP;
81242 +
81243 +#ifdef CONFIG_PAX_SEGMEXEC
81244 + vma_m = pax_find_mirror_vma(vma);
81245 + if (vma_m)
81246 + vma_m->vm_flags |= VM_MIXEDMAP;
81247 +#endif
81248 +
81249 }
81250 return insert_page(vma, addr, page, vma->vm_page_prot);
81251 }
81252 @@ -2202,6 +2213,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81253 unsigned long pfn)
81254 {
81255 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81256 + BUG_ON(vma->vm_mirror);
81257
81258 if (addr < vma->vm_start || addr >= vma->vm_end)
81259 return -EFAULT;
81260 @@ -2402,7 +2414,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81261
81262 BUG_ON(pud_huge(*pud));
81263
81264 - pmd = pmd_alloc(mm, pud, addr);
81265 + pmd = (mm == &init_mm) ?
81266 + pmd_alloc_kernel(mm, pud, addr) :
81267 + pmd_alloc(mm, pud, addr);
81268 if (!pmd)
81269 return -ENOMEM;
81270 do {
81271 @@ -2422,7 +2436,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81272 unsigned long next;
81273 int err;
81274
81275 - pud = pud_alloc(mm, pgd, addr);
81276 + pud = (mm == &init_mm) ?
81277 + pud_alloc_kernel(mm, pgd, addr) :
81278 + pud_alloc(mm, pgd, addr);
81279 if (!pud)
81280 return -ENOMEM;
81281 do {
81282 @@ -2510,6 +2526,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81283 copy_user_highpage(dst, src, va, vma);
81284 }
81285
81286 +#ifdef CONFIG_PAX_SEGMEXEC
81287 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81288 +{
81289 + struct mm_struct *mm = vma->vm_mm;
81290 + spinlock_t *ptl;
81291 + pte_t *pte, entry;
81292 +
81293 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81294 + entry = *pte;
81295 + if (!pte_present(entry)) {
81296 + if (!pte_none(entry)) {
81297 + BUG_ON(pte_file(entry));
81298 + free_swap_and_cache(pte_to_swp_entry(entry));
81299 + pte_clear_not_present_full(mm, address, pte, 0);
81300 + }
81301 + } else {
81302 + struct page *page;
81303 +
81304 + flush_cache_page(vma, address, pte_pfn(entry));
81305 + entry = ptep_clear_flush(vma, address, pte);
81306 + BUG_ON(pte_dirty(entry));
81307 + page = vm_normal_page(vma, address, entry);
81308 + if (page) {
81309 + update_hiwater_rss(mm);
81310 + if (PageAnon(page))
81311 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81312 + else
81313 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81314 + page_remove_rmap(page);
81315 + page_cache_release(page);
81316 + }
81317 + }
81318 + pte_unmap_unlock(pte, ptl);
81319 +}
81320 +
81321 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81322 + *
81323 + * the ptl of the lower mapped page is held on entry and is not released on exit
81324 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81325 + */
81326 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81327 +{
81328 + struct mm_struct *mm = vma->vm_mm;
81329 + unsigned long address_m;
81330 + spinlock_t *ptl_m;
81331 + struct vm_area_struct *vma_m;
81332 + pmd_t *pmd_m;
81333 + pte_t *pte_m, entry_m;
81334 +
81335 + BUG_ON(!page_m || !PageAnon(page_m));
81336 +
81337 + vma_m = pax_find_mirror_vma(vma);
81338 + if (!vma_m)
81339 + return;
81340 +
81341 + BUG_ON(!PageLocked(page_m));
81342 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81343 + address_m = address + SEGMEXEC_TASK_SIZE;
81344 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81345 + pte_m = pte_offset_map(pmd_m, address_m);
81346 + ptl_m = pte_lockptr(mm, pmd_m);
81347 + if (ptl != ptl_m) {
81348 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81349 + if (!pte_none(*pte_m))
81350 + goto out;
81351 + }
81352 +
81353 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81354 + page_cache_get(page_m);
81355 + page_add_anon_rmap(page_m, vma_m, address_m);
81356 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81357 + set_pte_at(mm, address_m, pte_m, entry_m);
81358 + update_mmu_cache(vma_m, address_m, entry_m);
81359 +out:
81360 + if (ptl != ptl_m)
81361 + spin_unlock(ptl_m);
81362 + pte_unmap(pte_m);
81363 + unlock_page(page_m);
81364 +}
81365 +
81366 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81367 +{
81368 + struct mm_struct *mm = vma->vm_mm;
81369 + unsigned long address_m;
81370 + spinlock_t *ptl_m;
81371 + struct vm_area_struct *vma_m;
81372 + pmd_t *pmd_m;
81373 + pte_t *pte_m, entry_m;
81374 +
81375 + BUG_ON(!page_m || PageAnon(page_m));
81376 +
81377 + vma_m = pax_find_mirror_vma(vma);
81378 + if (!vma_m)
81379 + return;
81380 +
81381 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81382 + address_m = address + SEGMEXEC_TASK_SIZE;
81383 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81384 + pte_m = pte_offset_map(pmd_m, address_m);
81385 + ptl_m = pte_lockptr(mm, pmd_m);
81386 + if (ptl != ptl_m) {
81387 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81388 + if (!pte_none(*pte_m))
81389 + goto out;
81390 + }
81391 +
81392 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81393 + page_cache_get(page_m);
81394 + page_add_file_rmap(page_m);
81395 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81396 + set_pte_at(mm, address_m, pte_m, entry_m);
81397 + update_mmu_cache(vma_m, address_m, entry_m);
81398 +out:
81399 + if (ptl != ptl_m)
81400 + spin_unlock(ptl_m);
81401 + pte_unmap(pte_m);
81402 +}
81403 +
81404 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81405 +{
81406 + struct mm_struct *mm = vma->vm_mm;
81407 + unsigned long address_m;
81408 + spinlock_t *ptl_m;
81409 + struct vm_area_struct *vma_m;
81410 + pmd_t *pmd_m;
81411 + pte_t *pte_m, entry_m;
81412 +
81413 + vma_m = pax_find_mirror_vma(vma);
81414 + if (!vma_m)
81415 + return;
81416 +
81417 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81418 + address_m = address + SEGMEXEC_TASK_SIZE;
81419 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81420 + pte_m = pte_offset_map(pmd_m, address_m);
81421 + ptl_m = pte_lockptr(mm, pmd_m);
81422 + if (ptl != ptl_m) {
81423 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81424 + if (!pte_none(*pte_m))
81425 + goto out;
81426 + }
81427 +
81428 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81429 + set_pte_at(mm, address_m, pte_m, entry_m);
81430 +out:
81431 + if (ptl != ptl_m)
81432 + spin_unlock(ptl_m);
81433 + pte_unmap(pte_m);
81434 +}
81435 +
81436 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81437 +{
81438 + struct page *page_m;
81439 + pte_t entry;
81440 +
81441 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81442 + goto out;
81443 +
81444 + entry = *pte;
81445 + page_m = vm_normal_page(vma, address, entry);
81446 + if (!page_m)
81447 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81448 + else if (PageAnon(page_m)) {
81449 + if (pax_find_mirror_vma(vma)) {
81450 + pte_unmap_unlock(pte, ptl);
81451 + lock_page(page_m);
81452 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81453 + if (pte_same(entry, *pte))
81454 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81455 + else
81456 + unlock_page(page_m);
81457 + }
81458 + } else
81459 + pax_mirror_file_pte(vma, address, page_m, ptl);
81460 +
81461 +out:
81462 + pte_unmap_unlock(pte, ptl);
81463 +}
81464 +#endif
81465 +
81466 /*
81467 * This routine handles present pages, when users try to write
81468 * to a shared page. It is done by copying the page to a new address
81469 @@ -2726,6 +2922,12 @@ gotten:
81470 */
81471 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81472 if (likely(pte_same(*page_table, orig_pte))) {
81473 +
81474 +#ifdef CONFIG_PAX_SEGMEXEC
81475 + if (pax_find_mirror_vma(vma))
81476 + BUG_ON(!trylock_page(new_page));
81477 +#endif
81478 +
81479 if (old_page) {
81480 if (!PageAnon(old_page)) {
81481 dec_mm_counter_fast(mm, MM_FILEPAGES);
81482 @@ -2777,6 +2979,10 @@ gotten:
81483 page_remove_rmap(old_page);
81484 }
81485
81486 +#ifdef CONFIG_PAX_SEGMEXEC
81487 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81488 +#endif
81489 +
81490 /* Free the old page.. */
81491 new_page = old_page;
81492 ret |= VM_FAULT_WRITE;
81493 @@ -3052,6 +3258,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81494 swap_free(entry);
81495 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81496 try_to_free_swap(page);
81497 +
81498 +#ifdef CONFIG_PAX_SEGMEXEC
81499 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81500 +#endif
81501 +
81502 unlock_page(page);
81503 if (swapcache) {
81504 /*
81505 @@ -3075,6 +3286,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81506
81507 /* No need to invalidate - it was non-present before */
81508 update_mmu_cache(vma, address, page_table);
81509 +
81510 +#ifdef CONFIG_PAX_SEGMEXEC
81511 + pax_mirror_anon_pte(vma, address, page, ptl);
81512 +#endif
81513 +
81514 unlock:
81515 pte_unmap_unlock(page_table, ptl);
81516 out:
81517 @@ -3094,40 +3310,6 @@ out_release:
81518 }
81519
81520 /*
81521 - * This is like a special single-page "expand_{down|up}wards()",
81522 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81523 - * doesn't hit another vma.
81524 - */
81525 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81526 -{
81527 - address &= PAGE_MASK;
81528 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81529 - struct vm_area_struct *prev = vma->vm_prev;
81530 -
81531 - /*
81532 - * Is there a mapping abutting this one below?
81533 - *
81534 - * That's only ok if it's the same stack mapping
81535 - * that has gotten split..
81536 - */
81537 - if (prev && prev->vm_end == address)
81538 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81539 -
81540 - expand_downwards(vma, address - PAGE_SIZE);
81541 - }
81542 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81543 - struct vm_area_struct *next = vma->vm_next;
81544 -
81545 - /* As VM_GROWSDOWN but s/below/above/ */
81546 - if (next && next->vm_start == address + PAGE_SIZE)
81547 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81548 -
81549 - expand_upwards(vma, address + PAGE_SIZE);
81550 - }
81551 - return 0;
81552 -}
81553 -
81554 -/*
81555 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81556 * but allow concurrent faults), and pte mapped but not yet locked.
81557 * We return with mmap_sem still held, but pte unmapped and unlocked.
81558 @@ -3136,27 +3318,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81559 unsigned long address, pte_t *page_table, pmd_t *pmd,
81560 unsigned int flags)
81561 {
81562 - struct page *page;
81563 + struct page *page = NULL;
81564 spinlock_t *ptl;
81565 pte_t entry;
81566
81567 - pte_unmap(page_table);
81568 -
81569 - /* Check if we need to add a guard page to the stack */
81570 - if (check_stack_guard_page(vma, address) < 0)
81571 - return VM_FAULT_SIGBUS;
81572 -
81573 - /* Use the zero-page for reads */
81574 if (!(flags & FAULT_FLAG_WRITE)) {
81575 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81576 vma->vm_page_prot));
81577 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81578 + ptl = pte_lockptr(mm, pmd);
81579 + spin_lock(ptl);
81580 if (!pte_none(*page_table))
81581 goto unlock;
81582 goto setpte;
81583 }
81584
81585 /* Allocate our own private page. */
81586 + pte_unmap(page_table);
81587 +
81588 if (unlikely(anon_vma_prepare(vma)))
81589 goto oom;
81590 page = alloc_zeroed_user_highpage_movable(vma, address);
81591 @@ -3175,6 +3353,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81592 if (!pte_none(*page_table))
81593 goto release;
81594
81595 +#ifdef CONFIG_PAX_SEGMEXEC
81596 + if (pax_find_mirror_vma(vma))
81597 + BUG_ON(!trylock_page(page));
81598 +#endif
81599 +
81600 inc_mm_counter_fast(mm, MM_ANONPAGES);
81601 page_add_new_anon_rmap(page, vma, address);
81602 setpte:
81603 @@ -3182,6 +3365,12 @@ setpte:
81604
81605 /* No need to invalidate - it was non-present before */
81606 update_mmu_cache(vma, address, page_table);
81607 +
81608 +#ifdef CONFIG_PAX_SEGMEXEC
81609 + if (page)
81610 + pax_mirror_anon_pte(vma, address, page, ptl);
81611 +#endif
81612 +
81613 unlock:
81614 pte_unmap_unlock(page_table, ptl);
81615 return 0;
81616 @@ -3325,6 +3514,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81617 */
81618 /* Only go through if we didn't race with anybody else... */
81619 if (likely(pte_same(*page_table, orig_pte))) {
81620 +
81621 +#ifdef CONFIG_PAX_SEGMEXEC
81622 + if (anon && pax_find_mirror_vma(vma))
81623 + BUG_ON(!trylock_page(page));
81624 +#endif
81625 +
81626 flush_icache_page(vma, page);
81627 entry = mk_pte(page, vma->vm_page_prot);
81628 if (flags & FAULT_FLAG_WRITE)
81629 @@ -3344,6 +3539,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81630
81631 /* no need to invalidate: a not-present page won't be cached */
81632 update_mmu_cache(vma, address, page_table);
81633 +
81634 +#ifdef CONFIG_PAX_SEGMEXEC
81635 + if (anon)
81636 + pax_mirror_anon_pte(vma, address, page, ptl);
81637 + else
81638 + pax_mirror_file_pte(vma, address, page, ptl);
81639 +#endif
81640 +
81641 } else {
81642 if (cow_page)
81643 mem_cgroup_uncharge_page(cow_page);
81644 @@ -3665,6 +3868,12 @@ int handle_pte_fault(struct mm_struct *mm,
81645 if (flags & FAULT_FLAG_WRITE)
81646 flush_tlb_fix_spurious_fault(vma, address);
81647 }
81648 +
81649 +#ifdef CONFIG_PAX_SEGMEXEC
81650 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81651 + return 0;
81652 +#endif
81653 +
81654 unlock:
81655 pte_unmap_unlock(pte, ptl);
81656 return 0;
81657 @@ -3681,6 +3890,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81658 pmd_t *pmd;
81659 pte_t *pte;
81660
81661 +#ifdef CONFIG_PAX_SEGMEXEC
81662 + struct vm_area_struct *vma_m;
81663 +#endif
81664 +
81665 __set_current_state(TASK_RUNNING);
81666
81667 count_vm_event(PGFAULT);
81668 @@ -3692,6 +3905,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81669 if (unlikely(is_vm_hugetlb_page(vma)))
81670 return hugetlb_fault(mm, vma, address, flags);
81671
81672 +#ifdef CONFIG_PAX_SEGMEXEC
81673 + vma_m = pax_find_mirror_vma(vma);
81674 + if (vma_m) {
81675 + unsigned long address_m;
81676 + pgd_t *pgd_m;
81677 + pud_t *pud_m;
81678 + pmd_t *pmd_m;
81679 +
81680 + if (vma->vm_start > vma_m->vm_start) {
81681 + address_m = address;
81682 + address -= SEGMEXEC_TASK_SIZE;
81683 + vma = vma_m;
81684 + } else
81685 + address_m = address + SEGMEXEC_TASK_SIZE;
81686 +
81687 + pgd_m = pgd_offset(mm, address_m);
81688 + pud_m = pud_alloc(mm, pgd_m, address_m);
81689 + if (!pud_m)
81690 + return VM_FAULT_OOM;
81691 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81692 + if (!pmd_m)
81693 + return VM_FAULT_OOM;
81694 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81695 + return VM_FAULT_OOM;
81696 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81697 + }
81698 +#endif
81699 +
81700 retry:
81701 pgd = pgd_offset(mm, address);
81702 pud = pud_alloc(mm, pgd, address);
81703 @@ -3790,6 +4031,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81704 spin_unlock(&mm->page_table_lock);
81705 return 0;
81706 }
81707 +
81708 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81709 +{
81710 + pud_t *new = pud_alloc_one(mm, address);
81711 + if (!new)
81712 + return -ENOMEM;
81713 +
81714 + smp_wmb(); /* See comment in __pte_alloc */
81715 +
81716 + spin_lock(&mm->page_table_lock);
81717 + if (pgd_present(*pgd)) /* Another has populated it */
81718 + pud_free(mm, new);
81719 + else
81720 + pgd_populate_kernel(mm, pgd, new);
81721 + spin_unlock(&mm->page_table_lock);
81722 + return 0;
81723 +}
81724 #endif /* __PAGETABLE_PUD_FOLDED */
81725
81726 #ifndef __PAGETABLE_PMD_FOLDED
81727 @@ -3820,11 +4078,35 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81728 spin_unlock(&mm->page_table_lock);
81729 return 0;
81730 }
81731 +
81732 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81733 +{
81734 + pmd_t *new = pmd_alloc_one(mm, address);
81735 + if (!new)
81736 + return -ENOMEM;
81737 +
81738 + smp_wmb(); /* See comment in __pte_alloc */
81739 +
81740 + spin_lock(&mm->page_table_lock);
81741 +#ifndef __ARCH_HAS_4LEVEL_HACK
81742 + if (pud_present(*pud)) /* Another has populated it */
81743 + pmd_free(mm, new);
81744 + else
81745 + pud_populate_kernel(mm, pud, new);
81746 +#else
81747 + if (pgd_present(*pud)) /* Another has populated it */
81748 + pmd_free(mm, new);
81749 + else
81750 + pgd_populate_kernel(mm, pud, new);
81751 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81752 + spin_unlock(&mm->page_table_lock);
81753 + return 0;
81754 +}
81755 #endif /* __PAGETABLE_PMD_FOLDED */
81756
81757 -int make_pages_present(unsigned long addr, unsigned long end)
81758 +ssize_t make_pages_present(unsigned long addr, unsigned long end)
81759 {
81760 - int ret, len, write;
81761 + ssize_t ret, len, write;
81762 struct vm_area_struct * vma;
81763
81764 vma = find_vma(current->mm, addr);
81765 @@ -3857,7 +4139,7 @@ static int __init gate_vma_init(void)
81766 gate_vma.vm_start = FIXADDR_USER_START;
81767 gate_vma.vm_end = FIXADDR_USER_END;
81768 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81769 - gate_vma.vm_page_prot = __P101;
81770 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81771
81772 return 0;
81773 }
81774 @@ -3991,8 +4273,8 @@ out:
81775 return ret;
81776 }
81777
81778 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81779 - void *buf, int len, int write)
81780 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81781 + void *buf, size_t len, int write)
81782 {
81783 resource_size_t phys_addr;
81784 unsigned long prot = 0;
81785 @@ -4017,8 +4299,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81786 * Access another process' address space as given in mm. If non-NULL, use the
81787 * given task for page fault accounting.
81788 */
81789 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81790 - unsigned long addr, void *buf, int len, int write)
81791 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81792 + unsigned long addr, void *buf, size_t len, int write)
81793 {
81794 struct vm_area_struct *vma;
81795 void *old_buf = buf;
81796 @@ -4026,7 +4308,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81797 down_read(&mm->mmap_sem);
81798 /* ignore errors, just check how much was successfully transferred */
81799 while (len) {
81800 - int bytes, ret, offset;
81801 + ssize_t bytes, ret, offset;
81802 void *maddr;
81803 struct page *page = NULL;
81804
81805 @@ -4085,8 +4367,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81806 *
81807 * The caller must hold a reference on @mm.
81808 */
81809 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81810 - void *buf, int len, int write)
81811 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81812 + void *buf, size_t len, int write)
81813 {
81814 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81815 }
81816 @@ -4096,11 +4378,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81817 * Source/target buffer must be kernel space,
81818 * Do not walk the page table directly, use get_user_pages
81819 */
81820 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81821 - void *buf, int len, int write)
81822 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81823 + void *buf, size_t len, int write)
81824 {
81825 struct mm_struct *mm;
81826 - int ret;
81827 + ssize_t ret;
81828
81829 mm = get_task_mm(tsk);
81830 if (!mm)
81831 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81832 index 3df6d12..a11056a 100644
81833 --- a/mm/mempolicy.c
81834 +++ b/mm/mempolicy.c
81835 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81836 unsigned long vmstart;
81837 unsigned long vmend;
81838
81839 +#ifdef CONFIG_PAX_SEGMEXEC
81840 + struct vm_area_struct *vma_m;
81841 +#endif
81842 +
81843 vma = find_vma(mm, start);
81844 if (!vma || vma->vm_start > start)
81845 return -EFAULT;
81846 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81847 if (err)
81848 goto out;
81849 }
81850 +
81851 err = vma_replace_policy(vma, new_pol);
81852 if (err)
81853 goto out;
81854 +
81855 +#ifdef CONFIG_PAX_SEGMEXEC
81856 + vma_m = pax_find_mirror_vma(vma);
81857 + if (vma_m) {
81858 + err = vma_replace_policy(vma_m, new_pol);
81859 + if (err)
81860 + goto out;
81861 + }
81862 +#endif
81863 +
81864 }
81865
81866 out:
81867 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
81868
81869 if (end < start)
81870 return -EINVAL;
81871 +
81872 +#ifdef CONFIG_PAX_SEGMEXEC
81873 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81874 + if (end > SEGMEXEC_TASK_SIZE)
81875 + return -EINVAL;
81876 + } else
81877 +#endif
81878 +
81879 + if (end > TASK_SIZE)
81880 + return -EINVAL;
81881 +
81882 if (end == start)
81883 return 0;
81884
81885 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81886 */
81887 tcred = __task_cred(task);
81888 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81889 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81890 - !capable(CAP_SYS_NICE)) {
81891 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81892 rcu_read_unlock();
81893 err = -EPERM;
81894 goto out_put;
81895 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81896 goto out;
81897 }
81898
81899 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81900 + if (mm != current->mm &&
81901 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
81902 + mmput(mm);
81903 + err = -EPERM;
81904 + goto out;
81905 + }
81906 +#endif
81907 +
81908 err = do_migrate_pages(mm, old, new,
81909 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
81910
81911 diff --git a/mm/migrate.c b/mm/migrate.c
81912 index 2fd8b4a..d70358f 100644
81913 --- a/mm/migrate.c
81914 +++ b/mm/migrate.c
81915 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
81916 */
81917 tcred = __task_cred(task);
81918 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81919 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81920 - !capable(CAP_SYS_NICE)) {
81921 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81922 rcu_read_unlock();
81923 err = -EPERM;
81924 goto out;
81925 diff --git a/mm/mlock.c b/mm/mlock.c
81926 index c9bd528..da8d069 100644
81927 --- a/mm/mlock.c
81928 +++ b/mm/mlock.c
81929 @@ -13,6 +13,7 @@
81930 #include <linux/pagemap.h>
81931 #include <linux/mempolicy.h>
81932 #include <linux/syscalls.h>
81933 +#include <linux/security.h>
81934 #include <linux/sched.h>
81935 #include <linux/export.h>
81936 #include <linux/rmap.h>
81937 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
81938 {
81939 unsigned long nstart, end, tmp;
81940 struct vm_area_struct * vma, * prev;
81941 - int error;
81942 + int error = 0;
81943
81944 VM_BUG_ON(start & ~PAGE_MASK);
81945 VM_BUG_ON(len != PAGE_ALIGN(len));
81946 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
81947 return -EINVAL;
81948 if (end == start)
81949 return 0;
81950 + if (end > TASK_SIZE)
81951 + return -EINVAL;
81952 +
81953 vma = find_vma(current->mm, start);
81954 if (!vma || vma->vm_start > start)
81955 return -ENOMEM;
81956 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
81957 for (nstart = start ; ; ) {
81958 vm_flags_t newflags;
81959
81960 +#ifdef CONFIG_PAX_SEGMEXEC
81961 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81962 + break;
81963 +#endif
81964 +
81965 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
81966
81967 newflags = vma->vm_flags | VM_LOCKED;
81968 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
81969 lock_limit >>= PAGE_SHIFT;
81970
81971 /* check against resource limits */
81972 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
81973 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
81974 error = do_mlock(start, len, 1);
81975 up_write(&current->mm->mmap_sem);
81976 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
81977 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
81978 vm_flags_t newflags;
81979
81980 +#ifdef CONFIG_PAX_SEGMEXEC
81981 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81982 + break;
81983 +#endif
81984 +
81985 + BUG_ON(vma->vm_end > TASK_SIZE);
81986 newflags = vma->vm_flags | VM_LOCKED;
81987 if (!(flags & MCL_CURRENT))
81988 newflags &= ~VM_LOCKED;
81989 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
81990 lock_limit >>= PAGE_SHIFT;
81991
81992 ret = -ENOMEM;
81993 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
81994 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
81995 capable(CAP_IPC_LOCK))
81996 ret = do_mlockall(flags);
81997 diff --git a/mm/mmap.c b/mm/mmap.c
81998 index 90db251..04240d1 100644
81999 --- a/mm/mmap.c
82000 +++ b/mm/mmap.c
82001 @@ -32,6 +32,7 @@
82002 #include <linux/khugepaged.h>
82003 #include <linux/uprobes.h>
82004 #include <linux/rbtree_augmented.h>
82005 +#include <linux/random.h>
82006
82007 #include <asm/uaccess.h>
82008 #include <asm/cacheflush.h>
82009 @@ -48,6 +49,16 @@
82010 #define arch_rebalance_pgtables(addr, len) (addr)
82011 #endif
82012
82013 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82014 +{
82015 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82016 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82017 + up_read(&mm->mmap_sem);
82018 + BUG();
82019 + }
82020 +#endif
82021 +}
82022 +
82023 static void unmap_region(struct mm_struct *mm,
82024 struct vm_area_struct *vma, struct vm_area_struct *prev,
82025 unsigned long start, unsigned long end);
82026 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
82027 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82028 *
82029 */
82030 -pgprot_t protection_map[16] = {
82031 +pgprot_t protection_map[16] __read_only = {
82032 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82033 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82034 };
82035
82036 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82037 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82038 {
82039 - return __pgprot(pgprot_val(protection_map[vm_flags &
82040 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82041 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82042 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82043 +
82044 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82045 + if (!(__supported_pte_mask & _PAGE_NX) &&
82046 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82047 + (vm_flags & (VM_READ | VM_WRITE)))
82048 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82049 +#endif
82050 +
82051 + return prot;
82052 }
82053 EXPORT_SYMBOL(vm_get_page_prot);
82054
82055 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
82056 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82057 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82058 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82059 /*
82060 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82061 * other variables. It can be updated by several CPUs frequently.
82062 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82063 struct vm_area_struct *next = vma->vm_next;
82064
82065 might_sleep();
82066 + BUG_ON(vma->vm_mirror);
82067 if (vma->vm_ops && vma->vm_ops->close)
82068 vma->vm_ops->close(vma);
82069 if (vma->vm_file)
82070 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82071 * not page aligned -Ram Gupta
82072 */
82073 rlim = rlimit(RLIMIT_DATA);
82074 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82075 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82076 (mm->end_data - mm->start_data) > rlim)
82077 goto out;
82078 @@ -888,6 +911,12 @@ static int
82079 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82080 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82081 {
82082 +
82083 +#ifdef CONFIG_PAX_SEGMEXEC
82084 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82085 + return 0;
82086 +#endif
82087 +
82088 if (is_mergeable_vma(vma, file, vm_flags) &&
82089 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82090 if (vma->vm_pgoff == vm_pgoff)
82091 @@ -907,6 +936,12 @@ static int
82092 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82093 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82094 {
82095 +
82096 +#ifdef CONFIG_PAX_SEGMEXEC
82097 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82098 + return 0;
82099 +#endif
82100 +
82101 if (is_mergeable_vma(vma, file, vm_flags) &&
82102 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82103 pgoff_t vm_pglen;
82104 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82105 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82106 struct vm_area_struct *prev, unsigned long addr,
82107 unsigned long end, unsigned long vm_flags,
82108 - struct anon_vma *anon_vma, struct file *file,
82109 + struct anon_vma *anon_vma, struct file *file,
82110 pgoff_t pgoff, struct mempolicy *policy)
82111 {
82112 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82113 struct vm_area_struct *area, *next;
82114 int err;
82115
82116 +#ifdef CONFIG_PAX_SEGMEXEC
82117 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82118 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82119 +
82120 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82121 +#endif
82122 +
82123 /*
82124 * We later require that vma->vm_flags == vm_flags,
82125 * so this tests vma->vm_flags & VM_SPECIAL, too.
82126 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82127 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82128 next = next->vm_next;
82129
82130 +#ifdef CONFIG_PAX_SEGMEXEC
82131 + if (prev)
82132 + prev_m = pax_find_mirror_vma(prev);
82133 + if (area)
82134 + area_m = pax_find_mirror_vma(area);
82135 + if (next)
82136 + next_m = pax_find_mirror_vma(next);
82137 +#endif
82138 +
82139 /*
82140 * Can it merge with the predecessor?
82141 */
82142 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82143 /* cases 1, 6 */
82144 err = vma_adjust(prev, prev->vm_start,
82145 next->vm_end, prev->vm_pgoff, NULL);
82146 - } else /* cases 2, 5, 7 */
82147 +
82148 +#ifdef CONFIG_PAX_SEGMEXEC
82149 + if (!err && prev_m)
82150 + err = vma_adjust(prev_m, prev_m->vm_start,
82151 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82152 +#endif
82153 +
82154 + } else { /* cases 2, 5, 7 */
82155 err = vma_adjust(prev, prev->vm_start,
82156 end, prev->vm_pgoff, NULL);
82157 +
82158 +#ifdef CONFIG_PAX_SEGMEXEC
82159 + if (!err && prev_m)
82160 + err = vma_adjust(prev_m, prev_m->vm_start,
82161 + end_m, prev_m->vm_pgoff, NULL);
82162 +#endif
82163 +
82164 + }
82165 if (err)
82166 return NULL;
82167 khugepaged_enter_vma_merge(prev);
82168 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82169 mpol_equal(policy, vma_policy(next)) &&
82170 can_vma_merge_before(next, vm_flags,
82171 anon_vma, file, pgoff+pglen)) {
82172 - if (prev && addr < prev->vm_end) /* case 4 */
82173 + if (prev && addr < prev->vm_end) { /* case 4 */
82174 err = vma_adjust(prev, prev->vm_start,
82175 addr, prev->vm_pgoff, NULL);
82176 - else /* cases 3, 8 */
82177 +
82178 +#ifdef CONFIG_PAX_SEGMEXEC
82179 + if (!err && prev_m)
82180 + err = vma_adjust(prev_m, prev_m->vm_start,
82181 + addr_m, prev_m->vm_pgoff, NULL);
82182 +#endif
82183 +
82184 + } else { /* cases 3, 8 */
82185 err = vma_adjust(area, addr, next->vm_end,
82186 next->vm_pgoff - pglen, NULL);
82187 +
82188 +#ifdef CONFIG_PAX_SEGMEXEC
82189 + if (!err && area_m)
82190 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82191 + next_m->vm_pgoff - pglen, NULL);
82192 +#endif
82193 +
82194 + }
82195 if (err)
82196 return NULL;
82197 khugepaged_enter_vma_merge(area);
82198 @@ -1120,8 +1201,10 @@ none:
82199 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82200 struct file *file, long pages)
82201 {
82202 - const unsigned long stack_flags
82203 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82204 +
82205 +#ifdef CONFIG_PAX_RANDMMAP
82206 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82207 +#endif
82208
82209 mm->total_vm += pages;
82210
82211 @@ -1129,7 +1212,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82212 mm->shared_vm += pages;
82213 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82214 mm->exec_vm += pages;
82215 - } else if (flags & stack_flags)
82216 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82217 mm->stack_vm += pages;
82218 }
82219 #endif /* CONFIG_PROC_FS */
82220 @@ -1165,7 +1248,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82221 * (the exception is when the underlying filesystem is noexec
82222 * mounted, in which case we dont add PROT_EXEC.)
82223 */
82224 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82225 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82226 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82227 prot |= PROT_EXEC;
82228
82229 @@ -1191,7 +1274,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82230 /* Obtain the address to map to. we verify (or select) it and ensure
82231 * that it represents a valid section of the address space.
82232 */
82233 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82234 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82235 if (addr & ~PAGE_MASK)
82236 return addr;
82237
82238 @@ -1202,6 +1285,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82239 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82240 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82241
82242 +#ifdef CONFIG_PAX_MPROTECT
82243 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82244 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82245 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82246 + gr_log_rwxmmap(file);
82247 +
82248 +#ifdef CONFIG_PAX_EMUPLT
82249 + vm_flags &= ~VM_EXEC;
82250 +#else
82251 + return -EPERM;
82252 +#endif
82253 +
82254 + }
82255 +
82256 + if (!(vm_flags & VM_EXEC))
82257 + vm_flags &= ~VM_MAYEXEC;
82258 +#else
82259 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82260 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82261 +#endif
82262 + else
82263 + vm_flags &= ~VM_MAYWRITE;
82264 + }
82265 +#endif
82266 +
82267 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82268 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82269 + vm_flags &= ~VM_PAGEEXEC;
82270 +#endif
82271 +
82272 if (flags & MAP_LOCKED)
82273 if (!can_do_mlock())
82274 return -EPERM;
82275 @@ -1213,6 +1326,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82276 locked += mm->locked_vm;
82277 lock_limit = rlimit(RLIMIT_MEMLOCK);
82278 lock_limit >>= PAGE_SHIFT;
82279 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82280 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82281 return -EAGAIN;
82282 }
82283 @@ -1279,6 +1393,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82284 }
82285 }
82286
82287 + if (!gr_acl_handle_mmap(file, prot))
82288 + return -EACCES;
82289 +
82290 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
82291 }
82292
82293 @@ -1356,7 +1473,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82294 vm_flags_t vm_flags = vma->vm_flags;
82295
82296 /* If it was private or non-writable, the write bit is already clear */
82297 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82298 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82299 return 0;
82300
82301 /* The backer wishes to know when pages are first written to? */
82302 @@ -1405,16 +1522,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82303 unsigned long charged = 0;
82304 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
82305
82306 +#ifdef CONFIG_PAX_SEGMEXEC
82307 + struct vm_area_struct *vma_m = NULL;
82308 +#endif
82309 +
82310 + /*
82311 + * mm->mmap_sem is required to protect against another thread
82312 + * changing the mappings in case we sleep.
82313 + */
82314 + verify_mm_writelocked(mm);
82315 +
82316 /* Clear old maps */
82317 error = -ENOMEM;
82318 -munmap_back:
82319 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82320 if (do_munmap(mm, addr, len))
82321 return -ENOMEM;
82322 - goto munmap_back;
82323 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82324 }
82325
82326 /* Check against address space limit. */
82327 +
82328 +#ifdef CONFIG_PAX_RANDMMAP
82329 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82330 +#endif
82331 +
82332 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82333 return -ENOMEM;
82334
82335 @@ -1460,6 +1591,16 @@ munmap_back:
82336 goto unacct_error;
82337 }
82338
82339 +#ifdef CONFIG_PAX_SEGMEXEC
82340 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82341 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82342 + if (!vma_m) {
82343 + error = -ENOMEM;
82344 + goto free_vma;
82345 + }
82346 + }
82347 +#endif
82348 +
82349 vma->vm_mm = mm;
82350 vma->vm_start = addr;
82351 vma->vm_end = addr + len;
82352 @@ -1484,6 +1625,13 @@ munmap_back:
82353 if (error)
82354 goto unmap_and_free_vma;
82355
82356 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82357 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82358 + vma->vm_flags |= VM_PAGEEXEC;
82359 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82360 + }
82361 +#endif
82362 +
82363 /* Can addr have changed??
82364 *
82365 * Answer: Yes, several device drivers can do it in their
82366 @@ -1522,6 +1670,11 @@ munmap_back:
82367 vma_link(mm, vma, prev, rb_link, rb_parent);
82368 file = vma->vm_file;
82369
82370 +#ifdef CONFIG_PAX_SEGMEXEC
82371 + if (vma_m)
82372 + BUG_ON(pax_mirror_vma(vma_m, vma));
82373 +#endif
82374 +
82375 /* Once vma denies write, undo our temporary denial count */
82376 if (correct_wcount)
82377 atomic_inc(&inode->i_writecount);
82378 @@ -1529,6 +1682,7 @@ out:
82379 perf_event_mmap(vma);
82380
82381 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82382 + track_exec_limit(mm, addr, addr + len, vm_flags);
82383 if (vm_flags & VM_LOCKED) {
82384 if (!mlock_vma_pages_range(vma, addr, addr + len))
82385 mm->locked_vm += (len >> PAGE_SHIFT);
82386 @@ -1550,6 +1704,12 @@ unmap_and_free_vma:
82387 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82388 charged = 0;
82389 free_vma:
82390 +
82391 +#ifdef CONFIG_PAX_SEGMEXEC
82392 + if (vma_m)
82393 + kmem_cache_free(vm_area_cachep, vma_m);
82394 +#endif
82395 +
82396 kmem_cache_free(vm_area_cachep, vma);
82397 unacct_error:
82398 if (charged)
82399 @@ -1557,6 +1717,62 @@ unacct_error:
82400 return error;
82401 }
82402
82403 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82404 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82405 +{
82406 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82407 + return (random32() & 0xFF) << PAGE_SHIFT;
82408 +
82409 + return 0;
82410 +}
82411 +#endif
82412 +
82413 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82414 +{
82415 + if (!vma) {
82416 +#ifdef CONFIG_STACK_GROWSUP
82417 + if (addr > sysctl_heap_stack_gap)
82418 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82419 + else
82420 + vma = find_vma(current->mm, 0);
82421 + if (vma && (vma->vm_flags & VM_GROWSUP))
82422 + return false;
82423 +#endif
82424 + return true;
82425 + }
82426 +
82427 + if (addr + len > vma->vm_start)
82428 + return false;
82429 +
82430 + if (vma->vm_flags & VM_GROWSDOWN)
82431 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82432 +#ifdef CONFIG_STACK_GROWSUP
82433 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82434 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82435 +#endif
82436 + else if (offset)
82437 + return offset <= vma->vm_start - addr - len;
82438 +
82439 + return true;
82440 +}
82441 +
82442 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82443 +{
82444 + if (vma->vm_start < len)
82445 + return -ENOMEM;
82446 +
82447 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82448 + if (offset <= vma->vm_start - len)
82449 + return vma->vm_start - len - offset;
82450 + else
82451 + return -ENOMEM;
82452 + }
82453 +
82454 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82455 + return vma->vm_start - len - sysctl_heap_stack_gap;
82456 + return -ENOMEM;
82457 +}
82458 +
82459 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82460 {
82461 /*
82462 @@ -1776,6 +1992,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82463 struct mm_struct *mm = current->mm;
82464 struct vm_area_struct *vma;
82465 struct vm_unmapped_area_info info;
82466 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82467
82468 if (len > TASK_SIZE)
82469 return -ENOMEM;
82470 @@ -1783,17 +2000,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82471 if (flags & MAP_FIXED)
82472 return addr;
82473
82474 +#ifdef CONFIG_PAX_RANDMMAP
82475 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82476 +#endif
82477 +
82478 if (addr) {
82479 addr = PAGE_ALIGN(addr);
82480 vma = find_vma(mm, addr);
82481 - if (TASK_SIZE - len >= addr &&
82482 - (!vma || addr + len <= vma->vm_start))
82483 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82484 return addr;
82485 }
82486
82487 info.flags = 0;
82488 info.length = len;
82489 info.low_limit = TASK_UNMAPPED_BASE;
82490 +
82491 +#ifdef CONFIG_PAX_RANDMMAP
82492 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82493 + info.low_limit += mm->delta_mmap;
82494 +#endif
82495 +
82496 info.high_limit = TASK_SIZE;
82497 info.align_mask = 0;
82498 return vm_unmapped_area(&info);
82499 @@ -1802,10 +2028,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82500
82501 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82502 {
82503 +
82504 +#ifdef CONFIG_PAX_SEGMEXEC
82505 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82506 + return;
82507 +#endif
82508 +
82509 /*
82510 * Is this a new hole at the lowest possible address?
82511 */
82512 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82513 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82514 mm->free_area_cache = addr;
82515 }
82516
82517 @@ -1823,6 +2055,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82518 struct mm_struct *mm = current->mm;
82519 unsigned long addr = addr0;
82520 struct vm_unmapped_area_info info;
82521 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82522
82523 /* requested length too big for entire address space */
82524 if (len > TASK_SIZE)
82525 @@ -1831,12 +2064,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82526 if (flags & MAP_FIXED)
82527 return addr;
82528
82529 +#ifdef CONFIG_PAX_RANDMMAP
82530 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82531 +#endif
82532 +
82533 /* requesting a specific address */
82534 if (addr) {
82535 addr = PAGE_ALIGN(addr);
82536 vma = find_vma(mm, addr);
82537 - if (TASK_SIZE - len >= addr &&
82538 - (!vma || addr + len <= vma->vm_start))
82539 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82540 return addr;
82541 }
82542
82543 @@ -1857,6 +2093,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82544 VM_BUG_ON(addr != -ENOMEM);
82545 info.flags = 0;
82546 info.low_limit = TASK_UNMAPPED_BASE;
82547 +
82548 +#ifdef CONFIG_PAX_RANDMMAP
82549 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82550 + info.low_limit += mm->delta_mmap;
82551 +#endif
82552 +
82553 info.high_limit = TASK_SIZE;
82554 addr = vm_unmapped_area(&info);
82555 }
82556 @@ -1867,6 +2109,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82557
82558 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82559 {
82560 +
82561 +#ifdef CONFIG_PAX_SEGMEXEC
82562 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82563 + return;
82564 +#endif
82565 +
82566 /*
82567 * Is this a new hole at the highest possible address?
82568 */
82569 @@ -1874,8 +2122,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82570 mm->free_area_cache = addr;
82571
82572 /* dont allow allocations above current base */
82573 - if (mm->free_area_cache > mm->mmap_base)
82574 + if (mm->free_area_cache > mm->mmap_base) {
82575 mm->free_area_cache = mm->mmap_base;
82576 + mm->cached_hole_size = ~0UL;
82577 + }
82578 }
82579
82580 unsigned long
82581 @@ -1974,6 +2224,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82582 return vma;
82583 }
82584
82585 +#ifdef CONFIG_PAX_SEGMEXEC
82586 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82587 +{
82588 + struct vm_area_struct *vma_m;
82589 +
82590 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82591 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82592 + BUG_ON(vma->vm_mirror);
82593 + return NULL;
82594 + }
82595 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82596 + vma_m = vma->vm_mirror;
82597 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82598 + BUG_ON(vma->vm_file != vma_m->vm_file);
82599 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82600 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82601 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82602 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82603 + return vma_m;
82604 +}
82605 +#endif
82606 +
82607 /*
82608 * Verify that the stack growth is acceptable and
82609 * update accounting. This is shared with both the
82610 @@ -1990,6 +2262,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82611 return -ENOMEM;
82612
82613 /* Stack limit test */
82614 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82615 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82616 return -ENOMEM;
82617
82618 @@ -2000,6 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82619 locked = mm->locked_vm + grow;
82620 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82621 limit >>= PAGE_SHIFT;
82622 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82623 if (locked > limit && !capable(CAP_IPC_LOCK))
82624 return -ENOMEM;
82625 }
82626 @@ -2029,37 +2303,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82627 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82628 * vma is the last one with address > vma->vm_end. Have to extend vma.
82629 */
82630 +#ifndef CONFIG_IA64
82631 +static
82632 +#endif
82633 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82634 {
82635 int error;
82636 + bool locknext;
82637
82638 if (!(vma->vm_flags & VM_GROWSUP))
82639 return -EFAULT;
82640
82641 + /* Also guard against wrapping around to address 0. */
82642 + if (address < PAGE_ALIGN(address+1))
82643 + address = PAGE_ALIGN(address+1);
82644 + else
82645 + return -ENOMEM;
82646 +
82647 /*
82648 * We must make sure the anon_vma is allocated
82649 * so that the anon_vma locking is not a noop.
82650 */
82651 if (unlikely(anon_vma_prepare(vma)))
82652 return -ENOMEM;
82653 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82654 + if (locknext && anon_vma_prepare(vma->vm_next))
82655 + return -ENOMEM;
82656 vma_lock_anon_vma(vma);
82657 + if (locknext)
82658 + vma_lock_anon_vma(vma->vm_next);
82659
82660 /*
82661 * vma->vm_start/vm_end cannot change under us because the caller
82662 * is required to hold the mmap_sem in read mode. We need the
82663 - * anon_vma lock to serialize against concurrent expand_stacks.
82664 - * Also guard against wrapping around to address 0.
82665 + * anon_vma locks to serialize against concurrent expand_stacks
82666 + * and expand_upwards.
82667 */
82668 - if (address < PAGE_ALIGN(address+4))
82669 - address = PAGE_ALIGN(address+4);
82670 - else {
82671 - vma_unlock_anon_vma(vma);
82672 - return -ENOMEM;
82673 - }
82674 error = 0;
82675
82676 /* Somebody else might have raced and expanded it already */
82677 - if (address > vma->vm_end) {
82678 + 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)
82679 + error = -ENOMEM;
82680 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82681 unsigned long size, grow;
82682
82683 size = address - vma->vm_start;
82684 @@ -2094,6 +2379,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82685 }
82686 }
82687 }
82688 + if (locknext)
82689 + vma_unlock_anon_vma(vma->vm_next);
82690 vma_unlock_anon_vma(vma);
82691 khugepaged_enter_vma_merge(vma);
82692 validate_mm(vma->vm_mm);
82693 @@ -2108,6 +2395,8 @@ int expand_downwards(struct vm_area_struct *vma,
82694 unsigned long address)
82695 {
82696 int error;
82697 + bool lockprev = false;
82698 + struct vm_area_struct *prev;
82699
82700 /*
82701 * We must make sure the anon_vma is allocated
82702 @@ -2121,6 +2410,15 @@ int expand_downwards(struct vm_area_struct *vma,
82703 if (error)
82704 return error;
82705
82706 + prev = vma->vm_prev;
82707 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82708 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82709 +#endif
82710 + if (lockprev && anon_vma_prepare(prev))
82711 + return -ENOMEM;
82712 + if (lockprev)
82713 + vma_lock_anon_vma(prev);
82714 +
82715 vma_lock_anon_vma(vma);
82716
82717 /*
82718 @@ -2130,9 +2428,17 @@ int expand_downwards(struct vm_area_struct *vma,
82719 */
82720
82721 /* Somebody else might have raced and expanded it already */
82722 - if (address < vma->vm_start) {
82723 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82724 + error = -ENOMEM;
82725 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82726 unsigned long size, grow;
82727
82728 +#ifdef CONFIG_PAX_SEGMEXEC
82729 + struct vm_area_struct *vma_m;
82730 +
82731 + vma_m = pax_find_mirror_vma(vma);
82732 +#endif
82733 +
82734 size = vma->vm_end - address;
82735 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82736
82737 @@ -2157,6 +2463,18 @@ int expand_downwards(struct vm_area_struct *vma,
82738 vma->vm_pgoff -= grow;
82739 anon_vma_interval_tree_post_update_vma(vma);
82740 vma_gap_update(vma);
82741 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82742 +
82743 +#ifdef CONFIG_PAX_SEGMEXEC
82744 + if (vma_m) {
82745 + anon_vma_interval_tree_pre_update_vma(vma_m);
82746 + vma_m->vm_start -= grow << PAGE_SHIFT;
82747 + vma_m->vm_pgoff -= grow;
82748 + anon_vma_interval_tree_post_update_vma(vma_m);
82749 + vma_gap_update(vma_m);
82750 + }
82751 +#endif
82752 +
82753 spin_unlock(&vma->vm_mm->page_table_lock);
82754
82755 perf_event_mmap(vma);
82756 @@ -2263,6 +2581,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82757 do {
82758 long nrpages = vma_pages(vma);
82759
82760 +#ifdef CONFIG_PAX_SEGMEXEC
82761 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82762 + vma = remove_vma(vma);
82763 + continue;
82764 + }
82765 +#endif
82766 +
82767 if (vma->vm_flags & VM_ACCOUNT)
82768 nr_accounted += nrpages;
82769 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82770 @@ -2308,6 +2633,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82771 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82772 vma->vm_prev = NULL;
82773 do {
82774 +
82775 +#ifdef CONFIG_PAX_SEGMEXEC
82776 + if (vma->vm_mirror) {
82777 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82778 + vma->vm_mirror->vm_mirror = NULL;
82779 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82780 + vma->vm_mirror = NULL;
82781 + }
82782 +#endif
82783 +
82784 vma_rb_erase(vma, &mm->mm_rb);
82785 mm->map_count--;
82786 tail_vma = vma;
82787 @@ -2339,14 +2674,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82788 struct vm_area_struct *new;
82789 int err = -ENOMEM;
82790
82791 +#ifdef CONFIG_PAX_SEGMEXEC
82792 + struct vm_area_struct *vma_m, *new_m = NULL;
82793 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82794 +#endif
82795 +
82796 if (is_vm_hugetlb_page(vma) && (addr &
82797 ~(huge_page_mask(hstate_vma(vma)))))
82798 return -EINVAL;
82799
82800 +#ifdef CONFIG_PAX_SEGMEXEC
82801 + vma_m = pax_find_mirror_vma(vma);
82802 +#endif
82803 +
82804 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82805 if (!new)
82806 goto out_err;
82807
82808 +#ifdef CONFIG_PAX_SEGMEXEC
82809 + if (vma_m) {
82810 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82811 + if (!new_m) {
82812 + kmem_cache_free(vm_area_cachep, new);
82813 + goto out_err;
82814 + }
82815 + }
82816 +#endif
82817 +
82818 /* most fields are the same, copy all, and then fixup */
82819 *new = *vma;
82820
82821 @@ -2359,6 +2713,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82822 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82823 }
82824
82825 +#ifdef CONFIG_PAX_SEGMEXEC
82826 + if (vma_m) {
82827 + *new_m = *vma_m;
82828 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
82829 + new_m->vm_mirror = new;
82830 + new->vm_mirror = new_m;
82831 +
82832 + if (new_below)
82833 + new_m->vm_end = addr_m;
82834 + else {
82835 + new_m->vm_start = addr_m;
82836 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
82837 + }
82838 + }
82839 +#endif
82840 +
82841 pol = mpol_dup(vma_policy(vma));
82842 if (IS_ERR(pol)) {
82843 err = PTR_ERR(pol);
82844 @@ -2381,6 +2751,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82845 else
82846 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
82847
82848 +#ifdef CONFIG_PAX_SEGMEXEC
82849 + if (!err && vma_m) {
82850 + if (anon_vma_clone(new_m, vma_m))
82851 + goto out_free_mpol;
82852 +
82853 + mpol_get(pol);
82854 + vma_set_policy(new_m, pol);
82855 +
82856 + if (new_m->vm_file)
82857 + get_file(new_m->vm_file);
82858 +
82859 + if (new_m->vm_ops && new_m->vm_ops->open)
82860 + new_m->vm_ops->open(new_m);
82861 +
82862 + if (new_below)
82863 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
82864 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
82865 + else
82866 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
82867 +
82868 + if (err) {
82869 + if (new_m->vm_ops && new_m->vm_ops->close)
82870 + new_m->vm_ops->close(new_m);
82871 + if (new_m->vm_file)
82872 + fput(new_m->vm_file);
82873 + mpol_put(pol);
82874 + }
82875 + }
82876 +#endif
82877 +
82878 /* Success. */
82879 if (!err)
82880 return 0;
82881 @@ -2390,10 +2790,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82882 new->vm_ops->close(new);
82883 if (new->vm_file)
82884 fput(new->vm_file);
82885 - unlink_anon_vmas(new);
82886 out_free_mpol:
82887 mpol_put(pol);
82888 out_free_vma:
82889 +
82890 +#ifdef CONFIG_PAX_SEGMEXEC
82891 + if (new_m) {
82892 + unlink_anon_vmas(new_m);
82893 + kmem_cache_free(vm_area_cachep, new_m);
82894 + }
82895 +#endif
82896 +
82897 + unlink_anon_vmas(new);
82898 kmem_cache_free(vm_area_cachep, new);
82899 out_err:
82900 return err;
82901 @@ -2406,6 +2814,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82902 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82903 unsigned long addr, int new_below)
82904 {
82905 +
82906 +#ifdef CONFIG_PAX_SEGMEXEC
82907 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82908 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
82909 + if (mm->map_count >= sysctl_max_map_count-1)
82910 + return -ENOMEM;
82911 + } else
82912 +#endif
82913 +
82914 if (mm->map_count >= sysctl_max_map_count)
82915 return -ENOMEM;
82916
82917 @@ -2417,11 +2834,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82918 * work. This now handles partial unmappings.
82919 * Jeremy Fitzhardinge <jeremy@goop.org>
82920 */
82921 +#ifdef CONFIG_PAX_SEGMEXEC
82922 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82923 {
82924 + int ret = __do_munmap(mm, start, len);
82925 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
82926 + return ret;
82927 +
82928 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
82929 +}
82930 +
82931 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82932 +#else
82933 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82934 +#endif
82935 +{
82936 unsigned long end;
82937 struct vm_area_struct *vma, *prev, *last;
82938
82939 + /*
82940 + * mm->mmap_sem is required to protect against another thread
82941 + * changing the mappings in case we sleep.
82942 + */
82943 + verify_mm_writelocked(mm);
82944 +
82945 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
82946 return -EINVAL;
82947
82948 @@ -2496,6 +2932,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82949 /* Fix up all other VM information */
82950 remove_vma_list(mm, vma);
82951
82952 + track_exec_limit(mm, start, end, 0UL);
82953 +
82954 return 0;
82955 }
82956
82957 @@ -2504,6 +2942,13 @@ int vm_munmap(unsigned long start, size_t len)
82958 int ret;
82959 struct mm_struct *mm = current->mm;
82960
82961 +
82962 +#ifdef CONFIG_PAX_SEGMEXEC
82963 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
82964 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
82965 + return -EINVAL;
82966 +#endif
82967 +
82968 down_write(&mm->mmap_sem);
82969 ret = do_munmap(mm, start, len);
82970 up_write(&mm->mmap_sem);
82971 @@ -2517,16 +2962,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
82972 return vm_munmap(addr, len);
82973 }
82974
82975 -static inline void verify_mm_writelocked(struct mm_struct *mm)
82976 -{
82977 -#ifdef CONFIG_DEBUG_VM
82978 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82979 - WARN_ON(1);
82980 - up_read(&mm->mmap_sem);
82981 - }
82982 -#endif
82983 -}
82984 -
82985 /*
82986 * this is really a simplified "do_mmap". it only handles
82987 * anonymous maps. eventually we may be able to do some
82988 @@ -2540,6 +2975,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82989 struct rb_node ** rb_link, * rb_parent;
82990 pgoff_t pgoff = addr >> PAGE_SHIFT;
82991 int error;
82992 + unsigned long charged;
82993
82994 len = PAGE_ALIGN(len);
82995 if (!len)
82996 @@ -2547,16 +2983,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82997
82998 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
82999
83000 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83001 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83002 + flags &= ~VM_EXEC;
83003 +
83004 +#ifdef CONFIG_PAX_MPROTECT
83005 + if (mm->pax_flags & MF_PAX_MPROTECT)
83006 + flags &= ~VM_MAYEXEC;
83007 +#endif
83008 +
83009 + }
83010 +#endif
83011 +
83012 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83013 if (error & ~PAGE_MASK)
83014 return error;
83015
83016 + charged = len >> PAGE_SHIFT;
83017 +
83018 /*
83019 * mlock MCL_FUTURE?
83020 */
83021 if (mm->def_flags & VM_LOCKED) {
83022 unsigned long locked, lock_limit;
83023 - locked = len >> PAGE_SHIFT;
83024 + locked = charged;
83025 locked += mm->locked_vm;
83026 lock_limit = rlimit(RLIMIT_MEMLOCK);
83027 lock_limit >>= PAGE_SHIFT;
83028 @@ -2573,21 +3023,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83029 /*
83030 * Clear old maps. this also does some error checking for us
83031 */
83032 - munmap_back:
83033 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83034 if (do_munmap(mm, addr, len))
83035 return -ENOMEM;
83036 - goto munmap_back;
83037 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83038 }
83039
83040 /* Check against address space limits *after* clearing old maps... */
83041 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83042 + if (!may_expand_vm(mm, charged))
83043 return -ENOMEM;
83044
83045 if (mm->map_count > sysctl_max_map_count)
83046 return -ENOMEM;
83047
83048 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83049 + if (security_vm_enough_memory_mm(mm, charged))
83050 return -ENOMEM;
83051
83052 /* Can we just expand an old private anonymous mapping? */
83053 @@ -2601,7 +3050,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83054 */
83055 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83056 if (!vma) {
83057 - vm_unacct_memory(len >> PAGE_SHIFT);
83058 + vm_unacct_memory(charged);
83059 return -ENOMEM;
83060 }
83061
83062 @@ -2615,11 +3064,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83063 vma_link(mm, vma, prev, rb_link, rb_parent);
83064 out:
83065 perf_event_mmap(vma);
83066 - mm->total_vm += len >> PAGE_SHIFT;
83067 + mm->total_vm += charged;
83068 if (flags & VM_LOCKED) {
83069 if (!mlock_vma_pages_range(vma, addr, addr + len))
83070 - mm->locked_vm += (len >> PAGE_SHIFT);
83071 + mm->locked_vm += charged;
83072 }
83073 + track_exec_limit(mm, addr, addr + len, flags);
83074 return addr;
83075 }
83076
83077 @@ -2677,6 +3127,7 @@ void exit_mmap(struct mm_struct *mm)
83078 while (vma) {
83079 if (vma->vm_flags & VM_ACCOUNT)
83080 nr_accounted += vma_pages(vma);
83081 + vma->vm_mirror = NULL;
83082 vma = remove_vma(vma);
83083 }
83084 vm_unacct_memory(nr_accounted);
83085 @@ -2693,6 +3144,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83086 struct vm_area_struct *prev;
83087 struct rb_node **rb_link, *rb_parent;
83088
83089 +#ifdef CONFIG_PAX_SEGMEXEC
83090 + struct vm_area_struct *vma_m = NULL;
83091 +#endif
83092 +
83093 + if (security_mmap_addr(vma->vm_start))
83094 + return -EPERM;
83095 +
83096 /*
83097 * The vm_pgoff of a purely anonymous vma should be irrelevant
83098 * until its first write fault, when page's anon_vma and index
83099 @@ -2716,7 +3174,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83100 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83101 return -ENOMEM;
83102
83103 +#ifdef CONFIG_PAX_SEGMEXEC
83104 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83105 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83106 + if (!vma_m)
83107 + return -ENOMEM;
83108 + }
83109 +#endif
83110 +
83111 vma_link(mm, vma, prev, rb_link, rb_parent);
83112 +
83113 +#ifdef CONFIG_PAX_SEGMEXEC
83114 + if (vma_m)
83115 + BUG_ON(pax_mirror_vma(vma_m, vma));
83116 +#endif
83117 +
83118 return 0;
83119 }
83120
83121 @@ -2736,6 +3208,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83122 struct mempolicy *pol;
83123 bool faulted_in_anon_vma = true;
83124
83125 + BUG_ON(vma->vm_mirror);
83126 +
83127 /*
83128 * If anonymous vma has not yet been faulted, update new pgoff
83129 * to match new location, to increase its chance of merging.
83130 @@ -2802,6 +3276,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83131 return NULL;
83132 }
83133
83134 +#ifdef CONFIG_PAX_SEGMEXEC
83135 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83136 +{
83137 + struct vm_area_struct *prev_m;
83138 + struct rb_node **rb_link_m, *rb_parent_m;
83139 + struct mempolicy *pol_m;
83140 +
83141 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83142 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83143 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83144 + *vma_m = *vma;
83145 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83146 + if (anon_vma_clone(vma_m, vma))
83147 + return -ENOMEM;
83148 + pol_m = vma_policy(vma_m);
83149 + mpol_get(pol_m);
83150 + vma_set_policy(vma_m, pol_m);
83151 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83152 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83153 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83154 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83155 + if (vma_m->vm_file)
83156 + get_file(vma_m->vm_file);
83157 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83158 + vma_m->vm_ops->open(vma_m);
83159 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83160 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83161 + vma_m->vm_mirror = vma;
83162 + vma->vm_mirror = vma_m;
83163 + return 0;
83164 +}
83165 +#endif
83166 +
83167 /*
83168 * Return true if the calling process may expand its vm space by the passed
83169 * number of pages
83170 @@ -2813,6 +3320,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83171
83172 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83173
83174 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83175 if (cur + npages > lim)
83176 return 0;
83177 return 1;
83178 @@ -2883,6 +3391,22 @@ int install_special_mapping(struct mm_struct *mm,
83179 vma->vm_start = addr;
83180 vma->vm_end = addr + len;
83181
83182 +#ifdef CONFIG_PAX_MPROTECT
83183 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83184 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83185 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83186 + return -EPERM;
83187 + if (!(vm_flags & VM_EXEC))
83188 + vm_flags &= ~VM_MAYEXEC;
83189 +#else
83190 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83191 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83192 +#endif
83193 + else
83194 + vm_flags &= ~VM_MAYWRITE;
83195 + }
83196 +#endif
83197 +
83198 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83199 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83200
83201 diff --git a/mm/mprotect.c b/mm/mprotect.c
83202 index 94722a4..9837984 100644
83203 --- a/mm/mprotect.c
83204 +++ b/mm/mprotect.c
83205 @@ -23,10 +23,17 @@
83206 #include <linux/mmu_notifier.h>
83207 #include <linux/migrate.h>
83208 #include <linux/perf_event.h>
83209 +
83210 +#ifdef CONFIG_PAX_MPROTECT
83211 +#include <linux/elf.h>
83212 +#include <linux/binfmts.h>
83213 +#endif
83214 +
83215 #include <asm/uaccess.h>
83216 #include <asm/pgtable.h>
83217 #include <asm/cacheflush.h>
83218 #include <asm/tlbflush.h>
83219 +#include <asm/mmu_context.h>
83220
83221 #ifndef pgprot_modify
83222 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83223 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83224 return pages;
83225 }
83226
83227 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83228 +/* called while holding the mmap semaphor for writing except stack expansion */
83229 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83230 +{
83231 + unsigned long oldlimit, newlimit = 0UL;
83232 +
83233 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83234 + return;
83235 +
83236 + spin_lock(&mm->page_table_lock);
83237 + oldlimit = mm->context.user_cs_limit;
83238 + if ((prot & VM_EXEC) && oldlimit < end)
83239 + /* USER_CS limit moved up */
83240 + newlimit = end;
83241 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83242 + /* USER_CS limit moved down */
83243 + newlimit = start;
83244 +
83245 + if (newlimit) {
83246 + mm->context.user_cs_limit = newlimit;
83247 +
83248 +#ifdef CONFIG_SMP
83249 + wmb();
83250 + cpus_clear(mm->context.cpu_user_cs_mask);
83251 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83252 +#endif
83253 +
83254 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83255 + }
83256 + spin_unlock(&mm->page_table_lock);
83257 + if (newlimit == end) {
83258 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83259 +
83260 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83261 + if (is_vm_hugetlb_page(vma))
83262 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83263 + else
83264 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83265 + }
83266 +}
83267 +#endif
83268 +
83269 int
83270 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83271 unsigned long start, unsigned long end, unsigned long newflags)
83272 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83273 int error;
83274 int dirty_accountable = 0;
83275
83276 +#ifdef CONFIG_PAX_SEGMEXEC
83277 + struct vm_area_struct *vma_m = NULL;
83278 + unsigned long start_m, end_m;
83279 +
83280 + start_m = start + SEGMEXEC_TASK_SIZE;
83281 + end_m = end + SEGMEXEC_TASK_SIZE;
83282 +#endif
83283 +
83284 if (newflags == oldflags) {
83285 *pprev = vma;
83286 return 0;
83287 }
83288
83289 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83290 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83291 +
83292 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83293 + return -ENOMEM;
83294 +
83295 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83296 + return -ENOMEM;
83297 + }
83298 +
83299 /*
83300 * If we make a private mapping writable we increase our commit;
83301 * but (without finer accounting) cannot reduce our commit if we
83302 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83303 }
83304 }
83305
83306 +#ifdef CONFIG_PAX_SEGMEXEC
83307 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83308 + if (start != vma->vm_start) {
83309 + error = split_vma(mm, vma, start, 1);
83310 + if (error)
83311 + goto fail;
83312 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83313 + *pprev = (*pprev)->vm_next;
83314 + }
83315 +
83316 + if (end != vma->vm_end) {
83317 + error = split_vma(mm, vma, end, 0);
83318 + if (error)
83319 + goto fail;
83320 + }
83321 +
83322 + if (pax_find_mirror_vma(vma)) {
83323 + error = __do_munmap(mm, start_m, end_m - start_m);
83324 + if (error)
83325 + goto fail;
83326 + } else {
83327 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83328 + if (!vma_m) {
83329 + error = -ENOMEM;
83330 + goto fail;
83331 + }
83332 + vma->vm_flags = newflags;
83333 + error = pax_mirror_vma(vma_m, vma);
83334 + if (error) {
83335 + vma->vm_flags = oldflags;
83336 + goto fail;
83337 + }
83338 + }
83339 + }
83340 +#endif
83341 +
83342 /*
83343 * First try to merge with previous and/or next vma.
83344 */
83345 @@ -296,9 +399,21 @@ success:
83346 * vm_flags and vm_page_prot are protected by the mmap_sem
83347 * held in write mode.
83348 */
83349 +
83350 +#ifdef CONFIG_PAX_SEGMEXEC
83351 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83352 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83353 +#endif
83354 +
83355 vma->vm_flags = newflags;
83356 +
83357 +#ifdef CONFIG_PAX_MPROTECT
83358 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83359 + mm->binfmt->handle_mprotect(vma, newflags);
83360 +#endif
83361 +
83362 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83363 - vm_get_page_prot(newflags));
83364 + vm_get_page_prot(vma->vm_flags));
83365
83366 if (vma_wants_writenotify(vma)) {
83367 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83368 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83369 end = start + len;
83370 if (end <= start)
83371 return -ENOMEM;
83372 +
83373 +#ifdef CONFIG_PAX_SEGMEXEC
83374 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83375 + if (end > SEGMEXEC_TASK_SIZE)
83376 + return -EINVAL;
83377 + } else
83378 +#endif
83379 +
83380 + if (end > TASK_SIZE)
83381 + return -EINVAL;
83382 +
83383 if (!arch_validate_prot(prot))
83384 return -EINVAL;
83385
83386 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83387 /*
83388 * Does the application expect PROT_READ to imply PROT_EXEC:
83389 */
83390 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83391 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83392 prot |= PROT_EXEC;
83393
83394 vm_flags = calc_vm_prot_bits(prot);
83395 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83396 if (start > vma->vm_start)
83397 prev = vma;
83398
83399 +#ifdef CONFIG_PAX_MPROTECT
83400 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83401 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83402 +#endif
83403 +
83404 for (nstart = start ; ; ) {
83405 unsigned long newflags;
83406
83407 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83408
83409 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83410 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83411 + if (prot & (PROT_WRITE | PROT_EXEC))
83412 + gr_log_rwxmprotect(vma->vm_file);
83413 +
83414 + error = -EACCES;
83415 + goto out;
83416 + }
83417 +
83418 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83419 error = -EACCES;
83420 goto out;
83421 }
83422 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83423 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83424 if (error)
83425 goto out;
83426 +
83427 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83428 +
83429 nstart = tmp;
83430
83431 if (nstart < prev->vm_end)
83432 diff --git a/mm/mremap.c b/mm/mremap.c
83433 index e1031e1..1f2a0a1 100644
83434 --- a/mm/mremap.c
83435 +++ b/mm/mremap.c
83436 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83437 continue;
83438 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83439 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83440 +
83441 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83442 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83443 + pte = pte_exprotect(pte);
83444 +#endif
83445 +
83446 set_pte_at(mm, new_addr, new_pte, pte);
83447 }
83448
83449 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83450 if (is_vm_hugetlb_page(vma))
83451 goto Einval;
83452
83453 +#ifdef CONFIG_PAX_SEGMEXEC
83454 + if (pax_find_mirror_vma(vma))
83455 + goto Einval;
83456 +#endif
83457 +
83458 /* We can't remap across vm area boundaries */
83459 if (old_len > vma->vm_end - addr)
83460 goto Efault;
83461 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
83462 unsigned long ret = -EINVAL;
83463 unsigned long charged = 0;
83464 unsigned long map_flags;
83465 + unsigned long pax_task_size = TASK_SIZE;
83466
83467 if (new_addr & ~PAGE_MASK)
83468 goto out;
83469
83470 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83471 +#ifdef CONFIG_PAX_SEGMEXEC
83472 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83473 + pax_task_size = SEGMEXEC_TASK_SIZE;
83474 +#endif
83475 +
83476 + pax_task_size -= PAGE_SIZE;
83477 +
83478 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83479 goto out;
83480
83481 /* Check if the location we're moving into overlaps the
83482 * old location at all, and fail if it does.
83483 */
83484 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83485 - goto out;
83486 -
83487 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83488 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83489 goto out;
83490
83491 ret = do_munmap(mm, new_addr, new_len);
83492 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83493 struct vm_area_struct *vma;
83494 unsigned long ret = -EINVAL;
83495 unsigned long charged = 0;
83496 + unsigned long pax_task_size = TASK_SIZE;
83497
83498 down_write(&current->mm->mmap_sem);
83499
83500 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83501 if (!new_len)
83502 goto out;
83503
83504 +#ifdef CONFIG_PAX_SEGMEXEC
83505 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83506 + pax_task_size = SEGMEXEC_TASK_SIZE;
83507 +#endif
83508 +
83509 + pax_task_size -= PAGE_SIZE;
83510 +
83511 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83512 + old_len > pax_task_size || addr > pax_task_size-old_len)
83513 + goto out;
83514 +
83515 if (flags & MREMAP_FIXED) {
83516 if (flags & MREMAP_MAYMOVE)
83517 ret = mremap_to(addr, old_len, new_addr, new_len);
83518 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83519 addr + new_len);
83520 }
83521 ret = addr;
83522 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83523 goto out;
83524 }
83525 }
83526 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83527 goto out;
83528 }
83529
83530 + map_flags = vma->vm_flags;
83531 ret = move_vma(vma, addr, old_len, new_len, new_addr);
83532 + if (!(ret & ~PAGE_MASK)) {
83533 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83534 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83535 + }
83536 }
83537 out:
83538 if (ret & ~PAGE_MASK)
83539 diff --git a/mm/nommu.c b/mm/nommu.c
83540 index bbe1f3f..b2601ea 100644
83541 --- a/mm/nommu.c
83542 +++ b/mm/nommu.c
83543 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83544 int sysctl_overcommit_ratio = 50; /* default is 50% */
83545 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83546 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83547 -int heap_stack_gap = 0;
83548
83549 atomic_long_t mmap_pages_allocated;
83550
83551 @@ -839,15 +838,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83552 EXPORT_SYMBOL(find_vma);
83553
83554 /*
83555 - * find a VMA
83556 - * - we don't extend stack VMAs under NOMMU conditions
83557 - */
83558 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83559 -{
83560 - return find_vma(mm, addr);
83561 -}
83562 -
83563 -/*
83564 * expand a stack to a given address
83565 * - not supported under NOMMU conditions
83566 */
83567 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83568
83569 /* most fields are the same, copy all, and then fixup */
83570 *new = *vma;
83571 + INIT_LIST_HEAD(&new->anon_vma_chain);
83572 *region = *vma->vm_region;
83573 new->vm_region = region;
83574
83575 @@ -1975,8 +1966,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83576 }
83577 EXPORT_SYMBOL(generic_file_remap_pages);
83578
83579 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83580 - unsigned long addr, void *buf, int len, int write)
83581 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83582 + unsigned long addr, void *buf, size_t len, int write)
83583 {
83584 struct vm_area_struct *vma;
83585
83586 @@ -2017,8 +2008,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83587 *
83588 * The caller must hold a reference on @mm.
83589 */
83590 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83591 - void *buf, int len, int write)
83592 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83593 + void *buf, size_t len, int write)
83594 {
83595 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83596 }
83597 @@ -2027,7 +2018,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83598 * Access another process' address space.
83599 * - source/target buffer must be kernel space
83600 */
83601 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83602 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83603 {
83604 struct mm_struct *mm;
83605
83606 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83607 index 0713bfb..b95bb87 100644
83608 --- a/mm/page-writeback.c
83609 +++ b/mm/page-writeback.c
83610 @@ -655,7 +655,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83611 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83612 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83613 */
83614 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83615 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83616 unsigned long thresh,
83617 unsigned long bg_thresh,
83618 unsigned long dirty,
83619 @@ -1630,7 +1630,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83620 }
83621 }
83622
83623 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83624 +static struct notifier_block ratelimit_nb = {
83625 .notifier_call = ratelimit_handler,
83626 .next = NULL,
83627 };
83628 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83629 index 6a83cd3..3ab04ef 100644
83630 --- a/mm/page_alloc.c
83631 +++ b/mm/page_alloc.c
83632 @@ -58,6 +58,7 @@
83633 #include <linux/prefetch.h>
83634 #include <linux/migrate.h>
83635 #include <linux/page-debug-flags.h>
83636 +#include <linux/random.h>
83637
83638 #include <asm/tlbflush.h>
83639 #include <asm/div64.h>
83640 @@ -338,7 +339,7 @@ out:
83641 * This usage means that zero-order pages may not be compound.
83642 */
83643
83644 -static void free_compound_page(struct page *page)
83645 +void free_compound_page(struct page *page)
83646 {
83647 __free_pages_ok(page, compound_order(page));
83648 }
83649 @@ -693,6 +694,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83650 int i;
83651 int bad = 0;
83652
83653 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83654 + unsigned long index = 1UL << order;
83655 +#endif
83656 +
83657 trace_mm_page_free(page, order);
83658 kmemcheck_free_shadow(page, order);
83659
83660 @@ -708,6 +713,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83661 debug_check_no_obj_freed(page_address(page),
83662 PAGE_SIZE << order);
83663 }
83664 +
83665 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83666 + for (; index; --index)
83667 + sanitize_highpage(page + index - 1);
83668 +#endif
83669 +
83670 arch_free_page(page, order);
83671 kernel_map_pages(page, 1 << order, 0);
83672
83673 @@ -730,6 +741,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83674 local_irq_restore(flags);
83675 }
83676
83677 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83678 +bool __meminitdata extra_latent_entropy;
83679 +
83680 +static int __init setup_pax_extra_latent_entropy(char *str)
83681 +{
83682 + extra_latent_entropy = true;
83683 + return 0;
83684 +}
83685 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83686 +
83687 +volatile u64 latent_entropy;
83688 +#endif
83689 +
83690 /*
83691 * Read access to zone->managed_pages is safe because it's unsigned long,
83692 * but we still need to serialize writers. Currently all callers of
83693 @@ -752,6 +776,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83694 set_page_count(p, 0);
83695 }
83696
83697 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83698 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83699 + u64 hash = 0;
83700 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83701 + const u64 *data = lowmem_page_address(page);
83702 +
83703 + for (index = 0; index < end; index++)
83704 + hash ^= hash + data[index];
83705 + latent_entropy ^= hash;
83706 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83707 + }
83708 +#endif
83709 +
83710 page_zone(page)->managed_pages += 1 << order;
83711 set_page_refcounted(page);
83712 __free_pages(page, order);
83713 @@ -861,8 +898,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83714 arch_alloc_page(page, order);
83715 kernel_map_pages(page, 1 << order, 1);
83716
83717 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83718 if (gfp_flags & __GFP_ZERO)
83719 prep_zero_page(page, order, gfp_flags);
83720 +#endif
83721
83722 if (order && (gfp_flags & __GFP_COMP))
83723 prep_compound_page(page, order);
83724 @@ -3752,7 +3791,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
83725 unsigned long pfn;
83726
83727 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
83728 +#ifdef CONFIG_X86_32
83729 + /* boot failures in VMware 8 on 32bit vanilla since
83730 + this change */
83731 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
83732 +#else
83733 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
83734 +#endif
83735 return 1;
83736 }
83737 return 0;
83738 diff --git a/mm/percpu.c b/mm/percpu.c
83739 index 8c8e08f..73a5cda 100644
83740 --- a/mm/percpu.c
83741 +++ b/mm/percpu.c
83742 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83743 static unsigned int pcpu_high_unit_cpu __read_mostly;
83744
83745 /* the address of the first chunk which starts with the kernel static area */
83746 -void *pcpu_base_addr __read_mostly;
83747 +void *pcpu_base_addr __read_only;
83748 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83749
83750 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83751 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83752 index fd26d04..0cea1b0 100644
83753 --- a/mm/process_vm_access.c
83754 +++ b/mm/process_vm_access.c
83755 @@ -13,6 +13,7 @@
83756 #include <linux/uio.h>
83757 #include <linux/sched.h>
83758 #include <linux/highmem.h>
83759 +#include <linux/security.h>
83760 #include <linux/ptrace.h>
83761 #include <linux/slab.h>
83762 #include <linux/syscalls.h>
83763 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83764 size_t iov_l_curr_offset = 0;
83765 ssize_t iov_len;
83766
83767 + return -ENOSYS; // PaX: until properly audited
83768 +
83769 /*
83770 * Work out how many pages of struct pages we're going to need
83771 * when eventually calling get_user_pages
83772 */
83773 for (i = 0; i < riovcnt; i++) {
83774 iov_len = rvec[i].iov_len;
83775 - if (iov_len > 0) {
83776 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83777 - + iov_len)
83778 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83779 - / PAGE_SIZE + 1;
83780 - nr_pages = max(nr_pages, nr_pages_iov);
83781 - }
83782 + if (iov_len <= 0)
83783 + continue;
83784 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83785 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83786 + nr_pages = max(nr_pages, nr_pages_iov);
83787 }
83788
83789 if (nr_pages == 0)
83790 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83791 goto free_proc_pages;
83792 }
83793
83794 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83795 + rc = -EPERM;
83796 + goto put_task_struct;
83797 + }
83798 +
83799 mm = mm_access(task, PTRACE_MODE_ATTACH);
83800 if (!mm || IS_ERR(mm)) {
83801 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83802 diff --git a/mm/rmap.c b/mm/rmap.c
83803 index 2c78f8c..9e9c624 100644
83804 --- a/mm/rmap.c
83805 +++ b/mm/rmap.c
83806 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83807 struct anon_vma *anon_vma = vma->anon_vma;
83808 struct anon_vma_chain *avc;
83809
83810 +#ifdef CONFIG_PAX_SEGMEXEC
83811 + struct anon_vma_chain *avc_m = NULL;
83812 +#endif
83813 +
83814 might_sleep();
83815 if (unlikely(!anon_vma)) {
83816 struct mm_struct *mm = vma->vm_mm;
83817 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83818 if (!avc)
83819 goto out_enomem;
83820
83821 +#ifdef CONFIG_PAX_SEGMEXEC
83822 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83823 + if (!avc_m)
83824 + goto out_enomem_free_avc;
83825 +#endif
83826 +
83827 anon_vma = find_mergeable_anon_vma(vma);
83828 allocated = NULL;
83829 if (!anon_vma) {
83830 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83831 /* page_table_lock to protect against threads */
83832 spin_lock(&mm->page_table_lock);
83833 if (likely(!vma->anon_vma)) {
83834 +
83835 +#ifdef CONFIG_PAX_SEGMEXEC
83836 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
83837 +
83838 + if (vma_m) {
83839 + BUG_ON(vma_m->anon_vma);
83840 + vma_m->anon_vma = anon_vma;
83841 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
83842 + avc_m = NULL;
83843 + }
83844 +#endif
83845 +
83846 vma->anon_vma = anon_vma;
83847 anon_vma_chain_link(vma, avc, anon_vma);
83848 allocated = NULL;
83849 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83850
83851 if (unlikely(allocated))
83852 put_anon_vma(allocated);
83853 +
83854 +#ifdef CONFIG_PAX_SEGMEXEC
83855 + if (unlikely(avc_m))
83856 + anon_vma_chain_free(avc_m);
83857 +#endif
83858 +
83859 if (unlikely(avc))
83860 anon_vma_chain_free(avc);
83861 }
83862 return 0;
83863
83864 out_enomem_free_avc:
83865 +
83866 +#ifdef CONFIG_PAX_SEGMEXEC
83867 + if (avc_m)
83868 + anon_vma_chain_free(avc_m);
83869 +#endif
83870 +
83871 anon_vma_chain_free(avc);
83872 out_enomem:
83873 return -ENOMEM;
83874 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
83875 * Attach the anon_vmas from src to dst.
83876 * Returns 0 on success, -ENOMEM on failure.
83877 */
83878 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83879 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
83880 {
83881 struct anon_vma_chain *avc, *pavc;
83882 struct anon_vma *root = NULL;
83883 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83884 * the corresponding VMA in the parent process is attached to.
83885 * Returns 0 on success, non-zero on failure.
83886 */
83887 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
83888 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
83889 {
83890 struct anon_vma_chain *avc;
83891 struct anon_vma *anon_vma;
83892 diff --git a/mm/shmem.c b/mm/shmem.c
83893 index efd0b3a..994b702 100644
83894 --- a/mm/shmem.c
83895 +++ b/mm/shmem.c
83896 @@ -31,7 +31,7 @@
83897 #include <linux/export.h>
83898 #include <linux/swap.h>
83899
83900 -static struct vfsmount *shm_mnt;
83901 +struct vfsmount *shm_mnt;
83902
83903 #ifdef CONFIG_SHMEM
83904 /*
83905 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
83906 #define BOGO_DIRENT_SIZE 20
83907
83908 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
83909 -#define SHORT_SYMLINK_LEN 128
83910 +#define SHORT_SYMLINK_LEN 64
83911
83912 /*
83913 * shmem_fallocate and shmem_writepage communicate via inode->i_private
83914 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
83915 static int shmem_xattr_validate(const char *name)
83916 {
83917 struct { const char *prefix; size_t len; } arr[] = {
83918 +
83919 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83920 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
83921 +#endif
83922 +
83923 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
83924 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
83925 };
83926 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
83927 if (err)
83928 return err;
83929
83930 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83931 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
83932 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
83933 + return -EOPNOTSUPP;
83934 + if (size > 8)
83935 + return -EINVAL;
83936 + }
83937 +#endif
83938 +
83939 return simple_xattr_set(&info->xattrs, name, value, size, flags);
83940 }
83941
83942 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
83943 int err = -ENOMEM;
83944
83945 /* Round up to L1_CACHE_BYTES to resist false sharing */
83946 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
83947 - L1_CACHE_BYTES), GFP_KERNEL);
83948 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
83949 if (!sbinfo)
83950 return -ENOMEM;
83951
83952 diff --git a/mm/slab.c b/mm/slab.c
83953 index e7667a3..a48e73b 100644
83954 --- a/mm/slab.c
83955 +++ b/mm/slab.c
83956 @@ -306,7 +306,7 @@ struct kmem_list3 {
83957 * Need this for bootstrapping a per node allocator.
83958 */
83959 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
83960 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
83961 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
83962 #define CACHE_CACHE 0
83963 #define SIZE_AC MAX_NUMNODES
83964 #define SIZE_L3 (2 * MAX_NUMNODES)
83965 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
83966 if ((x)->max_freeable < i) \
83967 (x)->max_freeable = i; \
83968 } while (0)
83969 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
83970 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
83971 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
83972 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
83973 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
83974 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
83975 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
83976 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
83977 #else
83978 #define STATS_INC_ACTIVE(x) do { } while (0)
83979 #define STATS_DEC_ACTIVE(x) do { } while (0)
83980 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
83981 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
83982 */
83983 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
83984 - const struct slab *slab, void *obj)
83985 + const struct slab *slab, const void *obj)
83986 {
83987 u32 offset = (obj - slab->s_mem);
83988 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
83989 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
83990 struct cache_names {
83991 char *name;
83992 char *name_dma;
83993 + char *name_usercopy;
83994 };
83995
83996 static struct cache_names __initdata cache_names[] = {
83997 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
83998 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
83999 #include <linux/kmalloc_sizes.h>
84000 - {NULL,}
84001 + {NULL}
84002 #undef CACHE
84003 };
84004
84005 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
84006 if (unlikely(gfpflags & GFP_DMA))
84007 return csizep->cs_dmacachep;
84008 #endif
84009 +
84010 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84011 + if (unlikely(gfpflags & GFP_USERCOPY))
84012 + return csizep->cs_usercopycachep;
84013 +#endif
84014 +
84015 return csizep->cs_cachep;
84016 }
84017
84018 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84019 return notifier_from_errno(err);
84020 }
84021
84022 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84023 +static struct notifier_block cpucache_notifier = {
84024 &cpuup_callback, NULL, 0
84025 };
84026
84027 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
84028 */
84029
84030 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
84031 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
84032 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84033
84034 if (INDEX_AC != INDEX_L3)
84035 sizes[INDEX_L3].cs_cachep =
84036 create_kmalloc_cache(names[INDEX_L3].name,
84037 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
84038 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84039
84040 slab_early_init = 0;
84041
84042 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
84043 */
84044 if (!sizes->cs_cachep)
84045 sizes->cs_cachep = create_kmalloc_cache(names->name,
84046 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
84047 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84048
84049 #ifdef CONFIG_ZONE_DMA
84050 sizes->cs_dmacachep = create_kmalloc_cache(
84051 names->name_dma, sizes->cs_size,
84052 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
84053 #endif
84054 +
84055 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84056 + sizes->cs_usercopycachep = create_kmalloc_cache(
84057 + names->name_usercopy, sizes->cs_size,
84058 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84059 +#endif
84060 +
84061 sizes++;
84062 names++;
84063 }
84064 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
84065
84066 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84067 return;
84068 + VM_BUG_ON(!virt_addr_valid(objp));
84069 local_irq_save(flags);
84070 kfree_debugcheck(objp);
84071 c = virt_to_cache(objp);
84072 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84073 }
84074 /* cpu stats */
84075 {
84076 - unsigned long allochit = atomic_read(&cachep->allochit);
84077 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84078 - unsigned long freehit = atomic_read(&cachep->freehit);
84079 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84080 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84081 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84082 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84083 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84084
84085 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84086 allochit, allocmiss, freehit, freemiss);
84087 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
84088 static int __init slab_proc_init(void)
84089 {
84090 #ifdef CONFIG_DEBUG_SLAB_LEAK
84091 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84092 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84093 #endif
84094 return 0;
84095 }
84096 module_init(slab_proc_init);
84097 #endif
84098
84099 +bool is_usercopy_object(const void *ptr)
84100 +{
84101 + struct page *page;
84102 + struct kmem_cache *cachep;
84103 +
84104 + if (ZERO_OR_NULL_PTR(ptr))
84105 + return false;
84106 +
84107 + if (!slab_is_available())
84108 + return false;
84109 +
84110 + if (!virt_addr_valid(ptr))
84111 + return false;
84112 +
84113 + page = virt_to_head_page(ptr);
84114 +
84115 + if (!PageSlab(page))
84116 + return false;
84117 +
84118 + cachep = page->slab_cache;
84119 + return cachep->flags & SLAB_USERCOPY;
84120 +}
84121 +
84122 +#ifdef CONFIG_PAX_USERCOPY
84123 +const char *check_heap_object(const void *ptr, unsigned long n)
84124 +{
84125 + struct page *page;
84126 + struct kmem_cache *cachep;
84127 + struct slab *slabp;
84128 + unsigned int objnr;
84129 + unsigned long offset;
84130 +
84131 + if (ZERO_OR_NULL_PTR(ptr))
84132 + return "<null>";
84133 +
84134 + if (!virt_addr_valid(ptr))
84135 + return NULL;
84136 +
84137 + page = virt_to_head_page(ptr);
84138 +
84139 + if (!PageSlab(page))
84140 + return NULL;
84141 +
84142 + cachep = page->slab_cache;
84143 + if (!(cachep->flags & SLAB_USERCOPY))
84144 + return cachep->name;
84145 +
84146 + slabp = page->slab_page;
84147 + objnr = obj_to_index(cachep, slabp, ptr);
84148 + BUG_ON(objnr >= cachep->num);
84149 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84150 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84151 + return NULL;
84152 +
84153 + return cachep->name;
84154 +}
84155 +#endif
84156 +
84157 /**
84158 * ksize - get the actual amount of memory allocated for a given object
84159 * @objp: Pointer to the object
84160 diff --git a/mm/slab.h b/mm/slab.h
84161 index 34a98d6..73633d1 100644
84162 --- a/mm/slab.h
84163 +++ b/mm/slab.h
84164 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84165
84166 /* Legal flag mask for kmem_cache_create(), for various configurations */
84167 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84168 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84169 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84170
84171 #if defined(CONFIG_DEBUG_SLAB)
84172 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84173 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84174 return s;
84175
84176 page = virt_to_head_page(x);
84177 +
84178 + BUG_ON(!PageSlab(page));
84179 +
84180 cachep = page->slab_cache;
84181 if (slab_equal_or_root(cachep, s))
84182 return cachep;
84183 diff --git a/mm/slab_common.c b/mm/slab_common.c
84184 index 3f3cd97..93b0236 100644
84185 --- a/mm/slab_common.c
84186 +++ b/mm/slab_common.c
84187 @@ -22,7 +22,7 @@
84188
84189 #include "slab.h"
84190
84191 -enum slab_state slab_state;
84192 +enum slab_state slab_state __read_only;
84193 LIST_HEAD(slab_caches);
84194 DEFINE_MUTEX(slab_mutex);
84195 struct kmem_cache *kmem_cache;
84196 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84197
84198 err = __kmem_cache_create(s, flags);
84199 if (!err) {
84200 - s->refcount = 1;
84201 + atomic_set(&s->refcount, 1);
84202 list_add(&s->list, &slab_caches);
84203 memcg_cache_list_add(memcg, s);
84204 } else {
84205 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84206
84207 get_online_cpus();
84208 mutex_lock(&slab_mutex);
84209 - s->refcount--;
84210 - if (!s->refcount) {
84211 + if (atomic_dec_and_test(&s->refcount)) {
84212 list_del(&s->list);
84213
84214 if (!__kmem_cache_shutdown(s)) {
84215 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84216 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
84217 name, size, err);
84218
84219 - s->refcount = -1; /* Exempt from merging for now */
84220 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84221 }
84222
84223 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84224 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84225
84226 create_boot_cache(s, name, size, flags);
84227 list_add(&s->list, &slab_caches);
84228 - s->refcount = 1;
84229 + atomic_set(&s->refcount, 1);
84230 return s;
84231 }
84232
84233 diff --git a/mm/slob.c b/mm/slob.c
84234 index a99fdf7..6ee34ec 100644
84235 --- a/mm/slob.c
84236 +++ b/mm/slob.c
84237 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84238 /*
84239 * Return the size of a slob block.
84240 */
84241 -static slobidx_t slob_units(slob_t *s)
84242 +static slobidx_t slob_units(const slob_t *s)
84243 {
84244 if (s->units > 0)
84245 return s->units;
84246 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84247 /*
84248 * Return the next free slob block pointer after this one.
84249 */
84250 -static slob_t *slob_next(slob_t *s)
84251 +static slob_t *slob_next(const slob_t *s)
84252 {
84253 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84254 slobidx_t next;
84255 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84256 /*
84257 * Returns true if s is the last free block in its page.
84258 */
84259 -static int slob_last(slob_t *s)
84260 +static int slob_last(const slob_t *s)
84261 {
84262 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84263 }
84264
84265 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84266 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84267 {
84268 - void *page;
84269 + struct page *page;
84270
84271 #ifdef CONFIG_NUMA
84272 if (node != NUMA_NO_NODE)
84273 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84274 if (!page)
84275 return NULL;
84276
84277 - return page_address(page);
84278 + __SetPageSlab(page);
84279 + return page;
84280 }
84281
84282 -static void slob_free_pages(void *b, int order)
84283 +static void slob_free_pages(struct page *sp, int order)
84284 {
84285 if (current->reclaim_state)
84286 current->reclaim_state->reclaimed_slab += 1 << order;
84287 - free_pages((unsigned long)b, order);
84288 + __ClearPageSlab(sp);
84289 + reset_page_mapcount(sp);
84290 + sp->private = 0;
84291 + __free_pages(sp, order);
84292 }
84293
84294 /*
84295 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84296
84297 /* Not enough space: must allocate a new page */
84298 if (!b) {
84299 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84300 - if (!b)
84301 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84302 + if (!sp)
84303 return NULL;
84304 - sp = virt_to_page(b);
84305 - __SetPageSlab(sp);
84306 + b = page_address(sp);
84307
84308 spin_lock_irqsave(&slob_lock, flags);
84309 sp->units = SLOB_UNITS(PAGE_SIZE);
84310 sp->freelist = b;
84311 + sp->private = 0;
84312 INIT_LIST_HEAD(&sp->list);
84313 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84314 set_slob_page_free(sp, slob_list);
84315 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84316 if (slob_page_free(sp))
84317 clear_slob_page_free(sp);
84318 spin_unlock_irqrestore(&slob_lock, flags);
84319 - __ClearPageSlab(sp);
84320 - reset_page_mapcount(sp);
84321 - slob_free_pages(b, 0);
84322 + slob_free_pages(sp, 0);
84323 return;
84324 }
84325
84326 @@ -424,11 +426,10 @@ out:
84327 */
84328
84329 static __always_inline void *
84330 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84331 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84332 {
84333 - unsigned int *m;
84334 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84335 - void *ret;
84336 + slob_t *m;
84337 + void *ret = NULL;
84338
84339 gfp &= gfp_allowed_mask;
84340
84341 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84342
84343 if (!m)
84344 return NULL;
84345 - *m = size;
84346 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84347 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84348 + m[0].units = size;
84349 + m[1].units = align;
84350 ret = (void *)m + align;
84351
84352 trace_kmalloc_node(caller, ret,
84353 size, size + align, gfp, node);
84354 } else {
84355 unsigned int order = get_order(size);
84356 + struct page *page;
84357
84358 if (likely(order))
84359 gfp |= __GFP_COMP;
84360 - ret = slob_new_pages(gfp, order, node);
84361 + page = slob_new_pages(gfp, order, node);
84362 + if (page) {
84363 + ret = page_address(page);
84364 + page->private = size;
84365 + }
84366
84367 trace_kmalloc_node(caller, ret,
84368 size, PAGE_SIZE << order, gfp, node);
84369 }
84370
84371 - kmemleak_alloc(ret, size, 1, gfp);
84372 + return ret;
84373 +}
84374 +
84375 +static __always_inline void *
84376 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84377 +{
84378 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84379 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84380 +
84381 + if (!ZERO_OR_NULL_PTR(ret))
84382 + kmemleak_alloc(ret, size, 1, gfp);
84383 return ret;
84384 }
84385
84386 @@ -493,34 +512,112 @@ void kfree(const void *block)
84387 return;
84388 kmemleak_free(block);
84389
84390 + VM_BUG_ON(!virt_addr_valid(block));
84391 sp = virt_to_page(block);
84392 - if (PageSlab(sp)) {
84393 + VM_BUG_ON(!PageSlab(sp));
84394 + if (!sp->private) {
84395 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84396 - unsigned int *m = (unsigned int *)(block - align);
84397 - slob_free(m, *m + align);
84398 - } else
84399 + slob_t *m = (slob_t *)(block - align);
84400 + slob_free(m, m[0].units + align);
84401 + } else {
84402 + __ClearPageSlab(sp);
84403 + reset_page_mapcount(sp);
84404 + sp->private = 0;
84405 __free_pages(sp, compound_order(sp));
84406 + }
84407 }
84408 EXPORT_SYMBOL(kfree);
84409
84410 +bool is_usercopy_object(const void *ptr)
84411 +{
84412 + if (!slab_is_available())
84413 + return false;
84414 +
84415 + // PAX: TODO
84416 +
84417 + return false;
84418 +}
84419 +
84420 +#ifdef CONFIG_PAX_USERCOPY
84421 +const char *check_heap_object(const void *ptr, unsigned long n)
84422 +{
84423 + struct page *page;
84424 + const slob_t *free;
84425 + const void *base;
84426 + unsigned long flags;
84427 +
84428 + if (ZERO_OR_NULL_PTR(ptr))
84429 + return "<null>";
84430 +
84431 + if (!virt_addr_valid(ptr))
84432 + return NULL;
84433 +
84434 + page = virt_to_head_page(ptr);
84435 + if (!PageSlab(page))
84436 + return NULL;
84437 +
84438 + if (page->private) {
84439 + base = page;
84440 + if (base <= ptr && n <= page->private - (ptr - base))
84441 + return NULL;
84442 + return "<slob>";
84443 + }
84444 +
84445 + /* some tricky double walking to find the chunk */
84446 + spin_lock_irqsave(&slob_lock, flags);
84447 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84448 + free = page->freelist;
84449 +
84450 + while (!slob_last(free) && (void *)free <= ptr) {
84451 + base = free + slob_units(free);
84452 + free = slob_next(free);
84453 + }
84454 +
84455 + while (base < (void *)free) {
84456 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84457 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84458 + int offset;
84459 +
84460 + if (ptr < base + align)
84461 + break;
84462 +
84463 + offset = ptr - base - align;
84464 + if (offset >= m) {
84465 + base += size;
84466 + continue;
84467 + }
84468 +
84469 + if (n > m - offset)
84470 + break;
84471 +
84472 + spin_unlock_irqrestore(&slob_lock, flags);
84473 + return NULL;
84474 + }
84475 +
84476 + spin_unlock_irqrestore(&slob_lock, flags);
84477 + return "<slob>";
84478 +}
84479 +#endif
84480 +
84481 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84482 size_t ksize(const void *block)
84483 {
84484 struct page *sp;
84485 int align;
84486 - unsigned int *m;
84487 + slob_t *m;
84488
84489 BUG_ON(!block);
84490 if (unlikely(block == ZERO_SIZE_PTR))
84491 return 0;
84492
84493 sp = virt_to_page(block);
84494 - if (unlikely(!PageSlab(sp)))
84495 - return PAGE_SIZE << compound_order(sp);
84496 + VM_BUG_ON(!PageSlab(sp));
84497 + if (sp->private)
84498 + return sp->private;
84499
84500 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84501 - m = (unsigned int *)(block - align);
84502 - return SLOB_UNITS(*m) * SLOB_UNIT;
84503 + m = (slob_t *)(block - align);
84504 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84505 }
84506 EXPORT_SYMBOL(ksize);
84507
84508 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84509
84510 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84511 {
84512 - void *b;
84513 + void *b = NULL;
84514
84515 flags &= gfp_allowed_mask;
84516
84517 lockdep_trace_alloc(flags);
84518
84519 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84520 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84521 +#else
84522 if (c->size < PAGE_SIZE) {
84523 b = slob_alloc(c->size, flags, c->align, node);
84524 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84525 SLOB_UNITS(c->size) * SLOB_UNIT,
84526 flags, node);
84527 } else {
84528 - b = slob_new_pages(flags, get_order(c->size), node);
84529 + struct page *sp;
84530 +
84531 + sp = slob_new_pages(flags, get_order(c->size), node);
84532 + if (sp) {
84533 + b = page_address(sp);
84534 + sp->private = c->size;
84535 + }
84536 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84537 PAGE_SIZE << get_order(c->size),
84538 flags, node);
84539 }
84540 +#endif
84541
84542 if (c->ctor)
84543 c->ctor(b);
84544 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84545
84546 static void __kmem_cache_free(void *b, int size)
84547 {
84548 - if (size < PAGE_SIZE)
84549 + struct page *sp;
84550 +
84551 + sp = virt_to_page(b);
84552 + BUG_ON(!PageSlab(sp));
84553 + if (!sp->private)
84554 slob_free(b, size);
84555 else
84556 - slob_free_pages(b, get_order(size));
84557 + slob_free_pages(sp, get_order(size));
84558 }
84559
84560 static void kmem_rcu_free(struct rcu_head *head)
84561 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84562
84563 void kmem_cache_free(struct kmem_cache *c, void *b)
84564 {
84565 + int size = c->size;
84566 +
84567 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84568 + if (size + c->align < PAGE_SIZE) {
84569 + size += c->align;
84570 + b -= c->align;
84571 + }
84572 +#endif
84573 +
84574 kmemleak_free_recursive(b, c->flags);
84575 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84576 struct slob_rcu *slob_rcu;
84577 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84578 - slob_rcu->size = c->size;
84579 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84580 + slob_rcu->size = size;
84581 call_rcu(&slob_rcu->head, kmem_rcu_free);
84582 } else {
84583 - __kmem_cache_free(b, c->size);
84584 + __kmem_cache_free(b, size);
84585 }
84586
84587 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84588 + trace_kfree(_RET_IP_, b);
84589 +#else
84590 trace_kmem_cache_free(_RET_IP_, b);
84591 +#endif
84592 +
84593 }
84594 EXPORT_SYMBOL(kmem_cache_free);
84595
84596 diff --git a/mm/slub.c b/mm/slub.c
84597 index ba2ca53..991c4f7 100644
84598 --- a/mm/slub.c
84599 +++ b/mm/slub.c
84600 @@ -197,7 +197,7 @@ struct track {
84601
84602 enum track_item { TRACK_ALLOC, TRACK_FREE };
84603
84604 -#ifdef CONFIG_SYSFS
84605 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84606 static int sysfs_slab_add(struct kmem_cache *);
84607 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84608 static void sysfs_slab_remove(struct kmem_cache *);
84609 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84610 if (!t->addr)
84611 return;
84612
84613 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84614 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84615 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84616 #ifdef CONFIG_STACKTRACE
84617 {
84618 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84619 * Merge control. If this is set then no merging of slab caches will occur.
84620 * (Could be removed. This was introduced to pacify the merge skeptics.)
84621 */
84622 -static int slub_nomerge;
84623 +static int slub_nomerge = 1;
84624
84625 /*
84626 * Calculate the order of allocation given an slab object size.
84627 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84628 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84629 #endif
84630
84631 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84632 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84633 +#endif
84634 +
84635 static int __init setup_slub_min_order(char *str)
84636 {
84637 get_option(&str, &slub_min_order);
84638 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84639 return kmalloc_dma_caches[index];
84640
84641 #endif
84642 +
84643 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84644 + if (flags & SLAB_USERCOPY)
84645 + return kmalloc_usercopy_caches[index];
84646 +
84647 +#endif
84648 +
84649 return kmalloc_caches[index];
84650 }
84651
84652 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84653 EXPORT_SYMBOL(__kmalloc_node);
84654 #endif
84655
84656 +bool is_usercopy_object(const void *ptr)
84657 +{
84658 + struct page *page;
84659 + struct kmem_cache *s;
84660 +
84661 + if (ZERO_OR_NULL_PTR(ptr))
84662 + return false;
84663 +
84664 + if (!slab_is_available())
84665 + return false;
84666 +
84667 + if (!virt_addr_valid(ptr))
84668 + return false;
84669 +
84670 + page = virt_to_head_page(ptr);
84671 +
84672 + if (!PageSlab(page))
84673 + return false;
84674 +
84675 + s = page->slab_cache;
84676 + return s->flags & SLAB_USERCOPY;
84677 +}
84678 +
84679 +#ifdef CONFIG_PAX_USERCOPY
84680 +const char *check_heap_object(const void *ptr, unsigned long n)
84681 +{
84682 + struct page *page;
84683 + struct kmem_cache *s;
84684 + unsigned long offset;
84685 +
84686 + if (ZERO_OR_NULL_PTR(ptr))
84687 + return "<null>";
84688 +
84689 + if (!virt_addr_valid(ptr))
84690 + return NULL;
84691 +
84692 + page = virt_to_head_page(ptr);
84693 +
84694 + if (!PageSlab(page))
84695 + return NULL;
84696 +
84697 + s = page->slab_cache;
84698 + if (!(s->flags & SLAB_USERCOPY))
84699 + return s->name;
84700 +
84701 + offset = (ptr - page_address(page)) % s->size;
84702 + if (offset <= s->object_size && n <= s->object_size - offset)
84703 + return NULL;
84704 +
84705 + return s->name;
84706 +}
84707 +#endif
84708 +
84709 size_t ksize(const void *object)
84710 {
84711 struct page *page;
84712 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84713 if (unlikely(ZERO_OR_NULL_PTR(x)))
84714 return;
84715
84716 + VM_BUG_ON(!virt_addr_valid(x));
84717 page = virt_to_head_page(x);
84718 if (unlikely(!PageSlab(page))) {
84719 BUG_ON(!PageCompound(page));
84720 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84721
84722 /* Caches that are not of the two-to-the-power-of size */
84723 if (KMALLOC_MIN_SIZE <= 32) {
84724 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84725 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84726 caches++;
84727 }
84728
84729 if (KMALLOC_MIN_SIZE <= 64) {
84730 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84731 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84732 caches++;
84733 }
84734
84735 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84736 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84737 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84738 caches++;
84739 }
84740
84741 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84742 }
84743 }
84744 #endif
84745 +
84746 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84747 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84748 + struct kmem_cache *s = kmalloc_caches[i];
84749 +
84750 + if (s && s->size) {
84751 + char *name = kasprintf(GFP_NOWAIT,
84752 + "usercopy-kmalloc-%d", s->object_size);
84753 +
84754 + BUG_ON(!name);
84755 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84756 + s->object_size, SLAB_USERCOPY);
84757 + }
84758 + }
84759 +#endif
84760 +
84761 printk(KERN_INFO
84762 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84763 " CPUs=%d, Nodes=%d\n",
84764 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84765 /*
84766 * We may have set a slab to be unmergeable during bootstrap.
84767 */
84768 - if (s->refcount < 0)
84769 + if (atomic_read(&s->refcount) < 0)
84770 return 1;
84771
84772 return 0;
84773 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84774
84775 s = find_mergeable(memcg, size, align, flags, name, ctor);
84776 if (s) {
84777 - s->refcount++;
84778 + atomic_inc(&s->refcount);
84779 /*
84780 * Adjust the object sizes so that we clear
84781 * the complete object on kzalloc.
84782 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84783 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84784
84785 if (sysfs_slab_alias(s, name)) {
84786 - s->refcount--;
84787 + atomic_dec(&s->refcount);
84788 s = NULL;
84789 }
84790 }
84791 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84792 return NOTIFY_OK;
84793 }
84794
84795 -static struct notifier_block __cpuinitdata slab_notifier = {
84796 +static struct notifier_block slab_notifier = {
84797 .notifier_call = slab_cpuup_callback
84798 };
84799
84800 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84801 }
84802 #endif
84803
84804 -#ifdef CONFIG_SYSFS
84805 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84806 static int count_inuse(struct page *page)
84807 {
84808 return page->inuse;
84809 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84810 validate_slab_cache(kmalloc_caches[9]);
84811 }
84812 #else
84813 -#ifdef CONFIG_SYSFS
84814 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84815 static void resiliency_test(void) {};
84816 #endif
84817 #endif
84818
84819 -#ifdef CONFIG_SYSFS
84820 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84821 enum slab_stat_type {
84822 SL_ALL, /* All slabs */
84823 SL_PARTIAL, /* Only partially allocated slabs */
84824 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84825
84826 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84827 {
84828 - return sprintf(buf, "%d\n", s->refcount - 1);
84829 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84830 }
84831 SLAB_ATTR_RO(aliases);
84832
84833 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
84834 return name;
84835 }
84836
84837 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84838 static int sysfs_slab_add(struct kmem_cache *s)
84839 {
84840 int err;
84841 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
84842 kobject_del(&s->kobj);
84843 kobject_put(&s->kobj);
84844 }
84845 +#endif
84846
84847 /*
84848 * Need to buffer aliases during bootup until sysfs becomes
84849 @@ -5336,6 +5419,7 @@ struct saved_alias {
84850
84851 static struct saved_alias *alias_list;
84852
84853 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84854 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84855 {
84856 struct saved_alias *al;
84857 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84858 alias_list = al;
84859 return 0;
84860 }
84861 +#endif
84862
84863 static int __init slab_sysfs_init(void)
84864 {
84865 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
84866 index 1b7e22a..3fcd4f3 100644
84867 --- a/mm/sparse-vmemmap.c
84868 +++ b/mm/sparse-vmemmap.c
84869 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
84870 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84871 if (!p)
84872 return NULL;
84873 - pud_populate(&init_mm, pud, p);
84874 + pud_populate_kernel(&init_mm, pud, p);
84875 }
84876 return pud;
84877 }
84878 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
84879 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84880 if (!p)
84881 return NULL;
84882 - pgd_populate(&init_mm, pgd, p);
84883 + pgd_populate_kernel(&init_mm, pgd, p);
84884 }
84885 return pgd;
84886 }
84887 diff --git a/mm/sparse.c b/mm/sparse.c
84888 index 6b5fb76..db0c190 100644
84889 --- a/mm/sparse.c
84890 +++ b/mm/sparse.c
84891 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
84892
84893 for (i = 0; i < PAGES_PER_SECTION; i++) {
84894 if (PageHWPoison(&memmap[i])) {
84895 - atomic_long_sub(1, &mce_bad_pages);
84896 + atomic_long_sub_unchecked(1, &mce_bad_pages);
84897 ClearPageHWPoison(&memmap[i]);
84898 }
84899 }
84900 diff --git a/mm/swap.c b/mm/swap.c
84901 index 6310dc2..3662b3f 100644
84902 --- a/mm/swap.c
84903 +++ b/mm/swap.c
84904 @@ -30,6 +30,7 @@
84905 #include <linux/backing-dev.h>
84906 #include <linux/memcontrol.h>
84907 #include <linux/gfp.h>
84908 +#include <linux/hugetlb.h>
84909
84910 #include "internal.h"
84911
84912 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
84913
84914 __page_cache_release(page);
84915 dtor = get_compound_page_dtor(page);
84916 + if (!PageHuge(page))
84917 + BUG_ON(dtor != free_compound_page);
84918 (*dtor)(page);
84919 }
84920
84921 diff --git a/mm/swapfile.c b/mm/swapfile.c
84922 index e97a0e5..b50e796 100644
84923 --- a/mm/swapfile.c
84924 +++ b/mm/swapfile.c
84925 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
84926
84927 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
84928 /* Activity counter to indicate that a swapon or swapoff has occurred */
84929 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
84930 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
84931
84932 static inline unsigned char swap_count(unsigned char ent)
84933 {
84934 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
84935 }
84936 filp_close(swap_file, NULL);
84937 err = 0;
84938 - atomic_inc(&proc_poll_event);
84939 + atomic_inc_unchecked(&proc_poll_event);
84940 wake_up_interruptible(&proc_poll_wait);
84941
84942 out_dput:
84943 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
84944
84945 poll_wait(file, &proc_poll_wait, wait);
84946
84947 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
84948 - seq->poll_event = atomic_read(&proc_poll_event);
84949 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
84950 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84951 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
84952 }
84953
84954 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
84955 return ret;
84956
84957 seq = file->private_data;
84958 - seq->poll_event = atomic_read(&proc_poll_event);
84959 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84960 return 0;
84961 }
84962
84963 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
84964 (frontswap_map) ? "FS" : "");
84965
84966 mutex_unlock(&swapon_mutex);
84967 - atomic_inc(&proc_poll_event);
84968 + atomic_inc_unchecked(&proc_poll_event);
84969 wake_up_interruptible(&proc_poll_wait);
84970
84971 if (S_ISREG(inode->i_mode))
84972 diff --git a/mm/util.c b/mm/util.c
84973 index c55e26b..3f913a9 100644
84974 --- a/mm/util.c
84975 +++ b/mm/util.c
84976 @@ -292,6 +292,12 @@ done:
84977 void arch_pick_mmap_layout(struct mm_struct *mm)
84978 {
84979 mm->mmap_base = TASK_UNMAPPED_BASE;
84980 +
84981 +#ifdef CONFIG_PAX_RANDMMAP
84982 + if (mm->pax_flags & MF_PAX_RANDMMAP)
84983 + mm->mmap_base += mm->delta_mmap;
84984 +#endif
84985 +
84986 mm->get_unmapped_area = arch_get_unmapped_area;
84987 mm->unmap_area = arch_unmap_area;
84988 }
84989 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
84990 index 5123a16..f234a48 100644
84991 --- a/mm/vmalloc.c
84992 +++ b/mm/vmalloc.c
84993 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
84994
84995 pte = pte_offset_kernel(pmd, addr);
84996 do {
84997 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84998 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84999 +
85000 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85001 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85002 + BUG_ON(!pte_exec(*pte));
85003 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85004 + continue;
85005 + }
85006 +#endif
85007 +
85008 + {
85009 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85010 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85011 + }
85012 } while (pte++, addr += PAGE_SIZE, addr != end);
85013 }
85014
85015 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85016 pte = pte_alloc_kernel(pmd, addr);
85017 if (!pte)
85018 return -ENOMEM;
85019 +
85020 + pax_open_kernel();
85021 do {
85022 struct page *page = pages[*nr];
85023
85024 - if (WARN_ON(!pte_none(*pte)))
85025 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85026 + if (pgprot_val(prot) & _PAGE_NX)
85027 +#endif
85028 +
85029 + if (!pte_none(*pte)) {
85030 + pax_close_kernel();
85031 + WARN_ON(1);
85032 return -EBUSY;
85033 - if (WARN_ON(!page))
85034 + }
85035 + if (!page) {
85036 + pax_close_kernel();
85037 + WARN_ON(1);
85038 return -ENOMEM;
85039 + }
85040 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85041 (*nr)++;
85042 } while (pte++, addr += PAGE_SIZE, addr != end);
85043 + pax_close_kernel();
85044 return 0;
85045 }
85046
85047 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85048 pmd_t *pmd;
85049 unsigned long next;
85050
85051 - pmd = pmd_alloc(&init_mm, pud, addr);
85052 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85053 if (!pmd)
85054 return -ENOMEM;
85055 do {
85056 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85057 pud_t *pud;
85058 unsigned long next;
85059
85060 - pud = pud_alloc(&init_mm, pgd, addr);
85061 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85062 if (!pud)
85063 return -ENOMEM;
85064 do {
85065 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
85066 * and fall back on vmalloc() if that fails. Others
85067 * just put it in the vmalloc space.
85068 */
85069 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
85070 +#ifdef CONFIG_MODULES
85071 +#ifdef MODULES_VADDR
85072 unsigned long addr = (unsigned long)x;
85073 if (addr >= MODULES_VADDR && addr < MODULES_END)
85074 return 1;
85075 #endif
85076 +
85077 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85078 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85079 + return 1;
85080 +#endif
85081 +
85082 +#endif
85083 +
85084 return is_vmalloc_addr(x);
85085 }
85086
85087 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85088
85089 if (!pgd_none(*pgd)) {
85090 pud_t *pud = pud_offset(pgd, addr);
85091 +#ifdef CONFIG_X86
85092 + if (!pud_large(*pud))
85093 +#endif
85094 if (!pud_none(*pud)) {
85095 pmd_t *pmd = pmd_offset(pud, addr);
85096 +#ifdef CONFIG_X86
85097 + if (!pmd_large(*pmd))
85098 +#endif
85099 if (!pmd_none(*pmd)) {
85100 pte_t *ptep, pte;
85101
85102 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
85103 * Allocate a region of KVA of the specified size and alignment, within the
85104 * vstart and vend.
85105 */
85106 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85107 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85108 unsigned long align,
85109 unsigned long vstart, unsigned long vend,
85110 int node, gfp_t gfp_mask)
85111 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85112 struct vm_struct *area;
85113
85114 BUG_ON(in_interrupt());
85115 +
85116 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85117 + if (flags & VM_KERNEXEC) {
85118 + if (start != VMALLOC_START || end != VMALLOC_END)
85119 + return NULL;
85120 + start = (unsigned long)MODULES_EXEC_VADDR;
85121 + end = (unsigned long)MODULES_EXEC_END;
85122 + }
85123 +#endif
85124 +
85125 if (flags & VM_IOREMAP) {
85126 int bit = fls(size);
85127
85128 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
85129 if (count > totalram_pages)
85130 return NULL;
85131
85132 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85133 + if (!(pgprot_val(prot) & _PAGE_NX))
85134 + flags |= VM_KERNEXEC;
85135 +#endif
85136 +
85137 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85138 __builtin_return_address(0));
85139 if (!area)
85140 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85141 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85142 goto fail;
85143
85144 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85145 + if (!(pgprot_val(prot) & _PAGE_NX))
85146 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85147 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85148 + else
85149 +#endif
85150 +
85151 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85152 start, end, node, gfp_mask, caller);
85153 if (!area)
85154 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
85155 * For tight control over page level allocator and protection flags
85156 * use __vmalloc() instead.
85157 */
85158 -
85159 void *vmalloc_exec(unsigned long size)
85160 {
85161 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85162 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85163 -1, __builtin_return_address(0));
85164 }
85165
85166 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85167 unsigned long uaddr = vma->vm_start;
85168 unsigned long usize = vma->vm_end - vma->vm_start;
85169
85170 + BUG_ON(vma->vm_mirror);
85171 +
85172 if ((PAGE_SIZE-1) & (unsigned long)addr)
85173 return -EINVAL;
85174
85175 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
85176 v->addr, v->addr + v->size, v->size);
85177
85178 if (v->caller)
85179 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85180 + seq_printf(m, " %pK", v->caller);
85181 +#else
85182 seq_printf(m, " %pS", v->caller);
85183 +#endif
85184
85185 if (v->nr_pages)
85186 seq_printf(m, " pages=%d", v->nr_pages);
85187 diff --git a/mm/vmstat.c b/mm/vmstat.c
85188 index 9800306..76b4b27 100644
85189 --- a/mm/vmstat.c
85190 +++ b/mm/vmstat.c
85191 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
85192 *
85193 * vm_stat contains the global counters
85194 */
85195 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85196 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85197 EXPORT_SYMBOL(vm_stat);
85198
85199 #ifdef CONFIG_SMP
85200 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
85201 v = p->vm_stat_diff[i];
85202 p->vm_stat_diff[i] = 0;
85203 local_irq_restore(flags);
85204 - atomic_long_add(v, &zone->vm_stat[i]);
85205 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85206 global_diff[i] += v;
85207 #ifdef CONFIG_NUMA
85208 /* 3 seconds idle till flush */
85209 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
85210
85211 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85212 if (global_diff[i])
85213 - atomic_long_add(global_diff[i], &vm_stat[i]);
85214 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85215 }
85216
85217 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85218 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85219 if (pset->vm_stat_diff[i]) {
85220 int v = pset->vm_stat_diff[i];
85221 pset->vm_stat_diff[i] = 0;
85222 - atomic_long_add(v, &zone->vm_stat[i]);
85223 - atomic_long_add(v, &vm_stat[i]);
85224 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85225 + atomic_long_add_unchecked(v, &vm_stat[i]);
85226 }
85227 }
85228 #endif
85229 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85230 return NOTIFY_OK;
85231 }
85232
85233 -static struct notifier_block __cpuinitdata vmstat_notifier =
85234 +static struct notifier_block vmstat_notifier =
85235 { &vmstat_cpuup_callback, NULL, 0 };
85236 #endif
85237
85238 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
85239 start_cpu_timer(cpu);
85240 #endif
85241 #ifdef CONFIG_PROC_FS
85242 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85243 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85244 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85245 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85246 + {
85247 + mode_t gr_mode = S_IRUGO;
85248 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85249 + gr_mode = S_IRUSR;
85250 +#endif
85251 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85252 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85253 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85254 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85255 +#else
85256 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85257 +#endif
85258 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85259 + }
85260 #endif
85261 return 0;
85262 }
85263 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85264 index acc74ad..be02639 100644
85265 --- a/net/8021q/vlan.c
85266 +++ b/net/8021q/vlan.c
85267 @@ -108,6 +108,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85268 if (vlan_id)
85269 vlan_vid_del(real_dev, vlan_id);
85270
85271 + /* Take it out of our own structures, but be sure to interlock with
85272 + * HW accelerating devices or SW vlan input packet processing if
85273 + * VLAN is not 0 (leave it there for 802.1p).
85274 + */
85275 + if (vlan_id)
85276 + vlan_vid_del(real_dev, vlan_id);
85277 +
85278 /* Get rid of the vlan's reference to real_dev */
85279 dev_put(real_dev);
85280 }
85281 @@ -485,7 +492,7 @@ out:
85282 return NOTIFY_DONE;
85283 }
85284
85285 -static struct notifier_block vlan_notifier_block __read_mostly = {
85286 +static struct notifier_block vlan_notifier_block = {
85287 .notifier_call = vlan_device_event,
85288 };
85289
85290 @@ -560,8 +567,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85291 err = -EPERM;
85292 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85293 break;
85294 - if ((args.u.name_type >= 0) &&
85295 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85296 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85297 struct vlan_net *vn;
85298
85299 vn = net_generic(net, vlan_net_id);
85300 diff --git a/net/9p/mod.c b/net/9p/mod.c
85301 index 6ab36ae..6f1841b 100644
85302 --- a/net/9p/mod.c
85303 +++ b/net/9p/mod.c
85304 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85305 void v9fs_register_trans(struct p9_trans_module *m)
85306 {
85307 spin_lock(&v9fs_trans_lock);
85308 - list_add_tail(&m->list, &v9fs_trans_list);
85309 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85310 spin_unlock(&v9fs_trans_lock);
85311 }
85312 EXPORT_SYMBOL(v9fs_register_trans);
85313 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85314 void v9fs_unregister_trans(struct p9_trans_module *m)
85315 {
85316 spin_lock(&v9fs_trans_lock);
85317 - list_del_init(&m->list);
85318 + pax_list_del_init((struct list_head *)&m->list);
85319 spin_unlock(&v9fs_trans_lock);
85320 }
85321 EXPORT_SYMBOL(v9fs_unregister_trans);
85322 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85323 index 02efb25..41541a9 100644
85324 --- a/net/9p/trans_fd.c
85325 +++ b/net/9p/trans_fd.c
85326 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85327 oldfs = get_fs();
85328 set_fs(get_ds());
85329 /* The cast to a user pointer is valid due to the set_fs() */
85330 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85331 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85332 set_fs(oldfs);
85333
85334 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85335 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85336 index 876fbe8..8bbea9f 100644
85337 --- a/net/atm/atm_misc.c
85338 +++ b/net/atm/atm_misc.c
85339 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85340 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85341 return 1;
85342 atm_return(vcc, truesize);
85343 - atomic_inc(&vcc->stats->rx_drop);
85344 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85345 return 0;
85346 }
85347 EXPORT_SYMBOL(atm_charge);
85348 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85349 }
85350 }
85351 atm_return(vcc, guess);
85352 - atomic_inc(&vcc->stats->rx_drop);
85353 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85354 return NULL;
85355 }
85356 EXPORT_SYMBOL(atm_alloc_charge);
85357 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85358
85359 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85360 {
85361 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85362 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85363 __SONET_ITEMS
85364 #undef __HANDLE_ITEM
85365 }
85366 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85367
85368 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85369 {
85370 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85371 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85372 __SONET_ITEMS
85373 #undef __HANDLE_ITEM
85374 }
85375 diff --git a/net/atm/lec.h b/net/atm/lec.h
85376 index a86aff9..3a0d6f6 100644
85377 --- a/net/atm/lec.h
85378 +++ b/net/atm/lec.h
85379 @@ -48,7 +48,7 @@ struct lane2_ops {
85380 const u8 *tlvs, u32 sizeoftlvs);
85381 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85382 const u8 *tlvs, u32 sizeoftlvs);
85383 -};
85384 +} __no_const;
85385
85386 /*
85387 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85388 diff --git a/net/atm/proc.c b/net/atm/proc.c
85389 index 0d020de..011c7bb 100644
85390 --- a/net/atm/proc.c
85391 +++ b/net/atm/proc.c
85392 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85393 const struct k_atm_aal_stats *stats)
85394 {
85395 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85396 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85397 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85398 - atomic_read(&stats->rx_drop));
85399 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85400 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85401 + atomic_read_unchecked(&stats->rx_drop));
85402 }
85403
85404 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85405 diff --git a/net/atm/resources.c b/net/atm/resources.c
85406 index 0447d5d..3cf4728 100644
85407 --- a/net/atm/resources.c
85408 +++ b/net/atm/resources.c
85409 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85410 static void copy_aal_stats(struct k_atm_aal_stats *from,
85411 struct atm_aal_stats *to)
85412 {
85413 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85414 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85415 __AAL_STAT_ITEMS
85416 #undef __HANDLE_ITEM
85417 }
85418 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85419 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85420 struct atm_aal_stats *to)
85421 {
85422 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85423 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85424 __AAL_STAT_ITEMS
85425 #undef __HANDLE_ITEM
85426 }
85427 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85428 index d5744b7..506bae3 100644
85429 --- a/net/ax25/sysctl_net_ax25.c
85430 +++ b/net/ax25/sysctl_net_ax25.c
85431 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85432 {
85433 char path[sizeof("net/ax25/") + IFNAMSIZ];
85434 int k;
85435 - struct ctl_table *table;
85436 + ctl_table_no_const *table;
85437
85438 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85439 if (!table)
85440 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85441 index 1ee94d0..14beea2 100644
85442 --- a/net/batman-adv/bat_iv_ogm.c
85443 +++ b/net/batman-adv/bat_iv_ogm.c
85444 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85445
85446 /* randomize initial seqno to avoid collision */
85447 get_random_bytes(&random_seqno, sizeof(random_seqno));
85448 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85449 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85450
85451 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85452 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85453 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85454 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85455
85456 /* change sequence number to network order */
85457 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85458 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85459 batadv_ogm_packet->seqno = htonl(seqno);
85460 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85461 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85462
85463 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85464 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85465 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85466 return;
85467
85468 /* could be changed by schedule_own_packet() */
85469 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85470 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85471
85472 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85473 has_directlink_flag = 1;
85474 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85475 index f1d37cd..4190879 100644
85476 --- a/net/batman-adv/hard-interface.c
85477 +++ b/net/batman-adv/hard-interface.c
85478 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85479 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85480 dev_add_pack(&hard_iface->batman_adv_ptype);
85481
85482 - atomic_set(&hard_iface->frag_seqno, 1);
85483 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85484 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85485 hard_iface->net_dev->name);
85486
85487 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85488 /* This can't be called via a bat_priv callback because
85489 * we have no bat_priv yet.
85490 */
85491 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85492 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85493 hard_iface->bat_iv.ogm_buff = NULL;
85494
85495 return hard_iface;
85496 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85497 index 6b548fd..fc32c8d 100644
85498 --- a/net/batman-adv/soft-interface.c
85499 +++ b/net/batman-adv/soft-interface.c
85500 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85501 primary_if->net_dev->dev_addr, ETH_ALEN);
85502
85503 /* set broadcast sequence number */
85504 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85505 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85506 bcast_packet->seqno = htonl(seqno);
85507
85508 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85509 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
85510 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85511
85512 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85513 - atomic_set(&bat_priv->bcast_seqno, 1);
85514 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85515 atomic_set(&bat_priv->tt.vn, 0);
85516 atomic_set(&bat_priv->tt.local_changes, 0);
85517 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85518 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85519 index ae9ac9a..11e0fe7 100644
85520 --- a/net/batman-adv/types.h
85521 +++ b/net/batman-adv/types.h
85522 @@ -48,7 +48,7 @@
85523 struct batadv_hard_iface_bat_iv {
85524 unsigned char *ogm_buff;
85525 int ogm_buff_len;
85526 - atomic_t ogm_seqno;
85527 + atomic_unchecked_t ogm_seqno;
85528 };
85529
85530 struct batadv_hard_iface {
85531 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
85532 int16_t if_num;
85533 char if_status;
85534 struct net_device *net_dev;
85535 - atomic_t frag_seqno;
85536 + atomic_unchecked_t frag_seqno;
85537 struct kobject *hardif_obj;
85538 atomic_t refcount;
85539 struct packet_type batman_adv_ptype;
85540 @@ -284,7 +284,7 @@ struct batadv_priv {
85541 atomic_t orig_interval; /* uint */
85542 atomic_t hop_penalty; /* uint */
85543 atomic_t log_level; /* uint */
85544 - atomic_t bcast_seqno;
85545 + atomic_unchecked_t bcast_seqno;
85546 atomic_t bcast_queue_left;
85547 atomic_t batman_queue_left;
85548 char num_ifaces;
85549 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85550 index 10aff49..ea8e021 100644
85551 --- a/net/batman-adv/unicast.c
85552 +++ b/net/batman-adv/unicast.c
85553 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85554 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85555 frag2->flags = large_tail;
85556
85557 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85558 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85559 frag1->seqno = htons(seqno - 1);
85560 frag2->seqno = htons(seqno);
85561
85562 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85563 index 07f0739..3c42e34 100644
85564 --- a/net/bluetooth/hci_sock.c
85565 +++ b/net/bluetooth/hci_sock.c
85566 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85567 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85568 }
85569
85570 - len = min_t(unsigned int, len, sizeof(uf));
85571 + len = min((size_t)len, sizeof(uf));
85572 if (copy_from_user(&uf, optval, len)) {
85573 err = -EFAULT;
85574 break;
85575 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85576 index 22e6583..426e2f3 100644
85577 --- a/net/bluetooth/l2cap_core.c
85578 +++ b/net/bluetooth/l2cap_core.c
85579 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85580 break;
85581
85582 case L2CAP_CONF_RFC:
85583 - if (olen == sizeof(rfc))
85584 - memcpy(&rfc, (void *)val, olen);
85585 + if (olen != sizeof(rfc))
85586 + break;
85587 +
85588 + memcpy(&rfc, (void *)val, olen);
85589
85590 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85591 rfc.mode != chan->mode)
85592 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85593 index 1bcfb84..dad9f98 100644
85594 --- a/net/bluetooth/l2cap_sock.c
85595 +++ b/net/bluetooth/l2cap_sock.c
85596 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85597 struct sock *sk = sock->sk;
85598 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85599 struct l2cap_options opts;
85600 - int len, err = 0;
85601 + int err = 0;
85602 + size_t len = optlen;
85603 u32 opt;
85604
85605 BT_DBG("sk %p", sk);
85606 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85607 opts.max_tx = chan->max_tx;
85608 opts.txwin_size = chan->tx_win;
85609
85610 - len = min_t(unsigned int, sizeof(opts), optlen);
85611 + len = min(sizeof(opts), len);
85612 if (copy_from_user((char *) &opts, optval, len)) {
85613 err = -EFAULT;
85614 break;
85615 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85616 struct bt_security sec;
85617 struct bt_power pwr;
85618 struct l2cap_conn *conn;
85619 - int len, err = 0;
85620 + int err = 0;
85621 + size_t len = optlen;
85622 u32 opt;
85623
85624 BT_DBG("sk %p", sk);
85625 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85626
85627 sec.level = BT_SECURITY_LOW;
85628
85629 - len = min_t(unsigned int, sizeof(sec), optlen);
85630 + len = min(sizeof(sec), len);
85631 if (copy_from_user((char *) &sec, optval, len)) {
85632 err = -EFAULT;
85633 break;
85634 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85635
85636 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85637
85638 - len = min_t(unsigned int, sizeof(pwr), optlen);
85639 + len = min(sizeof(pwr), len);
85640 if (copy_from_user((char *) &pwr, optval, len)) {
85641 err = -EFAULT;
85642 break;
85643 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85644 index ce3f665..2c7d08f 100644
85645 --- a/net/bluetooth/rfcomm/sock.c
85646 +++ b/net/bluetooth/rfcomm/sock.c
85647 @@ -667,7 +667,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85648 struct sock *sk = sock->sk;
85649 struct bt_security sec;
85650 int err = 0;
85651 - size_t len;
85652 + size_t len = optlen;
85653 u32 opt;
85654
85655 BT_DBG("sk %p", sk);
85656 @@ -689,7 +689,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85657
85658 sec.level = BT_SECURITY_LOW;
85659
85660 - len = min_t(unsigned int, sizeof(sec), optlen);
85661 + len = min(sizeof(sec), len);
85662 if (copy_from_user((char *) &sec, optval, len)) {
85663 err = -EFAULT;
85664 break;
85665 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85666 index bd6fd0f..6492cba 100644
85667 --- a/net/bluetooth/rfcomm/tty.c
85668 +++ b/net/bluetooth/rfcomm/tty.c
85669 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85670 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85671
85672 spin_lock_irqsave(&dev->port.lock, flags);
85673 - if (dev->port.count > 0) {
85674 + if (atomic_read(&dev->port.count) > 0) {
85675 spin_unlock_irqrestore(&dev->port.lock, flags);
85676 return;
85677 }
85678 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85679 return -ENODEV;
85680
85681 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85682 - dev->channel, dev->port.count);
85683 + dev->channel, atomic_read(&dev->port.count));
85684
85685 spin_lock_irqsave(&dev->port.lock, flags);
85686 - if (++dev->port.count > 1) {
85687 + if (atomic_inc_return(&dev->port.count) > 1) {
85688 spin_unlock_irqrestore(&dev->port.lock, flags);
85689 return 0;
85690 }
85691 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85692 return;
85693
85694 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85695 - dev->port.count);
85696 + atomic_read(&dev->port.count));
85697
85698 spin_lock_irqsave(&dev->port.lock, flags);
85699 - if (!--dev->port.count) {
85700 + if (!atomic_dec_return(&dev->port.count)) {
85701 spin_unlock_irqrestore(&dev->port.lock, flags);
85702 if (dev->tty_dev->parent)
85703 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85704 diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
85705 index d9576e6..85f4f4e 100644
85706 --- a/net/bridge/br_fdb.c
85707 +++ b/net/bridge/br_fdb.c
85708 @@ -386,7 +386,7 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
85709 return 0;
85710 br_warn(br, "adding interface %s with same address "
85711 "as a received packet\n",
85712 - source->dev->name);
85713 + source ? source->dev->name : br->dev->name);
85714 fdb_delete(br, fdb);
85715 }
85716
85717 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85718 index 5fe2ff3..121d696 100644
85719 --- a/net/bridge/netfilter/ebtables.c
85720 +++ b/net/bridge/netfilter/ebtables.c
85721 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85722 tmp.valid_hooks = t->table->valid_hooks;
85723 }
85724 mutex_unlock(&ebt_mutex);
85725 - if (copy_to_user(user, &tmp, *len) != 0){
85726 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85727 BUGPRINT("c2u Didn't work\n");
85728 ret = -EFAULT;
85729 break;
85730 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85731 goto out;
85732 tmp.valid_hooks = t->valid_hooks;
85733
85734 - if (copy_to_user(user, &tmp, *len) != 0) {
85735 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85736 ret = -EFAULT;
85737 break;
85738 }
85739 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85740 tmp.entries_size = t->table->entries_size;
85741 tmp.valid_hooks = t->table->valid_hooks;
85742
85743 - if (copy_to_user(user, &tmp, *len) != 0) {
85744 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85745 ret = -EFAULT;
85746 break;
85747 }
85748 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85749 index a376ec1..1fbd6be 100644
85750 --- a/net/caif/cfctrl.c
85751 +++ b/net/caif/cfctrl.c
85752 @@ -10,6 +10,7 @@
85753 #include <linux/spinlock.h>
85754 #include <linux/slab.h>
85755 #include <linux/pkt_sched.h>
85756 +#include <linux/sched.h>
85757 #include <net/caif/caif_layer.h>
85758 #include <net/caif/cfpkt.h>
85759 #include <net/caif/cfctrl.h>
85760 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85761 memset(&dev_info, 0, sizeof(dev_info));
85762 dev_info.id = 0xff;
85763 cfsrvl_init(&this->serv, 0, &dev_info, false);
85764 - atomic_set(&this->req_seq_no, 1);
85765 - atomic_set(&this->rsp_seq_no, 1);
85766 + atomic_set_unchecked(&this->req_seq_no, 1);
85767 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85768 this->serv.layer.receive = cfctrl_recv;
85769 sprintf(this->serv.layer.name, "ctrl");
85770 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85771 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85772 struct cfctrl_request_info *req)
85773 {
85774 spin_lock_bh(&ctrl->info_list_lock);
85775 - atomic_inc(&ctrl->req_seq_no);
85776 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85777 + atomic_inc_unchecked(&ctrl->req_seq_no);
85778 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85779 list_add_tail(&req->list, &ctrl->list);
85780 spin_unlock_bh(&ctrl->info_list_lock);
85781 }
85782 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85783 if (p != first)
85784 pr_warn("Requests are not received in order\n");
85785
85786 - atomic_set(&ctrl->rsp_seq_no,
85787 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85788 p->sequence_no);
85789 list_del(&p->list);
85790 goto out;
85791 diff --git a/net/can/af_can.c b/net/can/af_can.c
85792 index ddac1ee..3ee0a78 100644
85793 --- a/net/can/af_can.c
85794 +++ b/net/can/af_can.c
85795 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
85796 };
85797
85798 /* notifier block for netdevice event */
85799 -static struct notifier_block can_netdev_notifier __read_mostly = {
85800 +static struct notifier_block can_netdev_notifier = {
85801 .notifier_call = can_notifier,
85802 };
85803
85804 diff --git a/net/can/gw.c b/net/can/gw.c
85805 index 28e7bdc..d42c4cd 100644
85806 --- a/net/can/gw.c
85807 +++ b/net/can/gw.c
85808 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
85809 MODULE_ALIAS("can-gw");
85810
85811 static HLIST_HEAD(cgw_list);
85812 -static struct notifier_block notifier;
85813
85814 static struct kmem_cache *cgw_cache __read_mostly;
85815
85816 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
85817 return err;
85818 }
85819
85820 +static struct notifier_block notifier = {
85821 + .notifier_call = cgw_notifier
85822 +};
85823 +
85824 static __init int cgw_module_init(void)
85825 {
85826 printk(banner);
85827 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
85828 return -ENOMEM;
85829
85830 /* set notifier */
85831 - notifier.notifier_call = cgw_notifier;
85832 register_netdevice_notifier(&notifier);
85833
85834 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
85835 diff --git a/net/compat.c b/net/compat.c
85836 index 79ae884..17c5c09 100644
85837 --- a/net/compat.c
85838 +++ b/net/compat.c
85839 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
85840 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
85841 __get_user(kmsg->msg_flags, &umsg->msg_flags))
85842 return -EFAULT;
85843 - kmsg->msg_name = compat_ptr(tmp1);
85844 - kmsg->msg_iov = compat_ptr(tmp2);
85845 - kmsg->msg_control = compat_ptr(tmp3);
85846 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
85847 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
85848 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
85849 return 0;
85850 }
85851
85852 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85853
85854 if (kern_msg->msg_namelen) {
85855 if (mode == VERIFY_READ) {
85856 - int err = move_addr_to_kernel(kern_msg->msg_name,
85857 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
85858 kern_msg->msg_namelen,
85859 kern_address);
85860 if (err < 0)
85861 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85862 kern_msg->msg_name = NULL;
85863
85864 tot_len = iov_from_user_compat_to_kern(kern_iov,
85865 - (struct compat_iovec __user *)kern_msg->msg_iov,
85866 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
85867 kern_msg->msg_iovlen);
85868 if (tot_len >= 0)
85869 kern_msg->msg_iov = kern_iov;
85870 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85871
85872 #define CMSG_COMPAT_FIRSTHDR(msg) \
85873 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
85874 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
85875 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
85876 (struct compat_cmsghdr __user *)NULL)
85877
85878 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
85879 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
85880 (ucmlen) <= (unsigned long) \
85881 ((mhdr)->msg_controllen - \
85882 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
85883 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
85884
85885 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
85886 struct compat_cmsghdr __user *cmsg, int cmsg_len)
85887 {
85888 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
85889 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
85890 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
85891 msg->msg_controllen)
85892 return NULL;
85893 return (struct compat_cmsghdr __user *)ptr;
85894 @@ -219,7 +219,7 @@ Efault:
85895
85896 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
85897 {
85898 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85899 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85900 struct compat_cmsghdr cmhdr;
85901 struct compat_timeval ctv;
85902 struct compat_timespec cts[3];
85903 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
85904
85905 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
85906 {
85907 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85908 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85909 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
85910 int fdnum = scm->fp->count;
85911 struct file **fp = scm->fp->fp;
85912 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
85913 return -EFAULT;
85914 old_fs = get_fs();
85915 set_fs(KERNEL_DS);
85916 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
85917 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
85918 set_fs(old_fs);
85919
85920 return err;
85921 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
85922 len = sizeof(ktime);
85923 old_fs = get_fs();
85924 set_fs(KERNEL_DS);
85925 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
85926 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
85927 set_fs(old_fs);
85928
85929 if (!err) {
85930 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85931 case MCAST_JOIN_GROUP:
85932 case MCAST_LEAVE_GROUP:
85933 {
85934 - struct compat_group_req __user *gr32 = (void *)optval;
85935 + struct compat_group_req __user *gr32 = (void __user *)optval;
85936 struct group_req __user *kgr =
85937 compat_alloc_user_space(sizeof(struct group_req));
85938 u32 interface;
85939 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85940 case MCAST_BLOCK_SOURCE:
85941 case MCAST_UNBLOCK_SOURCE:
85942 {
85943 - struct compat_group_source_req __user *gsr32 = (void *)optval;
85944 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
85945 struct group_source_req __user *kgsr = compat_alloc_user_space(
85946 sizeof(struct group_source_req));
85947 u32 interface;
85948 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85949 }
85950 case MCAST_MSFILTER:
85951 {
85952 - struct compat_group_filter __user *gf32 = (void *)optval;
85953 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85954 struct group_filter __user *kgf;
85955 u32 interface, fmode, numsrc;
85956
85957 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
85958 char __user *optval, int __user *optlen,
85959 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
85960 {
85961 - struct compat_group_filter __user *gf32 = (void *)optval;
85962 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85963 struct group_filter __user *kgf;
85964 int __user *koptlen;
85965 u32 interface, fmode, numsrc;
85966 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
85967
85968 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
85969 return -EINVAL;
85970 - if (copy_from_user(a, args, nas[call]))
85971 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
85972 return -EFAULT;
85973 a0 = a[0];
85974 a1 = a[1];
85975 diff --git a/net/core/datagram.c b/net/core/datagram.c
85976 index 368f9c3..f82d4a3 100644
85977 --- a/net/core/datagram.c
85978 +++ b/net/core/datagram.c
85979 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
85980 }
85981
85982 kfree_skb(skb);
85983 - atomic_inc(&sk->sk_drops);
85984 + atomic_inc_unchecked(&sk->sk_drops);
85985 sk_mem_reclaim_partial(sk);
85986
85987 return err;
85988 diff --git a/net/core/dev.c b/net/core/dev.c
85989 index 5d9c43d..b471558 100644
85990 --- a/net/core/dev.c
85991 +++ b/net/core/dev.c
85992 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
85993 if (no_module && capable(CAP_NET_ADMIN))
85994 no_module = request_module("netdev-%s", name);
85995 if (no_module && capable(CAP_SYS_MODULE)) {
85996 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
85997 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
85998 +#else
85999 if (!request_module("%s", name))
86000 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86001 name);
86002 +#endif
86003 }
86004 }
86005 EXPORT_SYMBOL(dev_load);
86006 @@ -1714,7 +1718,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86007 {
86008 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86009 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86010 - atomic_long_inc(&dev->rx_dropped);
86011 + atomic_long_inc_unchecked(&dev->rx_dropped);
86012 kfree_skb(skb);
86013 return NET_RX_DROP;
86014 }
86015 @@ -1724,7 +1728,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86016 nf_reset(skb);
86017
86018 if (unlikely(!is_skb_forwardable(dev, skb))) {
86019 - atomic_long_inc(&dev->rx_dropped);
86020 + atomic_long_inc_unchecked(&dev->rx_dropped);
86021 kfree_skb(skb);
86022 return NET_RX_DROP;
86023 }
86024 @@ -2179,7 +2183,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86025
86026 struct dev_gso_cb {
86027 void (*destructor)(struct sk_buff *skb);
86028 -};
86029 +} __no_const;
86030
86031 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86032
86033 @@ -3052,7 +3056,7 @@ enqueue:
86034
86035 local_irq_restore(flags);
86036
86037 - atomic_long_inc(&skb->dev->rx_dropped);
86038 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86039 kfree_skb(skb);
86040 return NET_RX_DROP;
86041 }
86042 @@ -3124,7 +3128,7 @@ int netif_rx_ni(struct sk_buff *skb)
86043 }
86044 EXPORT_SYMBOL(netif_rx_ni);
86045
86046 -static void net_tx_action(struct softirq_action *h)
86047 +static void net_tx_action(void)
86048 {
86049 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86050
86051 @@ -3462,7 +3466,7 @@ ncls:
86052 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86053 } else {
86054 drop:
86055 - atomic_long_inc(&skb->dev->rx_dropped);
86056 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86057 kfree_skb(skb);
86058 /* Jamal, now you will not able to escape explaining
86059 * me how you were going to use this. :-)
86060 @@ -4045,7 +4049,7 @@ void netif_napi_del(struct napi_struct *napi)
86061 }
86062 EXPORT_SYMBOL(netif_napi_del);
86063
86064 -static void net_rx_action(struct softirq_action *h)
86065 +static void net_rx_action(void)
86066 {
86067 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86068 unsigned long time_limit = jiffies + 2;
86069 @@ -4529,8 +4533,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86070 else
86071 seq_printf(seq, "%04x", ntohs(pt->type));
86072
86073 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86074 + seq_printf(seq, " %-8s %p\n",
86075 + pt->dev ? pt->dev->name : "", NULL);
86076 +#else
86077 seq_printf(seq, " %-8s %pF\n",
86078 pt->dev ? pt->dev->name : "", pt->func);
86079 +#endif
86080 }
86081
86082 return 0;
86083 @@ -6102,7 +6111,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86084 } else {
86085 netdev_stats_to_stats64(storage, &dev->stats);
86086 }
86087 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86088 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86089 return storage;
86090 }
86091 EXPORT_SYMBOL(dev_get_stats);
86092 diff --git a/net/core/flow.c b/net/core/flow.c
86093 index 3bad824..2071a55 100644
86094 --- a/net/core/flow.c
86095 +++ b/net/core/flow.c
86096 @@ -61,7 +61,7 @@ struct flow_cache {
86097 struct timer_list rnd_timer;
86098 };
86099
86100 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86101 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86102 EXPORT_SYMBOL(flow_cache_genid);
86103 static struct flow_cache flow_cache_global;
86104 static struct kmem_cache *flow_cachep __read_mostly;
86105 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86106
86107 static int flow_entry_valid(struct flow_cache_entry *fle)
86108 {
86109 - if (atomic_read(&flow_cache_genid) != fle->genid)
86110 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86111 return 0;
86112 if (fle->object && !fle->object->ops->check(fle->object))
86113 return 0;
86114 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86115 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86116 fcp->hash_count++;
86117 }
86118 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86119 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86120 flo = fle->object;
86121 if (!flo)
86122 goto ret_object;
86123 @@ -280,7 +280,7 @@ nocache:
86124 }
86125 flo = resolver(net, key, family, dir, flo, ctx);
86126 if (fle) {
86127 - fle->genid = atomic_read(&flow_cache_genid);
86128 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86129 if (!IS_ERR(flo))
86130 fle->object = flo;
86131 else
86132 diff --git a/net/core/iovec.c b/net/core/iovec.c
86133 index 7e7aeb0..2a998cb 100644
86134 --- a/net/core/iovec.c
86135 +++ b/net/core/iovec.c
86136 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86137 if (m->msg_namelen) {
86138 if (mode == VERIFY_READ) {
86139 void __user *namep;
86140 - namep = (void __user __force *) m->msg_name;
86141 + namep = (void __force_user *) m->msg_name;
86142 err = move_addr_to_kernel(namep, m->msg_namelen,
86143 address);
86144 if (err < 0)
86145 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86146 }
86147
86148 size = m->msg_iovlen * sizeof(struct iovec);
86149 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86150 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86151 return -EFAULT;
86152
86153 m->msg_iov = iov;
86154 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86155 index c815f28..e6403f2 100644
86156 --- a/net/core/neighbour.c
86157 +++ b/net/core/neighbour.c
86158 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86159 size_t *lenp, loff_t *ppos)
86160 {
86161 int size, ret;
86162 - ctl_table tmp = *ctl;
86163 + ctl_table_no_const tmp = *ctl;
86164
86165 tmp.extra1 = &zero;
86166 tmp.extra2 = &unres_qlen_max;
86167 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86168 index 28c5f5a..7edf2e2 100644
86169 --- a/net/core/net-sysfs.c
86170 +++ b/net/core/net-sysfs.c
86171 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86172 }
86173 EXPORT_SYMBOL(netdev_class_remove_file);
86174
86175 -int netdev_kobject_init(void)
86176 +int __init netdev_kobject_init(void)
86177 {
86178 kobj_ns_type_register(&net_ns_type_operations);
86179 return class_register(&net_class);
86180 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86181 index 8acce01..2e306bb 100644
86182 --- a/net/core/net_namespace.c
86183 +++ b/net/core/net_namespace.c
86184 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
86185 int error;
86186 LIST_HEAD(net_exit_list);
86187
86188 - list_add_tail(&ops->list, list);
86189 + pax_list_add_tail((struct list_head *)&ops->list, list);
86190 if (ops->init || (ops->id && ops->size)) {
86191 for_each_net(net) {
86192 error = ops_init(ops, net);
86193 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
86194
86195 out_undo:
86196 /* If I have an error cleanup all namespaces I initialized */
86197 - list_del(&ops->list);
86198 + pax_list_del((struct list_head *)&ops->list);
86199 ops_exit_list(ops, &net_exit_list);
86200 ops_free_list(ops, &net_exit_list);
86201 return error;
86202 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86203 struct net *net;
86204 LIST_HEAD(net_exit_list);
86205
86206 - list_del(&ops->list);
86207 + pax_list_del((struct list_head *)&ops->list);
86208 for_each_net(net)
86209 list_add_tail(&net->exit_list, &net_exit_list);
86210 ops_exit_list(ops, &net_exit_list);
86211 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
86212 mutex_lock(&net_mutex);
86213 error = register_pernet_operations(&pernet_list, ops);
86214 if (!error && (first_device == &pernet_list))
86215 - first_device = &ops->list;
86216 + first_device = (struct list_head *)&ops->list;
86217 mutex_unlock(&net_mutex);
86218 return error;
86219 }
86220 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86221 index 6212ec9..5ee16b2 100644
86222 --- a/net/core/rtnetlink.c
86223 +++ b/net/core/rtnetlink.c
86224 @@ -58,7 +58,7 @@ struct rtnl_link {
86225 rtnl_doit_func doit;
86226 rtnl_dumpit_func dumpit;
86227 rtnl_calcit_func calcit;
86228 -};
86229 +} __no_const;
86230
86231 static DEFINE_MUTEX(rtnl_mutex);
86232
86233 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86234 if (rtnl_link_ops_get(ops->kind))
86235 return -EEXIST;
86236
86237 - if (!ops->dellink)
86238 - ops->dellink = unregister_netdevice_queue;
86239 + if (!ops->dellink) {
86240 + pax_open_kernel();
86241 + *(void **)&ops->dellink = unregister_netdevice_queue;
86242 + pax_close_kernel();
86243 + }
86244
86245 - list_add_tail(&ops->list, &link_ops);
86246 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86247 return 0;
86248 }
86249 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86250 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86251 for_each_net(net) {
86252 __rtnl_kill_links(net, ops);
86253 }
86254 - list_del(&ops->list);
86255 + pax_list_del((struct list_head *)&ops->list);
86256 }
86257 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86258
86259 @@ -1068,7 +1071,7 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
86260 rcu_read_lock();
86261 cb->seq = net->dev_base_seq;
86262
86263 - if (nlmsg_parse(cb->nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
86264 + if (nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
86265 ifla_policy) >= 0) {
86266
86267 if (tb[IFLA_EXT_MASK])
86268 @@ -1924,7 +1927,7 @@ static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
86269 u32 ext_filter_mask = 0;
86270 u16 min_ifinfo_dump_size = 0;
86271
86272 - if (nlmsg_parse(nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
86273 + if (nlmsg_parse(nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
86274 ifla_policy) >= 0) {
86275 if (tb[IFLA_EXT_MASK])
86276 ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
86277 diff --git a/net/core/scm.c b/net/core/scm.c
86278 index 2dc6cda..2159524 100644
86279 --- a/net/core/scm.c
86280 +++ b/net/core/scm.c
86281 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86282 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86283 {
86284 struct cmsghdr __user *cm
86285 - = (__force struct cmsghdr __user *)msg->msg_control;
86286 + = (struct cmsghdr __force_user *)msg->msg_control;
86287 struct cmsghdr cmhdr;
86288 int cmlen = CMSG_LEN(len);
86289 int err;
86290 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86291 err = -EFAULT;
86292 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86293 goto out;
86294 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86295 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86296 goto out;
86297 cmlen = CMSG_SPACE(len);
86298 if (msg->msg_controllen < cmlen)
86299 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86300 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86301 {
86302 struct cmsghdr __user *cm
86303 - = (__force struct cmsghdr __user*)msg->msg_control;
86304 + = (struct cmsghdr __force_user *)msg->msg_control;
86305
86306 int fdmax = 0;
86307 int fdnum = scm->fp->count;
86308 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86309 if (fdnum < fdmax)
86310 fdmax = fdnum;
86311
86312 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86313 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86314 i++, cmfptr++)
86315 {
86316 struct socket *sock;
86317 diff --git a/net/core/sock.c b/net/core/sock.c
86318 index bc131d4..029e378 100644
86319 --- a/net/core/sock.c
86320 +++ b/net/core/sock.c
86321 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86322 struct sk_buff_head *list = &sk->sk_receive_queue;
86323
86324 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86325 - atomic_inc(&sk->sk_drops);
86326 + atomic_inc_unchecked(&sk->sk_drops);
86327 trace_sock_rcvqueue_full(sk, skb);
86328 return -ENOMEM;
86329 }
86330 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86331 return err;
86332
86333 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86334 - atomic_inc(&sk->sk_drops);
86335 + atomic_inc_unchecked(&sk->sk_drops);
86336 return -ENOBUFS;
86337 }
86338
86339 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86340 skb_dst_force(skb);
86341
86342 spin_lock_irqsave(&list->lock, flags);
86343 - skb->dropcount = atomic_read(&sk->sk_drops);
86344 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86345 __skb_queue_tail(list, skb);
86346 spin_unlock_irqrestore(&list->lock, flags);
86347
86348 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86349 skb->dev = NULL;
86350
86351 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86352 - atomic_inc(&sk->sk_drops);
86353 + atomic_inc_unchecked(&sk->sk_drops);
86354 goto discard_and_relse;
86355 }
86356 if (nested)
86357 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86358 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86359 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86360 bh_unlock_sock(sk);
86361 - atomic_inc(&sk->sk_drops);
86362 + atomic_inc_unchecked(&sk->sk_drops);
86363 goto discard_and_relse;
86364 }
86365
86366 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86367 struct timeval tm;
86368 } v;
86369
86370 - int lv = sizeof(int);
86371 - int len;
86372 + unsigned int lv = sizeof(int);
86373 + unsigned int len;
86374
86375 if (get_user(len, optlen))
86376 return -EFAULT;
86377 - if (len < 0)
86378 + if (len > INT_MAX)
86379 return -EINVAL;
86380
86381 memset(&v, 0, sizeof(v));
86382 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86383
86384 case SO_PEERNAME:
86385 {
86386 - char address[128];
86387 + char address[_K_SS_MAXSIZE];
86388
86389 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86390 return -ENOTCONN;
86391 - if (lv < len)
86392 + if (lv < len || sizeof address < len)
86393 return -EINVAL;
86394 if (copy_to_user(optval, address, len))
86395 return -EFAULT;
86396 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86397
86398 if (len > lv)
86399 len = lv;
86400 - if (copy_to_user(optval, &v, len))
86401 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86402 return -EFAULT;
86403 lenout:
86404 if (put_user(len, optlen))
86405 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86406 */
86407 smp_wmb();
86408 atomic_set(&sk->sk_refcnt, 1);
86409 - atomic_set(&sk->sk_drops, 0);
86410 + atomic_set_unchecked(&sk->sk_drops, 0);
86411 }
86412 EXPORT_SYMBOL(sock_init_data);
86413
86414 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86415 index 750f44f..922399c 100644
86416 --- a/net/core/sock_diag.c
86417 +++ b/net/core/sock_diag.c
86418 @@ -9,26 +9,33 @@
86419 #include <linux/inet_diag.h>
86420 #include <linux/sock_diag.h>
86421
86422 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86423 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86424 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86425 static DEFINE_MUTEX(sock_diag_table_mutex);
86426
86427 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86428 {
86429 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86430 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86431 cookie[1] != INET_DIAG_NOCOOKIE) &&
86432 ((u32)(unsigned long)sk != cookie[0] ||
86433 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86434 return -ESTALE;
86435 else
86436 +#endif
86437 return 0;
86438 }
86439 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86440
86441 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86442 {
86443 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86444 + cookie[0] = 0;
86445 + cookie[1] = 0;
86446 +#else
86447 cookie[0] = (u32)(unsigned long)sk;
86448 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86449 +#endif
86450 }
86451 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86452
86453 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86454 mutex_lock(&sock_diag_table_mutex);
86455 if (sock_diag_handlers[hndl->family])
86456 err = -EBUSY;
86457 - else
86458 + else {
86459 + pax_open_kernel();
86460 sock_diag_handlers[hndl->family] = hndl;
86461 + pax_close_kernel();
86462 + }
86463 mutex_unlock(&sock_diag_table_mutex);
86464
86465 return err;
86466 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86467
86468 mutex_lock(&sock_diag_table_mutex);
86469 BUG_ON(sock_diag_handlers[family] != hnld);
86470 + pax_open_kernel();
86471 sock_diag_handlers[family] = NULL;
86472 + pax_close_kernel();
86473 mutex_unlock(&sock_diag_table_mutex);
86474 }
86475 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86476
86477 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
86478 -{
86479 - if (sock_diag_handlers[family] == NULL)
86480 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86481 - NETLINK_SOCK_DIAG, family);
86482 -
86483 - mutex_lock(&sock_diag_table_mutex);
86484 - return sock_diag_handlers[family];
86485 -}
86486 -
86487 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
86488 -{
86489 - mutex_unlock(&sock_diag_table_mutex);
86490 -}
86491 -
86492 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86493 {
86494 int err;
86495 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86496 if (req->sdiag_family >= AF_MAX)
86497 return -EINVAL;
86498
86499 - hndl = sock_diag_lock_handler(req->sdiag_family);
86500 + if (sock_diag_handlers[req->sdiag_family] == NULL)
86501 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86502 + NETLINK_SOCK_DIAG, req->sdiag_family);
86503 +
86504 + mutex_lock(&sock_diag_table_mutex);
86505 + hndl = sock_diag_handlers[req->sdiag_family];
86506 if (hndl == NULL)
86507 err = -ENOENT;
86508 else
86509 err = hndl->dump(skb, nlh);
86510 - sock_diag_unlock_handler(hndl);
86511 + mutex_unlock(&sock_diag_table_mutex);
86512
86513 return err;
86514 }
86515 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86516 index d1b0804..98cf5f7 100644
86517 --- a/net/core/sysctl_net_core.c
86518 +++ b/net/core/sysctl_net_core.c
86519 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86520 {
86521 unsigned int orig_size, size;
86522 int ret, i;
86523 - ctl_table tmp = {
86524 + ctl_table_no_const tmp = {
86525 .data = &size,
86526 .maxlen = sizeof(size),
86527 .mode = table->mode
86528 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
86529
86530 static __net_init int sysctl_core_net_init(struct net *net)
86531 {
86532 - struct ctl_table *tbl;
86533 + ctl_table_no_const *tbl = NULL;
86534
86535 net->core.sysctl_somaxconn = SOMAXCONN;
86536
86537 - tbl = netns_core_table;
86538 if (!net_eq(net, &init_net)) {
86539 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86540 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86541 if (tbl == NULL)
86542 goto err_dup;
86543
86544 @@ -221,17 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86545 if (net->user_ns != &init_user_ns) {
86546 tbl[0].procname = NULL;
86547 }
86548 - }
86549 -
86550 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86551 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86552 + } else
86553 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86554 if (net->core.sysctl_hdr == NULL)
86555 goto err_reg;
86556
86557 return 0;
86558
86559 err_reg:
86560 - if (tbl != netns_core_table)
86561 - kfree(tbl);
86562 + kfree(tbl);
86563 err_dup:
86564 return -ENOMEM;
86565 }
86566 @@ -246,7 +244,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86567 kfree(tbl);
86568 }
86569
86570 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86571 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86572 .init = sysctl_core_net_init,
86573 .exit = sysctl_core_net_exit,
86574 };
86575 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86576 index 307c322..78a4c6f 100644
86577 --- a/net/decnet/af_decnet.c
86578 +++ b/net/decnet/af_decnet.c
86579 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
86580 .sysctl_rmem = sysctl_decnet_rmem,
86581 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86582 .obj_size = sizeof(struct dn_sock),
86583 + .slab_flags = SLAB_USERCOPY,
86584 };
86585
86586 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86587 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86588 index a55eecc..dd8428c 100644
86589 --- a/net/decnet/sysctl_net_decnet.c
86590 +++ b/net/decnet/sysctl_net_decnet.c
86591 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86592
86593 if (len > *lenp) len = *lenp;
86594
86595 - if (copy_to_user(buffer, addr, len))
86596 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86597 return -EFAULT;
86598
86599 *lenp = len;
86600 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86601
86602 if (len > *lenp) len = *lenp;
86603
86604 - if (copy_to_user(buffer, devname, len))
86605 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86606 return -EFAULT;
86607
86608 *lenp = len;
86609 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86610 index fcf104e..95552d4 100644
86611 --- a/net/ipv4/af_inet.c
86612 +++ b/net/ipv4/af_inet.c
86613 @@ -1717,13 +1717,9 @@ static int __init inet_init(void)
86614
86615 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
86616
86617 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86618 - if (!sysctl_local_reserved_ports)
86619 - goto out;
86620 -
86621 rc = proto_register(&tcp_prot, 1);
86622 if (rc)
86623 - goto out_free_reserved_ports;
86624 + goto out;
86625
86626 rc = proto_register(&udp_prot, 1);
86627 if (rc)
86628 @@ -1832,8 +1828,6 @@ out_unregister_udp_proto:
86629 proto_unregister(&udp_prot);
86630 out_unregister_tcp_proto:
86631 proto_unregister(&tcp_prot);
86632 -out_free_reserved_ports:
86633 - kfree(sysctl_local_reserved_ports);
86634 goto out;
86635 }
86636
86637 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86638 index a69b4e4..dbccba5 100644
86639 --- a/net/ipv4/ah4.c
86640 +++ b/net/ipv4/ah4.c
86641 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86642 return;
86643
86644 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86645 - atomic_inc(&flow_cache_genid);
86646 + atomic_inc_unchecked(&flow_cache_genid);
86647 rt_genid_bump(net);
86648
86649 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86650 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86651 index a8e4f26..25e5f40 100644
86652 --- a/net/ipv4/devinet.c
86653 +++ b/net/ipv4/devinet.c
86654 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86655 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86656 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86657
86658 -static struct devinet_sysctl_table {
86659 +static const struct devinet_sysctl_table {
86660 struct ctl_table_header *sysctl_header;
86661 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86662 } devinet_sysctl = {
86663 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
86664 int err;
86665 struct ipv4_devconf *all, *dflt;
86666 #ifdef CONFIG_SYSCTL
86667 - struct ctl_table *tbl = ctl_forward_entry;
86668 + ctl_table_no_const *tbl = NULL;
86669 struct ctl_table_header *forw_hdr;
86670 #endif
86671
86672 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
86673 goto err_alloc_dflt;
86674
86675 #ifdef CONFIG_SYSCTL
86676 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86677 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86678 if (tbl == NULL)
86679 goto err_alloc_ctl;
86680
86681 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
86682 goto err_reg_dflt;
86683
86684 err = -ENOMEM;
86685 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86686 + if (!net_eq(net, &init_net))
86687 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86688 + else
86689 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86690 if (forw_hdr == NULL)
86691 goto err_reg_ctl;
86692 net->ipv4.forw_hdr = forw_hdr;
86693 @@ -1935,8 +1938,7 @@ err_reg_ctl:
86694 err_reg_dflt:
86695 __devinet_sysctl_unregister(all);
86696 err_reg_all:
86697 - if (tbl != ctl_forward_entry)
86698 - kfree(tbl);
86699 + kfree(tbl);
86700 err_alloc_ctl:
86701 #endif
86702 if (dflt != &ipv4_devconf_dflt)
86703 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86704 index 3b4f0cd..8cb864c 100644
86705 --- a/net/ipv4/esp4.c
86706 +++ b/net/ipv4/esp4.c
86707 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86708 return;
86709
86710 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86711 - atomic_inc(&flow_cache_genid);
86712 + atomic_inc_unchecked(&flow_cache_genid);
86713 rt_genid_bump(net);
86714
86715 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86716 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86717 index 5cd75e2..f57ef39 100644
86718 --- a/net/ipv4/fib_frontend.c
86719 +++ b/net/ipv4/fib_frontend.c
86720 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86721 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86722 fib_sync_up(dev);
86723 #endif
86724 - atomic_inc(&net->ipv4.dev_addr_genid);
86725 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86726 rt_cache_flush(dev_net(dev));
86727 break;
86728 case NETDEV_DOWN:
86729 fib_del_ifaddr(ifa, NULL);
86730 - atomic_inc(&net->ipv4.dev_addr_genid);
86731 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86732 if (ifa->ifa_dev->ifa_list == NULL) {
86733 /* Last address was deleted from this interface.
86734 * Disable IP.
86735 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86736 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86737 fib_sync_up(dev);
86738 #endif
86739 - atomic_inc(&net->ipv4.dev_addr_genid);
86740 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86741 rt_cache_flush(net);
86742 break;
86743 case NETDEV_DOWN:
86744 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86745 index 4797a80..2bd54e9 100644
86746 --- a/net/ipv4/fib_semantics.c
86747 +++ b/net/ipv4/fib_semantics.c
86748 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86749 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86750 nh->nh_gw,
86751 nh->nh_parent->fib_scope);
86752 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86753 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86754
86755 return nh->nh_saddr;
86756 }
86757 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86758 index d0670f0..744ac80 100644
86759 --- a/net/ipv4/inet_connection_sock.c
86760 +++ b/net/ipv4/inet_connection_sock.c
86761 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86762 .range = { 32768, 61000 },
86763 };
86764
86765 -unsigned long *sysctl_local_reserved_ports;
86766 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86767 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86768
86769 void inet_get_local_port_range(int *low, int *high)
86770 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86771 index fa3ae81..0dbe6b8 100644
86772 --- a/net/ipv4/inet_hashtables.c
86773 +++ b/net/ipv4/inet_hashtables.c
86774 @@ -18,12 +18,15 @@
86775 #include <linux/sched.h>
86776 #include <linux/slab.h>
86777 #include <linux/wait.h>
86778 +#include <linux/security.h>
86779
86780 #include <net/inet_connection_sock.h>
86781 #include <net/inet_hashtables.h>
86782 #include <net/secure_seq.h>
86783 #include <net/ip.h>
86784
86785 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86786 +
86787 /*
86788 * Allocate and initialize a new local port bind bucket.
86789 * The bindhash mutex for snum's hash chain must be held here.
86790 @@ -540,6 +543,8 @@ ok:
86791 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86792 spin_unlock(&head->lock);
86793
86794 + gr_update_task_in_ip_table(current, inet_sk(sk));
86795 +
86796 if (tw) {
86797 inet_twsk_deschedule(tw, death_row);
86798 while (twrefcnt) {
86799 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86800 index 000e3d2..5472da3 100644
86801 --- a/net/ipv4/inetpeer.c
86802 +++ b/net/ipv4/inetpeer.c
86803 @@ -503,8 +503,8 @@ relookup:
86804 if (p) {
86805 p->daddr = *daddr;
86806 atomic_set(&p->refcnt, 1);
86807 - atomic_set(&p->rid, 0);
86808 - atomic_set(&p->ip_id_count,
86809 + atomic_set_unchecked(&p->rid, 0);
86810 + atomic_set_unchecked(&p->ip_id_count,
86811 (daddr->family == AF_INET) ?
86812 secure_ip_id(daddr->addr.a4) :
86813 secure_ipv6_id(daddr->addr.a6));
86814 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
86815 index a8fc332..4ca4ca65 100644
86816 --- a/net/ipv4/ip_fragment.c
86817 +++ b/net/ipv4/ip_fragment.c
86818 @@ -319,7 +319,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
86819 return 0;
86820
86821 start = qp->rid;
86822 - end = atomic_inc_return(&peer->rid);
86823 + end = atomic_inc_return_unchecked(&peer->rid);
86824 qp->rid = end;
86825
86826 rc = qp->q.fragments && (end - start) > max;
86827 @@ -786,12 +786,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
86828
86829 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86830 {
86831 - struct ctl_table *table;
86832 + ctl_table_no_const *table = NULL;
86833 struct ctl_table_header *hdr;
86834
86835 - table = ip4_frags_ns_ctl_table;
86836 if (!net_eq(net, &init_net)) {
86837 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86838 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86839 if (table == NULL)
86840 goto err_alloc;
86841
86842 @@ -802,9 +801,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86843 /* Don't export sysctls to unprivileged users */
86844 if (net->user_ns != &init_user_ns)
86845 table[0].procname = NULL;
86846 - }
86847 + hdr = register_net_sysctl(net, "net/ipv4", table);
86848 + } else
86849 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
86850
86851 - hdr = register_net_sysctl(net, "net/ipv4", table);
86852 if (hdr == NULL)
86853 goto err_reg;
86854
86855 @@ -812,8 +812,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86856 return 0;
86857
86858 err_reg:
86859 - if (!net_eq(net, &init_net))
86860 - kfree(table);
86861 + kfree(table);
86862 err_alloc:
86863 return -ENOMEM;
86864 }
86865 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
86866 index a85062b..2958a9b 100644
86867 --- a/net/ipv4/ip_gre.c
86868 +++ b/net/ipv4/ip_gre.c
86869 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
86870 module_param(log_ecn_error, bool, 0644);
86871 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
86872
86873 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
86874 +static struct rtnl_link_ops ipgre_link_ops;
86875 static int ipgre_tunnel_init(struct net_device *dev);
86876 static void ipgre_tunnel_setup(struct net_device *dev);
86877 static int ipgre_tunnel_bind_dev(struct net_device *dev);
86878 @@ -1753,7 +1753,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
86879 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
86880 };
86881
86882 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86883 +static struct rtnl_link_ops ipgre_link_ops = {
86884 .kind = "gre",
86885 .maxtype = IFLA_GRE_MAX,
86886 .policy = ipgre_policy,
86887 @@ -1766,7 +1766,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86888 .fill_info = ipgre_fill_info,
86889 };
86890
86891 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
86892 +static struct rtnl_link_ops ipgre_tap_ops = {
86893 .kind = "gretap",
86894 .maxtype = IFLA_GRE_MAX,
86895 .policy = ipgre_policy,
86896 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
86897 index d9c4f11..02b82dbc 100644
86898 --- a/net/ipv4/ip_sockglue.c
86899 +++ b/net/ipv4/ip_sockglue.c
86900 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86901 len = min_t(unsigned int, len, opt->optlen);
86902 if (put_user(len, optlen))
86903 return -EFAULT;
86904 - if (copy_to_user(optval, opt->__data, len))
86905 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
86906 + copy_to_user(optval, opt->__data, len))
86907 return -EFAULT;
86908 return 0;
86909 }
86910 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86911 if (sk->sk_type != SOCK_STREAM)
86912 return -ENOPROTOOPT;
86913
86914 - msg.msg_control = optval;
86915 + msg.msg_control = (void __force_kernel *)optval;
86916 msg.msg_controllen = len;
86917 msg.msg_flags = flags;
86918
86919 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
86920 index c3a4233..1412161 100644
86921 --- a/net/ipv4/ip_vti.c
86922 +++ b/net/ipv4/ip_vti.c
86923 @@ -47,7 +47,7 @@
86924 #define HASH_SIZE 16
86925 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
86926
86927 -static struct rtnl_link_ops vti_link_ops __read_mostly;
86928 +static struct rtnl_link_ops vti_link_ops;
86929
86930 static int vti_net_id __read_mostly;
86931 struct vti_net {
86932 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
86933 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
86934 };
86935
86936 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
86937 +static struct rtnl_link_ops vti_link_ops = {
86938 .kind = "vti",
86939 .maxtype = IFLA_VTI_MAX,
86940 .policy = vti_policy,
86941 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
86942 index 9a46dae..5f793a0 100644
86943 --- a/net/ipv4/ipcomp.c
86944 +++ b/net/ipv4/ipcomp.c
86945 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
86946 return;
86947
86948 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86949 - atomic_inc(&flow_cache_genid);
86950 + atomic_inc_unchecked(&flow_cache_genid);
86951 rt_genid_bump(net);
86952
86953 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
86954 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
86955 index a2e50ae..e152b7c 100644
86956 --- a/net/ipv4/ipconfig.c
86957 +++ b/net/ipv4/ipconfig.c
86958 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
86959
86960 mm_segment_t oldfs = get_fs();
86961 set_fs(get_ds());
86962 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86963 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86964 set_fs(oldfs);
86965 return res;
86966 }
86967 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
86968
86969 mm_segment_t oldfs = get_fs();
86970 set_fs(get_ds());
86971 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86972 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86973 set_fs(oldfs);
86974 return res;
86975 }
86976 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
86977
86978 mm_segment_t oldfs = get_fs();
86979 set_fs(get_ds());
86980 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
86981 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
86982 set_fs(oldfs);
86983 return res;
86984 }
86985 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
86986 index 191fc24..1b3b804 100644
86987 --- a/net/ipv4/ipip.c
86988 +++ b/net/ipv4/ipip.c
86989 @@ -138,7 +138,7 @@ struct ipip_net {
86990 static int ipip_tunnel_init(struct net_device *dev);
86991 static void ipip_tunnel_setup(struct net_device *dev);
86992 static void ipip_dev_free(struct net_device *dev);
86993 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
86994 +static struct rtnl_link_ops ipip_link_ops;
86995
86996 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
86997 struct rtnl_link_stats64 *tot)
86998 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
86999 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87000 };
87001
87002 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87003 +static struct rtnl_link_ops ipip_link_ops = {
87004 .kind = "ipip",
87005 .maxtype = IFLA_IPTUN_MAX,
87006 .policy = ipip_policy,
87007 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87008 index 3ea4127..849297b 100644
87009 --- a/net/ipv4/netfilter/arp_tables.c
87010 +++ b/net/ipv4/netfilter/arp_tables.c
87011 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
87012 #endif
87013
87014 static int get_info(struct net *net, void __user *user,
87015 - const int *len, int compat)
87016 + int len, int compat)
87017 {
87018 char name[XT_TABLE_MAXNAMELEN];
87019 struct xt_table *t;
87020 int ret;
87021
87022 - if (*len != sizeof(struct arpt_getinfo)) {
87023 - duprintf("length %u != %Zu\n", *len,
87024 + if (len != sizeof(struct arpt_getinfo)) {
87025 + duprintf("length %u != %Zu\n", len,
87026 sizeof(struct arpt_getinfo));
87027 return -EINVAL;
87028 }
87029 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
87030 info.size = private->size;
87031 strcpy(info.name, name);
87032
87033 - if (copy_to_user(user, &info, *len) != 0)
87034 + if (copy_to_user(user, &info, len) != 0)
87035 ret = -EFAULT;
87036 else
87037 ret = 0;
87038 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87039
87040 switch (cmd) {
87041 case ARPT_SO_GET_INFO:
87042 - ret = get_info(sock_net(sk), user, len, 1);
87043 + ret = get_info(sock_net(sk), user, *len, 1);
87044 break;
87045 case ARPT_SO_GET_ENTRIES:
87046 ret = compat_get_entries(sock_net(sk), user, len);
87047 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87048
87049 switch (cmd) {
87050 case ARPT_SO_GET_INFO:
87051 - ret = get_info(sock_net(sk), user, len, 0);
87052 + ret = get_info(sock_net(sk), user, *len, 0);
87053 break;
87054
87055 case ARPT_SO_GET_ENTRIES:
87056 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87057 index 17c5e06..1b91206 100644
87058 --- a/net/ipv4/netfilter/ip_tables.c
87059 +++ b/net/ipv4/netfilter/ip_tables.c
87060 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87061 #endif
87062
87063 static int get_info(struct net *net, void __user *user,
87064 - const int *len, int compat)
87065 + int len, int compat)
87066 {
87067 char name[XT_TABLE_MAXNAMELEN];
87068 struct xt_table *t;
87069 int ret;
87070
87071 - if (*len != sizeof(struct ipt_getinfo)) {
87072 - duprintf("length %u != %zu\n", *len,
87073 + if (len != sizeof(struct ipt_getinfo)) {
87074 + duprintf("length %u != %zu\n", len,
87075 sizeof(struct ipt_getinfo));
87076 return -EINVAL;
87077 }
87078 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87079 info.size = private->size;
87080 strcpy(info.name, name);
87081
87082 - if (copy_to_user(user, &info, *len) != 0)
87083 + if (copy_to_user(user, &info, len) != 0)
87084 ret = -EFAULT;
87085 else
87086 ret = 0;
87087 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87088
87089 switch (cmd) {
87090 case IPT_SO_GET_INFO:
87091 - ret = get_info(sock_net(sk), user, len, 1);
87092 + ret = get_info(sock_net(sk), user, *len, 1);
87093 break;
87094 case IPT_SO_GET_ENTRIES:
87095 ret = compat_get_entries(sock_net(sk), user, len);
87096 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87097
87098 switch (cmd) {
87099 case IPT_SO_GET_INFO:
87100 - ret = get_info(sock_net(sk), user, len, 0);
87101 + ret = get_info(sock_net(sk), user, *len, 0);
87102 break;
87103
87104 case IPT_SO_GET_ENTRIES:
87105 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87106 index dc454cc..5bb917f 100644
87107 --- a/net/ipv4/ping.c
87108 +++ b/net/ipv4/ping.c
87109 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87110 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87111 0, sock_i_ino(sp),
87112 atomic_read(&sp->sk_refcnt), sp,
87113 - atomic_read(&sp->sk_drops), len);
87114 + atomic_read_unchecked(&sp->sk_drops), len);
87115 }
87116
87117 static int ping_seq_show(struct seq_file *seq, void *v)
87118 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87119 index 6f08991..55867ad 100644
87120 --- a/net/ipv4/raw.c
87121 +++ b/net/ipv4/raw.c
87122 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87123 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87124 {
87125 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87126 - atomic_inc(&sk->sk_drops);
87127 + atomic_inc_unchecked(&sk->sk_drops);
87128 kfree_skb(skb);
87129 return NET_RX_DROP;
87130 }
87131 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
87132
87133 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87134 {
87135 + struct icmp_filter filter;
87136 +
87137 if (optlen > sizeof(struct icmp_filter))
87138 optlen = sizeof(struct icmp_filter);
87139 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87140 + if (copy_from_user(&filter, optval, optlen))
87141 return -EFAULT;
87142 + raw_sk(sk)->filter = filter;
87143 return 0;
87144 }
87145
87146 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87147 {
87148 int len, ret = -EFAULT;
87149 + struct icmp_filter filter;
87150
87151 if (get_user(len, optlen))
87152 goto out;
87153 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87154 if (len > sizeof(struct icmp_filter))
87155 len = sizeof(struct icmp_filter);
87156 ret = -EFAULT;
87157 - if (put_user(len, optlen) ||
87158 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87159 + filter = raw_sk(sk)->filter;
87160 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87161 goto out;
87162 ret = 0;
87163 out: return ret;
87164 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87165 0, 0L, 0,
87166 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87167 0, sock_i_ino(sp),
87168 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87169 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87170 }
87171
87172 static int raw_seq_show(struct seq_file *seq, void *v)
87173 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87174 index a0fcc47..32e2c89 100644
87175 --- a/net/ipv4/route.c
87176 +++ b/net/ipv4/route.c
87177 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87178 .maxlen = sizeof(int),
87179 .mode = 0200,
87180 .proc_handler = ipv4_sysctl_rtcache_flush,
87181 + .extra1 = &init_net,
87182 },
87183 { },
87184 };
87185
87186 static __net_init int sysctl_route_net_init(struct net *net)
87187 {
87188 - struct ctl_table *tbl;
87189 + ctl_table_no_const *tbl = NULL;
87190
87191 - tbl = ipv4_route_flush_table;
87192 if (!net_eq(net, &init_net)) {
87193 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87194 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87195 if (tbl == NULL)
87196 goto err_dup;
87197
87198 /* Don't export sysctls to unprivileged users */
87199 if (net->user_ns != &init_user_ns)
87200 tbl[0].procname = NULL;
87201 - }
87202 - tbl[0].extra1 = net;
87203 + tbl[0].extra1 = net;
87204 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87205 + } else
87206 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87207
87208 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87209 if (net->ipv4.route_hdr == NULL)
87210 goto err_reg;
87211 return 0;
87212
87213 err_reg:
87214 - if (tbl != ipv4_route_flush_table)
87215 - kfree(tbl);
87216 + kfree(tbl);
87217 err_dup:
87218 return -ENOMEM;
87219 }
87220 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87221
87222 static __net_init int rt_genid_init(struct net *net)
87223 {
87224 - atomic_set(&net->rt_genid, 0);
87225 + atomic_set_unchecked(&net->rt_genid, 0);
87226 get_random_bytes(&net->ipv4.dev_addr_genid,
87227 sizeof(net->ipv4.dev_addr_genid));
87228 return 0;
87229 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87230 index d84400b..62e066e 100644
87231 --- a/net/ipv4/sysctl_net_ipv4.c
87232 +++ b/net/ipv4/sysctl_net_ipv4.c
87233 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87234 {
87235 int ret;
87236 int range[2];
87237 - ctl_table tmp = {
87238 + ctl_table_no_const tmp = {
87239 .data = &range,
87240 .maxlen = sizeof(range),
87241 .mode = table->mode,
87242 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87243 int ret;
87244 gid_t urange[2];
87245 kgid_t low, high;
87246 - ctl_table tmp = {
87247 + ctl_table_no_const tmp = {
87248 .data = &urange,
87249 .maxlen = sizeof(urange),
87250 .mode = table->mode,
87251 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87252 void __user *buffer, size_t *lenp, loff_t *ppos)
87253 {
87254 char val[TCP_CA_NAME_MAX];
87255 - ctl_table tbl = {
87256 + ctl_table_no_const tbl = {
87257 .data = val,
87258 .maxlen = TCP_CA_NAME_MAX,
87259 };
87260 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87261 void __user *buffer, size_t *lenp,
87262 loff_t *ppos)
87263 {
87264 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87265 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87266 int ret;
87267
87268 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87269 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87270 void __user *buffer, size_t *lenp,
87271 loff_t *ppos)
87272 {
87273 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87274 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87275 int ret;
87276
87277 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87278 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87279 struct mem_cgroup *memcg;
87280 #endif
87281
87282 - ctl_table tmp = {
87283 + ctl_table_no_const tmp = {
87284 .data = &vec,
87285 .maxlen = sizeof(vec),
87286 .mode = ctl->mode,
87287 };
87288
87289 if (!write) {
87290 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87291 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87292 + ctl_table_no_const tcp_mem = *ctl;
87293 +
87294 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87295 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87296 }
87297
87298 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87299 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87300 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87301 size_t *lenp, loff_t *ppos)
87302 {
87303 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87304 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87305 struct tcp_fastopen_context *ctxt;
87306 int ret;
87307 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87308 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
87309 },
87310 {
87311 .procname = "ip_local_reserved_ports",
87312 - .data = NULL, /* initialized in sysctl_ipv4_init */
87313 + .data = sysctl_local_reserved_ports,
87314 .maxlen = 65536,
87315 .mode = 0644,
87316 .proc_handler = proc_do_large_bitmap,
87317 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
87318
87319 static __net_init int ipv4_sysctl_init_net(struct net *net)
87320 {
87321 - struct ctl_table *table;
87322 + ctl_table_no_const *table = NULL;
87323
87324 - table = ipv4_net_table;
87325 if (!net_eq(net, &init_net)) {
87326 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87327 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87328 if (table == NULL)
87329 goto err_alloc;
87330
87331 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87332
87333 tcp_init_mem(net);
87334
87335 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87336 + if (!net_eq(net, &init_net))
87337 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87338 + else
87339 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87340 if (net->ipv4.ipv4_hdr == NULL)
87341 goto err_reg;
87342
87343 return 0;
87344
87345 err_reg:
87346 - if (!net_eq(net, &init_net))
87347 - kfree(table);
87348 + kfree(table);
87349 err_alloc:
87350 return -ENOMEM;
87351 }
87352 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87353 static __init int sysctl_ipv4_init(void)
87354 {
87355 struct ctl_table_header *hdr;
87356 - struct ctl_table *i;
87357 -
87358 - for (i = ipv4_table; i->procname; i++) {
87359 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87360 - i->data = sysctl_local_reserved_ports;
87361 - break;
87362 - }
87363 - }
87364 - if (!i->procname)
87365 - return -EINVAL;
87366
87367 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87368 if (hdr == NULL)
87369 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87370 index 9841a71..ef60409 100644
87371 --- a/net/ipv4/tcp_input.c
87372 +++ b/net/ipv4/tcp_input.c
87373 @@ -4730,7 +4730,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87374 * simplifies code)
87375 */
87376 static void
87377 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87378 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87379 struct sk_buff *head, struct sk_buff *tail,
87380 u32 start, u32 end)
87381 {
87382 @@ -5847,6 +5847,7 @@ discard:
87383 tcp_paws_reject(&tp->rx_opt, 0))
87384 goto discard_and_undo;
87385
87386 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87387 if (th->syn) {
87388 /* We see SYN without ACK. It is attempt of
87389 * simultaneous connect with crossed SYNs.
87390 @@ -5897,6 +5898,7 @@ discard:
87391 goto discard;
87392 #endif
87393 }
87394 +#endif
87395 /* "fifth, if neither of the SYN or RST bits is set then
87396 * drop the segment and return."
87397 */
87398 @@ -5941,7 +5943,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87399 goto discard;
87400
87401 if (th->syn) {
87402 - if (th->fin)
87403 + if (th->fin || th->urg || th->psh)
87404 goto discard;
87405 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87406 return 1;
87407 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87408 index d9130a9..00328ff 100644
87409 --- a/net/ipv4/tcp_ipv4.c
87410 +++ b/net/ipv4/tcp_ipv4.c
87411 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87412 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87413
87414
87415 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87416 +extern int grsec_enable_blackhole;
87417 +#endif
87418 +
87419 #ifdef CONFIG_TCP_MD5SIG
87420 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87421 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87422 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87423 return 0;
87424
87425 reset:
87426 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87427 + if (!grsec_enable_blackhole)
87428 +#endif
87429 tcp_v4_send_reset(rsk, skb);
87430 discard:
87431 kfree_skb(skb);
87432 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87433 TCP_SKB_CB(skb)->sacked = 0;
87434
87435 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87436 - if (!sk)
87437 + if (!sk) {
87438 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87439 + ret = 1;
87440 +#endif
87441 goto no_tcp_socket;
87442 -
87443 + }
87444 process:
87445 - if (sk->sk_state == TCP_TIME_WAIT)
87446 + if (sk->sk_state == TCP_TIME_WAIT) {
87447 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87448 + ret = 2;
87449 +#endif
87450 goto do_time_wait;
87451 + }
87452
87453 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87454 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87455 @@ -2050,6 +2064,10 @@ no_tcp_socket:
87456 bad_packet:
87457 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87458 } else {
87459 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87460 + if (!grsec_enable_blackhole || (ret == 1 &&
87461 + (skb->dev->flags & IFF_LOOPBACK)))
87462 +#endif
87463 tcp_v4_send_reset(NULL, skb);
87464 }
87465
87466 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87467 index f35f2df..ccb5ca6 100644
87468 --- a/net/ipv4/tcp_minisocks.c
87469 +++ b/net/ipv4/tcp_minisocks.c
87470 @@ -27,6 +27,10 @@
87471 #include <net/inet_common.h>
87472 #include <net/xfrm.h>
87473
87474 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87475 +extern int grsec_enable_blackhole;
87476 +#endif
87477 +
87478 int sysctl_tcp_syncookies __read_mostly = 1;
87479 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87480
87481 @@ -742,7 +746,10 @@ embryonic_reset:
87482 * avoid becoming vulnerable to outside attack aiming at
87483 * resetting legit local connections.
87484 */
87485 - req->rsk_ops->send_reset(sk, skb);
87486 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87487 + if (!grsec_enable_blackhole)
87488 +#endif
87489 + req->rsk_ops->send_reset(sk, skb);
87490 } else if (fastopen) { /* received a valid RST pkt */
87491 reqsk_fastopen_remove(sk, req, true);
87492 tcp_reset(sk);
87493 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87494 index 4526fe6..1a34e43 100644
87495 --- a/net/ipv4/tcp_probe.c
87496 +++ b/net/ipv4/tcp_probe.c
87497 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87498 if (cnt + width >= len)
87499 break;
87500
87501 - if (copy_to_user(buf + cnt, tbuf, width))
87502 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87503 return -EFAULT;
87504 cnt += width;
87505 }
87506 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87507 index b78aac3..e18230b 100644
87508 --- a/net/ipv4/tcp_timer.c
87509 +++ b/net/ipv4/tcp_timer.c
87510 @@ -22,6 +22,10 @@
87511 #include <linux/gfp.h>
87512 #include <net/tcp.h>
87513
87514 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87515 +extern int grsec_lastack_retries;
87516 +#endif
87517 +
87518 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87519 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87520 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87521 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87522 }
87523 }
87524
87525 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87526 + if ((sk->sk_state == TCP_LAST_ACK) &&
87527 + (grsec_lastack_retries > 0) &&
87528 + (grsec_lastack_retries < retry_until))
87529 + retry_until = grsec_lastack_retries;
87530 +#endif
87531 +
87532 if (retransmits_timed_out(sk, retry_until,
87533 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87534 /* Has it gone just too far? */
87535 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87536 index 1f4d405..3524677 100644
87537 --- a/net/ipv4/udp.c
87538 +++ b/net/ipv4/udp.c
87539 @@ -87,6 +87,7 @@
87540 #include <linux/types.h>
87541 #include <linux/fcntl.h>
87542 #include <linux/module.h>
87543 +#include <linux/security.h>
87544 #include <linux/socket.h>
87545 #include <linux/sockios.h>
87546 #include <linux/igmp.h>
87547 @@ -111,6 +112,10 @@
87548 #include <trace/events/skb.h>
87549 #include "udp_impl.h"
87550
87551 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87552 +extern int grsec_enable_blackhole;
87553 +#endif
87554 +
87555 struct udp_table udp_table __read_mostly;
87556 EXPORT_SYMBOL(udp_table);
87557
87558 @@ -569,6 +574,9 @@ found:
87559 return s;
87560 }
87561
87562 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87563 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87564 +
87565 /*
87566 * This routine is called by the ICMP module when it gets some
87567 * sort of error condition. If err < 0 then the socket should
87568 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87569 dport = usin->sin_port;
87570 if (dport == 0)
87571 return -EINVAL;
87572 +
87573 + err = gr_search_udp_sendmsg(sk, usin);
87574 + if (err)
87575 + return err;
87576 } else {
87577 if (sk->sk_state != TCP_ESTABLISHED)
87578 return -EDESTADDRREQ;
87579 +
87580 + err = gr_search_udp_sendmsg(sk, NULL);
87581 + if (err)
87582 + return err;
87583 +
87584 daddr = inet->inet_daddr;
87585 dport = inet->inet_dport;
87586 /* Open fast path for connected socket.
87587 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
87588 udp_lib_checksum_complete(skb)) {
87589 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87590 IS_UDPLITE(sk));
87591 - atomic_inc(&sk->sk_drops);
87592 + atomic_inc_unchecked(&sk->sk_drops);
87593 __skb_unlink(skb, rcvq);
87594 __skb_queue_tail(&list_kill, skb);
87595 }
87596 @@ -1194,6 +1211,10 @@ try_again:
87597 if (!skb)
87598 goto out;
87599
87600 + err = gr_search_udp_recvmsg(sk, skb);
87601 + if (err)
87602 + goto out_free;
87603 +
87604 ulen = skb->len - sizeof(struct udphdr);
87605 copied = len;
87606 if (copied > ulen)
87607 @@ -1227,7 +1248,7 @@ try_again:
87608 if (unlikely(err)) {
87609 trace_kfree_skb(skb, udp_recvmsg);
87610 if (!peeked) {
87611 - atomic_inc(&sk->sk_drops);
87612 + atomic_inc_unchecked(&sk->sk_drops);
87613 UDP_INC_STATS_USER(sock_net(sk),
87614 UDP_MIB_INERRORS, is_udplite);
87615 }
87616 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87617
87618 drop:
87619 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87620 - atomic_inc(&sk->sk_drops);
87621 + atomic_inc_unchecked(&sk->sk_drops);
87622 kfree_skb(skb);
87623 return -1;
87624 }
87625 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87626 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87627
87628 if (!skb1) {
87629 - atomic_inc(&sk->sk_drops);
87630 + atomic_inc_unchecked(&sk->sk_drops);
87631 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87632 IS_UDPLITE(sk));
87633 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87634 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87635 goto csum_error;
87636
87637 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87638 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87639 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87640 +#endif
87641 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87642
87643 /*
87644 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87645 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87646 0, sock_i_ino(sp),
87647 atomic_read(&sp->sk_refcnt), sp,
87648 - atomic_read(&sp->sk_drops), len);
87649 + atomic_read_unchecked(&sp->sk_drops), len);
87650 }
87651
87652 int udp4_seq_show(struct seq_file *seq, void *v)
87653 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87654 index a36d17e..96d099f 100644
87655 --- a/net/ipv6/addrconf.c
87656 +++ b/net/ipv6/addrconf.c
87657 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87658 p.iph.ihl = 5;
87659 p.iph.protocol = IPPROTO_IPV6;
87660 p.iph.ttl = 64;
87661 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87662 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87663
87664 if (ops->ndo_do_ioctl) {
87665 mm_segment_t oldfs = get_fs();
87666 @@ -4388,7 +4388,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87667 int *valp = ctl->data;
87668 int val = *valp;
87669 loff_t pos = *ppos;
87670 - ctl_table lctl;
87671 + ctl_table_no_const lctl;
87672 int ret;
87673
87674 /*
87675 @@ -4470,7 +4470,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87676 int *valp = ctl->data;
87677 int val = *valp;
87678 loff_t pos = *ppos;
87679 - ctl_table lctl;
87680 + ctl_table_no_const lctl;
87681 int ret;
87682
87683 /*
87684 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87685 index fff5bdd..15194fb 100644
87686 --- a/net/ipv6/icmp.c
87687 +++ b/net/ipv6/icmp.c
87688 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87689
87690 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87691 {
87692 - struct ctl_table *table;
87693 + ctl_table_no_const *table;
87694
87695 table = kmemdup(ipv6_icmp_table_template,
87696 sizeof(ipv6_icmp_table_template),
87697 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87698 index 131dd09..f7ed64f 100644
87699 --- a/net/ipv6/ip6_gre.c
87700 +++ b/net/ipv6/ip6_gre.c
87701 @@ -73,7 +73,7 @@ struct ip6gre_net {
87702 struct net_device *fb_tunnel_dev;
87703 };
87704
87705 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87706 +static struct rtnl_link_ops ip6gre_link_ops;
87707 static int ip6gre_tunnel_init(struct net_device *dev);
87708 static void ip6gre_tunnel_setup(struct net_device *dev);
87709 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87710 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87711 }
87712
87713
87714 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87715 +static struct inet6_protocol ip6gre_protocol = {
87716 .handler = ip6gre_rcv,
87717 .err_handler = ip6gre_err,
87718 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87719 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87720 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87721 };
87722
87723 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87724 +static struct rtnl_link_ops ip6gre_link_ops = {
87725 .kind = "ip6gre",
87726 .maxtype = IFLA_GRE_MAX,
87727 .policy = ip6gre_policy,
87728 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87729 .fill_info = ip6gre_fill_info,
87730 };
87731
87732 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87733 +static struct rtnl_link_ops ip6gre_tap_ops = {
87734 .kind = "ip6gretap",
87735 .maxtype = IFLA_GRE_MAX,
87736 .policy = ip6gre_policy,
87737 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87738 index a14f28b..b4b8956 100644
87739 --- a/net/ipv6/ip6_tunnel.c
87740 +++ b/net/ipv6/ip6_tunnel.c
87741 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87742
87743 static int ip6_tnl_dev_init(struct net_device *dev);
87744 static void ip6_tnl_dev_setup(struct net_device *dev);
87745 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87746 +static struct rtnl_link_ops ip6_link_ops;
87747
87748 static int ip6_tnl_net_id __read_mostly;
87749 struct ip6_tnl_net {
87750 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87751 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87752 };
87753
87754 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87755 +static struct rtnl_link_ops ip6_link_ops = {
87756 .kind = "ip6tnl",
87757 .maxtype = IFLA_IPTUN_MAX,
87758 .policy = ip6_tnl_policy,
87759 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87760 index d1e2e8e..51c19ae 100644
87761 --- a/net/ipv6/ipv6_sockglue.c
87762 +++ b/net/ipv6/ipv6_sockglue.c
87763 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87764 if (sk->sk_type != SOCK_STREAM)
87765 return -ENOPROTOOPT;
87766
87767 - msg.msg_control = optval;
87768 + msg.msg_control = (void __force_kernel *)optval;
87769 msg.msg_controllen = len;
87770 msg.msg_flags = flags;
87771
87772 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87773 index 125a90d..2a11f36 100644
87774 --- a/net/ipv6/netfilter/ip6_tables.c
87775 +++ b/net/ipv6/netfilter/ip6_tables.c
87776 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87777 #endif
87778
87779 static int get_info(struct net *net, void __user *user,
87780 - const int *len, int compat)
87781 + int len, int compat)
87782 {
87783 char name[XT_TABLE_MAXNAMELEN];
87784 struct xt_table *t;
87785 int ret;
87786
87787 - if (*len != sizeof(struct ip6t_getinfo)) {
87788 - duprintf("length %u != %zu\n", *len,
87789 + if (len != sizeof(struct ip6t_getinfo)) {
87790 + duprintf("length %u != %zu\n", len,
87791 sizeof(struct ip6t_getinfo));
87792 return -EINVAL;
87793 }
87794 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87795 info.size = private->size;
87796 strcpy(info.name, name);
87797
87798 - if (copy_to_user(user, &info, *len) != 0)
87799 + if (copy_to_user(user, &info, len) != 0)
87800 ret = -EFAULT;
87801 else
87802 ret = 0;
87803 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87804
87805 switch (cmd) {
87806 case IP6T_SO_GET_INFO:
87807 - ret = get_info(sock_net(sk), user, len, 1);
87808 + ret = get_info(sock_net(sk), user, *len, 1);
87809 break;
87810 case IP6T_SO_GET_ENTRIES:
87811 ret = compat_get_entries(sock_net(sk), user, len);
87812 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87813
87814 switch (cmd) {
87815 case IP6T_SO_GET_INFO:
87816 - ret = get_info(sock_net(sk), user, len, 0);
87817 + ret = get_info(sock_net(sk), user, *len, 0);
87818 break;
87819
87820 case IP6T_SO_GET_ENTRIES:
87821 diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c
87822 index 83acc14..0ea43c7 100644
87823 --- a/net/ipv6/netfilter/ip6t_NPT.c
87824 +++ b/net/ipv6/netfilter/ip6t_NPT.c
87825 @@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
87826 if (pfx_len - i >= 32)
87827 mask = 0;
87828 else
87829 - mask = htonl(~((1 << (pfx_len - i)) - 1));
87830 + mask = htonl((1 << (i - pfx_len + 32)) - 1);
87831
87832 idx = i / 32;
87833 addr->s6_addr32[idx] &= mask;
87834 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
87835 index 2f3a018..8bca195 100644
87836 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
87837 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
87838 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
87839
87840 static int nf_ct_frag6_sysctl_register(struct net *net)
87841 {
87842 - struct ctl_table *table;
87843 + ctl_table_no_const *table = NULL;
87844 struct ctl_table_header *hdr;
87845
87846 - table = nf_ct_frag6_sysctl_table;
87847 if (!net_eq(net, &init_net)) {
87848 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
87849 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
87850 GFP_KERNEL);
87851 if (table == NULL)
87852 goto err_alloc;
87853 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87854 table[0].data = &net->ipv6.frags.high_thresh;
87855 table[1].data = &net->ipv6.frags.low_thresh;
87856 table[2].data = &net->ipv6.frags.timeout;
87857 - }
87858 -
87859 - hdr = register_net_sysctl(net, "net/netfilter", table);
87860 + hdr = register_net_sysctl(net, "net/netfilter", table);
87861 + } else
87862 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
87863 if (hdr == NULL)
87864 goto err_reg;
87865
87866 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87867 return 0;
87868
87869 err_reg:
87870 - if (!net_eq(net, &init_net))
87871 - kfree(table);
87872 + kfree(table);
87873 err_alloc:
87874 return -ENOMEM;
87875 }
87876 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
87877 index 70fa814..d70c28c 100644
87878 --- a/net/ipv6/raw.c
87879 +++ b/net/ipv6/raw.c
87880 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
87881 {
87882 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
87883 skb_checksum_complete(skb)) {
87884 - atomic_inc(&sk->sk_drops);
87885 + atomic_inc_unchecked(&sk->sk_drops);
87886 kfree_skb(skb);
87887 return NET_RX_DROP;
87888 }
87889 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87890 struct raw6_sock *rp = raw6_sk(sk);
87891
87892 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
87893 - atomic_inc(&sk->sk_drops);
87894 + atomic_inc_unchecked(&sk->sk_drops);
87895 kfree_skb(skb);
87896 return NET_RX_DROP;
87897 }
87898 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87899
87900 if (inet->hdrincl) {
87901 if (skb_checksum_complete(skb)) {
87902 - atomic_inc(&sk->sk_drops);
87903 + atomic_inc_unchecked(&sk->sk_drops);
87904 kfree_skb(skb);
87905 return NET_RX_DROP;
87906 }
87907 @@ -604,7 +604,7 @@ out:
87908 return err;
87909 }
87910
87911 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
87912 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
87913 struct flowi6 *fl6, struct dst_entry **dstp,
87914 unsigned int flags)
87915 {
87916 @@ -916,12 +916,15 @@ do_confirm:
87917 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
87918 char __user *optval, int optlen)
87919 {
87920 + struct icmp6_filter filter;
87921 +
87922 switch (optname) {
87923 case ICMPV6_FILTER:
87924 if (optlen > sizeof(struct icmp6_filter))
87925 optlen = sizeof(struct icmp6_filter);
87926 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
87927 + if (copy_from_user(&filter, optval, optlen))
87928 return -EFAULT;
87929 + raw6_sk(sk)->filter = filter;
87930 return 0;
87931 default:
87932 return -ENOPROTOOPT;
87933 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87934 char __user *optval, int __user *optlen)
87935 {
87936 int len;
87937 + struct icmp6_filter filter;
87938
87939 switch (optname) {
87940 case ICMPV6_FILTER:
87941 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87942 len = sizeof(struct icmp6_filter);
87943 if (put_user(len, optlen))
87944 return -EFAULT;
87945 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
87946 + filter = raw6_sk(sk)->filter;
87947 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
87948 return -EFAULT;
87949 return 0;
87950 default:
87951 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87952 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87953 0,
87954 sock_i_ino(sp),
87955 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87956 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87957 }
87958
87959 static int raw6_seq_show(struct seq_file *seq, void *v)
87960 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
87961 index d9ba8a2..f3f9e14 100644
87962 --- a/net/ipv6/reassembly.c
87963 +++ b/net/ipv6/reassembly.c
87964 @@ -608,12 +608,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
87965
87966 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87967 {
87968 - struct ctl_table *table;
87969 + ctl_table_no_const *table = NULL;
87970 struct ctl_table_header *hdr;
87971
87972 - table = ip6_frags_ns_ctl_table;
87973 if (!net_eq(net, &init_net)) {
87974 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87975 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87976 if (table == NULL)
87977 goto err_alloc;
87978
87979 @@ -624,9 +623,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87980 /* Don't export sysctls to unprivileged users */
87981 if (net->user_ns != &init_user_ns)
87982 table[0].procname = NULL;
87983 - }
87984 + hdr = register_net_sysctl(net, "net/ipv6", table);
87985 + } else
87986 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
87987
87988 - hdr = register_net_sysctl(net, "net/ipv6", table);
87989 if (hdr == NULL)
87990 goto err_reg;
87991
87992 @@ -634,8 +634,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87993 return 0;
87994
87995 err_reg:
87996 - if (!net_eq(net, &init_net))
87997 - kfree(table);
87998 + kfree(table);
87999 err_alloc:
88000 return -ENOMEM;
88001 }
88002 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88003 index 5845613..3af8fc7 100644
88004 --- a/net/ipv6/route.c
88005 +++ b/net/ipv6/route.c
88006 @@ -2966,7 +2966,7 @@ ctl_table ipv6_route_table_template[] = {
88007
88008 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88009 {
88010 - struct ctl_table *table;
88011 + ctl_table_no_const *table;
88012
88013 table = kmemdup(ipv6_route_table_template,
88014 sizeof(ipv6_route_table_template),
88015 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88016 index cfba99b..20ca511 100644
88017 --- a/net/ipv6/sit.c
88018 +++ b/net/ipv6/sit.c
88019 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
88020 static int ipip6_tunnel_init(struct net_device *dev);
88021 static void ipip6_tunnel_setup(struct net_device *dev);
88022 static void ipip6_dev_free(struct net_device *dev);
88023 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88024 +static struct rtnl_link_ops sit_link_ops;
88025
88026 static int sit_net_id __read_mostly;
88027 struct sit_net {
88028 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88029 #endif
88030 };
88031
88032 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88033 +static struct rtnl_link_ops sit_link_ops = {
88034 .kind = "sit",
88035 .maxtype = IFLA_IPTUN_MAX,
88036 .policy = ipip6_policy,
88037 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88038 index e85c48b..b8268d3 100644
88039 --- a/net/ipv6/sysctl_net_ipv6.c
88040 +++ b/net/ipv6/sysctl_net_ipv6.c
88041 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88042
88043 static int __net_init ipv6_sysctl_net_init(struct net *net)
88044 {
88045 - struct ctl_table *ipv6_table;
88046 + ctl_table_no_const *ipv6_table;
88047 struct ctl_table *ipv6_route_table;
88048 struct ctl_table *ipv6_icmp_table;
88049 int err;
88050 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88051 index 8d19346..f122ba5 100644
88052 --- a/net/ipv6/tcp_ipv6.c
88053 +++ b/net/ipv6/tcp_ipv6.c
88054 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88055 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88056 }
88057
88058 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88059 +extern int grsec_enable_blackhole;
88060 +#endif
88061 +
88062 static void tcp_v6_hash(struct sock *sk)
88063 {
88064 if (sk->sk_state != TCP_CLOSE) {
88065 @@ -386,6 +390,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
88066
88067 if (dst)
88068 dst->ops->redirect(dst, sk, skb);
88069 + goto out;
88070 }
88071
88072 if (type == ICMPV6_PKT_TOOBIG) {
88073 @@ -1440,6 +1445,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88074 return 0;
88075
88076 reset:
88077 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88078 + if (!grsec_enable_blackhole)
88079 +#endif
88080 tcp_v6_send_reset(sk, skb);
88081 discard:
88082 if (opt_skb)
88083 @@ -1521,12 +1529,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88084 TCP_SKB_CB(skb)->sacked = 0;
88085
88086 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88087 - if (!sk)
88088 + if (!sk) {
88089 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88090 + ret = 1;
88091 +#endif
88092 goto no_tcp_socket;
88093 + }
88094
88095 process:
88096 - if (sk->sk_state == TCP_TIME_WAIT)
88097 + if (sk->sk_state == TCP_TIME_WAIT) {
88098 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88099 + ret = 2;
88100 +#endif
88101 goto do_time_wait;
88102 + }
88103
88104 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88105 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88106 @@ -1575,6 +1591,10 @@ no_tcp_socket:
88107 bad_packet:
88108 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88109 } else {
88110 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88111 + if (!grsec_enable_blackhole || (ret == 1 &&
88112 + (skb->dev->flags & IFF_LOOPBACK)))
88113 +#endif
88114 tcp_v6_send_reset(NULL, skb);
88115 }
88116
88117 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88118 index fb08329..2d6919e 100644
88119 --- a/net/ipv6/udp.c
88120 +++ b/net/ipv6/udp.c
88121 @@ -51,6 +51,10 @@
88122 #include <trace/events/skb.h>
88123 #include "udp_impl.h"
88124
88125 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88126 +extern int grsec_enable_blackhole;
88127 +#endif
88128 +
88129 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88130 {
88131 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88132 @@ -395,7 +399,7 @@ try_again:
88133 if (unlikely(err)) {
88134 trace_kfree_skb(skb, udpv6_recvmsg);
88135 if (!peeked) {
88136 - atomic_inc(&sk->sk_drops);
88137 + atomic_inc_unchecked(&sk->sk_drops);
88138 if (is_udp4)
88139 UDP_INC_STATS_USER(sock_net(sk),
88140 UDP_MIB_INERRORS,
88141 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88142 return rc;
88143 drop:
88144 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88145 - atomic_inc(&sk->sk_drops);
88146 + atomic_inc_unchecked(&sk->sk_drops);
88147 kfree_skb(skb);
88148 return -1;
88149 }
88150 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88151 if (likely(skb1 == NULL))
88152 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88153 if (!skb1) {
88154 - atomic_inc(&sk->sk_drops);
88155 + atomic_inc_unchecked(&sk->sk_drops);
88156 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88157 IS_UDPLITE(sk));
88158 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88159 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88160 goto discard;
88161
88162 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88163 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88164 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88165 +#endif
88166 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88167
88168 kfree_skb(skb);
88169 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88170 0,
88171 sock_i_ino(sp),
88172 atomic_read(&sp->sk_refcnt), sp,
88173 - atomic_read(&sp->sk_drops));
88174 + atomic_read_unchecked(&sp->sk_drops));
88175 }
88176
88177 int udp6_seq_show(struct seq_file *seq, void *v)
88178 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88179 index a68c88c..d55b0c5 100644
88180 --- a/net/irda/ircomm/ircomm_tty.c
88181 +++ b/net/irda/ircomm/ircomm_tty.c
88182 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88183 add_wait_queue(&port->open_wait, &wait);
88184
88185 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88186 - __FILE__, __LINE__, tty->driver->name, port->count);
88187 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88188
88189 spin_lock_irqsave(&port->lock, flags);
88190 if (!tty_hung_up_p(filp)) {
88191 extra_count = 1;
88192 - port->count--;
88193 + atomic_dec(&port->count);
88194 }
88195 spin_unlock_irqrestore(&port->lock, flags);
88196 port->blocked_open++;
88197 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88198 }
88199
88200 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88201 - __FILE__, __LINE__, tty->driver->name, port->count);
88202 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88203
88204 schedule();
88205 }
88206 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88207 if (extra_count) {
88208 /* ++ is not atomic, so this should be protected - Jean II */
88209 spin_lock_irqsave(&port->lock, flags);
88210 - port->count++;
88211 + atomic_inc(&port->count);
88212 spin_unlock_irqrestore(&port->lock, flags);
88213 }
88214 port->blocked_open--;
88215
88216 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88217 - __FILE__, __LINE__, tty->driver->name, port->count);
88218 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88219
88220 if (!retval)
88221 port->flags |= ASYNC_NORMAL_ACTIVE;
88222 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88223
88224 /* ++ is not atomic, so this should be protected - Jean II */
88225 spin_lock_irqsave(&self->port.lock, flags);
88226 - self->port.count++;
88227 + atomic_inc(&self->port.count);
88228 spin_unlock_irqrestore(&self->port.lock, flags);
88229 tty_port_tty_set(&self->port, tty);
88230
88231 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88232 - self->line, self->port.count);
88233 + self->line, atomic_read(&self->port.count));
88234
88235 /* Not really used by us, but lets do it anyway */
88236 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88237 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88238 tty_kref_put(port->tty);
88239 }
88240 port->tty = NULL;
88241 - port->count = 0;
88242 + atomic_set(&port->count, 0);
88243 spin_unlock_irqrestore(&port->lock, flags);
88244
88245 wake_up_interruptible(&port->open_wait);
88246 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88247 seq_putc(m, '\n');
88248
88249 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88250 - seq_printf(m, "Open count: %d\n", self->port.count);
88251 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88252 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88253 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88254
88255 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
88256 index e71e85b..29340a9 100644
88257 --- a/net/irda/iriap.c
88258 +++ b/net/irda/iriap.c
88259 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
88260 /* case CS_ISO_8859_9: */
88261 /* case CS_UNICODE: */
88262 default:
88263 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
88264 - __func__, ias_charset_types[charset]);
88265 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
88266 + __func__, charset,
88267 + charset < ARRAY_SIZE(ias_charset_types) ?
88268 + ias_charset_types[charset] :
88269 + "(unknown)");
88270
88271 /* Aborting, close connection! */
88272 iriap_disconnect_request(self);
88273 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88274 index cd6f7a9..e63fe89 100644
88275 --- a/net/iucv/af_iucv.c
88276 +++ b/net/iucv/af_iucv.c
88277 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
88278
88279 write_lock_bh(&iucv_sk_list.lock);
88280
88281 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88282 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88283 while (__iucv_get_sock_by_name(name)) {
88284 sprintf(name, "%08x",
88285 - atomic_inc_return(&iucv_sk_list.autobind_name));
88286 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88287 }
88288
88289 write_unlock_bh(&iucv_sk_list.lock);
88290 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88291 index df08250..02021fe 100644
88292 --- a/net/iucv/iucv.c
88293 +++ b/net/iucv/iucv.c
88294 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88295 return NOTIFY_OK;
88296 }
88297
88298 -static struct notifier_block __refdata iucv_cpu_notifier = {
88299 +static struct notifier_block iucv_cpu_notifier = {
88300 .notifier_call = iucv_cpu_notify,
88301 };
88302
88303 diff --git a/net/key/af_key.c b/net/key/af_key.c
88304 index 5b426a6..970032b 100644
88305 --- a/net/key/af_key.c
88306 +++ b/net/key/af_key.c
88307 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88308 static u32 get_acqseq(void)
88309 {
88310 u32 res;
88311 - static atomic_t acqseq;
88312 + static atomic_unchecked_t acqseq;
88313
88314 do {
88315 - res = atomic_inc_return(&acqseq);
88316 + res = atomic_inc_return_unchecked(&acqseq);
88317 } while (!res);
88318 return res;
88319 }
88320 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88321 index 49c48c6..9e72ff4 100644
88322 --- a/net/mac80211/cfg.c
88323 +++ b/net/mac80211/cfg.c
88324 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88325 ret = ieee80211_vif_use_channel(sdata, chandef,
88326 IEEE80211_CHANCTX_EXCLUSIVE);
88327 }
88328 - } else if (local->open_count == local->monitors) {
88329 + } else if (local_read(&local->open_count) == local->monitors) {
88330 local->_oper_channel = chandef->chan;
88331 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88332 ieee80211_hw_config(local, 0);
88333 @@ -2718,7 +2718,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88334 else
88335 local->probe_req_reg--;
88336
88337 - if (!local->open_count)
88338 + if (!local_read(&local->open_count))
88339 break;
88340
88341 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88342 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88343 index 55d8f89..bec0c2b 100644
88344 --- a/net/mac80211/ieee80211_i.h
88345 +++ b/net/mac80211/ieee80211_i.h
88346 @@ -28,6 +28,7 @@
88347 #include <net/ieee80211_radiotap.h>
88348 #include <net/cfg80211.h>
88349 #include <net/mac80211.h>
88350 +#include <asm/local.h>
88351 #include "key.h"
88352 #include "sta_info.h"
88353 #include "debug.h"
88354 @@ -910,7 +911,7 @@ struct ieee80211_local {
88355 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88356 spinlock_t queue_stop_reason_lock;
88357
88358 - int open_count;
88359 + local_t open_count;
88360 int monitors, cooked_mntrs;
88361 /* number of interfaces with corresponding FIF_ flags */
88362 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88363 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88364 index 8be854e..ad72a69 100644
88365 --- a/net/mac80211/iface.c
88366 +++ b/net/mac80211/iface.c
88367 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88368 break;
88369 }
88370
88371 - if (local->open_count == 0) {
88372 + if (local_read(&local->open_count) == 0) {
88373 res = drv_start(local);
88374 if (res)
88375 goto err_del_bss;
88376 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88377 break;
88378 }
88379
88380 - if (local->monitors == 0 && local->open_count == 0) {
88381 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88382 res = ieee80211_add_virtual_monitor(local);
88383 if (res)
88384 goto err_stop;
88385 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88386 mutex_unlock(&local->mtx);
88387
88388 if (coming_up)
88389 - local->open_count++;
88390 + local_inc(&local->open_count);
88391
88392 if (hw_reconf_flags)
88393 ieee80211_hw_config(local, hw_reconf_flags);
88394 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88395 err_del_interface:
88396 drv_remove_interface(local, sdata);
88397 err_stop:
88398 - if (!local->open_count)
88399 + if (!local_read(&local->open_count))
88400 drv_stop(local);
88401 err_del_bss:
88402 sdata->bss = NULL;
88403 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88404 }
88405
88406 if (going_down)
88407 - local->open_count--;
88408 + local_dec(&local->open_count);
88409
88410 switch (sdata->vif.type) {
88411 case NL80211_IFTYPE_AP_VLAN:
88412 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88413
88414 ieee80211_recalc_ps(local, -1);
88415
88416 - if (local->open_count == 0) {
88417 + if (local_read(&local->open_count) == 0) {
88418 if (local->ops->napi_poll)
88419 napi_disable(&local->napi);
88420 ieee80211_clear_tx_pending(local);
88421 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88422 }
88423 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88424
88425 - if (local->monitors == local->open_count && local->monitors > 0)
88426 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88427 ieee80211_add_virtual_monitor(local);
88428 }
88429
88430 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88431 index 1b087ff..bf600e9 100644
88432 --- a/net/mac80211/main.c
88433 +++ b/net/mac80211/main.c
88434 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88435 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88436 IEEE80211_CONF_CHANGE_POWER);
88437
88438 - if (changed && local->open_count) {
88439 + if (changed && local_read(&local->open_count)) {
88440 ret = drv_config(local, changed);
88441 /*
88442 * Goal:
88443 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88444 index 79a48f3..5e185c9 100644
88445 --- a/net/mac80211/pm.c
88446 +++ b/net/mac80211/pm.c
88447 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88448 struct sta_info *sta;
88449 struct ieee80211_chanctx *ctx;
88450
88451 - if (!local->open_count)
88452 + if (!local_read(&local->open_count))
88453 goto suspend;
88454
88455 ieee80211_scan_cancel(local);
88456 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88457 cancel_work_sync(&local->dynamic_ps_enable_work);
88458 del_timer_sync(&local->dynamic_ps_timer);
88459
88460 - local->wowlan = wowlan && local->open_count;
88461 + local->wowlan = wowlan && local_read(&local->open_count);
88462 if (local->wowlan) {
88463 int err = drv_suspend(local, wowlan);
88464 if (err < 0) {
88465 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88466 mutex_unlock(&local->chanctx_mtx);
88467
88468 /* stop hardware - this must stop RX */
88469 - if (local->open_count)
88470 + if (local_read(&local->open_count))
88471 ieee80211_stop_device(local);
88472
88473 suspend:
88474 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88475 index dd88381..eef4dd6 100644
88476 --- a/net/mac80211/rate.c
88477 +++ b/net/mac80211/rate.c
88478 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88479
88480 ASSERT_RTNL();
88481
88482 - if (local->open_count)
88483 + if (local_read(&local->open_count))
88484 return -EBUSY;
88485
88486 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88487 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88488 index c97a065..ff61928 100644
88489 --- a/net/mac80211/rc80211_pid_debugfs.c
88490 +++ b/net/mac80211/rc80211_pid_debugfs.c
88491 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88492
88493 spin_unlock_irqrestore(&events->lock, status);
88494
88495 - if (copy_to_user(buf, pb, p))
88496 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88497 return -EFAULT;
88498
88499 return p;
88500 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88501 index f11e8c5..08d0013 100644
88502 --- a/net/mac80211/util.c
88503 +++ b/net/mac80211/util.c
88504 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88505 }
88506 #endif
88507 /* everything else happens only if HW was up & running */
88508 - if (!local->open_count)
88509 + if (!local_read(&local->open_count))
88510 goto wake_up;
88511
88512 /*
88513 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88514 index 49e96df..63a51c3 100644
88515 --- a/net/netfilter/Kconfig
88516 +++ b/net/netfilter/Kconfig
88517 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
88518
88519 To compile it as a module, choose M here. If unsure, say N.
88520
88521 +config NETFILTER_XT_MATCH_GRADM
88522 + tristate '"gradm" match support'
88523 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88524 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88525 + ---help---
88526 + The gradm match allows to match on grsecurity RBAC being enabled.
88527 + It is useful when iptables rules are applied early on bootup to
88528 + prevent connections to the machine (except from a trusted host)
88529 + while the RBAC system is disabled.
88530 +
88531 config NETFILTER_XT_MATCH_HASHLIMIT
88532 tristate '"hashlimit" match support'
88533 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88534 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88535 index 3259697..54d5393 100644
88536 --- a/net/netfilter/Makefile
88537 +++ b/net/netfilter/Makefile
88538 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88539 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88540 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88541 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88542 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88543 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88544 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88545 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88546 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88547 index 6d6d8f2..a676749 100644
88548 --- a/net/netfilter/ipset/ip_set_core.c
88549 +++ b/net/netfilter/ipset/ip_set_core.c
88550 @@ -1800,7 +1800,7 @@ done:
88551 return ret;
88552 }
88553
88554 -static struct nf_sockopt_ops so_set __read_mostly = {
88555 +static struct nf_sockopt_ops so_set = {
88556 .pf = PF_INET,
88557 .get_optmin = SO_IP_SET,
88558 .get_optmax = SO_IP_SET + 1,
88559 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88560 index 30e764a..c3b6a9d 100644
88561 --- a/net/netfilter/ipvs/ip_vs_conn.c
88562 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88563 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88564 /* Increase the refcnt counter of the dest */
88565 atomic_inc(&dest->refcnt);
88566
88567 - conn_flags = atomic_read(&dest->conn_flags);
88568 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88569 if (cp->protocol != IPPROTO_UDP)
88570 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88571 flags = cp->flags;
88572 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88573 atomic_set(&cp->refcnt, 1);
88574
88575 atomic_set(&cp->n_control, 0);
88576 - atomic_set(&cp->in_pkts, 0);
88577 + atomic_set_unchecked(&cp->in_pkts, 0);
88578
88579 atomic_inc(&ipvs->conn_count);
88580 if (flags & IP_VS_CONN_F_NO_CPORT)
88581 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88582
88583 /* Don't drop the entry if its number of incoming packets is not
88584 located in [0, 8] */
88585 - i = atomic_read(&cp->in_pkts);
88586 + i = atomic_read_unchecked(&cp->in_pkts);
88587 if (i > 8 || i < 0) return 0;
88588
88589 if (!todrop_rate[i]) return 0;
88590 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88591 index 47edf5a..235b07d 100644
88592 --- a/net/netfilter/ipvs/ip_vs_core.c
88593 +++ b/net/netfilter/ipvs/ip_vs_core.c
88594 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88595 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88596 /* do not touch skb anymore */
88597
88598 - atomic_inc(&cp->in_pkts);
88599 + atomic_inc_unchecked(&cp->in_pkts);
88600 ip_vs_conn_put(cp);
88601 return ret;
88602 }
88603 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88604 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88605 pkts = sysctl_sync_threshold(ipvs);
88606 else
88607 - pkts = atomic_add_return(1, &cp->in_pkts);
88608 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88609
88610 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88611 ip_vs_sync_conn(net, cp, pkts);
88612 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88613 index ec664cb..7f34a77 100644
88614 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88615 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88616 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88617 ip_vs_rs_hash(ipvs, dest);
88618 write_unlock_bh(&ipvs->rs_lock);
88619 }
88620 - atomic_set(&dest->conn_flags, conn_flags);
88621 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88622
88623 /* bind the service */
88624 if (!dest->svc) {
88625 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88626 * align with netns init in ip_vs_control_net_init()
88627 */
88628
88629 -static struct ctl_table vs_vars[] = {
88630 +static ctl_table_no_const vs_vars[] __read_only = {
88631 {
88632 .procname = "amemthresh",
88633 .maxlen = sizeof(int),
88634 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88635 " %-7s %-6d %-10d %-10d\n",
88636 &dest->addr.in6,
88637 ntohs(dest->port),
88638 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88639 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88640 atomic_read(&dest->weight),
88641 atomic_read(&dest->activeconns),
88642 atomic_read(&dest->inactconns));
88643 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88644 "%-7s %-6d %-10d %-10d\n",
88645 ntohl(dest->addr.ip),
88646 ntohs(dest->port),
88647 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88648 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88649 atomic_read(&dest->weight),
88650 atomic_read(&dest->activeconns),
88651 atomic_read(&dest->inactconns));
88652 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88653
88654 entry.addr = dest->addr.ip;
88655 entry.port = dest->port;
88656 - entry.conn_flags = atomic_read(&dest->conn_flags);
88657 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88658 entry.weight = atomic_read(&dest->weight);
88659 entry.u_threshold = dest->u_threshold;
88660 entry.l_threshold = dest->l_threshold;
88661 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88662 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88663 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88664 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88665 - (atomic_read(&dest->conn_flags) &
88666 + (atomic_read_unchecked(&dest->conn_flags) &
88667 IP_VS_CONN_F_FWD_MASK)) ||
88668 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88669 atomic_read(&dest->weight)) ||
88670 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88671 {
88672 int idx;
88673 struct netns_ipvs *ipvs = net_ipvs(net);
88674 - struct ctl_table *tbl;
88675 + ctl_table_no_const *tbl;
88676
88677 atomic_set(&ipvs->dropentry, 0);
88678 spin_lock_init(&ipvs->dropentry_lock);
88679 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88680 index fdd89b9..bd96aa9 100644
88681 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88682 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88683 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
88684 * IPVS LBLC sysctl table
88685 */
88686 #ifdef CONFIG_SYSCTL
88687 -static ctl_table vs_vars_table[] = {
88688 +static ctl_table_no_const vs_vars_table[] __read_only = {
88689 {
88690 .procname = "lblc_expiration",
88691 .data = NULL,
88692 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
88693 index c03b6a3..8ce3681 100644
88694 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
88695 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
88696 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
88697 * IPVS LBLCR sysctl table
88698 */
88699
88700 -static ctl_table vs_vars_table[] = {
88701 +static ctl_table_no_const vs_vars_table[] __read_only = {
88702 {
88703 .procname = "lblcr_expiration",
88704 .data = NULL,
88705 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
88706 index 44fd10c..2a163b3 100644
88707 --- a/net/netfilter/ipvs/ip_vs_sync.c
88708 +++ b/net/netfilter/ipvs/ip_vs_sync.c
88709 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
88710 cp = cp->control;
88711 if (cp) {
88712 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88713 - pkts = atomic_add_return(1, &cp->in_pkts);
88714 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88715 else
88716 pkts = sysctl_sync_threshold(ipvs);
88717 ip_vs_sync_conn(net, cp->control, pkts);
88718 @@ -758,7 +758,7 @@ control:
88719 if (!cp)
88720 return;
88721 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88722 - pkts = atomic_add_return(1, &cp->in_pkts);
88723 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88724 else
88725 pkts = sysctl_sync_threshold(ipvs);
88726 goto sloop;
88727 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
88728
88729 if (opt)
88730 memcpy(&cp->in_seq, opt, sizeof(*opt));
88731 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88732 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88733 cp->state = state;
88734 cp->old_state = cp->state;
88735 /*
88736 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
88737 index ee6b7a9..f9a89f6 100644
88738 --- a/net/netfilter/ipvs/ip_vs_xmit.c
88739 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
88740 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
88741 else
88742 rc = NF_ACCEPT;
88743 /* do not touch skb anymore */
88744 - atomic_inc(&cp->in_pkts);
88745 + atomic_inc_unchecked(&cp->in_pkts);
88746 goto out;
88747 }
88748
88749 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
88750 else
88751 rc = NF_ACCEPT;
88752 /* do not touch skb anymore */
88753 - atomic_inc(&cp->in_pkts);
88754 + atomic_inc_unchecked(&cp->in_pkts);
88755 goto out;
88756 }
88757
88758 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
88759 index 7df424e..a527b02 100644
88760 --- a/net/netfilter/nf_conntrack_acct.c
88761 +++ b/net/netfilter/nf_conntrack_acct.c
88762 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
88763 #ifdef CONFIG_SYSCTL
88764 static int nf_conntrack_acct_init_sysctl(struct net *net)
88765 {
88766 - struct ctl_table *table;
88767 + ctl_table_no_const *table;
88768
88769 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
88770 GFP_KERNEL);
88771 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
88772 index e4a0c4f..c263f28 100644
88773 --- a/net/netfilter/nf_conntrack_core.c
88774 +++ b/net/netfilter/nf_conntrack_core.c
88775 @@ -1529,6 +1529,10 @@ err_extend:
88776 #define DYING_NULLS_VAL ((1<<30)+1)
88777 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
88778
88779 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88780 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
88781 +#endif
88782 +
88783 static int nf_conntrack_init_net(struct net *net)
88784 {
88785 int ret;
88786 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
88787 goto err_stat;
88788 }
88789
88790 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88791 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
88792 +#else
88793 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
88794 +#endif
88795 if (!net->ct.slabname) {
88796 ret = -ENOMEM;
88797 goto err_slabname;
88798 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
88799 index faa978f..1afb18f 100644
88800 --- a/net/netfilter/nf_conntrack_ecache.c
88801 +++ b/net/netfilter/nf_conntrack_ecache.c
88802 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
88803 #ifdef CONFIG_SYSCTL
88804 static int nf_conntrack_event_init_sysctl(struct net *net)
88805 {
88806 - struct ctl_table *table;
88807 + ctl_table_no_const *table;
88808
88809 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
88810 GFP_KERNEL);
88811 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
88812 index 884f2b3..d53b33a 100644
88813 --- a/net/netfilter/nf_conntrack_helper.c
88814 +++ b/net/netfilter/nf_conntrack_helper.c
88815 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
88816
88817 static int nf_conntrack_helper_init_sysctl(struct net *net)
88818 {
88819 - struct ctl_table *table;
88820 + ctl_table_no_const *table;
88821
88822 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
88823 GFP_KERNEL);
88824 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
88825 index 51e928d..72a413a 100644
88826 --- a/net/netfilter/nf_conntrack_proto.c
88827 +++ b/net/netfilter/nf_conntrack_proto.c
88828 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
88829
88830 static void
88831 nf_ct_unregister_sysctl(struct ctl_table_header **header,
88832 - struct ctl_table **table,
88833 + ctl_table_no_const **table,
88834 unsigned int users)
88835 {
88836 if (users > 0)
88837 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
88838 index e7185c6..4ad6c9c 100644
88839 --- a/net/netfilter/nf_conntrack_standalone.c
88840 +++ b/net/netfilter/nf_conntrack_standalone.c
88841 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
88842
88843 static int nf_conntrack_standalone_init_sysctl(struct net *net)
88844 {
88845 - struct ctl_table *table;
88846 + ctl_table_no_const *table;
88847
88848 if (net_eq(net, &init_net)) {
88849 nf_ct_netfilter_header =
88850 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
88851 index 7ea8026..bc9512d 100644
88852 --- a/net/netfilter/nf_conntrack_timestamp.c
88853 +++ b/net/netfilter/nf_conntrack_timestamp.c
88854 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
88855 #ifdef CONFIG_SYSCTL
88856 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
88857 {
88858 - struct ctl_table *table;
88859 + ctl_table_no_const *table;
88860
88861 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
88862 GFP_KERNEL);
88863 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
88864 index 9e31269..bc4c1b7 100644
88865 --- a/net/netfilter/nf_log.c
88866 +++ b/net/netfilter/nf_log.c
88867 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
88868
88869 #ifdef CONFIG_SYSCTL
88870 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
88871 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
88872 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
88873 static struct ctl_table_header *nf_log_dir_header;
88874
88875 static int nf_log_proc_dostring(ctl_table *table, int write,
88876 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
88877 rcu_assign_pointer(nf_loggers[tindex], logger);
88878 mutex_unlock(&nf_log_mutex);
88879 } else {
88880 + ctl_table_no_const nf_log_table = *table;
88881 +
88882 mutex_lock(&nf_log_mutex);
88883 logger = rcu_dereference_protected(nf_loggers[tindex],
88884 lockdep_is_held(&nf_log_mutex));
88885 if (!logger)
88886 - table->data = "NONE";
88887 + nf_log_table.data = "NONE";
88888 else
88889 - table->data = logger->name;
88890 - r = proc_dostring(table, write, buffer, lenp, ppos);
88891 + nf_log_table.data = logger->name;
88892 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
88893 mutex_unlock(&nf_log_mutex);
88894 }
88895
88896 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
88897 index f042ae5..30ea486 100644
88898 --- a/net/netfilter/nf_sockopt.c
88899 +++ b/net/netfilter/nf_sockopt.c
88900 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
88901 }
88902 }
88903
88904 - list_add(&reg->list, &nf_sockopts);
88905 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
88906 out:
88907 mutex_unlock(&nf_sockopt_mutex);
88908 return ret;
88909 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
88910 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
88911 {
88912 mutex_lock(&nf_sockopt_mutex);
88913 - list_del(&reg->list);
88914 + pax_list_del((struct list_head *)&reg->list);
88915 mutex_unlock(&nf_sockopt_mutex);
88916 }
88917 EXPORT_SYMBOL(nf_unregister_sockopt);
88918 diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
88919 index 589d686..dc3fd5d 100644
88920 --- a/net/netfilter/nfnetlink_acct.c
88921 +++ b/net/netfilter/nfnetlink_acct.c
88922 @@ -49,6 +49,8 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,
88923 return -EINVAL;
88924
88925 acct_name = nla_data(tb[NFACCT_NAME]);
88926 + if (strlen(acct_name) == 0)
88927 + return -EINVAL;
88928
88929 list_for_each_entry(nfacct, &nfnl_acct_list, head) {
88930 if (strncmp(nfacct->name, acct_name, NFACCT_NAME_MAX) != 0)
88931 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
88932 index 92fd8ec..3f6ea4b 100644
88933 --- a/net/netfilter/nfnetlink_log.c
88934 +++ b/net/netfilter/nfnetlink_log.c
88935 @@ -72,7 +72,7 @@ struct nfulnl_instance {
88936 };
88937
88938 static DEFINE_SPINLOCK(instances_lock);
88939 -static atomic_t global_seq;
88940 +static atomic_unchecked_t global_seq;
88941
88942 #define INSTANCE_BUCKETS 16
88943 static struct hlist_head instance_table[INSTANCE_BUCKETS];
88944 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
88945 /* global sequence number */
88946 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
88947 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
88948 - htonl(atomic_inc_return(&global_seq))))
88949 + htonl(atomic_inc_return_unchecked(&global_seq))))
88950 goto nla_put_failure;
88951
88952 if (data_len) {
88953 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
88954 index 3158d87..39006c9 100644
88955 --- a/net/netfilter/nfnetlink_queue_core.c
88956 +++ b/net/netfilter/nfnetlink_queue_core.c
88957 @@ -1064,8 +1064,10 @@ static int __init nfnetlink_queue_init(void)
88958
88959 #ifdef CONFIG_PROC_FS
88960 if (!proc_create("nfnetlink_queue", 0440,
88961 - proc_net_netfilter, &nfqnl_file_ops))
88962 + proc_net_netfilter, &nfqnl_file_ops)) {
88963 + status = -ENOMEM;
88964 goto cleanup_subsys;
88965 + }
88966 #endif
88967
88968 register_netdevice_notifier(&nfqnl_dev_notifier);
88969 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
88970 new file mode 100644
88971 index 0000000..c566332
88972 --- /dev/null
88973 +++ b/net/netfilter/xt_gradm.c
88974 @@ -0,0 +1,51 @@
88975 +/*
88976 + * gradm match for netfilter
88977 + * Copyright © Zbigniew Krzystolik, 2010
88978 + *
88979 + * This program is free software; you can redistribute it and/or modify
88980 + * it under the terms of the GNU General Public License; either version
88981 + * 2 or 3 as published by the Free Software Foundation.
88982 + */
88983 +#include <linux/module.h>
88984 +#include <linux/moduleparam.h>
88985 +#include <linux/skbuff.h>
88986 +#include <linux/netfilter/x_tables.h>
88987 +#include <linux/grsecurity.h>
88988 +#include <linux/netfilter/xt_gradm.h>
88989 +
88990 +static bool
88991 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
88992 +{
88993 + const struct xt_gradm_mtinfo *info = par->matchinfo;
88994 + bool retval = false;
88995 + if (gr_acl_is_enabled())
88996 + retval = true;
88997 + return retval ^ info->invflags;
88998 +}
88999 +
89000 +static struct xt_match gradm_mt_reg __read_mostly = {
89001 + .name = "gradm",
89002 + .revision = 0,
89003 + .family = NFPROTO_UNSPEC,
89004 + .match = gradm_mt,
89005 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89006 + .me = THIS_MODULE,
89007 +};
89008 +
89009 +static int __init gradm_mt_init(void)
89010 +{
89011 + return xt_register_match(&gradm_mt_reg);
89012 +}
89013 +
89014 +static void __exit gradm_mt_exit(void)
89015 +{
89016 + xt_unregister_match(&gradm_mt_reg);
89017 +}
89018 +
89019 +module_init(gradm_mt_init);
89020 +module_exit(gradm_mt_exit);
89021 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89022 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89023 +MODULE_LICENSE("GPL");
89024 +MODULE_ALIAS("ipt_gradm");
89025 +MODULE_ALIAS("ip6t_gradm");
89026 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89027 index 4fe4fb4..87a89e5 100644
89028 --- a/net/netfilter/xt_statistic.c
89029 +++ b/net/netfilter/xt_statistic.c
89030 @@ -19,7 +19,7 @@
89031 #include <linux/module.h>
89032
89033 struct xt_statistic_priv {
89034 - atomic_t count;
89035 + atomic_unchecked_t count;
89036 } ____cacheline_aligned_in_smp;
89037
89038 MODULE_LICENSE("GPL");
89039 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89040 break;
89041 case XT_STATISTIC_MODE_NTH:
89042 do {
89043 - oval = atomic_read(&info->master->count);
89044 + oval = atomic_read_unchecked(&info->master->count);
89045 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89046 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89047 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89048 if (nval == 0)
89049 ret = !ret;
89050 break;
89051 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89052 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89053 if (info->master == NULL)
89054 return -ENOMEM;
89055 - atomic_set(&info->master->count, info->u.nth.count);
89056 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89057
89058 return 0;
89059 }
89060 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89061 index c0353d5..fcb0270 100644
89062 --- a/net/netlink/af_netlink.c
89063 +++ b/net/netlink/af_netlink.c
89064 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
89065 sk->sk_error_report(sk);
89066 }
89067 }
89068 - atomic_inc(&sk->sk_drops);
89069 + atomic_inc_unchecked(&sk->sk_drops);
89070 }
89071
89072 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
89073 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89074 sk_wmem_alloc_get(s),
89075 nlk->cb,
89076 atomic_read(&s->sk_refcnt),
89077 - atomic_read(&s->sk_drops),
89078 + atomic_read_unchecked(&s->sk_drops),
89079 sock_i_ino(s)
89080 );
89081
89082 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89083 index 5a55be3..7630745 100644
89084 --- a/net/netlink/genetlink.c
89085 +++ b/net/netlink/genetlink.c
89086 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89087 goto errout;
89088 }
89089
89090 + pax_open_kernel();
89091 if (ops->dumpit)
89092 - ops->flags |= GENL_CMD_CAP_DUMP;
89093 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89094 if (ops->doit)
89095 - ops->flags |= GENL_CMD_CAP_DO;
89096 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89097 if (ops->policy)
89098 - ops->flags |= GENL_CMD_CAP_HASPOL;
89099 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89100 + pax_close_kernel();
89101
89102 genl_lock();
89103 - list_add_tail(&ops->ops_list, &family->ops_list);
89104 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89105 genl_unlock();
89106
89107 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89108 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89109 err = 0;
89110 errout:
89111 return err;
89112 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89113 genl_lock();
89114 list_for_each_entry(rc, &family->ops_list, ops_list) {
89115 if (rc == ops) {
89116 - list_del(&ops->ops_list);
89117 + pax_list_del((struct list_head *)&ops->ops_list);
89118 genl_unlock();
89119 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89120 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89121 return 0;
89122 }
89123 }
89124 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89125 index 7261eb8..44e8ac6 100644
89126 --- a/net/netrom/af_netrom.c
89127 +++ b/net/netrom/af_netrom.c
89128 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89129 struct sock *sk = sock->sk;
89130 struct nr_sock *nr = nr_sk(sk);
89131
89132 + memset(sax, 0, sizeof(*sax));
89133 lock_sock(sk);
89134 if (peer != 0) {
89135 if (sk->sk_state != TCP_ESTABLISHED) {
89136 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89137 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89138 } else {
89139 sax->fsa_ax25.sax25_family = AF_NETROM;
89140 - sax->fsa_ax25.sax25_ndigis = 0;
89141 sax->fsa_ax25.sax25_call = nr->source_addr;
89142 *uaddr_len = sizeof(struct sockaddr_ax25);
89143 }
89144 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89145 index c111bd0..7788ff7 100644
89146 --- a/net/packet/af_packet.c
89147 +++ b/net/packet/af_packet.c
89148 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89149
89150 spin_lock(&sk->sk_receive_queue.lock);
89151 po->stats.tp_packets++;
89152 - skb->dropcount = atomic_read(&sk->sk_drops);
89153 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89154 __skb_queue_tail(&sk->sk_receive_queue, skb);
89155 spin_unlock(&sk->sk_receive_queue.lock);
89156 sk->sk_data_ready(sk, skb->len);
89157 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89158 drop_n_acct:
89159 spin_lock(&sk->sk_receive_queue.lock);
89160 po->stats.tp_drops++;
89161 - atomic_inc(&sk->sk_drops);
89162 + atomic_inc_unchecked(&sk->sk_drops);
89163 spin_unlock(&sk->sk_receive_queue.lock);
89164
89165 drop_n_restore:
89166 @@ -2565,6 +2565,7 @@ out:
89167
89168 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89169 {
89170 + struct sock_extended_err ee;
89171 struct sock_exterr_skb *serr;
89172 struct sk_buff *skb, *skb2;
89173 int copied, err;
89174 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89175 sock_recv_timestamp(msg, sk, skb);
89176
89177 serr = SKB_EXT_ERR(skb);
89178 + ee = serr->ee;
89179 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89180 - sizeof(serr->ee), &serr->ee);
89181 + sizeof ee, &ee);
89182
89183 msg->msg_flags |= MSG_ERRQUEUE;
89184 err = copied;
89185 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89186 case PACKET_HDRLEN:
89187 if (len > sizeof(int))
89188 len = sizeof(int);
89189 - if (copy_from_user(&val, optval, len))
89190 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89191 return -EFAULT;
89192 switch (val) {
89193 case TPACKET_V1:
89194 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89195 len = lv;
89196 if (put_user(len, optlen))
89197 return -EFAULT;
89198 - if (copy_to_user(optval, data, len))
89199 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89200 return -EFAULT;
89201 return 0;
89202 }
89203 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89204 index 5a940db..f0b9c12 100644
89205 --- a/net/phonet/af_phonet.c
89206 +++ b/net/phonet/af_phonet.c
89207 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
89208 {
89209 struct phonet_protocol *pp;
89210
89211 - if (protocol >= PHONET_NPROTO)
89212 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89213 return NULL;
89214
89215 rcu_read_lock();
89216 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89217 {
89218 int err = 0;
89219
89220 - if (protocol >= PHONET_NPROTO)
89221 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89222 return -EINVAL;
89223
89224 err = proto_register(pp->prot, 1);
89225 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89226 index 576f22c..bc7a71b 100644
89227 --- a/net/phonet/pep.c
89228 +++ b/net/phonet/pep.c
89229 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89230
89231 case PNS_PEP_CTRL_REQ:
89232 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89233 - atomic_inc(&sk->sk_drops);
89234 + atomic_inc_unchecked(&sk->sk_drops);
89235 break;
89236 }
89237 __skb_pull(skb, 4);
89238 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89239 }
89240
89241 if (pn->rx_credits == 0) {
89242 - atomic_inc(&sk->sk_drops);
89243 + atomic_inc_unchecked(&sk->sk_drops);
89244 err = -ENOBUFS;
89245 break;
89246 }
89247 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89248 }
89249
89250 if (pn->rx_credits == 0) {
89251 - atomic_inc(&sk->sk_drops);
89252 + atomic_inc_unchecked(&sk->sk_drops);
89253 err = NET_RX_DROP;
89254 break;
89255 }
89256 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89257 index b7e9827..c264c85 100644
89258 --- a/net/phonet/socket.c
89259 +++ b/net/phonet/socket.c
89260 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89261 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89262 sock_i_ino(sk),
89263 atomic_read(&sk->sk_refcnt), sk,
89264 - atomic_read(&sk->sk_drops), &len);
89265 + atomic_read_unchecked(&sk->sk_drops), &len);
89266 }
89267 seq_printf(seq, "%*s\n", 127 - len, "");
89268 return 0;
89269 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89270 index d6bbbbd..61561e4 100644
89271 --- a/net/phonet/sysctl.c
89272 +++ b/net/phonet/sysctl.c
89273 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89274 {
89275 int ret;
89276 int range[2] = {local_port_range[0], local_port_range[1]};
89277 - ctl_table tmp = {
89278 + ctl_table_no_const tmp = {
89279 .data = &range,
89280 .maxlen = sizeof(range),
89281 .mode = table->mode,
89282 diff --git a/net/rds/cong.c b/net/rds/cong.c
89283 index e5b65ac..f3b6fb7 100644
89284 --- a/net/rds/cong.c
89285 +++ b/net/rds/cong.c
89286 @@ -78,7 +78,7 @@
89287 * finds that the saved generation number is smaller than the global generation
89288 * number, it wakes up the process.
89289 */
89290 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89291 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89292
89293 /*
89294 * Congestion monitoring
89295 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89296 rdsdebug("waking map %p for %pI4\n",
89297 map, &map->m_addr);
89298 rds_stats_inc(s_cong_update_received);
89299 - atomic_inc(&rds_cong_generation);
89300 + atomic_inc_unchecked(&rds_cong_generation);
89301 if (waitqueue_active(&map->m_waitq))
89302 wake_up(&map->m_waitq);
89303 if (waitqueue_active(&rds_poll_waitq))
89304 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89305
89306 int rds_cong_updated_since(unsigned long *recent)
89307 {
89308 - unsigned long gen = atomic_read(&rds_cong_generation);
89309 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89310
89311 if (likely(*recent == gen))
89312 return 0;
89313 diff --git a/net/rds/ib.h b/net/rds/ib.h
89314 index 7280ab8..e04f4ea 100644
89315 --- a/net/rds/ib.h
89316 +++ b/net/rds/ib.h
89317 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89318 /* sending acks */
89319 unsigned long i_ack_flags;
89320 #ifdef KERNEL_HAS_ATOMIC64
89321 - atomic64_t i_ack_next; /* next ACK to send */
89322 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89323 #else
89324 spinlock_t i_ack_lock; /* protect i_ack_next */
89325 u64 i_ack_next; /* next ACK to send */
89326 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89327 index 31b74f5..dc1fbfa 100644
89328 --- a/net/rds/ib_cm.c
89329 +++ b/net/rds/ib_cm.c
89330 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89331 /* Clear the ACK state */
89332 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89333 #ifdef KERNEL_HAS_ATOMIC64
89334 - atomic64_set(&ic->i_ack_next, 0);
89335 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89336 #else
89337 ic->i_ack_next = 0;
89338 #endif
89339 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89340 index 8eb9501..0c386ff 100644
89341 --- a/net/rds/ib_recv.c
89342 +++ b/net/rds/ib_recv.c
89343 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89344 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89345 int ack_required)
89346 {
89347 - atomic64_set(&ic->i_ack_next, seq);
89348 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89349 if (ack_required) {
89350 smp_mb__before_clear_bit();
89351 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89352 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89353 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89354 smp_mb__after_clear_bit();
89355
89356 - return atomic64_read(&ic->i_ack_next);
89357 + return atomic64_read_unchecked(&ic->i_ack_next);
89358 }
89359 #endif
89360
89361 diff --git a/net/rds/iw.h b/net/rds/iw.h
89362 index 04ce3b1..48119a6 100644
89363 --- a/net/rds/iw.h
89364 +++ b/net/rds/iw.h
89365 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89366 /* sending acks */
89367 unsigned long i_ack_flags;
89368 #ifdef KERNEL_HAS_ATOMIC64
89369 - atomic64_t i_ack_next; /* next ACK to send */
89370 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89371 #else
89372 spinlock_t i_ack_lock; /* protect i_ack_next */
89373 u64 i_ack_next; /* next ACK to send */
89374 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89375 index a91e1db..cf3053f 100644
89376 --- a/net/rds/iw_cm.c
89377 +++ b/net/rds/iw_cm.c
89378 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89379 /* Clear the ACK state */
89380 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89381 #ifdef KERNEL_HAS_ATOMIC64
89382 - atomic64_set(&ic->i_ack_next, 0);
89383 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89384 #else
89385 ic->i_ack_next = 0;
89386 #endif
89387 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89388 index 4503335..db566b4 100644
89389 --- a/net/rds/iw_recv.c
89390 +++ b/net/rds/iw_recv.c
89391 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89392 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89393 int ack_required)
89394 {
89395 - atomic64_set(&ic->i_ack_next, seq);
89396 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89397 if (ack_required) {
89398 smp_mb__before_clear_bit();
89399 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89400 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89401 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89402 smp_mb__after_clear_bit();
89403
89404 - return atomic64_read(&ic->i_ack_next);
89405 + return atomic64_read_unchecked(&ic->i_ack_next);
89406 }
89407 #endif
89408
89409 diff --git a/net/rds/rds.h b/net/rds/rds.h
89410 index ec1d731..90a3a8d 100644
89411 --- a/net/rds/rds.h
89412 +++ b/net/rds/rds.h
89413 @@ -449,7 +449,7 @@ struct rds_transport {
89414 void (*sync_mr)(void *trans_private, int direction);
89415 void (*free_mr)(void *trans_private, int invalidate);
89416 void (*flush_mrs)(void);
89417 -};
89418 +} __do_const;
89419
89420 struct rds_sock {
89421 struct sock rs_sk;
89422 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89423 index edac9ef..16bcb98 100644
89424 --- a/net/rds/tcp.c
89425 +++ b/net/rds/tcp.c
89426 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89427 int val = 1;
89428
89429 set_fs(KERNEL_DS);
89430 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89431 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89432 sizeof(val));
89433 set_fs(oldfs);
89434 }
89435 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89436 index 81cf5a4..b5826ff 100644
89437 --- a/net/rds/tcp_send.c
89438 +++ b/net/rds/tcp_send.c
89439 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89440
89441 oldfs = get_fs();
89442 set_fs(KERNEL_DS);
89443 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89444 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89445 sizeof(val));
89446 set_fs(oldfs);
89447 }
89448 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89449 index 05996d0..5a1dfe0 100644
89450 --- a/net/rxrpc/af_rxrpc.c
89451 +++ b/net/rxrpc/af_rxrpc.c
89452 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89453 __be32 rxrpc_epoch;
89454
89455 /* current debugging ID */
89456 -atomic_t rxrpc_debug_id;
89457 +atomic_unchecked_t rxrpc_debug_id;
89458
89459 /* count of skbs currently in use */
89460 atomic_t rxrpc_n_skbs;
89461 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89462 index e4d9cbc..b229649 100644
89463 --- a/net/rxrpc/ar-ack.c
89464 +++ b/net/rxrpc/ar-ack.c
89465 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89466
89467 _enter("{%d,%d,%d,%d},",
89468 call->acks_hard, call->acks_unacked,
89469 - atomic_read(&call->sequence),
89470 + atomic_read_unchecked(&call->sequence),
89471 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89472
89473 stop = 0;
89474 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89475
89476 /* each Tx packet has a new serial number */
89477 sp->hdr.serial =
89478 - htonl(atomic_inc_return(&call->conn->serial));
89479 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89480
89481 hdr = (struct rxrpc_header *) txb->head;
89482 hdr->serial = sp->hdr.serial;
89483 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89484 */
89485 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89486 {
89487 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89488 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89489 }
89490
89491 /*
89492 @@ -629,7 +629,7 @@ process_further:
89493
89494 latest = ntohl(sp->hdr.serial);
89495 hard = ntohl(ack.firstPacket);
89496 - tx = atomic_read(&call->sequence);
89497 + tx = atomic_read_unchecked(&call->sequence);
89498
89499 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89500 latest,
89501 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89502 goto maybe_reschedule;
89503
89504 send_ACK_with_skew:
89505 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89506 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89507 ntohl(ack.serial));
89508 send_ACK:
89509 mtu = call->conn->trans->peer->if_mtu;
89510 @@ -1173,7 +1173,7 @@ send_ACK:
89511 ackinfo.rxMTU = htonl(5692);
89512 ackinfo.jumbo_max = htonl(4);
89513
89514 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89515 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89516 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89517 ntohl(hdr.serial),
89518 ntohs(ack.maxSkew),
89519 @@ -1191,7 +1191,7 @@ send_ACK:
89520 send_message:
89521 _debug("send message");
89522
89523 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89524 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89525 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89526 send_message_2:
89527
89528 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89529 index a3bbb36..3341fb9 100644
89530 --- a/net/rxrpc/ar-call.c
89531 +++ b/net/rxrpc/ar-call.c
89532 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89533 spin_lock_init(&call->lock);
89534 rwlock_init(&call->state_lock);
89535 atomic_set(&call->usage, 1);
89536 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89537 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89538 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89539
89540 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89541 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89542 index 4106ca9..a338d7a 100644
89543 --- a/net/rxrpc/ar-connection.c
89544 +++ b/net/rxrpc/ar-connection.c
89545 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89546 rwlock_init(&conn->lock);
89547 spin_lock_init(&conn->state_lock);
89548 atomic_set(&conn->usage, 1);
89549 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89550 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89551 conn->avail_calls = RXRPC_MAXCALLS;
89552 conn->size_align = 4;
89553 conn->header_size = sizeof(struct rxrpc_header);
89554 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89555 index e7ed43a..6afa140 100644
89556 --- a/net/rxrpc/ar-connevent.c
89557 +++ b/net/rxrpc/ar-connevent.c
89558 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89559
89560 len = iov[0].iov_len + iov[1].iov_len;
89561
89562 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89563 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89564 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89565
89566 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89567 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89568 index 529572f..c758ca7 100644
89569 --- a/net/rxrpc/ar-input.c
89570 +++ b/net/rxrpc/ar-input.c
89571 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89572 /* track the latest serial number on this connection for ACK packet
89573 * information */
89574 serial = ntohl(sp->hdr.serial);
89575 - hi_serial = atomic_read(&call->conn->hi_serial);
89576 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89577 while (serial > hi_serial)
89578 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89579 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89580 serial);
89581
89582 /* request ACK generation for any ACK or DATA packet that requests
89583 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89584 index a693aca..81e7293 100644
89585 --- a/net/rxrpc/ar-internal.h
89586 +++ b/net/rxrpc/ar-internal.h
89587 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89588 int error; /* error code for local abort */
89589 int debug_id; /* debug ID for printks */
89590 unsigned int call_counter; /* call ID counter */
89591 - atomic_t serial; /* packet serial number counter */
89592 - atomic_t hi_serial; /* highest serial number received */
89593 + atomic_unchecked_t serial; /* packet serial number counter */
89594 + atomic_unchecked_t hi_serial; /* highest serial number received */
89595 u8 avail_calls; /* number of calls available */
89596 u8 size_align; /* data size alignment (for security) */
89597 u8 header_size; /* rxrpc + security header size */
89598 @@ -346,7 +346,7 @@ struct rxrpc_call {
89599 spinlock_t lock;
89600 rwlock_t state_lock; /* lock for state transition */
89601 atomic_t usage;
89602 - atomic_t sequence; /* Tx data packet sequence counter */
89603 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89604 u32 abort_code; /* local/remote abort code */
89605 enum { /* current state of call */
89606 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89607 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89608 */
89609 extern atomic_t rxrpc_n_skbs;
89610 extern __be32 rxrpc_epoch;
89611 -extern atomic_t rxrpc_debug_id;
89612 +extern atomic_unchecked_t rxrpc_debug_id;
89613 extern struct workqueue_struct *rxrpc_workqueue;
89614
89615 /*
89616 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89617 index 87f7135..74d3703 100644
89618 --- a/net/rxrpc/ar-local.c
89619 +++ b/net/rxrpc/ar-local.c
89620 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89621 spin_lock_init(&local->lock);
89622 rwlock_init(&local->services_lock);
89623 atomic_set(&local->usage, 1);
89624 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89625 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89626 memcpy(&local->srx, srx, sizeof(*srx));
89627 }
89628
89629 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89630 index e1ac183..b43e10e 100644
89631 --- a/net/rxrpc/ar-output.c
89632 +++ b/net/rxrpc/ar-output.c
89633 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89634 sp->hdr.cid = call->cid;
89635 sp->hdr.callNumber = call->call_id;
89636 sp->hdr.seq =
89637 - htonl(atomic_inc_return(&call->sequence));
89638 + htonl(atomic_inc_return_unchecked(&call->sequence));
89639 sp->hdr.serial =
89640 - htonl(atomic_inc_return(&conn->serial));
89641 + htonl(atomic_inc_return_unchecked(&conn->serial));
89642 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89643 sp->hdr.userStatus = 0;
89644 sp->hdr.securityIndex = conn->security_ix;
89645 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89646 index bebaa43..2644591 100644
89647 --- a/net/rxrpc/ar-peer.c
89648 +++ b/net/rxrpc/ar-peer.c
89649 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89650 INIT_LIST_HEAD(&peer->error_targets);
89651 spin_lock_init(&peer->lock);
89652 atomic_set(&peer->usage, 1);
89653 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89654 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89655 memcpy(&peer->srx, srx, sizeof(*srx));
89656
89657 rxrpc_assess_MTU_size(peer);
89658 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89659 index 38047f7..9f48511 100644
89660 --- a/net/rxrpc/ar-proc.c
89661 +++ b/net/rxrpc/ar-proc.c
89662 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89663 atomic_read(&conn->usage),
89664 rxrpc_conn_states[conn->state],
89665 key_serial(conn->key),
89666 - atomic_read(&conn->serial),
89667 - atomic_read(&conn->hi_serial));
89668 + atomic_read_unchecked(&conn->serial),
89669 + atomic_read_unchecked(&conn->hi_serial));
89670
89671 return 0;
89672 }
89673 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89674 index 92df566..87ec1bf 100644
89675 --- a/net/rxrpc/ar-transport.c
89676 +++ b/net/rxrpc/ar-transport.c
89677 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89678 spin_lock_init(&trans->client_lock);
89679 rwlock_init(&trans->conn_lock);
89680 atomic_set(&trans->usage, 1);
89681 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89682 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89683
89684 if (peer->srx.transport.family == AF_INET) {
89685 switch (peer->srx.transport_type) {
89686 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
89687 index f226709..0e735a8 100644
89688 --- a/net/rxrpc/rxkad.c
89689 +++ b/net/rxrpc/rxkad.c
89690 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
89691
89692 len = iov[0].iov_len + iov[1].iov_len;
89693
89694 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89695 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89696 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
89697
89698 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89699 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
89700
89701 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
89702
89703 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
89704 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89705 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
89706
89707 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
89708 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
89709 index 391a245..296b3d7 100644
89710 --- a/net/sctp/ipv6.c
89711 +++ b/net/sctp/ipv6.c
89712 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
89713 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
89714 };
89715
89716 -static struct sctp_af sctp_af_inet6 = {
89717 +static struct sctp_af sctp_af_inet6 __read_only = {
89718 .sa_family = AF_INET6,
89719 .sctp_xmit = sctp_v6_xmit,
89720 .setsockopt = ipv6_setsockopt,
89721 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
89722 #endif
89723 };
89724
89725 -static struct sctp_pf sctp_pf_inet6 = {
89726 +static struct sctp_pf sctp_pf_inet6 __read_only = {
89727 .event_msgname = sctp_inet6_event_msgname,
89728 .skb_msgname = sctp_inet6_skb_msgname,
89729 .af_supported = sctp_inet6_af_supported,
89730 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
89731
89732 void sctp_v6_pf_exit(void)
89733 {
89734 - list_del(&sctp_af_inet6.list);
89735 + pax_list_del(&sctp_af_inet6.list);
89736 }
89737
89738 /* Initialize IPv6 support and register with socket layer. */
89739 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
89740 index 8c19e97..16264b8 100644
89741 --- a/net/sctp/proc.c
89742 +++ b/net/sctp/proc.c
89743 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
89744 seq_printf(seq,
89745 "%8pK %8pK %-3d %-3d %-2d %-4d "
89746 "%4d %8d %8d %7d %5lu %-5d %5d ",
89747 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
89748 + assoc, sk,
89749 + sctp_sk(sk)->type, sk->sk_state,
89750 assoc->state, hash,
89751 assoc->assoc_id,
89752 assoc->sndbuf_used,
89753 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
89754 index f898b1c..a2d0fe8 100644
89755 --- a/net/sctp/protocol.c
89756 +++ b/net/sctp/protocol.c
89757 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
89758 return 0;
89759 }
89760
89761 + pax_open_kernel();
89762 INIT_LIST_HEAD(&af->list);
89763 - list_add_tail(&af->list, &sctp_address_families);
89764 + pax_close_kernel();
89765 + pax_list_add_tail(&af->list, &sctp_address_families);
89766 return 1;
89767 }
89768
89769 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
89770
89771 static struct sctp_af sctp_af_inet;
89772
89773 -static struct sctp_pf sctp_pf_inet = {
89774 +static struct sctp_pf sctp_pf_inet __read_only = {
89775 .event_msgname = sctp_inet_event_msgname,
89776 .skb_msgname = sctp_inet_skb_msgname,
89777 .af_supported = sctp_inet_af_supported,
89778 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
89779 };
89780
89781 /* IPv4 address related functions. */
89782 -static struct sctp_af sctp_af_inet = {
89783 +static struct sctp_af sctp_af_inet __read_only = {
89784 .sa_family = AF_INET,
89785 .sctp_xmit = sctp_v4_xmit,
89786 .setsockopt = ip_setsockopt,
89787 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
89788
89789 static void sctp_v4_pf_exit(void)
89790 {
89791 - list_del(&sctp_af_inet.list);
89792 + pax_list_del(&sctp_af_inet.list);
89793 }
89794
89795 static int sctp_v4_protosw_init(void)
89796 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
89797 index c957775..6d4593a 100644
89798 --- a/net/sctp/sm_sideeffect.c
89799 +++ b/net/sctp/sm_sideeffect.c
89800 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
89801 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
89802 }
89803
89804 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89805 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89806 NULL,
89807 sctp_generate_t1_cookie_event,
89808 sctp_generate_t1_init_event,
89809 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
89810 index 9ef5c73..1e9a9a9 100644
89811 --- a/net/sctp/socket.c
89812 +++ b/net/sctp/socket.c
89813 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
89814 {
89815 struct sctp_association *asoc;
89816 struct sctp_ulpevent *event;
89817 + struct sctp_event_subscribe subscribe;
89818
89819 if (optlen > sizeof(struct sctp_event_subscribe))
89820 return -EINVAL;
89821 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
89822 + if (copy_from_user(&subscribe, optval, optlen))
89823 return -EFAULT;
89824 + sctp_sk(sk)->subscribe = subscribe;
89825
89826 /*
89827 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
89828 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
89829 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89830 int __user *optlen)
89831 {
89832 + struct sctp_event_subscribe subscribe;
89833 +
89834 if (len <= 0)
89835 return -EINVAL;
89836 if (len > sizeof(struct sctp_event_subscribe))
89837 len = sizeof(struct sctp_event_subscribe);
89838 if (put_user(len, optlen))
89839 return -EFAULT;
89840 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
89841 + subscribe = sctp_sk(sk)->subscribe;
89842 + if (copy_to_user(optval, &subscribe, len))
89843 return -EFAULT;
89844 return 0;
89845 }
89846 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89847 */
89848 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
89849 {
89850 + __u32 autoclose;
89851 +
89852 /* Applicable to UDP-style socket only */
89853 if (sctp_style(sk, TCP))
89854 return -EOPNOTSUPP;
89855 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
89856 len = sizeof(int);
89857 if (put_user(len, optlen))
89858 return -EFAULT;
89859 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
89860 + autoclose = sctp_sk(sk)->autoclose;
89861 + if (copy_to_user(optval, &autoclose, sizeof(int)))
89862 return -EFAULT;
89863 return 0;
89864 }
89865 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
89866 */
89867 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
89868 {
89869 + struct sctp_initmsg initmsg;
89870 +
89871 if (len < sizeof(struct sctp_initmsg))
89872 return -EINVAL;
89873 len = sizeof(struct sctp_initmsg);
89874 if (put_user(len, optlen))
89875 return -EFAULT;
89876 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
89877 + initmsg = sctp_sk(sk)->initmsg;
89878 + if (copy_to_user(optval, &initmsg, len))
89879 return -EFAULT;
89880 return 0;
89881 }
89882 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
89883 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
89884 if (space_left < addrlen)
89885 return -ENOMEM;
89886 + if (addrlen > sizeof(temp) || addrlen < 0)
89887 + return -EFAULT;
89888 if (copy_to_user(to, &temp, addrlen))
89889 return -EFAULT;
89890 to += addrlen;
89891 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
89892 index 442ad4e..825ea94 100644
89893 --- a/net/sctp/ssnmap.c
89894 +++ b/net/sctp/ssnmap.c
89895 @@ -41,8 +41,6 @@
89896 #include <net/sctp/sctp.h>
89897 #include <net/sctp/sm.h>
89898
89899 -#define MAX_KMALLOC_SIZE 131072
89900 -
89901 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
89902 __u16 out);
89903
89904 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
89905 int size;
89906
89907 size = sctp_ssnmap_size(in, out);
89908 - if (size <= MAX_KMALLOC_SIZE)
89909 + if (size <= KMALLOC_MAX_SIZE)
89910 retval = kmalloc(size, gfp);
89911 else
89912 retval = (struct sctp_ssnmap *)
89913 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
89914 return retval;
89915
89916 fail_map:
89917 - if (size <= MAX_KMALLOC_SIZE)
89918 + if (size <= KMALLOC_MAX_SIZE)
89919 kfree(retval);
89920 else
89921 free_pages((unsigned long)retval, get_order(size));
89922 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
89923 int size;
89924
89925 size = sctp_ssnmap_size(map->in.len, map->out.len);
89926 - if (size <= MAX_KMALLOC_SIZE)
89927 + if (size <= KMALLOC_MAX_SIZE)
89928 kfree(map);
89929 else
89930 free_pages((unsigned long)map, get_order(size));
89931 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
89932 index bf3c6e8..376d8d0 100644
89933 --- a/net/sctp/sysctl.c
89934 +++ b/net/sctp/sysctl.c
89935 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89936 {
89937 struct net *net = current->nsproxy->net_ns;
89938 char tmp[8];
89939 - ctl_table tbl;
89940 + ctl_table_no_const tbl;
89941 int ret;
89942 int changed = 0;
89943 char *none = "none";
89944 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89945
89946 int sctp_sysctl_net_register(struct net *net)
89947 {
89948 - struct ctl_table *table;
89949 + ctl_table_no_const *table;
89950 int i;
89951
89952 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
89953 diff --git a/net/socket.c b/net/socket.c
89954 index 2ca51c7..ee5feb5 100644
89955 --- a/net/socket.c
89956 +++ b/net/socket.c
89957 @@ -89,6 +89,7 @@
89958 #include <linux/magic.h>
89959 #include <linux/slab.h>
89960 #include <linux/xattr.h>
89961 +#include <linux/in.h>
89962
89963 #include <asm/uaccess.h>
89964 #include <asm/unistd.h>
89965 @@ -106,6 +107,8 @@
89966 #include <linux/sockios.h>
89967 #include <linux/atalk.h>
89968
89969 +#include <linux/grsock.h>
89970 +
89971 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
89972 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
89973 unsigned long nr_segs, loff_t pos);
89974 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
89975 &sockfs_dentry_operations, SOCKFS_MAGIC);
89976 }
89977
89978 -static struct vfsmount *sock_mnt __read_mostly;
89979 +struct vfsmount *sock_mnt __read_mostly;
89980
89981 static struct file_system_type sock_fs_type = {
89982 .name = "sockfs",
89983 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
89984 return -EAFNOSUPPORT;
89985 if (type < 0 || type >= SOCK_MAX)
89986 return -EINVAL;
89987 + if (protocol < 0)
89988 + return -EINVAL;
89989
89990 /* Compatibility.
89991
89992 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
89993 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
89994 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
89995
89996 + if(!gr_search_socket(family, type, protocol)) {
89997 + retval = -EACCES;
89998 + goto out;
89999 + }
90000 +
90001 + if (gr_handle_sock_all(family, type, protocol)) {
90002 + retval = -EACCES;
90003 + goto out;
90004 + }
90005 +
90006 retval = sock_create(family, type, protocol, &sock);
90007 if (retval < 0)
90008 goto out;
90009 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90010 if (sock) {
90011 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90012 if (err >= 0) {
90013 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90014 + err = -EACCES;
90015 + goto error;
90016 + }
90017 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90018 + if (err)
90019 + goto error;
90020 +
90021 err = security_socket_bind(sock,
90022 (struct sockaddr *)&address,
90023 addrlen);
90024 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90025 (struct sockaddr *)
90026 &address, addrlen);
90027 }
90028 +error:
90029 fput_light(sock->file, fput_needed);
90030 }
90031 return err;
90032 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90033 if ((unsigned int)backlog > somaxconn)
90034 backlog = somaxconn;
90035
90036 + if (gr_handle_sock_server_other(sock->sk)) {
90037 + err = -EPERM;
90038 + goto error;
90039 + }
90040 +
90041 + err = gr_search_listen(sock);
90042 + if (err)
90043 + goto error;
90044 +
90045 err = security_socket_listen(sock, backlog);
90046 if (!err)
90047 err = sock->ops->listen(sock, backlog);
90048
90049 +error:
90050 fput_light(sock->file, fput_needed);
90051 }
90052 return err;
90053 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90054 newsock->type = sock->type;
90055 newsock->ops = sock->ops;
90056
90057 + if (gr_handle_sock_server_other(sock->sk)) {
90058 + err = -EPERM;
90059 + sock_release(newsock);
90060 + goto out_put;
90061 + }
90062 +
90063 + err = gr_search_accept(sock);
90064 + if (err) {
90065 + sock_release(newsock);
90066 + goto out_put;
90067 + }
90068 +
90069 /*
90070 * We don't need try_module_get here, as the listening socket (sock)
90071 * has the protocol module (sock->ops->owner) held.
90072 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90073 fd_install(newfd, newfile);
90074 err = newfd;
90075
90076 + gr_attach_curr_ip(newsock->sk);
90077 +
90078 out_put:
90079 fput_light(sock->file, fput_needed);
90080 out:
90081 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90082 int, addrlen)
90083 {
90084 struct socket *sock;
90085 + struct sockaddr *sck;
90086 struct sockaddr_storage address;
90087 int err, fput_needed;
90088
90089 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90090 if (err < 0)
90091 goto out_put;
90092
90093 + sck = (struct sockaddr *)&address;
90094 +
90095 + if (gr_handle_sock_client(sck)) {
90096 + err = -EACCES;
90097 + goto out_put;
90098 + }
90099 +
90100 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90101 + if (err)
90102 + goto out_put;
90103 +
90104 err =
90105 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90106 if (err)
90107 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90108 * the protocol.
90109 */
90110
90111 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90112 +
90113 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90114 unsigned int, flags, struct sockaddr __user *, addr,
90115 int, addr_len)
90116 @@ -1840,7 +1902,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90117 struct socket *sock;
90118 struct iovec iov;
90119 struct msghdr msg;
90120 - struct sockaddr_storage address;
90121 + struct sockaddr_storage address = { };
90122 int err, err2;
90123 int fput_needed;
90124
90125 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90126 * checking falls down on this.
90127 */
90128 if (copy_from_user(ctl_buf,
90129 - (void __user __force *)msg_sys->msg_control,
90130 + (void __force_user *)msg_sys->msg_control,
90131 ctl_len))
90132 goto out_freectl;
90133 msg_sys->msg_control = ctl_buf;
90134 @@ -2187,7 +2249,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90135 int err, total_len, len;
90136
90137 /* kernel mode address */
90138 - struct sockaddr_storage addr;
90139 + struct sockaddr_storage addr = { };
90140
90141 /* user mode address pointers */
90142 struct sockaddr __user *uaddr;
90143 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90144 * kernel msghdr to use the kernel address space)
90145 */
90146
90147 - uaddr = (__force void __user *)msg_sys->msg_name;
90148 + uaddr = (void __force_user *)msg_sys->msg_name;
90149 uaddr_len = COMPAT_NAMELEN(msg);
90150 if (MSG_CMSG_COMPAT & flags) {
90151 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90152 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90153 }
90154
90155 ifr = compat_alloc_user_space(buf_size);
90156 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
90157 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
90158
90159 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
90160 return -EFAULT;
90161 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90162 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
90163
90164 if (copy_in_user(rxnfc, compat_rxnfc,
90165 - (void *)(&rxnfc->fs.m_ext + 1) -
90166 - (void *)rxnfc) ||
90167 + (void __user *)(&rxnfc->fs.m_ext + 1) -
90168 + (void __user *)rxnfc) ||
90169 copy_in_user(&rxnfc->fs.ring_cookie,
90170 &compat_rxnfc->fs.ring_cookie,
90171 - (void *)(&rxnfc->fs.location + 1) -
90172 - (void *)&rxnfc->fs.ring_cookie) ||
90173 + (void __user *)(&rxnfc->fs.location + 1) -
90174 + (void __user *)&rxnfc->fs.ring_cookie) ||
90175 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
90176 sizeof(rxnfc->rule_cnt)))
90177 return -EFAULT;
90178 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90179
90180 if (convert_out) {
90181 if (copy_in_user(compat_rxnfc, rxnfc,
90182 - (const void *)(&rxnfc->fs.m_ext + 1) -
90183 - (const void *)rxnfc) ||
90184 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
90185 + (const void __user *)rxnfc) ||
90186 copy_in_user(&compat_rxnfc->fs.ring_cookie,
90187 &rxnfc->fs.ring_cookie,
90188 - (const void *)(&rxnfc->fs.location + 1) -
90189 - (const void *)&rxnfc->fs.ring_cookie) ||
90190 + (const void __user *)(&rxnfc->fs.location + 1) -
90191 + (const void __user *)&rxnfc->fs.ring_cookie) ||
90192 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
90193 sizeof(rxnfc->rule_cnt)))
90194 return -EFAULT;
90195 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90196 old_fs = get_fs();
90197 set_fs(KERNEL_DS);
90198 err = dev_ioctl(net, cmd,
90199 - (struct ifreq __user __force *) &kifr);
90200 + (struct ifreq __force_user *) &kifr);
90201 set_fs(old_fs);
90202
90203 return err;
90204 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90205
90206 old_fs = get_fs();
90207 set_fs(KERNEL_DS);
90208 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90209 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90210 set_fs(old_fs);
90211
90212 if (cmd == SIOCGIFMAP && !err) {
90213 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90214 ret |= __get_user(rtdev, &(ur4->rt_dev));
90215 if (rtdev) {
90216 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90217 - r4.rt_dev = (char __user __force *)devname;
90218 + r4.rt_dev = (char __force_user *)devname;
90219 devname[15] = 0;
90220 } else
90221 r4.rt_dev = NULL;
90222 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90223 int __user *uoptlen;
90224 int err;
90225
90226 - uoptval = (char __user __force *) optval;
90227 - uoptlen = (int __user __force *) optlen;
90228 + uoptval = (char __force_user *) optval;
90229 + uoptlen = (int __force_user *) optlen;
90230
90231 set_fs(KERNEL_DS);
90232 if (level == SOL_SOCKET)
90233 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90234 char __user *uoptval;
90235 int err;
90236
90237 - uoptval = (char __user __force *) optval;
90238 + uoptval = (char __force_user *) optval;
90239
90240 set_fs(KERNEL_DS);
90241 if (level == SOL_SOCKET)
90242 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90243 index 716aa41..75e88ea 100644
90244 --- a/net/sunrpc/clnt.c
90245 +++ b/net/sunrpc/clnt.c
90246 @@ -303,10 +303,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
90247 err = rpciod_up();
90248 if (err)
90249 goto out_no_rpciod;
90250 +
90251 err = -EINVAL;
90252 - if (!xprt)
90253 - goto out_no_xprt;
90254 -
90255 if (args->version >= program->nrvers)
90256 goto out_err;
90257 version = program->version[args->version];
90258 @@ -381,10 +379,9 @@ out_no_principal:
90259 out_no_stats:
90260 kfree(clnt);
90261 out_err:
90262 - xprt_put(xprt);
90263 -out_no_xprt:
90264 rpciod_down();
90265 out_no_rpciod:
90266 + xprt_put(xprt);
90267 return ERR_PTR(err);
90268 }
90269
90270 @@ -1270,7 +1267,9 @@ call_start(struct rpc_task *task)
90271 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90272
90273 /* Increment call count */
90274 - task->tk_msg.rpc_proc->p_count++;
90275 + pax_open_kernel();
90276 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90277 + pax_close_kernel();
90278 clnt->cl_stats->rpccnt++;
90279 task->tk_action = call_reserve;
90280 }
90281 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90282 index f8529fc..ce8c643 100644
90283 --- a/net/sunrpc/sched.c
90284 +++ b/net/sunrpc/sched.c
90285 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90286 #ifdef RPC_DEBUG
90287 static void rpc_task_set_debuginfo(struct rpc_task *task)
90288 {
90289 - static atomic_t rpc_pid;
90290 + static atomic_unchecked_t rpc_pid;
90291
90292 - task->tk_pid = atomic_inc_return(&rpc_pid);
90293 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90294 }
90295 #else
90296 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90297 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90298 index 2d34b6b..e2d584d 100644
90299 --- a/net/sunrpc/svc.c
90300 +++ b/net/sunrpc/svc.c
90301 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90302 svc_putnl(resv, RPC_SUCCESS);
90303
90304 /* Bump per-procedure stats counter */
90305 - procp->pc_count++;
90306 + pax_open_kernel();
90307 + (*(unsigned int *)&procp->pc_count)++;
90308 + pax_close_kernel();
90309
90310 /* Initialize storage for argp and resp */
90311 memset(rqstp->rq_argp, 0, procp->pc_argsize);
90312 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
90313 index 8343737..677025e 100644
90314 --- a/net/sunrpc/xprtrdma/svc_rdma.c
90315 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
90316 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90317 static unsigned int min_max_inline = 4096;
90318 static unsigned int max_max_inline = 65536;
90319
90320 -atomic_t rdma_stat_recv;
90321 -atomic_t rdma_stat_read;
90322 -atomic_t rdma_stat_write;
90323 -atomic_t rdma_stat_sq_starve;
90324 -atomic_t rdma_stat_rq_starve;
90325 -atomic_t rdma_stat_rq_poll;
90326 -atomic_t rdma_stat_rq_prod;
90327 -atomic_t rdma_stat_sq_poll;
90328 -atomic_t rdma_stat_sq_prod;
90329 +atomic_unchecked_t rdma_stat_recv;
90330 +atomic_unchecked_t rdma_stat_read;
90331 +atomic_unchecked_t rdma_stat_write;
90332 +atomic_unchecked_t rdma_stat_sq_starve;
90333 +atomic_unchecked_t rdma_stat_rq_starve;
90334 +atomic_unchecked_t rdma_stat_rq_poll;
90335 +atomic_unchecked_t rdma_stat_rq_prod;
90336 +atomic_unchecked_t rdma_stat_sq_poll;
90337 +atomic_unchecked_t rdma_stat_sq_prod;
90338
90339 /* Temporary NFS request map and context caches */
90340 struct kmem_cache *svc_rdma_map_cachep;
90341 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90342 len -= *ppos;
90343 if (len > *lenp)
90344 len = *lenp;
90345 - if (len && copy_to_user(buffer, str_buf, len))
90346 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90347 return -EFAULT;
90348 *lenp = len;
90349 *ppos += len;
90350 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90351 {
90352 .procname = "rdma_stat_read",
90353 .data = &rdma_stat_read,
90354 - .maxlen = sizeof(atomic_t),
90355 + .maxlen = sizeof(atomic_unchecked_t),
90356 .mode = 0644,
90357 .proc_handler = read_reset_stat,
90358 },
90359 {
90360 .procname = "rdma_stat_recv",
90361 .data = &rdma_stat_recv,
90362 - .maxlen = sizeof(atomic_t),
90363 + .maxlen = sizeof(atomic_unchecked_t),
90364 .mode = 0644,
90365 .proc_handler = read_reset_stat,
90366 },
90367 {
90368 .procname = "rdma_stat_write",
90369 .data = &rdma_stat_write,
90370 - .maxlen = sizeof(atomic_t),
90371 + .maxlen = sizeof(atomic_unchecked_t),
90372 .mode = 0644,
90373 .proc_handler = read_reset_stat,
90374 },
90375 {
90376 .procname = "rdma_stat_sq_starve",
90377 .data = &rdma_stat_sq_starve,
90378 - .maxlen = sizeof(atomic_t),
90379 + .maxlen = sizeof(atomic_unchecked_t),
90380 .mode = 0644,
90381 .proc_handler = read_reset_stat,
90382 },
90383 {
90384 .procname = "rdma_stat_rq_starve",
90385 .data = &rdma_stat_rq_starve,
90386 - .maxlen = sizeof(atomic_t),
90387 + .maxlen = sizeof(atomic_unchecked_t),
90388 .mode = 0644,
90389 .proc_handler = read_reset_stat,
90390 },
90391 {
90392 .procname = "rdma_stat_rq_poll",
90393 .data = &rdma_stat_rq_poll,
90394 - .maxlen = sizeof(atomic_t),
90395 + .maxlen = sizeof(atomic_unchecked_t),
90396 .mode = 0644,
90397 .proc_handler = read_reset_stat,
90398 },
90399 {
90400 .procname = "rdma_stat_rq_prod",
90401 .data = &rdma_stat_rq_prod,
90402 - .maxlen = sizeof(atomic_t),
90403 + .maxlen = sizeof(atomic_unchecked_t),
90404 .mode = 0644,
90405 .proc_handler = read_reset_stat,
90406 },
90407 {
90408 .procname = "rdma_stat_sq_poll",
90409 .data = &rdma_stat_sq_poll,
90410 - .maxlen = sizeof(atomic_t),
90411 + .maxlen = sizeof(atomic_unchecked_t),
90412 .mode = 0644,
90413 .proc_handler = read_reset_stat,
90414 },
90415 {
90416 .procname = "rdma_stat_sq_prod",
90417 .data = &rdma_stat_sq_prod,
90418 - .maxlen = sizeof(atomic_t),
90419 + .maxlen = sizeof(atomic_unchecked_t),
90420 .mode = 0644,
90421 .proc_handler = read_reset_stat,
90422 },
90423 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90424 index 0ce7552..d074459 100644
90425 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90426 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90427 @@ -501,7 +501,7 @@ next_sge:
90428 svc_rdma_put_context(ctxt, 0);
90429 goto out;
90430 }
90431 - atomic_inc(&rdma_stat_read);
90432 + atomic_inc_unchecked(&rdma_stat_read);
90433
90434 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90435 chl_map->ch[ch_no].count -= read_wr.num_sge;
90436 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90437 dto_q);
90438 list_del_init(&ctxt->dto_q);
90439 } else {
90440 - atomic_inc(&rdma_stat_rq_starve);
90441 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90442 clear_bit(XPT_DATA, &xprt->xpt_flags);
90443 ctxt = NULL;
90444 }
90445 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90446 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90447 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90448 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90449 - atomic_inc(&rdma_stat_recv);
90450 + atomic_inc_unchecked(&rdma_stat_recv);
90451
90452 /* Build up the XDR from the receive buffers. */
90453 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90454 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90455 index c1d124d..acfc59e 100644
90456 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90457 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90458 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90459 write_wr.wr.rdma.remote_addr = to;
90460
90461 /* Post It */
90462 - atomic_inc(&rdma_stat_write);
90463 + atomic_inc_unchecked(&rdma_stat_write);
90464 if (svc_rdma_send(xprt, &write_wr))
90465 goto err;
90466 return 0;
90467 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90468 index 62e4f9b..dd3f2d7 100644
90469 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90470 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90471 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90472 return;
90473
90474 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90475 - atomic_inc(&rdma_stat_rq_poll);
90476 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90477
90478 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90479 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90480 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90481 }
90482
90483 if (ctxt)
90484 - atomic_inc(&rdma_stat_rq_prod);
90485 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90486
90487 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90488 /*
90489 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90490 return;
90491
90492 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90493 - atomic_inc(&rdma_stat_sq_poll);
90494 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90495 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90496 if (wc.status != IB_WC_SUCCESS)
90497 /* Close the transport */
90498 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90499 }
90500
90501 if (ctxt)
90502 - atomic_inc(&rdma_stat_sq_prod);
90503 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90504 }
90505
90506 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90507 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90508 spin_lock_bh(&xprt->sc_lock);
90509 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90510 spin_unlock_bh(&xprt->sc_lock);
90511 - atomic_inc(&rdma_stat_sq_starve);
90512 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90513
90514 /* See if we can opportunistically reap SQ WR to make room */
90515 sq_cq_reap(xprt);
90516 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90517 index 9bc6db0..47ac8c0 100644
90518 --- a/net/sysctl_net.c
90519 +++ b/net/sysctl_net.c
90520 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90521 kgid_t root_gid = make_kgid(net->user_ns, 0);
90522
90523 /* Allow network administrator to have same access as root. */
90524 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90525 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90526 uid_eq(root_uid, current_uid())) {
90527 int mode = (table->mode >> 6) & 7;
90528 return (mode << 6) | (mode << 3) | mode;
90529 diff --git a/net/tipc/link.c b/net/tipc/link.c
90530 index daa6080..02d357f 100644
90531 --- a/net/tipc/link.c
90532 +++ b/net/tipc/link.c
90533 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90534 struct tipc_msg fragm_hdr;
90535 struct sk_buff *buf, *buf_chain, *prev;
90536 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90537 - const unchar *sect_crs;
90538 + const unchar __user *sect_crs;
90539 int curr_sect;
90540 u32 fragm_no;
90541
90542 @@ -1242,7 +1242,7 @@ again:
90543
90544 if (!sect_rest) {
90545 sect_rest = msg_sect[++curr_sect].iov_len;
90546 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90547 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90548 }
90549
90550 if (sect_rest < fragm_rest)
90551 @@ -1261,7 +1261,7 @@ error:
90552 }
90553 } else
90554 skb_copy_to_linear_data_offset(buf, fragm_crs,
90555 - sect_crs, sz);
90556 + (const void __force_kernel *)sect_crs, sz);
90557 sect_crs += sz;
90558 sect_rest -= sz;
90559 fragm_crs += sz;
90560 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90561 index f2db8a8..9245aa4 100644
90562 --- a/net/tipc/msg.c
90563 +++ b/net/tipc/msg.c
90564 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90565 msg_sect[cnt].iov_len);
90566 else
90567 skb_copy_to_linear_data_offset(*buf, pos,
90568 - msg_sect[cnt].iov_base,
90569 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90570 msg_sect[cnt].iov_len);
90571 pos += msg_sect[cnt].iov_len;
90572 }
90573 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90574 index 6b42d47..2ac24d5 100644
90575 --- a/net/tipc/subscr.c
90576 +++ b/net/tipc/subscr.c
90577 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90578 {
90579 struct iovec msg_sect;
90580
90581 - msg_sect.iov_base = (void *)&sub->evt;
90582 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90583 msg_sect.iov_len = sizeof(struct tipc_event);
90584
90585 sub->evt.event = htohl(event, sub->swap);
90586 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90587 index b45eb65..bb4b223 100644
90588 --- a/net/unix/af_unix.c
90589 +++ b/net/unix/af_unix.c
90590 @@ -785,6 +785,12 @@ static struct sock *unix_find_other(struct net *net,
90591 err = -ECONNREFUSED;
90592 if (!S_ISSOCK(inode->i_mode))
90593 goto put_fail;
90594 +
90595 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90596 + err = -EACCES;
90597 + goto put_fail;
90598 + }
90599 +
90600 u = unix_find_socket_byinode(inode);
90601 if (!u)
90602 goto put_fail;
90603 @@ -805,6 +811,13 @@ static struct sock *unix_find_other(struct net *net,
90604 if (u) {
90605 struct dentry *dentry;
90606 dentry = unix_sk(u)->path.dentry;
90607 +
90608 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90609 + err = -EPERM;
90610 + sock_put(u);
90611 + goto fail;
90612 + }
90613 +
90614 if (dentry)
90615 touch_atime(&unix_sk(u)->path);
90616 } else
90617 @@ -838,12 +851,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90618 */
90619 err = security_path_mknod(&path, dentry, mode, 0);
90620 if (!err) {
90621 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90622 + err = -EACCES;
90623 + goto out;
90624 + }
90625 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90626 if (!err) {
90627 res->mnt = mntget(path.mnt);
90628 res->dentry = dget(dentry);
90629 + gr_handle_create(dentry, path.mnt);
90630 }
90631 }
90632 +out:
90633 done_path_create(&path, dentry);
90634 return err;
90635 }
90636 @@ -1995,7 +2014,7 @@ again:
90637 if ((UNIXCB(skb).pid != siocb->scm->pid) ||
90638 (UNIXCB(skb).cred != siocb->scm->cred))
90639 break;
90640 - } else {
90641 + } else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
90642 /* Copy credentials */
90643 scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
90644 check_creds = 1;
90645 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90646 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90647 "Inode Path\n");
90648 else {
90649 - struct sock *s = v;
90650 + struct sock *s = v, *peer;
90651 struct unix_sock *u = unix_sk(s);
90652 unix_state_lock(s);
90653 + peer = unix_peer(s);
90654 + unix_state_unlock(s);
90655 +
90656 + unix_state_double_lock(s, peer);
90657
90658 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90659 s,
90660 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90661 }
90662 for ( ; i < len; i++)
90663 seq_putc(seq, u->addr->name->sun_path[i]);
90664 - }
90665 - unix_state_unlock(s);
90666 + } else if (peer)
90667 + seq_printf(seq, " P%lu", sock_i_ino(peer));
90668 +
90669 + unix_state_double_unlock(s, peer);
90670 seq_putc(seq, '\n');
90671 }
90672
90673 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
90674 index 8800604..0526440 100644
90675 --- a/net/unix/sysctl_net_unix.c
90676 +++ b/net/unix/sysctl_net_unix.c
90677 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
90678
90679 int __net_init unix_sysctl_register(struct net *net)
90680 {
90681 - struct ctl_table *table;
90682 + ctl_table_no_const *table;
90683
90684 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
90685 if (table == NULL)
90686 diff --git a/net/wireless/trace.h b/net/wireless/trace.h
90687 index 2134576..5d71a5a 100644
90688 --- a/net/wireless/trace.h
90689 +++ b/net/wireless/trace.h
90690 @@ -27,7 +27,8 @@
90691 #define WIPHY_PR_ARG __entry->wiphy_name
90692
90693 #define WDEV_ENTRY __field(u32, id)
90694 -#define WDEV_ASSIGN (__entry->id) = (wdev ? wdev->identifier : 0)
90695 +#define WDEV_ASSIGN (__entry->id) = (!IS_ERR_OR_NULL(wdev) \
90696 + ? wdev->identifier : 0)
90697 #define WDEV_PR_FMT "wdev(%u)"
90698 #define WDEV_PR_ARG (__entry->id)
90699
90700 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
90701 index c8717c1..08539f5 100644
90702 --- a/net/wireless/wext-core.c
90703 +++ b/net/wireless/wext-core.c
90704 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90705 */
90706
90707 /* Support for very large requests */
90708 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
90709 - (user_length > descr->max_tokens)) {
90710 + if (user_length > descr->max_tokens) {
90711 /* Allow userspace to GET more than max so
90712 * we can support any size GET requests.
90713 * There is still a limit : -ENOMEM.
90714 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90715 }
90716 }
90717
90718 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
90719 - /*
90720 - * If this is a GET, but not NOMAX, it means that the extra
90721 - * data is not bounded by userspace, but by max_tokens. Thus
90722 - * set the length to max_tokens. This matches the extra data
90723 - * allocation.
90724 - * The driver should fill it with the number of tokens it
90725 - * provided, and it may check iwp->length rather than having
90726 - * knowledge of max_tokens. If the driver doesn't change the
90727 - * iwp->length, this ioctl just copies back max_token tokens
90728 - * filled with zeroes. Hopefully the driver isn't claiming
90729 - * them to be valid data.
90730 - */
90731 - iwp->length = descr->max_tokens;
90732 - }
90733 -
90734 err = handler(dev, info, (union iwreq_data *) iwp, extra);
90735
90736 iwp->length += essid_compat;
90737 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
90738 index 07c5857..fde4018 100644
90739 --- a/net/xfrm/xfrm_policy.c
90740 +++ b/net/xfrm/xfrm_policy.c
90741 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
90742 {
90743 policy->walk.dead = 1;
90744
90745 - atomic_inc(&policy->genid);
90746 + atomic_inc_unchecked(&policy->genid);
90747
90748 if (del_timer(&policy->timer))
90749 xfrm_pol_put(policy);
90750 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
90751 hlist_add_head(&policy->bydst, chain);
90752 xfrm_pol_hold(policy);
90753 net->xfrm.policy_count[dir]++;
90754 - atomic_inc(&flow_cache_genid);
90755 + atomic_inc_unchecked(&flow_cache_genid);
90756 rt_genid_bump(net);
90757 if (delpol)
90758 __xfrm_policy_unlink(delpol, dir);
90759 @@ -1550,7 +1550,7 @@ free_dst:
90760 goto out;
90761 }
90762
90763 -static int inline
90764 +static inline int
90765 xfrm_dst_alloc_copy(void **target, const void *src, int size)
90766 {
90767 if (!*target) {
90768 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
90769 return 0;
90770 }
90771
90772 -static int inline
90773 +static inline int
90774 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90775 {
90776 #ifdef CONFIG_XFRM_SUB_POLICY
90777 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90778 #endif
90779 }
90780
90781 -static int inline
90782 +static inline int
90783 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
90784 {
90785 #ifdef CONFIG_XFRM_SUB_POLICY
90786 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
90787
90788 xdst->num_pols = num_pols;
90789 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
90790 - xdst->policy_genid = atomic_read(&pols[0]->genid);
90791 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
90792
90793 return xdst;
90794 }
90795 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
90796 if (xdst->xfrm_genid != dst->xfrm->genid)
90797 return 0;
90798 if (xdst->num_pols > 0 &&
90799 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
90800 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
90801 return 0;
90802
90803 mtu = dst_mtu(dst->child);
90804 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
90805 dst_ops->link_failure = xfrm_link_failure;
90806 if (likely(dst_ops->neigh_lookup == NULL))
90807 dst_ops->neigh_lookup = xfrm_neigh_lookup;
90808 - if (likely(afinfo->garbage_collect == NULL))
90809 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90810 + if (likely(afinfo->garbage_collect == NULL)) {
90811 + pax_open_kernel();
90812 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90813 + pax_close_kernel();
90814 + }
90815 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
90816 }
90817 spin_unlock(&xfrm_policy_afinfo_lock);
90818 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
90819 dst_ops->check = NULL;
90820 dst_ops->negative_advice = NULL;
90821 dst_ops->link_failure = NULL;
90822 - afinfo->garbage_collect = NULL;
90823 + pax_open_kernel();
90824 + *(void **)&afinfo->garbage_collect = NULL;
90825 + pax_close_kernel();
90826 }
90827 return err;
90828 }
90829 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
90830 sizeof(pol->xfrm_vec[i].saddr));
90831 pol->xfrm_vec[i].encap_family = mp->new_family;
90832 /* flush bundles */
90833 - atomic_inc(&pol->genid);
90834 + atomic_inc_unchecked(&pol->genid);
90835 }
90836 }
90837
90838 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
90839 index 3459692..e7cdb1a 100644
90840 --- a/net/xfrm/xfrm_state.c
90841 +++ b/net/xfrm/xfrm_state.c
90842 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
90843
90844 if (unlikely(afinfo == NULL))
90845 return -EAFNOSUPPORT;
90846 - typemap = afinfo->type_map;
90847 + typemap = (const struct xfrm_type **)afinfo->type_map;
90848
90849 - if (likely(typemap[type->proto] == NULL))
90850 + if (likely(typemap[type->proto] == NULL)) {
90851 + pax_open_kernel();
90852 typemap[type->proto] = type;
90853 - else
90854 + pax_close_kernel();
90855 + } else
90856 err = -EEXIST;
90857 xfrm_state_unlock_afinfo(afinfo);
90858 return err;
90859 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
90860
90861 if (unlikely(afinfo == NULL))
90862 return -EAFNOSUPPORT;
90863 - typemap = afinfo->type_map;
90864 + typemap = (const struct xfrm_type **)afinfo->type_map;
90865
90866 if (unlikely(typemap[type->proto] != type))
90867 err = -ENOENT;
90868 - else
90869 + else {
90870 + pax_open_kernel();
90871 typemap[type->proto] = NULL;
90872 + pax_close_kernel();
90873 + }
90874 xfrm_state_unlock_afinfo(afinfo);
90875 return err;
90876 }
90877 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
90878 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
90879 {
90880 struct xfrm_state_afinfo *afinfo;
90881 - const struct xfrm_type **typemap;
90882 const struct xfrm_type *type;
90883 int modload_attempted = 0;
90884
90885 @@ -235,9 +239,8 @@ retry:
90886 afinfo = xfrm_state_get_afinfo(family);
90887 if (unlikely(afinfo == NULL))
90888 return NULL;
90889 - typemap = afinfo->type_map;
90890
90891 - type = typemap[proto];
90892 + type = afinfo->type_map[proto];
90893 if (unlikely(type && !try_module_get(type->owner)))
90894 type = NULL;
90895 if (!type && !modload_attempted) {
90896 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90897 return -EAFNOSUPPORT;
90898
90899 err = -EEXIST;
90900 - modemap = afinfo->mode_map;
90901 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90902 if (modemap[mode->encap])
90903 goto out;
90904
90905 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90906 if (!try_module_get(afinfo->owner))
90907 goto out;
90908
90909 - mode->afinfo = afinfo;
90910 + pax_open_kernel();
90911 + *(const void **)&mode->afinfo = afinfo;
90912 modemap[mode->encap] = mode;
90913 + pax_close_kernel();
90914 err = 0;
90915
90916 out:
90917 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
90918 return -EAFNOSUPPORT;
90919
90920 err = -ENOENT;
90921 - modemap = afinfo->mode_map;
90922 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90923 if (likely(modemap[mode->encap] == mode)) {
90924 + pax_open_kernel();
90925 modemap[mode->encap] = NULL;
90926 + pax_close_kernel();
90927 module_put(mode->afinfo->owner);
90928 err = 0;
90929 }
90930 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
90931 index 05a6e3d..6716ec9 100644
90932 --- a/net/xfrm/xfrm_sysctl.c
90933 +++ b/net/xfrm/xfrm_sysctl.c
90934 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
90935
90936 int __net_init xfrm_sysctl_init(struct net *net)
90937 {
90938 - struct ctl_table *table;
90939 + ctl_table_no_const *table;
90940
90941 __xfrm_sysctl_init(net);
90942
90943 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
90944 index 0e801c3..5c8ad3b 100644
90945 --- a/scripts/Makefile.build
90946 +++ b/scripts/Makefile.build
90947 @@ -111,7 +111,7 @@ endif
90948 endif
90949
90950 # Do not include host rules unless needed
90951 -ifneq ($(hostprogs-y)$(hostprogs-m),)
90952 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
90953 include scripts/Makefile.host
90954 endif
90955
90956 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
90957 index 686cb0d..9d653bf 100644
90958 --- a/scripts/Makefile.clean
90959 +++ b/scripts/Makefile.clean
90960 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
90961 __clean-files := $(extra-y) $(always) \
90962 $(targets) $(clean-files) \
90963 $(host-progs) \
90964 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
90965 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
90966 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
90967
90968 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
90969
90970 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
90971 index 1ac414f..38575f7 100644
90972 --- a/scripts/Makefile.host
90973 +++ b/scripts/Makefile.host
90974 @@ -31,6 +31,8 @@
90975 # Note: Shared libraries consisting of C++ files are not supported
90976
90977 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
90978 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
90979 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
90980
90981 # C code
90982 # Executables compiled from a single .c file
90983 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
90984 # Shared libaries (only .c supported)
90985 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
90986 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
90987 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
90988 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
90989 # Remove .so files from "xxx-objs"
90990 host-cobjs := $(filter-out %.so,$(host-cobjs))
90991 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
90992
90993 -#Object (.o) files used by the shared libaries
90994 +# Object (.o) files used by the shared libaries
90995 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
90996 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
90997
90998 # output directory for programs/.o files
90999 # hostprogs-y := tools/build may have been specified. Retrieve directory
91000 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91001 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91002 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91003 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91004 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91005 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91006 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91007 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91008
91009 obj-dirs += $(host-objdirs)
91010 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91011 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91012 $(call if_changed_dep,host-cshobjs)
91013
91014 +# Compile .c file, create position independent .o file
91015 +# host-cxxshobjs -> .o
91016 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91017 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91018 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91019 + $(call if_changed_dep,host-cxxshobjs)
91020 +
91021 # Link a shared library, based on position independent .o files
91022 # *.o -> .so shared library (host-cshlib)
91023 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91024 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91025 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91026 $(call if_changed,host-cshlib)
91027
91028 +# Link a shared library, based on position independent .o files
91029 +# *.o -> .so shared library (host-cxxshlib)
91030 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91031 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91032 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91033 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91034 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91035 + $(call if_changed,host-cxxshlib)
91036 +
91037 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91038 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91039 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91040
91041 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91042 index cb1f50c..cef2a7c 100644
91043 --- a/scripts/basic/fixdep.c
91044 +++ b/scripts/basic/fixdep.c
91045 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91046 /*
91047 * Lookup a value in the configuration string.
91048 */
91049 -static int is_defined_config(const char *name, int len, unsigned int hash)
91050 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91051 {
91052 struct item *aux;
91053
91054 @@ -211,10 +211,10 @@ static void clear_config(void)
91055 /*
91056 * Record the use of a CONFIG_* word.
91057 */
91058 -static void use_config(const char *m, int slen)
91059 +static void use_config(const char *m, unsigned int slen)
91060 {
91061 unsigned int hash = strhash(m, slen);
91062 - int c, i;
91063 + unsigned int c, i;
91064
91065 if (is_defined_config(m, slen, hash))
91066 return;
91067 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91068
91069 static void parse_config_file(const char *map, size_t len)
91070 {
91071 - const int *end = (const int *) (map + len);
91072 + const unsigned int *end = (const unsigned int *) (map + len);
91073 /* start at +1, so that p can never be < map */
91074 - const int *m = (const int *) map + 1;
91075 + const unsigned int *m = (const unsigned int *) map + 1;
91076 const char *p, *q;
91077
91078 for (; m < end; m++) {
91079 @@ -406,7 +406,7 @@ static void print_deps(void)
91080 static void traps(void)
91081 {
91082 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91083 - int *p = (int *)test;
91084 + unsigned int *p = (unsigned int *)test;
91085
91086 if (*p != INT_CONF) {
91087 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
91088 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91089 new file mode 100644
91090 index 0000000..5e0222d
91091 --- /dev/null
91092 +++ b/scripts/gcc-plugin.sh
91093 @@ -0,0 +1,17 @@
91094 +#!/bin/bash
91095 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91096 +#include "gcc-plugin.h"
91097 +#include "tree.h"
91098 +#include "tm.h"
91099 +#include "rtl.h"
91100 +#ifdef ENABLE_BUILD_WITH_CXX
91101 +#warning $2
91102 +#else
91103 +#warning $1
91104 +#endif
91105 +EOF`
91106 +if [ $? -eq 0 ]
91107 +then
91108 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91109 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91110 +fi
91111 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
91112 index 581ca99..a6ff02e 100644
91113 --- a/scripts/headers_install.pl
91114 +++ b/scripts/headers_install.pl
91115 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
91116 $line =~ s/([\s(])__user\s/$1/g;
91117 $line =~ s/([\s(])__force\s/$1/g;
91118 $line =~ s/([\s(])__iomem\s/$1/g;
91119 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
91120 $line =~ s/\s__attribute_const__\s/ /g;
91121 $line =~ s/\s__attribute_const__$//g;
91122 $line =~ s/\b__packed\b/__attribute__((packed))/g;
91123 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91124 index b3d907e..a4782ab 100644
91125 --- a/scripts/link-vmlinux.sh
91126 +++ b/scripts/link-vmlinux.sh
91127 @@ -152,7 +152,7 @@ else
91128 fi;
91129
91130 # final build of init/
91131 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91132 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91133
91134 kallsymso=""
91135 kallsyms_vmlinux=""
91136 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91137 index df4fc23..0ea719d 100644
91138 --- a/scripts/mod/file2alias.c
91139 +++ b/scripts/mod/file2alias.c
91140 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
91141 unsigned long size, unsigned long id_size,
91142 void *symval)
91143 {
91144 - int i;
91145 + unsigned int i;
91146
91147 if (size % id_size || size < id_size) {
91148 if (cross_build != 0)
91149 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
91150 /* USB is special because the bcdDevice can be matched against a numeric range */
91151 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91152 static void do_usb_entry(struct usb_device_id *id,
91153 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91154 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91155 unsigned char range_lo, unsigned char range_hi,
91156 unsigned char max, struct module *mod)
91157 {
91158 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
91159 {
91160 unsigned int devlo, devhi;
91161 unsigned char chi, clo, max;
91162 - int ndigits;
91163 + unsigned int ndigits;
91164
91165 id->match_flags = TO_NATIVE(id->match_flags);
91166 id->idVendor = TO_NATIVE(id->idVendor);
91167 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91168 for (i = 0; i < count; i++) {
91169 const char *id = (char *)devs[i].id;
91170 char acpi_id[sizeof(devs[0].id)];
91171 - int j;
91172 + unsigned int j;
91173
91174 buf_printf(&mod->dev_table_buf,
91175 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91176 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91177
91178 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91179 const char *id = (char *)card->devs[j].id;
91180 - int i2, j2;
91181 + unsigned int i2, j2;
91182 int dup = 0;
91183
91184 if (!id[0])
91185 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91186 /* add an individual alias for every device entry */
91187 if (!dup) {
91188 char acpi_id[sizeof(card->devs[0].id)];
91189 - int k;
91190 + unsigned int k;
91191
91192 buf_printf(&mod->dev_table_buf,
91193 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91194 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91195 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
91196 char *alias)
91197 {
91198 - int i, j;
91199 + unsigned int i, j;
91200
91201 sprintf(alias, "dmi*");
91202
91203 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91204 index ff36c50..7ab4fa9 100644
91205 --- a/scripts/mod/modpost.c
91206 +++ b/scripts/mod/modpost.c
91207 @@ -929,6 +929,7 @@ enum mismatch {
91208 ANY_INIT_TO_ANY_EXIT,
91209 ANY_EXIT_TO_ANY_INIT,
91210 EXPORT_TO_INIT_EXIT,
91211 + DATA_TO_TEXT
91212 };
91213
91214 struct sectioncheck {
91215 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
91216 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91217 .mismatch = EXPORT_TO_INIT_EXIT,
91218 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91219 +},
91220 +/* Do not reference code from writable data */
91221 +{
91222 + .fromsec = { DATA_SECTIONS, NULL },
91223 + .tosec = { TEXT_SECTIONS, NULL },
91224 + .mismatch = DATA_TO_TEXT
91225 }
91226 };
91227
91228 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91229 continue;
91230 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91231 continue;
91232 - if (sym->st_value == addr)
91233 - return sym;
91234 /* Find a symbol nearby - addr are maybe negative */
91235 d = sym->st_value - addr;
91236 + if (d == 0)
91237 + return sym;
91238 if (d < 0)
91239 d = addr - sym->st_value;
91240 if (d < distance) {
91241 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
91242 tosym, prl_to, prl_to, tosym);
91243 free(prl_to);
91244 break;
91245 + case DATA_TO_TEXT:
91246 +#if 0
91247 + fprintf(stderr,
91248 + "The %s %s:%s references\n"
91249 + "the %s %s:%s%s\n",
91250 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91251 +#endif
91252 + break;
91253 }
91254 fprintf(stderr, "\n");
91255 }
91256 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91257 static void check_sec_ref(struct module *mod, const char *modname,
91258 struct elf_info *elf)
91259 {
91260 - int i;
91261 + unsigned int i;
91262 Elf_Shdr *sechdrs = elf->sechdrs;
91263
91264 /* Walk through all sections */
91265 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91266 va_end(ap);
91267 }
91268
91269 -void buf_write(struct buffer *buf, const char *s, int len)
91270 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91271 {
91272 if (buf->size - buf->pos < len) {
91273 buf->size += len + SZ;
91274 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91275 if (fstat(fileno(file), &st) < 0)
91276 goto close_write;
91277
91278 - if (st.st_size != b->pos)
91279 + if (st.st_size != (off_t)b->pos)
91280 goto close_write;
91281
91282 tmp = NOFAIL(malloc(b->pos));
91283 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91284 index 51207e4..f7d603d 100644
91285 --- a/scripts/mod/modpost.h
91286 +++ b/scripts/mod/modpost.h
91287 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91288
91289 struct buffer {
91290 char *p;
91291 - int pos;
91292 - int size;
91293 + unsigned int pos;
91294 + unsigned int size;
91295 };
91296
91297 void __attribute__((format(printf, 2, 3)))
91298 buf_printf(struct buffer *buf, const char *fmt, ...);
91299
91300 void
91301 -buf_write(struct buffer *buf, const char *s, int len);
91302 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91303
91304 struct module {
91305 struct module *next;
91306 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91307 index 9dfcd6d..099068e 100644
91308 --- a/scripts/mod/sumversion.c
91309 +++ b/scripts/mod/sumversion.c
91310 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
91311 goto out;
91312 }
91313
91314 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
91315 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
91316 warn("writing sum in %s failed: %s\n",
91317 filename, strerror(errno));
91318 goto out;
91319 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91320 index acb8650..b8c5f02 100644
91321 --- a/scripts/package/builddeb
91322 +++ b/scripts/package/builddeb
91323 @@ -246,6 +246,7 @@ fi
91324 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91325 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91326 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91327 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91328 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91329 mkdir -p "$destdir"
91330 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91331 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91332 index 68bb4ef..2f419e1 100644
91333 --- a/scripts/pnmtologo.c
91334 +++ b/scripts/pnmtologo.c
91335 @@ -244,14 +244,14 @@ static void write_header(void)
91336 fprintf(out, " * Linux logo %s\n", logoname);
91337 fputs(" */\n\n", out);
91338 fputs("#include <linux/linux_logo.h>\n\n", out);
91339 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91340 + fprintf(out, "static unsigned char %s_data[] = {\n",
91341 logoname);
91342 }
91343
91344 static void write_footer(void)
91345 {
91346 fputs("\n};\n\n", out);
91347 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91348 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91349 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91350 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91351 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91352 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91353 fputs("\n};\n\n", out);
91354
91355 /* write logo clut */
91356 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91357 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91358 logoname);
91359 write_hex_cnt = 0;
91360 for (i = 0; i < logo_clutsize; i++) {
91361 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91362 index e4fd45b..2eeb5c4 100644
91363 --- a/scripts/sortextable.h
91364 +++ b/scripts/sortextable.h
91365 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91366 const char *secstrtab;
91367 const char *strtab;
91368 char *extab_image;
91369 - int extab_index = 0;
91370 - int i;
91371 - int idx;
91372 + unsigned int extab_index = 0;
91373 + unsigned int i;
91374 + unsigned int idx;
91375
91376 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91377 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91378 diff --git a/security/Kconfig b/security/Kconfig
91379 index e9c6ac7..4cb4ecc 100644
91380 --- a/security/Kconfig
91381 +++ b/security/Kconfig
91382 @@ -4,6 +4,943 @@
91383
91384 menu "Security options"
91385
91386 +menu "Grsecurity"
91387 +
91388 + config ARCH_TRACK_EXEC_LIMIT
91389 + bool
91390 +
91391 + config PAX_KERNEXEC_PLUGIN
91392 + bool
91393 +
91394 + config PAX_PER_CPU_PGD
91395 + bool
91396 +
91397 + config TASK_SIZE_MAX_SHIFT
91398 + int
91399 + depends on X86_64
91400 + default 47 if !PAX_PER_CPU_PGD
91401 + default 42 if PAX_PER_CPU_PGD
91402 +
91403 + config PAX_ENABLE_PAE
91404 + bool
91405 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91406 +
91407 + config PAX_USERCOPY_SLABS
91408 + bool
91409 +
91410 +config GRKERNSEC
91411 + bool "Grsecurity"
91412 + select CRYPTO
91413 + select CRYPTO_SHA256
91414 + select PROC_FS
91415 + select STOP_MACHINE
91416 + help
91417 + If you say Y here, you will be able to configure many features
91418 + that will enhance the security of your system. It is highly
91419 + recommended that you say Y here and read through the help
91420 + for each option so that you fully understand the features and
91421 + can evaluate their usefulness for your machine.
91422 +
91423 +choice
91424 + prompt "Configuration Method"
91425 + depends on GRKERNSEC
91426 + default GRKERNSEC_CONFIG_CUSTOM
91427 + help
91428 +
91429 +config GRKERNSEC_CONFIG_AUTO
91430 + bool "Automatic"
91431 + help
91432 + If you choose this configuration method, you'll be able to answer a small
91433 + number of simple questions about how you plan to use this kernel.
91434 + The settings of grsecurity and PaX will be automatically configured for
91435 + the highest commonly-used settings within the provided constraints.
91436 +
91437 + If you require additional configuration, custom changes can still be made
91438 + from the "custom configuration" menu.
91439 +
91440 +config GRKERNSEC_CONFIG_CUSTOM
91441 + bool "Custom"
91442 + help
91443 + If you choose this configuration method, you'll be able to configure all
91444 + grsecurity and PaX settings manually. Via this method, no options are
91445 + automatically enabled.
91446 +
91447 +endchoice
91448 +
91449 +choice
91450 + prompt "Usage Type"
91451 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91452 + default GRKERNSEC_CONFIG_SERVER
91453 + help
91454 +
91455 +config GRKERNSEC_CONFIG_SERVER
91456 + bool "Server"
91457 + help
91458 + Choose this option if you plan to use this kernel on a server.
91459 +
91460 +config GRKERNSEC_CONFIG_DESKTOP
91461 + bool "Desktop"
91462 + help
91463 + Choose this option if you plan to use this kernel on a desktop.
91464 +
91465 +endchoice
91466 +
91467 +choice
91468 + prompt "Virtualization Type"
91469 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91470 + default GRKERNSEC_CONFIG_VIRT_NONE
91471 + help
91472 +
91473 +config GRKERNSEC_CONFIG_VIRT_NONE
91474 + bool "None"
91475 + help
91476 + Choose this option if this kernel will be run on bare metal.
91477 +
91478 +config GRKERNSEC_CONFIG_VIRT_GUEST
91479 + bool "Guest"
91480 + help
91481 + Choose this option if this kernel will be run as a VM guest.
91482 +
91483 +config GRKERNSEC_CONFIG_VIRT_HOST
91484 + bool "Host"
91485 + help
91486 + Choose this option if this kernel will be run as a VM host.
91487 +
91488 +endchoice
91489 +
91490 +choice
91491 + prompt "Virtualization Hardware"
91492 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91493 + help
91494 +
91495 +config GRKERNSEC_CONFIG_VIRT_EPT
91496 + bool "EPT/RVI Processor Support"
91497 + depends on X86
91498 + help
91499 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91500 + hardware virtualization. This allows for additional kernel hardening protections
91501 + to operate without additional performance impact.
91502 +
91503 + To see if your Intel processor supports EPT, see:
91504 + http://ark.intel.com/Products/VirtualizationTechnology
91505 + (Most Core i3/5/7 support EPT)
91506 +
91507 + To see if your AMD processor supports RVI, see:
91508 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91509 +
91510 +config GRKERNSEC_CONFIG_VIRT_SOFT
91511 + bool "First-gen/No Hardware Virtualization"
91512 + help
91513 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91514 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91515 +
91516 +endchoice
91517 +
91518 +choice
91519 + prompt "Virtualization Software"
91520 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91521 + help
91522 +
91523 +config GRKERNSEC_CONFIG_VIRT_XEN
91524 + bool "Xen"
91525 + help
91526 + Choose this option if this kernel is running as a Xen guest or host.
91527 +
91528 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91529 + bool "VMWare"
91530 + help
91531 + Choose this option if this kernel is running as a VMWare guest or host.
91532 +
91533 +config GRKERNSEC_CONFIG_VIRT_KVM
91534 + bool "KVM"
91535 + help
91536 + Choose this option if this kernel is running as a KVM guest or host.
91537 +
91538 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91539 + bool "VirtualBox"
91540 + help
91541 + Choose this option if this kernel is running as a VirtualBox guest or host.
91542 +
91543 +endchoice
91544 +
91545 +choice
91546 + prompt "Required Priorities"
91547 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91548 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91549 + help
91550 +
91551 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91552 + bool "Performance"
91553 + help
91554 + Choose this option if performance is of highest priority for this deployment
91555 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91556 + clearing of structures intended for userland, and freed memory sanitizing will
91557 + be disabled.
91558 +
91559 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91560 + bool "Security"
91561 + help
91562 + Choose this option if security is of highest priority for this deployment of
91563 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91564 + for userland, and freed memory sanitizing will be enabled for this kernel.
91565 + In a worst-case scenario, these features can introduce a 20% performance hit
91566 + (UDEREF on x64 contributing half of this hit).
91567 +
91568 +endchoice
91569 +
91570 +menu "Default Special Groups"
91571 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91572 +
91573 +config GRKERNSEC_PROC_GID
91574 + int "GID exempted from /proc restrictions"
91575 + default 1001
91576 + help
91577 + Setting this GID determines which group will be exempted from
91578 + grsecurity's /proc restrictions, allowing users of the specified
91579 + group to view network statistics and the existence of other users'
91580 + processes on the system. This GID may also be chosen at boot time
91581 + via "grsec_proc_gid=" on the kernel commandline.
91582 +
91583 +config GRKERNSEC_TPE_UNTRUSTED_GID
91584 + int "GID for TPE-untrusted users"
91585 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91586 + default 1005
91587 + help
91588 + Setting this GID determines which group untrusted users should
91589 + be added to. These users will be placed under grsecurity's Trusted Path
91590 + Execution mechanism, preventing them from executing their own binaries.
91591 + The users will only be able to execute binaries in directories owned and
91592 + writable only by the root user. If the sysctl option is enabled, a sysctl
91593 + option with name "tpe_gid" is created.
91594 +
91595 +config GRKERNSEC_TPE_TRUSTED_GID
91596 + int "GID for TPE-trusted users"
91597 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91598 + default 1005
91599 + help
91600 + Setting this GID determines what group TPE restrictions will be
91601 + *disabled* for. If the sysctl option is enabled, a sysctl option
91602 + with name "tpe_gid" is created.
91603 +
91604 +config GRKERNSEC_SYMLINKOWN_GID
91605 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91606 + depends on GRKERNSEC_CONFIG_SERVER
91607 + default 1006
91608 + help
91609 + Setting this GID determines what group kernel-enforced
91610 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91611 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91612 +
91613 +
91614 +endmenu
91615 +
91616 +menu "Customize Configuration"
91617 +depends on GRKERNSEC
91618 +
91619 +menu "PaX"
91620 +
91621 +config PAX
91622 + bool "Enable various PaX features"
91623 + default y if GRKERNSEC_CONFIG_AUTO
91624 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91625 + help
91626 + This allows you to enable various PaX features. PaX adds
91627 + intrusion prevention mechanisms to the kernel that reduce
91628 + the risks posed by exploitable memory corruption bugs.
91629 +
91630 +menu "PaX Control"
91631 + depends on PAX
91632 +
91633 +config PAX_SOFTMODE
91634 + bool 'Support soft mode'
91635 + help
91636 + Enabling this option will allow you to run PaX in soft mode, that
91637 + is, PaX features will not be enforced by default, only on executables
91638 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91639 + support as they are the only way to mark executables for soft mode use.
91640 +
91641 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91642 + line option on boot. Furthermore you can control various PaX features
91643 + at runtime via the entries in /proc/sys/kernel/pax.
91644 +
91645 +config PAX_EI_PAX
91646 + bool 'Use legacy ELF header marking'
91647 + default y if GRKERNSEC_CONFIG_AUTO
91648 + help
91649 + Enabling this option will allow you to control PaX features on
91650 + a per executable basis via the 'chpax' utility available at
91651 + http://pax.grsecurity.net/. The control flags will be read from
91652 + an otherwise reserved part of the ELF header. This marking has
91653 + numerous drawbacks (no support for soft-mode, toolchain does not
91654 + know about the non-standard use of the ELF header) therefore it
91655 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91656 + support.
91657 +
91658 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91659 + support as well, they will override the legacy EI_PAX marks.
91660 +
91661 + If you enable none of the marking options then all applications
91662 + will run with PaX enabled on them by default.
91663 +
91664 +config PAX_PT_PAX_FLAGS
91665 + bool 'Use ELF program header marking'
91666 + default y if GRKERNSEC_CONFIG_AUTO
91667 + help
91668 + Enabling this option will allow you to control PaX features on
91669 + a per executable basis via the 'paxctl' utility available at
91670 + http://pax.grsecurity.net/. The control flags will be read from
91671 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
91672 + has the benefits of supporting both soft mode and being fully
91673 + integrated into the toolchain (the binutils patch is available
91674 + from http://pax.grsecurity.net).
91675 +
91676 + Note that if you enable the legacy EI_PAX marking support as well,
91677 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
91678 +
91679 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91680 + must make sure that the marks are the same if a binary has both marks.
91681 +
91682 + If you enable none of the marking options then all applications
91683 + will run with PaX enabled on them by default.
91684 +
91685 +config PAX_XATTR_PAX_FLAGS
91686 + bool 'Use filesystem extended attributes marking'
91687 + default y if GRKERNSEC_CONFIG_AUTO
91688 + select CIFS_XATTR if CIFS
91689 + select EXT2_FS_XATTR if EXT2_FS
91690 + select EXT3_FS_XATTR if EXT3_FS
91691 + select EXT4_FS_XATTR if EXT4_FS
91692 + select JFFS2_FS_XATTR if JFFS2_FS
91693 + select REISERFS_FS_XATTR if REISERFS_FS
91694 + select SQUASHFS_XATTR if SQUASHFS
91695 + select TMPFS_XATTR if TMPFS
91696 + select UBIFS_FS_XATTR if UBIFS_FS
91697 + help
91698 + Enabling this option will allow you to control PaX features on
91699 + a per executable basis via the 'setfattr' utility. The control
91700 + flags will be read from the user.pax.flags extended attribute of
91701 + the file. This marking has the benefit of supporting binary-only
91702 + applications that self-check themselves (e.g., skype) and would
91703 + not tolerate chpax/paxctl changes. The main drawback is that
91704 + extended attributes are not supported by some filesystems (e.g.,
91705 + isofs, udf, vfat) so copying files through such filesystems will
91706 + lose the extended attributes and these PaX markings.
91707 +
91708 + Note that if you enable the legacy EI_PAX marking support as well,
91709 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
91710 +
91711 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91712 + must make sure that the marks are the same if a binary has both marks.
91713 +
91714 + If you enable none of the marking options then all applications
91715 + will run with PaX enabled on them by default.
91716 +
91717 +choice
91718 + prompt 'MAC system integration'
91719 + default PAX_HAVE_ACL_FLAGS
91720 + help
91721 + Mandatory Access Control systems have the option of controlling
91722 + PaX flags on a per executable basis, choose the method supported
91723 + by your particular system.
91724 +
91725 + - "none": if your MAC system does not interact with PaX,
91726 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
91727 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
91728 +
91729 + NOTE: this option is for developers/integrators only.
91730 +
91731 + config PAX_NO_ACL_FLAGS
91732 + bool 'none'
91733 +
91734 + config PAX_HAVE_ACL_FLAGS
91735 + bool 'direct'
91736 +
91737 + config PAX_HOOK_ACL_FLAGS
91738 + bool 'hook'
91739 +endchoice
91740 +
91741 +endmenu
91742 +
91743 +menu "Non-executable pages"
91744 + depends on PAX
91745 +
91746 +config PAX_NOEXEC
91747 + bool "Enforce non-executable pages"
91748 + default y if GRKERNSEC_CONFIG_AUTO
91749 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
91750 + help
91751 + By design some architectures do not allow for protecting memory
91752 + pages against execution or even if they do, Linux does not make
91753 + use of this feature. In practice this means that if a page is
91754 + readable (such as the stack or heap) it is also executable.
91755 +
91756 + There is a well known exploit technique that makes use of this
91757 + fact and a common programming mistake where an attacker can
91758 + introduce code of his choice somewhere in the attacked program's
91759 + memory (typically the stack or the heap) and then execute it.
91760 +
91761 + If the attacked program was running with different (typically
91762 + higher) privileges than that of the attacker, then he can elevate
91763 + his own privilege level (e.g. get a root shell, write to files for
91764 + which he does not have write access to, etc).
91765 +
91766 + Enabling this option will let you choose from various features
91767 + that prevent the injection and execution of 'foreign' code in
91768 + a program.
91769 +
91770 + This will also break programs that rely on the old behaviour and
91771 + expect that dynamically allocated memory via the malloc() family
91772 + of functions is executable (which it is not). Notable examples
91773 + are the XFree86 4.x server, the java runtime and wine.
91774 +
91775 +config PAX_PAGEEXEC
91776 + bool "Paging based non-executable pages"
91777 + default y if GRKERNSEC_CONFIG_AUTO
91778 + 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)
91779 + select S390_SWITCH_AMODE if S390
91780 + select S390_EXEC_PROTECT if S390
91781 + select ARCH_TRACK_EXEC_LIMIT if X86_32
91782 + help
91783 + This implementation is based on the paging feature of the CPU.
91784 + On i386 without hardware non-executable bit support there is a
91785 + variable but usually low performance impact, however on Intel's
91786 + P4 core based CPUs it is very high so you should not enable this
91787 + for kernels meant to be used on such CPUs.
91788 +
91789 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
91790 + with hardware non-executable bit support there is no performance
91791 + impact, on ppc the impact is negligible.
91792 +
91793 + Note that several architectures require various emulations due to
91794 + badly designed userland ABIs, this will cause a performance impact
91795 + but will disappear as soon as userland is fixed. For example, ppc
91796 + userland MUST have been built with secure-plt by a recent toolchain.
91797 +
91798 +config PAX_SEGMEXEC
91799 + bool "Segmentation based non-executable pages"
91800 + default y if GRKERNSEC_CONFIG_AUTO
91801 + depends on PAX_NOEXEC && X86_32
91802 + help
91803 + This implementation is based on the segmentation feature of the
91804 + CPU and has a very small performance impact, however applications
91805 + will be limited to a 1.5 GB address space instead of the normal
91806 + 3 GB.
91807 +
91808 +config PAX_EMUTRAMP
91809 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
91810 + default y if PARISC
91811 + help
91812 + There are some programs and libraries that for one reason or
91813 + another attempt to execute special small code snippets from
91814 + non-executable memory pages. Most notable examples are the
91815 + signal handler return code generated by the kernel itself and
91816 + the GCC trampolines.
91817 +
91818 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
91819 + such programs will no longer work under your kernel.
91820 +
91821 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
91822 + utilities to enable trampoline emulation for the affected programs
91823 + yet still have the protection provided by the non-executable pages.
91824 +
91825 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
91826 + your system will not even boot.
91827 +
91828 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
91829 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
91830 + for the affected files.
91831 +
91832 + NOTE: enabling this feature *may* open up a loophole in the
91833 + protection provided by non-executable pages that an attacker
91834 + could abuse. Therefore the best solution is to not have any
91835 + files on your system that would require this option. This can
91836 + be achieved by not using libc5 (which relies on the kernel
91837 + signal handler return code) and not using or rewriting programs
91838 + that make use of the nested function implementation of GCC.
91839 + Skilled users can just fix GCC itself so that it implements
91840 + nested function calls in a way that does not interfere with PaX.
91841 +
91842 +config PAX_EMUSIGRT
91843 + bool "Automatically emulate sigreturn trampolines"
91844 + depends on PAX_EMUTRAMP && PARISC
91845 + default y
91846 + help
91847 + Enabling this option will have the kernel automatically detect
91848 + and emulate signal return trampolines executing on the stack
91849 + that would otherwise lead to task termination.
91850 +
91851 + This solution is intended as a temporary one for users with
91852 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
91853 + Modula-3 runtime, etc) or executables linked to such, basically
91854 + everything that does not specify its own SA_RESTORER function in
91855 + normal executable memory like glibc 2.1+ does.
91856 +
91857 + On parisc you MUST enable this option, otherwise your system will
91858 + not even boot.
91859 +
91860 + NOTE: this feature cannot be disabled on a per executable basis
91861 + and since it *does* open up a loophole in the protection provided
91862 + by non-executable pages, the best solution is to not have any
91863 + files on your system that would require this option.
91864 +
91865 +config PAX_MPROTECT
91866 + bool "Restrict mprotect()"
91867 + default y if GRKERNSEC_CONFIG_AUTO
91868 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
91869 + help
91870 + Enabling this option will prevent programs from
91871 + - changing the executable status of memory pages that were
91872 + not originally created as executable,
91873 + - making read-only executable pages writable again,
91874 + - creating executable pages from anonymous memory,
91875 + - making read-only-after-relocations (RELRO) data pages writable again.
91876 +
91877 + You should say Y here to complete the protection provided by
91878 + the enforcement of non-executable pages.
91879 +
91880 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91881 + this feature on a per file basis.
91882 +
91883 +config PAX_MPROTECT_COMPAT
91884 + bool "Use legacy/compat protection demoting (read help)"
91885 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91886 + depends on PAX_MPROTECT
91887 + help
91888 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
91889 + by sending the proper error code to the application. For some broken
91890 + userland, this can cause problems with Python or other applications. The
91891 + current implementation however allows for applications like clamav to
91892 + detect if JIT compilation/execution is allowed and to fall back gracefully
91893 + to an interpreter-based mode if it does not. While we encourage everyone
91894 + to use the current implementation as-is and push upstream to fix broken
91895 + userland (note that the RWX logging option can assist with this), in some
91896 + environments this may not be possible. Having to disable MPROTECT
91897 + completely on certain binaries reduces the security benefit of PaX,
91898 + so this option is provided for those environments to revert to the old
91899 + behavior.
91900 +
91901 +config PAX_ELFRELOCS
91902 + bool "Allow ELF text relocations (read help)"
91903 + depends on PAX_MPROTECT
91904 + default n
91905 + help
91906 + Non-executable pages and mprotect() restrictions are effective
91907 + in preventing the introduction of new executable code into an
91908 + attacked task's address space. There remain only two venues
91909 + for this kind of attack: if the attacker can execute already
91910 + existing code in the attacked task then he can either have it
91911 + create and mmap() a file containing his code or have it mmap()
91912 + an already existing ELF library that does not have position
91913 + independent code in it and use mprotect() on it to make it
91914 + writable and copy his code there. While protecting against
91915 + the former approach is beyond PaX, the latter can be prevented
91916 + by having only PIC ELF libraries on one's system (which do not
91917 + need to relocate their code). If you are sure this is your case,
91918 + as is the case with all modern Linux distributions, then leave
91919 + this option disabled. You should say 'n' here.
91920 +
91921 +config PAX_ETEXECRELOCS
91922 + bool "Allow ELF ET_EXEC text relocations"
91923 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
91924 + select PAX_ELFRELOCS
91925 + default y
91926 + help
91927 + On some architectures there are incorrectly created applications
91928 + that require text relocations and would not work without enabling
91929 + this option. If you are an alpha, ia64 or parisc user, you should
91930 + enable this option and disable it once you have made sure that
91931 + none of your applications need it.
91932 +
91933 +config PAX_EMUPLT
91934 + bool "Automatically emulate ELF PLT"
91935 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
91936 + default y
91937 + help
91938 + Enabling this option will have the kernel automatically detect
91939 + and emulate the Procedure Linkage Table entries in ELF files.
91940 + On some architectures such entries are in writable memory, and
91941 + become non-executable leading to task termination. Therefore
91942 + it is mandatory that you enable this option on alpha, parisc,
91943 + sparc and sparc64, otherwise your system would not even boot.
91944 +
91945 + NOTE: this feature *does* open up a loophole in the protection
91946 + provided by the non-executable pages, therefore the proper
91947 + solution is to modify the toolchain to produce a PLT that does
91948 + not need to be writable.
91949 +
91950 +config PAX_DLRESOLVE
91951 + bool 'Emulate old glibc resolver stub'
91952 + depends on PAX_EMUPLT && SPARC
91953 + default n
91954 + help
91955 + This option is needed if userland has an old glibc (before 2.4)
91956 + that puts a 'save' instruction into the runtime generated resolver
91957 + stub that needs special emulation.
91958 +
91959 +config PAX_KERNEXEC
91960 + bool "Enforce non-executable kernel pages"
91961 + 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))
91962 + depends on ((X86 && (!X86_32 || X86_WP_WORKS_OK)) || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
91963 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
91964 + select PAX_KERNEXEC_PLUGIN if X86_64
91965 + help
91966 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
91967 + that is, enabling this option will make it harder to inject
91968 + and execute 'foreign' code in kernel memory itself.
91969 +
91970 +choice
91971 + prompt "Return Address Instrumentation Method"
91972 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
91973 + depends on PAX_KERNEXEC_PLUGIN
91974 + help
91975 + Select the method used to instrument function pointer dereferences.
91976 + Note that binary modules cannot be instrumented by this approach.
91977 +
91978 + Note that the implementation requires a gcc with plugin support,
91979 + i.e., gcc 4.5 or newer. You may need to install the supporting
91980 + headers explicitly in addition to the normal gcc package.
91981 +
91982 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
91983 + bool "bts"
91984 + help
91985 + This method is compatible with binary only modules but has
91986 + a higher runtime overhead.
91987 +
91988 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
91989 + bool "or"
91990 + depends on !PARAVIRT
91991 + help
91992 + This method is incompatible with binary only modules but has
91993 + a lower runtime overhead.
91994 +endchoice
91995 +
91996 +config PAX_KERNEXEC_PLUGIN_METHOD
91997 + string
91998 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
91999 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92000 + default ""
92001 +
92002 +config PAX_KERNEXEC_MODULE_TEXT
92003 + int "Minimum amount of memory reserved for module code"
92004 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92005 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92006 + depends on PAX_KERNEXEC && X86_32 && MODULES
92007 + help
92008 + Due to implementation details the kernel must reserve a fixed
92009 + amount of memory for module code at compile time that cannot be
92010 + changed at runtime. Here you can specify the minimum amount
92011 + in MB that will be reserved. Due to the same implementation
92012 + details this size will always be rounded up to the next 2/4 MB
92013 + boundary (depends on PAE) so the actually available memory for
92014 + module code will usually be more than this minimum.
92015 +
92016 + The default 4 MB should be enough for most users but if you have
92017 + an excessive number of modules (e.g., most distribution configs
92018 + compile many drivers as modules) or use huge modules such as
92019 + nvidia's kernel driver, you will need to adjust this amount.
92020 + A good rule of thumb is to look at your currently loaded kernel
92021 + modules and add up their sizes.
92022 +
92023 +endmenu
92024 +
92025 +menu "Address Space Layout Randomization"
92026 + depends on PAX
92027 +
92028 +config PAX_ASLR
92029 + bool "Address Space Layout Randomization"
92030 + default y if GRKERNSEC_CONFIG_AUTO
92031 + help
92032 + Many if not most exploit techniques rely on the knowledge of
92033 + certain addresses in the attacked program. The following options
92034 + will allow the kernel to apply a certain amount of randomization
92035 + to specific parts of the program thereby forcing an attacker to
92036 + guess them in most cases. Any failed guess will most likely crash
92037 + the attacked program which allows the kernel to detect such attempts
92038 + and react on them. PaX itself provides no reaction mechanisms,
92039 + instead it is strongly encouraged that you make use of Nergal's
92040 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92041 + (http://www.grsecurity.net/) built-in crash detection features or
92042 + develop one yourself.
92043 +
92044 + By saying Y here you can choose to randomize the following areas:
92045 + - top of the task's kernel stack
92046 + - top of the task's userland stack
92047 + - base address for mmap() requests that do not specify one
92048 + (this includes all libraries)
92049 + - base address of the main executable
92050 +
92051 + It is strongly recommended to say Y here as address space layout
92052 + randomization has negligible impact on performance yet it provides
92053 + a very effective protection.
92054 +
92055 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92056 + this feature on a per file basis.
92057 +
92058 +config PAX_RANDKSTACK
92059 + bool "Randomize kernel stack base"
92060 + default y if GRKERNSEC_CONFIG_AUTO
92061 + depends on X86_TSC && X86
92062 + help
92063 + By saying Y here the kernel will randomize every task's kernel
92064 + stack on every system call. This will not only force an attacker
92065 + to guess it but also prevent him from making use of possible
92066 + leaked information about it.
92067 +
92068 + Since the kernel stack is a rather scarce resource, randomization
92069 + may cause unexpected stack overflows, therefore you should very
92070 + carefully test your system. Note that once enabled in the kernel
92071 + configuration, this feature cannot be disabled on a per file basis.
92072 +
92073 +config PAX_RANDUSTACK
92074 + bool "Randomize user stack base"
92075 + default y if GRKERNSEC_CONFIG_AUTO
92076 + depends on PAX_ASLR
92077 + help
92078 + By saying Y here the kernel will randomize every task's userland
92079 + stack. The randomization is done in two steps where the second
92080 + one may apply a big amount of shift to the top of the stack and
92081 + cause problems for programs that want to use lots of memory (more
92082 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92083 + For this reason the second step can be controlled by 'chpax' or
92084 + 'paxctl' on a per file basis.
92085 +
92086 +config PAX_RANDMMAP
92087 + bool "Randomize mmap() base"
92088 + default y if GRKERNSEC_CONFIG_AUTO
92089 + depends on PAX_ASLR
92090 + help
92091 + By saying Y here the kernel will use a randomized base address for
92092 + mmap() requests that do not specify one themselves. As a result
92093 + all dynamically loaded libraries will appear at random addresses
92094 + and therefore be harder to exploit by a technique where an attacker
92095 + attempts to execute library code for his purposes (e.g. spawn a
92096 + shell from an exploited program that is running at an elevated
92097 + privilege level).
92098 +
92099 + Furthermore, if a program is relinked as a dynamic ELF file, its
92100 + base address will be randomized as well, completing the full
92101 + randomization of the address space layout. Attacking such programs
92102 + becomes a guess game. You can find an example of doing this at
92103 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92104 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92105 +
92106 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92107 + feature on a per file basis.
92108 +
92109 +endmenu
92110 +
92111 +menu "Miscellaneous hardening features"
92112 +
92113 +config PAX_MEMORY_SANITIZE
92114 + bool "Sanitize all freed memory"
92115 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92116 + depends on !HIBERNATION
92117 + help
92118 + By saying Y here the kernel will erase memory pages as soon as they
92119 + are freed. This in turn reduces the lifetime of data stored in the
92120 + pages, making it less likely that sensitive information such as
92121 + passwords, cryptographic secrets, etc stay in memory for too long.
92122 +
92123 + This is especially useful for programs whose runtime is short, long
92124 + lived processes and the kernel itself benefit from this as long as
92125 + they operate on whole memory pages and ensure timely freeing of pages
92126 + that may hold sensitive information.
92127 +
92128 + The tradeoff is performance impact, on a single CPU system kernel
92129 + compilation sees a 3% slowdown, other systems and workloads may vary
92130 + and you are advised to test this feature on your expected workload
92131 + before deploying it.
92132 +
92133 + Note that this feature does not protect data stored in live pages,
92134 + e.g., process memory swapped to disk may stay there for a long time.
92135 +
92136 +config PAX_MEMORY_STACKLEAK
92137 + bool "Sanitize kernel stack"
92138 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92139 + depends on X86
92140 + help
92141 + By saying Y here the kernel will erase the kernel stack before it
92142 + returns from a system call. This in turn reduces the information
92143 + that a kernel stack leak bug can reveal.
92144 +
92145 + Note that such a bug can still leak information that was put on
92146 + the stack by the current system call (the one eventually triggering
92147 + the bug) but traces of earlier system calls on the kernel stack
92148 + cannot leak anymore.
92149 +
92150 + The tradeoff is performance impact: on a single CPU system kernel
92151 + compilation sees a 1% slowdown, other systems and workloads may vary
92152 + and you are advised to test this feature on your expected workload
92153 + before deploying it.
92154 +
92155 + Note that the full feature requires a gcc with plugin support,
92156 + i.e., gcc 4.5 or newer. You may need to install the supporting
92157 + headers explicitly in addition to the normal gcc package. Using
92158 + older gcc versions means that functions with large enough stack
92159 + frames may leave uninitialized memory behind that may be exposed
92160 + to a later syscall leaking the stack.
92161 +
92162 +config PAX_MEMORY_STRUCTLEAK
92163 + bool "Forcibly initialize local variables copied to userland"
92164 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92165 + help
92166 + By saying Y here the kernel will zero initialize some local
92167 + variables that are going to be copied to userland. This in
92168 + turn prevents unintended information leakage from the kernel
92169 + stack should later code forget to explicitly set all parts of
92170 + the copied variable.
92171 +
92172 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92173 + at a much smaller coverage.
92174 +
92175 + Note that the implementation requires a gcc with plugin support,
92176 + i.e., gcc 4.5 or newer. You may need to install the supporting
92177 + headers explicitly in addition to the normal gcc package.
92178 +
92179 +config PAX_MEMORY_UDEREF
92180 + bool "Prevent invalid userland pointer dereference"
92181 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92182 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92183 + select PAX_PER_CPU_PGD if X86_64
92184 + help
92185 + By saying Y here the kernel will be prevented from dereferencing
92186 + userland pointers in contexts where the kernel expects only kernel
92187 + pointers. This is both a useful runtime debugging feature and a
92188 + security measure that prevents exploiting a class of kernel bugs.
92189 +
92190 + The tradeoff is that some virtualization solutions may experience
92191 + a huge slowdown and therefore you should not enable this feature
92192 + for kernels meant to run in such environments. Whether a given VM
92193 + solution is affected or not is best determined by simply trying it
92194 + out, the performance impact will be obvious right on boot as this
92195 + mechanism engages from very early on. A good rule of thumb is that
92196 + VMs running on CPUs without hardware virtualization support (i.e.,
92197 + the majority of IA-32 CPUs) will likely experience the slowdown.
92198 +
92199 +config PAX_REFCOUNT
92200 + bool "Prevent various kernel object reference counter overflows"
92201 + default y if GRKERNSEC_CONFIG_AUTO
92202 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92203 + help
92204 + By saying Y here the kernel will detect and prevent overflowing
92205 + various (but not all) kinds of object reference counters. Such
92206 + overflows can normally occur due to bugs only and are often, if
92207 + not always, exploitable.
92208 +
92209 + The tradeoff is that data structures protected by an overflowed
92210 + refcount will never be freed and therefore will leak memory. Note
92211 + that this leak also happens even without this protection but in
92212 + that case the overflow can eventually trigger the freeing of the
92213 + data structure while it is still being used elsewhere, resulting
92214 + in the exploitable situation that this feature prevents.
92215 +
92216 + Since this has a negligible performance impact, you should enable
92217 + this feature.
92218 +
92219 +config PAX_CONSTIFY_PLUGIN
92220 + bool "Automatically constify eligible structures"
92221 + default y
92222 + depends on !UML && PAX_KERNEXEC
92223 + help
92224 + By saying Y here the compiler will automatically constify a class
92225 + of types that contain only function pointers. This reduces the
92226 + kernel's attack surface and also produces a better memory layout.
92227 +
92228 + Note that the implementation requires a gcc with plugin support,
92229 + i.e., gcc 4.5 or newer. You may need to install the supporting
92230 + headers explicitly in addition to the normal gcc package.
92231 +
92232 + Note that if some code really has to modify constified variables
92233 + then the source code will have to be patched to allow it. Examples
92234 + can be found in PaX itself (the no_const attribute) and for some
92235 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92236 +
92237 +config PAX_USERCOPY
92238 + bool "Harden heap object copies between kernel and userland"
92239 + default y if GRKERNSEC_CONFIG_AUTO
92240 + depends on ARM || IA64 || PPC || SPARC || X86
92241 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92242 + select PAX_USERCOPY_SLABS
92243 + help
92244 + By saying Y here the kernel will enforce the size of heap objects
92245 + when they are copied in either direction between the kernel and
92246 + userland, even if only a part of the heap object is copied.
92247 +
92248 + Specifically, this checking prevents information leaking from the
92249 + kernel heap during kernel to userland copies (if the kernel heap
92250 + object is otherwise fully initialized) and prevents kernel heap
92251 + overflows during userland to kernel copies.
92252 +
92253 + Note that the current implementation provides the strictest bounds
92254 + checks for the SLUB allocator.
92255 +
92256 + Enabling this option also enables per-slab cache protection against
92257 + data in a given cache being copied into/out of via userland
92258 + accessors. Though the whitelist of regions will be reduced over
92259 + time, it notably protects important data structures like task structs.
92260 +
92261 + If frame pointers are enabled on x86, this option will also restrict
92262 + copies into and out of the kernel stack to local variables within a
92263 + single frame.
92264 +
92265 + Since this has a negligible performance impact, you should enable
92266 + this feature.
92267 +
92268 +config PAX_USERCOPY_DEBUG
92269 + bool
92270 + depends on X86 && PAX_USERCOPY
92271 + default n
92272 +
92273 +config PAX_SIZE_OVERFLOW
92274 + bool "Prevent various integer overflows in function size parameters"
92275 + default y if GRKERNSEC_CONFIG_AUTO
92276 + depends on X86
92277 + help
92278 + By saying Y here the kernel recomputes expressions of function
92279 + arguments marked by a size_overflow attribute with double integer
92280 + precision (DImode/TImode for 32/64 bit integer types).
92281 +
92282 + The recomputed argument is checked against TYPE_MAX and an event
92283 + is logged on overflow and the triggering process is killed.
92284 +
92285 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92286 +
92287 + Note that the implementation requires a gcc with plugin support,
92288 + i.e., gcc 4.5 or newer. You may need to install the supporting
92289 + headers explicitly in addition to the normal gcc package.
92290 +
92291 +config PAX_LATENT_ENTROPY
92292 + bool "Generate some entropy during boot"
92293 + default y if GRKERNSEC_CONFIG_AUTO
92294 + help
92295 + By saying Y here the kernel will instrument early boot code to
92296 + extract some entropy from both original and artificially created
92297 + program state. This will help especially embedded systems where
92298 + there is little 'natural' source of entropy normally. The cost
92299 + is some slowdown of the boot process.
92300 +
92301 + When pax_extra_latent_entropy is passed on the kernel command line,
92302 + entropy will be extracted from up to the first 4GB of RAM while the
92303 + runtime memory allocator is being initialized. This costs even more
92304 + slowdown of the boot process.
92305 +
92306 + Note that the implementation requires a gcc with plugin support,
92307 + i.e., gcc 4.5 or newer. You may need to install the supporting
92308 + headers explicitly in addition to the normal gcc package.
92309 +
92310 + Note that entropy extracted this way is not cryptographically
92311 + secure!
92312 +
92313 +endmenu
92314 +
92315 +endmenu
92316 +
92317 +source grsecurity/Kconfig
92318 +
92319 +endmenu
92320 +
92321 +endmenu
92322 +
92323 source security/keys/Kconfig
92324
92325 config SECURITY_DMESG_RESTRICT
92326 @@ -103,7 +1040,7 @@ config INTEL_TXT
92327 config LSM_MMAP_MIN_ADDR
92328 int "Low address space for LSM to protect from user allocation"
92329 depends on SECURITY && SECURITY_SELINUX
92330 - default 32768 if ARM
92331 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92332 default 65536
92333 help
92334 This is the portion of low virtual memory which should be protected
92335 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92336 index 8c2a7f6..b133ac9 100644
92337 --- a/security/apparmor/lsm.c
92338 +++ b/security/apparmor/lsm.c
92339 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92340 return error;
92341 }
92342
92343 -static struct security_operations apparmor_ops = {
92344 +static struct security_operations apparmor_ops __read_only = {
92345 .name = "apparmor",
92346
92347 .ptrace_access_check = apparmor_ptrace_access_check,
92348 diff --git a/security/commoncap.c b/security/commoncap.c
92349 index 7ee08c7..8d1a9d6 100644
92350 --- a/security/commoncap.c
92351 +++ b/security/commoncap.c
92352 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92353 return 0;
92354 }
92355
92356 +/* returns:
92357 + 1 for suid privilege
92358 + 2 for sgid privilege
92359 + 3 for fscap privilege
92360 +*/
92361 +int is_privileged_binary(const struct dentry *dentry)
92362 +{
92363 + struct cpu_vfs_cap_data capdata;
92364 + struct inode *inode = dentry->d_inode;
92365 +
92366 + if (!inode || S_ISDIR(inode->i_mode))
92367 + return 0;
92368 +
92369 + if (inode->i_mode & S_ISUID)
92370 + return 1;
92371 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92372 + return 2;
92373 +
92374 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92375 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92376 + return 3;
92377 + }
92378 +
92379 + return 0;
92380 +}
92381 +
92382 /*
92383 * Attempt to get the on-exec apply capability sets for an executable file from
92384 * its xattrs and, if present, apply them to the proposed credentials being
92385 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92386 const struct cred *cred = current_cred();
92387 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92388
92389 + if (gr_acl_enable_at_secure())
92390 + return 1;
92391 +
92392 if (!uid_eq(cred->uid, root_uid)) {
92393 if (bprm->cap_effective)
92394 return 1;
92395 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92396 index 079a85d..12e93f8 100644
92397 --- a/security/integrity/ima/ima.h
92398 +++ b/security/integrity/ima/ima.h
92399 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92400 extern spinlock_t ima_queue_lock;
92401
92402 struct ima_h_table {
92403 - atomic_long_t len; /* number of stored measurements in the list */
92404 - atomic_long_t violations;
92405 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92406 + atomic_long_unchecked_t violations;
92407 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92408 };
92409 extern struct ima_h_table ima_htable;
92410 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92411 index 0cea3db..2f0ef77 100644
92412 --- a/security/integrity/ima/ima_api.c
92413 +++ b/security/integrity/ima/ima_api.c
92414 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92415 int result;
92416
92417 /* can overflow, only indicator */
92418 - atomic_long_inc(&ima_htable.violations);
92419 + atomic_long_inc_unchecked(&ima_htable.violations);
92420
92421 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92422 if (!entry) {
92423 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92424 index 38477c9..87a60c7 100644
92425 --- a/security/integrity/ima/ima_fs.c
92426 +++ b/security/integrity/ima/ima_fs.c
92427 @@ -28,12 +28,12 @@
92428 static int valid_policy = 1;
92429 #define TMPBUFLEN 12
92430 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92431 - loff_t *ppos, atomic_long_t *val)
92432 + loff_t *ppos, atomic_long_unchecked_t *val)
92433 {
92434 char tmpbuf[TMPBUFLEN];
92435 ssize_t len;
92436
92437 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92438 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92439 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92440 }
92441
92442 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92443 index 55a6271..ad829c3 100644
92444 --- a/security/integrity/ima/ima_queue.c
92445 +++ b/security/integrity/ima/ima_queue.c
92446 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92447 INIT_LIST_HEAD(&qe->later);
92448 list_add_tail_rcu(&qe->later, &ima_measurements);
92449
92450 - atomic_long_inc(&ima_htable.len);
92451 + atomic_long_inc_unchecked(&ima_htable.len);
92452 key = ima_hash_key(entry->digest);
92453 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92454 return 0;
92455 diff --git a/security/keys/compat.c b/security/keys/compat.c
92456 index d65fa7f..cbfe366 100644
92457 --- a/security/keys/compat.c
92458 +++ b/security/keys/compat.c
92459 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92460 if (ret == 0)
92461 goto no_payload_free;
92462
92463 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92464 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92465 err:
92466 if (iov != iovstack)
92467 kfree(iov);
92468 diff --git a/security/keys/key.c b/security/keys/key.c
92469 index 8fb7c7b..ba3610d 100644
92470 --- a/security/keys/key.c
92471 +++ b/security/keys/key.c
92472 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92473
92474 atomic_set(&key->usage, 1);
92475 init_rwsem(&key->sem);
92476 - lockdep_set_class(&key->sem, &type->lock_class);
92477 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92478 key->type = type;
92479 key->user = user;
92480 key->quotalen = quotalen;
92481 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92482 struct key_type *p;
92483 int ret;
92484
92485 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92486 + pax_open_kernel();
92487 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92488 + pax_close_kernel();
92489
92490 ret = -EEXIST;
92491 down_write(&key_types_sem);
92492 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92493 }
92494
92495 /* store the type */
92496 - list_add(&ktype->link, &key_types_list);
92497 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92498
92499 pr_notice("Key type %s registered\n", ktype->name);
92500 ret = 0;
92501 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92502 void unregister_key_type(struct key_type *ktype)
92503 {
92504 down_write(&key_types_sem);
92505 - list_del_init(&ktype->link);
92506 + pax_list_del_init((struct list_head *)&ktype->link);
92507 downgrade_write(&key_types_sem);
92508 key_gc_keytype(ktype);
92509 pr_notice("Key type %s unregistered\n", ktype->name);
92510 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92511 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92512
92513 /* add the special key types */
92514 - list_add_tail(&key_type_keyring.link, &key_types_list);
92515 - list_add_tail(&key_type_dead.link, &key_types_list);
92516 - list_add_tail(&key_type_user.link, &key_types_list);
92517 - list_add_tail(&key_type_logon.link, &key_types_list);
92518 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92519 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92520 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92521 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92522
92523 /* record the root user tracking */
92524 rb_link_node(&root_key_user.node,
92525 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92526 index 4b5c948..2054dc1 100644
92527 --- a/security/keys/keyctl.c
92528 +++ b/security/keys/keyctl.c
92529 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92530 /*
92531 * Copy the iovec data from userspace
92532 */
92533 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92534 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92535 unsigned ioc)
92536 {
92537 for (; ioc > 0; ioc--) {
92538 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92539 * If successful, 0 will be returned.
92540 */
92541 long keyctl_instantiate_key_common(key_serial_t id,
92542 - const struct iovec *payload_iov,
92543 + const struct iovec __user *payload_iov,
92544 unsigned ioc,
92545 size_t plen,
92546 key_serial_t ringid)
92547 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92548 [0].iov_len = plen
92549 };
92550
92551 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92552 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92553 }
92554
92555 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92556 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92557 if (ret == 0)
92558 goto no_payload_free;
92559
92560 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92561 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92562 err:
92563 if (iov != iovstack)
92564 kfree(iov);
92565 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92566 index 6ece7f2..ecdb55c 100644
92567 --- a/security/keys/keyring.c
92568 +++ b/security/keys/keyring.c
92569 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92570 ret = -EFAULT;
92571
92572 for (loop = 0; loop < klist->nkeys; loop++) {
92573 + key_serial_t serial;
92574 key = rcu_deref_link_locked(klist, loop,
92575 keyring);
92576 + serial = key->serial;
92577
92578 tmp = sizeof(key_serial_t);
92579 if (tmp > buflen)
92580 tmp = buflen;
92581
92582 - if (copy_to_user(buffer,
92583 - &key->serial,
92584 - tmp) != 0)
92585 + if (copy_to_user(buffer, &serial, tmp))
92586 goto error;
92587
92588 buflen -= tmp;
92589 diff --git a/security/min_addr.c b/security/min_addr.c
92590 index f728728..6457a0c 100644
92591 --- a/security/min_addr.c
92592 +++ b/security/min_addr.c
92593 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92594 */
92595 static void update_mmap_min_addr(void)
92596 {
92597 +#ifndef SPARC
92598 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92599 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92600 mmap_min_addr = dac_mmap_min_addr;
92601 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92602 #else
92603 mmap_min_addr = dac_mmap_min_addr;
92604 #endif
92605 +#endif
92606 }
92607
92608 /*
92609 diff --git a/security/security.c b/security/security.c
92610 index 7b88c6a..1e3ea8f 100644
92611 --- a/security/security.c
92612 +++ b/security/security.c
92613 @@ -20,6 +20,7 @@
92614 #include <linux/ima.h>
92615 #include <linux/evm.h>
92616 #include <linux/fsnotify.h>
92617 +#include <linux/mm.h>
92618 #include <linux/mman.h>
92619 #include <linux/mount.h>
92620 #include <linux/personality.h>
92621 @@ -32,8 +33,8 @@
92622 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92623 CONFIG_DEFAULT_SECURITY;
92624
92625 -static struct security_operations *security_ops;
92626 -static struct security_operations default_security_ops = {
92627 +static struct security_operations *security_ops __read_only;
92628 +static struct security_operations default_security_ops __read_only = {
92629 .name = "default",
92630 };
92631
92632 @@ -74,7 +75,9 @@ int __init security_init(void)
92633
92634 void reset_security_ops(void)
92635 {
92636 + pax_open_kernel();
92637 security_ops = &default_security_ops;
92638 + pax_close_kernel();
92639 }
92640
92641 /* Save user chosen LSM */
92642 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92643 index ef26e96..642fb78 100644
92644 --- a/security/selinux/hooks.c
92645 +++ b/security/selinux/hooks.c
92646 @@ -95,8 +95,6 @@
92647
92648 #define NUM_SEL_MNT_OPTS 5
92649
92650 -extern struct security_operations *security_ops;
92651 -
92652 /* SECMARK reference count */
92653 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92654
92655 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92656
92657 #endif
92658
92659 -static struct security_operations selinux_ops = {
92660 +static struct security_operations selinux_ops __read_only = {
92661 .name = "selinux",
92662
92663 .ptrace_access_check = selinux_ptrace_access_check,
92664 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
92665 index 65f67cb..3f141ef 100644
92666 --- a/security/selinux/include/xfrm.h
92667 +++ b/security/selinux/include/xfrm.h
92668 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
92669
92670 static inline void selinux_xfrm_notify_policyload(void)
92671 {
92672 - atomic_inc(&flow_cache_genid);
92673 + atomic_inc_unchecked(&flow_cache_genid);
92674 rt_genid_bump(&init_net);
92675 }
92676 #else
92677 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
92678 index 38be92c..21f49ee 100644
92679 --- a/security/smack/smack_lsm.c
92680 +++ b/security/smack/smack_lsm.c
92681 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
92682 return 0;
92683 }
92684
92685 -struct security_operations smack_ops = {
92686 +struct security_operations smack_ops __read_only = {
92687 .name = "smack",
92688
92689 .ptrace_access_check = smack_ptrace_access_check,
92690 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
92691 index 390c646..f2f8db3 100644
92692 --- a/security/tomoyo/mount.c
92693 +++ b/security/tomoyo/mount.c
92694 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
92695 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
92696 need_dev = -1; /* dev_name is a directory */
92697 } else {
92698 + if (!capable(CAP_SYS_ADMIN)) {
92699 + error = -EPERM;
92700 + goto out;
92701 + }
92702 fstype = get_fs_type(type);
92703 if (!fstype) {
92704 error = -ENODEV;
92705 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
92706 index a2ee362..5754f34 100644
92707 --- a/security/tomoyo/tomoyo.c
92708 +++ b/security/tomoyo/tomoyo.c
92709 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
92710 * tomoyo_security_ops is a "struct security_operations" which is used for
92711 * registering TOMOYO.
92712 */
92713 -static struct security_operations tomoyo_security_ops = {
92714 +static struct security_operations tomoyo_security_ops __read_only = {
92715 .name = "tomoyo",
92716 .cred_alloc_blank = tomoyo_cred_alloc_blank,
92717 .cred_prepare = tomoyo_cred_prepare,
92718 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
92719 index 20ef514..4182bed 100644
92720 --- a/security/yama/Kconfig
92721 +++ b/security/yama/Kconfig
92722 @@ -1,6 +1,6 @@
92723 config SECURITY_YAMA
92724 bool "Yama support"
92725 - depends on SECURITY
92726 + depends on SECURITY && !GRKERNSEC
92727 select SECURITYFS
92728 select SECURITY_PATH
92729 default n
92730 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
92731 index 23414b9..f8c115e 100644
92732 --- a/security/yama/yama_lsm.c
92733 +++ b/security/yama/yama_lsm.c
92734 @@ -347,10 +347,8 @@ int yama_ptrace_traceme(struct task_struct *parent)
92735 /* Only disallow PTRACE_TRACEME on more aggressive settings. */
92736 switch (ptrace_scope) {
92737 case YAMA_SCOPE_CAPABILITY:
92738 - rcu_read_lock();
92739 - if (!ns_capable(__task_cred(parent)->user_ns, CAP_SYS_PTRACE))
92740 + if (!has_ns_capability(parent, current_user_ns(), CAP_SYS_PTRACE))
92741 rc = -EPERM;
92742 - rcu_read_unlock();
92743 break;
92744 case YAMA_SCOPE_NO_ATTACH:
92745 rc = -EPERM;
92746 @@ -367,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
92747 }
92748
92749 #ifndef CONFIG_SECURITY_YAMA_STACKED
92750 -static struct security_operations yama_ops = {
92751 +static struct security_operations yama_ops __read_only = {
92752 .name = "yama",
92753
92754 .ptrace_access_check = yama_ptrace_access_check,
92755 @@ -378,28 +376,24 @@ static struct security_operations yama_ops = {
92756 #endif
92757
92758 #ifdef CONFIG_SYSCTL
92759 +static int zero __read_only;
92760 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
92761 +
92762 static int yama_dointvec_minmax(struct ctl_table *table, int write,
92763 void __user *buffer, size_t *lenp, loff_t *ppos)
92764 {
92765 - int rc;
92766 + ctl_table_no_const yama_table;
92767
92768 if (write && !capable(CAP_SYS_PTRACE))
92769 return -EPERM;
92770
92771 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
92772 - if (rc)
92773 - return rc;
92774 -
92775 + yama_table = *table;
92776 /* Lock the max value if it ever gets set. */
92777 - if (write && *(int *)table->data == *(int *)table->extra2)
92778 - table->extra1 = table->extra2;
92779 -
92780 - return rc;
92781 + if (ptrace_scope == max_scope)
92782 + yama_table.extra1 = &max_scope;
92783 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
92784 }
92785
92786 -static int zero;
92787 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
92788 -
92789 struct ctl_path yama_sysctl_path[] = {
92790 { .procname = "kernel", },
92791 { .procname = "yama", },
92792 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
92793 index 4cedc69..e59d8a3 100644
92794 --- a/sound/aoa/codecs/onyx.c
92795 +++ b/sound/aoa/codecs/onyx.c
92796 @@ -54,7 +54,7 @@ struct onyx {
92797 spdif_locked:1,
92798 analog_locked:1,
92799 original_mute:2;
92800 - int open_count;
92801 + local_t open_count;
92802 struct codec_info *codec_info;
92803
92804 /* mutex serializes concurrent access to the device
92805 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
92806 struct onyx *onyx = cii->codec_data;
92807
92808 mutex_lock(&onyx->mutex);
92809 - onyx->open_count++;
92810 + local_inc(&onyx->open_count);
92811 mutex_unlock(&onyx->mutex);
92812
92813 return 0;
92814 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
92815 struct onyx *onyx = cii->codec_data;
92816
92817 mutex_lock(&onyx->mutex);
92818 - onyx->open_count--;
92819 - if (!onyx->open_count)
92820 + if (local_dec_and_test(&onyx->open_count))
92821 onyx->spdif_locked = onyx->analog_locked = 0;
92822 mutex_unlock(&onyx->mutex);
92823
92824 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
92825 index ffd2025..df062c9 100644
92826 --- a/sound/aoa/codecs/onyx.h
92827 +++ b/sound/aoa/codecs/onyx.h
92828 @@ -11,6 +11,7 @@
92829 #include <linux/i2c.h>
92830 #include <asm/pmac_low_i2c.h>
92831 #include <asm/prom.h>
92832 +#include <asm/local.h>
92833
92834 /* PCM3052 register definitions */
92835
92836 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
92837 index 4c1cc51..16040040 100644
92838 --- a/sound/core/oss/pcm_oss.c
92839 +++ b/sound/core/oss/pcm_oss.c
92840 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
92841 if (in_kernel) {
92842 mm_segment_t fs;
92843 fs = snd_enter_user();
92844 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92845 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92846 snd_leave_user(fs);
92847 } else {
92848 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92849 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92850 }
92851 if (ret != -EPIPE && ret != -ESTRPIPE)
92852 break;
92853 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
92854 if (in_kernel) {
92855 mm_segment_t fs;
92856 fs = snd_enter_user();
92857 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92858 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92859 snd_leave_user(fs);
92860 } else {
92861 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92862 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92863 }
92864 if (ret == -EPIPE) {
92865 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
92866 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
92867 struct snd_pcm_plugin_channel *channels;
92868 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
92869 if (!in_kernel) {
92870 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
92871 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
92872 return -EFAULT;
92873 buf = runtime->oss.buffer;
92874 }
92875 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
92876 }
92877 } else {
92878 tmp = snd_pcm_oss_write2(substream,
92879 - (const char __force *)buf,
92880 + (const char __force_kernel *)buf,
92881 runtime->oss.period_bytes, 0);
92882 if (tmp <= 0)
92883 goto err;
92884 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
92885 struct snd_pcm_runtime *runtime = substream->runtime;
92886 snd_pcm_sframes_t frames, frames1;
92887 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
92888 - char __user *final_dst = (char __force __user *)buf;
92889 + char __user *final_dst = (char __force_user *)buf;
92890 if (runtime->oss.plugin_first) {
92891 struct snd_pcm_plugin_channel *channels;
92892 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
92893 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
92894 xfer += tmp;
92895 runtime->oss.buffer_used -= tmp;
92896 } else {
92897 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
92898 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
92899 runtime->oss.period_bytes, 0);
92900 if (tmp <= 0)
92901 goto err;
92902 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
92903 size1);
92904 size1 /= runtime->channels; /* frames */
92905 fs = snd_enter_user();
92906 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
92907 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
92908 snd_leave_user(fs);
92909 }
92910 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
92911 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
92912 index af49721..e85058e 100644
92913 --- a/sound/core/pcm_compat.c
92914 +++ b/sound/core/pcm_compat.c
92915 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
92916 int err;
92917
92918 fs = snd_enter_user();
92919 - err = snd_pcm_delay(substream, &delay);
92920 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
92921 snd_leave_user(fs);
92922 if (err < 0)
92923 return err;
92924 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
92925 index 09b4286..8620fac 100644
92926 --- a/sound/core/pcm_native.c
92927 +++ b/sound/core/pcm_native.c
92928 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
92929 switch (substream->stream) {
92930 case SNDRV_PCM_STREAM_PLAYBACK:
92931 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
92932 - (void __user *)arg);
92933 + (void __force_user *)arg);
92934 break;
92935 case SNDRV_PCM_STREAM_CAPTURE:
92936 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
92937 - (void __user *)arg);
92938 + (void __force_user *)arg);
92939 break;
92940 default:
92941 result = -EINVAL;
92942 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
92943 index 040c60e..989a19a 100644
92944 --- a/sound/core/seq/seq_device.c
92945 +++ b/sound/core/seq/seq_device.c
92946 @@ -64,7 +64,7 @@ struct ops_list {
92947 int argsize; /* argument size */
92948
92949 /* operators */
92950 - struct snd_seq_dev_ops ops;
92951 + struct snd_seq_dev_ops *ops;
92952
92953 /* registered devices */
92954 struct list_head dev_list; /* list of devices */
92955 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
92956
92957 mutex_lock(&ops->reg_mutex);
92958 /* copy driver operators */
92959 - ops->ops = *entry;
92960 + ops->ops = entry;
92961 ops->driver |= DRIVER_LOADED;
92962 ops->argsize = argsize;
92963
92964 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
92965 dev->name, ops->id, ops->argsize, dev->argsize);
92966 return -EINVAL;
92967 }
92968 - if (ops->ops.init_device(dev) >= 0) {
92969 + if (ops->ops->init_device(dev) >= 0) {
92970 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
92971 ops->num_init_devices++;
92972 } else {
92973 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
92974 dev->name, ops->id, ops->argsize, dev->argsize);
92975 return -EINVAL;
92976 }
92977 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
92978 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
92979 dev->status = SNDRV_SEQ_DEVICE_FREE;
92980 dev->driver_data = NULL;
92981 ops->num_init_devices--;
92982 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
92983 index 4e0dd22..7a1f32c 100644
92984 --- a/sound/drivers/mts64.c
92985 +++ b/sound/drivers/mts64.c
92986 @@ -29,6 +29,7 @@
92987 #include <sound/initval.h>
92988 #include <sound/rawmidi.h>
92989 #include <sound/control.h>
92990 +#include <asm/local.h>
92991
92992 #define CARD_NAME "Miditerminal 4140"
92993 #define DRIVER_NAME "MTS64"
92994 @@ -67,7 +68,7 @@ struct mts64 {
92995 struct pardevice *pardev;
92996 int pardev_claimed;
92997
92998 - int open_count;
92999 + local_t open_count;
93000 int current_midi_output_port;
93001 int current_midi_input_port;
93002 u8 mode[MTS64_NUM_INPUT_PORTS];
93003 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93004 {
93005 struct mts64 *mts = substream->rmidi->private_data;
93006
93007 - if (mts->open_count == 0) {
93008 + if (local_read(&mts->open_count) == 0) {
93009 /* We don't need a spinlock here, because this is just called
93010 if the device has not been opened before.
93011 So there aren't any IRQs from the device */
93012 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93013
93014 msleep(50);
93015 }
93016 - ++(mts->open_count);
93017 + local_inc(&mts->open_count);
93018
93019 return 0;
93020 }
93021 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93022 struct mts64 *mts = substream->rmidi->private_data;
93023 unsigned long flags;
93024
93025 - --(mts->open_count);
93026 - if (mts->open_count == 0) {
93027 + if (local_dec_return(&mts->open_count) == 0) {
93028 /* We need the spinlock_irqsave here because we can still
93029 have IRQs at this point */
93030 spin_lock_irqsave(&mts->lock, flags);
93031 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93032
93033 msleep(500);
93034
93035 - } else if (mts->open_count < 0)
93036 - mts->open_count = 0;
93037 + } else if (local_read(&mts->open_count) < 0)
93038 + local_set(&mts->open_count, 0);
93039
93040 return 0;
93041 }
93042 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
93043 index b953fb4..1999c01 100644
93044 --- a/sound/drivers/opl4/opl4_lib.c
93045 +++ b/sound/drivers/opl4/opl4_lib.c
93046 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
93047 MODULE_DESCRIPTION("OPL4 driver");
93048 MODULE_LICENSE("GPL");
93049
93050 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93051 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93052 {
93053 int timeout = 10;
93054 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93055 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93056 index 991018d..8984740 100644
93057 --- a/sound/drivers/portman2x4.c
93058 +++ b/sound/drivers/portman2x4.c
93059 @@ -48,6 +48,7 @@
93060 #include <sound/initval.h>
93061 #include <sound/rawmidi.h>
93062 #include <sound/control.h>
93063 +#include <asm/local.h>
93064
93065 #define CARD_NAME "Portman 2x4"
93066 #define DRIVER_NAME "portman"
93067 @@ -85,7 +86,7 @@ struct portman {
93068 struct pardevice *pardev;
93069 int pardev_claimed;
93070
93071 - int open_count;
93072 + local_t open_count;
93073 int mode[PORTMAN_NUM_INPUT_PORTS];
93074 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93075 };
93076 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93077 index ea995af..f1bfa37 100644
93078 --- a/sound/firewire/amdtp.c
93079 +++ b/sound/firewire/amdtp.c
93080 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93081 ptr = s->pcm_buffer_pointer + data_blocks;
93082 if (ptr >= pcm->runtime->buffer_size)
93083 ptr -= pcm->runtime->buffer_size;
93084 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93085 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93086
93087 s->pcm_period_pointer += data_blocks;
93088 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93089 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93090 */
93091 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93092 {
93093 - ACCESS_ONCE(s->source_node_id_field) =
93094 + ACCESS_ONCE_RW(s->source_node_id_field) =
93095 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93096 }
93097 EXPORT_SYMBOL(amdtp_out_stream_update);
93098 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93099 index b680c5e..061b7a0 100644
93100 --- a/sound/firewire/amdtp.h
93101 +++ b/sound/firewire/amdtp.h
93102 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93103 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93104 struct snd_pcm_substream *pcm)
93105 {
93106 - ACCESS_ONCE(s->pcm) = pcm;
93107 + ACCESS_ONCE_RW(s->pcm) = pcm;
93108 }
93109
93110 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93111 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93112 index d428ffe..751ef78 100644
93113 --- a/sound/firewire/isight.c
93114 +++ b/sound/firewire/isight.c
93115 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
93116 ptr += count;
93117 if (ptr >= runtime->buffer_size)
93118 ptr -= runtime->buffer_size;
93119 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
93120 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
93121
93122 isight->period_counter += count;
93123 if (isight->period_counter >= runtime->period_size) {
93124 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
93125 if (err < 0)
93126 return err;
93127
93128 - ACCESS_ONCE(isight->pcm_active) = true;
93129 + ACCESS_ONCE_RW(isight->pcm_active) = true;
93130
93131 return 0;
93132 }
93133 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
93134 {
93135 struct isight *isight = substream->private_data;
93136
93137 - ACCESS_ONCE(isight->pcm_active) = false;
93138 + ACCESS_ONCE_RW(isight->pcm_active) = false;
93139
93140 mutex_lock(&isight->mutex);
93141 isight_stop_streaming(isight);
93142 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
93143
93144 switch (cmd) {
93145 case SNDRV_PCM_TRIGGER_START:
93146 - ACCESS_ONCE(isight->pcm_running) = true;
93147 + ACCESS_ONCE_RW(isight->pcm_running) = true;
93148 break;
93149 case SNDRV_PCM_TRIGGER_STOP:
93150 - ACCESS_ONCE(isight->pcm_running) = false;
93151 + ACCESS_ONCE_RW(isight->pcm_running) = false;
93152 break;
93153 default:
93154 return -EINVAL;
93155 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
93156 index 844a555..985ab83 100644
93157 --- a/sound/firewire/scs1x.c
93158 +++ b/sound/firewire/scs1x.c
93159 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
93160 {
93161 struct scs *scs = stream->rmidi->private_data;
93162
93163 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
93164 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
93165 if (up) {
93166 scs->output_idle = false;
93167 tasklet_schedule(&scs->tasklet);
93168 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
93169 {
93170 struct scs *scs = stream->rmidi->private_data;
93171
93172 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
93173 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
93174 }
93175
93176 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
93177 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
93178
93179 snd_card_disconnect(scs->card);
93180
93181 - ACCESS_ONCE(scs->output) = NULL;
93182 - ACCESS_ONCE(scs->input) = NULL;
93183 + ACCESS_ONCE_RW(scs->output) = NULL;
93184 + ACCESS_ONCE_RW(scs->input) = NULL;
93185
93186 wait_event(scs->idle_wait, scs->output_idle);
93187
93188 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
93189 index 048439a..3be9f6f 100644
93190 --- a/sound/oss/sb_audio.c
93191 +++ b/sound/oss/sb_audio.c
93192 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
93193 buf16 = (signed short *)(localbuf + localoffs);
93194 while (c)
93195 {
93196 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93197 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93198 if (copy_from_user(lbuf8,
93199 userbuf+useroffs + p,
93200 locallen))
93201 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
93202 index 7d8803a..559f8d0 100644
93203 --- a/sound/oss/swarm_cs4297a.c
93204 +++ b/sound/oss/swarm_cs4297a.c
93205 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
93206 {
93207 struct cs4297a_state *s;
93208 u32 pwr, id;
93209 - mm_segment_t fs;
93210 int rval;
93211 #ifndef CONFIG_BCM_CS4297A_CSWARM
93212 u64 cfg;
93213 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
93214 if (!rval) {
93215 char *sb1250_duart_present;
93216
93217 +#if 0
93218 + mm_segment_t fs;
93219 fs = get_fs();
93220 set_fs(KERNEL_DS);
93221 -#if 0
93222 val = SOUND_MASK_LINE;
93223 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
93224 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
93225 val = initvol[i].vol;
93226 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
93227 }
93228 + set_fs(fs);
93229 // cs4297a_write_ac97(s, 0x18, 0x0808);
93230 #else
93231 // cs4297a_write_ac97(s, 0x5e, 0x180);
93232 cs4297a_write_ac97(s, 0x02, 0x0808);
93233 cs4297a_write_ac97(s, 0x18, 0x0808);
93234 #endif
93235 - set_fs(fs);
93236
93237 list_add(&s->list, &cs4297a_devs);
93238
93239 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
93240 index 4631a23..001ae57 100644
93241 --- a/sound/pci/ymfpci/ymfpci.h
93242 +++ b/sound/pci/ymfpci/ymfpci.h
93243 @@ -358,7 +358,7 @@ struct snd_ymfpci {
93244 spinlock_t reg_lock;
93245 spinlock_t voice_lock;
93246 wait_queue_head_t interrupt_sleep;
93247 - atomic_t interrupt_sleep_count;
93248 + atomic_unchecked_t interrupt_sleep_count;
93249 struct snd_info_entry *proc_entry;
93250 const struct firmware *dsp_microcode;
93251 const struct firmware *controller_microcode;
93252 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
93253 index 22056c5..25d3244 100644
93254 --- a/sound/pci/ymfpci/ymfpci_main.c
93255 +++ b/sound/pci/ymfpci/ymfpci_main.c
93256 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
93257 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
93258 break;
93259 }
93260 - if (atomic_read(&chip->interrupt_sleep_count)) {
93261 - atomic_set(&chip->interrupt_sleep_count, 0);
93262 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93263 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93264 wake_up(&chip->interrupt_sleep);
93265 }
93266 __end:
93267 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
93268 continue;
93269 init_waitqueue_entry(&wait, current);
93270 add_wait_queue(&chip->interrupt_sleep, &wait);
93271 - atomic_inc(&chip->interrupt_sleep_count);
93272 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
93273 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
93274 remove_wait_queue(&chip->interrupt_sleep, &wait);
93275 }
93276 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
93277 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
93278 spin_unlock(&chip->reg_lock);
93279
93280 - if (atomic_read(&chip->interrupt_sleep_count)) {
93281 - atomic_set(&chip->interrupt_sleep_count, 0);
93282 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93283 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93284 wake_up(&chip->interrupt_sleep);
93285 }
93286 }
93287 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
93288 spin_lock_init(&chip->reg_lock);
93289 spin_lock_init(&chip->voice_lock);
93290 init_waitqueue_head(&chip->interrupt_sleep);
93291 - atomic_set(&chip->interrupt_sleep_count, 0);
93292 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93293 chip->card = card;
93294 chip->pci = pci;
93295 chip->irq = -1;
93296 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
93297 new file mode 100644
93298 index 0000000..50f2f2f
93299 --- /dev/null
93300 +++ b/tools/gcc/.gitignore
93301 @@ -0,0 +1 @@
93302 +size_overflow_hash.h
93303 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93304 new file mode 100644
93305 index 0000000..144dbee
93306 --- /dev/null
93307 +++ b/tools/gcc/Makefile
93308 @@ -0,0 +1,45 @@
93309 +#CC := gcc
93310 +#PLUGIN_SOURCE_FILES := pax_plugin.c
93311 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
93312 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
93313 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
93314 +
93315 +ifeq ($(PLUGINCC),$(HOSTCC))
93316 +HOSTLIBS := hostlibs
93317 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93318 +else
93319 +HOSTLIBS := hostcxxlibs
93320 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93321 +endif
93322 +
93323 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93324 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93325 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93326 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93327 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93328 +$(HOSTLIBS)-y += colorize_plugin.so
93329 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93330 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93331 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93332 +
93333 +always := $($(HOSTLIBS)-y)
93334 +
93335 +constify_plugin-objs := constify_plugin.o
93336 +stackleak_plugin-objs := stackleak_plugin.o
93337 +kallocstat_plugin-objs := kallocstat_plugin.o
93338 +kernexec_plugin-objs := kernexec_plugin.o
93339 +checker_plugin-objs := checker_plugin.o
93340 +colorize_plugin-objs := colorize_plugin.o
93341 +size_overflow_plugin-objs := size_overflow_plugin.o
93342 +latent_entropy_plugin-objs := latent_entropy_plugin.o
93343 +structleak_plugin-objs := structleak_plugin.o
93344 +
93345 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
93346 +
93347 +quiet_cmd_build_size_overflow_hash = GENHASH $@
93348 + cmd_build_size_overflow_hash = \
93349 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
93350 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
93351 + $(call if_changed,build_size_overflow_hash)
93352 +
93353 +targets += size_overflow_hash.h
93354 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
93355 new file mode 100644
93356 index 0000000..d41b5af
93357 --- /dev/null
93358 +++ b/tools/gcc/checker_plugin.c
93359 @@ -0,0 +1,171 @@
93360 +/*
93361 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
93362 + * Licensed under the GPL v2
93363 + *
93364 + * Note: the choice of the license means that the compilation process is
93365 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93366 + * but for the kernel it doesn't matter since it doesn't link against
93367 + * any of the gcc libraries
93368 + *
93369 + * gcc plugin to implement various sparse (source code checker) features
93370 + *
93371 + * TODO:
93372 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93373 + *
93374 + * BUGS:
93375 + * - none known
93376 + */
93377 +#include "gcc-plugin.h"
93378 +#include "config.h"
93379 +#include "system.h"
93380 +#include "coretypes.h"
93381 +#include "tree.h"
93382 +#include "tree-pass.h"
93383 +#include "flags.h"
93384 +#include "intl.h"
93385 +#include "toplev.h"
93386 +#include "plugin.h"
93387 +//#include "expr.h" where are you...
93388 +#include "diagnostic.h"
93389 +#include "plugin-version.h"
93390 +#include "tm.h"
93391 +#include "function.h"
93392 +#include "basic-block.h"
93393 +#include "gimple.h"
93394 +#include "rtl.h"
93395 +#include "emit-rtl.h"
93396 +#include "tree-flow.h"
93397 +#include "target.h"
93398 +
93399 +extern void c_register_addr_space (const char *str, addr_space_t as);
93400 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93401 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93402 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93403 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93404 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93405 +
93406 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93407 +extern rtx emit_move_insn(rtx x, rtx y);
93408 +
93409 +int plugin_is_GPL_compatible;
93410 +
93411 +static struct plugin_info checker_plugin_info = {
93412 + .version = "201111150100",
93413 +};
93414 +
93415 +#define ADDR_SPACE_KERNEL 0
93416 +#define ADDR_SPACE_FORCE_KERNEL 1
93417 +#define ADDR_SPACE_USER 2
93418 +#define ADDR_SPACE_FORCE_USER 3
93419 +#define ADDR_SPACE_IOMEM 0
93420 +#define ADDR_SPACE_FORCE_IOMEM 0
93421 +#define ADDR_SPACE_PERCPU 0
93422 +#define ADDR_SPACE_FORCE_PERCPU 0
93423 +#define ADDR_SPACE_RCU 0
93424 +#define ADDR_SPACE_FORCE_RCU 0
93425 +
93426 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93427 +{
93428 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93429 +}
93430 +
93431 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93432 +{
93433 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93434 +}
93435 +
93436 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93437 +{
93438 + return default_addr_space_valid_pointer_mode(mode, as);
93439 +}
93440 +
93441 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93442 +{
93443 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93444 +}
93445 +
93446 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93447 +{
93448 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93449 +}
93450 +
93451 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93452 +{
93453 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93454 + return true;
93455 +
93456 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93457 + return true;
93458 +
93459 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93460 + return true;
93461 +
93462 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93463 + return true;
93464 +
93465 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93466 + return true;
93467 +
93468 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93469 + return true;
93470 +
93471 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93472 + return true;
93473 +
93474 + return subset == superset;
93475 +}
93476 +
93477 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93478 +{
93479 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93480 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93481 +
93482 + return op;
93483 +}
93484 +
93485 +static void register_checker_address_spaces(void *event_data, void *data)
93486 +{
93487 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93488 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93489 + c_register_addr_space("__user", ADDR_SPACE_USER);
93490 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93491 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93492 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93493 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93494 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93495 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93496 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93497 +
93498 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93499 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93500 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93501 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93502 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93503 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93504 + targetm.addr_space.convert = checker_addr_space_convert;
93505 +}
93506 +
93507 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93508 +{
93509 + const char * const plugin_name = plugin_info->base_name;
93510 + const int argc = plugin_info->argc;
93511 + const struct plugin_argument * const argv = plugin_info->argv;
93512 + int i;
93513 +
93514 + if (!plugin_default_version_check(version, &gcc_version)) {
93515 + error(G_("incompatible gcc/plugin versions"));
93516 + return 1;
93517 + }
93518 +
93519 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93520 +
93521 + for (i = 0; i < argc; ++i)
93522 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93523 +
93524 + if (TARGET_64BIT == 0)
93525 + return 0;
93526 +
93527 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93528 +
93529 + return 0;
93530 +}
93531 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93532 new file mode 100644
93533 index 0000000..414fe5e
93534 --- /dev/null
93535 +++ b/tools/gcc/colorize_plugin.c
93536 @@ -0,0 +1,151 @@
93537 +/*
93538 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93539 + * Licensed under the GPL v2
93540 + *
93541 + * Note: the choice of the license means that the compilation process is
93542 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93543 + * but for the kernel it doesn't matter since it doesn't link against
93544 + * any of the gcc libraries
93545 + *
93546 + * gcc plugin to colorize diagnostic output
93547 + *
93548 + */
93549 +
93550 +#include "gcc-plugin.h"
93551 +#include "config.h"
93552 +#include "system.h"
93553 +#include "coretypes.h"
93554 +#include "tree.h"
93555 +#include "tree-pass.h"
93556 +#include "flags.h"
93557 +#include "intl.h"
93558 +#include "toplev.h"
93559 +#include "plugin.h"
93560 +#include "diagnostic.h"
93561 +#include "plugin-version.h"
93562 +#include "tm.h"
93563 +
93564 +int plugin_is_GPL_compatible;
93565 +
93566 +static struct plugin_info colorize_plugin_info = {
93567 + .version = "201302112000",
93568 + .help = NULL,
93569 +};
93570 +
93571 +#define GREEN "\033[32m\033[2m"
93572 +#define LIGHTGREEN "\033[32m\033[1m"
93573 +#define YELLOW "\033[33m\033[2m"
93574 +#define LIGHTYELLOW "\033[33m\033[1m"
93575 +#define RED "\033[31m\033[2m"
93576 +#define LIGHTRED "\033[31m\033[1m"
93577 +#define BLUE "\033[34m\033[2m"
93578 +#define LIGHTBLUE "\033[34m\033[1m"
93579 +#define BRIGHT "\033[m\033[1m"
93580 +#define NORMAL "\033[m"
93581 +
93582 +static diagnostic_starter_fn old_starter;
93583 +static diagnostic_finalizer_fn old_finalizer;
93584 +
93585 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93586 +{
93587 + const char *color;
93588 + char *newprefix;
93589 +
93590 + switch (diagnostic->kind) {
93591 + case DK_NOTE:
93592 + color = LIGHTBLUE;
93593 + break;
93594 +
93595 + case DK_PEDWARN:
93596 + case DK_WARNING:
93597 + color = LIGHTYELLOW;
93598 + break;
93599 +
93600 + case DK_ERROR:
93601 + case DK_FATAL:
93602 + case DK_ICE:
93603 + case DK_PERMERROR:
93604 + case DK_SORRY:
93605 + color = LIGHTRED;
93606 + break;
93607 +
93608 + default:
93609 + color = NORMAL;
93610 + }
93611 +
93612 + old_starter(context, diagnostic);
93613 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93614 + return;
93615 + pp_destroy_prefix(context->printer);
93616 + pp_set_prefix(context->printer, newprefix);
93617 +}
93618 +
93619 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93620 +{
93621 + old_finalizer(context, diagnostic);
93622 +}
93623 +
93624 +static void colorize_arm(void)
93625 +{
93626 + old_starter = diagnostic_starter(global_dc);
93627 + old_finalizer = diagnostic_finalizer(global_dc);
93628 +
93629 + diagnostic_starter(global_dc) = start_colorize;
93630 + diagnostic_finalizer(global_dc) = finalize_colorize;
93631 +}
93632 +
93633 +static unsigned int execute_colorize_rearm(void)
93634 +{
93635 + if (diagnostic_starter(global_dc) == start_colorize)
93636 + return 0;
93637 +
93638 + colorize_arm();
93639 + return 0;
93640 +}
93641 +
93642 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93643 + .pass = {
93644 + .type = SIMPLE_IPA_PASS,
93645 + .name = "colorize_rearm",
93646 +#if BUILDING_GCC_VERSION >= 4008
93647 + .optinfo_flags = OPTGROUP_NONE,
93648 +#endif
93649 + .gate = NULL,
93650 + .execute = execute_colorize_rearm,
93651 + .sub = NULL,
93652 + .next = NULL,
93653 + .static_pass_number = 0,
93654 + .tv_id = TV_NONE,
93655 + .properties_required = 0,
93656 + .properties_provided = 0,
93657 + .properties_destroyed = 0,
93658 + .todo_flags_start = 0,
93659 + .todo_flags_finish = 0
93660 + }
93661 +};
93662 +
93663 +static void colorize_start_unit(void *gcc_data, void *user_data)
93664 +{
93665 + colorize_arm();
93666 +}
93667 +
93668 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93669 +{
93670 + const char * const plugin_name = plugin_info->base_name;
93671 + struct register_pass_info colorize_rearm_pass_info = {
93672 + .pass = &pass_ipa_colorize_rearm.pass,
93673 + .reference_pass_name = "*free_lang_data",
93674 + .ref_pass_instance_number = 1,
93675 + .pos_op = PASS_POS_INSERT_AFTER
93676 + };
93677 +
93678 + if (!plugin_default_version_check(version, &gcc_version)) {
93679 + error(G_("incompatible gcc/plugin versions"));
93680 + return 1;
93681 + }
93682 +
93683 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
93684 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
93685 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
93686 + return 0;
93687 +}
93688 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
93689 new file mode 100644
93690 index 0000000..bee0acb
93691 --- /dev/null
93692 +++ b/tools/gcc/constify_plugin.c
93693 @@ -0,0 +1,518 @@
93694 +/*
93695 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
93696 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
93697 + * Licensed under the GPL v2, or (at your option) v3
93698 + *
93699 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
93700 + *
93701 + * Homepage:
93702 + * http://www.grsecurity.net/~ephox/const_plugin/
93703 + *
93704 + * Usage:
93705 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
93706 + * $ gcc -fplugin=constify_plugin.so test.c -O2
93707 + */
93708 +
93709 +#include "gcc-plugin.h"
93710 +#include "config.h"
93711 +#include "system.h"
93712 +#include "coretypes.h"
93713 +#include "tree.h"
93714 +#include "tree-pass.h"
93715 +#include "flags.h"
93716 +#include "intl.h"
93717 +#include "toplev.h"
93718 +#include "plugin.h"
93719 +#include "diagnostic.h"
93720 +#include "plugin-version.h"
93721 +#include "tm.h"
93722 +#include "function.h"
93723 +#include "basic-block.h"
93724 +#include "gimple.h"
93725 +#include "rtl.h"
93726 +#include "emit-rtl.h"
93727 +#include "tree-flow.h"
93728 +#include "target.h"
93729 +#include "langhooks.h"
93730 +
93731 +// should come from c-tree.h if only it were installed for gcc 4.5...
93732 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
93733 +
93734 +// unused type flag in all versions 4.5-4.8
93735 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
93736 +
93737 +int plugin_is_GPL_compatible;
93738 +
93739 +static struct plugin_info const_plugin_info = {
93740 + .version = "201303270300",
93741 + .help = "no-constify\tturn off constification\n",
93742 +};
93743 +
93744 +typedef struct {
93745 + bool has_fptr_field;
93746 + bool has_writable_field;
93747 + bool has_do_const_field;
93748 + bool has_no_const_field;
93749 +} constify_info;
93750 +
93751 +static const_tree get_field_type(const_tree field)
93752 +{
93753 + return strip_array_types(TREE_TYPE(field));
93754 +}
93755 +
93756 +static bool is_fptr(const_tree field)
93757 +{
93758 + const_tree ptr = get_field_type(field);
93759 +
93760 + if (TREE_CODE(ptr) != POINTER_TYPE)
93761 + return false;
93762 +
93763 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
93764 +}
93765 +
93766 +/*
93767 + * determine whether the given structure type meets the requirements for automatic constification,
93768 + * including the constification attributes on nested structure types
93769 + */
93770 +static void constifiable(const_tree node, constify_info *cinfo)
93771 +{
93772 + const_tree field;
93773 +
93774 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93775 +
93776 + // e.g., pointer to structure fields while still constructing the structure type
93777 + if (TYPE_FIELDS(node) == NULL_TREE)
93778 + return;
93779 +
93780 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
93781 + const_tree type = get_field_type(field);
93782 + enum tree_code code = TREE_CODE(type);
93783 +
93784 + if (node == type)
93785 + continue;
93786 +
93787 + if (is_fptr(field))
93788 + cinfo->has_fptr_field = true;
93789 + else if (!TREE_READONLY(field))
93790 + cinfo->has_writable_field = true;
93791 +
93792 + if (code == RECORD_TYPE || code == UNION_TYPE) {
93793 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93794 + cinfo->has_do_const_field = true;
93795 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
93796 + cinfo->has_no_const_field = true;
93797 + else
93798 + constifiable(type, cinfo);
93799 + }
93800 + }
93801 +}
93802 +
93803 +static bool constified(const_tree node)
93804 +{
93805 + constify_info cinfo = {
93806 + .has_fptr_field = false,
93807 + .has_writable_field = false,
93808 + .has_do_const_field = false,
93809 + .has_no_const_field = false
93810 + };
93811 +
93812 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93813 +
93814 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
93815 + gcc_assert(!TYPE_READONLY(node));
93816 + return false;
93817 + }
93818 +
93819 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
93820 + gcc_assert(TYPE_READONLY(node));
93821 + return true;
93822 + }
93823 +
93824 + constifiable(node, &cinfo);
93825 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
93826 + return false;
93827 +
93828 + return TYPE_READONLY(node);
93829 +}
93830 +
93831 +static void deconstify_tree(tree node);
93832 +
93833 +static void deconstify_type(tree type)
93834 +{
93835 + tree field;
93836 +
93837 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
93838 +
93839 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
93840 + const_tree fieldtype = get_field_type(field);
93841 +
93842 + // special case handling of simple ptr-to-same-array-type members
93843 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
93844 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
93845 +
93846 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
93847 + continue;
93848 + if (TREE_TYPE(TREE_TYPE(field)) == type)
93849 + continue;
93850 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
93851 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
93852 + TREE_TYPE(TREE_TYPE(field)) = type;
93853 + }
93854 + continue;
93855 + }
93856 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
93857 + continue;
93858 + if (!constified(fieldtype))
93859 + continue;
93860 +
93861 + deconstify_tree(field);
93862 + TREE_READONLY(field) = 0;
93863 + }
93864 + TYPE_READONLY(type) = 0;
93865 + C_TYPE_FIELDS_READONLY(type) = 0;
93866 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93867 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
93868 +}
93869 +
93870 +static void deconstify_tree(tree node)
93871 +{
93872 + tree old_type, new_type, field;
93873 +
93874 + old_type = TREE_TYPE(node);
93875 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
93876 + node = TREE_TYPE(node) = copy_node(old_type);
93877 + old_type = TREE_TYPE(old_type);
93878 + }
93879 +
93880 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
93881 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
93882 +
93883 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
93884 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
93885 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
93886 + DECL_FIELD_CONTEXT(field) = new_type;
93887 +
93888 + deconstify_type(new_type);
93889 +
93890 + TREE_TYPE(node) = new_type;
93891 +}
93892 +
93893 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93894 +{
93895 + tree type;
93896 + constify_info cinfo = {
93897 + .has_fptr_field = false,
93898 + .has_writable_field = false,
93899 + .has_do_const_field = false,
93900 + .has_no_const_field = false
93901 + };
93902 +
93903 + *no_add_attrs = true;
93904 + if (TREE_CODE(*node) == FUNCTION_DECL) {
93905 + error("%qE attribute does not apply to functions", name);
93906 + return NULL_TREE;
93907 + }
93908 +
93909 + if (TREE_CODE(*node) == PARM_DECL) {
93910 + error("%qE attribute does not apply to function parameters", name);
93911 + return NULL_TREE;
93912 + }
93913 +
93914 + if (TREE_CODE(*node) == VAR_DECL) {
93915 + error("%qE attribute does not apply to variables", name);
93916 + return NULL_TREE;
93917 + }
93918 +
93919 + if (TYPE_P(*node)) {
93920 + *no_add_attrs = false;
93921 + type = *node;
93922 + } else {
93923 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
93924 + type = TREE_TYPE(*node);
93925 + }
93926 +
93927 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
93928 + error("%qE attribute applies to struct and union types only", name);
93929 + return NULL_TREE;
93930 + }
93931 +
93932 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
93933 + error("%qE attribute is already applied to the type", name);
93934 + return NULL_TREE;
93935 + }
93936 +
93937 + if (TYPE_P(*node)) {
93938 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93939 + error("%qE attribute is incompatible with 'do_const'", name);
93940 + return NULL_TREE;
93941 + }
93942 +
93943 + constifiable(type, &cinfo);
93944 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93945 + deconstify_tree(*node);
93946 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
93947 + return NULL_TREE;
93948 + }
93949 +
93950 + error("%qE attribute used on type that is not constified", name);
93951 + return NULL_TREE;
93952 +}
93953 +
93954 +static void constify_type(tree type)
93955 +{
93956 + TYPE_READONLY(type) = 1;
93957 + C_TYPE_FIELDS_READONLY(type) = 1;
93958 + TYPE_CONSTIFY_VISITED(type) = 1;
93959 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
93960 +}
93961 +
93962 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93963 +{
93964 + *no_add_attrs = true;
93965 + if (!TYPE_P(*node)) {
93966 + error("%qE attribute applies to types only", name);
93967 + return NULL_TREE;
93968 + }
93969 +
93970 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
93971 + error("%qE attribute applies to struct and union types only", name);
93972 + return NULL_TREE;
93973 + }
93974 +
93975 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
93976 + error("%qE attribute is already applied to the type", name);
93977 + return NULL_TREE;
93978 + }
93979 +
93980 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
93981 + error("%qE attribute is incompatible with 'no_const'", name);
93982 + return NULL_TREE;
93983 + }
93984 +
93985 + *no_add_attrs = false;
93986 + return NULL_TREE;
93987 +}
93988 +
93989 +static struct attribute_spec no_const_attr = {
93990 + .name = "no_const",
93991 + .min_length = 0,
93992 + .max_length = 0,
93993 + .decl_required = false,
93994 + .type_required = false,
93995 + .function_type_required = false,
93996 + .handler = handle_no_const_attribute,
93997 +#if BUILDING_GCC_VERSION >= 4007
93998 + .affects_type_identity = true
93999 +#endif
94000 +};
94001 +
94002 +static struct attribute_spec do_const_attr = {
94003 + .name = "do_const",
94004 + .min_length = 0,
94005 + .max_length = 0,
94006 + .decl_required = false,
94007 + .type_required = false,
94008 + .function_type_required = false,
94009 + .handler = handle_do_const_attribute,
94010 +#if BUILDING_GCC_VERSION >= 4007
94011 + .affects_type_identity = true
94012 +#endif
94013 +};
94014 +
94015 +static void register_attributes(void *event_data, void *data)
94016 +{
94017 + register_attribute(&no_const_attr);
94018 + register_attribute(&do_const_attr);
94019 +}
94020 +
94021 +static void finish_type(void *event_data, void *data)
94022 +{
94023 + tree type = (tree)event_data;
94024 + constify_info cinfo = {
94025 + .has_fptr_field = false,
94026 + .has_writable_field = false,
94027 + .has_do_const_field = false,
94028 + .has_no_const_field = false
94029 + };
94030 +
94031 + if (type == NULL_TREE || type == error_mark_node)
94032 + return;
94033 +
94034 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
94035 + return;
94036 +
94037 + constifiable(type, &cinfo);
94038 +
94039 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
94040 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94041 + return;
94042 + if (cinfo.has_writable_field)
94043 + return;
94044 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
94045 + return;
94046 + }
94047 +
94048 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
94049 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
94050 + deconstify_type(type);
94051 + TYPE_CONSTIFY_VISITED(type) = 1;
94052 + } else
94053 + error("'no_const' attribute used on type that is not constified");
94054 + return;
94055 + }
94056 +
94057 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94058 + constify_type(type);
94059 + return;
94060 + }
94061 +
94062 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94063 + constify_type(type);
94064 + return;
94065 + }
94066 +
94067 + deconstify_type(type);
94068 + TYPE_CONSTIFY_VISITED(type) = 1;
94069 +}
94070 +
94071 +static unsigned int check_local_variables(void)
94072 +{
94073 + unsigned int ret = 0;
94074 + tree var;
94075 +
94076 +#if BUILDING_GCC_VERSION == 4005
94077 + tree vars;
94078 +#else
94079 + unsigned int i;
94080 +#endif
94081 +
94082 +#if BUILDING_GCC_VERSION == 4005
94083 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
94084 + var = TREE_VALUE(vars);
94085 +#else
94086 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
94087 +#endif
94088 + tree type = TREE_TYPE(var);
94089 +
94090 + gcc_assert(DECL_P(var));
94091 + if (is_global_var(var))
94092 + continue;
94093 +
94094 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94095 + continue;
94096 +
94097 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94098 + continue;
94099 +
94100 + if (!TYPE_CONSTIFY_VISITED(type))
94101 + continue;
94102 +
94103 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
94104 + ret = 1;
94105 + }
94106 + return ret;
94107 +}
94108 +
94109 +static struct gimple_opt_pass pass_local_variable = {
94110 + {
94111 + .type = GIMPLE_PASS,
94112 + .name = "check_local_variables",
94113 +#if BUILDING_GCC_VERSION >= 4008
94114 + .optinfo_flags = OPTGROUP_NONE,
94115 +#endif
94116 + .gate = NULL,
94117 + .execute = check_local_variables,
94118 + .sub = NULL,
94119 + .next = NULL,
94120 + .static_pass_number = 0,
94121 + .tv_id = TV_NONE,
94122 + .properties_required = 0,
94123 + .properties_provided = 0,
94124 + .properties_destroyed = 0,
94125 + .todo_flags_start = 0,
94126 + .todo_flags_finish = 0
94127 + }
94128 +};
94129 +
94130 +static struct {
94131 + const char *name;
94132 + const char *asm_op;
94133 +} sections[] = {
94134 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
94135 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
94136 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
94137 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
94138 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
94139 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
94140 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
94141 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
94142 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
94143 +};
94144 +
94145 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
94146 +
94147 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
94148 +{
94149 + size_t i;
94150 +
94151 + for (i = 0; i < ARRAY_SIZE(sections); i++)
94152 + if (!strcmp(sections[i].name, name))
94153 + return 0;
94154 + return old_section_type_flags(decl, name, reloc);
94155 +}
94156 +
94157 +static void constify_start_unit(void *gcc_data, void *user_data)
94158 +{
94159 +// size_t i;
94160 +
94161 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
94162 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
94163 +// sections[i].section = get_section(sections[i].name, 0, NULL);
94164 +
94165 + old_section_type_flags = targetm.section_type_flags;
94166 + targetm.section_type_flags = constify_section_type_flags;
94167 +}
94168 +
94169 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94170 +{
94171 + const char * const plugin_name = plugin_info->base_name;
94172 + const int argc = plugin_info->argc;
94173 + const struct plugin_argument * const argv = plugin_info->argv;
94174 + int i;
94175 + bool constify = true;
94176 +
94177 + struct register_pass_info local_variable_pass_info = {
94178 + .pass = &pass_local_variable.pass,
94179 + .reference_pass_name = "ssa",
94180 + .ref_pass_instance_number = 1,
94181 + .pos_op = PASS_POS_INSERT_BEFORE
94182 + };
94183 +
94184 + if (!plugin_default_version_check(version, &gcc_version)) {
94185 + error(G_("incompatible gcc/plugin versions"));
94186 + return 1;
94187 + }
94188 +
94189 + for (i = 0; i < argc; ++i) {
94190 + if (!(strcmp(argv[i].key, "no-constify"))) {
94191 + constify = false;
94192 + continue;
94193 + }
94194 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94195 + }
94196 +
94197 + if (strcmp(lang_hooks.name, "GNU C")) {
94198 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
94199 + constify = false;
94200 + }
94201 +
94202 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
94203 + if (constify) {
94204 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
94205 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
94206 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
94207 + }
94208 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94209 +
94210 + return 0;
94211 +}
94212 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
94213 new file mode 100644
94214 index 0000000..e518932
94215 --- /dev/null
94216 +++ b/tools/gcc/generate_size_overflow_hash.sh
94217 @@ -0,0 +1,94 @@
94218 +#!/bin/bash
94219 +
94220 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
94221 +
94222 +header1="size_overflow_hash.h"
94223 +database="size_overflow_hash.data"
94224 +n=65536
94225 +
94226 +usage() {
94227 +cat <<EOF
94228 +usage: $0 options
94229 +OPTIONS:
94230 + -h|--help help
94231 + -o header file
94232 + -d database file
94233 + -n hash array size
94234 +EOF
94235 + return 0
94236 +}
94237 +
94238 +while true
94239 +do
94240 + case "$1" in
94241 + -h|--help) usage && exit 0;;
94242 + -n) n=$2; shift 2;;
94243 + -o) header1="$2"; shift 2;;
94244 + -d) database="$2"; shift 2;;
94245 + --) shift 1; break ;;
94246 + *) break ;;
94247 + esac
94248 +done
94249 +
94250 +create_defines() {
94251 + for i in `seq 0 31`
94252 + do
94253 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
94254 + done
94255 + echo >> "$header1"
94256 +}
94257 +
94258 +create_structs() {
94259 + rm -f "$header1"
94260 +
94261 + create_defines
94262 +
94263 + cat "$database" | while read data
94264 + do
94265 + data_array=($data)
94266 + struct_hash_name="${data_array[0]}"
94267 + funcn="${data_array[1]}"
94268 + params="${data_array[2]}"
94269 + next="${data_array[4]}"
94270 +
94271 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94272 +
94273 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94274 + echo -en "\t.param\t= " >> "$header1"
94275 + line=
94276 + for param_num in ${params//-/ };
94277 + do
94278 + line="${line}PARAM"$param_num"|"
94279 + done
94280 +
94281 + echo -e "${line%?},\n};\n" >> "$header1"
94282 + done
94283 +}
94284 +
94285 +create_headers() {
94286 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94287 +}
94288 +
94289 +create_array_elements() {
94290 + index=0
94291 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94292 + do
94293 + data_array=($data)
94294 + i="${data_array[3]}"
94295 + hash="${data_array[0]}"
94296 + while [[ $index -lt $i ]]
94297 + do
94298 + echo -e "\t["$index"]\t= NULL," >> "$header1"
94299 + index=$(($index + 1))
94300 + done
94301 + index=$(($index + 1))
94302 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
94303 + done
94304 + echo '};' >> $header1
94305 +}
94306 +
94307 +create_structs
94308 +create_headers
94309 +create_array_elements
94310 +
94311 +exit 0
94312 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
94313 new file mode 100644
94314 index 0000000..568b360
94315 --- /dev/null
94316 +++ b/tools/gcc/kallocstat_plugin.c
94317 @@ -0,0 +1,170 @@
94318 +/*
94319 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94320 + * Licensed under the GPL v2
94321 + *
94322 + * Note: the choice of the license means that the compilation process is
94323 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94324 + * but for the kernel it doesn't matter since it doesn't link against
94325 + * any of the gcc libraries
94326 + *
94327 + * gcc plugin to find the distribution of k*alloc sizes
94328 + *
94329 + * TODO:
94330 + *
94331 + * BUGS:
94332 + * - none known
94333 + */
94334 +#include "gcc-plugin.h"
94335 +#include "config.h"
94336 +#include "system.h"
94337 +#include "coretypes.h"
94338 +#include "tree.h"
94339 +#include "tree-pass.h"
94340 +#include "flags.h"
94341 +#include "intl.h"
94342 +#include "toplev.h"
94343 +#include "plugin.h"
94344 +//#include "expr.h" where are you...
94345 +#include "diagnostic.h"
94346 +#include "plugin-version.h"
94347 +#include "tm.h"
94348 +#include "function.h"
94349 +#include "basic-block.h"
94350 +#include "gimple.h"
94351 +#include "rtl.h"
94352 +#include "emit-rtl.h"
94353 +
94354 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94355 +
94356 +int plugin_is_GPL_compatible;
94357 +
94358 +static const char * const kalloc_functions[] = {
94359 + "__kmalloc",
94360 + "kmalloc",
94361 + "kmalloc_large",
94362 + "kmalloc_node",
94363 + "kmalloc_order",
94364 + "kmalloc_order_trace",
94365 + "kmalloc_slab",
94366 + "kzalloc",
94367 + "kzalloc_node",
94368 +};
94369 +
94370 +static struct plugin_info kallocstat_plugin_info = {
94371 + .version = "201302112000",
94372 +};
94373 +
94374 +static unsigned int execute_kallocstat(void);
94375 +
94376 +static struct gimple_opt_pass kallocstat_pass = {
94377 + .pass = {
94378 + .type = GIMPLE_PASS,
94379 + .name = "kallocstat",
94380 +#if BUILDING_GCC_VERSION >= 4008
94381 + .optinfo_flags = OPTGROUP_NONE,
94382 +#endif
94383 + .gate = NULL,
94384 + .execute = execute_kallocstat,
94385 + .sub = NULL,
94386 + .next = NULL,
94387 + .static_pass_number = 0,
94388 + .tv_id = TV_NONE,
94389 + .properties_required = 0,
94390 + .properties_provided = 0,
94391 + .properties_destroyed = 0,
94392 + .todo_flags_start = 0,
94393 + .todo_flags_finish = 0
94394 + }
94395 +};
94396 +
94397 +static bool is_kalloc(const char *fnname)
94398 +{
94399 + size_t i;
94400 +
94401 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94402 + if (!strcmp(fnname, kalloc_functions[i]))
94403 + return true;
94404 + return false;
94405 +}
94406 +
94407 +static unsigned int execute_kallocstat(void)
94408 +{
94409 + basic_block bb;
94410 +
94411 + // 1. loop through BBs and GIMPLE statements
94412 + FOR_EACH_BB(bb) {
94413 + gimple_stmt_iterator gsi;
94414 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94415 + // gimple match:
94416 + tree fndecl, size;
94417 + gimple call_stmt;
94418 + const char *fnname;
94419 +
94420 + // is it a call
94421 + call_stmt = gsi_stmt(gsi);
94422 + if (!is_gimple_call(call_stmt))
94423 + continue;
94424 + fndecl = gimple_call_fndecl(call_stmt);
94425 + if (fndecl == NULL_TREE)
94426 + continue;
94427 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94428 + continue;
94429 +
94430 + // is it a call to k*alloc
94431 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94432 + if (!is_kalloc(fnname))
94433 + continue;
94434 +
94435 + // is the size arg the result of a simple const assignment
94436 + size = gimple_call_arg(call_stmt, 0);
94437 + while (true) {
94438 + gimple def_stmt;
94439 + expanded_location xloc;
94440 + size_t size_val;
94441 +
94442 + if (TREE_CODE(size) != SSA_NAME)
94443 + break;
94444 + def_stmt = SSA_NAME_DEF_STMT(size);
94445 + if (!def_stmt || !is_gimple_assign(def_stmt))
94446 + break;
94447 + if (gimple_num_ops(def_stmt) != 2)
94448 + break;
94449 + size = gimple_assign_rhs1(def_stmt);
94450 + if (!TREE_CONSTANT(size))
94451 + continue;
94452 + xloc = expand_location(gimple_location(def_stmt));
94453 + if (!xloc.file)
94454 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94455 + size_val = TREE_INT_CST_LOW(size);
94456 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94457 + break;
94458 + }
94459 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94460 +//debug_tree(gimple_call_fn(call_stmt));
94461 +//print_node(stderr, "pax", fndecl, 4);
94462 + }
94463 + }
94464 +
94465 + return 0;
94466 +}
94467 +
94468 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94469 +{
94470 + const char * const plugin_name = plugin_info->base_name;
94471 + struct register_pass_info kallocstat_pass_info = {
94472 + .pass = &kallocstat_pass.pass,
94473 + .reference_pass_name = "ssa",
94474 + .ref_pass_instance_number = 1,
94475 + .pos_op = PASS_POS_INSERT_AFTER
94476 + };
94477 +
94478 + if (!plugin_default_version_check(version, &gcc_version)) {
94479 + error(G_("incompatible gcc/plugin versions"));
94480 + return 1;
94481 + }
94482 +
94483 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94484 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94485 +
94486 + return 0;
94487 +}
94488 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94489 new file mode 100644
94490 index 0000000..0408e06
94491 --- /dev/null
94492 +++ b/tools/gcc/kernexec_plugin.c
94493 @@ -0,0 +1,465 @@
94494 +/*
94495 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94496 + * Licensed under the GPL v2
94497 + *
94498 + * Note: the choice of the license means that the compilation process is
94499 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94500 + * but for the kernel it doesn't matter since it doesn't link against
94501 + * any of the gcc libraries
94502 + *
94503 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94504 + *
94505 + * TODO:
94506 + *
94507 + * BUGS:
94508 + * - none known
94509 + */
94510 +#include "gcc-plugin.h"
94511 +#include "config.h"
94512 +#include "system.h"
94513 +#include "coretypes.h"
94514 +#include "tree.h"
94515 +#include "tree-pass.h"
94516 +#include "flags.h"
94517 +#include "intl.h"
94518 +#include "toplev.h"
94519 +#include "plugin.h"
94520 +//#include "expr.h" where are you...
94521 +#include "diagnostic.h"
94522 +#include "plugin-version.h"
94523 +#include "tm.h"
94524 +#include "function.h"
94525 +#include "basic-block.h"
94526 +#include "gimple.h"
94527 +#include "rtl.h"
94528 +#include "emit-rtl.h"
94529 +#include "tree-flow.h"
94530 +
94531 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94532 +extern rtx emit_move_insn(rtx x, rtx y);
94533 +
94534 +#if BUILDING_GCC_VERSION <= 4006
94535 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94536 +#endif
94537 +
94538 +#if BUILDING_GCC_VERSION >= 4008
94539 +#define TODO_dump_func 0
94540 +#endif
94541 +
94542 +int plugin_is_GPL_compatible;
94543 +
94544 +static struct plugin_info kernexec_plugin_info = {
94545 + .version = "201302112000",
94546 + .help = "method=[bts|or]\tinstrumentation method\n"
94547 +};
94548 +
94549 +static unsigned int execute_kernexec_reload(void);
94550 +static unsigned int execute_kernexec_fptr(void);
94551 +static unsigned int execute_kernexec_retaddr(void);
94552 +static bool kernexec_cmodel_check(void);
94553 +
94554 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94555 +static void (*kernexec_instrument_retaddr)(rtx);
94556 +
94557 +static struct gimple_opt_pass kernexec_reload_pass = {
94558 + .pass = {
94559 + .type = GIMPLE_PASS,
94560 + .name = "kernexec_reload",
94561 +#if BUILDING_GCC_VERSION >= 4008
94562 + .optinfo_flags = OPTGROUP_NONE,
94563 +#endif
94564 + .gate = kernexec_cmodel_check,
94565 + .execute = execute_kernexec_reload,
94566 + .sub = NULL,
94567 + .next = NULL,
94568 + .static_pass_number = 0,
94569 + .tv_id = TV_NONE,
94570 + .properties_required = 0,
94571 + .properties_provided = 0,
94572 + .properties_destroyed = 0,
94573 + .todo_flags_start = 0,
94574 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94575 + }
94576 +};
94577 +
94578 +static struct gimple_opt_pass kernexec_fptr_pass = {
94579 + .pass = {
94580 + .type = GIMPLE_PASS,
94581 + .name = "kernexec_fptr",
94582 +#if BUILDING_GCC_VERSION >= 4008
94583 + .optinfo_flags = OPTGROUP_NONE,
94584 +#endif
94585 + .gate = kernexec_cmodel_check,
94586 + .execute = execute_kernexec_fptr,
94587 + .sub = NULL,
94588 + .next = NULL,
94589 + .static_pass_number = 0,
94590 + .tv_id = TV_NONE,
94591 + .properties_required = 0,
94592 + .properties_provided = 0,
94593 + .properties_destroyed = 0,
94594 + .todo_flags_start = 0,
94595 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94596 + }
94597 +};
94598 +
94599 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94600 + .pass = {
94601 + .type = RTL_PASS,
94602 + .name = "kernexec_retaddr",
94603 +#if BUILDING_GCC_VERSION >= 4008
94604 + .optinfo_flags = OPTGROUP_NONE,
94605 +#endif
94606 + .gate = kernexec_cmodel_check,
94607 + .execute = execute_kernexec_retaddr,
94608 + .sub = NULL,
94609 + .next = NULL,
94610 + .static_pass_number = 0,
94611 + .tv_id = TV_NONE,
94612 + .properties_required = 0,
94613 + .properties_provided = 0,
94614 + .properties_destroyed = 0,
94615 + .todo_flags_start = 0,
94616 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94617 + }
94618 +};
94619 +
94620 +static bool kernexec_cmodel_check(void)
94621 +{
94622 + tree section;
94623 +
94624 + if (ix86_cmodel != CM_KERNEL)
94625 + return false;
94626 +
94627 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94628 + if (!section || !TREE_VALUE(section))
94629 + return true;
94630 +
94631 + section = TREE_VALUE(TREE_VALUE(section));
94632 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94633 + return true;
94634 +
94635 + return false;
94636 +}
94637 +
94638 +/*
94639 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94640 + */
94641 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94642 +{
94643 + gimple asm_movabs_stmt;
94644 +
94645 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94646 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94647 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94648 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94649 + update_stmt(asm_movabs_stmt);
94650 +}
94651 +
94652 +/*
94653 + * find all asm() stmts that clobber r10 and add a reload of r10
94654 + */
94655 +static unsigned int execute_kernexec_reload(void)
94656 +{
94657 + basic_block bb;
94658 +
94659 + // 1. loop through BBs and GIMPLE statements
94660 + FOR_EACH_BB(bb) {
94661 + gimple_stmt_iterator gsi;
94662 +
94663 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94664 + // gimple match: __asm__ ("" : : : "r10");
94665 + gimple asm_stmt;
94666 + size_t nclobbers;
94667 +
94668 + // is it an asm ...
94669 + asm_stmt = gsi_stmt(gsi);
94670 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
94671 + continue;
94672 +
94673 + // ... clobbering r10
94674 + nclobbers = gimple_asm_nclobbers(asm_stmt);
94675 + while (nclobbers--) {
94676 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
94677 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
94678 + continue;
94679 + kernexec_reload_fptr_mask(&gsi);
94680 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
94681 + break;
94682 + }
94683 + }
94684 + }
94685 +
94686 + return 0;
94687 +}
94688 +
94689 +/*
94690 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
94691 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
94692 + */
94693 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
94694 +{
94695 + gimple assign_intptr, assign_new_fptr, call_stmt;
94696 + tree intptr, old_fptr, new_fptr, kernexec_mask;
94697 +
94698 + call_stmt = gsi_stmt(*gsi);
94699 + old_fptr = gimple_call_fn(call_stmt);
94700 +
94701 + // create temporary unsigned long variable used for bitops and cast fptr to it
94702 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
94703 +#if BUILDING_GCC_VERSION <= 4007
94704 + add_referenced_var(intptr);
94705 + mark_sym_for_renaming(intptr);
94706 +#endif
94707 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
94708 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94709 + update_stmt(assign_intptr);
94710 +
94711 + // apply logical or to temporary unsigned long and bitmask
94712 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
94713 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
94714 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
94715 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94716 + update_stmt(assign_intptr);
94717 +
94718 + // cast temporary unsigned long back to a temporary fptr variable
94719 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
94720 +#if BUILDING_GCC_VERSION <= 4007
94721 + add_referenced_var(new_fptr);
94722 + mark_sym_for_renaming(new_fptr);
94723 +#endif
94724 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
94725 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
94726 + update_stmt(assign_new_fptr);
94727 +
94728 + // replace call stmt fn with the new fptr
94729 + gimple_call_set_fn(call_stmt, new_fptr);
94730 + update_stmt(call_stmt);
94731 +}
94732 +
94733 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
94734 +{
94735 + gimple asm_or_stmt, call_stmt;
94736 + tree old_fptr, new_fptr, input, output;
94737 +#if BUILDING_GCC_VERSION <= 4007
94738 + VEC(tree, gc) *inputs = NULL;
94739 + VEC(tree, gc) *outputs = NULL;
94740 +#else
94741 + vec<tree, va_gc> *inputs = NULL;
94742 + vec<tree, va_gc> *outputs = NULL;
94743 +#endif
94744 +
94745 + call_stmt = gsi_stmt(*gsi);
94746 + old_fptr = gimple_call_fn(call_stmt);
94747 +
94748 + // create temporary fptr variable
94749 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
94750 +#if BUILDING_GCC_VERSION <= 4007
94751 + add_referenced_var(new_fptr);
94752 + mark_sym_for_renaming(new_fptr);
94753 +#endif
94754 +
94755 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
94756 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
94757 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
94758 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
94759 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
94760 +#if BUILDING_GCC_VERSION <= 4007
94761 + VEC_safe_push(tree, gc, inputs, input);
94762 + VEC_safe_push(tree, gc, outputs, output);
94763 +#else
94764 + vec_safe_push(inputs, input);
94765 + vec_safe_push(outputs, output);
94766 +#endif
94767 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
94768 + gimple_asm_set_volatile(asm_or_stmt, true);
94769 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
94770 + update_stmt(asm_or_stmt);
94771 +
94772 + // replace call stmt fn with the new fptr
94773 + gimple_call_set_fn(call_stmt, new_fptr);
94774 + update_stmt(call_stmt);
94775 +}
94776 +
94777 +/*
94778 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
94779 + */
94780 +static unsigned int execute_kernexec_fptr(void)
94781 +{
94782 + basic_block bb;
94783 +
94784 + // 1. loop through BBs and GIMPLE statements
94785 + FOR_EACH_BB(bb) {
94786 + gimple_stmt_iterator gsi;
94787 +
94788 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94789 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
94790 + tree fn;
94791 + gimple call_stmt;
94792 +
94793 + // is it a call ...
94794 + call_stmt = gsi_stmt(gsi);
94795 + if (!is_gimple_call(call_stmt))
94796 + continue;
94797 + fn = gimple_call_fn(call_stmt);
94798 + if (TREE_CODE(fn) == ADDR_EXPR)
94799 + continue;
94800 + if (TREE_CODE(fn) != SSA_NAME)
94801 + gcc_unreachable();
94802 +
94803 + // ... through a function pointer
94804 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
94805 + fn = SSA_NAME_VAR(fn);
94806 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
94807 + debug_tree(fn);
94808 + gcc_unreachable();
94809 + }
94810 + }
94811 + fn = TREE_TYPE(fn);
94812 + if (TREE_CODE(fn) != POINTER_TYPE)
94813 + continue;
94814 + fn = TREE_TYPE(fn);
94815 + if (TREE_CODE(fn) != FUNCTION_TYPE)
94816 + continue;
94817 +
94818 + kernexec_instrument_fptr(&gsi);
94819 +
94820 +//debug_tree(gimple_call_fn(call_stmt));
94821 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94822 + }
94823 + }
94824 +
94825 + return 0;
94826 +}
94827 +
94828 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
94829 +static void kernexec_instrument_retaddr_bts(rtx insn)
94830 +{
94831 + rtx btsq;
94832 + rtvec argvec, constraintvec, labelvec;
94833 + int line;
94834 +
94835 + // create asm volatile("btsq $63,(%%rsp)":::)
94836 + argvec = rtvec_alloc(0);
94837 + constraintvec = rtvec_alloc(0);
94838 + labelvec = rtvec_alloc(0);
94839 + line = expand_location(RTL_LOCATION(insn)).line;
94840 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94841 + MEM_VOLATILE_P(btsq) = 1;
94842 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
94843 + emit_insn_before(btsq, insn);
94844 +}
94845 +
94846 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
94847 +static void kernexec_instrument_retaddr_or(rtx insn)
94848 +{
94849 + rtx orq;
94850 + rtvec argvec, constraintvec, labelvec;
94851 + int line;
94852 +
94853 + // create asm volatile("orq %%r10,(%%rsp)":::)
94854 + argvec = rtvec_alloc(0);
94855 + constraintvec = rtvec_alloc(0);
94856 + labelvec = rtvec_alloc(0);
94857 + line = expand_location(RTL_LOCATION(insn)).line;
94858 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94859 + MEM_VOLATILE_P(orq) = 1;
94860 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
94861 + emit_insn_before(orq, insn);
94862 +}
94863 +
94864 +/*
94865 + * find all asm level function returns and forcibly set the highest bit of the return address
94866 + */
94867 +static unsigned int execute_kernexec_retaddr(void)
94868 +{
94869 + rtx insn;
94870 +
94871 + // 1. find function returns
94872 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
94873 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
94874 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
94875 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
94876 + rtx body;
94877 +
94878 + // is it a retn
94879 + if (!JUMP_P(insn))
94880 + continue;
94881 + body = PATTERN(insn);
94882 + if (GET_CODE(body) == PARALLEL)
94883 + body = XVECEXP(body, 0, 0);
94884 + if (!ANY_RETURN_P(body))
94885 + continue;
94886 + kernexec_instrument_retaddr(insn);
94887 + }
94888 +
94889 +// print_simple_rtl(stderr, get_insns());
94890 +// print_rtl(stderr, get_insns());
94891 +
94892 + return 0;
94893 +}
94894 +
94895 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94896 +{
94897 + const char * const plugin_name = plugin_info->base_name;
94898 + const int argc = plugin_info->argc;
94899 + const struct plugin_argument * const argv = plugin_info->argv;
94900 + int i;
94901 + struct register_pass_info kernexec_reload_pass_info = {
94902 + .pass = &kernexec_reload_pass.pass,
94903 + .reference_pass_name = "ssa",
94904 + .ref_pass_instance_number = 1,
94905 + .pos_op = PASS_POS_INSERT_AFTER
94906 + };
94907 + struct register_pass_info kernexec_fptr_pass_info = {
94908 + .pass = &kernexec_fptr_pass.pass,
94909 + .reference_pass_name = "ssa",
94910 + .ref_pass_instance_number = 1,
94911 + .pos_op = PASS_POS_INSERT_AFTER
94912 + };
94913 + struct register_pass_info kernexec_retaddr_pass_info = {
94914 + .pass = &kernexec_retaddr_pass.pass,
94915 + .reference_pass_name = "pro_and_epilogue",
94916 + .ref_pass_instance_number = 1,
94917 + .pos_op = PASS_POS_INSERT_AFTER
94918 + };
94919 +
94920 + if (!plugin_default_version_check(version, &gcc_version)) {
94921 + error(G_("incompatible gcc/plugin versions"));
94922 + return 1;
94923 + }
94924 +
94925 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
94926 +
94927 + if (TARGET_64BIT == 0)
94928 + return 0;
94929 +
94930 + for (i = 0; i < argc; ++i) {
94931 + if (!strcmp(argv[i].key, "method")) {
94932 + if (!argv[i].value) {
94933 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94934 + continue;
94935 + }
94936 + if (!strcmp(argv[i].value, "bts")) {
94937 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
94938 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
94939 + } else if (!strcmp(argv[i].value, "or")) {
94940 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
94941 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
94942 + fix_register("r10", 1, 1);
94943 + } else
94944 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
94945 + continue;
94946 + }
94947 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94948 + }
94949 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
94950 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
94951 +
94952 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
94953 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
94954 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
94955 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
94956 +
94957 + return 0;
94958 +}
94959 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
94960 new file mode 100644
94961 index 0000000..b5395ba
94962 --- /dev/null
94963 +++ b/tools/gcc/latent_entropy_plugin.c
94964 @@ -0,0 +1,327 @@
94965 +/*
94966 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
94967 + * Licensed under the GPL v2
94968 + *
94969 + * Note: the choice of the license means that the compilation process is
94970 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94971 + * but for the kernel it doesn't matter since it doesn't link against
94972 + * any of the gcc libraries
94973 + *
94974 + * gcc plugin to help generate a little bit of entropy from program state,
94975 + * used during boot in the kernel
94976 + *
94977 + * TODO:
94978 + * - add ipa pass to identify not explicitly marked candidate functions
94979 + * - mix in more program state (function arguments/return values, loop variables, etc)
94980 + * - more instrumentation control via attribute parameters
94981 + *
94982 + * BUGS:
94983 + * - LTO needs -flto-partition=none for now
94984 + */
94985 +#include "gcc-plugin.h"
94986 +#include "config.h"
94987 +#include "system.h"
94988 +#include "coretypes.h"
94989 +#include "tree.h"
94990 +#include "tree-pass.h"
94991 +#include "flags.h"
94992 +#include "intl.h"
94993 +#include "toplev.h"
94994 +#include "plugin.h"
94995 +//#include "expr.h" where are you...
94996 +#include "diagnostic.h"
94997 +#include "plugin-version.h"
94998 +#include "tm.h"
94999 +#include "function.h"
95000 +#include "basic-block.h"
95001 +#include "gimple.h"
95002 +#include "rtl.h"
95003 +#include "emit-rtl.h"
95004 +#include "tree-flow.h"
95005 +#include "langhooks.h"
95006 +
95007 +#if BUILDING_GCC_VERSION >= 4008
95008 +#define TODO_dump_func 0
95009 +#endif
95010 +
95011 +int plugin_is_GPL_compatible;
95012 +
95013 +static tree latent_entropy_decl;
95014 +
95015 +static struct plugin_info latent_entropy_plugin_info = {
95016 + .version = "201303102320",
95017 + .help = NULL
95018 +};
95019 +
95020 +static unsigned int execute_latent_entropy(void);
95021 +static bool gate_latent_entropy(void);
95022 +
95023 +static struct gimple_opt_pass latent_entropy_pass = {
95024 + .pass = {
95025 + .type = GIMPLE_PASS,
95026 + .name = "latent_entropy",
95027 +#if BUILDING_GCC_VERSION >= 4008
95028 + .optinfo_flags = OPTGROUP_NONE,
95029 +#endif
95030 + .gate = gate_latent_entropy,
95031 + .execute = execute_latent_entropy,
95032 + .sub = NULL,
95033 + .next = NULL,
95034 + .static_pass_number = 0,
95035 + .tv_id = TV_NONE,
95036 + .properties_required = PROP_gimple_leh | PROP_cfg,
95037 + .properties_provided = 0,
95038 + .properties_destroyed = 0,
95039 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
95040 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
95041 + }
95042 +};
95043 +
95044 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95045 +{
95046 + if (TREE_CODE(*node) != FUNCTION_DECL) {
95047 + *no_add_attrs = true;
95048 + error("%qE attribute only applies to functions", name);
95049 + }
95050 + return NULL_TREE;
95051 +}
95052 +
95053 +static struct attribute_spec latent_entropy_attr = {
95054 + .name = "latent_entropy",
95055 + .min_length = 0,
95056 + .max_length = 0,
95057 + .decl_required = true,
95058 + .type_required = false,
95059 + .function_type_required = false,
95060 + .handler = handle_latent_entropy_attribute,
95061 +#if BUILDING_GCC_VERSION >= 4007
95062 + .affects_type_identity = false
95063 +#endif
95064 +};
95065 +
95066 +static void register_attributes(void *event_data, void *data)
95067 +{
95068 + register_attribute(&latent_entropy_attr);
95069 +}
95070 +
95071 +static bool gate_latent_entropy(void)
95072 +{
95073 + tree latent_entropy_attr;
95074 +
95075 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
95076 + return latent_entropy_attr != NULL_TREE;
95077 +}
95078 +
95079 +static unsigned HOST_WIDE_INT seed;
95080 +static unsigned HOST_WIDE_INT get_random_const(void)
95081 +{
95082 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
95083 + return seed;
95084 +}
95085 +
95086 +static enum tree_code get_op(tree *rhs)
95087 +{
95088 + static enum tree_code op;
95089 + unsigned HOST_WIDE_INT random_const;
95090 +
95091 + random_const = get_random_const();
95092 +
95093 + switch (op) {
95094 + case BIT_XOR_EXPR:
95095 + op = PLUS_EXPR;
95096 + break;
95097 +
95098 + case PLUS_EXPR:
95099 + if (rhs) {
95100 + op = LROTATE_EXPR;
95101 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
95102 + break;
95103 + }
95104 +
95105 + case LROTATE_EXPR:
95106 + default:
95107 + op = BIT_XOR_EXPR;
95108 + break;
95109 + }
95110 + if (rhs)
95111 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
95112 + return op;
95113 +}
95114 +
95115 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
95116 +{
95117 + gimple_stmt_iterator gsi;
95118 + gimple assign;
95119 + tree addxorrol, rhs;
95120 + enum tree_code op;
95121 +
95122 + op = get_op(&rhs);
95123 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
95124 + assign = gimple_build_assign(local_entropy, addxorrol);
95125 +#if BUILDING_GCC_VERSION <= 4007
95126 + find_referenced_vars_in(assign);
95127 +#endif
95128 +//debug_bb(bb);
95129 + gsi = gsi_after_labels(bb);
95130 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
95131 + update_stmt(assign);
95132 +}
95133 +
95134 +static void perturb_latent_entropy(basic_block bb, tree rhs)
95135 +{
95136 + gimple_stmt_iterator gsi;
95137 + gimple assign;
95138 + tree addxorrol, temp;
95139 +
95140 + // 1. create temporary copy of latent_entropy
95141 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
95142 +#if BUILDING_GCC_VERSION <= 4007
95143 + add_referenced_var(temp);
95144 + mark_sym_for_renaming(temp);
95145 +#endif
95146 +
95147 + // 2. read...
95148 + assign = gimple_build_assign(temp, latent_entropy_decl);
95149 +#if BUILDING_GCC_VERSION <= 4007
95150 + find_referenced_vars_in(assign);
95151 +#endif
95152 + gsi = gsi_after_labels(bb);
95153 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95154 + update_stmt(assign);
95155 +
95156 + // 3. ...modify...
95157 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
95158 + assign = gimple_build_assign(temp, addxorrol);
95159 +#if BUILDING_GCC_VERSION <= 4007
95160 + find_referenced_vars_in(assign);
95161 +#endif
95162 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95163 + update_stmt(assign);
95164 +
95165 + // 4. ...write latent_entropy
95166 + assign = gimple_build_assign(latent_entropy_decl, temp);
95167 +#if BUILDING_GCC_VERSION <= 4007
95168 + find_referenced_vars_in(assign);
95169 +#endif
95170 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95171 + update_stmt(assign);
95172 +}
95173 +
95174 +static unsigned int execute_latent_entropy(void)
95175 +{
95176 + basic_block bb;
95177 + gimple assign;
95178 + gimple_stmt_iterator gsi;
95179 + tree local_entropy;
95180 +
95181 + if (!latent_entropy_decl) {
95182 + struct varpool_node *node;
95183 +
95184 +#if BUILDING_GCC_VERSION <= 4007
95185 + for (node = varpool_nodes; node; node = node->next) {
95186 + tree var = node->decl;
95187 +#else
95188 + FOR_EACH_VARIABLE(node) {
95189 + tree var = node->symbol.decl;
95190 +#endif
95191 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
95192 + continue;
95193 + latent_entropy_decl = var;
95194 +// debug_tree(var);
95195 + break;
95196 + }
95197 + if (!latent_entropy_decl) {
95198 +// debug_tree(current_function_decl);
95199 + return 0;
95200 + }
95201 + }
95202 +
95203 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
95204 +
95205 + // 1. create local entropy variable
95206 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
95207 +#if BUILDING_GCC_VERSION <= 4007
95208 + add_referenced_var(local_entropy);
95209 + mark_sym_for_renaming(local_entropy);
95210 +#endif
95211 +
95212 + // 2. initialize local entropy variable
95213 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95214 + if (dom_info_available_p(CDI_DOMINATORS))
95215 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
95216 + gsi = gsi_start_bb(bb);
95217 +
95218 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
95219 +// gimple_set_location(assign, loc);
95220 +#if BUILDING_GCC_VERSION <= 4007
95221 + find_referenced_vars_in(assign);
95222 +#endif
95223 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95224 + update_stmt(assign);
95225 + bb = bb->next_bb;
95226 +
95227 + // 3. instrument each BB with an operation on the local entropy variable
95228 + while (bb != EXIT_BLOCK_PTR) {
95229 + perturb_local_entropy(bb, local_entropy);
95230 + bb = bb->next_bb;
95231 + };
95232 +
95233 + // 4. mix local entropy into the global entropy variable
95234 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
95235 + return 0;
95236 +}
95237 +
95238 +static void start_unit_callback(void *gcc_data, void *user_data)
95239 +{
95240 + tree latent_entropy_type;
95241 +
95242 +#if BUILDING_GCC_VERSION >= 4007
95243 + seed = get_random_seed(false);
95244 +#else
95245 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
95246 + seed *= seed;
95247 +#endif
95248 +
95249 + if (in_lto_p)
95250 + return;
95251 +
95252 + // extern volatile u64 latent_entropy
95253 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
95254 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
95255 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
95256 +
95257 + TREE_STATIC(latent_entropy_decl) = 1;
95258 + TREE_PUBLIC(latent_entropy_decl) = 1;
95259 + TREE_USED(latent_entropy_decl) = 1;
95260 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95261 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95262 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95263 + DECL_INITIAL(latent_entropy_decl) = NULL;
95264 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95265 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95266 +// varpool_finalize_decl(latent_entropy_decl);
95267 +// varpool_mark_needed_node(latent_entropy_decl);
95268 +}
95269 +
95270 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95271 +{
95272 + const char * const plugin_name = plugin_info->base_name;
95273 + struct register_pass_info latent_entropy_pass_info = {
95274 + .pass = &latent_entropy_pass.pass,
95275 + .reference_pass_name = "optimized",
95276 + .ref_pass_instance_number = 1,
95277 + .pos_op = PASS_POS_INSERT_BEFORE
95278 + };
95279 +
95280 + if (!plugin_default_version_check(version, &gcc_version)) {
95281 + error(G_("incompatible gcc/plugin versions"));
95282 + return 1;
95283 + }
95284 +
95285 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95286 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95287 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95288 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95289 +
95290 + return 0;
95291 +}
95292 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95293 new file mode 100644
95294 index 0000000..ddd5b2e
95295 --- /dev/null
95296 +++ b/tools/gcc/size_overflow_hash.data
95297 @@ -0,0 +1,5876 @@
95298 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
95299 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
95300 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
95301 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
95302 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
95303 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
95304 +padzero_55 padzero 1 55 &sel_read_policyvers_55
95305 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
95306 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
95307 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
95308 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
95309 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
95310 +load_msg_95 load_msg 2 95 NULL
95311 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
95312 +init_q_132 init_q 4 132 NULL
95313 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
95314 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
95315 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
95316 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
95317 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
95318 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
95319 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
95320 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
95321 +br_port_info_size_268 br_port_info_size 0 268 NULL
95322 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
95323 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
95324 +syslog_print_307 syslog_print 2 307 NULL
95325 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95326 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95327 +next_node_allowed_318 next_node_allowed 1 318 NULL
95328 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95329 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95330 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95331 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95332 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95333 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95334 +pidlist_resize_496 pidlist_resize 2 496 NULL
95335 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95336 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95337 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95338 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
95339 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95340 +dle_count_543 dle_count 0 543 NULL
95341 +devres_alloc_551 devres_alloc 2 551 NULL
95342 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95343 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95344 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95345 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95346 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95347 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95348 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95349 +isp1760_register_628 isp1760_register 1-2 628 NULL
95350 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95351 +unlink_queued_645 unlink_queued 3-4 645 NULL
95352 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95353 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
95354 +div_u64_rem_672 div_u64_rem 0 672 NULL
95355 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95356 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95357 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95358 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95359 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95360 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
95361 +dvb_video_write_754 dvb_video_write 3 754 NULL
95362 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
95363 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
95364 +if_writecmd_815 if_writecmd 2 815 NULL
95365 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95366 +read_fifo_826 read_fifo 3 826 NULL
95367 +read_tree_block_841 read_tree_block 3 841 NULL
95368 +um_idi_read_850 um_idi_read 3 850 NULL
95369 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95370 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95371 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95372 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95373 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95374 +readw_931 readw 0 931 NULL
95375 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95376 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
95377 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
95378 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95379 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
95380 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95381 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
95382 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95383 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95384 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95385 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95386 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95387 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95388 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95389 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95390 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
95391 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95392 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95393 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95394 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95395 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95396 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95397 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95398 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95399 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95400 +thin_status_1239 thin_status 5 1239 NULL
95401 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95402 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95403 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95404 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95405 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95406 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95407 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95408 +ffs_1322 ffs 0 1322 NULL
95409 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95410 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95411 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95412 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95413 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95414 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95415 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95416 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95417 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95418 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95419 +zone_page_state_1393 zone_page_state 0 1393 NULL
95420 +file_read_actor_1401 file_read_actor 4 1401 NULL
95421 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
95422 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95423 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95424 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95425 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95426 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95427 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95428 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95429 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95430 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95431 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95432 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95433 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95434 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95435 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95436 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95437 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95438 +rmap_add_1677 rmap_add 3 1677 NULL
95439 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95440 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95441 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95442 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95443 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95444 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95445 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95446 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95447 +cosa_write_1774 cosa_write 3 1774 NULL
95448 +update_macheader_1775 update_macheader 7 1775 NULL
95449 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95450 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95451 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95452 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95453 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95454 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95455 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95456 +read_swap_header_1957 read_swap_header 0 1957 NULL
95457 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95458 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95459 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
95460 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95461 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95462 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95463 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95464 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95465 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95466 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95467 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95468 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95469 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95470 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95471 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95472 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
95473 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95474 +audit_expand_2098 audit_expand 2 2098 NULL
95475 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95476 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95477 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95478 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95479 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95480 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
95481 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95482 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
95483 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
95484 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95485 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95486 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95487 +u32_array_read_2219 u32_array_read 3 2219 NULL
95488 +vhci_write_2224 vhci_write 3 2224 NULL
95489 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95490 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95491 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95492 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95493 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95494 +do_update_counters_2259 do_update_counters 4 2259 NULL
95495 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95496 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95497 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
95498 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95499 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95500 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95501 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95502 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95503 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95504 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95505 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95506 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95507 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95508 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95509 +raid1_size_2419 raid1_size 0-2 2419 NULL
95510 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95511 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95512 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95513 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95514 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
95515 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
95516 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95517 +update_pmkid_2481 update_pmkid 4 2481 NULL
95518 +wiphy_new_2482 wiphy_new 2 2482 NULL
95519 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95520 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95521 +dm_write_2513 dm_write 3 2513 NULL
95522 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95523 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95524 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95525 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95526 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95527 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95528 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95529 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95530 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95531 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95532 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95533 +__next_cpu_2782 __next_cpu 1 2782 NULL
95534 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95535 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
95536 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
95537 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95538 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95539 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95540 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95541 +__swab64p_2875 __swab64p 0 2875 NULL
95542 +nla_padlen_2883 nla_padlen 1 2883 NULL
95543 +cmm_write_2896 cmm_write 3 2896 NULL
95544 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
95545 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95546 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95547 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95548 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95549 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95550 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95551 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95552 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95553 +depth_write_3021 depth_write 3 3021 NULL
95554 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95555 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95556 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95557 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95558 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95559 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95560 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95561 +free_coherent_3082 free_coherent 4-2 3082 NULL
95562 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
95563 +rb_alloc_3102 rb_alloc 1 3102 NULL
95564 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95565 +print_time_3132 print_time 0 3132 NULL
95566 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95567 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95568 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95569 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95570 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95571 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95572 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95573 +alloc_context_3194 alloc_context 1 3194 NULL
95574 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95575 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95576 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95577 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95578 +key_key_read_3241 key_key_read 3 3241 NULL
95579 +number_3243 number 0 3243 NULL
95580 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95581 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95582 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95583 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95584 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95585 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
95586 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95587 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95588 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95589 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95590 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95591 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
95592 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
95593 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95594 +send_stream_3397 send_stream 4 3397 NULL
95595 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95596 +msix_map_region_3411 msix_map_region 3 3411 NULL
95597 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95598 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95599 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95600 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95601 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95602 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95603 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95604 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95605 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95606 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95607 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95608 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95609 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95610 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95611 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95612 +evtchn_read_3569 evtchn_read 3 3569 NULL
95613 +vc_resize_3585 vc_resize 2-3 3585 NULL
95614 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95615 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95616 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95617 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95618 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95619 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
95620 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
95621 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95622 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95623 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
95624 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95625 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95626 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95627 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95628 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
95629 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95630 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95631 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95632 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95633 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95634 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95635 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95636 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95637 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95638 +get_fd_set_3866 get_fd_set 1 3866 NULL
95639 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95640 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95641 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95642 +nvram_write_3894 nvram_write 3 3894 NULL
95643 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95644 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95645 +vcs_write_3910 vcs_write 3 3910 NULL
95646 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95647 +do_add_counters_3992 do_add_counters 3 3992 NULL
95648 +userspace_status_4004 userspace_status 4 4004 NULL
95649 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95650 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95651 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95652 +blk_end_request_4024 blk_end_request 3 4024 NULL
95653 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95654 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95655 +read_file_queues_4078 read_file_queues 3 4078 NULL
95656 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95657 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95658 +tm6000_read_4151 tm6000_read 3 4151 NULL
95659 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95660 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95661 +get_alua_req_4166 get_alua_req 3 4166 NULL
95662 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95663 +read_file_bool_4180 read_file_bool 3 4180 NULL
95664 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
95665 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
95666 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
95667 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
95668 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
95669 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
95670 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
95671 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
95672 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
95673 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
95674 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
95675 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
95676 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
95677 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
95678 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
95679 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
95680 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
95681 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
95682 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
95683 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
95684 +set_link_security_4502 set_link_security 4 4502 NULL
95685 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
95686 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
95687 +tty_register_device_4544 tty_register_device 2 4544 NULL
95688 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
95689 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
95690 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
95691 +bch_alloc_4593 bch_alloc 1 4593 NULL
95692 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
95693 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
95694 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
95695 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
95696 +kone_receive_4690 kone_receive 4 4690 NULL
95697 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
95698 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
95699 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
95700 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
95701 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
95702 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
95703 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
95704 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
95705 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
95706 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
95707 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
95708 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
95709 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
95710 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
95711 +sys_ipc_4889 sys_ipc 3 4889 NULL
95712 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
95713 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
95714 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
95715 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
95716 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
95717 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
95718 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
95719 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
95720 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
95721 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
95722 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
95723 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
95724 +do_mincore_5018 do_mincore 0-1 5018 NULL
95725 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
95726 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
95727 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
95728 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
95729 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
95730 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
95731 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
95732 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
95733 +sound_write_5102 sound_write 3 5102 NULL
95734 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
95735 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
95736 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
95737 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
95738 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
95739 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
95740 +skb_network_header_5203 skb_network_header 0 5203 NULL
95741 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
95742 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
95743 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
95744 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
95745 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
95746 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
95747 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
95748 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
95749 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
95750 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
95751 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
95752 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
95753 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
95754 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
95755 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
95756 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
95757 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
95758 +tty_write_5494 tty_write 3 5494 NULL
95759 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
95760 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
95761 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
95762 +spidev_message_5518 spidev_message 3 5518 NULL
95763 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
95764 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
95765 +le_readq_5557 le_readq 0 5557 NULL
95766 +inw_5558 inw 0 5558 NULL
95767 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
95768 +fir16_create_5574 fir16_create 3 5574 NULL
95769 +bioset_create_5580 bioset_create 1 5580 NULL
95770 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
95771 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
95772 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
95773 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
95774 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
95775 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
95776 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
95777 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
95778 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
95779 +get_arg_5694 get_arg 3 5694 NULL
95780 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
95781 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
95782 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
95783 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
95784 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
95785 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
95786 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
95787 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
95788 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
95789 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
95790 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
95791 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
95792 +setup_req_5848 setup_req 3 5848 NULL
95793 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
95794 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
95795 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
95796 +port_show_regs_5904 port_show_regs 3 5904 NULL
95797 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
95798 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
95799 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
95800 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
95801 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
95802 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
95803 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
95804 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
95805 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
95806 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
95807 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
95808 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
95809 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
95810 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
95811 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
95812 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
95813 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
95814 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
95815 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
95816 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
95817 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
95818 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
95819 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
95820 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
95821 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
95822 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
95823 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
95824 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
95825 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
95826 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
95827 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
95828 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
95829 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
95830 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
95831 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
95832 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
95833 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
95834 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
95835 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
95836 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
95837 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
95838 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
95839 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
95840 +mei_read_6507 mei_read 3 6507 NULL
95841 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
95842 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
95843 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
95844 +wdm_read_6549 wdm_read 3 6549 NULL
95845 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
95846 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
95847 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
95848 +usemap_size_6601 usemap_size 0-1 6601 NULL
95849 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
95850 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
95851 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
95852 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
95853 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
95854 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
95855 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
95856 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
95857 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
95858 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
95859 +mpeg_read_6708 mpeg_read 3 6708 NULL
95860 +video_proc_write_6724 video_proc_write 3 6724 NULL
95861 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
95862 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
95863 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
95864 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
95865 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
95866 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
95867 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
95868 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
95869 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
95870 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
95871 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
95872 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
95873 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
95874 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
95875 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
95876 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
95877 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
95878 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
95879 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
95880 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
95881 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
95882 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
95883 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
95884 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
95885 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
95886 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
95887 +request_key_async_6990 request_key_async 4 6990 NULL
95888 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
95889 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
95890 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
95891 +wimax_msg_7030 wimax_msg 4 7030 NULL
95892 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
95893 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
95894 +event_enable_read_7074 event_enable_read 3 7074 NULL
95895 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
95896 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
95897 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
95898 +check_header_7108 check_header 0 7108 NULL
95899 +utf16_strsize_7203 utf16_strsize 0 7203 NULL nohasharray
95900 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 &utf16_strsize_7203
95901 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
95902 +get_param_h_7247 get_param_h 0 7247 NULL
95903 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
95904 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
95905 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
95906 +mgmt_control_7349 mgmt_control 3 7349 NULL
95907 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
95908 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
95909 +hweight_long_7388 hweight_long 0-1 7388 NULL
95910 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
95911 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
95912 +readb_7401 readb 0 7401 NULL
95913 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
95914 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
95915 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
95916 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
95917 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
95918 +garp_request_join_7471 garp_request_join 4 7471 NULL
95919 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
95920 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
95921 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
95922 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
95923 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
95924 +setup_usemap_7524 setup_usemap 3 7524 NULL
95925 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
95926 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
95927 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
95928 +groups_alloc_7614 groups_alloc 1 7614 NULL
95929 +sg_virt_7616 sg_virt 0 7616 NULL
95930 +cpumask_first_7648 cpumask_first 0 7648 NULL
95931 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
95932 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
95933 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
95934 +dev_write_7708 dev_write 3 7708 NULL
95935 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
95936 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
95937 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
95938 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
95939 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
95940 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
95941 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
95942 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
95943 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
95944 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
95945 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
95946 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
95947 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
95948 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
95949 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
95950 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
95951 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
95952 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
95953 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
95954 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
95955 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
95956 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
95957 +sys_mbind_7990 sys_mbind 5 7990 NULL
95958 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
95959 +vcs_read_8017 vcs_read 3 8017 NULL
95960 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
95961 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
95962 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
95963 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
95964 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
95965 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
95966 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
95967 +venus_lookup_8121 venus_lookup 4 8121 NULL
95968 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
95969 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
95970 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
95971 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
95972 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
95973 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
95974 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
95975 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
95976 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
95977 +play_iframe_8219 play_iframe 3 8219 NULL
95978 +create_log_8225 create_log 2 8225 NULL nohasharray
95979 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
95980 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
95981 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
95982 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
95983 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
95984 +init_cdev_8274 init_cdev 1 8274 NULL
95985 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
95986 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
95987 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
95988 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
95989 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
95990 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
95991 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
95992 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
95993 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
95994 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
95995 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
95996 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
95997 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
95998 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
95999 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
96000 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
96001 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
96002 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
96003 +dev_config_8506 dev_config 3 8506 NULL
96004 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
96005 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
96006 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
96007 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
96008 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
96009 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
96010 +profile_remove_8556 profile_remove 3 8556 NULL
96011 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
96012 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
96013 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
96014 +tower_write_8580 tower_write 3 8580 NULL
96015 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
96016 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
96017 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
96018 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
96019 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
96020 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
96021 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
96022 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
96023 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
96024 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
96025 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
96026 +arcfb_write_8702 arcfb_write 3 8702 NULL
96027 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
96028 +init_header_8703 init_header 0 8703 &i_size_read_8703
96029 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
96030 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
96031 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
96032 +f_dupfd_8730 f_dupfd 1 8730 NULL
96033 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
96034 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
96035 +sys_prctl_8766 sys_prctl 4 8766 NULL
96036 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
96037 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
96038 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
96039 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
96040 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
96041 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
96042 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
96043 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
96044 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
96045 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
96046 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
96047 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
96048 +send_pages_8872 send_pages 3 8872 NULL
96049 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
96050 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
96051 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
96052 +layout_commit_8926 layout_commit 3 8926 NULL
96053 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
96054 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
96055 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
96056 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
96057 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
96058 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
96059 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
96060 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
96061 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
96062 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
96063 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
96064 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
96065 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
96066 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
96067 +nla_put_9042 nla_put 3 9042 NULL
96068 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
96069 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
96070 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
96071 +string_9080 string 0 9080 NULL
96072 +create_queues_9088 create_queues 2-3 9088 NULL
96073 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
96074 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
96075 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
96076 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
96077 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
96078 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
96079 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
96080 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
96081 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
96082 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
96083 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
96084 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
96085 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
96086 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
96087 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
96088 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
96089 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
96090 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
96091 +flakey_status_9274 flakey_status 5 9274 NULL
96092 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
96093 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
96094 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
96095 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
96096 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
96097 +read_9397 read 3 9397 NULL
96098 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
96099 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
96100 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
96101 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
96102 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
96103 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
96104 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
96105 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
96106 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
96107 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
96108 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
96109 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
96110 +lp_write_9511 lp_write 3 9511 NULL
96111 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
96112 +lm3533_update_9529 lm3533_update 2 9529 NULL
96113 +read_file_dma_9530 read_file_dma 3 9530 NULL
96114 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
96115 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
96116 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
96117 +readl_9557 readl 0 9557 NULL
96118 +fw_node_create_9559 fw_node_create 2 9559 NULL
96119 +kobj_map_9566 kobj_map 2-3 9566 NULL
96120 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
96121 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
96122 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
96123 +do_sync_9604 do_sync 1 9604 NULL
96124 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
96125 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
96126 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
96127 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
96128 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
96129 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
96130 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
96131 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
96132 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
96133 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
96134 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
96135 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 NULL nohasharray
96136 +is_hole_9694 is_hole 2 9694 &x25_asy_compat_ioctl_9694
96137 +fnb_9703 fnb 2-3 9703 NULL
96138 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
96139 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
96140 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
96141 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
96142 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
96143 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
96144 +do_sigpending_9766 do_sigpending 2 9766 NULL
96145 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
96146 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
96147 +_regmap_write_9803 _regmap_write 2 9803 NULL
96148 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
96149 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
96150 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
96151 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
96152 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
96153 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
96154 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
96155 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
96156 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
96157 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
96158 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
96159 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
96160 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
96161 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
96162 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
96163 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
96164 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
96165 +read_file_misc_9948 read_file_misc 3 9948 NULL
96166 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
96167 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
96168 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
96169 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
96170 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
96171 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
96172 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
96173 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
96174 +handle_request_10024 handle_request 9 10024 NULL
96175 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
96176 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
96177 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
96178 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
96179 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
96180 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
96181 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
96182 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
96183 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
96184 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
96185 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
96186 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
96187 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
96188 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
96189 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
96190 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
96191 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
96192 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
96193 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
96194 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
96195 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
96196 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
96197 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
96198 +read_emulate_10310 read_emulate 2-4 10310 NULL
96199 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
96200 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
96201 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
96202 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
96203 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
96204 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
96205 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
96206 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
96207 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
96208 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
96209 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
96210 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
96211 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
96212 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
96213 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
96214 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
96215 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
96216 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
96217 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
96218 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
96219 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
96220 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
96221 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
96222 +otp_read_10594 otp_read 2-4-5 10594 NULL
96223 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
96224 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
96225 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
96226 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
96227 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
96228 +parport_write_10669 parport_write 0 10669 NULL
96229 +inl_10708 inl 0 10708 NULL nohasharray
96230 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
96231 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
96232 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
96233 +spi_sync_10731 spi_sync 0 10731 NULL
96234 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
96235 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
96236 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
96237 +sys_syslog_10746 sys_syslog 3 10746 NULL
96238 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
96239 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
96240 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
96241 +sys_bind_10799 sys_bind 3 10799 NULL
96242 +compat_put_int_10828 compat_put_int 1 10828 NULL
96243 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
96244 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
96245 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
96246 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
96247 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
96248 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
96249 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96250 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96251 +get_scq_10897 get_scq 2 10897 NULL
96252 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96253 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96254 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96255 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96256 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96257 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96258 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96259 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96260 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96261 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96262 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96263 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96264 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
96265 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96266 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
96267 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96268 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
96269 +count_argc_11083 count_argc 0 11083 NULL
96270 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96271 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96272 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96273 +page_offset_11120 page_offset 0 11120 NULL
96274 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96275 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
96276 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96277 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96278 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96279 +__swab16p_11220 __swab16p 0 11220 NULL
96280 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96281 +of_irq_count_11253 of_irq_count 0 11253 NULL
96282 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96283 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96284 +cru_detect_11272 cru_detect 1 11272 NULL
96285 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96286 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96287 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96288 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
96289 +next_segment_11330 next_segment 0-2-1 11330 NULL
96290 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
96291 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
96292 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
96293 +sel_write_create_11353 sel_write_create 3 11353 NULL
96294 +handle_unit_11355 handle_unit 0-1 11355 NULL
96295 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
96296 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
96297 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
96298 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
96299 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
96300 +str_to_user_11411 str_to_user 2 11411 NULL
96301 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
96302 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
96303 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
96304 +trace_options_read_11419 trace_options_read 3 11419 NULL
96305 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
96306 +prepare_image_11424 prepare_image 0 11424 NULL
96307 +vring_size_11426 vring_size 0-1-2 11426 NULL
96308 +bttv_read_11432 bttv_read 3 11432 NULL
96309 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
96310 +swp_offset_11475 swp_offset 0 11475 NULL
96311 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
96312 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
96313 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
96314 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
96315 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
96316 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
96317 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96318 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96319 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96320 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96321 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96322 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96323 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96324 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96325 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96326 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
96327 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96328 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96329 +split_11691 split 2 11691 NULL
96330 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96331 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96332 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96333 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96334 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96335 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96336 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96337 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96338 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96339 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
96340 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96341 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96342 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96343 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96344 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96345 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96346 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96347 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96348 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96349 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96350 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96351 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
96352 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96353 +atmel_read16_11981 atmel_read16 0 11981 NULL
96354 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96355 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
96356 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96357 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96358 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96359 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96360 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96361 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
96362 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96363 +set_powered_12129 set_powered 4 12129 NULL
96364 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96365 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96366 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96367 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96368 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96369 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96370 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96371 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96372 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96373 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96374 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96375 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96376 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96377 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96378 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96379 +receive_copy_12216 receive_copy 3 12216 NULL
96380 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96381 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
96382 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96383 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96384 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96385 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96386 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96387 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96388 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96389 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96390 +split_bvec_12312 split_bvec 6 12312 NULL
96391 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96392 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96393 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96394 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96395 +receive_packet_12367 receive_packet 2 12367 NULL
96396 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96397 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96398 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
96399 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96400 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96401 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96402 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96403 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96404 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96405 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96406 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
96407 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96408 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96409 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96410 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96411 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96412 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96413 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96414 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96415 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96416 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96417 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
96418 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96419 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96420 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96421 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96422 +ivtv_write_12721 ivtv_write 3 12721 NULL
96423 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96424 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96425 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96426 +listxattr_12769 listxattr 3 12769 NULL
96427 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96428 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96429 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96430 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96431 +readq_12825 readq 0 12825 NULL
96432 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96433 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 NULL nohasharray
96434 +spidev_sync_12842 spidev_sync 0 12842 &ath6kl_wmi_add_wow_pattern_cmd_12842
96435 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96436 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96437 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96438 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96439 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96440 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96441 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
96442 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96443 +bm_status_write_12964 bm_status_write 3 12964 NULL
96444 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96445 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96446 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96447 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96448 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96449 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96450 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96451 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96452 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96453 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
96454 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96455 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96456 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96457 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96458 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96459 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96460 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96461 +blk_update_request_13146 blk_update_request 3 13146 NULL
96462 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96463 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96464 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96465 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96466 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96467 +comedi_read_13199 comedi_read 3 13199 NULL
96468 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96469 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96470 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
96471 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96472 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96473 +fw_download_code_13249 fw_download_code 3 13249 NULL
96474 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96475 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96476 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96477 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96478 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96479 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96480 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96481 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96482 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96483 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
96484 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96485 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96486 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96487 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96488 +sky2_receive_13407 sky2_receive 2 13407 NULL
96489 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96490 +keyring_read_13438 keyring_read 3 13438 NULL
96491 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96492 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96493 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
96494 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96495 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96496 +core_status_13515 core_status 4 13515 NULL
96497 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96498 +bm_init_13529 bm_init 2 13529 NULL
96499 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
96500 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96501 +alloc_tio_13564 alloc_tio 3 13564 NULL
96502 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96503 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96504 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
96505 +cache_write_13589 cache_write 3 13589 NULL
96506 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96507 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96508 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96509 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96510 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96511 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
96512 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96513 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96514 +packet_snd_13634 packet_snd 3 13634 NULL
96515 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96516 +cache_downcall_13666 cache_downcall 3 13666 NULL
96517 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96518 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96519 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96520 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96521 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96522 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96523 +random_read_13815 random_read 3 13815 NULL
96524 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96525 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96526 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96527 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96528 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96529 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96530 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96531 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96532 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96533 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96534 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96535 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96536 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96537 +com90xx_found_13974 com90xx_found 3 13974 NULL
96538 +qcam_read_13977 qcam_read 3 13977 NULL
96539 +dsp_read_13980 dsp_read 2 13980 NULL
96540 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96541 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96542 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
96543 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96544 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96545 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96546 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96547 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96548 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96549 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96550 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96551 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96552 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96553 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96554 +em_canid_change_14150 em_canid_change 3 14150 NULL
96555 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96556 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96557 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96558 +alloc_async_14208 alloc_async 1 14208 NULL
96559 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96560 +pool_status_14230 pool_status 5 14230 NULL
96561 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96562 +inode_to_path_14235 inode_to_path 2 14235 NULL
96563 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96564 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
96565 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96566 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
96567 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96568 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96569 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96570 +rr_status_14293 rr_status 5 14293 NULL
96571 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
96572 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96573 +oo_objects_14319 oo_objects 0 14319 NULL
96574 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96575 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96576 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96577 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96578 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96579 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96580 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96581 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96582 +block_size_14443 block_size 0 14443 NULL
96583 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96584 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96585 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96586 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96587 +stripe_status_14506 stripe_status 5 14506 NULL
96588 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96589 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96590 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96591 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96592 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96593 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96594 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96595 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96596 +dbJoin_14644 dbJoin 0 14644 NULL
96597 +profile_replace_14652 profile_replace 3 14652 NULL
96598 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96599 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96600 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96601 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96602 +vfd_write_14717 vfd_write 3 14717 NULL
96603 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96604 +raid1_resize_14740 raid1_resize 2 14740 NULL
96605 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96606 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96607 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96608 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96609 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
96610 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96611 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96612 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96613 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96614 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96615 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
96616 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96617 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96618 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96619 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96620 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96621 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96622 +unifi_read_14899 unifi_read 3 14899 NULL
96623 +krealloc_14908 krealloc 2 14908 NULL
96624 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96625 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
96626 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96627 +queue_cnt_14951 queue_cnt 0 14951 NULL
96628 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96629 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96630 +setkey_14987 setkey 3 14987 NULL nohasharray
96631 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96632 +vmap_15025 vmap 2 15025 NULL
96633 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96634 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96635 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96636 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96637 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96638 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96639 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
96640 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96641 +start_port_15124 start_port 0 15124 NULL
96642 +memchr_15126 memchr 0 15126 NULL
96643 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96644 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96645 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96646 +reserve_resources_15194 reserve_resources 3 15194 NULL
96647 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96648 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
96649 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96650 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96651 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96652 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96653 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96654 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96655 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96656 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96657 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96658 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96659 +ioread16_15342 ioread16 0 15342 NULL
96660 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96661 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96662 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96663 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96664 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
96665 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
96666 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
96667 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
96668 +get_modalias_15406 get_modalias 2 15406 NULL
96669 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
96670 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
96671 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
96672 +memweight_15450 memweight 2 15450 NULL
96673 +vmalloc_15464 vmalloc 1 15464 NULL
96674 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
96675 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
96676 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
96677 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
96678 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
96679 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
96680 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
96681 +persistent_status_15574 persistent_status 4 15574 NULL
96682 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
96683 +vme_user_write_15587 vme_user_write 3 15587 NULL
96684 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
96685 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
96686 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
96687 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
96688 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
96689 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
96690 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
96691 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
96692 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
96693 +fs_path_add_15648 fs_path_add 3 15648 NULL
96694 +xsd_read_15653 xsd_read 3 15653 NULL
96695 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
96696 +unix_bind_15668 unix_bind 3 15668 NULL
96697 +dm_read_15674 dm_read 3 15674 NULL
96698 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
96699 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
96700 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
96701 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
96702 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
96703 +do_test_15766 do_test 1 15766 NULL
96704 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
96705 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
96706 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
96707 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
96708 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
96709 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
96710 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
96711 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
96712 +table_size_15851 table_size 0-1-2 15851 NULL
96713 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
96714 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
96715 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
96716 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
96717 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
96718 +native_read_msr_15905 native_read_msr 0 15905 NULL
96719 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
96720 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
96721 +power_read_15939 power_read 3 15939 NULL
96722 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
96723 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
96724 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
96725 +set_spte_15977 set_spte 7-6 15977 NULL
96726 +frame_alloc_15981 frame_alloc 4 15981 NULL
96727 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
96728 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
96729 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
96730 +got_frame_16028 got_frame 2 16028 NULL
96731 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
96732 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
96733 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
96734 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
96735 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
96736 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
96737 +fsm_init_16134 fsm_init 2 16134 NULL
96738 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
96739 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
96740 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
96741 +mapping_level_16188 mapping_level 2 16188 NULL
96742 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
96743 +create_table_16213 create_table 2 16213 NULL
96744 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
96745 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
96746 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
96747 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
96748 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
96749 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
96750 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
96751 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
96752 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
96753 +account_16283 account 0-2-4 16283 NULL nohasharray
96754 +mirror_status_16283 mirror_status 5 16283 &account_16283
96755 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
96756 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
96757 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
96758 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
96759 +tps80031_update_16360 tps80031_update 3 16360 NULL
96760 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
96761 +rbd_add_16366 rbd_add 3 16366 NULL
96762 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
96763 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
96764 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
96765 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
96766 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
96767 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
96768 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
96769 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
96770 +raid10_resize_16537 raid10_resize 2 16537 NULL
96771 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
96772 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
96773 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
96774 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
96775 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
96776 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
96777 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
96778 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
96779 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
96780 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
96781 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
96782 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
96783 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
96784 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
96785 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
96786 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
96787 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
96788 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
96789 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
96790 +st_write_16874 st_write 3 16874 NULL
96791 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
96792 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
96793 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
96794 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
96795 +random32_16937 random32 0 16937 NULL
96796 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
96797 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
96798 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
96799 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
96800 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
96801 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
96802 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
96803 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
96804 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
96805 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
96806 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
96807 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
96808 +mac_address_string_17091 mac_address_string 0 17091 NULL
96809 +entry_length_17093 entry_length 0 17093 NULL
96810 +sys_preadv_17100 sys_preadv 3 17100 NULL
96811 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
96812 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
96813 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
96814 +sep_read_17161 sep_read 3 17161 NULL
96815 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
96816 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
96817 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
96818 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
96819 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
96820 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
96821 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
96822 +ms_rw_17220 ms_rw 3-4 17220 NULL
96823 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
96824 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
96825 +alloc_ep_17269 alloc_ep 1 17269 NULL
96826 +pg_read_17276 pg_read 3 17276 NULL
96827 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
96828 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
96829 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
96830 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
96831 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
96832 +skb_pad_17302 skb_pad 2 17302 NULL
96833 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
96834 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
96835 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
96836 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
96837 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
96838 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
96839 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
96840 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
96841 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
96842 +compat_cmd_17465 compat_cmd 2 17465 NULL
96843 +probe_bios_17467 probe_bios 1 17467 NULL
96844 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
96845 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
96846 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
96847 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
96848 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
96849 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
96850 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
96851 +copy_from_user_17559 copy_from_user 3 17559 NULL
96852 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
96853 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
96854 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
96855 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
96856 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
96857 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
96858 +osst_execute_17607 osst_execute 7-6 17607 NULL
96859 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
96860 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
96861 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
96862 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
96863 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
96864 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
96865 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
96866 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
96867 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
96868 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
96869 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
96870 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
96871 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
96872 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
96873 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
96874 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
96875 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
96876 +count_leafs_17842 count_leafs 0 17842 NULL
96877 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
96878 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
96879 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
96880 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
96881 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
96882 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
96883 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
96884 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
96885 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
96886 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
96887 +recover_head_17904 recover_head 3 17904 NULL
96888 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
96889 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
96890 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
96891 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
96892 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
96893 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
96894 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
96895 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
96896 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
96897 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
96898 +prandom32_18007 prandom32 0 18007 NULL
96899 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
96900 +fill_read_18019 fill_read 0 18019 NULL
96901 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
96902 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
96903 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
96904 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
96905 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
96906 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
96907 +packet_came_18072 packet_came 3 18072 NULL
96908 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
96909 +get_vm_area_18080 get_vm_area 1 18080 NULL
96910 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
96911 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
96912 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
96913 +svc_getnl_18120 svc_getnl 0 18120 NULL
96914 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
96915 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
96916 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
96917 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
96918 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
96919 +_has_tag_18169 _has_tag 2 18169 NULL
96920 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
96921 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
96922 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
96923 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
96924 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
96925 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
96926 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
96927 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
96928 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
96929 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
96930 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
96931 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
96932 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
96933 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
96934 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
96935 +um_idi_write_18293 um_idi_write 3 18293 NULL
96936 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
96937 +vga_r_18310 vga_r 0 18310 NULL
96938 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
96939 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
96940 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
96941 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
96942 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
96943 +ep_io_18367 ep_io 0 18367 NULL
96944 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
96945 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
96946 +__video_register_device_18399 __video_register_device 3 18399 NULL
96947 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
96948 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
96949 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
96950 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
96951 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
96952 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
96953 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
96954 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
96955 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
96956 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
96957 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
96958 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
96959 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
96960 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
96961 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
96962 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
96963 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
96964 +debug_output_18575 debug_output 3 18575 NULL
96965 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
96966 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
96967 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
96968 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
96969 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
96970 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
96971 +from_buffer_18625 from_buffer 3 18625 NULL
96972 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
96973 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
96974 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
96975 +unmap_page_18665 unmap_page 2-3 18665 NULL
96976 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
96977 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
96978 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
96979 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
96980 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
96981 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
96982 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
96983 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
96984 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
96985 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
96986 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
96987 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
96988 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
96989 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
96990 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
96991 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
96992 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
96993 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
96994 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
96995 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
96996 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
96997 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
96998 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
96999 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
97000 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
97001 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
97002 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
97003 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
97004 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
97005 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
97006 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
97007 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
97008 +huge_page_size_19008 huge_page_size 0 19008 NULL
97009 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
97010 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
97011 +revalidate_19043 revalidate 2 19043 NULL
97012 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
97013 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
97014 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
97015 +copy_and_check_19089 copy_and_check 3 19089 NULL
97016 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
97017 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
97018 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
97019 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
97020 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
97021 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
97022 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
97023 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
97024 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
97025 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
97026 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
97027 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
97028 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
97029 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
97030 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
97031 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
97032 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
97033 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
97034 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
97035 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
97036 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
97037 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
97038 +qc_capture_19298 qc_capture 3 19298 NULL
97039 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
97040 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
97041 +debug_read_19322 debug_read 3 19322 NULL
97042 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
97043 +read_zero_19366 read_zero 3 19366 NULL
97044 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
97045 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
97046 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
97047 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
97048 +__phys_addr_19434 __phys_addr 0 19434 NULL
97049 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
97050 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
97051 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
97052 +sky2_read16_19475 sky2_read16 0 19475 NULL
97053 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
97054 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
97055 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
97056 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
97057 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
97058 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
97059 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
97060 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
97061 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
97062 +nfsd_read_19568 nfsd_read 5 19568 NULL
97063 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
97064 +bm_status_read_19583 bm_status_read 3 19583 NULL
97065 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
97066 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
97067 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
97068 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
97069 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
97070 +read_reg_19723 read_reg 0 19723 NULL
97071 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
97072 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
97073 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
97074 +p9_client_read_19750 p9_client_read 5 19750 NULL
97075 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
97076 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
97077 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
97078 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
97079 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
97080 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
97081 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
97082 +vip_read_19832 vip_read 3 19832 NULL nohasharray
97083 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
97084 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
97085 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
97086 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
97087 +__nla_put_19857 __nla_put 3 19857 NULL
97088 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
97089 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
97090 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
97091 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
97092 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
97093 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
97094 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
97095 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
97096 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
97097 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
97098 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
97099 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
97100 +team_options_register_20091 team_options_register 3 20091 NULL
97101 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
97102 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
97103 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
97104 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
97105 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
97106 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
97107 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
97108 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
97109 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
97110 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
97111 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
97112 +resource_size_20256 resource_size 0 20256 NULL
97113 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
97114 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
97115 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
97116 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
97117 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
97118 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
97119 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
97120 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
97121 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
97122 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
97123 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
97124 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
97125 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
97126 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
97127 +read_buf_20469 read_buf 2 20469 NULL
97128 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
97129 +fast_user_write_20494 fast_user_write 5 20494 NULL
97130 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
97131 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
97132 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
97133 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
97134 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
97135 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
97136 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
97137 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
97138 +venus_create_20555 venus_create 4 20555 NULL
97139 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
97140 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
97141 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
97142 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
97143 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
97144 +lirc_write_20604 lirc_write 3 20604 NULL
97145 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
97146 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
97147 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
97148 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
97149 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
97150 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
97151 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
97152 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
97153 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
97154 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
97155 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
97156 +cpumask_size_20683 cpumask_size 0 20683 NULL
97157 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
97158 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
97159 +__maestro_read_20700 __maestro_read 0 20700 NULL
97160 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
97161 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
97162 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
97163 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
97164 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
97165 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
97166 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
97167 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
97168 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
97169 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
97170 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
97171 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
97172 +sys_sendto_20809 sys_sendto 6 20809 NULL
97173 +strndup_user_20819 strndup_user 2 20819 NULL
97174 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
97175 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
97176 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
97177 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
97178 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
97179 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
97180 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
97181 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
97182 +htable_bits_20933 htable_bits 0 20933 NULL
97183 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
97184 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
97185 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
97186 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
97187 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
97188 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
97189 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
97190 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
97191 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
97192 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
97193 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
97194 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
97195 +multipath_status_21094 multipath_status 5 21094 NULL
97196 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
97197 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
97198 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
97199 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
97200 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
97201 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
97202 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
97203 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
97204 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
97205 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
97206 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
97207 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
97208 +input_ff_create_21240 input_ff_create 2 21240 NULL
97209 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
97210 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
97211 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
97212 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
97213 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
97214 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
97215 +add_res_range_21310 add_res_range 4 21310 NULL
97216 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
97217 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
97218 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
97219 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
97220 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
97221 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
97222 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
97223 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
97224 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
97225 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
97226 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
97227 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
97228 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
97229 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
97230 +concat_writev_21451 concat_writev 3 21451 NULL
97231 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
97232 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
97233 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
97234 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
97235 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
97236 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
97237 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
97238 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
97239 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
97240 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
97241 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
97242 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
97243 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
97244 +validate_nnode_21638 validate_nnode 0 21638 NULL
97245 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
97246 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
97247 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
97248 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
97249 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
97250 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
97251 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
97252 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
97253 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
97254 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
97255 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
97256 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
97257 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
97258 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
97259 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97260 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97261 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97262 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97263 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97264 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97265 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97266 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97267 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97268 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97269 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97270 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97271 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
97272 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97273 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97274 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97275 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97276 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97277 +ti_recv_22027 ti_recv 4 22027 NULL
97278 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
97279 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97280 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97281 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97282 +mem_rw_22085 mem_rw 3 22085 NULL
97283 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
97284 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97285 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97286 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97287 +compat_insn_22142 compat_insn 2 22142 NULL
97288 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
97289 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97290 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
97291 +fls_22210 fls 0 22210 NULL
97292 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
97293 +mem_write_22232 mem_write 3 22232 NULL
97294 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97295 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97296 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97297 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97298 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
97299 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
97300 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
97301 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
97302 +get_segment_base_22324 get_segment_base 0 22324 NULL
97303 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
97304 +atomic_read_22342 atomic_read 0 22342 NULL
97305 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
97306 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
97307 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
97308 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
97309 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
97310 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
97311 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
97312 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
97313 +zoran_write_22404 zoran_write 3 22404 NULL
97314 +queue_reply_22416 queue_reply 3 22416 NULL
97315 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
97316 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
97317 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
97318 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
97319 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
97320 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
97321 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
97322 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
97323 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97324 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97325 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97326 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97327 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97328 +snapshot_read_22601 snapshot_read 3 22601 NULL
97329 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97330 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97331 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97332 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97333 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97334 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97335 +fill_gap_22681 fill_gap 0 22681 NULL
97336 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97337 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97338 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97339 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97340 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97341 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97342 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97343 +print_frame_22769 print_frame 0 22769 NULL
97344 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97345 +retu_write_22800 retu_write 2 22800 NULL
97346 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97347 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
97348 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
97349 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97350 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
97351 +create_attr_set_22861 create_attr_set 1 22861 NULL
97352 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97353 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97354 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97355 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97356 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97357 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97358 +vme_get_size_22964 vme_get_size 0 22964 NULL
97359 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97360 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97361 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97362 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97363 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97364 +st_status_23032 st_status 5 23032 NULL
97365 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97366 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97367 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97368 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97369 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97370 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97371 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97372 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97373 +fls_long_23096 fls_long 0 23096 NULL
97374 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97375 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97376 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97377 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97378 +__clear_user_23118 __clear_user 0 23118 NULL
97379 +dm_write_async_23120 dm_write_async 3 23120 NULL
97380 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97381 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97382 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
97383 +read_file_ani_23161 read_file_ani 3 23161 NULL
97384 +ioremap_23172 ioremap 1-2 23172 NULL
97385 +usblp_write_23178 usblp_write 3 23178 NULL
97386 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97387 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97388 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97389 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97390 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97391 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
97392 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97393 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97394 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97395 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97396 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97397 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97398 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97399 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97400 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97401 +doc_probe_23285 doc_probe 1 23285 NULL
97402 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97403 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97404 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97405 +page_readlink_23346 page_readlink 3 23346 NULL
97406 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97407 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97408 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97409 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97410 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
97411 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
97412 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97413 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97414 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97415 +event_filter_read_23494 event_filter_read 3 23494 NULL
97416 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97417 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97418 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97419 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97420 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97421 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97422 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97423 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97424 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97425 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97426 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97427 +sInW_23663 sInW 0 23663 NULL
97428 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97429 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97430 +cx18_read_23699 cx18_read 3 23699 NULL
97431 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97432 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97433 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97434 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97435 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97436 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97437 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97438 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
97439 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97440 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97441 +p54_init_common_23850 p54_init_common 1 23850 NULL
97442 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97443 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97444 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97445 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97446 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
97447 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97448 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97449 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97450 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97451 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97452 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97453 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97454 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97455 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97456 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97457 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97458 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97459 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97460 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97461 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97462 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97463 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97464 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97465 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97466 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97467 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
97468 +mpu401_read_24126 mpu401_read 3 24126 NULL
97469 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97470 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97471 +adu_read_24177 adu_read 3 24177 NULL
97472 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97473 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97474 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97475 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97476 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97477 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97478 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97479 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97480 +thin_status_24278 thin_status 5 24278 NULL
97481 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97482 +msg_size_24288 msg_size 0 24288 NULL
97483 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97484 +map_page_24298 map_page 3-4 24298 NULL
97485 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97486 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97487 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97488 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97489 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97490 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97491 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97492 +igetword_24373 igetword 0 24373 NULL
97493 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97494 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97495 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97496 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97497 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
97498 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97499 +smk_user_access_24440 smk_user_access 3 24440 NULL
97500 +page_address_24444 page_address 0 24444 NULL
97501 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97502 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97503 +pd_video_read_24510 pd_video_read 3 24510 NULL
97504 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97505 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97506 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97507 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97508 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97509 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97510 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97511 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
97512 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
97513 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97514 +context_alloc_24645 context_alloc 3 24645 NULL
97515 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97516 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97517 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97518 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97519 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97520 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97521 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97522 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97523 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97524 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97525 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97526 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97527 +cache_read_24790 cache_read 3 24790 NULL
97528 +unpack_str_24798 unpack_str 0 24798 NULL
97529 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97530 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97531 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97532 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97533 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97534 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97535 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97536 +queues_read_24877 queues_read 3 24877 NULL
97537 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97538 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97539 +next_token_24929 next_token 0 24929 NULL
97540 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97541 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97542 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97543 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97544 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97545 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97546 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97547 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97548 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97549 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97550 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97551 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97552 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97553 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
97554 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
97555 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97556 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
97557 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97558 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97559 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
97560 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97561 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97562 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97563 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97564 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97565 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97566 +stripe_status_25259 stripe_status 5 25259 NULL
97567 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97568 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97569 +vfs_writev_25278 vfs_writev 3 25278 NULL
97570 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97571 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97572 +help_25316 help 5 25316 NULL nohasharray
97573 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97574 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97575 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
97576 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97577 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97578 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97579 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97580 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97581 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97582 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97583 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97584 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97585 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97586 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97587 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97588 +sb_permission_25523 sb_permission 0 25523 NULL
97589 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97590 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97591 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97592 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97593 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97594 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97595 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97596 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97597 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
97598 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97599 +__direct_map_25647 __direct_map 5-6 25647 NULL
97600 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97601 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97602 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97603 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97604 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97605 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97606 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97607 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
97608 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97609 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97610 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97611 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97612 +sg_read_25799 sg_read 3 25799 NULL
97613 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
97614 +system_enable_read_25815 system_enable_read 3 25815 NULL
97615 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97616 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97617 +parport_read_25855 parport_read 0 25855 NULL
97618 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97619 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97620 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97621 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97622 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97623 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97624 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97625 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
97626 +rcname_read_25919 rcname_read 3 25919 NULL
97627 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97628 +key_flags_read_25931 key_flags_read 3 25931 NULL
97629 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97630 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
97631 +flush_25957 flush 2 25957 NULL
97632 +video_register_device_25971 video_register_device 3 25971 NULL
97633 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97634 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97635 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97636 +mirror_status_26010 mirror_status 5 26010 NULL
97637 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97638 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97639 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97640 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97641 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97642 +tun_do_read_26047 tun_do_read 5 26047 NULL
97643 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97644 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97645 +cpumask_next_26096 cpumask_next 1 26096 NULL
97646 +skb_cow_26138 skb_cow 2 26138 NULL
97647 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97648 +__fswab64_26155 __fswab64 0 26155 NULL
97649 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97650 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97651 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97652 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97653 +disk_devt_26180 disk_devt 0 26180 NULL
97654 +get_registers_26187 get_registers 3 26187 NULL
97655 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97656 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97657 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97658 +mce_write_26201 mce_write 3 26201 NULL
97659 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97660 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
97661 +bio_split_26235 bio_split 2 26235 NULL
97662 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97663 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97664 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
97665 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
97666 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
97667 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
97668 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
97669 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
97670 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
97671 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
97672 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
97673 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
97674 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
97675 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
97676 +read_vmcore_26501 read_vmcore 3 26501 NULL
97677 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
97678 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
97679 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
97680 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
97681 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
97682 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
97683 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
97684 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
97685 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
97686 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
97687 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
97688 +mmap_region_26649 mmap_region 0-2 26649 NULL
97689 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
97690 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
97691 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
97692 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
97693 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
97694 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
97695 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
97696 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
97697 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
97698 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
97699 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
97700 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
97701 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
97702 +smk_write_load_26829 smk_write_load 3 26829 NULL
97703 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
97704 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
97705 +scnprint_id_26842 scnprint_id 3 26842 NULL
97706 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
97707 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
97708 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
97709 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
97710 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
97711 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
97712 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
97713 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
97714 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
97715 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
97716 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
97717 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
97718 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
97719 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
97720 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
97721 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
97722 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
97723 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
97724 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
97725 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
97726 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
97727 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
97728 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
97729 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
97730 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
97731 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
97732 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
97733 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
97734 +pms_capture_27142 pms_capture 4 27142 NULL
97735 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
97736 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
97737 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
97738 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
97739 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
97740 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
97741 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
97742 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
97743 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
97744 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
97745 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
97746 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
97747 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
97748 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
97749 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
97750 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
97751 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
97752 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
97753 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
97754 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
97755 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
97756 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
97757 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
97758 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
97759 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
97760 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
97761 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
97762 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
97763 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
97764 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
97765 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
97766 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
97767 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
97768 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
97769 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
97770 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
97771 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
97772 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
97773 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
97774 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
97775 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
97776 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
97777 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
97778 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
97779 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
97780 +qword_get_27670 qword_get 0 27670 NULL
97781 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
97782 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
97783 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
97784 +evm_write_key_27715 evm_write_key 3 27715 NULL
97785 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
97786 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
97787 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
97788 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
97789 +kcalloc_27770 kcalloc 1-2 27770 NULL
97790 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
97791 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
97792 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
97793 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
97794 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
97795 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
97796 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
97797 +read_profile_27859 read_profile 3 27859 NULL
97798 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
97799 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
97800 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
97801 +gluebi_write_27905 gluebi_write 3 27905 NULL
97802 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
97803 +bm_find_next_27929 bm_find_next 2 27929 NULL
97804 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
97805 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
97806 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
97807 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
97808 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
97809 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
97810 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
97811 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
97812 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
97813 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
97814 +pool_status_28055 pool_status 5 28055 NULL
97815 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
97816 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
97817 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
97818 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
97819 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
97820 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
97821 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
97822 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
97823 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
97824 +video_read_28148 video_read 3 28148 NULL
97825 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
97826 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
97827 +vread_28173 vread 0 28173 NULL
97828 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
97829 +d_path_28198 d_path 0 28198 NULL
97830 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
97831 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
97832 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
97833 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
97834 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
97835 +usemap_size_28281 usemap_size 0 28281 NULL
97836 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
97837 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
97838 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
97839 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
97840 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
97841 +snapshot_write_28351 snapshot_write 3 28351 NULL
97842 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
97843 +sys_writev_28384 sys_writev 3 28384 NULL
97844 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
97845 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
97846 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
97847 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
97848 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
97849 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
97850 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
97851 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
97852 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
97853 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
97854 +max_response_pages_28492 max_response_pages 0 28492 NULL
97855 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
97856 +__next_node_28521 __next_node 1 28521 NULL
97857 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
97858 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
97859 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
97860 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
97861 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
97862 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
97863 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
97864 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
97865 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
97866 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
97867 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
97868 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
97869 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
97870 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
97871 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
97872 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
97873 +_set_range_28627 _set_range 3 28627 NULL
97874 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
97875 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
97876 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
97877 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
97878 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
97879 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
97880 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
97881 +spi_execute_28736 spi_execute 5 28736 NULL
97882 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
97883 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
97884 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
97885 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
97886 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
97887 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
97888 +sel_write_member_28800 sel_write_member 3 28800 NULL
97889 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
97890 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
97891 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
97892 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
97893 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
97894 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
97895 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
97896 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
97897 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
97898 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
97899 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
97900 +push_rx_28939 push_rx 3 28939 NULL
97901 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
97902 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
97903 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
97904 +bin_uuid_28999 bin_uuid 3 28999 NULL
97905 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
97906 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
97907 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
97908 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
97909 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
97910 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
97911 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
97912 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
97913 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
97914 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
97915 +snprintf_29125 snprintf 0 29125 NULL
97916 +iov_shorten_29130 iov_shorten 0 29130 NULL
97917 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
97918 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
97919 +reshape_ring_29147 reshape_ring 2 29147 NULL
97920 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
97921 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
97922 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
97923 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
97924 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
97925 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
97926 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
97927 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
97928 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
97929 +recover_peb_29238 recover_peb 6-7 29238 NULL
97930 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
97931 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
97932 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
97933 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
97934 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
97935 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
97936 +tun_put_user_29337 tun_put_user 5 29337 NULL
97937 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
97938 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
97939 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
97940 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
97941 +mempool_create_29437 mempool_create 1 29437 NULL
97942 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
97943 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
97944 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
97945 +do_register_entry_29478 do_register_entry 4 29478 NULL
97946 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
97947 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
97948 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
97949 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
97950 +ftrace_write_29551 ftrace_write 3 29551 NULL
97951 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
97952 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
97953 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
97954 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
97955 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
97956 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
97957 +slots_per_page_29601 slots_per_page 0 29601 NULL
97958 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
97959 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
97960 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
97961 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
97962 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
97963 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
97964 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
97965 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
97966 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
97967 +probes_write_29711 probes_write 3 29711 NULL
97968 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
97969 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
97970 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
97971 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
97972 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
97973 +dbAlloc_29794 dbAlloc 0 29794 NULL
97974 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
97975 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
97976 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
97977 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
97978 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
97979 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
97980 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
97981 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
97982 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
97983 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
97984 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
97985 +check586_29914 check586 2 29914 NULL
97986 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
97987 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
97988 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
97989 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
97990 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
97991 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
97992 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
97993 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
97994 +drp_wmove_30043 drp_wmove 4 30043 NULL
97995 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
97996 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
97997 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
97998 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
97999 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
98000 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
98001 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
98002 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
98003 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
98004 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
98005 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
98006 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
98007 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
98008 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
98009 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
98010 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
98011 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
98012 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
98013 +compat_readv_30273 compat_readv 3 30273 NULL
98014 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
98015 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
98016 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
98017 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
98018 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
98019 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
98020 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
98021 +resource_from_user_30341 resource_from_user 3 30341 NULL
98022 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
98023 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
98024 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
98025 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
98026 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
98027 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
98028 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
98029 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
98030 +enable_write_30456 enable_write 3 30456 NULL
98031 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
98032 +urandom_read_30462 urandom_read 3 30462 NULL
98033 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
98034 +write_head_30481 write_head 4 30481 NULL
98035 +adu_write_30487 adu_write 3 30487 NULL
98036 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
98037 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
98038 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
98039 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
98040 +set_le_30581 set_le 4 30581 NULL
98041 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
98042 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
98043 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
98044 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
98045 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
98046 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
98047 +agp_remap_30665 agp_remap 2 30665 NULL
98048 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
98049 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
98050 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
98051 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
98052 +snapshot_status_30744 snapshot_status 5 30744 NULL
98053 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
98054 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
98055 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
98056 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
98057 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
98058 +create_subvol_30836 create_subvol 4 30836 NULL
98059 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
98060 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
98061 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
98062 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
98063 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
98064 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
98065 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
98066 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
98067 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
98068 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
98069 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
98070 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
98071 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
98072 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
98073 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
98074 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
98075 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
98076 +sys_mincore_31079 sys_mincore 1 31079 NULL
98077 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
98078 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
98079 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
98080 +depth_read_31112 depth_read 3 31112 NULL
98081 +ssb_read16_31139 ssb_read16 0 31139 NULL
98082 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
98083 +size_inside_page_31141 size_inside_page 0 31141 NULL
98084 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
98085 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
98086 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
98087 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
98088 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
98089 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
98090 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
98091 +__read_reg_31216 __read_reg 0 31216 NULL
98092 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
98093 +cyy_readb_31240 cyy_readb 0 31240 NULL
98094 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
98095 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
98096 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
98097 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
98098 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
98099 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
98100 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
98101 +command_file_write_31318 command_file_write 3 31318 NULL
98102 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
98103 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
98104 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
98105 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
98106 +inb_31388 inb 0 31388 NULL
98107 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
98108 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
98109 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
98110 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
98111 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
98112 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
98113 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
98114 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
98115 +do_fcntl_31468 do_fcntl 3 31468 NULL
98116 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
98117 +alg_setkey_31485 alg_setkey 3 31485 NULL
98118 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
98119 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
98120 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
98121 +hidraw_write_31536 hidraw_write 3 31536 NULL
98122 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
98123 +usbvision_read_31555 usbvision_read 3 31555 NULL
98124 +normalize_31566 normalize 0-1-2 31566 NULL
98125 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
98126 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
98127 +osst_write_31581 osst_write 3 31581 NULL
98128 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
98129 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
98130 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
98131 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
98132 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
98133 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
98134 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
98135 +__lgread_31668 __lgread 4 31668 NULL
98136 +symbol_string_31670 symbol_string 0 31670 NULL
98137 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
98138 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
98139 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
98140 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
98141 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
98142 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
98143 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
98144 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
98145 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
98146 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
98147 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
98148 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
98149 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
98150 +get_count_order_31800 get_count_order 0 31800 NULL
98151 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
98152 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
98153 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
98154 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
98155 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
98156 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
98157 +xattr_permission_31907 xattr_permission 0 31907 NULL
98158 +new_dir_31919 new_dir 3 31919 NULL
98159 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
98160 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
98161 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
98162 +vb2_write_31948 vb2_write 3 31948 NULL
98163 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
98164 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
98165 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
98166 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
98167 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
98168 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
98169 +calc_hmac_32010 calc_hmac 3 32010 NULL
98170 +aead_len_32021 aead_len 0 32021 NULL
98171 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
98172 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
98173 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
98174 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
98175 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
98176 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
98177 +bio_alloc_32095 bio_alloc 2 32095 NULL
98178 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
98179 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
98180 +disk_status_32120 disk_status 4 32120 NULL
98181 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
98182 +venus_link_32165 venus_link 5 32165 NULL
98183 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
98184 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
98185 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
98186 +load_header_32183 load_header 0 32183 NULL
98187 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
98188 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
98189 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
98190 +lm3533_write_32236 lm3533_write 2 32236 NULL
98191 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
98192 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
98193 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
98194 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
98195 +hex_string_32310 hex_string 0 32310 NULL
98196 +flakey_status_32315 flakey_status 5 32315 NULL
98197 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
98198 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
98199 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
98200 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
98201 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
98202 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
98203 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
98204 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
98205 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
98206 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
98207 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
98208 +log_text_32428 log_text 0 32428 NULL
98209 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
98210 +hid_input_report_32458 hid_input_report 4 32458 NULL
98211 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
98212 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
98213 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
98214 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
98215 +disconnect_32521 disconnect 4 32521 NULL
98216 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
98217 +ilo_read_32531 ilo_read 3 32531 NULL
98218 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
98219 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
98220 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
98221 +__first_node_32558 __first_node 0 32558 NULL
98222 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
98223 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
98224 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
98225 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
98226 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
98227 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
98228 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
98229 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
98230 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
98231 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
98232 +kvmalloc_32646 kvmalloc 1 32646 NULL
98233 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
98234 +generic_readlink_32654 generic_readlink 3 32654 NULL
98235 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
98236 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
98237 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
98238 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
98239 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
98240 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
98241 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
98242 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
98243 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
98244 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
98245 +vga_rseq_32848 vga_rseq 0 32848 NULL
98246 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
98247 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
98248 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
98249 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
98250 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
98251 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
98252 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
98253 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
98254 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
98255 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
98256 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
98257 +compat_filldir_32999 compat_filldir 3 32999 NULL
98258 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
98259 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
98260 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
98261 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
98262 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
98263 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
98264 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
98265 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98266 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98267 +write_node_33121 write_node 4 33121 NULL
98268 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98269 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98270 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98271 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98272 +pp_read_33210 pp_read 3 33210 NULL
98273 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98274 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98275 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98276 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98277 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98278 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
98279 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98280 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98281 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98282 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98283 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98284 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98285 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98286 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
98287 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98288 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98289 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98290 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98291 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98292 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98293 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98294 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98295 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98296 +create_entry_33479 create_entry 2 33479 NULL
98297 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98298 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98299 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98300 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
98301 +res_counter_read_33499 res_counter_read 4 33499 NULL
98302 +fb_read_33506 fb_read 3 33506 NULL
98303 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
98304 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
98305 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
98306 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
98307 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
98308 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
98309 +dup_array_33551 dup_array 3 33551 NULL
98310 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
98311 +count_subheaders_33591 count_subheaders 0 33591 NULL
98312 +scsi_execute_33596 scsi_execute 5 33596 NULL
98313 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
98314 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
98315 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
98316 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
98317 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
98318 +inw_p_33668 inw_p 0 33668 NULL
98319 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
98320 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
98321 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
98322 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
98323 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
98324 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
98325 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
98326 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
98327 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
98328 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
98329 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98330 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98331 +Read_hfc_33755 Read_hfc 0 33755 NULL
98332 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98333 +hashtab_create_33769 hashtab_create 3 33769 NULL
98334 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98335 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98336 +find_next_offset_33804 find_next_offset 3 33804 NULL
98337 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98338 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98339 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98340 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98341 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
98342 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98343 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98344 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98345 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98346 +config_proc_write_33878 config_proc_write 3 33878 NULL
98347 +get_user_pages_33908 get_user_pages 0 33908 NULL
98348 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98349 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98350 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98351 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98352 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98353 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98354 +ppp_write_34034 ppp_write 3 34034 NULL
98355 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98356 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98357 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98358 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98359 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98360 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
98361 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98362 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98363 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98364 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98365 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98366 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98367 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98368 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98369 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98370 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98371 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98372 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98373 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98374 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98375 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98376 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98377 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98378 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98379 +ea_read_34378 ea_read 0 34378 NULL
98380 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98381 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98382 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98383 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
98384 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
98385 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98386 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98387 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98388 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
98389 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98390 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98391 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98392 +alloc_buf_34532 alloc_buf 1 34532 NULL
98393 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98394 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98395 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98396 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98397 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98398 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98399 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98400 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98401 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98402 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98403 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98404 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98405 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98406 +port_print_34704 port_print 3 34704 NULL
98407 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98408 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98409 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98410 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98411 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98412 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
98413 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98414 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98415 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98416 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98417 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98418 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98419 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98420 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
98421 +msg_print_text_34889 msg_print_text 0 34889 NULL
98422 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98423 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98424 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98425 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98426 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98427 +Realloc_34961 Realloc 2 34961 NULL
98428 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98429 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98430 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98431 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98432 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98433 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98434 +store_ifalias_35088 store_ifalias 4 35088 NULL
98435 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98436 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98437 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98438 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98439 +pointer_35138 pointer 0 35138 NULL
98440 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98441 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98442 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98443 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98444 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98445 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98446 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98447 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
98448 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
98449 +set_fd_set_35249 set_fd_set 1 35249 NULL
98450 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98451 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98452 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98453 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98454 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98455 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98456 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98457 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98458 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98459 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
98460 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98461 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98462 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98463 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98464 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98465 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98466 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98467 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98468 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98469 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98470 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
98471 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98472 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98473 +async_setkey_35521 async_setkey 3 35521 NULL
98474 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98475 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98476 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98477 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98478 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98479 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98480 +ReadZReg_35604 ReadZReg 0 35604 NULL
98481 +kernel_readv_35617 kernel_readv 3 35617 NULL
98482 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98483 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
98484 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98485 +store_debug_level_35652 store_debug_level 3 35652 NULL
98486 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
98487 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98488 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98489 +dm_table_create_35687 dm_table_create 3 35687 NULL
98490 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98491 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98492 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98493 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98494 +read_file_stations_35795 read_file_stations 3 35795 NULL
98495 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98496 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98497 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98498 +fls64_35862 fls64 0 35862 NULL
98499 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98500 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98501 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98502 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98503 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98504 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98505 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98506 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98507 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
98508 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98509 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98510 +acl_alloc_35979 acl_alloc 1 35979 NULL
98511 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98512 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98513 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98514 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98515 +sys_init_module_36047 sys_init_module 2 36047 NULL
98516 +account_shadowed_36048 account_shadowed 2 36048 NULL
98517 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98518 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
98519 +write_emulate_36065 write_emulate 2-4 36065 NULL
98520 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98521 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98522 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98523 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98524 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98525 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98526 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98527 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98528 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98529 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98530 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
98531 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98532 +twl_set_36154 twl_set 2 36154 NULL
98533 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98534 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98535 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98536 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98537 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98538 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98539 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98540 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98541 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98542 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98543 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98544 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98545 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98546 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
98547 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98548 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98549 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98550 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98551 +lc_create_36332 lc_create 4 36332 NULL
98552 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98553 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98554 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98555 +to_sector_36361 to_sector 0-1 36361 NULL
98556 +tunables_read_36385 tunables_read 3 36385 NULL
98557 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98558 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98559 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98560 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98561 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98562 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98563 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98564 +get_param_l_36518 get_param_l 0 36518 NULL
98565 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98566 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98567 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98568 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
98569 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98570 +get_entry_len_36549 get_entry_len 0 36549 NULL
98571 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98572 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98573 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98574 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98575 +__erst_read_36579 __erst_read 0 36579 NULL
98576 +put_cmsg_36589 put_cmsg 4 36589 NULL
98577 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98578 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98579 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98580 +format_decode_36638 format_decode 0 36638 NULL
98581 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98582 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98583 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98584 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98585 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98586 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98587 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
98588 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98589 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98590 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98591 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98592 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
98593 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98594 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98595 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98596 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98597 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98598 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
98599 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
98600 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98601 +cm_write_36858 cm_write 3 36858 NULL
98602 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98603 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98604 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98605 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98606 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
98607 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98608 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98609 +div_u64_36951 div_u64 0 36951 NULL
98610 +write_leb_36957 write_leb 5 36957 NULL
98611 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98612 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98613 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
98614 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98615 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98616 +setxattr_37006 setxattr 4 37006 NULL
98617 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
98618 +parse_command_37079 parse_command 2 37079 NULL
98619 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
98620 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98621 +tun_get_user_37094 tun_get_user 5 37094 NULL
98622 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98623 +msg_word_37164 msg_word 0 37164 NULL
98624 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98625 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98626 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98627 +__do_replace_37227 __do_replace 5 37227 NULL
98628 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98629 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98630 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98631 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98632 +c101_run_37279 c101_run 2 37279 NULL
98633 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98634 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98635 +send_msg_37323 send_msg 4 37323 NULL
98636 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98637 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98638 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98639 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98640 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98641 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98642 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98643 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98644 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98645 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98646 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98647 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98648 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98649 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98650 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98651 +get_est_timing_37484 get_est_timing 0 37484 NULL
98652 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
98653 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98654 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98655 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98656 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98657 +hdr_size_37536 hdr_size 0 37536 NULL
98658 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98659 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98660 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98661 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98662 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
98663 +alloc_fd_37637 alloc_fd 1 37637 NULL
98664 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
98665 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
98666 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
98667 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
98668 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
98669 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
98670 +nametbl_header_37698 nametbl_header 2 37698 NULL
98671 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
98672 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
98673 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
98674 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
98675 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
98676 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
98677 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
98678 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
98679 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
98680 +deny_write_access_37813 deny_write_access 0 37813 NULL
98681 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
98682 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
98683 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
98684 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
98685 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
98686 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
98687 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
98688 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
98689 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
98690 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
98691 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
98692 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
98693 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
98694 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
98695 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
98696 +vfs_readv_38011 vfs_readv 3 38011 NULL
98697 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
98698 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
98699 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
98700 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
98701 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
98702 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
98703 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
98704 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
98705 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
98706 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
98707 +ep0_read_38095 ep0_read 3 38095 NULL
98708 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
98709 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
98710 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
98711 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
98712 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
98713 +cdev_add_38176 cdev_add 2-3 38176 NULL
98714 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
98715 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
98716 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
98717 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
98718 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
98719 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
98720 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
98721 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
98722 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
98723 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
98724 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
98725 +verity_status_38273 verity_status 5 38273 NULL
98726 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
98727 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
98728 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
98729 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
98730 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
98731 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
98732 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
98733 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
98734 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
98735 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
98736 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
98737 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
98738 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
98739 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
98740 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
98741 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
98742 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
98743 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
98744 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
98745 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
98746 +dev_names_read_38509 dev_names_read 3 38509 NULL
98747 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
98748 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
98749 +set_queue_count_38519 set_queue_count 0 38519 NULL
98750 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
98751 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
98752 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
98753 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
98754 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
98755 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
98756 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
98757 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
98758 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
98759 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
98760 +delay_status_38606 delay_status 5 38606 NULL
98761 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
98762 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
98763 +cma_create_area_38642 cma_create_area 2 38642 NULL
98764 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
98765 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
98766 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
98767 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
98768 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
98769 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
98770 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
98771 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
98772 +udf_readpages_38761 udf_readpages 4 38761 NULL
98773 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
98774 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
98775 +err_decode_38804 err_decode 2 38804 NULL
98776 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
98777 +sys_select_38827 sys_select 1 38827 NULL
98778 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
98779 +direct_entry_38836 direct_entry 3 38836 NULL
98780 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
98781 +interfaces_38859 interfaces 2 38859 NULL
98782 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
98783 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
98784 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
98785 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
98786 +__fswab16_38898 __fswab16 0 38898 NULL
98787 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
98788 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
98789 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
98790 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
98791 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
98792 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
98793 +udf_new_block_38999 udf_new_block 4 38999 NULL
98794 +get_nodes_39012 get_nodes 3 39012 NULL
98795 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
98796 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
98797 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
98798 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
98799 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
98800 +tun_get_user_39099 tun_get_user 4 39099 NULL
98801 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
98802 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
98803 +ea_foreach_39133 ea_foreach 0 39133 NULL
98804 +generic_permission_39150 generic_permission 0 39150 NULL
98805 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
98806 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
98807 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
98808 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
98809 +init_list_set_39188 init_list_set 2-3 39188 NULL
98810 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
98811 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
98812 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
98813 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
98814 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
98815 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
98816 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
98817 +drm_order_39244 drm_order 0 39244 NULL
98818 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
98819 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
98820 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
98821 +__skb_cow_39254 __skb_cow 2 39254 NULL
98822 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
98823 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
98824 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
98825 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
98826 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
98827 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
98828 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
98829 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
98830 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
98831 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
98832 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
98833 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
98834 +__send_to_port_39386 __send_to_port 3 39386 NULL
98835 +user_power_read_39414 user_power_read 3 39414 NULL
98836 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
98837 +sys_semop_39457 sys_semop 3 39457 NULL
98838 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
98839 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
98840 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
98841 +int_proc_write_39542 int_proc_write 3 39542 NULL
98842 +pp_write_39554 pp_write 3 39554 NULL
98843 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
98844 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
98845 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
98846 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
98847 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
98848 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
98849 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
98850 +ext_depth_39607 ext_depth 0 39607 NULL
98851 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
98852 +sdio_readb_39618 sdio_readb 0 39618 NULL
98853 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
98854 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
98855 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
98856 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
98857 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
98858 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
98859 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
98860 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
98861 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
98862 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
98863 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
98864 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
98865 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
98866 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
98867 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
98868 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
98869 +pkt_add_39897 pkt_add 3 39897 NULL
98870 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
98871 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
98872 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
98873 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
98874 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
98875 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
98876 +__spi_async_39932 __spi_async 0 39932 NULL
98877 +__get_order_39935 __get_order 0 39935 NULL
98878 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
98879 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
98880 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
98881 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
98882 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
98883 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
98884 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
98885 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
98886 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
98887 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
98888 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
98889 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
98890 +add_tty_40055 add_tty 1 40055 NULL nohasharray
98891 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
98892 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
98893 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
98894 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
98895 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
98896 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
98897 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
98898 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
98899 +pt_write_40159 pt_write 3 40159 NULL
98900 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
98901 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
98902 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
98903 +allocate_probes_40204 allocate_probes 1 40204 NULL
98904 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
98905 +compat_put_long_40214 compat_put_long 1 40214 NULL
98906 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
98907 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
98908 +osst_read_40237 osst_read 3 40237 NULL
98909 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
98910 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
98911 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
98912 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
98913 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
98914 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
98915 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
98916 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
98917 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
98918 +mmio_read_40348 mmio_read 4 40348 NULL
98919 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
98920 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
98921 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
98922 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
98923 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
98924 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
98925 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
98926 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
98927 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
98928 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
98929 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
98930 +tty_write_room_40495 tty_write_room 0 40495 NULL
98931 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
98932 +sg_phys_40507 sg_phys 0 40507 NULL
98933 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
98934 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
98935 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
98936 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
98937 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
98938 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
98939 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
98940 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
98941 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
98942 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
98943 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
98944 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
98945 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
98946 +fops_read_40672 fops_read 3 40672 NULL
98947 +tps80031_write_40678 tps80031_write 3 40678 NULL
98948 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
98949 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
98950 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
98951 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
98952 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
98953 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
98954 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
98955 +card_send_command_40757 card_send_command 3 40757 NULL
98956 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
98957 +pg_write_40766 pg_write 3 40766 NULL
98958 +show_list_40775 show_list 3 40775 NULL
98959 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
98960 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
98961 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
98962 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
98963 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
98964 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
98965 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
98966 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
98967 +read_file_queue_40895 read_file_queue 3 40895 NULL
98968 +waiters_read_40902 waiters_read 3 40902 NULL
98969 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
98970 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
98971 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
98972 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
98973 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
98974 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
98975 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
98976 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
98977 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
98978 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
98979 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
98980 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
98981 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
98982 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
98983 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
98984 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
98985 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
98986 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
98987 +dma_attach_41094 dma_attach 5-6 41094 NULL
98988 +provide_user_output_41105 provide_user_output 3 41105 NULL
98989 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
98990 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
98991 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
98992 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
98993 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
98994 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
98995 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
98996 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
98997 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
98998 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
98999 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
99000 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
99001 +erst_read_41260 erst_read 0 41260 NULL
99002 +__fprog_create_41263 __fprog_create 2 41263 NULL
99003 +alloc_context_41283 alloc_context 1 41283 NULL
99004 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
99005 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
99006 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
99007 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
99008 +kmp_init_41373 kmp_init 2 41373 NULL
99009 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
99010 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
99011 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
99012 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
99013 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
99014 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
99015 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
99016 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
99017 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
99018 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
99019 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
99020 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
99021 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
99022 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
99023 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
99024 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
99025 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
99026 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
99027 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
99028 +gserial_setup_41558 gserial_setup 2 41558 NULL
99029 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
99030 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
99031 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
99032 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
99033 +vga_io_r_41609 vga_io_r 0 41609 NULL
99034 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
99035 +a2mp_send_41615 a2mp_send 4 41615 NULL
99036 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
99037 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
99038 +get_std_timing_41654 get_std_timing 0 41654 NULL
99039 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
99040 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
99041 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
99042 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
99043 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
99044 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
99045 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
99046 +fillonedir_41746 fillonedir 3 41746 NULL
99047 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
99048 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
99049 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
99050 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
99051 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
99052 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
99053 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
99054 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
99055 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
99056 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
99057 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
99058 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
99059 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
99060 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
99061 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
99062 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
99063 +portnames_read_41958 portnames_read 3 41958 NULL
99064 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
99065 +dst_mtu_41969 dst_mtu 0 41969 NULL
99066 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
99067 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
99068 +lguest_map_42008 lguest_map 1-2 42008 NULL
99069 +pool_allocate_42012 pool_allocate 3 42012 NULL
99070 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
99071 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
99072 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
99073 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
99074 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
99075 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
99076 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
99077 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
99078 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
99079 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
99080 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
99081 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
99082 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
99083 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
99084 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
99085 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
99086 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
99087 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
99088 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
99089 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
99090 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
99091 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
99092 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
99093 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
99094 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
99095 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
99096 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
99097 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
99098 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
99099 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
99100 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
99101 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
99102 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
99103 +krng_get_random_42420 krng_get_random 3 42420 NULL
99104 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
99105 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
99106 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
99107 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
99108 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
99109 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
99110 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
99111 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
99112 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
99113 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
99114 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
99115 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
99116 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
99117 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
99118 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
99119 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
99120 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
99121 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
99122 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
99123 +map_state_42602 map_state 1 42602 NULL nohasharray
99124 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
99125 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
99126 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
99127 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
99128 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
99129 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
99130 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
99131 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
99132 +vb2_read_42703 vb2_read 3 42703 NULL
99133 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
99134 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
99135 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
99136 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
99137 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
99138 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
99139 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
99140 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
99141 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
99142 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
99143 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
99144 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
99145 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
99146 +set_arg_42824 set_arg 3 42824 NULL
99147 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
99148 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
99149 +prandom_u32_42853 prandom_u32 0 42853 NULL
99150 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
99151 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
99152 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
99153 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
99154 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
99155 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
99156 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
99157 +hd_end_request_42904 hd_end_request 2 42904 NULL
99158 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
99159 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
99160 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
99161 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
99162 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
99163 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
99164 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
99165 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
99166 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
99167 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
99168 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
99169 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
99170 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
99171 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
99172 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
99173 +uuid_string_43154 uuid_string 0 43154 NULL
99174 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
99175 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
99176 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
99177 +process_measurement_43190 process_measurement 0 43190 NULL
99178 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
99179 +uio_write_43202 uio_write 3 43202 NULL
99180 +iso_callback_43208 iso_callback 3 43208 NULL
99181 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
99182 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
99183 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
99184 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
99185 +fixup_leb_43256 fixup_leb 3 43256 NULL
99186 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
99187 +evtchn_write_43278 evtchn_write 3 43278 NULL
99188 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
99189 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
99190 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
99191 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
99192 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
99193 +xenfb_write_43412 xenfb_write 3 43412 NULL
99194 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 NULL nohasharray
99195 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 &gdm_wimax_netif_rx_43423
99196 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
99197 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
99198 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
99199 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
99200 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
99201 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
99202 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
99203 +do_readlink_43518 do_readlink 2 43518 NULL
99204 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
99205 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
99206 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
99207 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
99208 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
99209 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
99210 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
99211 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
99212 +proc_read_43614 proc_read 3 43614 NULL
99213 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
99214 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
99215 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
99216 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
99217 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
99218 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
99219 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
99220 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
99221 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
99222 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
99223 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
99224 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
99225 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
99226 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
99227 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
99228 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
99229 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
99230 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
99231 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
99232 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
99233 +read_flush_43851 read_flush 3 43851 NULL
99234 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
99235 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
99236 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
99237 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
99238 +SendString_43928 SendString 3 43928 NULL
99239 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
99240 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
99241 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
99242 +nla_reserve_43984 nla_reserve 3 43984 NULL
99243 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
99244 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
99245 +emit_flags_44006 emit_flags 4-3 44006 NULL
99246 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
99247 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
99248 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
99249 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
99250 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99251 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99252 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99253 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99254 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99255 +__set_free_44211 __set_free 2 44211 NULL
99256 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99257 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99258 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99259 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99260 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99261 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
99262 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
99263 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99264 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99265 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99266 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
99267 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99268 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99269 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99270 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99271 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99272 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99273 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99274 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99275 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99276 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99277 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99278 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99279 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99280 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99281 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99282 +spidev_write_44510 spidev_write 3 44510 NULL
99283 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99284 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
99285 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
99286 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
99287 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
99288 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
99289 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
99290 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
99291 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
99292 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
99293 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
99294 +mpi_resize_44674 mpi_resize 2 44674 NULL
99295 +ts_read_44687 ts_read 3 44687 NULL
99296 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
99297 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
99298 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
99299 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
99300 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
99301 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
99302 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
99303 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
99304 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
99305 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
99306 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
99307 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
99308 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
99309 +sisusb_write_44834 sisusb_write 3 44834 NULL
99310 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
99311 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
99312 +skb_availroom_44883 skb_availroom 0 44883 NULL
99313 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
99314 +do_tty_write_44896 do_tty_write 5 44896 NULL
99315 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99316 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99317 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
99318 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
99319 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99320 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99321 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99322 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99323 +sel_write_user_45060 sel_write_user 3 45060 NULL
99324 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99325 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99326 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99327 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99328 +usbdev_read_45114 usbdev_read 3 45114 NULL
99329 +send_to_tty_45141 send_to_tty 3 45141 NULL
99330 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99331 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99332 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99333 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99334 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99335 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99336 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99337 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99338 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99339 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99340 +add_child_45201 add_child 4 45201 NULL
99341 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99342 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99343 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99344 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99345 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99346 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99347 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99348 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99349 +keymap_store_45406 keymap_store 4 45406 NULL
99350 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
99351 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99352 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
99353 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99354 +__node_remap_45458 __node_remap 4 45458 NULL
99355 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99356 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99357 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99358 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
99359 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
99360 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99361 +clone_bio_45516 clone_bio 6 45516 NULL
99362 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99363 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99364 +copy_macs_45534 copy_macs 4 45534 NULL
99365 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99366 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99367 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99368 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99369 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99370 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99371 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99372 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99373 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99374 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99375 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99376 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99377 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
99378 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99379 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99380 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99381 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99382 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99383 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99384 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99385 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99386 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99387 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99388 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99389 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99390 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99391 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99392 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99393 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99394 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99395 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99396 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99397 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99398 +amthi_read_45831 amthi_read 4 45831 NULL
99399 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99400 +isdn_write_45863 isdn_write 3 45863 NULL
99401 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
99402 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99403 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99404 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99405 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99406 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99407 +alloc_mr_45935 alloc_mr 1 45935 NULL
99408 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99409 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99410 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99411 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99412 +get_free_entries_46030 get_free_entries 1 46030 NULL
99413 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99414 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99415 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99416 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99417 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99418 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99419 +slhc_toss_46066 slhc_toss 0 46066 NULL
99420 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99421 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99422 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99423 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99424 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99425 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99426 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99427 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99428 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99429 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
99430 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99431 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99432 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99433 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99434 +dsp_write_46218 dsp_write 2 46218 NULL
99435 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99436 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
99437 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99438 +ReadReg_46277 ReadReg 0 46277 NULL
99439 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99440 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99441 +twl6040_write_46351 twl6040_write 2 46351 NULL
99442 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99443 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99444 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99445 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99446 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99447 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99448 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99449 +filldir64_46469 filldir64 3 46469 NULL
99450 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99451 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99452 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99453 +kmsg_read_46514 kmsg_read 3 46514 NULL
99454 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99455 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99456 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99457 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99458 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99459 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99460 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99461 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99462 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99463 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99464 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99465 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99466 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99467 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
99468 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99469 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99470 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99471 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99472 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99473 +prepare_copy_46725 prepare_copy 2 46725 NULL
99474 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99475 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
99476 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99477 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99478 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99479 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
99480 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99481 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99482 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99483 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99484 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
99485 +spi_async_46857 spi_async 0 46857 NULL
99486 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
99487 +vsnprintf_46863 vsnprintf 0 46863 NULL
99488 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99489 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99490 +rvmalloc_46873 rvmalloc 1 46873 NULL
99491 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99492 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99493 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
99494 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99495 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99496 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99497 +fb_write_46924 fb_write 3 46924 NULL
99498 +raid_status_46930 raid_status 5 46930 NULL
99499 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99500 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99501 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99502 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99503 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99504 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99505 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99506 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99507 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99508 +__map_single_47020 __map_single 3-4-7 47020 NULL
99509 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99510 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99511 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
99512 +fs_path_len_47060 fs_path_len 0 47060 NULL
99513 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99514 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99515 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99516 +mousedev_read_47123 mousedev_read 3 47123 NULL
99517 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99518 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99519 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
99520 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99521 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99522 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99523 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99524 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99525 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99526 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99527 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
99528 +l2headersize_47238 l2headersize 0 47238 NULL
99529 +options_write_47243 options_write 3 47243 NULL
99530 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99531 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99532 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99533 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99534 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99535 +vsnprintf_47291 vsnprintf 0 47291 NULL
99536 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99537 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99538 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99539 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99540 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99541 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
99542 +nametbl_list_47391 nametbl_list 2 47391 NULL
99543 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99544 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99545 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99546 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99547 +vzalloc_47421 vzalloc 1 47421 NULL
99548 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99549 +newpart_47485 newpart 6 47485 NULL
99550 +core_sys_select_47494 core_sys_select 1 47494 NULL
99551 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
99552 +unlink_simple_47506 unlink_simple 3 47506 NULL
99553 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99554 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
99555 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99556 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99557 +oz_events_read_47535 oz_events_read 3 47535 NULL
99558 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99559 +cycx_setup_47562 cycx_setup 4 47562 NULL
99560 +read_ldt_47570 read_ldt 2 47570 NULL
99561 +pci_iomap_47575 pci_iomap 3 47575 NULL
99562 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99563 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99564 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
99565 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99566 +uea_request_47613 uea_request 4 47613 NULL
99567 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99568 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
99569 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99570 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99571 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99572 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
99573 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
99574 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99575 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99576 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99577 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99578 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99579 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99580 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
99581 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99582 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99583 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99584 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99585 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99586 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
99587 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99588 +vhci_read_47878 vhci_read 3 47878 NULL
99589 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99590 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99591 +timeout_read_47915 timeout_read 3 47915 NULL
99592 +comedi_write_47926 comedi_write 3 47926 NULL
99593 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99594 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99595 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99596 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
99597 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99598 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99599 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99600 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99601 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99602 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99603 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99604 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99605 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99606 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99607 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99608 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
99609 +set_discoverable_48141 set_discoverable 4 48141 NULL
99610 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99611 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99612 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99613 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99614 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99615 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99616 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
99617 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
99618 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99619 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99620 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99621 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99622 +read_file_recv_48232 read_file_recv 3 48232 NULL
99623 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
99624 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
99625 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99626 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99627 +send_set_info_48288 send_set_info 7 48288 NULL
99628 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99629 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99630 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99631 +hash_setkey_48310 hash_setkey 3 48310 NULL
99632 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99633 +skb_add_data_48363 skb_add_data 3 48363 NULL
99634 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99635 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99636 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
99637 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99638 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99639 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99640 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99641 +send_control_msg_48498 send_control_msg 6 48498 NULL
99642 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99643 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99644 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99645 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99646 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99647 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99648 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99649 +named_distribute_48544 named_distribute 4 48544 NULL
99650 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99651 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
99652 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99653 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99654 +mtd_read_48655 mtd_read 0 48655 NULL
99655 +lc_create_48662 lc_create 3 48662 NULL
99656 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99657 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99658 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99659 +altera_drscan_48698 altera_drscan 2 48698 NULL
99660 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99661 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99662 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99663 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99664 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
99665 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
99666 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
99667 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
99668 +azx_get_position_48841 azx_get_position 0 48841 NULL
99669 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
99670 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
99671 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
99672 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
99673 +get_num_ops_48886 get_num_ops 0 48886 NULL
99674 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
99675 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
99676 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
99677 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
99678 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
99679 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
99680 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
99681 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
99682 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
99683 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
99684 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
99685 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
99686 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
99687 +xd_rw_49020 xd_rw 3-4 49020 NULL
99688 +transient_status_49027 transient_status 4 49027 NULL
99689 +ubi_read_49061 ubi_read 0 49061 NULL
99690 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
99691 +calc_layout_49074 calc_layout 4 49074 NULL
99692 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
99693 +scsi_register_49094 scsi_register 2 49094 NULL
99694 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
99695 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
99696 +pt_read_49136 pt_read 3 49136 NULL
99697 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
99698 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
99699 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
99700 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
99701 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
99702 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
99703 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
99704 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
99705 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
99706 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
99707 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
99708 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
99709 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
99710 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
99711 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
99712 +uio_read_49300 uio_read 3 49300 NULL
99713 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
99714 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
99715 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
99716 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
99717 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
99718 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
99719 +px_raw_event_49371 px_raw_event 4 49371 NULL
99720 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
99721 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
99722 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
99723 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
99724 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
99725 +md_domain_init_49432 md_domain_init 2 49432 NULL
99726 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
99727 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
99728 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
99729 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
99730 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
99731 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
99732 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
99733 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
99734 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
99735 +smk_write_access_49561 smk_write_access 3 49561 NULL
99736 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
99737 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
99738 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
99739 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
99740 +heap_init_49617 heap_init 2 49617 NULL
99741 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
99742 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
99743 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
99744 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
99745 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
99746 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
99747 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
99748 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
99749 +check_frame_49741 check_frame 0 49741 NULL
99750 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
99751 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
99752 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
99753 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
99754 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
99755 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
99756 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
99757 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
99758 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
99759 +add_uuid_49831 add_uuid 4 49831 NULL
99760 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
99761 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
99762 +twl4030_write_49846 twl4030_write 2 49846 NULL
99763 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
99764 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
99765 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
99766 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
99767 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
99768 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
99769 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
99770 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
99771 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
99772 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
99773 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
99774 +__module_alloc_50004 __module_alloc 1 50004 NULL
99775 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
99776 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
99777 +isdn_read_50021 isdn_read 3 50021 NULL
99778 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
99779 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
99780 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
99781 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
99782 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
99783 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
99784 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
99785 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
99786 +read_file_slot_50111 read_file_slot 3 50111 NULL
99787 +copy_items_50140 copy_items 6 50140 NULL
99788 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
99789 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
99790 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
99791 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
99792 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
99793 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
99794 +odev_update_50169 odev_update 2 50169 NULL
99795 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
99796 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
99797 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
99798 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
99799 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
99800 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
99801 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
99802 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
99803 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
99804 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
99805 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
99806 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
99807 +do_launder_page_50329 do_launder_page 0 50329 NULL
99808 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
99809 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
99810 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
99811 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
99812 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
99813 +tpm_read_50344 tpm_read 3 50344 NULL
99814 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
99815 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
99816 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
99817 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
99818 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
99819 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
99820 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
99821 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
99822 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
99823 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
99824 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
99825 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
99826 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
99827 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
99828 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
99829 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
99830 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
99831 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
99832 +fat_readpages_50582 fat_readpages 4 50582 NULL
99833 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
99834 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
99835 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
99836 +__ffs_50625 __ffs 0 50625 NULL
99837 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
99838 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
99839 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
99840 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
99841 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
99842 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
99843 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
99844 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
99845 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
99846 +skb_padto_50759 skb_padto 2 50759 NULL
99847 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
99848 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
99849 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
99850 +tpm_write_50798 tpm_write 3 50798 NULL
99851 +tun_do_read_50800 tun_do_read 4 50800 NULL
99852 +write_flush_50803 write_flush 3 50803 NULL
99853 +dvb_play_50814 dvb_play 3 50814 NULL
99854 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
99855 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
99856 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
99857 +dma_attach_50831 dma_attach 6-7 50831 NULL
99858 +SetArea_50835 SetArea 4 50835 NULL nohasharray
99859 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
99860 +self_check_write_50856 self_check_write 5 50856 NULL
99861 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
99862 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
99863 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
99864 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
99865 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
99866 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
99867 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
99868 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
99869 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
99870 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
99871 +timeout_write_50991 timeout_write 3 50991 NULL
99872 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
99873 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
99874 +proc_write_51003 proc_write 3 51003 NULL
99875 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
99876 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
99877 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
99878 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
99879 +dump_midi_51040 dump_midi 3 51040 NULL
99880 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
99881 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
99882 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
99883 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
99884 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
99885 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
99886 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
99887 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
99888 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
99889 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
99890 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
99891 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
99892 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
99893 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
99894 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
99895 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
99896 +tipc_send_51238 tipc_send 4 51238 NULL
99897 +drm_property_create_51239 drm_property_create 4 51239 NULL
99898 +st_read_51251 st_read 3 51251 NULL
99899 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
99900 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
99901 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
99902 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
99903 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
99904 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
99905 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
99906 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
99907 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
99908 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
99909 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
99910 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
99911 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
99912 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
99913 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
99914 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
99915 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
99916 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
99917 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
99918 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
99919 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
99920 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
99921 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
99922 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
99923 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
99924 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
99925 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
99926 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
99927 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
99928 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
99929 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
99930 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
99931 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
99932 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
99933 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
99934 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
99935 +sel_write_access_51704 sel_write_access 3 51704 NULL
99936 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
99937 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
99938 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
99939 +msg_set_51725 msg_set 3 51725 NULL
99940 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
99941 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
99942 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
99943 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
99944 +if_write_51756 if_write 3 51756 NULL
99945 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
99946 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
99947 +__fswab32_51781 __fswab32 0 51781 NULL
99948 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
99949 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
99950 +wm2000_write_51834 wm2000_write 2 51834 NULL
99951 +ioread32_51847 ioread32 0 51847 NULL nohasharray
99952 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
99953 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
99954 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
99955 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
99956 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
99957 +user_read_51881 user_read 3 51881 NULL
99958 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
99959 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
99960 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
99961 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
99962 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
99963 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
99964 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
99965 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
99966 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
99967 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
99968 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
99969 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
99970 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
99971 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
99972 +rdmalt_52022 rdmalt 0 52022 NULL
99973 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
99974 +override_release_52032 override_release 2 52032 NULL
99975 +end_port_52042 end_port 0 52042 NULL
99976 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
99977 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
99978 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
99979 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
99980 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
99981 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
99982 +retry_count_read_52129 retry_count_read 3 52129 NULL
99983 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
99984 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
99985 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
99986 +htable_size_52148 htable_size 0-1 52148 NULL
99987 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
99988 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
99989 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
99990 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
99991 +print_prefix_52176 print_prefix 0 52176 NULL
99992 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
99993 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
99994 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
99995 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
99996 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
99997 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
99998 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
99999 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
100000 +read_file_reset_52310 read_file_reset 3 52310 NULL
100001 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
100002 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
100003 +hwflags_read_52318 hwflags_read 3 52318 NULL
100004 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
100005 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
100006 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
100007 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
100008 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
100009 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
100010 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
100011 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
100012 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
100013 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
100014 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
100015 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
100016 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
100017 +delay_status_52431 delay_status 5 52431 NULL
100018 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
100019 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
100020 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
100021 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
100022 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
100023 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
100024 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
100025 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
100026 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
100027 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
100028 +emit_code_52583 emit_code 0-3 52583 NULL
100029 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
100030 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
100031 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
100032 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
100033 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
100034 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
100035 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
100036 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
100037 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
100038 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
100039 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
100040 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
100041 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
100042 +twlreg_write_52880 twlreg_write 3 52880 NULL
100043 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
100044 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
100045 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
100046 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
100047 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
100048 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
100049 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
100050 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
100051 +send_packet_52960 send_packet 4 52960 NULL
100052 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
100053 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
100054 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
100055 +num_node_state_52989 num_node_state 0 52989 NULL
100056 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
100057 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
100058 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
100059 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
100060 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
100061 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
100062 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
100063 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
100064 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
100065 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
100066 +verity_status_53120 verity_status 5 53120 NULL
100067 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
100068 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
100069 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
100070 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
100071 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
100072 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
100073 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
100074 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
100075 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
100076 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
100077 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
100078 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
100079 +vm_mmap_53339 vm_mmap 0 53339 NULL
100080 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
100081 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
100082 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
100083 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
100084 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
100085 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
100086 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
100087 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
100088 +n2_run_53459 n2_run 3 53459 NULL
100089 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
100090 +wm831x_write_53469 wm831x_write 2 53469 NULL
100091 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
100092 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
100093 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
100094 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
100095 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
100096 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
100097 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
100098 +check_acl_53512 check_acl 0 53512 NULL
100099 +set_registers_53582 set_registers 3 53582 NULL
100100 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
100101 +__readw_53594 __readw 0 53594 NULL
100102 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
100103 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
100104 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
100105 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
100106 +_preload_range_53676 _preload_range 2-3 53676 NULL
100107 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
100108 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
100109 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 NULL nohasharray
100110 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
100111 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
100112 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
100113 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
100114 +wdm_write_53735 wdm_write 3 53735 NULL
100115 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
100116 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
100117 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
100118 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
100119 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
100120 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
100121 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
100122 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
100123 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
100124 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
100125 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
100126 +pms_read_53873 pms_read 3 53873 NULL
100127 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
100128 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
100129 +proc_file_read_53905 proc_file_read 3 53905 NULL
100130 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
100131 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
100132 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
100133 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
100134 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
100135 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
100136 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
100137 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
100138 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
100139 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
100140 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
100141 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
100142 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
100143 +_malloc_54077 _malloc 1 54077 NULL
100144 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
100145 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
100146 +create_xattr_54106 create_xattr 5 54106 NULL
100147 +strn_len_54122 strn_len 0 54122 NULL
100148 +isku_receive_54130 isku_receive 4 54130 NULL
100149 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
100150 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
100151 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
100152 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
100153 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
100154 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
100155 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
100156 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
100157 +reada_add_block_54247 reada_add_block 2 54247 NULL
100158 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
100159 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
100160 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
100161 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
100162 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
100163 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
100164 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
100165 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
100166 +sprintf_54306 sprintf 0 54306 NULL
100167 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
100168 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
100169 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
100170 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
100171 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
100172 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
100173 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
100174 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
100175 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
100176 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
100177 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
100178 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
100179 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
100180 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
100181 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
100182 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
100183 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
100184 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
100185 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
100186 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
100187 +viacam_read_54526 viacam_read 3 54526 NULL
100188 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
100189 +setsockopt_54539 setsockopt 5 54539 NULL
100190 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
100191 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
100192 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
100193 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
100194 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
100195 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
100196 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
100197 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
100198 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
100199 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
100200 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
100201 +evm_read_key_54674 evm_read_key 3 54674 NULL
100202 +resource_string_54699 resource_string 0 54699 NULL
100203 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
100204 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
100205 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
100206 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
100207 +kzalloc_54740 kzalloc 1 54740 NULL
100208 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
100209 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
100210 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
100211 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
100212 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
100213 +domain_init_54797 domain_init 2 54797 NULL
100214 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
100215 +nfsd_write_54809 nfsd_write 6 54809 NULL
100216 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
100217 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
100218 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
100219 +write_rio_54837 write_rio 3 54837 NULL
100220 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
100221 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
100222 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
100223 +printer_read_54851 printer_read 3 54851 NULL
100224 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
100225 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
100226 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
100227 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
100228 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
100229 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
100230 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
100231 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
100232 +add_port_54941 add_port 2 54941 NULL
100233 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
100234 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
100235 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
100236 +c4_add_card_54968 c4_add_card 3 54968 NULL
100237 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
100238 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
100239 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
100240 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
100241 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
100242 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
100243 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
100244 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
100245 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
100246 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
100247 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100248 +corrupt_data_55120 corrupt_data 0 55120 NULL
100249 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100250 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100251 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100252 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100253 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100254 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100255 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100256 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100257 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
100258 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
100259 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
100260 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
100261 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100262 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100263 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100264 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100265 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100266 +ptrace_request_55288 ptrace_request 3 55288 NULL
100267 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100268 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
100269 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100270 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
100271 +vme_user_read_55338 vme_user_read 3 55338 NULL
100272 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100273 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100274 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100275 +__send_to_port_55383 __send_to_port 3 55383 NULL
100276 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100277 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100278 +alloc_skb_55439 alloc_skb 1 55439 NULL
100279 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100280 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100281 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100282 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100283 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
100284 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
100285 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
100286 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
100287 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
100288 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
100289 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
100290 +ea_get_55522 ea_get 0 55522 NULL
100291 +buffer_size_55534 buffer_size 0 55534 NULL
100292 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
100293 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
100294 +add_partition_55588 add_partition 2 55588 NULL
100295 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
100296 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
100297 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
100298 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
100299 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
100300 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
100301 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
100302 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
100303 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
100304 +read_oldmem_55658 read_oldmem 3 55658 NULL
100305 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
100306 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
100307 +get_info_55681 get_info 3 55681 NULL
100308 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
100309 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
100310 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
100311 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
100312 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
100313 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
100314 +set_local_name_55757 set_local_name 4 55757 NULL
100315 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
100316 +strlen_55778 strlen 0 55778 NULL nohasharray
100317 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
100318 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100319 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100320 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100321 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
100322 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100323 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100324 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100325 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100326 +hsc_write_55875 hsc_write 3 55875 NULL
100327 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100328 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100329 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100330 +handle_response_55951 handle_response 5 55951 NULL
100331 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100332 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100333 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100334 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100335 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100336 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100337 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100338 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100339 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100340 +map_addr_56144 map_addr 7 56144 NULL
100341 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100342 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100343 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100344 +skb_headroom_56200 skb_headroom 0 56200 NULL
100345 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100346 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100347 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100348 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100349 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100350 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
100351 +fd_copyin_56247 fd_copyin 3 56247 NULL
100352 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100353 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100354 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100355 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100356 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100357 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100358 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100359 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100360 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100361 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100362 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100363 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100364 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
100365 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100366 +dev_read_56369 dev_read 3 56369 NULL
100367 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
100368 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
100369 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100370 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100371 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100372 +store_msg_56417 store_msg 3 56417 NULL
100373 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100374 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
100375 +fl_create_56435 fl_create 5 56435 NULL
100376 +gnttab_map_56439 gnttab_map 2 56439 NULL
100377 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100378 +set_connectable_56458 set_connectable 4 56458 NULL
100379 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100380 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100381 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100382 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100383 +ip_options_get_56538 ip_options_get 4 56538 NULL
100384 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100385 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100386 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100387 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100388 +event_filter_write_56609 event_filter_write 3 56609 NULL
100389 +gather_array_56641 gather_array 3 56641 NULL
100390 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100391 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100392 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100393 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100394 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100395 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100396 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100397 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100398 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100399 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100400 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100401 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100402 +do_syslog_56807 do_syslog 3 56807 NULL
100403 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100404 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100405 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100406 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100407 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100408 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100409 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100410 +strcspn_56913 strcspn 0 56913 NULL
100411 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100412 +check_header_56930 check_header 2 56930 NULL
100413 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100414 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100415 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100416 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100417 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100418 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100419 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100420 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100421 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100422 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100423 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100424 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100425 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100426 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100427 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100428 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
100429 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100430 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100431 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100432 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100433 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100434 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100435 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100436 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100437 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100438 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100439 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100440 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100441 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100442 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100443 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100444 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100445 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100446 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100447 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100448 +fw_file_size_57307 fw_file_size 0 57307 NULL
100449 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100450 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100451 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100452 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100453 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100454 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100455 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100456 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100457 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100458 +read_file_blob_57406 read_file_blob 3 57406 NULL
100459 +enclosure_register_57412 enclosure_register 3 57412 NULL
100460 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100461 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
100462 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100463 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100464 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100465 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100466 +ReadReg_57453 ReadReg 0 57453 NULL
100467 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100468 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100469 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100470 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100471 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100472 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100473 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100474 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100475 +skb_headlen_57501 skb_headlen 0 57501 NULL
100476 +copy_in_user_57502 copy_in_user 3 57502 NULL
100477 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100478 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100479 +init_tag_map_57515 init_tag_map 3 57515 NULL
100480 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100481 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100482 +inode_permission_57531 inode_permission 0 57531 NULL
100483 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100484 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100485 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100486 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100487 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
100488 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100489 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100490 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
100491 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
100492 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100493 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100494 +mem_read_57631 mem_read 3 57631 NULL
100495 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100496 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100497 +r3964_write_57662 r3964_write 4 57662 NULL
100498 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100499 +__lgwrite_57669 __lgwrite 4 57669 NULL
100500 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100501 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100502 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100503 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100504 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100505 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100506 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100507 +ld2_57794 ld2 0 57794 NULL
100508 +ivtv_read_57796 ivtv_read 3 57796 NULL
100509 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100510 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100511 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100512 +copy_to_user_57835 copy_to_user 3 57835 NULL
100513 +flash_read_57843 flash_read 3 57843 NULL
100514 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100515 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
100516 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100517 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100518 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100519 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100520 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100521 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100522 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100523 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100524 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100525 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100526 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100527 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100528 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100529 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100530 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100531 +mc13783_write_58033 mc13783_write 2 58033 NULL
100532 +mce_async_out_58056 mce_async_out 3 58056 NULL
100533 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100534 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100535 +cm4040_write_58079 cm4040_write 3 58079 NULL
100536 +udi_log_event_58105 udi_log_event 3 58105 NULL
100537 +savemem_58129 savemem 3 58129 NULL
100538 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100539 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100540 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100541 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100542 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100543 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
100544 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100545 +read_file_debug_58256 read_file_debug 3 58256 NULL
100546 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100547 +profile_load_58267 profile_load 3 58267 NULL
100548 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100549 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100550 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100551 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100552 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100553 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100554 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100555 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
100556 +next_pidmap_58347 next_pidmap 2 58347 NULL
100557 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100558 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100559 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100560 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100561 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100562 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100563 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100564 +capabilities_read_58457 capabilities_read 3 58457 NULL
100565 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100566 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100567 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100568 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100569 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100570 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100571 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
100572 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100573 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100574 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100575 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100576 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100577 +xip_file_read_58592 xip_file_read 3 58592 NULL
100578 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100579 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100580 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100581 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100582 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100583 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100584 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100585 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100586 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100587 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100588 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100589 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100590 +acpi_map_58725 acpi_map 1-2 58725 NULL
100591 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100592 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100593 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100594 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100595 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100596 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100597 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100598 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100599 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100600 +ep_read_58813 ep_read 3 58813 NULL
100601 +command_write_58841 command_write 3 58841 NULL
100602 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100603 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100604 +hw_write_58881 hw_write 2 58881 NULL
100605 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100606 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100607 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100608 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100609 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100610 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100611 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100612 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100613 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100614 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100615 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100616 +ep_write_59008 ep_write 3 59008 NULL
100617 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100618 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100619 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100620 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100621 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100622 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
100623 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100624 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100625 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100626 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100627 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100628 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100629 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100630 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100631 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100632 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100633 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100634 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100635 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100636 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100637 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100638 +dt3155_read_59226 dt3155_read 3 59226 NULL
100639 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100640 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
100641 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100642 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100643 +nla_len_59258 nla_len 0 59258 NULL
100644 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
100645 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100646 +fd_copyout_59323 fd_copyout 3 59323 NULL
100647 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100648 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100649 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
100650 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100651 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100652 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100653 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100654 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
100655 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100656 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100657 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100658 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100659 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100660 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100661 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100662 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
100663 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100664 +tunables_write_59563 tunables_write 3 59563 NULL
100665 +memdup_user_59590 memdup_user 2 59590 NULL
100666 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
100667 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
100668 +mtrr_write_59622 mtrr_write 3 59622 NULL
100669 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
100670 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
100671 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
100672 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
100673 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
100674 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
100675 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
100676 +wm8400_write_59675 wm8400_write 2 59675 NULL
100677 +sriov_enable_59689 sriov_enable 2 59689 NULL
100678 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
100679 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
100680 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
100681 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
100682 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
100683 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
100684 +strnlen_59746 strnlen 0 59746 NULL
100685 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
100686 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
100687 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
100688 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
100689 +venus_remove_59781 venus_remove 4 59781 NULL
100690 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
100691 +ipw_write_59807 ipw_write 3 59807 NULL
100692 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
100693 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
100694 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
100695 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
100696 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
100697 +tun_put_user_59849 tun_put_user 4 59849 NULL
100698 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
100699 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
100700 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
100701 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
100702 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
100703 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 NULL nohasharray
100704 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 &compat_ipmi_ioctl_59956
100705 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
100706 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
100707 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
100708 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
100709 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
100710 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
100711 +register_device_60015 register_device 2-3 60015 NULL
100712 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
100713 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
100714 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
100715 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
100716 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
100717 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
100718 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
100719 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
100720 +load_module_60056 load_module 2 60056 NULL nohasharray
100721 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
100722 +compat_writev_60063 compat_writev 3 60063 NULL
100723 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
100724 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
100725 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
100726 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
100727 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
100728 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
100729 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
100730 +init_state_60165 init_state 2 60165 NULL
100731 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
100732 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
100733 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
100734 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
100735 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
100736 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
100737 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
100738 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
100739 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
100740 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
100741 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
100742 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
100743 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
100744 +printer_write_60276 printer_write 3 60276 NULL
100745 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
100746 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
100747 +getDataLength_60301 getDataLength 0 60301 NULL
100748 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
100749 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
100750 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
100751 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
100752 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
100753 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
100754 +driver_names_read_60399 driver_names_read 3 60399 NULL
100755 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
100756 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
100757 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
100758 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
100759 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
100760 +rx_data_60442 rx_data 4 60442 NULL
100761 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
100762 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
100763 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
100764 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
100765 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
100766 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
100767 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
100768 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
100769 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
100770 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
100771 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
100772 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
100773 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
100774 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
100775 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
100776 +init_data_container_60709 init_data_container 1 60709 NULL
100777 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
100778 +raid_status_60755 raid_status 5 60755 NULL
100779 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
100780 +opticon_write_60775 opticon_write 4 60775 NULL
100781 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
100782 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
100783 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
100784 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
100785 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
100786 +generic_writepages_60871 generic_writepages 0 60871 NULL
100787 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
100788 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
100789 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
100790 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
100791 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
100792 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
100793 +pti_char_write_60960 pti_char_write 3 60960 NULL
100794 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
100795 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
100796 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
100797 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
100798 +symtab_init_61050 symtab_init 2 61050 NULL
100799 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
100800 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
100801 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
100802 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
100803 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
100804 +get_derived_key_61100 get_derived_key 4 61100 NULL
100805 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
100806 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
100807 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
100808 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
100809 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
100810 +__vmalloc_61168 __vmalloc 1 61168 NULL
100811 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
100812 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
100813 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
100814 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
100815 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
100816 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
100817 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
100818 +sys_add_key_61288 sys_add_key 4 61288 NULL
100819 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
100820 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
100821 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
100822 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
100823 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
100824 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
100825 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
100826 +change_xattr_61390 change_xattr 5 61390 NULL
100827 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
100828 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
100829 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
100830 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
100831 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
100832 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
100833 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
100834 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
100835 +erst_errno_61526 erst_errno 0 61526 NULL
100836 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
100837 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
100838 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
100839 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
100840 +seq_open_private_61589 seq_open_private 3 61589 NULL
100841 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
100842 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
100843 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
100844 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
100845 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
100846 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
100847 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
100848 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
100849 +resize_stripes_61650 resize_stripes 2 61650 NULL
100850 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
100851 +insert_one_name_61668 insert_one_name 7 61668 NULL
100852 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
100853 +lock_loop_61681 lock_loop 1 61681 NULL
100854 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
100855 +filter_read_61692 filter_read 3 61692 NULL
100856 +iov_length_61716 iov_length 0 61716 NULL
100857 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
100858 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
100859 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
100860 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
100861 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
100862 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
100863 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
100864 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
100865 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
100866 +get_fw_name_61874 get_fw_name 3 61874 NULL
100867 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
100868 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
100869 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
100870 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
100871 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
100872 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
100873 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
100874 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
100875 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
100876 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
100877 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
100878 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
100879 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
100880 +cow_file_range_61979 cow_file_range 3 61979 NULL
100881 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
100882 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
100883 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
100884 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
100885 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
100886 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
100887 +do_pselect_62061 do_pselect 1 62061 NULL
100888 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
100889 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
100890 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
100891 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
100892 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
100893 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
100894 +ql_status_62135 ql_status 5 62135 NULL
100895 +video_usercopy_62151 video_usercopy 2 62151 NULL
100896 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
100897 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
100898 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
100899 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
100900 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
100901 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
100902 +allocate_partition_62245 allocate_partition 4 62245 NULL
100903 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
100904 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
100905 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
100906 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
100907 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
100908 +subseq_list_62332 subseq_list 3-0 62332 NULL
100909 +flash_write_62354 flash_write 3 62354 NULL
100910 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
100911 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
100912 +altera_irscan_62396 altera_irscan 2 62396 NULL
100913 +set_ssp_62411 set_ssp 4 62411 NULL
100914 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
100915 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
100916 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
100917 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
100918 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
100919 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
100920 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
100921 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
100922 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
100923 +debugfs_read_62535 debugfs_read 3 62535 NULL
100924 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
100925 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
100926 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
100927 +get_subdir_62581 get_subdir 3 62581 NULL
100928 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
100929 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
100930 +get_desc_base_62617 get_desc_base 0 62617 NULL
100931 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
100932 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
100933 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
100934 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
100935 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
100936 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
100937 +write_62671 write 3 62671 NULL
100938 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
100939 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
100940 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
100941 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
100942 +rdm_62719 rdm 0 62719 NULL
100943 +key_replays_read_62746 key_replays_read 3 62746 NULL
100944 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
100945 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
100946 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
100947 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
100948 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
100949 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
100950 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
100951 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
100952 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
100953 +aoechr_write_62883 aoechr_write 3 62883 NULL nohasharray
100954 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 &aoechr_write_62883
100955 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
100956 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
100957 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
100958 +getdqbuf_62908 getdqbuf 1 62908 NULL
100959 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
100960 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
100961 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
100962 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
100963 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
100964 +unlink1_63059 unlink1 3 63059 NULL
100965 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
100966 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
100967 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
100968 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
100969 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
100970 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
100971 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
100972 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
100973 +vme_master_read_63221 vme_master_read 0 63221 NULL
100974 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
100975 +ptp_read_63251 ptp_read 4 63251 NULL
100976 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
100977 +raid5_resize_63306 raid5_resize 2 63306 NULL
100978 +proc_info_read_63344 proc_info_read 3 63344 NULL
100979 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
100980 +idmouse_read_63374 idmouse_read 3 63374 NULL
100981 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
100982 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
100983 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
100984 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
100985 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
100986 +kone_send_63435 kone_send 4 63435 NULL
100987 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
100988 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
100989 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
100990 +read_kcore_63488 read_kcore 3 63488 NULL
100991 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
100992 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
100993 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
100994 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
100995 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
100996 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
100997 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
100998 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
100999 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
101000 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
101001 +module_alloc_63630 module_alloc 1 63630 NULL
101002 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
101003 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
101004 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
101005 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
101006 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
101007 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
101008 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
101009 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
101010 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
101011 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
101012 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
101013 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
101014 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
101015 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
101016 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
101017 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
101018 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
101019 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
101020 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
101021 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
101022 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
101023 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
101024 +sel_write_load_63830 sel_write_load 3 63830 NULL
101025 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
101026 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
101027 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
101028 +divas_write_63901 divas_write 3 63901 NULL
101029 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
101030 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
101031 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
101032 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
101033 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
101034 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
101035 +__team_options_register_63941 __team_options_register 3 63941 NULL
101036 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
101037 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
101038 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
101039 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
101040 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
101041 +kmemdup_64015 kmemdup 2 64015 NULL
101042 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
101043 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
101044 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
101045 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
101046 +get_u8_64076 get_u8 0 64076 NULL
101047 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
101048 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
101049 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
101050 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
101051 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
101052 +init_bch_64130 init_bch 1-2 64130 NULL
101053 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
101054 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
101055 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
101056 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
101057 +read_pulse_64227 read_pulse 0-3 64227 NULL
101058 +header_len_64232 header_len 0 64232 NULL
101059 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
101060 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
101061 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
101062 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
101063 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
101064 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
101065 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
101066 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
101067 +ffz_64324 ffz 0 64324 NULL
101068 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
101069 +ts_write_64336 ts_write 3 64336 NULL
101070 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
101071 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
101072 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
101073 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
101074 +ilo_write_64378 ilo_write 3 64378 NULL
101075 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
101076 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
101077 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
101078 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
101079 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
101080 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
101081 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
101082 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
101083 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
101084 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
101085 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
101086 +cap_capable_64462 cap_capable 0 64462 NULL
101087 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
101088 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
101089 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
101090 +remove_uuid_64505 remove_uuid 4 64505 NULL
101091 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
101092 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
101093 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
101094 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
101095 +__spi_sync_64561 __spi_sync 0 64561 NULL
101096 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
101097 +fanotify_write_64623 fanotify_write 3 64623 NULL
101098 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
101099 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
101100 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
101101 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
101102 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
101103 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
101104 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
101105 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
101106 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
101107 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
101108 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
101109 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
101110 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
101111 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
101112 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
101113 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
101114 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
101115 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
101116 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
101117 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
101118 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
101119 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
101120 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
101121 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
101122 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
101123 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
101124 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
101125 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
101126 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
101127 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
101128 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
101129 +pskb_pull_65005 pskb_pull 2 65005 NULL
101130 +unifi_write_65012 unifi_write 3 65012 NULL
101131 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
101132 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
101133 +insert_dent_65034 insert_dent 7 65034 NULL
101134 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
101135 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
101136 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
101137 +make_idx_node_65068 make_idx_node 0 65068 NULL
101138 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
101139 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
101140 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
101141 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
101142 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
101143 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
101144 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
101145 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
101146 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
101147 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
101148 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
101149 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
101150 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
101151 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
101152 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
101153 +get_var_len_65304 get_var_len 0 65304 NULL
101154 +unpack_array_65318 unpack_array 0 65318 NULL
101155 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
101156 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
101157 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
101158 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
101159 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
101160 +strchr_65372 strchr 0 65372 NULL
101161 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
101162 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
101163 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
101164 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
101165 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
101166 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
101167 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
101168 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
101169 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
101170 +regmap_write_65478 regmap_write 2 65478 NULL
101171 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
101172 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
101173 +alloc_dr_65495 alloc_dr 2 65495 NULL
101174 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
101175 new file mode 100644
101176 index 0000000..9db0d0e
101177 --- /dev/null
101178 +++ b/tools/gcc/size_overflow_plugin.c
101179 @@ -0,0 +1,2114 @@
101180 +/*
101181 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
101182 + * Licensed under the GPL v2, or (at your option) v3
101183 + *
101184 + * Homepage:
101185 + * http://www.grsecurity.net/~ephox/overflow_plugin/
101186 + *
101187 + * Documentation:
101188 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
101189 + *
101190 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
101191 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
101192 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
101193 + *
101194 + * Usage:
101195 + * $ 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
101196 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
101197 + */
101198 +
101199 +#include "gcc-plugin.h"
101200 +#include "config.h"
101201 +#include "system.h"
101202 +#include "coretypes.h"
101203 +#include "tree.h"
101204 +#include "tree-pass.h"
101205 +#include "intl.h"
101206 +#include "plugin-version.h"
101207 +#include "tm.h"
101208 +#include "toplev.h"
101209 +#include "function.h"
101210 +#include "tree-flow.h"
101211 +#include "plugin.h"
101212 +#include "gimple.h"
101213 +#include "diagnostic.h"
101214 +#include "cfgloop.h"
101215 +
101216 +#if BUILDING_GCC_VERSION >= 4008
101217 +#define TODO_dump_func 0
101218 +#endif
101219 +
101220 +struct size_overflow_hash {
101221 + const struct size_overflow_hash * const next;
101222 + const char * const name;
101223 + const unsigned int param;
101224 +};
101225 +
101226 +#include "size_overflow_hash.h"
101227 +
101228 +enum mark {
101229 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
101230 +};
101231 +
101232 +enum err_code_conditions {
101233 + CAST_ONLY, FROM_CONST
101234 +};
101235 +
101236 +static unsigned int call_count = 0;
101237 +
101238 +#define __unused __attribute__((__unused__))
101239 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
101240 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
101241 +#define BEFORE_STMT true
101242 +#define AFTER_STMT false
101243 +#define CREATE_NEW_VAR NULL_TREE
101244 +#define CODES_LIMIT 32
101245 +#define MAX_PARAM 31
101246 +#define MY_STMT GF_PLF_1
101247 +#define NO_CAST_CHECK GF_PLF_2
101248 +#define FROM_ARG true
101249 +#define FROM_RET false
101250 +
101251 +#if BUILDING_GCC_VERSION == 4005
101252 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101253 +#endif
101254 +
101255 +int plugin_is_GPL_compatible;
101256 +void debug_gimple_stmt(gimple gs);
101257 +
101258 +static tree expand(struct pointer_set_t *visited, tree lhs);
101259 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101260 +static tree report_size_overflow_decl;
101261 +static const_tree const_char_ptr_type_node;
101262 +static unsigned int handle_function(void);
101263 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101264 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101265 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101266 +static void print_missing_msg(tree func, unsigned int argnum);
101267 +
101268 +static struct plugin_info size_overflow_plugin_info = {
101269 + .version = "20130410beta",
101270 + .help = "no-size-overflow\tturn off size overflow checking\n",
101271 +};
101272 +
101273 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101274 +{
101275 + unsigned int arg_count;
101276 + enum tree_code code = TREE_CODE(*node);
101277 +
101278 + switch (code) {
101279 + case FUNCTION_DECL:
101280 + arg_count = type_num_arguments(TREE_TYPE(*node));
101281 + break;
101282 + case FUNCTION_TYPE:
101283 + case METHOD_TYPE:
101284 + arg_count = type_num_arguments(*node);
101285 + break;
101286 + default:
101287 + *no_add_attrs = true;
101288 + error("%s: %qE attribute only applies to functions", __func__, name);
101289 + return NULL_TREE;
101290 + }
101291 +
101292 + for (; args; args = TREE_CHAIN(args)) {
101293 + tree position = TREE_VALUE(args);
101294 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101295 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101296 + *no_add_attrs = true;
101297 + }
101298 + }
101299 + return NULL_TREE;
101300 +}
101301 +
101302 +static const char* get_asm_name(tree node)
101303 +{
101304 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
101305 +}
101306 +
101307 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101308 +{
101309 + unsigned int arg_count, arg_num;
101310 + enum tree_code code = TREE_CODE(*node);
101311 +
101312 + switch (code) {
101313 + case FUNCTION_DECL:
101314 + arg_count = type_num_arguments(TREE_TYPE(*node));
101315 + break;
101316 + case FUNCTION_TYPE:
101317 + case METHOD_TYPE:
101318 + arg_count = type_num_arguments(*node);
101319 + break;
101320 + case FIELD_DECL:
101321 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101322 + if (arg_num != 0) {
101323 + *no_add_attrs = true;
101324 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101325 + }
101326 + return NULL_TREE;
101327 + default:
101328 + *no_add_attrs = true;
101329 + error("%qE attribute only applies to functions", name);
101330 + return NULL_TREE;
101331 + }
101332 +
101333 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101334 + return NULL_TREE;
101335 +
101336 + for (; args; args = TREE_CHAIN(args)) {
101337 + tree position = TREE_VALUE(args);
101338 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101339 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101340 + *no_add_attrs = true;
101341 + }
101342 + }
101343 + return NULL_TREE;
101344 +}
101345 +
101346 +static struct attribute_spec size_overflow_attr = {
101347 + .name = "size_overflow",
101348 + .min_length = 1,
101349 + .max_length = -1,
101350 + .decl_required = true,
101351 + .type_required = false,
101352 + .function_type_required = false,
101353 + .handler = handle_size_overflow_attribute,
101354 +#if BUILDING_GCC_VERSION >= 4007
101355 + .affects_type_identity = false
101356 +#endif
101357 +};
101358 +
101359 +static struct attribute_spec intentional_overflow_attr = {
101360 + .name = "intentional_overflow",
101361 + .min_length = 1,
101362 + .max_length = -1,
101363 + .decl_required = true,
101364 + .type_required = false,
101365 + .function_type_required = false,
101366 + .handler = handle_intentional_overflow_attribute,
101367 +#if BUILDING_GCC_VERSION >= 4007
101368 + .affects_type_identity = false
101369 +#endif
101370 +};
101371 +
101372 +static void register_attributes(void __unused *event_data, void __unused *data)
101373 +{
101374 + register_attribute(&size_overflow_attr);
101375 + register_attribute(&intentional_overflow_attr);
101376 +}
101377 +
101378 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101379 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101380 +{
101381 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101382 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101383 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101384 +
101385 + unsigned int m = 0x57559429;
101386 + unsigned int n = 0x5052acdb;
101387 + const unsigned int *key4 = (const unsigned int *)key;
101388 + unsigned int h = len;
101389 + unsigned int k = len + seed + n;
101390 + unsigned long long p;
101391 +
101392 + while (len >= 8) {
101393 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101394 + len -= 8;
101395 + }
101396 + if (len >= 4) {
101397 + cwmixb(key4[0]) key4 += 1;
101398 + len -= 4;
101399 + }
101400 + if (len)
101401 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101402 + cwmixb(h ^ (k + n));
101403 + return k ^ h;
101404 +
101405 +#undef cwfold
101406 +#undef cwmixa
101407 +#undef cwmixb
101408 +}
101409 +
101410 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101411 +{
101412 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101413 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101414 + return fn ^ codes;
101415 +}
101416 +
101417 +static inline tree get_original_function_decl(tree fndecl)
101418 +{
101419 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101420 + return DECL_ABSTRACT_ORIGIN(fndecl);
101421 + return fndecl;
101422 +}
101423 +
101424 +static inline gimple get_def_stmt(const_tree node)
101425 +{
101426 + gcc_assert(node != NULL_TREE);
101427 + if (TREE_CODE(node) != SSA_NAME)
101428 + return NULL;
101429 + return SSA_NAME_DEF_STMT(node);
101430 +}
101431 +
101432 +static unsigned char get_tree_code(const_tree type)
101433 +{
101434 + switch (TREE_CODE(type)) {
101435 + case ARRAY_TYPE:
101436 + return 0;
101437 + case BOOLEAN_TYPE:
101438 + return 1;
101439 + case ENUMERAL_TYPE:
101440 + return 2;
101441 + case FUNCTION_TYPE:
101442 + return 3;
101443 + case INTEGER_TYPE:
101444 + return 4;
101445 + case POINTER_TYPE:
101446 + return 5;
101447 + case RECORD_TYPE:
101448 + return 6;
101449 + case UNION_TYPE:
101450 + return 7;
101451 + case VOID_TYPE:
101452 + return 8;
101453 + case REAL_TYPE:
101454 + return 9;
101455 + case VECTOR_TYPE:
101456 + return 10;
101457 + case REFERENCE_TYPE:
101458 + return 11;
101459 + case OFFSET_TYPE:
101460 + return 12;
101461 + case COMPLEX_TYPE:
101462 + return 13;
101463 + default:
101464 + debug_tree((tree)type);
101465 + gcc_unreachable();
101466 + }
101467 +}
101468 +
101469 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101470 +{
101471 + gcc_assert(type != NULL_TREE);
101472 +
101473 + while (type && len < CODES_LIMIT) {
101474 + tree_codes[len] = get_tree_code(type);
101475 + len++;
101476 + type = TREE_TYPE(type);
101477 + }
101478 + return len;
101479 +}
101480 +
101481 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101482 +{
101483 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101484 + enum tree_code code = TREE_CODE(type);
101485 + size_t len = 0;
101486 +
101487 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101488 +
101489 + arg = TYPE_ARG_TYPES(type);
101490 + // skip builtins __builtin_constant_p
101491 + if (!arg && DECL_BUILT_IN(fndecl))
101492 + return 0;
101493 +
101494 + if (TREE_CODE_CLASS(code) == tcc_type)
101495 + result = type;
101496 + else
101497 + result = DECL_RESULT(fndecl);
101498 +
101499 + gcc_assert(result != NULL_TREE);
101500 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101501 +
101502 + if (arg == NULL_TREE) {
101503 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101504 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101505 + if (arg_field == NULL_TREE)
101506 + return 0;
101507 + arg = TREE_TYPE(arg_field);
101508 + len = add_type_codes(arg, tree_codes, len);
101509 + gcc_assert(len != 0);
101510 + return len;
101511 + }
101512 +
101513 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101514 + while (arg && len < CODES_LIMIT) {
101515 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101516 + arg = TREE_CHAIN(arg);
101517 + }
101518 +
101519 + gcc_assert(len != 0);
101520 + return len;
101521 +}
101522 +
101523 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101524 +{
101525 + unsigned int hash;
101526 + const struct size_overflow_hash *entry;
101527 + unsigned char tree_codes[CODES_LIMIT];
101528 + size_t len;
101529 + const char *func_name;
101530 +
101531 + fndecl = get_original_function_decl(fndecl);
101532 + len = get_function_decl(fndecl, tree_codes);
101533 + if (len == 0)
101534 + return NULL;
101535 +
101536 + func_name = get_asm_name(fndecl);
101537 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101538 +
101539 + entry = size_overflow_hash[hash];
101540 + while (entry) {
101541 + if (!strcmp(entry->name, func_name))
101542 + return entry;
101543 + entry = entry->next;
101544 + }
101545 +
101546 + return NULL;
101547 +}
101548 +
101549 +static bool is_bool(const_tree node)
101550 +{
101551 + const_tree type;
101552 +
101553 + if (node == NULL_TREE)
101554 + return false;
101555 +
101556 + type = TREE_TYPE(node);
101557 + if (!INTEGRAL_TYPE_P(type))
101558 + return false;
101559 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101560 + return true;
101561 + if (TYPE_PRECISION(type) == 1)
101562 + return true;
101563 + return false;
101564 +}
101565 +
101566 +static bool skip_types(const_tree var)
101567 +{
101568 + tree type;
101569 +
101570 + if (is_gimple_constant(var))
101571 + return true;
101572 +
101573 + switch (TREE_CODE(var)) {
101574 + case ADDR_EXPR:
101575 +#if BUILDING_GCC_VERSION >= 4006
101576 + case MEM_REF:
101577 +#endif
101578 + case ARRAY_REF:
101579 + case BIT_FIELD_REF:
101580 + case INDIRECT_REF:
101581 + case TARGET_MEM_REF:
101582 + return true;
101583 + case PARM_DECL:
101584 + case VAR_DECL:
101585 + case COMPONENT_REF:
101586 + return false;
101587 + default:
101588 + break;
101589 + }
101590 +
101591 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101592 +
101593 + type = TREE_TYPE(var);
101594 + switch (TREE_CODE(type)) {
101595 + case INTEGER_TYPE:
101596 + case ENUMERAL_TYPE:
101597 + return false;
101598 + case BOOLEAN_TYPE:
101599 + return is_bool(var);
101600 + default:
101601 + break;
101602 + }
101603 +
101604 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101605 +
101606 + type = TREE_TYPE(type);
101607 + gcc_assert(type != NULL_TREE);
101608 + switch (TREE_CODE(type)) {
101609 + case RECORD_TYPE:
101610 + case POINTER_TYPE:
101611 + case ARRAY_TYPE:
101612 + return true;
101613 + case VOID_TYPE:
101614 + case INTEGER_TYPE:
101615 + case UNION_TYPE:
101616 + return false;
101617 + default:
101618 + break;
101619 + }
101620 +
101621 + debug_tree((tree)var);
101622 + gcc_unreachable();
101623 +}
101624 +
101625 +static unsigned int find_arg_number(const_tree arg, tree func)
101626 +{
101627 + tree var;
101628 + unsigned int argnum = 1;
101629 +
101630 + if (TREE_CODE(arg) == SSA_NAME)
101631 + arg = SSA_NAME_VAR(arg);
101632 +
101633 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101634 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101635 + continue;
101636 + if (!skip_types(var))
101637 + return argnum;
101638 + }
101639 +
101640 + return 0;
101641 +}
101642 +
101643 +static tree create_new_var(tree type)
101644 +{
101645 + tree new_var = create_tmp_var(type, "cicus");
101646 +
101647 +#if BUILDING_GCC_VERSION <= 4007
101648 + add_referenced_var(new_var);
101649 + mark_sym_for_renaming(new_var);
101650 +#endif
101651 + return new_var;
101652 +}
101653 +
101654 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101655 +{
101656 + gimple assign;
101657 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101658 + tree type = TREE_TYPE(rhs1);
101659 + tree lhs = create_new_var(type);
101660 +
101661 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101662 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101663 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101664 +
101665 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101666 + update_stmt(assign);
101667 + gimple_set_plf(assign, MY_STMT, true);
101668 + return assign;
101669 +}
101670 +
101671 +static tree cast_a_tree(tree type, tree var)
101672 +{
101673 + gcc_assert(type != NULL_TREE);
101674 + gcc_assert(var != NULL_TREE);
101675 + gcc_assert(fold_convertible_p(type, var));
101676 +
101677 + return fold_convert(type, var);
101678 +}
101679 +
101680 +static tree get_lhs(const_gimple stmt)
101681 +{
101682 + switch (gimple_code(stmt)) {
101683 + case GIMPLE_ASSIGN:
101684 + return gimple_get_lhs(stmt);
101685 + case GIMPLE_PHI:
101686 + return gimple_phi_result(stmt);
101687 + case GIMPLE_CALL:
101688 + return gimple_call_lhs(stmt);
101689 + default:
101690 + return NULL_TREE;
101691 + }
101692 +}
101693 +
101694 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
101695 +{
101696 + const_gimple def_stmt = get_def_stmt(rhs);
101697 +
101698 + if (force)
101699 + return false;
101700 +
101701 + if (is_gimple_constant(rhs))
101702 + return false;
101703 +
101704 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101705 + return false;
101706 +
101707 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
101708 + return false;
101709 +
101710 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
101711 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101712 + return false;
101713 +
101714 + return true;
101715 +}
101716 +
101717 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
101718 +{
101719 + gimple assign, def_stmt;
101720 +
101721 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
101722 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
101723 + gcc_unreachable();
101724 +
101725 + def_stmt = get_def_stmt(rhs);
101726 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
101727 + return def_stmt;
101728 +
101729 + if (lhs == CREATE_NEW_VAR)
101730 + lhs = create_new_var(dst_type);
101731 +
101732 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
101733 +
101734 + if (!gsi_end_p(*gsi)) {
101735 + location_t loc = gimple_location(gsi_stmt(*gsi));
101736 + gimple_set_location(assign, loc);
101737 + }
101738 +
101739 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101740 +
101741 + if (before)
101742 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
101743 + else
101744 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
101745 + update_stmt(assign);
101746 + gimple_set_plf(assign, MY_STMT, true);
101747 +
101748 + return assign;
101749 +}
101750 +
101751 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
101752 +{
101753 + gimple_stmt_iterator gsi;
101754 + tree lhs;
101755 + const_gimple new_stmt;
101756 +
101757 + if (rhs == NULL_TREE)
101758 + return NULL_TREE;
101759 +
101760 + gsi = gsi_for_stmt(stmt);
101761 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
101762 +
101763 + lhs = get_lhs(new_stmt);
101764 + gcc_assert(lhs != NULL_TREE);
101765 + return lhs;
101766 +}
101767 +
101768 +static tree cast_to_TI_type(gimple stmt, tree node)
101769 +{
101770 + gimple_stmt_iterator gsi;
101771 + gimple cast_stmt;
101772 + tree type = TREE_TYPE(node);
101773 +
101774 + if (types_compatible_p(type, intTI_type_node))
101775 + return node;
101776 +
101777 + gsi = gsi_for_stmt(stmt);
101778 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101779 + return gimple_get_lhs(cast_stmt);
101780 +}
101781 +
101782 +static void check_function_hash(const_gimple stmt)
101783 +{
101784 + tree func;
101785 + const struct size_overflow_hash *hash;
101786 +
101787 + if (gimple_code(stmt) != GIMPLE_CALL)
101788 + return;
101789 +
101790 + func = gimple_call_fndecl(stmt);
101791 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
101792 + if (func == NULL_TREE)
101793 + return;
101794 +
101795 + hash = get_function_hash(func);
101796 + if (!hash)
101797 + print_missing_msg(func, 0);
101798 +}
101799 +
101800 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
101801 +{
101802 + tree lhs, new_lhs;
101803 + gimple_stmt_iterator gsi;
101804 +
101805 + if (rhs1 == NULL_TREE) {
101806 + debug_gimple_stmt(oldstmt);
101807 + error("%s: rhs1 is NULL_TREE", __func__);
101808 + gcc_unreachable();
101809 + }
101810 +
101811 + switch (gimple_code(oldstmt)) {
101812 + case GIMPLE_ASM:
101813 + lhs = rhs1;
101814 + break;
101815 + case GIMPLE_CALL:
101816 + lhs = gimple_call_lhs(oldstmt);
101817 + break;
101818 + case GIMPLE_ASSIGN:
101819 + lhs = gimple_get_lhs(oldstmt);
101820 + break;
101821 + default:
101822 + debug_gimple_stmt(oldstmt);
101823 + gcc_unreachable();
101824 + }
101825 +
101826 + gsi = gsi_for_stmt(oldstmt);
101827 + pointer_set_insert(visited, oldstmt);
101828 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
101829 + basic_block next_bb, cur_bb;
101830 + const_edge e;
101831 +
101832 + gcc_assert(before == false);
101833 + gcc_assert(stmt_can_throw_internal(oldstmt));
101834 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
101835 + gcc_assert(!gsi_end_p(gsi));
101836 +
101837 + cur_bb = gimple_bb(oldstmt);
101838 + next_bb = cur_bb->next_bb;
101839 + e = find_edge(cur_bb, next_bb);
101840 + gcc_assert(e != NULL);
101841 + gcc_assert(e->flags & EDGE_FALLTHRU);
101842 +
101843 + gsi = gsi_after_labels(next_bb);
101844 + gcc_assert(!gsi_end_p(gsi));
101845 +
101846 + before = true;
101847 + oldstmt = gsi_stmt(gsi);
101848 + }
101849 +
101850 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
101851 + return new_lhs;
101852 +}
101853 +
101854 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
101855 +{
101856 + gimple stmt;
101857 + gimple_stmt_iterator gsi;
101858 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
101859 +
101860 + if (gimple_plf(oldstmt, MY_STMT))
101861 + return lhs;
101862 +
101863 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
101864 + rhs1 = gimple_assign_rhs1(oldstmt);
101865 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
101866 + }
101867 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
101868 + rhs2 = gimple_assign_rhs2(oldstmt);
101869 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
101870 + }
101871 +
101872 + stmt = gimple_copy(oldstmt);
101873 + gimple_set_location(stmt, gimple_location(oldstmt));
101874 + gimple_set_plf(stmt, MY_STMT, true);
101875 +
101876 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
101877 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
101878 +
101879 + size_overflow_type = get_size_overflow_type(oldstmt, node);
101880 +
101881 + new_var = create_new_var(size_overflow_type);
101882 + new_var = make_ssa_name(new_var, stmt);
101883 + gimple_set_lhs(stmt, new_var);
101884 +
101885 + if (rhs1 != NULL_TREE)
101886 + gimple_assign_set_rhs1(stmt, rhs1);
101887 +
101888 + if (rhs2 != NULL_TREE)
101889 + gimple_assign_set_rhs2(stmt, rhs2);
101890 +#if BUILDING_GCC_VERSION >= 4007
101891 + if (rhs3 != NULL_TREE)
101892 + gimple_assign_set_rhs3(stmt, rhs3);
101893 +#endif
101894 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
101895 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
101896 +
101897 + gsi = gsi_for_stmt(oldstmt);
101898 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
101899 + update_stmt(stmt);
101900 + pointer_set_insert(visited, oldstmt);
101901 + return gimple_get_lhs(stmt);
101902 +}
101903 +
101904 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
101905 +{
101906 + basic_block first_bb;
101907 + gimple assign;
101908 + gimple_stmt_iterator gsi;
101909 +
101910 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101911 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101912 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
101913 +
101914 + gsi = gsi_start_bb(first_bb);
101915 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101916 + return gimple_get_lhs(assign);
101917 +}
101918 +
101919 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
101920 +{
101921 + gimple_stmt_iterator gsi;
101922 + const_gimple assign;
101923 + gimple def_stmt = get_def_stmt(new_arg);
101924 +
101925 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
101926 + gsi = gsi_after_labels(gimple_bb(def_stmt));
101927 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
101928 + } else {
101929 + gsi = gsi_for_stmt(def_stmt);
101930 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
101931 + }
101932 +
101933 + return gimple_get_lhs(assign);
101934 +}
101935 +
101936 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
101937 +{
101938 + basic_block bb;
101939 + gimple_stmt_iterator gsi;
101940 + const_gimple assign, def_stmt;
101941 +
101942 + def_stmt = get_def_stmt(arg);
101943 + bb = gimple_bb(def_stmt);
101944 + gcc_assert(bb->index != 0);
101945 + gsi = gsi_after_labels(bb);
101946 +
101947 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101948 + return gimple_get_lhs(assign);
101949 +}
101950 +
101951 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
101952 +{
101953 + tree size_overflow_type;
101954 + const_gimple def_stmt = get_def_stmt(arg);
101955 +
101956 + if (phi_ssa_name != NULL_TREE)
101957 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
101958 +
101959 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
101960 +
101961 + if (new_arg != NULL_TREE) {
101962 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
101963 + return use_phi_ssa_name(phi_ssa_name, new_arg);
101964 + }
101965 +
101966 + switch(gimple_code(def_stmt)) {
101967 + case GIMPLE_PHI:
101968 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
101969 + case GIMPLE_NOP:
101970 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
101971 + default:
101972 + debug_gimple_stmt((gimple)def_stmt);
101973 + gcc_unreachable();
101974 + }
101975 +}
101976 +
101977 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
101978 +{
101979 + basic_block bb;
101980 + gimple phi;
101981 + gimple_seq seq;
101982 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
101983 +
101984 + bb = gsi_bb(gsi);
101985 +
101986 + phi = create_phi_node(result, bb);
101987 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
101988 + seq = phi_nodes(bb);
101989 + gsi = gsi_last(seq);
101990 + gsi_remove(&gsi, false);
101991 +
101992 + gsi = gsi_for_stmt(oldstmt);
101993 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
101994 + gimple_set_bb(phi, bb);
101995 + gimple_set_plf(phi, MY_STMT, true);
101996 + return phi;
101997 +}
101998 +
101999 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
102000 +{
102001 + gimple new_phi = NULL;
102002 + gimple oldstmt = get_def_stmt(orig_result);
102003 + tree phi_ssa_name = NULL_TREE;
102004 + unsigned int i;
102005 +
102006 + pointer_set_insert(visited, oldstmt);
102007 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
102008 + tree arg, new_arg;
102009 +
102010 + arg = gimple_phi_arg_def(oldstmt, i);
102011 +
102012 + new_arg = expand(visited, arg);
102013 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
102014 + if (i == 0) {
102015 + phi_ssa_name = new_arg;
102016 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
102017 + }
102018 +
102019 + gcc_assert(new_phi != NULL);
102020 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
102021 + }
102022 +
102023 + gcc_assert(new_phi != NULL);
102024 + update_stmt(new_phi);
102025 + return gimple_phi_result(new_phi);
102026 +}
102027 +
102028 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
102029 +{
102030 + const_gimple assign;
102031 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102032 + tree origtype = TREE_TYPE(orig_rhs);
102033 +
102034 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
102035 +
102036 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102037 + return gimple_get_lhs(assign);
102038 +}
102039 +
102040 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
102041 +{
102042 + const_tree rhs1, lhs, rhs1_type, lhs_type;
102043 + enum machine_mode lhs_mode, rhs_mode;
102044 + gimple def_stmt = get_def_stmt(no_const_rhs);
102045 +
102046 + if (!gimple_assign_cast_p(def_stmt))
102047 + return false;
102048 +
102049 + rhs1 = gimple_assign_rhs1(def_stmt);
102050 + lhs = gimple_get_lhs(def_stmt);
102051 + rhs1_type = TREE_TYPE(rhs1);
102052 + lhs_type = TREE_TYPE(lhs);
102053 + rhs_mode = TYPE_MODE(rhs1_type);
102054 + lhs_mode = TYPE_MODE(lhs_type);
102055 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
102056 + return false;
102057 +
102058 + return true;
102059 +}
102060 +
102061 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
102062 +{
102063 + tree rhs1 = gimple_assign_rhs1(stmt);
102064 + tree lhs = gimple_get_lhs(stmt);
102065 + const_tree rhs1_type = TREE_TYPE(rhs1);
102066 + const_tree lhs_type = TREE_TYPE(lhs);
102067 +
102068 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
102069 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102070 +
102071 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
102072 +}
102073 +
102074 +static bool no_uses(tree node)
102075 +{
102076 + imm_use_iterator imm_iter;
102077 + use_operand_p use_p;
102078 +
102079 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
102080 + const_gimple use_stmt = USE_STMT(use_p);
102081 + if (use_stmt == NULL)
102082 + return true;
102083 + if (is_gimple_debug(use_stmt))
102084 + continue;
102085 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
102086 + continue;
102087 + return false;
102088 + }
102089 + return true;
102090 +}
102091 +
102092 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
102093 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
102094 +{
102095 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
102096 + gimple def_stmt = get_def_stmt(lhs);
102097 +
102098 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102099 + return false;
102100 +
102101 + rhs1 = gimple_assign_rhs1(def_stmt);
102102 + rhs_type = TREE_TYPE(rhs1);
102103 + lhs_type = TREE_TYPE(lhs);
102104 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
102105 + return false;
102106 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
102107 + return false;
102108 +
102109 + def_stmt = get_def_stmt(rhs1);
102110 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
102111 + return false;
102112 +
102113 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
102114 + return false;
102115 +
102116 + rhs1 = gimple_assign_rhs1(def_stmt);
102117 + rhs2 = gimple_assign_rhs2(def_stmt);
102118 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
102119 + return false;
102120 +
102121 + if (is_gimple_constant(rhs2))
102122 + not_const_rhs = rhs1;
102123 + else
102124 + not_const_rhs = rhs2;
102125 +
102126 + return no_uses(not_const_rhs);
102127 +}
102128 +
102129 +static bool skip_lhs_cast_check(const_gimple stmt)
102130 +{
102131 + const_tree rhs = gimple_assign_rhs1(stmt);
102132 + const_gimple def_stmt = get_def_stmt(rhs);
102133 +
102134 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
102135 + if (gimple_code(def_stmt) == GIMPLE_ASM)
102136 + return true;
102137 +
102138 + if (is_const_plus_unsigned_signed_truncation(rhs))
102139 + return true;
102140 +
102141 + return false;
102142 +}
102143 +
102144 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
102145 +{
102146 + bool cast_lhs, cast_rhs;
102147 + tree lhs = gimple_get_lhs(stmt);
102148 + tree rhs = gimple_assign_rhs1(stmt);
102149 + const_tree lhs_type = TREE_TYPE(lhs);
102150 + const_tree rhs_type = TREE_TYPE(rhs);
102151 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
102152 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
102153 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
102154 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
102155 +
102156 + static bool check_lhs[3][4] = {
102157 + // ss su us uu
102158 + { false, true, true, false }, // lhs > rhs
102159 + { false, false, false, false }, // lhs = rhs
102160 + { true, true, true, true }, // lhs < rhs
102161 + };
102162 +
102163 + static bool check_rhs[3][4] = {
102164 + // ss su us uu
102165 + { true, false, true, true }, // lhs > rhs
102166 + { true, false, true, true }, // lhs = rhs
102167 + { true, false, true, true }, // lhs < rhs
102168 + };
102169 +
102170 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
102171 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
102172 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102173 +
102174 + if (lhs_size > rhs_size) {
102175 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102176 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102177 + } else if (lhs_size == rhs_size) {
102178 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102179 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102180 + } else {
102181 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102182 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102183 + }
102184 +
102185 + if (!cast_lhs && !cast_rhs)
102186 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102187 +
102188 + if (cast_lhs && !skip_lhs_cast_check(stmt))
102189 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
102190 +
102191 + if (cast_rhs)
102192 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
102193 +
102194 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102195 +}
102196 +
102197 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
102198 +{
102199 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
102200 +
102201 + if (gimple_plf(stmt, MY_STMT))
102202 + return lhs;
102203 +
102204 + rhs1 = gimple_assign_rhs1(stmt);
102205 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
102206 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102207 +
102208 + new_rhs1 = expand(visited, rhs1);
102209 +
102210 + if (new_rhs1 == NULL_TREE)
102211 + return create_cast_assign(visited, stmt);
102212 +
102213 + if (gimple_plf(stmt, NO_CAST_CHECK))
102214 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102215 +
102216 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
102217 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
102218 +
102219 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
102220 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
102221 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102222 + }
102223 +
102224 + if (!gimple_assign_cast_p(stmt))
102225 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102226 +
102227 + return create_cast_overflow_check(visited, new_rhs1, stmt);
102228 +}
102229 +
102230 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
102231 +{
102232 + tree rhs1, lhs = gimple_get_lhs(stmt);
102233 + gimple def_stmt = get_def_stmt(lhs);
102234 +
102235 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
102236 + rhs1 = gimple_assign_rhs1(def_stmt);
102237 +
102238 + if (is_gimple_constant(rhs1))
102239 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102240 +
102241 + switch (TREE_CODE(rhs1)) {
102242 + case SSA_NAME:
102243 + return handle_unary_rhs(visited, def_stmt);
102244 + case ARRAY_REF:
102245 + case BIT_FIELD_REF:
102246 + case ADDR_EXPR:
102247 + case COMPONENT_REF:
102248 + case INDIRECT_REF:
102249 +#if BUILDING_GCC_VERSION >= 4006
102250 + case MEM_REF:
102251 +#endif
102252 + case TARGET_MEM_REF:
102253 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102254 + case PARM_DECL:
102255 + case VAR_DECL:
102256 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102257 +
102258 + default:
102259 + debug_gimple_stmt(def_stmt);
102260 + debug_tree(rhs1);
102261 + gcc_unreachable();
102262 + }
102263 +}
102264 +
102265 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102266 +{
102267 + gimple cond_stmt;
102268 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102269 +
102270 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102271 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102272 + update_stmt(cond_stmt);
102273 +}
102274 +
102275 +static tree create_string_param(tree string)
102276 +{
102277 + tree i_type, a_type;
102278 + const int length = TREE_STRING_LENGTH(string);
102279 +
102280 + gcc_assert(length > 0);
102281 +
102282 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
102283 + a_type = build_array_type(char_type_node, i_type);
102284 +
102285 + TREE_TYPE(string) = a_type;
102286 + TREE_CONSTANT(string) = 1;
102287 + TREE_READONLY(string) = 1;
102288 +
102289 + return build1(ADDR_EXPR, ptr_type_node, string);
102290 +}
102291 +
102292 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
102293 +{
102294 + gimple func_stmt;
102295 + const_gimple def_stmt;
102296 + const_tree loc_line;
102297 + tree loc_file, ssa_name, current_func;
102298 + expanded_location xloc;
102299 + char *ssa_name_buf;
102300 + int len;
102301 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
102302 +
102303 + def_stmt = get_def_stmt(arg);
102304 + xloc = expand_location(gimple_location(def_stmt));
102305 +
102306 + if (!gimple_has_location(def_stmt)) {
102307 + xloc = expand_location(gimple_location(stmt));
102308 + if (!gimple_has_location(stmt))
102309 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102310 + }
102311 +
102312 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
102313 +
102314 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
102315 + loc_file = create_string_param(loc_file);
102316 +
102317 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
102318 + current_func = create_string_param(current_func);
102319 +
102320 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
102321 + call_count++;
102322 + 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);
102323 + gcc_assert(len > 0);
102324 + ssa_name = build_string(len + 1, ssa_name_buf);
102325 + free(ssa_name_buf);
102326 + ssa_name = create_string_param(ssa_name);
102327 +
102328 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
102329 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
102330 +
102331 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
102332 +}
102333 +
102334 +static void __unused print_the_code_insertions(const_gimple stmt)
102335 +{
102336 + location_t loc = gimple_location(stmt);
102337 +
102338 + inform(loc, "Integer size_overflow check applied here.");
102339 +}
102340 +
102341 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
102342 +{
102343 + basic_block cond_bb, join_bb, bb_true;
102344 + edge e;
102345 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102346 +
102347 + cond_bb = gimple_bb(stmt);
102348 + if (before)
102349 + gsi_prev(&gsi);
102350 + if (gsi_end_p(gsi))
102351 + e = split_block_after_labels(cond_bb);
102352 + else
102353 + e = split_block(cond_bb, gsi_stmt(gsi));
102354 + cond_bb = e->src;
102355 + join_bb = e->dest;
102356 + e->flags = EDGE_FALSE_VALUE;
102357 + e->probability = REG_BR_PROB_BASE;
102358 +
102359 + bb_true = create_empty_bb(cond_bb);
102360 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
102361 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
102362 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
102363 +
102364 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102365 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
102366 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
102367 +
102368 + if (current_loops != NULL) {
102369 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
102370 + add_bb_to_loop(bb_true, cond_bb->loop_father);
102371 + }
102372 +
102373 + insert_cond(cond_bb, arg, cond_code, type_value);
102374 + insert_cond_result(bb_true, stmt, arg, min);
102375 +
102376 +// print_the_code_insertions(stmt);
102377 +}
102378 +
102379 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102380 +{
102381 + const_tree rhs_type = TREE_TYPE(rhs);
102382 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102383 +
102384 + gcc_assert(rhs_type != NULL_TREE);
102385 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102386 + return;
102387 +
102388 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102389 +
102390 + if (is_const_plus_unsigned_signed_truncation(rhs))
102391 + return;
102392 +
102393 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102394 + // typemax (-1) < typemin (0)
102395 + if (TREE_OVERFLOW(type_max))
102396 + return;
102397 +
102398 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102399 +
102400 + cast_rhs_type = TREE_TYPE(cast_rhs);
102401 + type_max_type = TREE_TYPE(type_max);
102402 + type_min_type = TREE_TYPE(type_min);
102403 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102404 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102405 +
102406 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102407 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102408 +}
102409 +
102410 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102411 +{
102412 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102413 + return false;
102414 + if (!is_gimple_constant(rhs))
102415 + return false;
102416 + return true;
102417 +}
102418 +
102419 +static tree get_def_stmt_rhs(const_tree var)
102420 +{
102421 + tree rhs1, def_stmt_rhs1;
102422 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102423 +
102424 + def_stmt = get_def_stmt(var);
102425 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102426 +
102427 + rhs1 = gimple_assign_rhs1(def_stmt);
102428 + rhs1_def_stmt = get_def_stmt(rhs1);
102429 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102430 + return rhs1;
102431 +
102432 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102433 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102434 +
102435 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102436 + case GIMPLE_CALL:
102437 + case GIMPLE_NOP:
102438 + case GIMPLE_ASM:
102439 + case GIMPLE_PHI:
102440 + return def_stmt_rhs1;
102441 + case GIMPLE_ASSIGN:
102442 + return rhs1;
102443 + default:
102444 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102445 + gcc_unreachable();
102446 + }
102447 +}
102448 +
102449 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102450 +{
102451 + tree new_rhs, orig_rhs;
102452 + void (*gimple_assign_set_rhs)(gimple, tree);
102453 + tree rhs1 = gimple_assign_rhs1(stmt);
102454 + tree rhs2 = gimple_assign_rhs2(stmt);
102455 + tree lhs = gimple_get_lhs(stmt);
102456 +
102457 + if (!check_overflow)
102458 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102459 +
102460 + if (change_rhs == NULL_TREE)
102461 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102462 +
102463 + if (new_rhs2 == NULL_TREE) {
102464 + orig_rhs = rhs1;
102465 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102466 + } else {
102467 + orig_rhs = rhs2;
102468 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102469 + }
102470 +
102471 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102472 +
102473 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102474 + gimple_assign_set_rhs(stmt, new_rhs);
102475 + update_stmt(stmt);
102476 +
102477 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102478 +}
102479 +
102480 +static bool is_subtraction_special(const_gimple stmt)
102481 +{
102482 + gimple rhs1_def_stmt, rhs2_def_stmt;
102483 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102484 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102485 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102486 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102487 +
102488 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102489 + return false;
102490 +
102491 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102492 +
102493 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102494 + return false;
102495 +
102496 + rhs1_def_stmt = get_def_stmt(rhs1);
102497 + rhs2_def_stmt = get_def_stmt(rhs2);
102498 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102499 + return false;
102500 +
102501 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102502 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102503 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102504 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102505 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102506 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102507 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102508 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102509 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102510 + return false;
102511 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102512 + return false;
102513 +
102514 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102515 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102516 + return true;
102517 +}
102518 +
102519 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102520 +{
102521 + tree new_rhs1, new_rhs2;
102522 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102523 + gimple assign, stmt = get_def_stmt(lhs);
102524 + tree rhs1 = gimple_assign_rhs1(stmt);
102525 + tree rhs2 = gimple_assign_rhs2(stmt);
102526 +
102527 + if (!is_subtraction_special(stmt))
102528 + return NULL_TREE;
102529 +
102530 + new_rhs1 = expand(visited, rhs1);
102531 + new_rhs2 = expand(visited, rhs2);
102532 +
102533 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102534 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102535 +
102536 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102537 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102538 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102539 + }
102540 +
102541 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102542 + new_lhs = gimple_get_lhs(assign);
102543 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102544 +
102545 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102546 +}
102547 +
102548 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102549 +{
102550 + const_gimple def_stmt;
102551 +
102552 + if (TREE_CODE(rhs) != SSA_NAME)
102553 + return false;
102554 +
102555 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102556 + return false;
102557 +
102558 + def_stmt = get_def_stmt(rhs);
102559 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102560 + return false;
102561 +
102562 + return true;
102563 +}
102564 +
102565 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102566 +{
102567 + tree rhs1, rhs2, new_lhs;
102568 + gimple def_stmt = get_def_stmt(lhs);
102569 + tree new_rhs1 = NULL_TREE;
102570 + tree new_rhs2 = NULL_TREE;
102571 +
102572 + rhs1 = gimple_assign_rhs1(def_stmt);
102573 + rhs2 = gimple_assign_rhs2(def_stmt);
102574 +
102575 + /* no DImode/TImode division in the 32/64 bit kernel */
102576 + switch (gimple_assign_rhs_code(def_stmt)) {
102577 + case RDIV_EXPR:
102578 + case TRUNC_DIV_EXPR:
102579 + case CEIL_DIV_EXPR:
102580 + case FLOOR_DIV_EXPR:
102581 + case ROUND_DIV_EXPR:
102582 + case TRUNC_MOD_EXPR:
102583 + case CEIL_MOD_EXPR:
102584 + case FLOOR_MOD_EXPR:
102585 + case ROUND_MOD_EXPR:
102586 + case EXACT_DIV_EXPR:
102587 + case POINTER_PLUS_EXPR:
102588 + case BIT_AND_EXPR:
102589 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102590 + default:
102591 + break;
102592 + }
102593 +
102594 + new_lhs = handle_integer_truncation(visited, lhs);
102595 + if (new_lhs != NULL_TREE)
102596 + return new_lhs;
102597 +
102598 + if (TREE_CODE(rhs1) == SSA_NAME)
102599 + new_rhs1 = expand(visited, rhs1);
102600 + if (TREE_CODE(rhs2) == SSA_NAME)
102601 + new_rhs2 = expand(visited, rhs2);
102602 +
102603 + if (is_a_neg_overflow(def_stmt, rhs2))
102604 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102605 + if (is_a_neg_overflow(def_stmt, rhs1))
102606 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102607 +
102608 +
102609 + if (is_a_constant_overflow(def_stmt, rhs2))
102610 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102611 + if (is_a_constant_overflow(def_stmt, rhs1))
102612 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102613 +
102614 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102615 +}
102616 +
102617 +#if BUILDING_GCC_VERSION >= 4007
102618 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102619 +{
102620 + if (is_gimple_constant(rhs))
102621 + return cast_a_tree(size_overflow_type, rhs);
102622 + if (TREE_CODE(rhs) != SSA_NAME)
102623 + return NULL_TREE;
102624 + return expand(visited, rhs);
102625 +}
102626 +
102627 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102628 +{
102629 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102630 + gimple def_stmt = get_def_stmt(lhs);
102631 +
102632 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102633 +
102634 + rhs1 = gimple_assign_rhs1(def_stmt);
102635 + rhs2 = gimple_assign_rhs2(def_stmt);
102636 + rhs3 = gimple_assign_rhs3(def_stmt);
102637 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102638 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102639 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102640 +
102641 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102642 +}
102643 +#endif
102644 +
102645 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102646 +{
102647 + const_tree type;
102648 + tree new_type;
102649 +
102650 + gcc_assert(node != NULL_TREE);
102651 +
102652 + type = TREE_TYPE(node);
102653 +
102654 + if (gimple_plf(stmt, MY_STMT))
102655 + return TREE_TYPE(node);
102656 +
102657 + switch (TYPE_MODE(type)) {
102658 + case QImode:
102659 + new_type = intHI_type_node;
102660 + break;
102661 + case HImode:
102662 + new_type = intSI_type_node;
102663 + break;
102664 + case SImode:
102665 + new_type = intDI_type_node;
102666 + break;
102667 + case DImode:
102668 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102669 + new_type = intDI_type_node;
102670 + else
102671 + new_type = intTI_type_node;
102672 + break;
102673 + default:
102674 + debug_tree((tree)node);
102675 + error("%s: unsupported gcc configuration.", __func__);
102676 + gcc_unreachable();
102677 + }
102678 +
102679 + if (TYPE_QUALS(type) != 0)
102680 + return build_qualified_type(new_type, TYPE_QUALS(type));
102681 + return new_type;
102682 +}
102683 +
102684 +static tree expand_visited(gimple def_stmt)
102685 +{
102686 + const_gimple next_stmt;
102687 + gimple_stmt_iterator gsi;
102688 + enum gimple_code code = gimple_code(def_stmt);
102689 +
102690 + if (code == GIMPLE_ASM)
102691 + return NULL_TREE;
102692 +
102693 + gsi = gsi_for_stmt(def_stmt);
102694 + gsi_next(&gsi);
102695 +
102696 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
102697 + return NULL_TREE;
102698 + gcc_assert(!gsi_end_p(gsi));
102699 + next_stmt = gsi_stmt(gsi);
102700 +
102701 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
102702 + return NULL_TREE;
102703 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
102704 +
102705 + return get_lhs(next_stmt);
102706 +}
102707 +
102708 +static tree expand(struct pointer_set_t *visited, tree lhs)
102709 +{
102710 + gimple def_stmt;
102711 +
102712 + if (skip_types(lhs))
102713 + return NULL_TREE;
102714 +
102715 + def_stmt = get_def_stmt(lhs);
102716 +
102717 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102718 + return NULL_TREE;
102719 +
102720 + if (gimple_plf(def_stmt, MY_STMT))
102721 + return lhs;
102722 +
102723 + if (pointer_set_contains(visited, def_stmt))
102724 + return expand_visited(def_stmt);
102725 +
102726 + switch (gimple_code(def_stmt)) {
102727 + case GIMPLE_PHI:
102728 + return handle_phi(visited, lhs);
102729 + case GIMPLE_CALL:
102730 + case GIMPLE_ASM:
102731 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102732 + case GIMPLE_ASSIGN:
102733 + switch (gimple_num_ops(def_stmt)) {
102734 + case 2:
102735 + return handle_unary_ops(visited, def_stmt);
102736 + case 3:
102737 + return handle_binary_ops(visited, lhs);
102738 +#if BUILDING_GCC_VERSION >= 4007
102739 + case 4:
102740 + return handle_ternary_ops(visited, lhs);
102741 +#endif
102742 + }
102743 + default:
102744 + debug_gimple_stmt(def_stmt);
102745 + error("%s: unknown gimple code", __func__);
102746 + gcc_unreachable();
102747 + }
102748 +}
102749 +
102750 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
102751 +{
102752 + const_gimple assign;
102753 + tree orig_type = TREE_TYPE(orig_node);
102754 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102755 +
102756 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102757 + return gimple_get_lhs(assign);
102758 +}
102759 +
102760 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
102761 +{
102762 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
102763 + update_stmt(stmt);
102764 +}
102765 +
102766 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
102767 +{
102768 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
102769 + update_stmt(stmt);
102770 +}
102771 +
102772 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
102773 +{
102774 + tree arg;
102775 + const_tree origarg;
102776 +
102777 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
102778 + return true;
102779 +
102780 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
102781 + while (origarg && *argnum) {
102782 + (*argnum)--;
102783 + origarg = TREE_CHAIN(origarg);
102784 + }
102785 +
102786 + gcc_assert(*argnum == 0);
102787 +
102788 + gcc_assert(origarg != NULL_TREE);
102789 + *argnum = 0;
102790 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
102791 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
102792 + return true;
102793 + return false;
102794 +}
102795 +
102796 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
102797 +{
102798 + gimple phi = get_def_stmt(result);
102799 + unsigned int i, n = gimple_phi_num_args(phi);
102800 +
102801 + if (!phi)
102802 + return MARK_NO;
102803 +
102804 + pointer_set_insert(visited, phi);
102805 + for (i = 0; i < n; i++) {
102806 + enum mark marked;
102807 + const_tree arg = gimple_phi_arg_def(phi, i);
102808 + marked = pre_expand(visited, search_err_code, arg);
102809 + if (marked != MARK_NO)
102810 + return marked;
102811 + }
102812 + return MARK_NO;
102813 +}
102814 +
102815 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102816 +{
102817 + gimple def_stmt = get_def_stmt(lhs);
102818 + const_tree rhs;
102819 +
102820 + if (!def_stmt)
102821 + return MARK_NO;
102822 +
102823 + rhs = gimple_assign_rhs1(def_stmt);
102824 +
102825 + def_stmt = get_def_stmt(rhs);
102826 + if (is_gimple_constant(rhs))
102827 + search_err_code[FROM_CONST] = true;
102828 +
102829 + return pre_expand(visited, search_err_code, rhs);
102830 +}
102831 +
102832 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102833 +{
102834 + gimple def_stmt = get_def_stmt(lhs);
102835 + const_tree rhs1, rhs2;
102836 + enum mark marked;
102837 +
102838 + if (!def_stmt)
102839 + return MARK_NO;
102840 +
102841 + search_err_code[CAST_ONLY] = false;
102842 +
102843 + rhs1 = gimple_assign_rhs1(def_stmt);
102844 + rhs2 = gimple_assign_rhs2(def_stmt);
102845 + marked = pre_expand(visited, search_err_code, rhs1);
102846 + if (marked != MARK_NO)
102847 + return marked;
102848 + return pre_expand(visited, search_err_code, rhs2);
102849 +}
102850 +
102851 +static const_tree search_field_decl(const_tree comp_ref)
102852 +{
102853 + const_tree field = NULL_TREE;
102854 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
102855 +
102856 + for (i = 0; i < len; i++) {
102857 + field = TREE_OPERAND(comp_ref, i);
102858 + if (TREE_CODE(field) == FIELD_DECL)
102859 + break;
102860 + }
102861 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
102862 + return field;
102863 +}
102864 +
102865 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
102866 +{
102867 + const_tree attr, p;
102868 +
102869 + // 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);
102870 + if (fndecl == NULL_TREE)
102871 + return MARK_NO;
102872 +
102873 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
102874 + if (!attr || !TREE_VALUE(attr))
102875 + return MARK_NO;
102876 +
102877 + p = TREE_VALUE(attr);
102878 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
102879 + return MARK_TURN_OFF;
102880 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
102881 + return MARK_NOT_INTENTIONAL;
102882 + if (argnum == 0) {
102883 + gcc_assert(current_function_decl == fndecl);
102884 + return MARK_NO;
102885 + }
102886 +
102887 + do {
102888 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
102889 + return MARK_YES;
102890 + p = TREE_CHAIN(p);
102891 + } while (p);
102892 +
102893 + return MARK_NO;
102894 +}
102895 +
102896 +static void print_missing_msg(tree func, unsigned int argnum)
102897 +{
102898 + unsigned int new_hash;
102899 + size_t len;
102900 + unsigned char tree_codes[CODES_LIMIT];
102901 + location_t loc;
102902 + const char *curfunc;
102903 +
102904 + func = get_original_function_decl(func);
102905 + loc = DECL_SOURCE_LOCATION(func);
102906 + curfunc = get_asm_name(func);
102907 +
102908 + len = get_function_decl(func, tree_codes);
102909 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
102910 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
102911 +}
102912 +
102913 +static unsigned int search_missing_attribute(const_tree arg)
102914 +{
102915 + unsigned int argnum;
102916 + const struct size_overflow_hash *hash;
102917 + const_tree type = TREE_TYPE(arg);
102918 + tree func = get_original_function_decl(current_function_decl);
102919 +
102920 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
102921 +
102922 + if (TREE_CODE(type) == POINTER_TYPE)
102923 + return 0;
102924 +
102925 + argnum = find_arg_number(arg, func);
102926 + if (argnum == 0)
102927 + return 0;
102928 +
102929 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
102930 + return argnum;
102931 +
102932 + hash = get_function_hash(func);
102933 + if (!hash || !(hash->param & (1U << argnum))) {
102934 + print_missing_msg(func, argnum);
102935 + return 0;
102936 + }
102937 + return argnum;
102938 +}
102939 +
102940 +static enum mark is_already_marked(const_tree lhs)
102941 +{
102942 + unsigned int argnum;
102943 + const_tree fndecl;
102944 +
102945 + argnum = search_missing_attribute(lhs);
102946 + fndecl = get_original_function_decl(current_function_decl);
102947 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
102948 + return MARK_YES;
102949 + return MARK_NO;
102950 +}
102951 +
102952 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102953 +{
102954 + const_gimple def_stmt;
102955 +
102956 + if (skip_types(lhs))
102957 + return MARK_NO;
102958 +
102959 + if (TREE_CODE(lhs) == PARM_DECL)
102960 + return is_already_marked(lhs);
102961 +
102962 + if (TREE_CODE(lhs) == COMPONENT_REF) {
102963 + const_tree field, attr;
102964 +
102965 + field = search_field_decl(lhs);
102966 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
102967 + if (!attr || !TREE_VALUE(attr))
102968 + return MARK_NO;
102969 + return MARK_YES;
102970 + }
102971 +
102972 + def_stmt = get_def_stmt(lhs);
102973 +
102974 + if (!def_stmt)
102975 + return MARK_NO;
102976 +
102977 + if (pointer_set_contains(visited, def_stmt))
102978 + return MARK_NO;
102979 +
102980 + switch (gimple_code(def_stmt)) {
102981 + case GIMPLE_NOP:
102982 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
102983 + return is_already_marked(lhs);
102984 + return MARK_NO;
102985 + case GIMPLE_PHI:
102986 + return walk_phi(visited, search_err_code, lhs);
102987 + case GIMPLE_CALL:
102988 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
102989 + return MARK_TURN_OFF;
102990 + check_function_hash(def_stmt);
102991 + return MARK_NO;
102992 + case GIMPLE_ASM:
102993 + search_err_code[CAST_ONLY] = false;
102994 + return MARK_NO;
102995 + case GIMPLE_ASSIGN:
102996 + switch (gimple_num_ops(def_stmt)) {
102997 + case 2:
102998 + return walk_unary_ops(visited, search_err_code, lhs);
102999 + case 3:
103000 + return walk_binary_ops(visited, search_err_code, lhs);
103001 + }
103002 + default:
103003 + debug_gimple_stmt((gimple)def_stmt);
103004 + error("%s: unknown gimple code", __func__);
103005 + gcc_unreachable();
103006 + }
103007 +}
103008 +
103009 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
103010 +static bool skip_asm(const_tree arg)
103011 +{
103012 + gimple def_stmt = get_def_stmt(arg);
103013 +
103014 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103015 + return false;
103016 +
103017 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
103018 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
103019 +}
103020 +
103021 +/*
103022 +0</MARK_YES: no dup, search attributes (so, int)
103023 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
103024 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
103025 +*/
103026 +
103027 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
103028 +{
103029 + struct pointer_set_t *visited;
103030 + enum mark is_marked, is_found;
103031 + location_t loc;
103032 + bool search_err_code[2] = {true, false};
103033 +
103034 + is_marked = mark_status(current_function_decl, 0);
103035 + if (is_marked == MARK_TURN_OFF)
103036 + return true;
103037 +
103038 + is_marked = mark_status(fndecl, argnum + 1);
103039 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
103040 + return true;
103041 +
103042 + visited = pointer_set_create();
103043 + is_found = pre_expand(visited, search_err_code, arg);
103044 + pointer_set_destroy(visited);
103045 +
103046 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
103047 + return true;
103048 +
103049 + if (where == FROM_ARG && skip_asm(arg))
103050 + return true;
103051 +
103052 + if (is_found == MARK_TURN_OFF)
103053 + return true;
103054 +
103055 + if ((is_found == MARK_YES && is_marked == MARK_YES))
103056 + return true;
103057 +
103058 + if (is_found == MARK_YES) {
103059 + loc = DECL_SOURCE_LOCATION(fndecl);
103060 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
103061 + return true;
103062 + }
103063 + return false;
103064 +}
103065 +
103066 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
103067 +{
103068 + struct pointer_set_t *visited;
103069 + tree arg, new_arg;
103070 + bool match;
103071 +
103072 + if (argnum == 0)
103073 + return;
103074 +
103075 + argnum--;
103076 +
103077 + match = get_function_arg(&argnum, fndecl);
103078 + if (!match)
103079 + return;
103080 + gcc_assert(gimple_call_num_args(stmt) > argnum);
103081 + arg = gimple_call_arg(stmt, argnum);
103082 + if (arg == NULL_TREE)
103083 + return;
103084 +
103085 + if (skip_types(arg))
103086 + return;
103087 +
103088 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
103089 + return;
103090 +
103091 + visited = pointer_set_create();
103092 + new_arg = expand(visited, arg);
103093 + pointer_set_destroy(visited);
103094 +
103095 + if (new_arg == NULL_TREE)
103096 + return;
103097 +
103098 + change_function_arg(stmt, arg, argnum, new_arg);
103099 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
103100 +}
103101 +
103102 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
103103 +{
103104 + tree p = TREE_VALUE(attr);
103105 + do {
103106 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
103107 + p = TREE_CHAIN(p);
103108 + } while (p);
103109 +}
103110 +
103111 +static void handle_function_by_hash(gimple stmt, tree fndecl)
103112 +{
103113 + unsigned int num;
103114 + const struct size_overflow_hash *hash;
103115 +
103116 + hash = get_function_hash(fndecl);
103117 + if (!hash)
103118 + return;
103119 +
103120 + for (num = 0; num <= MAX_PARAM; num++)
103121 + if (hash->param & (1U << num))
103122 + handle_function_arg(stmt, fndecl, num);
103123 +}
103124 +
103125 +static bool check_return_value(void)
103126 +{
103127 + const struct size_overflow_hash *hash;
103128 +
103129 + hash = get_function_hash(current_function_decl);
103130 + if (!hash || !(hash->param & 1U << 0))
103131 + return false;
103132 +
103133 + return true;
103134 +}
103135 +
103136 +static void handle_return_value(gimple ret_stmt)
103137 +{
103138 + struct pointer_set_t *visited;
103139 + tree ret, new_ret;
103140 +
103141 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
103142 + return;
103143 +
103144 + ret = gimple_return_retval(ret_stmt);
103145 +
103146 + if (skip_types(ret))
103147 + return;
103148 +
103149 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
103150 + return;
103151 +
103152 + visited = pointer_set_create();
103153 + new_ret = expand(visited, ret);
103154 + pointer_set_destroy(visited);
103155 +
103156 + change_function_return(ret_stmt, ret, new_ret);
103157 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
103158 +}
103159 +
103160 +static void set_plf_false(void)
103161 +{
103162 + basic_block bb;
103163 +
103164 + FOR_ALL_BB(bb) {
103165 + gimple_stmt_iterator si;
103166 +
103167 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
103168 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103169 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
103170 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103171 + }
103172 +}
103173 +
103174 +static unsigned int handle_function(void)
103175 +{
103176 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
103177 + bool check_ret;
103178 +
103179 + set_plf_false();
103180 +
103181 + check_ret = check_return_value();
103182 +
103183 + do {
103184 + gimple_stmt_iterator gsi;
103185 + next = bb->next_bb;
103186 +
103187 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103188 + tree fndecl, attr;
103189 + gimple stmt = gsi_stmt(gsi);
103190 +
103191 + if (check_ret)
103192 + handle_return_value(stmt);
103193 +
103194 + if (!(is_gimple_call(stmt)))
103195 + continue;
103196 + fndecl = gimple_call_fndecl(stmt);
103197 + if (fndecl == NULL_TREE)
103198 + continue;
103199 + if (gimple_call_num_args(stmt) == 0)
103200 + continue;
103201 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
103202 + if (!attr || !TREE_VALUE(attr))
103203 + handle_function_by_hash(stmt, fndecl);
103204 + else
103205 + handle_function_by_attribute(stmt, attr, fndecl);
103206 + gsi = gsi_for_stmt(stmt);
103207 + next = gimple_bb(stmt)->next_bb;
103208 + }
103209 + bb = next;
103210 + } while (bb);
103211 + return 0;
103212 +}
103213 +
103214 +static struct gimple_opt_pass size_overflow_pass = {
103215 + .pass = {
103216 + .type = GIMPLE_PASS,
103217 + .name = "size_overflow",
103218 +#if BUILDING_GCC_VERSION >= 4008
103219 + .optinfo_flags = OPTGROUP_NONE,
103220 +#endif
103221 + .gate = NULL,
103222 + .execute = handle_function,
103223 + .sub = NULL,
103224 + .next = NULL,
103225 + .static_pass_number = 0,
103226 + .tv_id = TV_NONE,
103227 + .properties_required = PROP_cfg,
103228 + .properties_provided = 0,
103229 + .properties_destroyed = 0,
103230 + .todo_flags_start = 0,
103231 + .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
103232 + }
103233 +};
103234 +
103235 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
103236 +{
103237 + tree fntype;
103238 +
103239 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
103240 +
103241 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
103242 + fntype = build_function_type_list(void_type_node,
103243 + const_char_ptr_type_node,
103244 + unsigned_type_node,
103245 + const_char_ptr_type_node,
103246 + const_char_ptr_type_node,
103247 + NULL_TREE);
103248 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103249 +
103250 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103251 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103252 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103253 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103254 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103255 +}
103256 +
103257 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103258 +{
103259 + int i;
103260 + const char * const plugin_name = plugin_info->base_name;
103261 + const int argc = plugin_info->argc;
103262 + const struct plugin_argument * const argv = plugin_info->argv;
103263 + bool enable = true;
103264 +
103265 + struct register_pass_info size_overflow_pass_info = {
103266 + .pass = &size_overflow_pass.pass,
103267 + .reference_pass_name = "ssa",
103268 + .ref_pass_instance_number = 1,
103269 + .pos_op = PASS_POS_INSERT_AFTER
103270 + };
103271 +
103272 + if (!plugin_default_version_check(version, &gcc_version)) {
103273 + error(G_("incompatible gcc/plugin versions"));
103274 + return 1;
103275 + }
103276 +
103277 + for (i = 0; i < argc; ++i) {
103278 + if (!strcmp(argv[i].key, "no-size-overflow")) {
103279 + enable = false;
103280 + continue;
103281 + }
103282 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103283 + }
103284 +
103285 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
103286 + if (enable) {
103287 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103288 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
103289 + }
103290 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103291 +
103292 + return 0;
103293 +}
103294 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
103295 new file mode 100644
103296 index 0000000..ac2901e
103297 --- /dev/null
103298 +++ b/tools/gcc/stackleak_plugin.c
103299 @@ -0,0 +1,327 @@
103300 +/*
103301 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103302 + * Licensed under the GPL v2
103303 + *
103304 + * Note: the choice of the license means that the compilation process is
103305 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103306 + * but for the kernel it doesn't matter since it doesn't link against
103307 + * any of the gcc libraries
103308 + *
103309 + * gcc plugin to help implement various PaX features
103310 + *
103311 + * - track lowest stack pointer
103312 + *
103313 + * TODO:
103314 + * - initialize all local variables
103315 + *
103316 + * BUGS:
103317 + * - none known
103318 + */
103319 +#include "gcc-plugin.h"
103320 +#include "config.h"
103321 +#include "system.h"
103322 +#include "coretypes.h"
103323 +#include "tree.h"
103324 +#include "tree-pass.h"
103325 +#include "flags.h"
103326 +#include "intl.h"
103327 +#include "toplev.h"
103328 +#include "plugin.h"
103329 +//#include "expr.h" where are you...
103330 +#include "diagnostic.h"
103331 +#include "plugin-version.h"
103332 +#include "tm.h"
103333 +#include "function.h"
103334 +#include "basic-block.h"
103335 +#include "gimple.h"
103336 +#include "rtl.h"
103337 +#include "emit-rtl.h"
103338 +
103339 +#if BUILDING_GCC_VERSION >= 4008
103340 +#define TODO_dump_func 0
103341 +#endif
103342 +
103343 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103344 +
103345 +int plugin_is_GPL_compatible;
103346 +
103347 +static int track_frame_size = -1;
103348 +static const char track_function[] = "pax_track_stack";
103349 +static const char check_function[] = "pax_check_alloca";
103350 +static bool init_locals;
103351 +
103352 +static struct plugin_info stackleak_plugin_info = {
103353 + .version = "201302112000",
103354 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
103355 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
103356 +};
103357 +
103358 +static bool gate_stackleak_track_stack(void);
103359 +static unsigned int execute_stackleak_tree_instrument(void);
103360 +static unsigned int execute_stackleak_final(void);
103361 +
103362 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
103363 + .pass = {
103364 + .type = GIMPLE_PASS,
103365 + .name = "stackleak_tree_instrument",
103366 +#if BUILDING_GCC_VERSION >= 4008
103367 + .optinfo_flags = OPTGROUP_NONE,
103368 +#endif
103369 + .gate = gate_stackleak_track_stack,
103370 + .execute = execute_stackleak_tree_instrument,
103371 + .sub = NULL,
103372 + .next = NULL,
103373 + .static_pass_number = 0,
103374 + .tv_id = TV_NONE,
103375 + .properties_required = PROP_gimple_leh | PROP_cfg,
103376 + .properties_provided = 0,
103377 + .properties_destroyed = 0,
103378 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103379 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103380 + }
103381 +};
103382 +
103383 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103384 + .pass = {
103385 + .type = RTL_PASS,
103386 + .name = "stackleak_final",
103387 +#if BUILDING_GCC_VERSION >= 4008
103388 + .optinfo_flags = OPTGROUP_NONE,
103389 +#endif
103390 + .gate = gate_stackleak_track_stack,
103391 + .execute = execute_stackleak_final,
103392 + .sub = NULL,
103393 + .next = NULL,
103394 + .static_pass_number = 0,
103395 + .tv_id = TV_NONE,
103396 + .properties_required = 0,
103397 + .properties_provided = 0,
103398 + .properties_destroyed = 0,
103399 + .todo_flags_start = 0,
103400 + .todo_flags_finish = TODO_dump_func
103401 + }
103402 +};
103403 +
103404 +static bool gate_stackleak_track_stack(void)
103405 +{
103406 + return track_frame_size >= 0;
103407 +}
103408 +
103409 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103410 +{
103411 + gimple check_alloca;
103412 + tree fntype, fndecl, alloca_size;
103413 +
103414 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103415 + fndecl = build_fn_decl(check_function, fntype);
103416 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103417 +
103418 + // insert call to void pax_check_alloca(unsigned long size)
103419 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103420 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103421 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103422 +}
103423 +
103424 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103425 +{
103426 + gimple track_stack;
103427 + tree fntype, fndecl;
103428 +
103429 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103430 + fndecl = build_fn_decl(track_function, fntype);
103431 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103432 +
103433 + // insert call to void pax_track_stack(void)
103434 + track_stack = gimple_build_call(fndecl, 0);
103435 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103436 +}
103437 +
103438 +#if BUILDING_GCC_VERSION == 4005
103439 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103440 +{
103441 + tree fndecl;
103442 +
103443 + if (!is_gimple_call(stmt))
103444 + return false;
103445 + fndecl = gimple_call_fndecl(stmt);
103446 + if (!fndecl)
103447 + return false;
103448 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103449 + return false;
103450 +// print_node(stderr, "pax", fndecl, 4);
103451 + return DECL_FUNCTION_CODE(fndecl) == code;
103452 +}
103453 +#endif
103454 +
103455 +static bool is_alloca(gimple stmt)
103456 +{
103457 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103458 + return true;
103459 +
103460 +#if BUILDING_GCC_VERSION >= 4007
103461 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103462 + return true;
103463 +#endif
103464 +
103465 + return false;
103466 +}
103467 +
103468 +static unsigned int execute_stackleak_tree_instrument(void)
103469 +{
103470 + basic_block bb, entry_bb;
103471 + bool prologue_instrumented = false, is_leaf = true;
103472 +
103473 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103474 +
103475 + // 1. loop through BBs and GIMPLE statements
103476 + FOR_EACH_BB(bb) {
103477 + gimple_stmt_iterator gsi;
103478 +
103479 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103480 + gimple stmt;
103481 +
103482 + stmt = gsi_stmt(gsi);
103483 +
103484 + if (is_gimple_call(stmt))
103485 + is_leaf = false;
103486 +
103487 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103488 + if (!is_alloca(stmt))
103489 + continue;
103490 +
103491 + // 2. insert stack overflow check before each __builtin_alloca call
103492 + stackleak_check_alloca(&gsi);
103493 +
103494 + // 3. insert track call after each __builtin_alloca call
103495 + stackleak_add_instrumentation(&gsi);
103496 + if (bb == entry_bb)
103497 + prologue_instrumented = true;
103498 + }
103499 + }
103500 +
103501 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103502 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103503 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103504 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103505 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103506 + return 0;
103507 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103508 + return 0;
103509 +
103510 + // 4. insert track call at the beginning
103511 + if (!prologue_instrumented) {
103512 + gimple_stmt_iterator gsi;
103513 +
103514 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103515 + if (dom_info_available_p(CDI_DOMINATORS))
103516 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103517 + gsi = gsi_start_bb(bb);
103518 + stackleak_add_instrumentation(&gsi);
103519 + }
103520 +
103521 + return 0;
103522 +}
103523 +
103524 +static unsigned int execute_stackleak_final(void)
103525 +{
103526 + rtx insn, next;
103527 +
103528 + if (cfun->calls_alloca)
103529 + return 0;
103530 +
103531 + // keep calls only if function frame is big enough
103532 + if (get_frame_size() >= track_frame_size)
103533 + return 0;
103534 +
103535 + // 1. find pax_track_stack calls
103536 + for (insn = get_insns(); insn; insn = next) {
103537 + // 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))
103538 + rtx body;
103539 +
103540 + next = NEXT_INSN(insn);
103541 + if (!CALL_P(insn))
103542 + continue;
103543 + body = PATTERN(insn);
103544 + if (GET_CODE(body) != CALL)
103545 + continue;
103546 + body = XEXP(body, 0);
103547 + if (GET_CODE(body) != MEM)
103548 + continue;
103549 + body = XEXP(body, 0);
103550 + if (GET_CODE(body) != SYMBOL_REF)
103551 + continue;
103552 + if (strcmp(XSTR(body, 0), track_function))
103553 + continue;
103554 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103555 + // 2. delete call
103556 + delete_insn_and_edges(insn);
103557 +#if BUILDING_GCC_VERSION >= 4007
103558 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103559 + insn = next;
103560 + next = NEXT_INSN(insn);
103561 + delete_insn_and_edges(insn);
103562 + }
103563 +#endif
103564 + }
103565 +
103566 +// print_simple_rtl(stderr, get_insns());
103567 +// print_rtl(stderr, get_insns());
103568 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103569 +
103570 + return 0;
103571 +}
103572 +
103573 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103574 +{
103575 + const char * const plugin_name = plugin_info->base_name;
103576 + const int argc = plugin_info->argc;
103577 + const struct plugin_argument * const argv = plugin_info->argv;
103578 + int i;
103579 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103580 + .pass = &stackleak_tree_instrument_pass.pass,
103581 +// .reference_pass_name = "tree_profile",
103582 + .reference_pass_name = "optimized",
103583 + .ref_pass_instance_number = 1,
103584 + .pos_op = PASS_POS_INSERT_BEFORE
103585 + };
103586 + struct register_pass_info stackleak_final_pass_info = {
103587 + .pass = &stackleak_final_rtl_opt_pass.pass,
103588 + .reference_pass_name = "final",
103589 + .ref_pass_instance_number = 1,
103590 + .pos_op = PASS_POS_INSERT_BEFORE
103591 + };
103592 +
103593 + if (!plugin_default_version_check(version, &gcc_version)) {
103594 + error(G_("incompatible gcc/plugin versions"));
103595 + return 1;
103596 + }
103597 +
103598 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103599 +
103600 + for (i = 0; i < argc; ++i) {
103601 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103602 + if (!argv[i].value) {
103603 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103604 + continue;
103605 + }
103606 + track_frame_size = atoi(argv[i].value);
103607 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103608 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103609 + continue;
103610 + }
103611 + if (!strcmp(argv[i].key, "initialize-locals")) {
103612 + if (argv[i].value) {
103613 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103614 + continue;
103615 + }
103616 + init_locals = true;
103617 + continue;
103618 + }
103619 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103620 + }
103621 +
103622 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103623 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103624 +
103625 + return 0;
103626 +}
103627 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103628 new file mode 100644
103629 index 0000000..41770fc
103630 --- /dev/null
103631 +++ b/tools/gcc/structleak_plugin.c
103632 @@ -0,0 +1,272 @@
103633 +/*
103634 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103635 + * Licensed under the GPL v2
103636 + *
103637 + * Note: the choice of the license means that the compilation process is
103638 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103639 + * but for the kernel it doesn't matter since it doesn't link against
103640 + * any of the gcc libraries
103641 + *
103642 + * gcc plugin to forcibly initialize certain local variables that could
103643 + * otherwise leak kernel stack to userland if they aren't properly initialized
103644 + * by later code
103645 + *
103646 + * Homepage: http://pax.grsecurity.net/
103647 + *
103648 + * Usage:
103649 + * $ # for 4.5/4.6/C based 4.7
103650 + * $ 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
103651 + * $ # for C++ based 4.7/4.8+
103652 + * $ 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
103653 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103654 + *
103655 + * TODO: eliminate redundant initializers
103656 + * increase type coverage
103657 + */
103658 +
103659 +#include "gcc-plugin.h"
103660 +#include "config.h"
103661 +#include "system.h"
103662 +#include "coretypes.h"
103663 +#include "tree.h"
103664 +#include "tree-pass.h"
103665 +#include "intl.h"
103666 +#include "plugin-version.h"
103667 +#include "tm.h"
103668 +#include "toplev.h"
103669 +#include "function.h"
103670 +#include "tree-flow.h"
103671 +#include "plugin.h"
103672 +#include "gimple.h"
103673 +#include "diagnostic.h"
103674 +#include "cfgloop.h"
103675 +#include "langhooks.h"
103676 +
103677 +#if BUILDING_GCC_VERSION >= 4008
103678 +#define TODO_dump_func 0
103679 +#endif
103680 +
103681 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103682 +
103683 +// unused type flag in all versions 4.5-4.8
103684 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
103685 +
103686 +int plugin_is_GPL_compatible;
103687 +void debug_gimple_stmt(gimple gs);
103688 +
103689 +static struct plugin_info structleak_plugin_info = {
103690 + .version = "201304082245",
103691 + .help = "disable\tdo not activate plugin\n",
103692 +};
103693 +
103694 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103695 +{
103696 + *no_add_attrs = true;
103697 +
103698 + // check for types? for now accept everything linux has to offer
103699 + if (TREE_CODE(*node) != FIELD_DECL)
103700 + return NULL_TREE;
103701 +
103702 + *no_add_attrs = false;
103703 + return NULL_TREE;
103704 +}
103705 +
103706 +static struct attribute_spec user_attr = {
103707 + .name = "user",
103708 + .min_length = 0,
103709 + .max_length = 0,
103710 + .decl_required = false,
103711 + .type_required = false,
103712 + .function_type_required = false,
103713 + .handler = handle_user_attribute,
103714 +#if BUILDING_GCC_VERSION >= 4007
103715 + .affects_type_identity = true
103716 +#endif
103717 +};
103718 +
103719 +static void register_attributes(void *event_data, void *data)
103720 +{
103721 + register_attribute(&user_attr);
103722 +// register_attribute(&force_attr);
103723 +}
103724 +
103725 +static tree get_field_type(tree field)
103726 +{
103727 + return strip_array_types(TREE_TYPE(field));
103728 +}
103729 +
103730 +static bool is_userspace_type(tree type)
103731 +{
103732 + tree field;
103733 +
103734 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
103735 + tree fieldtype = get_field_type(field);
103736 + enum tree_code code = TREE_CODE(fieldtype);
103737 +
103738 + if (code == RECORD_TYPE || code == UNION_TYPE)
103739 + if (is_userspace_type(fieldtype))
103740 + return true;
103741 +
103742 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
103743 + return true;
103744 + }
103745 + return false;
103746 +}
103747 +
103748 +static void finish_type(void *event_data, void *data)
103749 +{
103750 + tree type = (tree)event_data;
103751 +
103752 + if (TYPE_USERSPACE(type))
103753 + return;
103754 +
103755 + if (is_userspace_type(type))
103756 + TYPE_USERSPACE(type) = 1;
103757 +}
103758 +
103759 +static void initialize(tree var)
103760 +{
103761 + basic_block bb;
103762 + gimple_stmt_iterator gsi;
103763 + tree initializer;
103764 + gimple init_stmt;
103765 +
103766 + // this is the original entry bb before the forced split
103767 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
103768 +
103769 + // first check if the variable is already initialized, warn otherwise
103770 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103771 + gimple stmt = gsi_stmt(gsi);
103772 + tree rhs1 = gimple_assign_rhs1(stmt);
103773 +
103774 + // we're looking for an assignment of a single rhs...
103775 + if (!gimple_assign_single_p(stmt))
103776 + continue;
103777 +#if BUILDING_GCC_VERSION >= 4007
103778 + // ... of a non-clobbering expression...
103779 + if (TREE_CLOBBER_P(rhs1))
103780 + continue;
103781 +#endif
103782 + // ... to our variable...
103783 + if (gimple_get_lhs(stmt) != var)
103784 + continue;
103785 + // if it's an initializer then we're good
103786 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
103787 + return;
103788 + }
103789 +
103790 + // build the initializer expression
103791 + initializer = build_constructor(TREE_TYPE(var), NULL);
103792 +
103793 + // build the initializer stmt
103794 + init_stmt = gimple_build_assign(var, initializer);
103795 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
103796 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
103797 + update_stmt(init_stmt);
103798 +}
103799 +
103800 +static unsigned int handle_function(void)
103801 +{
103802 + basic_block bb;
103803 + unsigned int ret = 0;
103804 + tree var;
103805 +
103806 +#if BUILDING_GCC_VERSION == 4005
103807 + tree vars;
103808 +#else
103809 + unsigned int i;
103810 +#endif
103811 +
103812 + // split the first bb where we can put the forced initializers
103813 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103814 + if (dom_info_available_p(CDI_DOMINATORS))
103815 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103816 +
103817 + // enumarate all local variables and forcibly initialize our targets
103818 +#if BUILDING_GCC_VERSION == 4005
103819 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
103820 + var = TREE_VALUE(vars);
103821 +#else
103822 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
103823 +#endif
103824 + tree type = TREE_TYPE(var);
103825 +
103826 + gcc_assert(DECL_P(var));
103827 + if (!auto_var_in_fn_p(var, current_function_decl))
103828 + continue;
103829 +
103830 + // only care about structure types
103831 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
103832 + continue;
103833 +
103834 + // if the type is of interest, examine the variable
103835 + if (TYPE_USERSPACE(type))
103836 + initialize(var);
103837 + }
103838 +
103839 + return ret;
103840 +}
103841 +
103842 +static struct gimple_opt_pass structleak_pass = {
103843 + .pass = {
103844 + .type = GIMPLE_PASS,
103845 + .name = "structleak",
103846 +#if BUILDING_GCC_VERSION >= 4008
103847 + .optinfo_flags = OPTGROUP_NONE,
103848 +#endif
103849 + .gate = NULL,
103850 + .execute = handle_function,
103851 + .sub = NULL,
103852 + .next = NULL,
103853 + .static_pass_number = 0,
103854 + .tv_id = TV_NONE,
103855 + .properties_required = PROP_cfg,
103856 + .properties_provided = 0,
103857 + .properties_destroyed = 0,
103858 + .todo_flags_start = 0,
103859 + .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
103860 + }
103861 +};
103862 +
103863 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103864 +{
103865 + int i;
103866 + const char * const plugin_name = plugin_info->base_name;
103867 + const int argc = plugin_info->argc;
103868 + const struct plugin_argument * const argv = plugin_info->argv;
103869 + bool enable = true;
103870 +
103871 + struct register_pass_info structleak_pass_info = {
103872 + .pass = &structleak_pass.pass,
103873 + .reference_pass_name = "ssa",
103874 + .ref_pass_instance_number = 1,
103875 + .pos_op = PASS_POS_INSERT_AFTER
103876 + };
103877 +
103878 + if (!plugin_default_version_check(version, &gcc_version)) {
103879 + error(G_("incompatible gcc/plugin versions"));
103880 + return 1;
103881 + }
103882 +
103883 + if (strcmp(lang_hooks.name, "GNU C")) {
103884 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
103885 + enable = false;
103886 + }
103887 +
103888 + for (i = 0; i < argc; ++i) {
103889 + if (!strcmp(argv[i].key, "disable")) {
103890 + enable = false;
103891 + continue;
103892 + }
103893 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103894 + }
103895 +
103896 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
103897 + if (enable) {
103898 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
103899 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
103900 + }
103901 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103902 +
103903 + return 0;
103904 +}
103905 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
103906 index 6789d78..4afd019e 100644
103907 --- a/tools/perf/util/include/asm/alternative-asm.h
103908 +++ b/tools/perf/util/include/asm/alternative-asm.h
103909 @@ -5,4 +5,7 @@
103910
103911 #define altinstruction_entry #
103912
103913 + .macro pax_force_retaddr rip=0, reload=0
103914 + .endm
103915 +
103916 #endif
103917 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
103918 index 96b919d..c49bb74 100644
103919 --- a/tools/perf/util/include/linux/compiler.h
103920 +++ b/tools/perf/util/include/linux/compiler.h
103921 @@ -18,4 +18,12 @@
103922 #define __force
103923 #endif
103924
103925 +#ifndef __size_overflow
103926 +# define __size_overflow(...)
103927 +#endif
103928 +
103929 +#ifndef __intentional_overflow
103930 +# define __intentional_overflow(...)
103931 +#endif
103932 +
103933 #endif
103934 diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
103935 index cfb7e4d..52058f0 100644
103936 --- a/virt/kvm/ioapic.c
103937 +++ b/virt/kvm/ioapic.c
103938 @@ -73,9 +73,12 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
103939 u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
103940 u64 redir_content;
103941
103942 - ASSERT(redir_index < IOAPIC_NUM_PINS);
103943 + if (redir_index < IOAPIC_NUM_PINS)
103944 + redir_content =
103945 + ioapic->redirtbl[redir_index].bits;
103946 + else
103947 + redir_content = ~0ULL;
103948
103949 - redir_content = ioapic->redirtbl[redir_index].bits;
103950 result = (ioapic->ioregsel & 0x1) ?
103951 (redir_content >> 32) & 0xffffffff :
103952 redir_content & 0xffffffff;
103953 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
103954 index 1cd693a..f4a7b20 100644
103955 --- a/virt/kvm/kvm_main.c
103956 +++ b/virt/kvm/kvm_main.c
103957 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
103958
103959 static cpumask_var_t cpus_hardware_enabled;
103960 static int kvm_usage_count = 0;
103961 -static atomic_t hardware_enable_failed;
103962 +static atomic_unchecked_t hardware_enable_failed;
103963
103964 struct kmem_cache *kvm_vcpu_cache;
103965 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
103966
103967 -static __read_mostly struct preempt_ops kvm_preempt_ops;
103968 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
103969 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
103970 +static struct preempt_ops kvm_preempt_ops = {
103971 + .sched_in = kvm_sched_in,
103972 + .sched_out = kvm_sched_out,
103973 +};
103974
103975 struct dentry *kvm_debugfs_dir;
103976
103977 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
103978 /* We can read the guest memory with __xxx_user() later on. */
103979 if (user_alloc &&
103980 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
103981 - !access_ok(VERIFY_WRITE,
103982 + !__access_ok(VERIFY_WRITE,
103983 (void __user *)(unsigned long)mem->userspace_addr,
103984 mem->memory_size)))
103985 goto out;
103986 @@ -1783,7 +1788,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
103987 return 0;
103988 }
103989
103990 -static struct file_operations kvm_vcpu_fops = {
103991 +static file_operations_no_const kvm_vcpu_fops __read_only = {
103992 .release = kvm_vcpu_release,
103993 .unlocked_ioctl = kvm_vcpu_ioctl,
103994 #ifdef CONFIG_COMPAT
103995 @@ -2304,7 +2309,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
103996 return 0;
103997 }
103998
103999 -static struct file_operations kvm_vm_fops = {
104000 +static file_operations_no_const kvm_vm_fops __read_only = {
104001 .release = kvm_vm_release,
104002 .unlocked_ioctl = kvm_vm_ioctl,
104003 #ifdef CONFIG_COMPAT
104004 @@ -2402,7 +2407,7 @@ out:
104005 return r;
104006 }
104007
104008 -static struct file_operations kvm_chardev_ops = {
104009 +static file_operations_no_const kvm_chardev_ops __read_only = {
104010 .unlocked_ioctl = kvm_dev_ioctl,
104011 .compat_ioctl = kvm_dev_ioctl,
104012 .llseek = noop_llseek,
104013 @@ -2428,7 +2433,7 @@ static void hardware_enable_nolock(void *junk)
104014
104015 if (r) {
104016 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
104017 - atomic_inc(&hardware_enable_failed);
104018 + atomic_inc_unchecked(&hardware_enable_failed);
104019 printk(KERN_INFO "kvm: enabling virtualization on "
104020 "CPU%d failed\n", cpu);
104021 }
104022 @@ -2482,10 +2487,10 @@ static int hardware_enable_all(void)
104023
104024 kvm_usage_count++;
104025 if (kvm_usage_count == 1) {
104026 - atomic_set(&hardware_enable_failed, 0);
104027 + atomic_set_unchecked(&hardware_enable_failed, 0);
104028 on_each_cpu(hardware_enable_nolock, NULL, 1);
104029
104030 - if (atomic_read(&hardware_enable_failed)) {
104031 + if (atomic_read_unchecked(&hardware_enable_failed)) {
104032 hardware_disable_all_nolock();
104033 r = -EBUSY;
104034 }
104035 @@ -2843,7 +2848,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
104036 kvm_arch_vcpu_put(vcpu);
104037 }
104038
104039 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104040 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104041 struct module *module)
104042 {
104043 int r;
104044 @@ -2879,7 +2884,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104045 if (!vcpu_align)
104046 vcpu_align = __alignof__(struct kvm_vcpu);
104047 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
104048 - 0, NULL);
104049 + SLAB_USERCOPY, NULL);
104050 if (!kvm_vcpu_cache) {
104051 r = -ENOMEM;
104052 goto out_free_3;
104053 @@ -2889,9 +2894,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104054 if (r)
104055 goto out_free;
104056
104057 + pax_open_kernel();
104058 kvm_chardev_ops.owner = module;
104059 kvm_vm_fops.owner = module;
104060 kvm_vcpu_fops.owner = module;
104061 + pax_close_kernel();
104062
104063 r = misc_register(&kvm_dev);
104064 if (r) {
104065 @@ -2901,9 +2908,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104066
104067 register_syscore_ops(&kvm_syscore_ops);
104068
104069 - kvm_preempt_ops.sched_in = kvm_sched_in;
104070 - kvm_preempt_ops.sched_out = kvm_sched_out;
104071 -
104072 r = kvm_init_debug();
104073 if (r) {
104074 printk(KERN_ERR "kvm: create debugfs files failed\n");