]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.8.5-201304032222.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.8.5-201304032222.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 14b38cf..90b3a74 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 +HOSTCLFAGS += $(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..0e40765 100644
810 --- a/arch/arm/Kconfig
811 +++ b/arch/arm/Kconfig
812 @@ -1813,7 +1813,7 @@ config ALIGNMENT_TRAP
813
814 config UACCESS_WITH_MEMCPY
815 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
816 - depends on MMU
817 + depends on MMU && !PAX_MEMORY_UDEREF
818 default y if CPU_FEROCEON
819 help
820 Implement faster copy_to_user and clear_user methods for CPU
821 diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
822 index 87dfa902..3a523fc 100644
823 --- a/arch/arm/common/gic.c
824 +++ b/arch/arm/common/gic.c
825 @@ -81,7 +81,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
826 * Supported arch specific GIC irq extension.
827 * Default make them NULL.
828 */
829 -struct irq_chip gic_arch_extn = {
830 +irq_chip_no_const gic_arch_extn __read_only = {
831 .irq_eoi = NULL,
832 .irq_mask = NULL,
833 .irq_unmask = NULL,
834 @@ -329,7 +329,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
835 chained_irq_exit(chip, desc);
836 }
837
838 -static struct irq_chip gic_chip = {
839 +static irq_chip_no_const gic_chip __read_only = {
840 .name = "GIC",
841 .irq_mask = gic_mask_irq,
842 .irq_unmask = gic_unmask_irq,
843 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
844 index c79f61f..9ac0642 100644
845 --- a/arch/arm/include/asm/atomic.h
846 +++ b/arch/arm/include/asm/atomic.h
847 @@ -17,17 +17,35 @@
848 #include <asm/barrier.h>
849 #include <asm/cmpxchg.h>
850
851 +#ifdef CONFIG_GENERIC_ATOMIC64
852 +#include <asm-generic/atomic64.h>
853 +#endif
854 +
855 #define ATOMIC_INIT(i) { (i) }
856
857 #ifdef __KERNEL__
858
859 +#define _ASM_EXTABLE(from, to) \
860 +" .pushsection __ex_table,\"a\"\n"\
861 +" .align 3\n" \
862 +" .long " #from ", " #to"\n" \
863 +" .popsection"
864 +
865 /*
866 * On ARM, ordinary assignment (str instruction) doesn't clear the local
867 * strex/ldrex monitor on some implementations. The reason we can use it for
868 * atomic_set() is the clrex or dummy strex done on every exception return.
869 */
870 #define atomic_read(v) (*(volatile int *)&(v)->counter)
871 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
872 +{
873 + return v->counter;
874 +}
875 #define atomic_set(v,i) (((v)->counter) = (i))
876 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
877 +{
878 + v->counter = i;
879 +}
880
881 #if __LINUX_ARM_ARCH__ >= 6
882
883 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
884 int result;
885
886 __asm__ __volatile__("@ atomic_add\n"
887 +"1: ldrex %1, [%3]\n"
888 +" adds %0, %1, %4\n"
889 +
890 +#ifdef CONFIG_PAX_REFCOUNT
891 +" bvc 3f\n"
892 +"2: bkpt 0xf103\n"
893 +"3:\n"
894 +#endif
895 +
896 +" strex %1, %0, [%3]\n"
897 +" teq %1, #0\n"
898 +" bne 1b"
899 +
900 +#ifdef CONFIG_PAX_REFCOUNT
901 +"\n4:\n"
902 + _ASM_EXTABLE(2b, 4b)
903 +#endif
904 +
905 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
906 + : "r" (&v->counter), "Ir" (i)
907 + : "cc");
908 +}
909 +
910 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
911 +{
912 + unsigned long tmp;
913 + int result;
914 +
915 + __asm__ __volatile__("@ atomic_add_unchecked\n"
916 "1: ldrex %0, [%3]\n"
917 " add %0, %0, %4\n"
918 " strex %1, %0, [%3]\n"
919 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
920 smp_mb();
921
922 __asm__ __volatile__("@ atomic_add_return\n"
923 +"1: ldrex %1, [%3]\n"
924 +" adds %0, %1, %4\n"
925 +
926 +#ifdef CONFIG_PAX_REFCOUNT
927 +" bvc 3f\n"
928 +" mov %0, %1\n"
929 +"2: bkpt 0xf103\n"
930 +"3:\n"
931 +#endif
932 +
933 +" strex %1, %0, [%3]\n"
934 +" teq %1, #0\n"
935 +" bne 1b"
936 +
937 +#ifdef CONFIG_PAX_REFCOUNT
938 +"\n4:\n"
939 + _ASM_EXTABLE(2b, 4b)
940 +#endif
941 +
942 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
943 + : "r" (&v->counter), "Ir" (i)
944 + : "cc");
945 +
946 + smp_mb();
947 +
948 + return result;
949 +}
950 +
951 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
952 +{
953 + unsigned long tmp;
954 + int result;
955 +
956 + smp_mb();
957 +
958 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
959 "1: ldrex %0, [%3]\n"
960 " add %0, %0, %4\n"
961 " strex %1, %0, [%3]\n"
962 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
963 int result;
964
965 __asm__ __volatile__("@ atomic_sub\n"
966 +"1: ldrex %1, [%3]\n"
967 +" subs %0, %1, %4\n"
968 +
969 +#ifdef CONFIG_PAX_REFCOUNT
970 +" bvc 3f\n"
971 +"2: bkpt 0xf103\n"
972 +"3:\n"
973 +#endif
974 +
975 +" strex %1, %0, [%3]\n"
976 +" teq %1, #0\n"
977 +" bne 1b"
978 +
979 +#ifdef CONFIG_PAX_REFCOUNT
980 +"\n4:\n"
981 + _ASM_EXTABLE(2b, 4b)
982 +#endif
983 +
984 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
985 + : "r" (&v->counter), "Ir" (i)
986 + : "cc");
987 +}
988 +
989 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
990 +{
991 + unsigned long tmp;
992 + int result;
993 +
994 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
995 "1: ldrex %0, [%3]\n"
996 " sub %0, %0, %4\n"
997 " strex %1, %0, [%3]\n"
998 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
999 smp_mb();
1000
1001 __asm__ __volatile__("@ atomic_sub_return\n"
1002 -"1: ldrex %0, [%3]\n"
1003 -" sub %0, %0, %4\n"
1004 +"1: ldrex %1, [%3]\n"
1005 +" subs %0, %1, %4\n"
1006 +
1007 +#ifdef CONFIG_PAX_REFCOUNT
1008 +" bvc 3f\n"
1009 +" mov %0, %1\n"
1010 +"2: bkpt 0xf103\n"
1011 +"3:\n"
1012 +#endif
1013 +
1014 " strex %1, %0, [%3]\n"
1015 " teq %1, #0\n"
1016 " bne 1b"
1017 +
1018 +#ifdef CONFIG_PAX_REFCOUNT
1019 +"\n4:\n"
1020 + _ASM_EXTABLE(2b, 4b)
1021 +#endif
1022 +
1023 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1024 : "r" (&v->counter), "Ir" (i)
1025 : "cc");
1026 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1027 return oldval;
1028 }
1029
1030 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1031 +{
1032 + unsigned long oldval, res;
1033 +
1034 + smp_mb();
1035 +
1036 + do {
1037 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1038 + "ldrex %1, [%3]\n"
1039 + "mov %0, #0\n"
1040 + "teq %1, %4\n"
1041 + "strexeq %0, %5, [%3]\n"
1042 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1043 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1044 + : "cc");
1045 + } while (res);
1046 +
1047 + smp_mb();
1048 +
1049 + return oldval;
1050 +}
1051 +
1052 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1053 {
1054 unsigned long tmp, tmp2;
1055 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1056
1057 return val;
1058 }
1059 +
1060 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1061 +{
1062 + return atomic_add_return(i, v);
1063 +}
1064 +
1065 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1066 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1067 +{
1068 + (void) atomic_add_return(i, v);
1069 +}
1070
1071 static inline int atomic_sub_return(int i, atomic_t *v)
1072 {
1073 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1074 return val;
1075 }
1076 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1077 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1078 +{
1079 + (void) atomic_sub_return(i, v);
1080 +}
1081
1082 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1083 {
1084 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1085 return ret;
1086 }
1087
1088 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1089 +{
1090 + return atomic_cmpxchg(v, old, new);
1091 +}
1092 +
1093 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1094 {
1095 unsigned long flags;
1096 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1097 #endif /* __LINUX_ARM_ARCH__ */
1098
1099 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1100 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1101 +{
1102 + return xchg(&v->counter, new);
1103 +}
1104
1105 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1106 {
1107 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1108 }
1109
1110 #define atomic_inc(v) atomic_add(1, v)
1111 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1112 +{
1113 + atomic_add_unchecked(1, v);
1114 +}
1115 #define atomic_dec(v) atomic_sub(1, v)
1116 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1117 +{
1118 + atomic_sub_unchecked(1, v);
1119 +}
1120
1121 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1122 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1123 +{
1124 + return atomic_add_return_unchecked(1, v) == 0;
1125 +}
1126 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1127 #define atomic_inc_return(v) (atomic_add_return(1, v))
1128 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1129 +{
1130 + return atomic_add_return_unchecked(1, v);
1131 +}
1132 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1133 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1134
1135 @@ -241,6 +428,14 @@ typedef struct {
1136 u64 __aligned(8) counter;
1137 } atomic64_t;
1138
1139 +#ifdef CONFIG_PAX_REFCOUNT
1140 +typedef struct {
1141 + u64 __aligned(8) counter;
1142 +} atomic64_unchecked_t;
1143 +#else
1144 +typedef atomic64_t atomic64_unchecked_t;
1145 +#endif
1146 +
1147 #define ATOMIC64_INIT(i) { (i) }
1148
1149 static inline u64 atomic64_read(const atomic64_t *v)
1150 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1151 return result;
1152 }
1153
1154 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1155 +{
1156 + u64 result;
1157 +
1158 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1159 +" ldrexd %0, %H0, [%1]"
1160 + : "=&r" (result)
1161 + : "r" (&v->counter), "Qo" (v->counter)
1162 + );
1163 +
1164 + return result;
1165 +}
1166 +
1167 static inline void atomic64_set(atomic64_t *v, u64 i)
1168 {
1169 u64 tmp;
1170 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1171 : "cc");
1172 }
1173
1174 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1175 +{
1176 + u64 tmp;
1177 +
1178 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1179 +"1: ldrexd %0, %H0, [%2]\n"
1180 +" strexd %0, %3, %H3, [%2]\n"
1181 +" teq %0, #0\n"
1182 +" bne 1b"
1183 + : "=&r" (tmp), "=Qo" (v->counter)
1184 + : "r" (&v->counter), "r" (i)
1185 + : "cc");
1186 +}
1187 +
1188 static inline void atomic64_add(u64 i, atomic64_t *v)
1189 {
1190 u64 result;
1191 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1192 __asm__ __volatile__("@ atomic64_add\n"
1193 "1: ldrexd %0, %H0, [%3]\n"
1194 " adds %0, %0, %4\n"
1195 +" adcs %H0, %H0, %H4\n"
1196 +
1197 +#ifdef CONFIG_PAX_REFCOUNT
1198 +" bvc 3f\n"
1199 +"2: bkpt 0xf103\n"
1200 +"3:\n"
1201 +#endif
1202 +
1203 +" strexd %1, %0, %H0, [%3]\n"
1204 +" teq %1, #0\n"
1205 +" bne 1b"
1206 +
1207 +#ifdef CONFIG_PAX_REFCOUNT
1208 +"\n4:\n"
1209 + _ASM_EXTABLE(2b, 4b)
1210 +#endif
1211 +
1212 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1213 + : "r" (&v->counter), "r" (i)
1214 + : "cc");
1215 +}
1216 +
1217 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1218 +{
1219 + u64 result;
1220 + unsigned long tmp;
1221 +
1222 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1223 +"1: ldrexd %0, %H0, [%3]\n"
1224 +" adds %0, %0, %4\n"
1225 " adc %H0, %H0, %H4\n"
1226 " strexd %1, %0, %H0, [%3]\n"
1227 " teq %1, #0\n"
1228 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1229
1230 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1231 {
1232 - u64 result;
1233 - unsigned long tmp;
1234 + u64 result, tmp;
1235
1236 smp_mb();
1237
1238 __asm__ __volatile__("@ atomic64_add_return\n"
1239 +"1: ldrexd %1, %H1, [%3]\n"
1240 +" adds %0, %1, %4\n"
1241 +" adcs %H0, %H1, %H4\n"
1242 +
1243 +#ifdef CONFIG_PAX_REFCOUNT
1244 +" bvc 3f\n"
1245 +" mov %0, %1\n"
1246 +" mov %H0, %H1\n"
1247 +"2: bkpt 0xf103\n"
1248 +"3:\n"
1249 +#endif
1250 +
1251 +" strexd %1, %0, %H0, [%3]\n"
1252 +" teq %1, #0\n"
1253 +" bne 1b"
1254 +
1255 +#ifdef CONFIG_PAX_REFCOUNT
1256 +"\n4:\n"
1257 + _ASM_EXTABLE(2b, 4b)
1258 +#endif
1259 +
1260 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1261 + : "r" (&v->counter), "r" (i)
1262 + : "cc");
1263 +
1264 + smp_mb();
1265 +
1266 + return result;
1267 +}
1268 +
1269 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1270 +{
1271 + u64 result;
1272 + unsigned long tmp;
1273 +
1274 + smp_mb();
1275 +
1276 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1277 "1: ldrexd %0, %H0, [%3]\n"
1278 " adds %0, %0, %4\n"
1279 " adc %H0, %H0, %H4\n"
1280 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1281 __asm__ __volatile__("@ atomic64_sub\n"
1282 "1: ldrexd %0, %H0, [%3]\n"
1283 " subs %0, %0, %4\n"
1284 +" sbcs %H0, %H0, %H4\n"
1285 +
1286 +#ifdef CONFIG_PAX_REFCOUNT
1287 +" bvc 3f\n"
1288 +"2: bkpt 0xf103\n"
1289 +"3:\n"
1290 +#endif
1291 +
1292 +" strexd %1, %0, %H0, [%3]\n"
1293 +" teq %1, #0\n"
1294 +" bne 1b"
1295 +
1296 +#ifdef CONFIG_PAX_REFCOUNT
1297 +"\n4:\n"
1298 + _ASM_EXTABLE(2b, 4b)
1299 +#endif
1300 +
1301 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1302 + : "r" (&v->counter), "r" (i)
1303 + : "cc");
1304 +}
1305 +
1306 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1307 +{
1308 + u64 result;
1309 + unsigned long tmp;
1310 +
1311 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1312 +"1: ldrexd %0, %H0, [%3]\n"
1313 +" subs %0, %0, %4\n"
1314 " sbc %H0, %H0, %H4\n"
1315 " strexd %1, %0, %H0, [%3]\n"
1316 " teq %1, #0\n"
1317 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1318
1319 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1320 {
1321 - u64 result;
1322 - unsigned long tmp;
1323 + u64 result, tmp;
1324
1325 smp_mb();
1326
1327 __asm__ __volatile__("@ atomic64_sub_return\n"
1328 -"1: ldrexd %0, %H0, [%3]\n"
1329 -" subs %0, %0, %4\n"
1330 -" sbc %H0, %H0, %H4\n"
1331 +"1: ldrexd %1, %H1, [%3]\n"
1332 +" subs %0, %1, %4\n"
1333 +" sbcs %H0, %H1, %H4\n"
1334 +
1335 +#ifdef CONFIG_PAX_REFCOUNT
1336 +" bvc 3f\n"
1337 +" mov %0, %1\n"
1338 +" mov %H0, %H1\n"
1339 +"2: bkpt 0xf103\n"
1340 +"3:\n"
1341 +#endif
1342 +
1343 " strexd %1, %0, %H0, [%3]\n"
1344 " teq %1, #0\n"
1345 " bne 1b"
1346 +
1347 +#ifdef CONFIG_PAX_REFCOUNT
1348 +"\n4:\n"
1349 + _ASM_EXTABLE(2b, 4b)
1350 +#endif
1351 +
1352 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1353 : "r" (&v->counter), "r" (i)
1354 : "cc");
1355 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1356 return oldval;
1357 }
1358
1359 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1360 +{
1361 + u64 oldval;
1362 + unsigned long res;
1363 +
1364 + smp_mb();
1365 +
1366 + do {
1367 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1368 + "ldrexd %1, %H1, [%3]\n"
1369 + "mov %0, #0\n"
1370 + "teq %1, %4\n"
1371 + "teqeq %H1, %H4\n"
1372 + "strexdeq %0, %5, %H5, [%3]"
1373 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1374 + : "r" (&ptr->counter), "r" (old), "r" (new)
1375 + : "cc");
1376 + } while (res);
1377 +
1378 + smp_mb();
1379 +
1380 + return oldval;
1381 +}
1382 +
1383 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1384 {
1385 u64 result;
1386 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1387
1388 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1389 {
1390 - u64 result;
1391 - unsigned long tmp;
1392 + u64 result, tmp;
1393
1394 smp_mb();
1395
1396 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1397 -"1: ldrexd %0, %H0, [%3]\n"
1398 -" subs %0, %0, #1\n"
1399 -" sbc %H0, %H0, #0\n"
1400 +"1: ldrexd %1, %H1, [%3]\n"
1401 +" subs %0, %1, #1\n"
1402 +" sbcs %H0, %H1, #0\n"
1403 +
1404 +#ifdef CONFIG_PAX_REFCOUNT
1405 +" bvc 3f\n"
1406 +" mov %0, %1\n"
1407 +" mov %H0, %H1\n"
1408 +"2: bkpt 0xf103\n"
1409 +"3:\n"
1410 +#endif
1411 +
1412 " teq %H0, #0\n"
1413 -" bmi 2f\n"
1414 +" bmi 4f\n"
1415 " strexd %1, %0, %H0, [%3]\n"
1416 " teq %1, #0\n"
1417 " bne 1b\n"
1418 -"2:"
1419 +"4:\n"
1420 +
1421 +#ifdef CONFIG_PAX_REFCOUNT
1422 + _ASM_EXTABLE(2b, 4b)
1423 +#endif
1424 +
1425 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1426 : "r" (&v->counter)
1427 : "cc");
1428 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1429 " teq %0, %5\n"
1430 " teqeq %H0, %H5\n"
1431 " moveq %1, #0\n"
1432 -" beq 2f\n"
1433 +" beq 4f\n"
1434 " adds %0, %0, %6\n"
1435 -" adc %H0, %H0, %H6\n"
1436 +" adcs %H0, %H0, %H6\n"
1437 +
1438 +#ifdef CONFIG_PAX_REFCOUNT
1439 +" bvc 3f\n"
1440 +"2: bkpt 0xf103\n"
1441 +"3:\n"
1442 +#endif
1443 +
1444 " strexd %2, %0, %H0, [%4]\n"
1445 " teq %2, #0\n"
1446 " bne 1b\n"
1447 -"2:"
1448 +"4:\n"
1449 +
1450 +#ifdef CONFIG_PAX_REFCOUNT
1451 + _ASM_EXTABLE(2b, 4b)
1452 +#endif
1453 +
1454 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1455 : "r" (&v->counter), "r" (u), "r" (a)
1456 : "cc");
1457 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1458
1459 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1460 #define atomic64_inc(v) atomic64_add(1LL, (v))
1461 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1462 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1463 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1464 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1465 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1466 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1467 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1468 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1469 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1470 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1471 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1472 index 75fe66b..ba3dee4 100644
1473 --- a/arch/arm/include/asm/cache.h
1474 +++ b/arch/arm/include/asm/cache.h
1475 @@ -4,8 +4,10 @@
1476 #ifndef __ASMARM_CACHE_H
1477 #define __ASMARM_CACHE_H
1478
1479 +#include <linux/const.h>
1480 +
1481 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1482 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1483 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1484
1485 /*
1486 * Memory returned by kmalloc() may be used for DMA, so we must make
1487 @@ -24,5 +26,6 @@
1488 #endif
1489
1490 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1491 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1492
1493 #endif
1494 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1495 index e1489c5..d418304 100644
1496 --- a/arch/arm/include/asm/cacheflush.h
1497 +++ b/arch/arm/include/asm/cacheflush.h
1498 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1499 void (*dma_unmap_area)(const void *, size_t, int);
1500
1501 void (*dma_flush_range)(const void *, const void *);
1502 -};
1503 +} __no_const;
1504
1505 /*
1506 * Select the calling method
1507 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1508 index 6dcc164..b14d917 100644
1509 --- a/arch/arm/include/asm/checksum.h
1510 +++ b/arch/arm/include/asm/checksum.h
1511 @@ -37,7 +37,19 @@ __wsum
1512 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1513
1514 __wsum
1515 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1516 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1517 +
1518 +static inline __wsum
1519 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1520 +{
1521 + __wsum ret;
1522 + pax_open_userland();
1523 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1524 + pax_close_userland();
1525 + return ret;
1526 +}
1527 +
1528 +
1529
1530 /*
1531 * Fold a partial checksum without adding pseudo headers
1532 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1533 index 7eb18c1..e38b6d2 100644
1534 --- a/arch/arm/include/asm/cmpxchg.h
1535 +++ b/arch/arm/include/asm/cmpxchg.h
1536 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1537
1538 #define xchg(ptr,x) \
1539 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1540 +#define xchg_unchecked(ptr,x) \
1541 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1542
1543 #include <asm-generic/cmpxchg-local.h>
1544
1545 diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h
1546 index 720799f..2f67631 100644
1547 --- a/arch/arm/include/asm/delay.h
1548 +++ b/arch/arm/include/asm/delay.h
1549 @@ -25,9 +25,9 @@ extern struct arm_delay_ops {
1550 void (*const_udelay)(unsigned long);
1551 void (*udelay)(unsigned long);
1552 bool const_clock;
1553 -} arm_delay_ops;
1554 +} *arm_delay_ops;
1555
1556 -#define __delay(n) arm_delay_ops.delay(n)
1557 +#define __delay(n) arm_delay_ops->delay(n)
1558
1559 /*
1560 * This function intentionally does not exist; if you see references to
1561 @@ -48,8 +48,8 @@ extern void __bad_udelay(void);
1562 * first constant multiplications gets optimized away if the delay is
1563 * a constant)
1564 */
1565 -#define __udelay(n) arm_delay_ops.udelay(n)
1566 -#define __const_udelay(n) arm_delay_ops.const_udelay(n)
1567 +#define __udelay(n) arm_delay_ops->udelay(n)
1568 +#define __const_udelay(n) arm_delay_ops->const_udelay(n)
1569
1570 #define udelay(n) \
1571 (__builtin_constant_p(n) ? \
1572 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1573 index 6ddbe44..b5e38b1 100644
1574 --- a/arch/arm/include/asm/domain.h
1575 +++ b/arch/arm/include/asm/domain.h
1576 @@ -48,18 +48,37 @@
1577 * Domain types
1578 */
1579 #define DOMAIN_NOACCESS 0
1580 -#define DOMAIN_CLIENT 1
1581 #ifdef CONFIG_CPU_USE_DOMAINS
1582 +#define DOMAIN_USERCLIENT 1
1583 +#define DOMAIN_KERNELCLIENT 1
1584 #define DOMAIN_MANAGER 3
1585 +#define DOMAIN_VECTORS DOMAIN_USER
1586 #else
1587 +
1588 +#ifdef CONFIG_PAX_KERNEXEC
1589 #define DOMAIN_MANAGER 1
1590 +#define DOMAIN_KERNEXEC 3
1591 +#else
1592 +#define DOMAIN_MANAGER 1
1593 +#endif
1594 +
1595 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1596 +#define DOMAIN_USERCLIENT 0
1597 +#define DOMAIN_UDEREF 1
1598 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1599 +#else
1600 +#define DOMAIN_USERCLIENT 1
1601 +#define DOMAIN_VECTORS DOMAIN_USER
1602 +#endif
1603 +#define DOMAIN_KERNELCLIENT 1
1604 +
1605 #endif
1606
1607 #define domain_val(dom,type) ((type) << (2*(dom)))
1608
1609 #ifndef __ASSEMBLY__
1610
1611 -#ifdef CONFIG_CPU_USE_DOMAINS
1612 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1613 static inline void set_domain(unsigned val)
1614 {
1615 asm volatile(
1616 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1617 isb();
1618 }
1619
1620 -#define modify_domain(dom,type) \
1621 - do { \
1622 - struct thread_info *thread = current_thread_info(); \
1623 - unsigned int domain = thread->cpu_domain; \
1624 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1625 - thread->cpu_domain = domain | domain_val(dom, type); \
1626 - set_domain(thread->cpu_domain); \
1627 - } while (0)
1628 -
1629 +extern void modify_domain(unsigned int dom, unsigned int type);
1630 #else
1631 static inline void set_domain(unsigned val) { }
1632 static inline void modify_domain(unsigned dom, unsigned type) { }
1633 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1634 index 38050b1..9d90e8b 100644
1635 --- a/arch/arm/include/asm/elf.h
1636 +++ b/arch/arm/include/asm/elf.h
1637 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1638 the loader. We need to make sure that it is out of the way of the program
1639 that it will "exec", and that there is sufficient room for the brk. */
1640
1641 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1642 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1643 +
1644 +#ifdef CONFIG_PAX_ASLR
1645 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1646 +
1647 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1648 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1649 +#endif
1650
1651 /* When the program starts, a1 contains a pointer to a function to be
1652 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1653 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1654 extern void elf_set_personality(const struct elf32_hdr *);
1655 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1656
1657 -struct mm_struct;
1658 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1659 -#define arch_randomize_brk arch_randomize_brk
1660 -
1661 #endif
1662 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1663 index de53547..52b9a28 100644
1664 --- a/arch/arm/include/asm/fncpy.h
1665 +++ b/arch/arm/include/asm/fncpy.h
1666 @@ -81,7 +81,9 @@
1667 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1668 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1669 \
1670 + pax_open_kernel(); \
1671 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1672 + pax_close_kernel(); \
1673 flush_icache_range((unsigned long)(dest_buf), \
1674 (unsigned long)(dest_buf) + (size)); \
1675 \
1676 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1677 index e42cf59..7b94b8f 100644
1678 --- a/arch/arm/include/asm/futex.h
1679 +++ b/arch/arm/include/asm/futex.h
1680 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1681 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1682 return -EFAULT;
1683
1684 + pax_open_userland();
1685 +
1686 smp_mb();
1687 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1688 "1: ldrex %1, [%4]\n"
1689 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1690 : "cc", "memory");
1691 smp_mb();
1692
1693 + pax_close_userland();
1694 +
1695 *uval = val;
1696 return ret;
1697 }
1698 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1699 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1700 return -EFAULT;
1701
1702 + pax_open_userland();
1703 +
1704 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1705 "1: " TUSER(ldr) " %1, [%4]\n"
1706 " teq %1, %2\n"
1707 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1708 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1709 : "cc", "memory");
1710
1711 + pax_close_userland();
1712 +
1713 *uval = val;
1714 return ret;
1715 }
1716 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1717 return -EFAULT;
1718
1719 pagefault_disable(); /* implies preempt_disable() */
1720 + pax_open_userland();
1721
1722 switch (op) {
1723 case FUTEX_OP_SET:
1724 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1725 ret = -ENOSYS;
1726 }
1727
1728 + pax_close_userland();
1729 pagefault_enable(); /* subsumes preempt_enable() */
1730
1731 if (!ret) {
1732 diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h
1733 index 4b1ce6c..bea3f73 100644
1734 --- a/arch/arm/include/asm/hardware/gic.h
1735 +++ b/arch/arm/include/asm/hardware/gic.h
1736 @@ -34,9 +34,10 @@
1737
1738 #ifndef __ASSEMBLY__
1739 #include <linux/irqdomain.h>
1740 +#include <linux/irq.h>
1741 struct device_node;
1742
1743 -extern struct irq_chip gic_arch_extn;
1744 +extern irq_chip_no_const gic_arch_extn;
1745
1746 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
1747 u32 offset, struct device_node *);
1748 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1749 index 83eb2f7..ed77159 100644
1750 --- a/arch/arm/include/asm/kmap_types.h
1751 +++ b/arch/arm/include/asm/kmap_types.h
1752 @@ -4,6 +4,6 @@
1753 /*
1754 * This is the "bare minimum". AIO seems to require this.
1755 */
1756 -#define KM_TYPE_NR 16
1757 +#define KM_TYPE_NR 17
1758
1759 #endif
1760 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1761 index 9e614a1..3302cca 100644
1762 --- a/arch/arm/include/asm/mach/dma.h
1763 +++ b/arch/arm/include/asm/mach/dma.h
1764 @@ -22,7 +22,7 @@ struct dma_ops {
1765 int (*residue)(unsigned int, dma_t *); /* optional */
1766 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1767 const char *type;
1768 -};
1769 +} __do_const;
1770
1771 struct dma_struct {
1772 void *addr; /* single DMA address */
1773 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1774 index 2fe141f..192dc01 100644
1775 --- a/arch/arm/include/asm/mach/map.h
1776 +++ b/arch/arm/include/asm/mach/map.h
1777 @@ -27,13 +27,16 @@ struct map_desc {
1778 #define MT_MINICLEAN 6
1779 #define MT_LOW_VECTORS 7
1780 #define MT_HIGH_VECTORS 8
1781 -#define MT_MEMORY 9
1782 +#define MT_MEMORY_RWX 9
1783 #define MT_ROM 10
1784 -#define MT_MEMORY_NONCACHED 11
1785 +#define MT_MEMORY_NONCACHED_RX 11
1786 #define MT_MEMORY_DTCM 12
1787 #define MT_MEMORY_ITCM 13
1788 #define MT_MEMORY_SO 14
1789 #define MT_MEMORY_DMA_READY 15
1790 +#define MT_MEMORY_RW 16
1791 +#define MT_MEMORY_RX 17
1792 +#define MT_MEMORY_NONCACHED_RW 18
1793
1794 #ifdef CONFIG_MMU
1795 extern void iotable_init(struct map_desc *, int);
1796 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1797 index 53426c6..c7baff3 100644
1798 --- a/arch/arm/include/asm/outercache.h
1799 +++ b/arch/arm/include/asm/outercache.h
1800 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1801 #endif
1802 void (*set_debug)(unsigned long);
1803 void (*resume)(void);
1804 -};
1805 +} __no_const;
1806
1807 #ifdef CONFIG_OUTER_CACHE
1808
1809 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1810 index 812a494..71fc0b6 100644
1811 --- a/arch/arm/include/asm/page.h
1812 +++ b/arch/arm/include/asm/page.h
1813 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1814 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1815 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1816 unsigned long vaddr, struct vm_area_struct *vma);
1817 -};
1818 +} __no_const;
1819
1820 #ifdef MULTI_USER
1821 extern struct cpu_user_fns cpu_user;
1822 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1823 index 943504f..c37a730 100644
1824 --- a/arch/arm/include/asm/pgalloc.h
1825 +++ b/arch/arm/include/asm/pgalloc.h
1826 @@ -17,6 +17,7 @@
1827 #include <asm/processor.h>
1828 #include <asm/cacheflush.h>
1829 #include <asm/tlbflush.h>
1830 +#include <asm/system_info.h>
1831
1832 #define check_pgt_cache() do { } while (0)
1833
1834 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1835 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1836 }
1837
1838 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1839 +{
1840 + pud_populate(mm, pud, pmd);
1841 +}
1842 +
1843 #else /* !CONFIG_ARM_LPAE */
1844
1845 /*
1846 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1847 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1848 #define pmd_free(mm, pmd) do { } while (0)
1849 #define pud_populate(mm,pmd,pte) BUG()
1850 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1851
1852 #endif /* CONFIG_ARM_LPAE */
1853
1854 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1855 __free_page(pte);
1856 }
1857
1858 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1859 +{
1860 +#ifdef CONFIG_ARM_LPAE
1861 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1862 +#else
1863 + if (addr & SECTION_SIZE)
1864 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1865 + else
1866 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1867 +#endif
1868 + flush_pmd_entry(pmdp);
1869 +}
1870 +
1871 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1872 pmdval_t prot)
1873 {
1874 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1875 static inline void
1876 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1877 {
1878 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1879 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1880 }
1881 #define pmd_pgtable(pmd) pmd_page(pmd)
1882
1883 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 index 5cfba15..f415e1a 100644
1885 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1886 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1887 @@ -20,12 +20,15 @@
1888 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1889 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1890 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1891 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1892 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1893 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1894 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1895 +
1896 /*
1897 * - section
1898 */
1899 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1900 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1901 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1902 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1903 @@ -37,6 +40,7 @@
1904 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1905 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1906 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1907 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1908
1909 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1910 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1911 @@ -66,6 +70,7 @@
1912 * - extended small page/tiny page
1913 */
1914 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1915 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1916 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1917 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1918 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1919 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1920 index f97ee02..07f1be5 100644
1921 --- a/arch/arm/include/asm/pgtable-2level.h
1922 +++ b/arch/arm/include/asm/pgtable-2level.h
1923 @@ -125,6 +125,7 @@
1924 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1925 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1926 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1927 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1928
1929 /*
1930 * These are the memory types, defined to be compatible with
1931 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1932 index d795282..a43ea90 100644
1933 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1935 @@ -32,15 +32,18 @@
1936 #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0)
1937 #define PMD_BIT4 (_AT(pmdval_t, 0))
1938 #define PMD_DOMAIN(x) (_AT(pmdval_t, 0))
1939 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 59) /* PXNTable */
1940
1941 /*
1942 * - section
1943 */
1944 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1945 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1946 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1947 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1948 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1949 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1950 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
1951 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54)
1952 #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0))
1953 #define PMD_SECT_AP_READ (_AT(pmdval_t, 0))
1954 @@ -66,6 +69,7 @@
1955 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1956 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1957 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1958 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1959 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1960
1961 /*
1962 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1963 index a3f3792..7b932a6 100644
1964 --- a/arch/arm/include/asm/pgtable-3level.h
1965 +++ b/arch/arm/include/asm/pgtable-3level.h
1966 @@ -74,6 +74,7 @@
1967 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1968 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1969 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1970 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1971 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1972 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1973 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1974 @@ -82,6 +83,7 @@
1975 /*
1976 * To be used in assembly code with the upper page attributes.
1977 */
1978 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1979 #define L_PTE_XN_HIGH (1 << (54 - 32))
1980 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1981
1982 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1983 index c094749..a6ff605 100644
1984 --- a/arch/arm/include/asm/pgtable.h
1985 +++ b/arch/arm/include/asm/pgtable.h
1986 @@ -30,6 +30,9 @@
1987 #include <asm/pgtable-2level.h>
1988 #endif
1989
1990 +#define ktla_ktva(addr) (addr)
1991 +#define ktva_ktla(addr) (addr)
1992 +
1993 /*
1994 * Just any arbitrary offset to the start of the vmalloc VM area: the
1995 * current 8MB value just means that there will be a 8MB "hole" after the
1996 @@ -45,6 +48,9 @@
1997 #define LIBRARY_TEXT_START 0x0c000000
1998
1999 #ifndef __ASSEMBLY__
2000 +extern pteval_t __supported_pte_mask;
2001 +extern pmdval_t __supported_pmd_mask;
2002 +
2003 extern void __pte_error(const char *file, int line, pte_t);
2004 extern void __pmd_error(const char *file, int line, pmd_t);
2005 extern void __pgd_error(const char *file, int line, pgd_t);
2006 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2007 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2008 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2009
2010 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2011 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2012 +
2013 +#ifdef CONFIG_PAX_KERNEXEC
2014 +#include <asm/domain.h>
2015 +#include <linux/thread_info.h>
2016 +#include <linux/preempt.h>
2017 +#endif
2018 +
2019 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2020 +static inline int test_domain(int domain, int domaintype)
2021 +{
2022 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2023 +}
2024 +#endif
2025 +
2026 +#ifdef CONFIG_PAX_KERNEXEC
2027 +static inline unsigned long pax_open_kernel(void) {
2028 +#ifdef CONFIG_ARM_LPAE
2029 + /* TODO */
2030 +#else
2031 + preempt_disable();
2032 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2033 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2034 +#endif
2035 + return 0;
2036 +}
2037 +
2038 +static inline unsigned long pax_close_kernel(void) {
2039 +#ifdef CONFIG_ARM_LPAE
2040 + /* TODO */
2041 +#else
2042 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2043 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2044 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2045 + preempt_enable_no_resched();
2046 +#endif
2047 + return 0;
2048 +}
2049 +#else
2050 +static inline unsigned long pax_open_kernel(void) { return 0; }
2051 +static inline unsigned long pax_close_kernel(void) { return 0; }
2052 +#endif
2053 +
2054 /*
2055 * This is the lowest virtual address we can permit any user space
2056 * mapping to be mapped at. This is particularly important for
2057 @@ -63,8 +113,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2058 /*
2059 * The pgprot_* and protection_map entries will be fixed up in runtime
2060 * to include the cachable and bufferable bits based on memory policy,
2061 - * as well as any architecture dependent bits like global/ASID and SMP
2062 - * shared mapping bits.
2063 + * as well as any architecture dependent bits like global/ASID, PXN,
2064 + * and SMP shared mapping bits.
2065 */
2066 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2067
2068 @@ -241,7 +291,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2069 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2070 {
2071 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2072 - L_PTE_NONE | L_PTE_VALID;
2073 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2074 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2075 return pte;
2076 }
2077 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2078 index f3628fb..a0672dd 100644
2079 --- a/arch/arm/include/asm/proc-fns.h
2080 +++ b/arch/arm/include/asm/proc-fns.h
2081 @@ -75,7 +75,7 @@ extern struct processor {
2082 unsigned int suspend_size;
2083 void (*do_suspend)(void *);
2084 void (*do_resume)(void *);
2085 -} processor;
2086 +} __do_const processor;
2087
2088 #ifndef MULTI_CPU
2089 extern void cpu_proc_init(void);
2090 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2091 index 06e7d50..8a8e251 100644
2092 --- a/arch/arm/include/asm/processor.h
2093 +++ b/arch/arm/include/asm/processor.h
2094 @@ -65,9 +65,8 @@ struct thread_struct {
2095 regs->ARM_cpsr |= PSR_ENDSTATE; \
2096 regs->ARM_pc = pc & ~1; /* pc */ \
2097 regs->ARM_sp = sp; /* sp */ \
2098 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2099 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2100 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2101 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2102 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2103 nommu_start_thread(regs); \
2104 })
2105
2106 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2107 index d3a22be..3a69ad5 100644
2108 --- a/arch/arm/include/asm/smp.h
2109 +++ b/arch/arm/include/asm/smp.h
2110 @@ -107,7 +107,7 @@ struct smp_operations {
2111 int (*cpu_disable)(unsigned int cpu);
2112 #endif
2113 #endif
2114 -};
2115 +} __no_const;
2116
2117 /*
2118 * set platform specific SMP operations
2119 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2120 index cddda1f..ff357f7 100644
2121 --- a/arch/arm/include/asm/thread_info.h
2122 +++ b/arch/arm/include/asm/thread_info.h
2123 @@ -77,9 +77,9 @@ struct thread_info {
2124 .flags = 0, \
2125 .preempt_count = INIT_PREEMPT_COUNT, \
2126 .addr_limit = KERNEL_DS, \
2127 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2128 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2129 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2130 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2131 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2132 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2133 .restart_block = { \
2134 .fn = do_no_restart_syscall, \
2135 }, \
2136 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2137 #define TIF_SYSCALL_AUDIT 9
2138 #define TIF_SYSCALL_TRACEPOINT 10
2139 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2140 +
2141 +/* within 8 bits of TIF_SYSCALL_TRACE
2142 + * to meet flexible second operand requirements
2143 + */
2144 +#define TIF_GRSEC_SETXID 12
2145 +
2146 #define TIF_USING_IWMMXT 17
2147 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2148 #define TIF_RESTORE_SIGMASK 20
2149 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2150 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2151 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2152 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2153 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2154
2155 /* Checks for any syscall work in entry-common.S */
2156 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2157 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2158 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2159
2160 /*
2161 * Change these and you break ASM code in entry-common.S
2162 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2163 index 7e1f760..752fcb7 100644
2164 --- a/arch/arm/include/asm/uaccess.h
2165 +++ b/arch/arm/include/asm/uaccess.h
2166 @@ -18,6 +18,7 @@
2167 #include <asm/domain.h>
2168 #include <asm/unified.h>
2169 #include <asm/compiler.h>
2170 +#include <asm/pgtable.h>
2171
2172 #define VERIFY_READ 0
2173 #define VERIFY_WRITE 1
2174 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2175 #define USER_DS TASK_SIZE
2176 #define get_fs() (current_thread_info()->addr_limit)
2177
2178 +static inline void pax_open_userland(void)
2179 +{
2180 +
2181 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2182 + if (get_fs() == USER_DS) {
2183 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2184 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2185 + }
2186 +#endif
2187 +
2188 +}
2189 +
2190 +static inline void pax_close_userland(void)
2191 +{
2192 +
2193 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2194 + if (get_fs() == USER_DS) {
2195 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2196 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2197 + }
2198 +#endif
2199 +
2200 +}
2201 +
2202 static inline void set_fs(mm_segment_t fs)
2203 {
2204 current_thread_info()->addr_limit = fs;
2205 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2206 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2207 }
2208
2209 #define segment_eq(a,b) ((a) == (b))
2210 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2211
2212 #define get_user(x,p) \
2213 ({ \
2214 + int __e; \
2215 might_fault(); \
2216 - __get_user_check(x,p); \
2217 + pax_open_userland(); \
2218 + __e = __get_user_check(x,p); \
2219 + pax_close_userland(); \
2220 + __e; \
2221 })
2222
2223 extern int __put_user_1(void *, unsigned int);
2224 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2225
2226 #define put_user(x,p) \
2227 ({ \
2228 + int __e; \
2229 might_fault(); \
2230 - __put_user_check(x,p); \
2231 + pax_open_userland(); \
2232 + __e = __put_user_check(x,p); \
2233 + pax_close_userland(); \
2234 + __e; \
2235 })
2236
2237 #else /* CONFIG_MMU */
2238 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2239 #define __get_user(x,ptr) \
2240 ({ \
2241 long __gu_err = 0; \
2242 + pax_open_userland(); \
2243 __get_user_err((x),(ptr),__gu_err); \
2244 + pax_close_userland(); \
2245 __gu_err; \
2246 })
2247
2248 #define __get_user_error(x,ptr,err) \
2249 ({ \
2250 + pax_open_userland(); \
2251 __get_user_err((x),(ptr),err); \
2252 + pax_close_userland(); \
2253 (void) 0; \
2254 })
2255
2256 @@ -312,13 +349,17 @@ do { \
2257 #define __put_user(x,ptr) \
2258 ({ \
2259 long __pu_err = 0; \
2260 + pax_open_userland(); \
2261 __put_user_err((x),(ptr),__pu_err); \
2262 + pax_close_userland(); \
2263 __pu_err; \
2264 })
2265
2266 #define __put_user_error(x,ptr,err) \
2267 ({ \
2268 + pax_open_userland(); \
2269 __put_user_err((x),(ptr),err); \
2270 + pax_close_userland(); \
2271 (void) 0; \
2272 })
2273
2274 @@ -418,11 +459,44 @@ do { \
2275
2276
2277 #ifdef CONFIG_MMU
2278 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2279 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2280 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2281 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2282 +
2283 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2284 +{
2285 + unsigned long ret;
2286 +
2287 + check_object_size(to, n, false);
2288 + pax_open_userland();
2289 + ret = ___copy_from_user(to, from, n);
2290 + pax_close_userland();
2291 + return ret;
2292 +}
2293 +
2294 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2295 +{
2296 + unsigned long ret;
2297 +
2298 + check_object_size(from, n, true);
2299 + pax_open_userland();
2300 + ret = ___copy_to_user(to, from, n);
2301 + pax_close_userland();
2302 + return ret;
2303 +}
2304 +
2305 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2306 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2307 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2308 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2309 +
2310 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2311 +{
2312 + unsigned long ret;
2313 + pax_open_userland();
2314 + ret = ___clear_user(addr, n);
2315 + pax_close_userland();
2316 + return ret;
2317 +}
2318 +
2319 #else
2320 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2321 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2322 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2323
2324 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2325 {
2326 + if ((long)n < 0)
2327 + return n;
2328 +
2329 if (access_ok(VERIFY_READ, from, n))
2330 n = __copy_from_user(to, from, n);
2331 else /* security hole - plug it */
2332 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2333
2334 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2335 {
2336 + if ((long)n < 0)
2337 + return n;
2338 +
2339 if (access_ok(VERIFY_WRITE, to, n))
2340 n = __copy_to_user(to, from, n);
2341 return n;
2342 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2343 index 96ee092..37f1844 100644
2344 --- a/arch/arm/include/uapi/asm/ptrace.h
2345 +++ b/arch/arm/include/uapi/asm/ptrace.h
2346 @@ -73,7 +73,7 @@
2347 * ARMv7 groups of PSR bits
2348 */
2349 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2350 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2351 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2352 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2353 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2354
2355 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2356 index 60d3b73..d27ee09 100644
2357 --- a/arch/arm/kernel/armksyms.c
2358 +++ b/arch/arm/kernel/armksyms.c
2359 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2360 #ifdef CONFIG_MMU
2361 EXPORT_SYMBOL(copy_page);
2362
2363 -EXPORT_SYMBOL(__copy_from_user);
2364 -EXPORT_SYMBOL(__copy_to_user);
2365 -EXPORT_SYMBOL(__clear_user);
2366 +EXPORT_SYMBOL(___copy_from_user);
2367 +EXPORT_SYMBOL(___copy_to_user);
2368 +EXPORT_SYMBOL(___clear_user);
2369
2370 EXPORT_SYMBOL(__get_user_1);
2371 EXPORT_SYMBOL(__get_user_2);
2372 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2373 index 0f82098..3dbd3ee 100644
2374 --- a/arch/arm/kernel/entry-armv.S
2375 +++ b/arch/arm/kernel/entry-armv.S
2376 @@ -47,6 +47,87 @@
2377 9997:
2378 .endm
2379
2380 + .macro pax_enter_kernel
2381 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2382 + @ make aligned space for saved DACR
2383 + sub sp, sp, #8
2384 + @ save regs
2385 + stmdb sp!, {r1, r2}
2386 + @ read DACR from cpu_domain into r1
2387 + mov r2, sp
2388 + @ assume 8K pages, since we have to split the immediate in two
2389 + bic r2, r2, #(0x1fc0)
2390 + bic r2, r2, #(0x3f)
2391 + ldr r1, [r2, #TI_CPU_DOMAIN]
2392 + @ store old DACR on stack
2393 + str r1, [sp, #8]
2394 +#ifdef CONFIG_PAX_KERNEXEC
2395 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2396 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2397 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2398 +#endif
2399 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2400 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2401 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2402 +#endif
2403 + @ write r1 to current_thread_info()->cpu_domain
2404 + str r1, [r2, #TI_CPU_DOMAIN]
2405 + @ write r1 to DACR
2406 + mcr p15, 0, r1, c3, c0, 0
2407 + @ instruction sync
2408 + instr_sync
2409 + @ restore regs
2410 + ldmia sp!, {r1, r2}
2411 +#endif
2412 + .endm
2413 +
2414 + .macro pax_open_userland
2415 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2416 + @ save regs
2417 + stmdb sp!, {r0, r1}
2418 + @ read DACR from cpu_domain into r1
2419 + mov r0, sp
2420 + @ assume 8K pages, since we have to split the immediate in two
2421 + bic r0, r0, #(0x1fc0)
2422 + bic r0, r0, #(0x3f)
2423 + ldr r1, [r0, #TI_CPU_DOMAIN]
2424 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2425 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2426 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2427 + @ write r1 to current_thread_info()->cpu_domain
2428 + str r1, [r0, #TI_CPU_DOMAIN]
2429 + @ write r1 to DACR
2430 + mcr p15, 0, r1, c3, c0, 0
2431 + @ instruction sync
2432 + instr_sync
2433 + @ restore regs
2434 + ldmia sp!, {r0, r1}
2435 +#endif
2436 + .endm
2437 +
2438 + .macro pax_close_userland
2439 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2440 + @ save regs
2441 + stmdb sp!, {r0, r1}
2442 + @ read DACR from cpu_domain into r1
2443 + mov r0, sp
2444 + @ assume 8K pages, since we have to split the immediate in two
2445 + bic r0, r0, #(0x1fc0)
2446 + bic r0, r0, #(0x3f)
2447 + ldr r1, [r0, #TI_CPU_DOMAIN]
2448 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2449 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2450 + @ write r1 to current_thread_info()->cpu_domain
2451 + str r1, [r0, #TI_CPU_DOMAIN]
2452 + @ write r1 to DACR
2453 + mcr p15, 0, r1, c3, c0, 0
2454 + @ instruction sync
2455 + instr_sync
2456 + @ restore regs
2457 + ldmia sp!, {r0, r1}
2458 +#endif
2459 + .endm
2460 +
2461 .macro pabt_helper
2462 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2463 #ifdef MULTI_PABORT
2464 @@ -89,11 +170,15 @@
2465 * Invalid mode handlers
2466 */
2467 .macro inv_entry, reason
2468 +
2469 + pax_enter_kernel
2470 +
2471 sub sp, sp, #S_FRAME_SIZE
2472 ARM( stmib sp, {r1 - lr} )
2473 THUMB( stmia sp, {r0 - r12} )
2474 THUMB( str sp, [sp, #S_SP] )
2475 THUMB( str lr, [sp, #S_LR] )
2476 +
2477 mov r1, #\reason
2478 .endm
2479
2480 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2481 .macro svc_entry, stack_hole=0
2482 UNWIND(.fnstart )
2483 UNWIND(.save {r0 - pc} )
2484 +
2485 + pax_enter_kernel
2486 +
2487 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2488 +
2489 #ifdef CONFIG_THUMB2_KERNEL
2490 SPFIX( str r0, [sp] ) @ temporarily saved
2491 SPFIX( mov r0, sp )
2492 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2493 ldmia r0, {r3 - r5}
2494 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2495 mov r6, #-1 @ "" "" "" ""
2496 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2497 + @ offset sp by 8 as done in pax_enter_kernel
2498 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2499 +#else
2500 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2501 +#endif
2502 SPFIX( addeq r2, r2, #4 )
2503 str r3, [sp, #-4]! @ save the "real" r0 copied
2504 @ from the exception stack
2505 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2506 .macro usr_entry
2507 UNWIND(.fnstart )
2508 UNWIND(.cantunwind ) @ don't unwind the user space
2509 +
2510 + pax_enter_kernel_user
2511 +
2512 sub sp, sp, #S_FRAME_SIZE
2513 ARM( stmib sp, {r1 - r12} )
2514 THUMB( stmia sp, {r0 - r12} )
2515 @@ -456,7 +553,9 @@ __und_usr:
2516 tst r3, #PSR_T_BIT @ Thumb mode?
2517 bne __und_usr_thumb
2518 sub r4, r2, #4 @ ARM instr at LR - 4
2519 + pax_open_userland
2520 1: ldrt r0, [r4]
2521 + pax_close_userland
2522 #ifdef CONFIG_CPU_ENDIAN_BE8
2523 rev r0, r0 @ little endian instruction
2524 #endif
2525 @@ -491,10 +590,14 @@ __und_usr_thumb:
2526 */
2527 .arch armv6t2
2528 #endif
2529 + pax_open_userland
2530 2: ldrht r5, [r4]
2531 + pax_close_userland
2532 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2533 blo __und_usr_fault_16 @ 16bit undefined instruction
2534 + pax_open_userland
2535 3: ldrht r0, [r2]
2536 + pax_close_userland
2537 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2538 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2539 orr r0, r0, r5, lsl #16
2540 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2541 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2542 THUMB( str sp, [ip], #4 )
2543 THUMB( str lr, [ip], #4 )
2544 -#ifdef CONFIG_CPU_USE_DOMAINS
2545 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2546 ldr r6, [r2, #TI_CPU_DOMAIN]
2547 #endif
2548 set_tls r3, r4, r5
2549 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2550 ldr r8, =__stack_chk_guard
2551 ldr r7, [r7, #TSK_STACK_CANARY]
2552 #endif
2553 -#ifdef CONFIG_CPU_USE_DOMAINS
2554 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2555 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2556 #endif
2557 mov r5, r0
2558 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2559 index a6c301e..908821b 100644
2560 --- a/arch/arm/kernel/entry-common.S
2561 +++ b/arch/arm/kernel/entry-common.S
2562 @@ -10,18 +10,46 @@
2563
2564 #include <asm/unistd.h>
2565 #include <asm/ftrace.h>
2566 +#include <asm/domain.h>
2567 #include <asm/unwind.h>
2568
2569 +#include "entry-header.S"
2570 +
2571 #ifdef CONFIG_NEED_RET_TO_USER
2572 #include <mach/entry-macro.S>
2573 #else
2574 .macro arch_ret_to_user, tmp1, tmp2
2575 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2576 + @ save regs
2577 + stmdb sp!, {r1, r2}
2578 + @ read DACR from cpu_domain into r1
2579 + mov r2, sp
2580 + @ assume 8K pages, since we have to split the immediate in two
2581 + bic r2, r2, #(0x1fc0)
2582 + bic r2, r2, #(0x3f)
2583 + ldr r1, [r2, #TI_CPU_DOMAIN]
2584 +#ifdef CONFIG_PAX_KERNEXEC
2585 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2586 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2587 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2588 +#endif
2589 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2590 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2591 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2592 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2593 +#endif
2594 + @ write r1 to current_thread_info()->cpu_domain
2595 + str r1, [r2, #TI_CPU_DOMAIN]
2596 + @ write r1 to DACR
2597 + mcr p15, 0, r1, c3, c0, 0
2598 + @ instruction sync
2599 + instr_sync
2600 + @ restore regs
2601 + ldmia sp!, {r1, r2}
2602 +#endif
2603 .endm
2604 #endif
2605
2606 -#include "entry-header.S"
2607 -
2608 -
2609 .align 5
2610 /*
2611 * This is the fast syscall return path. We do as little as
2612 @@ -339,6 +367,7 @@ ENDPROC(ftrace_stub)
2613
2614 .align 5
2615 ENTRY(vector_swi)
2616 +
2617 sub sp, sp, #S_FRAME_SIZE
2618 stmia sp, {r0 - r12} @ Calling r0 - r12
2619 ARM( add r8, sp, #S_PC )
2620 @@ -388,6 +417,12 @@ ENTRY(vector_swi)
2621 ldr scno, [lr, #-4] @ get SWI instruction
2622 #endif
2623
2624 + /*
2625 + * do this here to avoid a performance hit of wrapping the code above
2626 + * that directly dereferences userland to parse the SWI instruction
2627 + */
2628 + pax_enter_kernel_user
2629 +
2630 #ifdef CONFIG_ALIGNMENT_TRAP
2631 ldr ip, __cr_alignment
2632 ldr ip, [ip]
2633 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2634 index 9a8531e..812e287 100644
2635 --- a/arch/arm/kernel/entry-header.S
2636 +++ b/arch/arm/kernel/entry-header.S
2637 @@ -73,9 +73,66 @@
2638 msr cpsr_c, \rtemp @ switch back to the SVC mode
2639 .endm
2640
2641 + .macro pax_enter_kernel_user
2642 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2643 + @ save regs
2644 + stmdb sp!, {r0, r1}
2645 + @ read DACR from cpu_domain into r1
2646 + mov r0, sp
2647 + @ assume 8K pages, since we have to split the immediate in two
2648 + bic r0, r0, #(0x1fc0)
2649 + bic r0, r0, #(0x3f)
2650 + ldr r1, [r0, #TI_CPU_DOMAIN]
2651 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2652 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2653 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2654 +#endif
2655 +#ifdef CONFIG_PAX_KERNEXEC
2656 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2657 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2658 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2659 +#endif
2660 + @ write r1 to current_thread_info()->cpu_domain
2661 + str r1, [r0, #TI_CPU_DOMAIN]
2662 + @ write r1 to DACR
2663 + mcr p15, 0, r1, c3, c0, 0
2664 + @ instruction sync
2665 + instr_sync
2666 + @ restore regs
2667 + ldmia sp!, {r0, r1}
2668 +#endif
2669 + .endm
2670 +
2671 + .macro pax_exit_kernel
2672 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2673 + @ save regs
2674 + stmdb sp!, {r0, r1}
2675 + @ read old DACR from stack into r1
2676 + ldr r1, [sp, #(8 + S_SP)]
2677 + sub r1, r1, #8
2678 + ldr r1, [r1]
2679 +
2680 + @ write r1 to current_thread_info()->cpu_domain
2681 + mov r0, sp
2682 + @ assume 8K pages, since we have to split the immediate in two
2683 + bic r0, r0, #(0x1fc0)
2684 + bic r0, r0, #(0x3f)
2685 + str r1, [r0, #TI_CPU_DOMAIN]
2686 + @ write r1 to DACR
2687 + mcr p15, 0, r1, c3, c0, 0
2688 + @ instruction sync
2689 + instr_sync
2690 + @ restore regs
2691 + ldmia sp!, {r0, r1}
2692 +#endif
2693 + .endm
2694 +
2695 #ifndef CONFIG_THUMB2_KERNEL
2696 .macro svc_exit, rpsr
2697 msr spsr_cxsf, \rpsr
2698 +
2699 + pax_exit_kernel
2700 +
2701 #if defined(CONFIG_CPU_V6)
2702 ldr r0, [sp]
2703 strex r1, r2, [sp] @ clear the exclusive monitor
2704 @@ -121,6 +178,9 @@
2705 .endm
2706 #else /* CONFIG_THUMB2_KERNEL */
2707 .macro svc_exit, rpsr
2708 +
2709 + pax_exit_kernel
2710 +
2711 ldr lr, [sp, #S_SP] @ top of the stack
2712 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2713 clrex @ clear the exclusive monitor
2714 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2715 index 2adda11..7fbe958 100644
2716 --- a/arch/arm/kernel/fiq.c
2717 +++ b/arch/arm/kernel/fiq.c
2718 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2719 #if defined(CONFIG_CPU_USE_DOMAINS)
2720 memcpy((void *)0xffff001c, start, length);
2721 #else
2722 + pax_open_kernel();
2723 memcpy(vectors_page + 0x1c, start, length);
2724 + pax_close_kernel();
2725 #endif
2726 flush_icache_range(0xffff001c, 0xffff001c + length);
2727 if (!vectors_high())
2728 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2729 index e0eb9a1..c7d74a3 100644
2730 --- a/arch/arm/kernel/head.S
2731 +++ b/arch/arm/kernel/head.S
2732 @@ -52,7 +52,9 @@
2733 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2734
2735 .macro pgtbl, rd, phys
2736 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2737 + mov \rd, #TEXT_OFFSET
2738 + sub \rd, #PG_DIR_SIZE
2739 + add \rd, \rd, \phys
2740 .endm
2741
2742 /*
2743 @@ -434,7 +436,7 @@ __enable_mmu:
2744 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2745 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2746 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2747 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2748 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2749 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2750 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2751 #endif
2752 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2753 index 5ff2e77..556d030 100644
2754 --- a/arch/arm/kernel/hw_breakpoint.c
2755 +++ b/arch/arm/kernel/hw_breakpoint.c
2756 @@ -1011,7 +1011,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2757 return NOTIFY_OK;
2758 }
2759
2760 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2761 +static struct notifier_block dbg_reset_nb = {
2762 .notifier_call = dbg_reset_notify,
2763 };
2764
2765 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2766 index 1e9be5d..03edbc2 100644
2767 --- a/arch/arm/kernel/module.c
2768 +++ b/arch/arm/kernel/module.c
2769 @@ -37,12 +37,37 @@
2770 #endif
2771
2772 #ifdef CONFIG_MMU
2773 -void *module_alloc(unsigned long size)
2774 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2775 {
2776 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2777 + return NULL;
2778 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2779 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2780 + GFP_KERNEL, prot, -1,
2781 __builtin_return_address(0));
2782 }
2783 +
2784 +void *module_alloc(unsigned long size)
2785 +{
2786 +
2787 +#ifdef CONFIG_PAX_KERNEXEC
2788 + return __module_alloc(size, PAGE_KERNEL);
2789 +#else
2790 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2791 +#endif
2792 +
2793 +}
2794 +
2795 +#ifdef CONFIG_PAX_KERNEXEC
2796 +void module_free_exec(struct module *mod, void *module_region)
2797 +{
2798 + module_free(mod, module_region);
2799 +}
2800 +
2801 +void *module_alloc_exec(unsigned long size)
2802 +{
2803 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2804 +}
2805 +#endif
2806 #endif
2807
2808 int
2809 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2810 index 07314af..c46655c 100644
2811 --- a/arch/arm/kernel/patch.c
2812 +++ b/arch/arm/kernel/patch.c
2813 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2814 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2815 int size;
2816
2817 + pax_open_kernel();
2818 if (thumb2 && __opcode_is_thumb16(insn)) {
2819 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2820 size = sizeof(u16);
2821 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2822 *(u32 *)addr = insn;
2823 size = sizeof(u32);
2824 }
2825 + pax_close_kernel();
2826
2827 flush_icache_range((uintptr_t)(addr),
2828 (uintptr_t)(addr) + size);
2829 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2830 index 5f66206..dce492f 100644
2831 --- a/arch/arm/kernel/perf_event_cpu.c
2832 +++ b/arch/arm/kernel/perf_event_cpu.c
2833 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2834 return NOTIFY_OK;
2835 }
2836
2837 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2838 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2839 .notifier_call = cpu_pmu_notify,
2840 };
2841
2842 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2843 index c6dec5f..e0fddd1 100644
2844 --- a/arch/arm/kernel/process.c
2845 +++ b/arch/arm/kernel/process.c
2846 @@ -28,7 +28,6 @@
2847 #include <linux/tick.h>
2848 #include <linux/utsname.h>
2849 #include <linux/uaccess.h>
2850 -#include <linux/random.h>
2851 #include <linux/hw_breakpoint.h>
2852 #include <linux/cpuidle.h>
2853 #include <linux/leds.h>
2854 @@ -256,9 +255,10 @@ void machine_power_off(void)
2855 machine_shutdown();
2856 if (pm_power_off)
2857 pm_power_off();
2858 + BUG();
2859 }
2860
2861 -void machine_restart(char *cmd)
2862 +__noreturn void machine_restart(char *cmd)
2863 {
2864 machine_shutdown();
2865
2866 @@ -283,8 +283,8 @@ void __show_regs(struct pt_regs *regs)
2867 init_utsname()->release,
2868 (int)strcspn(init_utsname()->version, " "),
2869 init_utsname()->version);
2870 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2871 - print_symbol("LR is at %s\n", regs->ARM_lr);
2872 + printk("PC is at %pA\n", instruction_pointer(regs));
2873 + printk("LR is at %pA\n", regs->ARM_lr);
2874 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2875 "sp : %08lx ip : %08lx fp : %08lx\n",
2876 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2877 @@ -452,12 +452,6 @@ unsigned long get_wchan(struct task_struct *p)
2878 return 0;
2879 }
2880
2881 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2882 -{
2883 - unsigned long range_end = mm->brk + 0x02000000;
2884 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2885 -}
2886 -
2887 #ifdef CONFIG_MMU
2888 /*
2889 * The vectors page is always readable from user space for the
2890 @@ -470,9 +464,8 @@ static int __init gate_vma_init(void)
2891 {
2892 gate_vma.vm_start = 0xffff0000;
2893 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2894 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2895 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2896 - VM_MAYREAD | VM_MAYEXEC;
2897 + gate_vma.vm_flags = VM_NONE;
2898 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2899 return 0;
2900 }
2901 arch_initcall(gate_vma_init);
2902 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2903 index 03deeff..741ce88 100644
2904 --- a/arch/arm/kernel/ptrace.c
2905 +++ b/arch/arm/kernel/ptrace.c
2906 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2907 return current_thread_info()->syscall;
2908 }
2909
2910 +#ifdef CONFIG_GRKERNSEC_SETXID
2911 +extern void gr_delayed_cred_worker(void);
2912 +#endif
2913 +
2914 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2915 {
2916 current_thread_info()->syscall = scno;
2917
2918 +#ifdef CONFIG_GRKERNSEC_SETXID
2919 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2920 + gr_delayed_cred_worker();
2921 +#endif
2922 +
2923 /* Do the secure computing check first; failures should be fast. */
2924 if (secure_computing(scno) == -1)
2925 return -1;
2926 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2927 index 3f6cbb2..6d856f5 100644
2928 --- a/arch/arm/kernel/setup.c
2929 +++ b/arch/arm/kernel/setup.c
2930 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
2931 unsigned int elf_hwcap __read_mostly;
2932 EXPORT_SYMBOL(elf_hwcap);
2933
2934 +pteval_t __supported_pte_mask __read_only;
2935 +pmdval_t __supported_pmd_mask __read_only;
2936
2937 #ifdef MULTI_CPU
2938 -struct processor processor __read_mostly;
2939 +struct processor processor;
2940 #endif
2941 #ifdef MULTI_TLB
2942 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2943 +struct cpu_tlb_fns cpu_tlb __read_only;
2944 #endif
2945 #ifdef MULTI_USER
2946 -struct cpu_user_fns cpu_user __read_mostly;
2947 +struct cpu_user_fns cpu_user __read_only;
2948 #endif
2949 #ifdef MULTI_CACHE
2950 -struct cpu_cache_fns cpu_cache __read_mostly;
2951 +struct cpu_cache_fns cpu_cache __read_only;
2952 #endif
2953 #ifdef CONFIG_OUTER_CACHE
2954 -struct outer_cache_fns outer_cache __read_mostly;
2955 +struct outer_cache_fns outer_cache __read_only;
2956 EXPORT_SYMBOL(outer_cache);
2957 #endif
2958
2959 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
2960 asm("mrc p15, 0, %0, c0, c1, 4"
2961 : "=r" (mmfr0));
2962 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2963 - (mmfr0 & 0x000000f0) >= 0x00000030)
2964 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2965 cpu_arch = CPU_ARCH_ARMv7;
2966 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2967 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2968 + __supported_pte_mask |= L_PTE_PXN;
2969 + __supported_pmd_mask |= PMD_PXNTABLE;
2970 + }
2971 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2972 (mmfr0 & 0x000000f0) == 0x00000020)
2973 cpu_arch = CPU_ARCH_ARMv6;
2974 else
2975 @@ -462,7 +468,7 @@ static void __init setup_processor(void)
2976 __cpu_architecture = __get_cpu_architecture();
2977
2978 #ifdef MULTI_CPU
2979 - processor = *list->proc;
2980 + memcpy((void *)&processor, list->proc, sizeof processor);
2981 #endif
2982 #ifdef MULTI_TLB
2983 cpu_tlb = *list->tlb;
2984 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
2985 index 56f72d2..6924200 100644
2986 --- a/arch/arm/kernel/signal.c
2987 +++ b/arch/arm/kernel/signal.c
2988 @@ -433,22 +433,14 @@ setup_return(struct pt_regs *regs, struct k_sigaction *ka,
2989 __put_user(sigreturn_codes[idx+1], rc+1))
2990 return 1;
2991
2992 - if (cpsr & MODE32_BIT) {
2993 - /*
2994 - * 32-bit code can use the new high-page
2995 - * signal return code support.
2996 - */
2997 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
2998 - } else {
2999 - /*
3000 - * Ensure that the instruction cache sees
3001 - * the return code written onto the stack.
3002 - */
3003 - flush_icache_range((unsigned long)rc,
3004 - (unsigned long)(rc + 2));
3005 + /*
3006 + * Ensure that the instruction cache sees
3007 + * the return code written onto the stack.
3008 + */
3009 + flush_icache_range((unsigned long)rc,
3010 + (unsigned long)(rc + 2));
3011
3012 - retcode = ((unsigned long)rc) + thumb;
3013 - }
3014 + retcode = ((unsigned long)rc) + thumb;
3015 }
3016
3017 regs->ARM_r0 = usig;
3018 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3019 index 58af91c..343ce99 100644
3020 --- a/arch/arm/kernel/smp.c
3021 +++ b/arch/arm/kernel/smp.c
3022 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3023
3024 static DECLARE_COMPLETION(cpu_running);
3025
3026 -static struct smp_operations smp_ops;
3027 +static struct smp_operations smp_ops __read_only;
3028
3029 void __init smp_set_ops(struct smp_operations *ops)
3030 {
3031 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3032 index b0179b8..829510e 100644
3033 --- a/arch/arm/kernel/traps.c
3034 +++ b/arch/arm/kernel/traps.c
3035 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3036 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3037 {
3038 #ifdef CONFIG_KALLSYMS
3039 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3040 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3041 #else
3042 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3043 #endif
3044 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3045 static int die_owner = -1;
3046 static unsigned int die_nest_count;
3047
3048 +extern void gr_handle_kernel_exploit(void);
3049 +
3050 static unsigned long oops_begin(void)
3051 {
3052 int cpu;
3053 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3054 panic("Fatal exception in interrupt");
3055 if (panic_on_oops)
3056 panic("Fatal exception");
3057 +
3058 + gr_handle_kernel_exploit();
3059 +
3060 if (signr)
3061 do_exit(signr);
3062 }
3063 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3064 * The user helper at 0xffff0fe0 must be used instead.
3065 * (see entry-armv.S for details)
3066 */
3067 + pax_open_kernel();
3068 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3069 + pax_close_kernel();
3070 }
3071 return 0;
3072
3073 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3074 */
3075 kuser_get_tls_init(vectors);
3076
3077 - /*
3078 - * Copy signal return handlers into the vector page, and
3079 - * set sigreturn to be a pointer to these.
3080 - */
3081 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3082 - sigreturn_codes, sizeof(sigreturn_codes));
3083 -
3084 flush_icache_range(vectors, vectors + PAGE_SIZE);
3085 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3086 +
3087 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3088 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3089 +#endif
3090 +
3091 }
3092 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3093 index 11c1785..c67d54c 100644
3094 --- a/arch/arm/kernel/vmlinux.lds.S
3095 +++ b/arch/arm/kernel/vmlinux.lds.S
3096 @@ -8,7 +8,11 @@
3097 #include <asm/thread_info.h>
3098 #include <asm/memory.h>
3099 #include <asm/page.h>
3100 -
3101 +
3102 +#ifdef CONFIG_PAX_KERNEXEC
3103 +#include <asm/pgtable.h>
3104 +#endif
3105 +
3106 #define PROC_INFO \
3107 . = ALIGN(4); \
3108 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3109 @@ -90,6 +94,11 @@ SECTIONS
3110 _text = .;
3111 HEAD_TEXT
3112 }
3113 +
3114 +#ifdef CONFIG_PAX_KERNEXEC
3115 + . = ALIGN(1<<SECTION_SHIFT);
3116 +#endif
3117 +
3118 .text : { /* Real text segment */
3119 _stext = .; /* Text and read-only data */
3120 __exception_text_start = .;
3121 @@ -144,6 +153,10 @@ SECTIONS
3122
3123 _etext = .; /* End of text and rodata section */
3124
3125 +#ifdef CONFIG_PAX_KERNEXEC
3126 + . = ALIGN(1<<SECTION_SHIFT);
3127 +#endif
3128 +
3129 #ifndef CONFIG_XIP_KERNEL
3130 . = ALIGN(PAGE_SIZE);
3131 __init_begin = .;
3132 @@ -203,6 +216,11 @@ SECTIONS
3133 . = PAGE_OFFSET + TEXT_OFFSET;
3134 #else
3135 __init_end = .;
3136 +
3137 +#ifdef CONFIG_PAX_KERNEXEC
3138 + . = ALIGN(1<<SECTION_SHIFT);
3139 +#endif
3140 +
3141 . = ALIGN(THREAD_SIZE);
3142 __data_loc = .;
3143 #endif
3144 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3145 index 14a0d98..7771a7d 100644
3146 --- a/arch/arm/lib/clear_user.S
3147 +++ b/arch/arm/lib/clear_user.S
3148 @@ -12,14 +12,14 @@
3149
3150 .text
3151
3152 -/* Prototype: int __clear_user(void *addr, size_t sz)
3153 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3154 * Purpose : clear some user memory
3155 * Params : addr - user memory address to clear
3156 * : sz - number of bytes to clear
3157 * Returns : number of bytes NOT cleared
3158 */
3159 ENTRY(__clear_user_std)
3160 -WEAK(__clear_user)
3161 +WEAK(___clear_user)
3162 stmfd sp!, {r1, lr}
3163 mov r2, #0
3164 cmp r1, #4
3165 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3166 USER( strnebt r2, [r0])
3167 mov r0, #0
3168 ldmfd sp!, {r1, pc}
3169 -ENDPROC(__clear_user)
3170 +ENDPROC(___clear_user)
3171 ENDPROC(__clear_user_std)
3172
3173 .pushsection .fixup,"ax"
3174 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3175 index 66a477a..bee61d3 100644
3176 --- a/arch/arm/lib/copy_from_user.S
3177 +++ b/arch/arm/lib/copy_from_user.S
3178 @@ -16,7 +16,7 @@
3179 /*
3180 * Prototype:
3181 *
3182 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3183 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3184 *
3185 * Purpose:
3186 *
3187 @@ -84,11 +84,11 @@
3188
3189 .text
3190
3191 -ENTRY(__copy_from_user)
3192 +ENTRY(___copy_from_user)
3193
3194 #include "copy_template.S"
3195
3196 -ENDPROC(__copy_from_user)
3197 +ENDPROC(___copy_from_user)
3198
3199 .pushsection .fixup,"ax"
3200 .align 0
3201 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3202 index 6ee2f67..d1cce76 100644
3203 --- a/arch/arm/lib/copy_page.S
3204 +++ b/arch/arm/lib/copy_page.S
3205 @@ -10,6 +10,7 @@
3206 * ASM optimised string functions
3207 */
3208 #include <linux/linkage.h>
3209 +#include <linux/const.h>
3210 #include <asm/assembler.h>
3211 #include <asm/asm-offsets.h>
3212 #include <asm/cache.h>
3213 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3214 index d066df6..df28194 100644
3215 --- a/arch/arm/lib/copy_to_user.S
3216 +++ b/arch/arm/lib/copy_to_user.S
3217 @@ -16,7 +16,7 @@
3218 /*
3219 * Prototype:
3220 *
3221 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3222 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3223 *
3224 * Purpose:
3225 *
3226 @@ -88,11 +88,11 @@
3227 .text
3228
3229 ENTRY(__copy_to_user_std)
3230 -WEAK(__copy_to_user)
3231 +WEAK(___copy_to_user)
3232
3233 #include "copy_template.S"
3234
3235 -ENDPROC(__copy_to_user)
3236 +ENDPROC(___copy_to_user)
3237 ENDPROC(__copy_to_user_std)
3238
3239 .pushsection .fixup,"ax"
3240 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3241 index 7d08b43..f7ca7ea 100644
3242 --- a/arch/arm/lib/csumpartialcopyuser.S
3243 +++ b/arch/arm/lib/csumpartialcopyuser.S
3244 @@ -57,8 +57,8 @@
3245 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3246 */
3247
3248 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3249 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3250 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3251 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3252
3253 #include "csumpartialcopygeneric.S"
3254
3255 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3256 index 6b93f6a..1aa92d0 100644
3257 --- a/arch/arm/lib/delay.c
3258 +++ b/arch/arm/lib/delay.c
3259 @@ -28,12 +28,15 @@
3260 /*
3261 * Default to the loop-based delay implementation.
3262 */
3263 -struct arm_delay_ops arm_delay_ops = {
3264 +static struct arm_delay_ops arm_loop_delay_ops = {
3265 .delay = __loop_delay,
3266 .const_udelay = __loop_const_udelay,
3267 .udelay = __loop_udelay,
3268 + .const_clock = false,
3269 };
3270
3271 +struct arm_delay_ops *arm_delay_ops __read_only = &arm_loop_delay_ops;
3272 +
3273 static const struct delay_timer *delay_timer;
3274 static bool delay_calibrated;
3275
3276 @@ -67,6 +70,13 @@ static void __timer_udelay(unsigned long usecs)
3277 __timer_const_udelay(usecs * UDELAY_MULT);
3278 }
3279
3280 +static struct arm_delay_ops arm_timer_delay_ops = {
3281 + .delay = __timer_delay,
3282 + .const_udelay = __timer_const_udelay,
3283 + .udelay = __timer_udelay,
3284 + .const_clock = true,
3285 +};
3286 +
3287 void __init register_current_timer_delay(const struct delay_timer *timer)
3288 {
3289 if (!delay_calibrated) {
3290 @@ -74,10 +84,7 @@ void __init register_current_timer_delay(const struct delay_timer *timer)
3291 delay_timer = timer;
3292 lpj_fine = timer->freq / HZ;
3293 loops_per_jiffy = lpj_fine;
3294 - arm_delay_ops.delay = __timer_delay;
3295 - arm_delay_ops.const_udelay = __timer_const_udelay;
3296 - arm_delay_ops.udelay = __timer_udelay;
3297 - arm_delay_ops.const_clock = true;
3298 + arm_delay_ops = &arm_timer_delay_ops;
3299 delay_calibrated = true;
3300 } else {
3301 pr_info("Ignoring duplicate/late registration of read_current_timer delay\n");
3302 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3303 index 025f742..8432b08 100644
3304 --- a/arch/arm/lib/uaccess_with_memcpy.c
3305 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3306 @@ -104,7 +104,7 @@ out:
3307 }
3308
3309 unsigned long
3310 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3311 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3312 {
3313 /*
3314 * This test is stubbed out of the main function above to keep
3315 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3316 index bac21a5..b67ef8e 100644
3317 --- a/arch/arm/mach-kirkwood/common.c
3318 +++ b/arch/arm/mach-kirkwood/common.c
3319 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3320 clk_gate_ops.disable(hw);
3321 }
3322
3323 -static struct clk_ops clk_gate_fn_ops;
3324 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3325 +{
3326 + return clk_gate_ops.is_enabled(hw);
3327 +}
3328 +
3329 +static struct clk_ops clk_gate_fn_ops = {
3330 + .enable = clk_gate_fn_enable,
3331 + .disable = clk_gate_fn_disable,
3332 + .is_enabled = clk_gate_fn_is_enabled,
3333 +};
3334
3335 static struct clk __init *clk_register_gate_fn(struct device *dev,
3336 const char *name,
3337 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3338 gate_fn->fn_en = fn_en;
3339 gate_fn->fn_dis = fn_dis;
3340
3341 - /* ops is the gate ops, but with our enable/disable functions */
3342 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3343 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3344 - clk_gate_fn_ops = clk_gate_ops;
3345 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3346 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3347 - }
3348 -
3349 clk = clk_register(dev, &gate_fn->gate.hw);
3350
3351 if (IS_ERR(clk))
3352 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3353 index 0abb30f..54064da 100644
3354 --- a/arch/arm/mach-omap2/board-n8x0.c
3355 +++ b/arch/arm/mach-omap2/board-n8x0.c
3356 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3357 }
3358 #endif
3359
3360 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3361 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3362 .late_init = n8x0_menelaus_late_init,
3363 };
3364
3365 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3366 index 8033cb7..2f7cb62 100644
3367 --- a/arch/arm/mach-omap2/gpmc.c
3368 +++ b/arch/arm/mach-omap2/gpmc.c
3369 @@ -139,7 +139,6 @@ struct omap3_gpmc_regs {
3370 };
3371
3372 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3373 -static struct irq_chip gpmc_irq_chip;
3374 static unsigned gpmc_irq_start;
3375
3376 static struct resource gpmc_mem_root;
3377 @@ -700,6 +699,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3378
3379 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3380
3381 +static struct irq_chip gpmc_irq_chip = {
3382 + .name = "gpmc",
3383 + .irq_startup = gpmc_irq_noop_ret,
3384 + .irq_enable = gpmc_irq_enable,
3385 + .irq_disable = gpmc_irq_disable,
3386 + .irq_shutdown = gpmc_irq_noop,
3387 + .irq_ack = gpmc_irq_noop,
3388 + .irq_mask = gpmc_irq_noop,
3389 + .irq_unmask = gpmc_irq_noop,
3390 +
3391 +};
3392 +
3393 static int gpmc_setup_irq(void)
3394 {
3395 int i;
3396 @@ -714,15 +725,6 @@ static int gpmc_setup_irq(void)
3397 return gpmc_irq_start;
3398 }
3399
3400 - gpmc_irq_chip.name = "gpmc";
3401 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3402 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3403 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3404 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3405 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3406 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3407 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3408 -
3409 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3410 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3411
3412 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3413 index 5d3b4f4..ddba3c0 100644
3414 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3415 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3416 @@ -340,7 +340,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3417 return NOTIFY_OK;
3418 }
3419
3420 -static struct notifier_block __refdata irq_hotplug_notifier = {
3421 +static struct notifier_block irq_hotplug_notifier = {
3422 .notifier_call = irq_cpu_hotplug_notify,
3423 };
3424
3425 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3426 index e065daa..7b1ad9b 100644
3427 --- a/arch/arm/mach-omap2/omap_device.c
3428 +++ b/arch/arm/mach-omap2/omap_device.c
3429 @@ -686,7 +686,7 @@ void omap_device_delete(struct omap_device *od)
3430 * passes along the return value of omap_device_build_ss().
3431 */
3432 struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
3433 - struct omap_hwmod *oh, void *pdata,
3434 + struct omap_hwmod *oh, const void *pdata,
3435 int pdata_len,
3436 struct omap_device_pm_latency *pm_lats,
3437 int pm_lats_cnt, int is_early_device)
3438 @@ -720,7 +720,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
3439 */
3440 struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
3441 struct omap_hwmod **ohs, int oh_cnt,
3442 - void *pdata, int pdata_len,
3443 + const void *pdata, int pdata_len,
3444 struct omap_device_pm_latency *pm_lats,
3445 int pm_lats_cnt, int is_early_device)
3446 {
3447 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3448 index 0933c59..42b8e2d 100644
3449 --- a/arch/arm/mach-omap2/omap_device.h
3450 +++ b/arch/arm/mach-omap2/omap_device.h
3451 @@ -91,14 +91,14 @@ int omap_device_shutdown(struct platform_device *pdev);
3452 /* Core code interface */
3453
3454 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3455 - struct omap_hwmod *oh, void *pdata,
3456 + struct omap_hwmod *oh, const void *pdata,
3457 int pdata_len,
3458 struct omap_device_pm_latency *pm_lats,
3459 int pm_lats_cnt, int is_early_device);
3460
3461 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3462 struct omap_hwmod **oh, int oh_cnt,
3463 - void *pdata, int pdata_len,
3464 + const void *pdata, int pdata_len,
3465 struct omap_device_pm_latency *pm_lats,
3466 int pm_lats_cnt, int is_early_device);
3467
3468 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3469 index 4653efb..8c60bf7 100644
3470 --- a/arch/arm/mach-omap2/omap_hwmod.c
3471 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3472 @@ -189,10 +189,10 @@ struct omap_hwmod_soc_ops {
3473 int (*init_clkdm)(struct omap_hwmod *oh);
3474 void (*update_context_lost)(struct omap_hwmod *oh);
3475 int (*get_context_lost)(struct omap_hwmod *oh);
3476 -};
3477 +} __no_const;
3478
3479 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3480 -static struct omap_hwmod_soc_ops soc_ops;
3481 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3482
3483 /* omap_hwmod_list contains all registered struct omap_hwmods */
3484 static LIST_HEAD(omap_hwmod_list);
3485 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3486 index 7c2b4ed..b2ea51f 100644
3487 --- a/arch/arm/mach-omap2/wd_timer.c
3488 +++ b/arch/arm/mach-omap2/wd_timer.c
3489 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3490 struct omap_hwmod *oh;
3491 char *oh_name = "wd_timer2";
3492 char *dev_name = "omap_wdt";
3493 - struct omap_wd_timer_platform_data pdata;
3494 + static struct omap_wd_timer_platform_data pdata = {
3495 + .read_reset_sources = prm_read_reset_sources
3496 + };
3497
3498 if (!cpu_class_is_omap2() || of_have_populated_dt())
3499 return 0;
3500 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3501 return -EINVAL;
3502 }
3503
3504 - pdata.read_reset_sources = prm_read_reset_sources;
3505 -
3506 pdev = omap_device_build(dev_name, id, oh, &pdata,
3507 sizeof(struct omap_wd_timer_platform_data),
3508 NULL, 0, 0);
3509 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3510 index 6be4c4d..32ac32a 100644
3511 --- a/arch/arm/mach-ux500/include/mach/setup.h
3512 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3513 @@ -38,13 +38,6 @@ extern struct sys_timer ux500_timer;
3514 .type = MT_DEVICE, \
3515 }
3516
3517 -#define __MEM_DEV_DESC(x, sz) { \
3518 - .virtual = IO_ADDRESS(x), \
3519 - .pfn = __phys_to_pfn(x), \
3520 - .length = sz, \
3521 - .type = MT_MEMORY, \
3522 -}
3523 -
3524 extern struct smp_operations ux500_smp_ops;
3525 extern void ux500_cpu_die(unsigned int cpu);
3526
3527 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3528 index 3fd629d..8b1aca9 100644
3529 --- a/arch/arm/mm/Kconfig
3530 +++ b/arch/arm/mm/Kconfig
3531 @@ -425,7 +425,7 @@ config CPU_32v5
3532
3533 config CPU_32v6
3534 bool
3535 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3536 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3537 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3538
3539 config CPU_32v6K
3540 @@ -577,6 +577,7 @@ config CPU_CP15_MPU
3541
3542 config CPU_USE_DOMAINS
3543 bool
3544 + depends on !ARM_LPAE && !PAX_KERNEXEC
3545 help
3546 This option enables or disables the use of domain switching
3547 via the set_fs() function.
3548 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3549 index db26e2e..ee44569 100644
3550 --- a/arch/arm/mm/alignment.c
3551 +++ b/arch/arm/mm/alignment.c
3552 @@ -211,10 +211,12 @@ union offset_union {
3553 #define __get16_unaligned_check(ins,val,addr) \
3554 do { \
3555 unsigned int err = 0, v, a = addr; \
3556 + pax_open_userland(); \
3557 __get8_unaligned_check(ins,v,a,err); \
3558 val = v << ((BE) ? 8 : 0); \
3559 __get8_unaligned_check(ins,v,a,err); \
3560 val |= v << ((BE) ? 0 : 8); \
3561 + pax_close_userland(); \
3562 if (err) \
3563 goto fault; \
3564 } while (0)
3565 @@ -228,6 +230,7 @@ union offset_union {
3566 #define __get32_unaligned_check(ins,val,addr) \
3567 do { \
3568 unsigned int err = 0, v, a = addr; \
3569 + pax_open_userland(); \
3570 __get8_unaligned_check(ins,v,a,err); \
3571 val = v << ((BE) ? 24 : 0); \
3572 __get8_unaligned_check(ins,v,a,err); \
3573 @@ -236,6 +239,7 @@ union offset_union {
3574 val |= v << ((BE) ? 8 : 16); \
3575 __get8_unaligned_check(ins,v,a,err); \
3576 val |= v << ((BE) ? 0 : 24); \
3577 + pax_close_userland(); \
3578 if (err) \
3579 goto fault; \
3580 } while (0)
3581 @@ -249,6 +253,7 @@ union offset_union {
3582 #define __put16_unaligned_check(ins,val,addr) \
3583 do { \
3584 unsigned int err = 0, v = val, a = addr; \
3585 + pax_open_userland(); \
3586 __asm__( FIRST_BYTE_16 \
3587 ARM( "1: "ins" %1, [%2], #1\n" ) \
3588 THUMB( "1: "ins" %1, [%2]\n" ) \
3589 @@ -268,6 +273,7 @@ union offset_union {
3590 " .popsection\n" \
3591 : "=r" (err), "=&r" (v), "=&r" (a) \
3592 : "0" (err), "1" (v), "2" (a)); \
3593 + pax_close_userland(); \
3594 if (err) \
3595 goto fault; \
3596 } while (0)
3597 @@ -281,6 +287,7 @@ union offset_union {
3598 #define __put32_unaligned_check(ins,val,addr) \
3599 do { \
3600 unsigned int err = 0, v = val, a = addr; \
3601 + pax_open_userland(); \
3602 __asm__( FIRST_BYTE_32 \
3603 ARM( "1: "ins" %1, [%2], #1\n" ) \
3604 THUMB( "1: "ins" %1, [%2]\n" ) \
3605 @@ -310,6 +317,7 @@ union offset_union {
3606 " .popsection\n" \
3607 : "=r" (err), "=&r" (v), "=&r" (a) \
3608 : "0" (err), "1" (v), "2" (a)); \
3609 + pax_close_userland(); \
3610 if (err) \
3611 goto fault; \
3612 } while (0)
3613 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3614 index 5dbf13f..1a60561 100644
3615 --- a/arch/arm/mm/fault.c
3616 +++ b/arch/arm/mm/fault.c
3617 @@ -25,6 +25,7 @@
3618 #include <asm/system_misc.h>
3619 #include <asm/system_info.h>
3620 #include <asm/tlbflush.h>
3621 +#include <asm/sections.h>
3622
3623 #include "fault.h"
3624
3625 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3626 if (fixup_exception(regs))
3627 return;
3628
3629 +#ifdef CONFIG_PAX_KERNEXEC
3630 + if ((fsr & FSR_WRITE) &&
3631 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3632 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3633 + {
3634 + if (current->signal->curr_ip)
3635 + 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),
3636 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3637 + else
3638 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3639 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3640 + }
3641 +#endif
3642 +
3643 /*
3644 * No handler, we'll have to terminate things with extreme prejudice.
3645 */
3646 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3647 }
3648 #endif
3649
3650 +#ifdef CONFIG_PAX_PAGEEXEC
3651 + if (fsr & FSR_LNX_PF) {
3652 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3653 + do_group_exit(SIGKILL);
3654 + }
3655 +#endif
3656 +
3657 tsk->thread.address = addr;
3658 tsk->thread.error_code = fsr;
3659 tsk->thread.trap_no = 14;
3660 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3661 }
3662 #endif /* CONFIG_MMU */
3663
3664 +#ifdef CONFIG_PAX_PAGEEXEC
3665 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3666 +{
3667 + long i;
3668 +
3669 + printk(KERN_ERR "PAX: bytes at PC: ");
3670 + for (i = 0; i < 20; i++) {
3671 + unsigned char c;
3672 + if (get_user(c, (__force unsigned char __user *)pc+i))
3673 + printk(KERN_CONT "?? ");
3674 + else
3675 + printk(KERN_CONT "%02x ", c);
3676 + }
3677 + printk("\n");
3678 +
3679 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3680 + for (i = -1; i < 20; i++) {
3681 + unsigned long c;
3682 + if (get_user(c, (__force unsigned long __user *)sp+i))
3683 + printk(KERN_CONT "???????? ");
3684 + else
3685 + printk(KERN_CONT "%08lx ", c);
3686 + }
3687 + printk("\n");
3688 +}
3689 +#endif
3690 +
3691 /*
3692 * First Level Translation Fault Handler
3693 *
3694 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3695 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3696 struct siginfo info;
3697
3698 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3699 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3700 + if (current->signal->curr_ip)
3701 + 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),
3702 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3703 + else
3704 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3705 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3706 + goto die;
3707 + }
3708 +#endif
3709 +
3710 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3711 return;
3712
3713 +die:
3714 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3715 inf->name, fsr, addr);
3716
3717 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3718 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3719 struct siginfo info;
3720
3721 + if (user_mode(regs)) {
3722 + if (addr == 0xffff0fe0UL) {
3723 + /*
3724 + * PaX: __kuser_get_tls emulation
3725 + */
3726 + regs->ARM_r0 = current_thread_info()->tp_value;
3727 + regs->ARM_pc = regs->ARM_lr;
3728 + return;
3729 + }
3730 + }
3731 +
3732 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3733 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3734 + if (current->signal->curr_ip)
3735 + 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),
3736 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3737 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3738 + else
3739 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3740 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3741 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3742 + goto die;
3743 + }
3744 +#endif
3745 +
3746 +#ifdef CONFIG_PAX_REFCOUNT
3747 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3748 + unsigned int bkpt;
3749 +
3750 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3751 + current->thread.error_code = ifsr;
3752 + current->thread.trap_no = 0;
3753 + pax_report_refcount_overflow(regs);
3754 + fixup_exception(regs);
3755 + return;
3756 + }
3757 + }
3758 +#endif
3759 +
3760 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3761 return;
3762
3763 +die:
3764 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3765 inf->name, ifsr, addr);
3766
3767 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3768 index cf08bdf..772656c 100644
3769 --- a/arch/arm/mm/fault.h
3770 +++ b/arch/arm/mm/fault.h
3771 @@ -3,6 +3,7 @@
3772
3773 /*
3774 * Fault status register encodings. We steal bit 31 for our own purposes.
3775 + * Set when the FSR value is from an instruction fault.
3776 */
3777 #define FSR_LNX_PF (1 << 31)
3778 #define FSR_WRITE (1 << 11)
3779 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3780 }
3781 #endif
3782
3783 +/* valid for LPAE and !LPAE */
3784 +static inline int is_xn_fault(unsigned int fsr)
3785 +{
3786 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3787 +}
3788 +
3789 +static inline int is_domain_fault(unsigned int fsr)
3790 +{
3791 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3792 +}
3793 +
3794 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3795 unsigned long search_exception_table(unsigned long addr);
3796
3797 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3798 index ad722f1..763fdd3 100644
3799 --- a/arch/arm/mm/init.c
3800 +++ b/arch/arm/mm/init.c
3801 @@ -30,6 +30,8 @@
3802 #include <asm/setup.h>
3803 #include <asm/tlb.h>
3804 #include <asm/fixmap.h>
3805 +#include <asm/system_info.h>
3806 +#include <asm/cp15.h>
3807
3808 #include <asm/mach/arch.h>
3809 #include <asm/mach/map.h>
3810 @@ -736,7 +738,46 @@ void free_initmem(void)
3811 {
3812 #ifdef CONFIG_HAVE_TCM
3813 extern char __tcm_start, __tcm_end;
3814 +#endif
3815
3816 +#ifdef CONFIG_PAX_KERNEXEC
3817 + unsigned long addr;
3818 + pgd_t *pgd;
3819 + pud_t *pud;
3820 + pmd_t *pmd;
3821 + int cpu_arch = cpu_architecture();
3822 + unsigned int cr = get_cr();
3823 +
3824 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3825 + /* make pages tables, etc before .text NX */
3826 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3827 + pgd = pgd_offset_k(addr);
3828 + pud = pud_offset(pgd, addr);
3829 + pmd = pmd_offset(pud, addr);
3830 + __section_update(pmd, addr, PMD_SECT_XN);
3831 + }
3832 + /* make init NX */
3833 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3834 + pgd = pgd_offset_k(addr);
3835 + pud = pud_offset(pgd, addr);
3836 + pmd = pmd_offset(pud, addr);
3837 + __section_update(pmd, addr, PMD_SECT_XN);
3838 + }
3839 + /* make kernel code/rodata RX */
3840 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3841 + pgd = pgd_offset_k(addr);
3842 + pud = pud_offset(pgd, addr);
3843 + pmd = pmd_offset(pud, addr);
3844 +#ifdef CONFIG_ARM_LPAE
3845 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3846 +#else
3847 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3848 +#endif
3849 + }
3850 + }
3851 +#endif
3852 +
3853 +#ifdef CONFIG_HAVE_TCM
3854 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3855 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
3856 __phys_to_pfn(__pa(&__tcm_end)),
3857 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3858 index 88fd86c..7a224ce 100644
3859 --- a/arch/arm/mm/ioremap.c
3860 +++ b/arch/arm/mm/ioremap.c
3861 @@ -335,9 +335,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
3862 unsigned int mtype;
3863
3864 if (cached)
3865 - mtype = MT_MEMORY;
3866 + mtype = MT_MEMORY_RX;
3867 else
3868 - mtype = MT_MEMORY_NONCACHED;
3869 + mtype = MT_MEMORY_NONCACHED_RX;
3870
3871 return __arm_ioremap_caller(phys_addr, size, mtype,
3872 __builtin_return_address(0));
3873 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
3874 index 10062ce..aa96dd7 100644
3875 --- a/arch/arm/mm/mmap.c
3876 +++ b/arch/arm/mm/mmap.c
3877 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3878 struct vm_area_struct *vma;
3879 int do_align = 0;
3880 int aliasing = cache_is_vipt_aliasing();
3881 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3882 struct vm_unmapped_area_info info;
3883
3884 /*
3885 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3886 if (len > TASK_SIZE)
3887 return -ENOMEM;
3888
3889 +#ifdef CONFIG_PAX_RANDMMAP
3890 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3891 +#endif
3892 +
3893 if (addr) {
3894 if (do_align)
3895 addr = COLOUR_ALIGN(addr, pgoff);
3896 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3897 addr = PAGE_ALIGN(addr);
3898
3899 vma = find_vma(mm, addr);
3900 - if (TASK_SIZE - len >= addr &&
3901 - (!vma || addr + len <= vma->vm_start))
3902 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3903 return addr;
3904 }
3905
3906 @@ -112,6 +116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3907 unsigned long addr = addr0;
3908 int do_align = 0;
3909 int aliasing = cache_is_vipt_aliasing();
3910 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3911 struct vm_unmapped_area_info info;
3912
3913 /*
3914 @@ -132,6 +137,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3915 return addr;
3916 }
3917
3918 +#ifdef CONFIG_PAX_RANDMMAP
3919 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3920 +#endif
3921 +
3922 /* requesting a specific address */
3923 if (addr) {
3924 if (do_align)
3925 @@ -139,8 +148,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3926 else
3927 addr = PAGE_ALIGN(addr);
3928 vma = find_vma(mm, addr);
3929 - if (TASK_SIZE - len >= addr &&
3930 - (!vma || addr + len <= vma->vm_start))
3931 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3932 return addr;
3933 }
3934
3935 @@ -162,6 +170,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3936 VM_BUG_ON(addr != -ENOMEM);
3937 info.flags = 0;
3938 info.low_limit = mm->mmap_base;
3939 +
3940 +#ifdef CONFIG_PAX_RANDMMAP
3941 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3942 + info.low_limit += mm->delta_mmap;
3943 +#endif
3944 +
3945 info.high_limit = TASK_SIZE;
3946 addr = vm_unmapped_area(&info);
3947 }
3948 @@ -173,6 +187,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3949 {
3950 unsigned long random_factor = 0UL;
3951
3952 +#ifdef CONFIG_PAX_RANDMMAP
3953 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3954 +#endif
3955 +
3956 /* 8 bits of randomness in 20 address space bits */
3957 if ((current->flags & PF_RANDOMIZE) &&
3958 !(current->personality & ADDR_NO_RANDOMIZE))
3959 @@ -180,10 +198,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3960
3961 if (mmap_is_legacy()) {
3962 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3963 +
3964 +#ifdef CONFIG_PAX_RANDMMAP
3965 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3966 + mm->mmap_base += mm->delta_mmap;
3967 +#endif
3968 +
3969 mm->get_unmapped_area = arch_get_unmapped_area;
3970 mm->unmap_area = arch_unmap_area;
3971 } else {
3972 mm->mmap_base = mmap_base(random_factor);
3973 +
3974 +#ifdef CONFIG_PAX_RANDMMAP
3975 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3976 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3977 +#endif
3978 +
3979 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3980 mm->unmap_area = arch_unmap_area_topdown;
3981 }
3982 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
3983 index ce328c7..35b88dc 100644
3984 --- a/arch/arm/mm/mmu.c
3985 +++ b/arch/arm/mm/mmu.c
3986 @@ -35,6 +35,23 @@
3987
3988 #include "mm.h"
3989
3990 +
3991 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3992 +void modify_domain(unsigned int dom, unsigned int type)
3993 +{
3994 + struct thread_info *thread = current_thread_info();
3995 + unsigned int domain = thread->cpu_domain;
3996 + /*
3997 + * DOMAIN_MANAGER might be defined to some other value,
3998 + * use the arch-defined constant
3999 + */
4000 + domain &= ~domain_val(dom, 3);
4001 + thread->cpu_domain = domain | domain_val(dom, type);
4002 + set_domain(thread->cpu_domain);
4003 +}
4004 +EXPORT_SYMBOL(modify_domain);
4005 +#endif
4006 +
4007 /*
4008 * empty_zero_page is a special page that is used for
4009 * zero-initialized data and COW.
4010 @@ -195,10 +212,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
4011 }
4012 #endif
4013
4014 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4015 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4016 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4017
4018 -static struct mem_type mem_types[] = {
4019 +#ifdef CONFIG_PAX_KERNEXEC
4020 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4021 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4022 +#else
4023 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4024 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4025 +#endif
4026 +
4027 +static struct mem_type mem_types[] __read_only = {
4028 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4029 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4030 L_PTE_SHARED,
4031 @@ -227,16 +252,16 @@ static struct mem_type mem_types[] = {
4032 [MT_UNCACHED] = {
4033 .prot_pte = PROT_PTE_DEVICE,
4034 .prot_l1 = PMD_TYPE_TABLE,
4035 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4036 + .prot_sect = PROT_SECT_DEVICE,
4037 .domain = DOMAIN_IO,
4038 },
4039 [MT_CACHECLEAN] = {
4040 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4041 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4042 .domain = DOMAIN_KERNEL,
4043 },
4044 #ifndef CONFIG_ARM_LPAE
4045 [MT_MINICLEAN] = {
4046 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4047 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4048 .domain = DOMAIN_KERNEL,
4049 },
4050 #endif
4051 @@ -244,36 +269,54 @@ static struct mem_type mem_types[] = {
4052 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4053 L_PTE_RDONLY,
4054 .prot_l1 = PMD_TYPE_TABLE,
4055 - .domain = DOMAIN_USER,
4056 + .domain = DOMAIN_VECTORS,
4057 },
4058 [MT_HIGH_VECTORS] = {
4059 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4060 - L_PTE_USER | L_PTE_RDONLY,
4061 + L_PTE_RDONLY,
4062 .prot_l1 = PMD_TYPE_TABLE,
4063 - .domain = DOMAIN_USER,
4064 + .domain = DOMAIN_VECTORS,
4065 },
4066 - [MT_MEMORY] = {
4067 + [MT_MEMORY_RWX] = {
4068 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4069 .prot_l1 = PMD_TYPE_TABLE,
4070 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4071 .domain = DOMAIN_KERNEL,
4072 },
4073 + [MT_MEMORY_RW] = {
4074 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4075 + .prot_l1 = PMD_TYPE_TABLE,
4076 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4077 + .domain = DOMAIN_KERNEL,
4078 + },
4079 + [MT_MEMORY_RX] = {
4080 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4081 + .prot_l1 = PMD_TYPE_TABLE,
4082 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4083 + .domain = DOMAIN_KERNEL,
4084 + },
4085 [MT_ROM] = {
4086 - .prot_sect = PMD_TYPE_SECT,
4087 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4088 .domain = DOMAIN_KERNEL,
4089 },
4090 - [MT_MEMORY_NONCACHED] = {
4091 + [MT_MEMORY_NONCACHED_RW] = {
4092 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4093 L_PTE_MT_BUFFERABLE,
4094 .prot_l1 = PMD_TYPE_TABLE,
4095 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4096 .domain = DOMAIN_KERNEL,
4097 },
4098 + [MT_MEMORY_NONCACHED_RX] = {
4099 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4100 + L_PTE_MT_BUFFERABLE,
4101 + .prot_l1 = PMD_TYPE_TABLE,
4102 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4103 + .domain = DOMAIN_KERNEL,
4104 + },
4105 [MT_MEMORY_DTCM] = {
4106 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4107 - L_PTE_XN,
4108 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4109 .prot_l1 = PMD_TYPE_TABLE,
4110 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4111 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4112 .domain = DOMAIN_KERNEL,
4113 },
4114 [MT_MEMORY_ITCM] = {
4115 @@ -283,10 +326,10 @@ static struct mem_type mem_types[] = {
4116 },
4117 [MT_MEMORY_SO] = {
4118 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4119 - L_PTE_MT_UNCACHED | L_PTE_XN,
4120 + L_PTE_MT_UNCACHED,
4121 .prot_l1 = PMD_TYPE_TABLE,
4122 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4123 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4124 + PMD_SECT_UNCACHED,
4125 .domain = DOMAIN_KERNEL,
4126 },
4127 [MT_MEMORY_DMA_READY] = {
4128 @@ -371,9 +414,35 @@ static void __init build_mem_type_table(void)
4129 * to prevent speculative instruction fetches.
4130 */
4131 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4132 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4133 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4134 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4135 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4136 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4137 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4138 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4139 +
4140 + /* Mark other regions on ARMv6+ as execute-never */
4141 +
4142 +#ifdef CONFIG_PAX_KERNEXEC
4143 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4144 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4145 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4146 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4147 +#ifndef CONFIG_ARM_LPAE
4148 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4149 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4150 +#endif
4151 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4152 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4153 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4154 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4155 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4156 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4157 +#endif
4158 +
4159 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4160 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4161 }
4162 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4163 /*
4164 @@ -432,6 +501,9 @@ static void __init build_mem_type_table(void)
4165 * from SVC mode and no access from userspace.
4166 */
4167 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4168 +#ifdef CONFIG_PAX_KERNEXEC
4169 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4170 +#endif
4171 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4172 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4173 #endif
4174 @@ -448,11 +520,17 @@ static void __init build_mem_type_table(void)
4175 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4176 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4177 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4178 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4179 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4180 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4181 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4182 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4183 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4184 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4185 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4186 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4187 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4188 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4189 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4190 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4191 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4192 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4193 }
4194 }
4195
4196 @@ -463,15 +541,20 @@ static void __init build_mem_type_table(void)
4197 if (cpu_arch >= CPU_ARCH_ARMv6) {
4198 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4199 /* Non-cacheable Normal is XCB = 001 */
4200 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4201 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4202 + PMD_SECT_BUFFERED;
4203 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4204 PMD_SECT_BUFFERED;
4205 } else {
4206 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4207 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4208 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4209 + PMD_SECT_TEX(1);
4210 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4211 PMD_SECT_TEX(1);
4212 }
4213 } else {
4214 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4215 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4216 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4217 }
4218
4219 #ifdef CONFIG_ARM_LPAE
4220 @@ -487,6 +570,8 @@ static void __init build_mem_type_table(void)
4221 vecs_pgprot |= PTE_EXT_AF;
4222 #endif
4223
4224 + user_pgprot |= __supported_pte_mask;
4225 +
4226 for (i = 0; i < 16; i++) {
4227 pteval_t v = pgprot_val(protection_map[i]);
4228 protection_map[i] = __pgprot(v | user_pgprot);
4229 @@ -501,10 +586,15 @@ static void __init build_mem_type_table(void)
4230
4231 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4232 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4233 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4234 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4235 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4236 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4237 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4238 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4239 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4240 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4241 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4242 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4243 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4244 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4245 mem_types[MT_ROM].prot_sect |= cp->pmd;
4246
4247 switch (cp->pmd) {
4248 @@ -1105,18 +1195,15 @@ void __init arm_mm_memblock_reserve(void)
4249 * called function. This means you can't use any function or debugging
4250 * method which may touch any device, otherwise the kernel _will_ crash.
4251 */
4252 +
4253 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4254 +
4255 static void __init devicemaps_init(struct machine_desc *mdesc)
4256 {
4257 struct map_desc map;
4258 unsigned long addr;
4259 - void *vectors;
4260
4261 - /*
4262 - * Allocate the vector page early.
4263 - */
4264 - vectors = early_alloc(PAGE_SIZE);
4265 -
4266 - early_trap_init(vectors);
4267 + early_trap_init(&vectors);
4268
4269 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4270 pmd_clear(pmd_off_k(addr));
4271 @@ -1156,7 +1243,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4272 * location (0xffff0000). If we aren't using high-vectors, also
4273 * create a mapping at the low-vectors virtual address.
4274 */
4275 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4276 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4277 map.virtual = 0xffff0000;
4278 map.length = PAGE_SIZE;
4279 map.type = MT_HIGH_VECTORS;
4280 @@ -1214,8 +1301,39 @@ static void __init map_lowmem(void)
4281 map.pfn = __phys_to_pfn(start);
4282 map.virtual = __phys_to_virt(start);
4283 map.length = end - start;
4284 - map.type = MT_MEMORY;
4285
4286 +#ifdef CONFIG_PAX_KERNEXEC
4287 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4288 + struct map_desc kernel;
4289 + struct map_desc initmap;
4290 +
4291 + /* when freeing initmem we will make this RW */
4292 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4293 + initmap.virtual = (unsigned long)__init_begin;
4294 + initmap.length = _sdata - __init_begin;
4295 + initmap.type = MT_MEMORY_RWX;
4296 + create_mapping(&initmap);
4297 +
4298 + /* when freeing initmem we will make this RX */
4299 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4300 + kernel.virtual = (unsigned long)_stext;
4301 + kernel.length = __init_begin - _stext;
4302 + kernel.type = MT_MEMORY_RWX;
4303 + create_mapping(&kernel);
4304 +
4305 + if (map.virtual < (unsigned long)_stext) {
4306 + map.length = (unsigned long)_stext - map.virtual;
4307 + map.type = MT_MEMORY_RWX;
4308 + create_mapping(&map);
4309 + }
4310 +
4311 + map.pfn = __phys_to_pfn(__pa(_sdata));
4312 + map.virtual = (unsigned long)_sdata;
4313 + map.length = end - __pa(_sdata);
4314 + }
4315 +#endif
4316 +
4317 + map.type = MT_MEMORY_RW;
4318 create_mapping(&map);
4319 }
4320 }
4321 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4322 index 6d98c13..3cfb174 100644
4323 --- a/arch/arm/mm/proc-v7-2level.S
4324 +++ b/arch/arm/mm/proc-v7-2level.S
4325 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4326 tst r1, #L_PTE_XN
4327 orrne r3, r3, #PTE_EXT_XN
4328
4329 + tst r1, #L_PTE_PXN
4330 + orrne r3, r3, #PTE_EXT_PXN
4331 +
4332 tst r1, #L_PTE_YOUNG
4333 tstne r1, #L_PTE_VALID
4334 #ifndef CONFIG_CPU_USE_DOMAINS
4335 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4336 index a5bc92d..0bb4730 100644
4337 --- a/arch/arm/plat-omap/sram.c
4338 +++ b/arch/arm/plat-omap/sram.c
4339 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4340 * Looks like we need to preserve some bootloader code at the
4341 * beginning of SRAM for jumping to flash for reboot to work...
4342 */
4343 + pax_open_kernel();
4344 memset_io(omap_sram_base + omap_sram_skip, 0,
4345 omap_sram_size - omap_sram_skip);
4346 + pax_close_kernel();
4347 }
4348 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4349 index f5144cd..71f6d1f 100644
4350 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4351 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4352 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4353 int (*started)(unsigned ch);
4354 int (*flush)(unsigned ch);
4355 int (*stop)(unsigned ch);
4356 -};
4357 +} __no_const;
4358
4359 extern void *samsung_dmadev_get_ops(void);
4360 extern void *s3c_dma_get_ops(void);
4361 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4362 index 0c3ba9f..95722b3 100644
4363 --- a/arch/arm64/kernel/debug-monitors.c
4364 +++ b/arch/arm64/kernel/debug-monitors.c
4365 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4366 return NOTIFY_OK;
4367 }
4368
4369 -static struct notifier_block __cpuinitdata os_lock_nb = {
4370 +static struct notifier_block os_lock_nb = {
4371 .notifier_call = os_lock_notify,
4372 };
4373
4374 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4375 index 5ab825c..96aaec8 100644
4376 --- a/arch/arm64/kernel/hw_breakpoint.c
4377 +++ b/arch/arm64/kernel/hw_breakpoint.c
4378 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4379 return NOTIFY_OK;
4380 }
4381
4382 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4383 +static struct notifier_block hw_breakpoint_reset_nb = {
4384 .notifier_call = hw_breakpoint_reset_notify,
4385 };
4386
4387 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4388 index c3a58a1..78fbf54 100644
4389 --- a/arch/avr32/include/asm/cache.h
4390 +++ b/arch/avr32/include/asm/cache.h
4391 @@ -1,8 +1,10 @@
4392 #ifndef __ASM_AVR32_CACHE_H
4393 #define __ASM_AVR32_CACHE_H
4394
4395 +#include <linux/const.h>
4396 +
4397 #define L1_CACHE_SHIFT 5
4398 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4399 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4400
4401 /*
4402 * Memory returned by kmalloc() may be used for DMA, so we must make
4403 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4404 index e2c3287..6c4f98c 100644
4405 --- a/arch/avr32/include/asm/elf.h
4406 +++ b/arch/avr32/include/asm/elf.h
4407 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4408 the loader. We need to make sure that it is out of the way of the program
4409 that it will "exec", and that there is sufficient room for the brk. */
4410
4411 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4412 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4413
4414 +#ifdef CONFIG_PAX_ASLR
4415 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4416 +
4417 +#define PAX_DELTA_MMAP_LEN 15
4418 +#define PAX_DELTA_STACK_LEN 15
4419 +#endif
4420
4421 /* This yields a mask that user programs can use to figure out what
4422 instruction set this CPU supports. This could be done in user space,
4423 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4424 index 479330b..53717a8 100644
4425 --- a/arch/avr32/include/asm/kmap_types.h
4426 +++ b/arch/avr32/include/asm/kmap_types.h
4427 @@ -2,9 +2,9 @@
4428 #define __ASM_AVR32_KMAP_TYPES_H
4429
4430 #ifdef CONFIG_DEBUG_HIGHMEM
4431 -# define KM_TYPE_NR 29
4432 +# define KM_TYPE_NR 30
4433 #else
4434 -# define KM_TYPE_NR 14
4435 +# define KM_TYPE_NR 15
4436 #endif
4437
4438 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4439 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4440 index b2f2d2d..d1c85cb 100644
4441 --- a/arch/avr32/mm/fault.c
4442 +++ b/arch/avr32/mm/fault.c
4443 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4444
4445 int exception_trace = 1;
4446
4447 +#ifdef CONFIG_PAX_PAGEEXEC
4448 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4449 +{
4450 + unsigned long i;
4451 +
4452 + printk(KERN_ERR "PAX: bytes at PC: ");
4453 + for (i = 0; i < 20; i++) {
4454 + unsigned char c;
4455 + if (get_user(c, (unsigned char *)pc+i))
4456 + printk(KERN_CONT "???????? ");
4457 + else
4458 + printk(KERN_CONT "%02x ", c);
4459 + }
4460 + printk("\n");
4461 +}
4462 +#endif
4463 +
4464 /*
4465 * This routine handles page faults. It determines the address and the
4466 * problem, and then passes it off to one of the appropriate routines.
4467 @@ -174,6 +191,16 @@ bad_area:
4468 up_read(&mm->mmap_sem);
4469
4470 if (user_mode(regs)) {
4471 +
4472 +#ifdef CONFIG_PAX_PAGEEXEC
4473 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4474 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4475 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4476 + do_group_exit(SIGKILL);
4477 + }
4478 + }
4479 +#endif
4480 +
4481 if (exception_trace && printk_ratelimit())
4482 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4483 "sp %08lx ecr %lu\n",
4484 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4485 index 568885a..f8008df 100644
4486 --- a/arch/blackfin/include/asm/cache.h
4487 +++ b/arch/blackfin/include/asm/cache.h
4488 @@ -7,6 +7,7 @@
4489 #ifndef __ARCH_BLACKFIN_CACHE_H
4490 #define __ARCH_BLACKFIN_CACHE_H
4491
4492 +#include <linux/const.h>
4493 #include <linux/linkage.h> /* for asmlinkage */
4494
4495 /*
4496 @@ -14,7 +15,7 @@
4497 * Blackfin loads 32 bytes for cache
4498 */
4499 #define L1_CACHE_SHIFT 5
4500 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4501 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4502 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4503
4504 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4505 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4506 index aea2718..3639a60 100644
4507 --- a/arch/cris/include/arch-v10/arch/cache.h
4508 +++ b/arch/cris/include/arch-v10/arch/cache.h
4509 @@ -1,8 +1,9 @@
4510 #ifndef _ASM_ARCH_CACHE_H
4511 #define _ASM_ARCH_CACHE_H
4512
4513 +#include <linux/const.h>
4514 /* Etrax 100LX have 32-byte cache-lines. */
4515 -#define L1_CACHE_BYTES 32
4516 #define L1_CACHE_SHIFT 5
4517 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4518
4519 #endif /* _ASM_ARCH_CACHE_H */
4520 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4521 index 7caf25d..ee65ac5 100644
4522 --- a/arch/cris/include/arch-v32/arch/cache.h
4523 +++ b/arch/cris/include/arch-v32/arch/cache.h
4524 @@ -1,11 +1,12 @@
4525 #ifndef _ASM_CRIS_ARCH_CACHE_H
4526 #define _ASM_CRIS_ARCH_CACHE_H
4527
4528 +#include <linux/const.h>
4529 #include <arch/hwregs/dma.h>
4530
4531 /* A cache-line is 32 bytes. */
4532 -#define L1_CACHE_BYTES 32
4533 #define L1_CACHE_SHIFT 5
4534 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4535
4536 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4537
4538 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4539 index b86329d..6709906 100644
4540 --- a/arch/frv/include/asm/atomic.h
4541 +++ b/arch/frv/include/asm/atomic.h
4542 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4543 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4544 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4545
4546 +#define atomic64_read_unchecked(v) atomic64_read(v)
4547 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4548 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4549 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4550 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4551 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4552 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4553 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4554 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4555 +
4556 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4557 {
4558 int c, old;
4559 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4560 index 2797163..c2a401d 100644
4561 --- a/arch/frv/include/asm/cache.h
4562 +++ b/arch/frv/include/asm/cache.h
4563 @@ -12,10 +12,11 @@
4564 #ifndef __ASM_CACHE_H
4565 #define __ASM_CACHE_H
4566
4567 +#include <linux/const.h>
4568
4569 /* bytes per L1 cache line */
4570 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4571 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4572 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4573
4574 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4575 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4576 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4577 index 43901f2..0d8b865 100644
4578 --- a/arch/frv/include/asm/kmap_types.h
4579 +++ b/arch/frv/include/asm/kmap_types.h
4580 @@ -2,6 +2,6 @@
4581 #ifndef _ASM_KMAP_TYPES_H
4582 #define _ASM_KMAP_TYPES_H
4583
4584 -#define KM_TYPE_NR 17
4585 +#define KM_TYPE_NR 18
4586
4587 #endif
4588 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4589 index 385fd30..3aaf4fe 100644
4590 --- a/arch/frv/mm/elf-fdpic.c
4591 +++ b/arch/frv/mm/elf-fdpic.c
4592 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4593 {
4594 struct vm_area_struct *vma;
4595 unsigned long limit;
4596 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4597
4598 if (len > TASK_SIZE)
4599 return -ENOMEM;
4600 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4601 if (addr) {
4602 addr = PAGE_ALIGN(addr);
4603 vma = find_vma(current->mm, addr);
4604 - if (TASK_SIZE - len >= addr &&
4605 - (!vma || addr + len <= vma->vm_start))
4606 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4607 goto success;
4608 }
4609
4610 @@ -89,7 +89,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4611 for (; vma; vma = vma->vm_next) {
4612 if (addr > limit)
4613 break;
4614 - if (addr + len <= vma->vm_start)
4615 + if (check_heap_stack_gap(vma, addr, len, offset))
4616 goto success;
4617 addr = vma->vm_end;
4618 }
4619 @@ -104,7 +104,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4620 for (; vma; vma = vma->vm_next) {
4621 if (addr > limit)
4622 break;
4623 - if (addr + len <= vma->vm_start)
4624 + if (check_heap_stack_gap(vma, addr, len, offset))
4625 goto success;
4626 addr = vma->vm_end;
4627 }
4628 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4629 index f4ca594..adc72fd6 100644
4630 --- a/arch/hexagon/include/asm/cache.h
4631 +++ b/arch/hexagon/include/asm/cache.h
4632 @@ -21,9 +21,11 @@
4633 #ifndef __ASM_CACHE_H
4634 #define __ASM_CACHE_H
4635
4636 +#include <linux/const.h>
4637 +
4638 /* Bytes per L1 cache line */
4639 -#define L1_CACHE_SHIFT (5)
4640 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4641 +#define L1_CACHE_SHIFT 5
4642 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4643
4644 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4645 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4646 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4647 index 6e6fe18..a6ae668 100644
4648 --- a/arch/ia64/include/asm/atomic.h
4649 +++ b/arch/ia64/include/asm/atomic.h
4650 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4651 #define atomic64_inc(v) atomic64_add(1, (v))
4652 #define atomic64_dec(v) atomic64_sub(1, (v))
4653
4654 +#define atomic64_read_unchecked(v) atomic64_read(v)
4655 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4656 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4657 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4658 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4659 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4660 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4661 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4662 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4663 +
4664 /* Atomic operations are already serializing */
4665 #define smp_mb__before_atomic_dec() barrier()
4666 #define smp_mb__after_atomic_dec() barrier()
4667 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4668 index 988254a..e1ee885 100644
4669 --- a/arch/ia64/include/asm/cache.h
4670 +++ b/arch/ia64/include/asm/cache.h
4671 @@ -1,6 +1,7 @@
4672 #ifndef _ASM_IA64_CACHE_H
4673 #define _ASM_IA64_CACHE_H
4674
4675 +#include <linux/const.h>
4676
4677 /*
4678 * Copyright (C) 1998-2000 Hewlett-Packard Co
4679 @@ -9,7 +10,7 @@
4680
4681 /* Bytes per L1 (data) cache line. */
4682 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4683 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4684 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4685
4686 #ifdef CONFIG_SMP
4687 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4688 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4689 index b5298eb..67c6e62 100644
4690 --- a/arch/ia64/include/asm/elf.h
4691 +++ b/arch/ia64/include/asm/elf.h
4692 @@ -42,6 +42,13 @@
4693 */
4694 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4695
4696 +#ifdef CONFIG_PAX_ASLR
4697 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4698 +
4699 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4700 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4701 +#endif
4702 +
4703 #define PT_IA_64_UNWIND 0x70000001
4704
4705 /* IA-64 relocations: */
4706 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4707 index 96a8d92..617a1cf 100644
4708 --- a/arch/ia64/include/asm/pgalloc.h
4709 +++ b/arch/ia64/include/asm/pgalloc.h
4710 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4711 pgd_val(*pgd_entry) = __pa(pud);
4712 }
4713
4714 +static inline void
4715 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4716 +{
4717 + pgd_populate(mm, pgd_entry, pud);
4718 +}
4719 +
4720 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4721 {
4722 return quicklist_alloc(0, GFP_KERNEL, NULL);
4723 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4724 pud_val(*pud_entry) = __pa(pmd);
4725 }
4726
4727 +static inline void
4728 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4729 +{
4730 + pud_populate(mm, pud_entry, pmd);
4731 +}
4732 +
4733 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4734 {
4735 return quicklist_alloc(0, GFP_KERNEL, NULL);
4736 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4737 index 815810c..d60bd4c 100644
4738 --- a/arch/ia64/include/asm/pgtable.h
4739 +++ b/arch/ia64/include/asm/pgtable.h
4740 @@ -12,7 +12,7 @@
4741 * David Mosberger-Tang <davidm@hpl.hp.com>
4742 */
4743
4744 -
4745 +#include <linux/const.h>
4746 #include <asm/mman.h>
4747 #include <asm/page.h>
4748 #include <asm/processor.h>
4749 @@ -142,6 +142,17 @@
4750 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4751 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4752 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4753 +
4754 +#ifdef CONFIG_PAX_PAGEEXEC
4755 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4756 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4757 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4758 +#else
4759 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4760 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4761 +# define PAGE_COPY_NOEXEC PAGE_COPY
4762 +#endif
4763 +
4764 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4765 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4766 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4767 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4768 index 54ff557..70c88b7 100644
4769 --- a/arch/ia64/include/asm/spinlock.h
4770 +++ b/arch/ia64/include/asm/spinlock.h
4771 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4772 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4773
4774 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4775 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4776 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4777 }
4778
4779 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4780 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4781 index 449c8c0..50cdf87 100644
4782 --- a/arch/ia64/include/asm/uaccess.h
4783 +++ b/arch/ia64/include/asm/uaccess.h
4784 @@ -42,6 +42,8 @@
4785 #include <asm/pgtable.h>
4786 #include <asm/io.h>
4787
4788 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
4789 +
4790 /*
4791 * For historical reasons, the following macros are grossly misnamed:
4792 */
4793 @@ -240,12 +242,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4794 static inline unsigned long
4795 __copy_to_user (void __user *to, const void *from, unsigned long count)
4796 {
4797 + if (count > INT_MAX)
4798 + return count;
4799 +
4800 + if (!__builtin_constant_p(count))
4801 + check_object_size(from, count, true);
4802 +
4803 return __copy_user(to, (__force void __user *) from, count);
4804 }
4805
4806 static inline unsigned long
4807 __copy_from_user (void *to, const void __user *from, unsigned long count)
4808 {
4809 + if (count > INT_MAX)
4810 + return count;
4811 +
4812 + if (!__builtin_constant_p(count))
4813 + check_object_size(to, count, false);
4814 +
4815 return __copy_user((__force void __user *) to, from, count);
4816 }
4817
4818 @@ -255,10 +269,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4819 ({ \
4820 void __user *__cu_to = (to); \
4821 const void *__cu_from = (from); \
4822 - long __cu_len = (n); \
4823 + unsigned long __cu_len = (n); \
4824 \
4825 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4826 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4827 + if (!__builtin_constant_p(n)) \
4828 + check_object_size(__cu_from, __cu_len, true); \
4829 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4830 + } \
4831 __cu_len; \
4832 })
4833
4834 @@ -266,11 +283,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4835 ({ \
4836 void *__cu_to = (to); \
4837 const void __user *__cu_from = (from); \
4838 - long __cu_len = (n); \
4839 + unsigned long __cu_len = (n); \
4840 \
4841 __chk_user_ptr(__cu_from); \
4842 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4843 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4844 + if (!__builtin_constant_p(n)) \
4845 + check_object_size(__cu_to, __cu_len, false); \
4846 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4847 + } \
4848 __cu_len; \
4849 })
4850
4851 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4852 index 2d67317..07d8bfa 100644
4853 --- a/arch/ia64/kernel/err_inject.c
4854 +++ b/arch/ia64/kernel/err_inject.c
4855 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4856 return NOTIFY_OK;
4857 }
4858
4859 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4860 +static struct notifier_block err_inject_cpu_notifier =
4861 {
4862 .notifier_call = err_inject_cpu_callback,
4863 };
4864 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4865 index 65bf9cd..794f06b 100644
4866 --- a/arch/ia64/kernel/mca.c
4867 +++ b/arch/ia64/kernel/mca.c
4868 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4869 return NOTIFY_OK;
4870 }
4871
4872 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4873 +static struct notifier_block mca_cpu_notifier = {
4874 .notifier_call = mca_cpu_callback
4875 };
4876
4877 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4878 index 24603be..948052d 100644
4879 --- a/arch/ia64/kernel/module.c
4880 +++ b/arch/ia64/kernel/module.c
4881 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4882 void
4883 module_free (struct module *mod, void *module_region)
4884 {
4885 - if (mod && mod->arch.init_unw_table &&
4886 - module_region == mod->module_init) {
4887 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4888 unw_remove_unwind_table(mod->arch.init_unw_table);
4889 mod->arch.init_unw_table = NULL;
4890 }
4891 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4892 }
4893
4894 static inline int
4895 +in_init_rx (const struct module *mod, uint64_t addr)
4896 +{
4897 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4898 +}
4899 +
4900 +static inline int
4901 +in_init_rw (const struct module *mod, uint64_t addr)
4902 +{
4903 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4904 +}
4905 +
4906 +static inline int
4907 in_init (const struct module *mod, uint64_t addr)
4908 {
4909 - return addr - (uint64_t) mod->module_init < mod->init_size;
4910 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4911 +}
4912 +
4913 +static inline int
4914 +in_core_rx (const struct module *mod, uint64_t addr)
4915 +{
4916 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4917 +}
4918 +
4919 +static inline int
4920 +in_core_rw (const struct module *mod, uint64_t addr)
4921 +{
4922 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4923 }
4924
4925 static inline int
4926 in_core (const struct module *mod, uint64_t addr)
4927 {
4928 - return addr - (uint64_t) mod->module_core < mod->core_size;
4929 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4930 }
4931
4932 static inline int
4933 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4934 break;
4935
4936 case RV_BDREL:
4937 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4938 + if (in_init_rx(mod, val))
4939 + val -= (uint64_t) mod->module_init_rx;
4940 + else if (in_init_rw(mod, val))
4941 + val -= (uint64_t) mod->module_init_rw;
4942 + else if (in_core_rx(mod, val))
4943 + val -= (uint64_t) mod->module_core_rx;
4944 + else if (in_core_rw(mod, val))
4945 + val -= (uint64_t) mod->module_core_rw;
4946 break;
4947
4948 case RV_LTV:
4949 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4950 * addresses have been selected...
4951 */
4952 uint64_t gp;
4953 - if (mod->core_size > MAX_LTOFF)
4954 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4955 /*
4956 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4957 * at the end of the module.
4958 */
4959 - gp = mod->core_size - MAX_LTOFF / 2;
4960 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4961 else
4962 - gp = mod->core_size / 2;
4963 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4964 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4965 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4966 mod->arch.gp = gp;
4967 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4968 }
4969 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4970 index 77597e5..6f28f3f 100644
4971 --- a/arch/ia64/kernel/palinfo.c
4972 +++ b/arch/ia64/kernel/palinfo.c
4973 @@ -1045,7 +1045,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4974 return NOTIFY_OK;
4975 }
4976
4977 -static struct notifier_block __refdata palinfo_cpu_notifier =
4978 +static struct notifier_block palinfo_cpu_notifier =
4979 {
4980 .notifier_call = palinfo_cpu_callback,
4981 .priority = 0,
4982 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4983 index 79802e5..1a89ec5 100644
4984 --- a/arch/ia64/kernel/salinfo.c
4985 +++ b/arch/ia64/kernel/salinfo.c
4986 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4987 return NOTIFY_OK;
4988 }
4989
4990 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4991 +static struct notifier_block salinfo_cpu_notifier =
4992 {
4993 .notifier_call = salinfo_cpu_callback,
4994 .priority = 0,
4995 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4996 index d9439ef..d0cac6b 100644
4997 --- a/arch/ia64/kernel/sys_ia64.c
4998 +++ b/arch/ia64/kernel/sys_ia64.c
4999 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5000 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
5001 struct mm_struct *mm = current->mm;
5002 struct vm_area_struct *vma;
5003 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5004
5005 if (len > RGN_MAP_LIMIT)
5006 return -ENOMEM;
5007 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5008 if (REGION_NUMBER(addr) == RGN_HPAGE)
5009 addr = 0;
5010 #endif
5011 +
5012 +#ifdef CONFIG_PAX_RANDMMAP
5013 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5014 + addr = mm->free_area_cache;
5015 + else
5016 +#endif
5017 +
5018 if (!addr)
5019 addr = mm->free_area_cache;
5020
5021 @@ -61,14 +69,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5022 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
5023 /* At this point: (!vma || addr < vma->vm_end). */
5024 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
5025 - if (start_addr != TASK_UNMAPPED_BASE) {
5026 + if (start_addr != mm->mmap_base) {
5027 /* Start a new search --- just in case we missed some holes. */
5028 - addr = TASK_UNMAPPED_BASE;
5029 + addr = mm->mmap_base;
5030 goto full_search;
5031 }
5032 return -ENOMEM;
5033 }
5034 - if (!vma || addr + len <= vma->vm_start) {
5035 + if (check_heap_stack_gap(vma, addr, len, offset)) {
5036 /* Remember the address where we stopped this search: */
5037 mm->free_area_cache = addr + len;
5038 return addr;
5039 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5040 index dc00b2c..cce53c2 100644
5041 --- a/arch/ia64/kernel/topology.c
5042 +++ b/arch/ia64/kernel/topology.c
5043 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5044 return NOTIFY_OK;
5045 }
5046
5047 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5048 +static struct notifier_block cache_cpu_notifier =
5049 {
5050 .notifier_call = cache_cpu_callback
5051 };
5052 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5053 index 0ccb28f..8992469 100644
5054 --- a/arch/ia64/kernel/vmlinux.lds.S
5055 +++ b/arch/ia64/kernel/vmlinux.lds.S
5056 @@ -198,7 +198,7 @@ SECTIONS {
5057 /* Per-cpu data: */
5058 . = ALIGN(PERCPU_PAGE_SIZE);
5059 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5060 - __phys_per_cpu_start = __per_cpu_load;
5061 + __phys_per_cpu_start = per_cpu_load;
5062 /*
5063 * ensure percpu data fits
5064 * into percpu page size
5065 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5066 index 6cf0341..d352594 100644
5067 --- a/arch/ia64/mm/fault.c
5068 +++ b/arch/ia64/mm/fault.c
5069 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5070 return pte_present(pte);
5071 }
5072
5073 +#ifdef CONFIG_PAX_PAGEEXEC
5074 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5075 +{
5076 + unsigned long i;
5077 +
5078 + printk(KERN_ERR "PAX: bytes at PC: ");
5079 + for (i = 0; i < 8; i++) {
5080 + unsigned int c;
5081 + if (get_user(c, (unsigned int *)pc+i))
5082 + printk(KERN_CONT "???????? ");
5083 + else
5084 + printk(KERN_CONT "%08x ", c);
5085 + }
5086 + printk("\n");
5087 +}
5088 +#endif
5089 +
5090 # define VM_READ_BIT 0
5091 # define VM_WRITE_BIT 1
5092 # define VM_EXEC_BIT 2
5093 @@ -149,8 +166,21 @@ retry:
5094 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5095 goto bad_area;
5096
5097 - if ((vma->vm_flags & mask) != mask)
5098 + if ((vma->vm_flags & mask) != mask) {
5099 +
5100 +#ifdef CONFIG_PAX_PAGEEXEC
5101 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5102 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5103 + goto bad_area;
5104 +
5105 + up_read(&mm->mmap_sem);
5106 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5107 + do_group_exit(SIGKILL);
5108 + }
5109 +#endif
5110 +
5111 goto bad_area;
5112 + }
5113
5114 /*
5115 * If for any reason at all we couldn't handle the fault, make
5116 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5117 index 5ca674b..127c3cb 100644
5118 --- a/arch/ia64/mm/hugetlbpage.c
5119 +++ b/arch/ia64/mm/hugetlbpage.c
5120 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5121 unsigned long pgoff, unsigned long flags)
5122 {
5123 struct vm_area_struct *vmm;
5124 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5125
5126 if (len > RGN_MAP_LIMIT)
5127 return -ENOMEM;
5128 @@ -171,7 +172,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5129 /* At this point: (!vmm || addr < vmm->vm_end). */
5130 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
5131 return -ENOMEM;
5132 - if (!vmm || (addr + len) <= vmm->vm_start)
5133 + if (check_heap_stack_gap(vmm, addr, len, offset))
5134 return addr;
5135 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
5136 }
5137 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5138 index b755ea9..b9a969e 100644
5139 --- a/arch/ia64/mm/init.c
5140 +++ b/arch/ia64/mm/init.c
5141 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5142 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5143 vma->vm_end = vma->vm_start + PAGE_SIZE;
5144 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5145 +
5146 +#ifdef CONFIG_PAX_PAGEEXEC
5147 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5148 + vma->vm_flags &= ~VM_EXEC;
5149 +
5150 +#ifdef CONFIG_PAX_MPROTECT
5151 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5152 + vma->vm_flags &= ~VM_MAYEXEC;
5153 +#endif
5154 +
5155 + }
5156 +#endif
5157 +
5158 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5159 down_write(&current->mm->mmap_sem);
5160 if (insert_vm_struct(current->mm, vma)) {
5161 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5162 index 40b3ee9..8c2c112 100644
5163 --- a/arch/m32r/include/asm/cache.h
5164 +++ b/arch/m32r/include/asm/cache.h
5165 @@ -1,8 +1,10 @@
5166 #ifndef _ASM_M32R_CACHE_H
5167 #define _ASM_M32R_CACHE_H
5168
5169 +#include <linux/const.h>
5170 +
5171 /* L1 cache line size */
5172 #define L1_CACHE_SHIFT 4
5173 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5174 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5175
5176 #endif /* _ASM_M32R_CACHE_H */
5177 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5178 index 82abd15..d95ae5d 100644
5179 --- a/arch/m32r/lib/usercopy.c
5180 +++ b/arch/m32r/lib/usercopy.c
5181 @@ -14,6 +14,9 @@
5182 unsigned long
5183 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5184 {
5185 + if ((long)n < 0)
5186 + return n;
5187 +
5188 prefetch(from);
5189 if (access_ok(VERIFY_WRITE, to, n))
5190 __copy_user(to,from,n);
5191 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5192 unsigned long
5193 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5194 {
5195 + if ((long)n < 0)
5196 + return n;
5197 +
5198 prefetchw(to);
5199 if (access_ok(VERIFY_READ, from, n))
5200 __copy_user_zeroing(to,from,n);
5201 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5202 index 0395c51..5f26031 100644
5203 --- a/arch/m68k/include/asm/cache.h
5204 +++ b/arch/m68k/include/asm/cache.h
5205 @@ -4,9 +4,11 @@
5206 #ifndef __ARCH_M68K_CACHE_H
5207 #define __ARCH_M68K_CACHE_H
5208
5209 +#include <linux/const.h>
5210 +
5211 /* bytes per L1 cache line */
5212 #define L1_CACHE_SHIFT 4
5213 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5214 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5215
5216 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5217
5218 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5219 index 4efe96a..60e8699 100644
5220 --- a/arch/microblaze/include/asm/cache.h
5221 +++ b/arch/microblaze/include/asm/cache.h
5222 @@ -13,11 +13,12 @@
5223 #ifndef _ASM_MICROBLAZE_CACHE_H
5224 #define _ASM_MICROBLAZE_CACHE_H
5225
5226 +#include <linux/const.h>
5227 #include <asm/registers.h>
5228
5229 #define L1_CACHE_SHIFT 5
5230 /* word-granular cache in microblaze */
5231 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5232 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5233
5234 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5235
5236 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5237 index 01cc6ba..bcb7a5d 100644
5238 --- a/arch/mips/include/asm/atomic.h
5239 +++ b/arch/mips/include/asm/atomic.h
5240 @@ -21,6 +21,10 @@
5241 #include <asm/cmpxchg.h>
5242 #include <asm/war.h>
5243
5244 +#ifdef CONFIG_GENERIC_ATOMIC64
5245 +#include <asm-generic/atomic64.h>
5246 +#endif
5247 +
5248 #define ATOMIC_INIT(i) { (i) }
5249
5250 /*
5251 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5252 */
5253 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5254
5255 +#define atomic64_read_unchecked(v) atomic64_read(v)
5256 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5257 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5258 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5259 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5260 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5261 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5262 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5263 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5264 +
5265 #endif /* CONFIG_64BIT */
5266
5267 /*
5268 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5269 index b4db69f..8f3b093 100644
5270 --- a/arch/mips/include/asm/cache.h
5271 +++ b/arch/mips/include/asm/cache.h
5272 @@ -9,10 +9,11 @@
5273 #ifndef _ASM_CACHE_H
5274 #define _ASM_CACHE_H
5275
5276 +#include <linux/const.h>
5277 #include <kmalloc.h>
5278
5279 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5280 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5281 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5282
5283 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5284 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5285 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5286 index 455c0ac..ad65fbe 100644
5287 --- a/arch/mips/include/asm/elf.h
5288 +++ b/arch/mips/include/asm/elf.h
5289 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5290 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5291 #endif
5292
5293 +#ifdef CONFIG_PAX_ASLR
5294 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5295 +
5296 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5297 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5298 +#endif
5299 +
5300 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5301 struct linux_binprm;
5302 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5303 int uses_interp);
5304
5305 -struct mm_struct;
5306 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5307 -#define arch_randomize_brk arch_randomize_brk
5308 -
5309 #endif /* _ASM_ELF_H */
5310 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5311 index c1f6afa..38cc6e9 100644
5312 --- a/arch/mips/include/asm/exec.h
5313 +++ b/arch/mips/include/asm/exec.h
5314 @@ -12,6 +12,6 @@
5315 #ifndef _ASM_EXEC_H
5316 #define _ASM_EXEC_H
5317
5318 -extern unsigned long arch_align_stack(unsigned long sp);
5319 +#define arch_align_stack(x) ((x) & ~0xfUL)
5320
5321 #endif /* _ASM_EXEC_H */
5322 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5323 index dbaec94..6a14935 100644
5324 --- a/arch/mips/include/asm/page.h
5325 +++ b/arch/mips/include/asm/page.h
5326 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5327 #ifdef CONFIG_CPU_MIPS32
5328 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5329 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5330 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5331 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5332 #else
5333 typedef struct { unsigned long long pte; } pte_t;
5334 #define pte_val(x) ((x).pte)
5335 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5336 index 881d18b..cea38bc 100644
5337 --- a/arch/mips/include/asm/pgalloc.h
5338 +++ b/arch/mips/include/asm/pgalloc.h
5339 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5340 {
5341 set_pud(pud, __pud((unsigned long)pmd));
5342 }
5343 +
5344 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5345 +{
5346 + pud_populate(mm, pud, pmd);
5347 +}
5348 #endif
5349
5350 /*
5351 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5352 index b2050b9..d71bb1b 100644
5353 --- a/arch/mips/include/asm/thread_info.h
5354 +++ b/arch/mips/include/asm/thread_info.h
5355 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5356 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5357 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5358 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5359 +/* li takes a 32bit immediate */
5360 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5361 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5362
5363 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5364 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5365 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5366 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5367 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5368 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5369 +
5370 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5371
5372 /* work to do in syscall_trace_leave() */
5373 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5374 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5375
5376 /* work to do on interrupt/exception return */
5377 #define _TIF_WORK_MASK \
5378 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5379 /* work to do on any return to u-space */
5380 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5381 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5382
5383 #endif /* __KERNEL__ */
5384
5385 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5386 index 9fdd8bc..4bd7f1a 100644
5387 --- a/arch/mips/kernel/binfmt_elfn32.c
5388 +++ b/arch/mips/kernel/binfmt_elfn32.c
5389 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5390 #undef ELF_ET_DYN_BASE
5391 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5392
5393 +#ifdef CONFIG_PAX_ASLR
5394 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5395 +
5396 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5397 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5398 +#endif
5399 +
5400 #include <asm/processor.h>
5401 #include <linux/module.h>
5402 #include <linux/elfcore.h>
5403 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5404 index ff44823..97f8906 100644
5405 --- a/arch/mips/kernel/binfmt_elfo32.c
5406 +++ b/arch/mips/kernel/binfmt_elfo32.c
5407 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5408 #undef ELF_ET_DYN_BASE
5409 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5410
5411 +#ifdef CONFIG_PAX_ASLR
5412 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5413 +
5414 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5415 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5416 +#endif
5417 +
5418 #include <asm/processor.h>
5419
5420 /*
5421 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5422 index a11c6f9..be5e164 100644
5423 --- a/arch/mips/kernel/process.c
5424 +++ b/arch/mips/kernel/process.c
5425 @@ -460,15 +460,3 @@ unsigned long get_wchan(struct task_struct *task)
5426 out:
5427 return pc;
5428 }
5429 -
5430 -/*
5431 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5432 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5433 - */
5434 -unsigned long arch_align_stack(unsigned long sp)
5435 -{
5436 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5437 - sp -= get_random_int() & ~PAGE_MASK;
5438 -
5439 - return sp & ALMASK;
5440 -}
5441 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5442 index 4812c6d..2069554 100644
5443 --- a/arch/mips/kernel/ptrace.c
5444 +++ b/arch/mips/kernel/ptrace.c
5445 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5446 return arch;
5447 }
5448
5449 +#ifdef CONFIG_GRKERNSEC_SETXID
5450 +extern void gr_delayed_cred_worker(void);
5451 +#endif
5452 +
5453 /*
5454 * Notification of system call entry/exit
5455 * - triggered by current->work.syscall_trace
5456 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5457 /* do the secure computing check first */
5458 secure_computing_strict(regs->regs[2]);
5459
5460 +#ifdef CONFIG_GRKERNSEC_SETXID
5461 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5462 + gr_delayed_cred_worker();
5463 +#endif
5464 +
5465 if (!(current->ptrace & PT_PTRACED))
5466 goto out;
5467
5468 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5469 index d20a4bc..7096ae5 100644
5470 --- a/arch/mips/kernel/scall32-o32.S
5471 +++ b/arch/mips/kernel/scall32-o32.S
5472 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5473
5474 stack_done:
5475 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5476 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5477 + li t1, _TIF_SYSCALL_WORK
5478 and t0, t1
5479 bnez t0, syscall_trace_entry # -> yes
5480
5481 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5482 index b64f642..0fe6eab 100644
5483 --- a/arch/mips/kernel/scall64-64.S
5484 +++ b/arch/mips/kernel/scall64-64.S
5485 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5486
5487 sd a3, PT_R26(sp) # save a3 for syscall restarting
5488
5489 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5490 + li t1, _TIF_SYSCALL_WORK
5491 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5492 and t0, t1, t0
5493 bnez t0, syscall_trace_entry
5494 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5495 index c29ac19..c592d05 100644
5496 --- a/arch/mips/kernel/scall64-n32.S
5497 +++ b/arch/mips/kernel/scall64-n32.S
5498 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5499
5500 sd a3, PT_R26(sp) # save a3 for syscall restarting
5501
5502 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5503 + li t1, _TIF_SYSCALL_WORK
5504 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5505 and t0, t1, t0
5506 bnez t0, n32_syscall_trace_entry
5507 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5508 index cf3e75e..72e93fe 100644
5509 --- a/arch/mips/kernel/scall64-o32.S
5510 +++ b/arch/mips/kernel/scall64-o32.S
5511 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5512 PTR 4b, bad_stack
5513 .previous
5514
5515 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5516 + li t1, _TIF_SYSCALL_WORK
5517 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5518 and t0, t1, t0
5519 bnez t0, trace_a_syscall
5520 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5521 index ddcec1e..c7f983e 100644
5522 --- a/arch/mips/mm/fault.c
5523 +++ b/arch/mips/mm/fault.c
5524 @@ -27,6 +27,23 @@
5525 #include <asm/highmem.h> /* For VMALLOC_END */
5526 #include <linux/kdebug.h>
5527
5528 +#ifdef CONFIG_PAX_PAGEEXEC
5529 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5530 +{
5531 + unsigned long i;
5532 +
5533 + printk(KERN_ERR "PAX: bytes at PC: ");
5534 + for (i = 0; i < 5; i++) {
5535 + unsigned int c;
5536 + if (get_user(c, (unsigned int *)pc+i))
5537 + printk(KERN_CONT "???????? ");
5538 + else
5539 + printk(KERN_CONT "%08x ", c);
5540 + }
5541 + printk("\n");
5542 +}
5543 +#endif
5544 +
5545 /*
5546 * This routine handles page faults. It determines the address,
5547 * and the problem, and then passes it off to one of the appropriate
5548 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5549 index 7e5fe27..479a219 100644
5550 --- a/arch/mips/mm/mmap.c
5551 +++ b/arch/mips/mm/mmap.c
5552 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5553 struct vm_area_struct *vma;
5554 unsigned long addr = addr0;
5555 int do_color_align;
5556 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5557 struct vm_unmapped_area_info info;
5558
5559 if (unlikely(len > TASK_SIZE))
5560 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5561 do_color_align = 1;
5562
5563 /* requesting a specific address */
5564 +
5565 +#ifdef CONFIG_PAX_RANDMMAP
5566 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5567 +#endif
5568 +
5569 if (addr) {
5570 if (do_color_align)
5571 addr = COLOUR_ALIGN(addr, pgoff);
5572 @@ -91,8 +97,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5573 addr = PAGE_ALIGN(addr);
5574
5575 vma = find_vma(mm, addr);
5576 - if (TASK_SIZE - len >= addr &&
5577 - (!vma || addr + len <= vma->vm_start))
5578 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5579 return addr;
5580 }
5581
5582 @@ -146,6 +151,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5583 {
5584 unsigned long random_factor = 0UL;
5585
5586 +#ifdef CONFIG_PAX_RANDMMAP
5587 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5588 +#endif
5589 +
5590 if (current->flags & PF_RANDOMIZE) {
5591 random_factor = get_random_int();
5592 random_factor = random_factor << PAGE_SHIFT;
5593 @@ -157,42 +166,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5594
5595 if (mmap_is_legacy()) {
5596 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5597 +
5598 +#ifdef CONFIG_PAX_RANDMMAP
5599 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5600 + mm->mmap_base += mm->delta_mmap;
5601 +#endif
5602 +
5603 mm->get_unmapped_area = arch_get_unmapped_area;
5604 mm->unmap_area = arch_unmap_area;
5605 } else {
5606 mm->mmap_base = mmap_base(random_factor);
5607 +
5608 +#ifdef CONFIG_PAX_RANDMMAP
5609 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5610 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5611 +#endif
5612 +
5613 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5614 mm->unmap_area = arch_unmap_area_topdown;
5615 }
5616 }
5617
5618 -static inline unsigned long brk_rnd(void)
5619 -{
5620 - unsigned long rnd = get_random_int();
5621 -
5622 - rnd = rnd << PAGE_SHIFT;
5623 - /* 8MB for 32bit, 256MB for 64bit */
5624 - if (TASK_IS_32BIT_ADDR)
5625 - rnd = rnd & 0x7ffffful;
5626 - else
5627 - rnd = rnd & 0xffffffful;
5628 -
5629 - return rnd;
5630 -}
5631 -
5632 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5633 -{
5634 - unsigned long base = mm->brk;
5635 - unsigned long ret;
5636 -
5637 - ret = PAGE_ALIGN(base + brk_rnd());
5638 -
5639 - if (ret < mm->brk)
5640 - return mm->brk;
5641 -
5642 - return ret;
5643 -}
5644 -
5645 int __virt_addr_valid(const volatile void *kaddr)
5646 {
5647 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5648 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5649 index 967d144..db12197 100644
5650 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5651 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5652 @@ -11,12 +11,14 @@
5653 #ifndef _ASM_PROC_CACHE_H
5654 #define _ASM_PROC_CACHE_H
5655
5656 +#include <linux/const.h>
5657 +
5658 /* L1 cache */
5659
5660 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5661 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5662 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5663 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5664 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5665 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5666
5667 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5668 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5669 index bcb5df2..84fabd2 100644
5670 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5671 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5672 @@ -16,13 +16,15 @@
5673 #ifndef _ASM_PROC_CACHE_H
5674 #define _ASM_PROC_CACHE_H
5675
5676 +#include <linux/const.h>
5677 +
5678 /*
5679 * L1 cache
5680 */
5681 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5682 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5683 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5684 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5685 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5686 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5687
5688 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5689 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5690 index 4ce7a01..449202a 100644
5691 --- a/arch/openrisc/include/asm/cache.h
5692 +++ b/arch/openrisc/include/asm/cache.h
5693 @@ -19,11 +19,13 @@
5694 #ifndef __ASM_OPENRISC_CACHE_H
5695 #define __ASM_OPENRISC_CACHE_H
5696
5697 +#include <linux/const.h>
5698 +
5699 /* FIXME: How can we replace these with values from the CPU...
5700 * they shouldn't be hard-coded!
5701 */
5702
5703 -#define L1_CACHE_BYTES 16
5704 #define L1_CACHE_SHIFT 4
5705 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5706
5707 #endif /* __ASM_OPENRISC_CACHE_H */
5708 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5709 index af9cf30..2aae9b2 100644
5710 --- a/arch/parisc/include/asm/atomic.h
5711 +++ b/arch/parisc/include/asm/atomic.h
5712 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5713
5714 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5715
5716 +#define atomic64_read_unchecked(v) atomic64_read(v)
5717 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5718 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5719 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5720 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5721 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5722 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5723 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5724 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5725 +
5726 #endif /* !CONFIG_64BIT */
5727
5728
5729 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5730 index 47f11c7..3420df2 100644
5731 --- a/arch/parisc/include/asm/cache.h
5732 +++ b/arch/parisc/include/asm/cache.h
5733 @@ -5,6 +5,7 @@
5734 #ifndef __ARCH_PARISC_CACHE_H
5735 #define __ARCH_PARISC_CACHE_H
5736
5737 +#include <linux/const.h>
5738
5739 /*
5740 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5741 @@ -15,13 +16,13 @@
5742 * just ruin performance.
5743 */
5744 #ifdef CONFIG_PA20
5745 -#define L1_CACHE_BYTES 64
5746 #define L1_CACHE_SHIFT 6
5747 #else
5748 -#define L1_CACHE_BYTES 32
5749 #define L1_CACHE_SHIFT 5
5750 #endif
5751
5752 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5753 +
5754 #ifndef __ASSEMBLY__
5755
5756 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5757 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5758 index 19f6cb1..6c78cf2 100644
5759 --- a/arch/parisc/include/asm/elf.h
5760 +++ b/arch/parisc/include/asm/elf.h
5761 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5762
5763 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5764
5765 +#ifdef CONFIG_PAX_ASLR
5766 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5767 +
5768 +#define PAX_DELTA_MMAP_LEN 16
5769 +#define PAX_DELTA_STACK_LEN 16
5770 +#endif
5771 +
5772 /* This yields a mask that user programs can use to figure out what
5773 instruction set this CPU supports. This could be done in user space,
5774 but it's not easy, and we've already done it here. */
5775 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5776 index fc987a1..6e068ef 100644
5777 --- a/arch/parisc/include/asm/pgalloc.h
5778 +++ b/arch/parisc/include/asm/pgalloc.h
5779 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5780 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5781 }
5782
5783 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5784 +{
5785 + pgd_populate(mm, pgd, pmd);
5786 +}
5787 +
5788 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5789 {
5790 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5791 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5792 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5793 #define pmd_free(mm, x) do { } while (0)
5794 #define pgd_populate(mm, pmd, pte) BUG()
5795 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5796
5797 #endif
5798
5799 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5800 index 7df49fa..38b62bf 100644
5801 --- a/arch/parisc/include/asm/pgtable.h
5802 +++ b/arch/parisc/include/asm/pgtable.h
5803 @@ -218,6 +218,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5804 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5805 #define PAGE_COPY PAGE_EXECREAD
5806 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5807 +
5808 +#ifdef CONFIG_PAX_PAGEEXEC
5809 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5810 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5811 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5812 +#else
5813 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5814 +# define PAGE_COPY_NOEXEC PAGE_COPY
5815 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5816 +#endif
5817 +
5818 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5819 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5820 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5821 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5822 index 4ba2c93..f5e3974 100644
5823 --- a/arch/parisc/include/asm/uaccess.h
5824 +++ b/arch/parisc/include/asm/uaccess.h
5825 @@ -251,10 +251,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5826 const void __user *from,
5827 unsigned long n)
5828 {
5829 - int sz = __compiletime_object_size(to);
5830 + size_t sz = __compiletime_object_size(to);
5831 int ret = -EFAULT;
5832
5833 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5834 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5835 ret = __copy_from_user(to, from, n);
5836 else
5837 copy_from_user_overflow();
5838 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5839 index 2a625fb..9908930 100644
5840 --- a/arch/parisc/kernel/module.c
5841 +++ b/arch/parisc/kernel/module.c
5842 @@ -98,16 +98,38 @@
5843
5844 /* three functions to determine where in the module core
5845 * or init pieces the location is */
5846 +static inline int in_init_rx(struct module *me, void *loc)
5847 +{
5848 + return (loc >= me->module_init_rx &&
5849 + loc < (me->module_init_rx + me->init_size_rx));
5850 +}
5851 +
5852 +static inline int in_init_rw(struct module *me, void *loc)
5853 +{
5854 + return (loc >= me->module_init_rw &&
5855 + loc < (me->module_init_rw + me->init_size_rw));
5856 +}
5857 +
5858 static inline int in_init(struct module *me, void *loc)
5859 {
5860 - return (loc >= me->module_init &&
5861 - loc <= (me->module_init + me->init_size));
5862 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5863 +}
5864 +
5865 +static inline int in_core_rx(struct module *me, void *loc)
5866 +{
5867 + return (loc >= me->module_core_rx &&
5868 + loc < (me->module_core_rx + me->core_size_rx));
5869 +}
5870 +
5871 +static inline int in_core_rw(struct module *me, void *loc)
5872 +{
5873 + return (loc >= me->module_core_rw &&
5874 + loc < (me->module_core_rw + me->core_size_rw));
5875 }
5876
5877 static inline int in_core(struct module *me, void *loc)
5878 {
5879 - return (loc >= me->module_core &&
5880 - loc <= (me->module_core + me->core_size));
5881 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5882 }
5883
5884 static inline int in_local(struct module *me, void *loc)
5885 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5886 }
5887
5888 /* align things a bit */
5889 - me->core_size = ALIGN(me->core_size, 16);
5890 - me->arch.got_offset = me->core_size;
5891 - me->core_size += gots * sizeof(struct got_entry);
5892 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5893 + me->arch.got_offset = me->core_size_rw;
5894 + me->core_size_rw += gots * sizeof(struct got_entry);
5895
5896 - me->core_size = ALIGN(me->core_size, 16);
5897 - me->arch.fdesc_offset = me->core_size;
5898 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5899 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5900 + me->arch.fdesc_offset = me->core_size_rw;
5901 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5902
5903 me->arch.got_max = gots;
5904 me->arch.fdesc_max = fdescs;
5905 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5906
5907 BUG_ON(value == 0);
5908
5909 - got = me->module_core + me->arch.got_offset;
5910 + got = me->module_core_rw + me->arch.got_offset;
5911 for (i = 0; got[i].addr; i++)
5912 if (got[i].addr == value)
5913 goto out;
5914 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5915 #ifdef CONFIG_64BIT
5916 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5917 {
5918 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5919 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5920
5921 if (!value) {
5922 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5923 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5924
5925 /* Create new one */
5926 fdesc->addr = value;
5927 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5928 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5929 return (Elf_Addr)fdesc;
5930 }
5931 #endif /* CONFIG_64BIT */
5932 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5933
5934 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5935 end = table + sechdrs[me->arch.unwind_section].sh_size;
5936 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5937 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5938
5939 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5940 me->arch.unwind_section, table, end, gp);
5941 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5942 index f76c108..92bad82 100644
5943 --- a/arch/parisc/kernel/sys_parisc.c
5944 +++ b/arch/parisc/kernel/sys_parisc.c
5945 @@ -33,9 +33,11 @@
5946 #include <linux/utsname.h>
5947 #include <linux/personality.h>
5948
5949 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5950 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5951 + unsigned long flags)
5952 {
5953 struct vm_area_struct *vma;
5954 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5955
5956 addr = PAGE_ALIGN(addr);
5957
5958 @@ -43,7 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5959 /* At this point: (!vma || addr < vma->vm_end). */
5960 if (TASK_SIZE - len < addr)
5961 return -ENOMEM;
5962 - if (!vma || addr + len <= vma->vm_start)
5963 + if (check_heap_stack_gap(vma, addr, len, offset))
5964 return addr;
5965 addr = vma->vm_end;
5966 }
5967 @@ -67,11 +69,12 @@ static int get_offset(struct address_space *mapping)
5968 return offset & 0x3FF000;
5969 }
5970
5971 -static unsigned long get_shared_area(struct address_space *mapping,
5972 - unsigned long addr, unsigned long len, unsigned long pgoff)
5973 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5974 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5975 {
5976 struct vm_area_struct *vma;
5977 int offset = mapping ? get_offset(mapping) : 0;
5978 + unsigned long rand_offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5979
5980 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
5981
5982 @@ -81,7 +84,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5983 /* At this point: (!vma || addr < vma->vm_end). */
5984 if (TASK_SIZE - len < addr)
5985 return -ENOMEM;
5986 - if (!vma || addr + len <= vma->vm_start)
5987 + if (check_heap_stack_gap(vma, addr, len, rand_offset))
5988 return addr;
5989 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
5990 if (addr < vma->vm_end) /* handle wraparound */
5991 @@ -100,14 +103,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5992 if (flags & MAP_FIXED)
5993 return addr;
5994 if (!addr)
5995 - addr = TASK_UNMAPPED_BASE;
5996 + addr = current->mm->mmap_base;
5997
5998 if (filp) {
5999 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6000 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6001 } else if(flags & MAP_SHARED) {
6002 - addr = get_shared_area(NULL, addr, len, pgoff);
6003 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6004 } else {
6005 - addr = get_unshared_area(addr, len);
6006 + addr = get_unshared_area(filp, addr, len, flags);
6007 }
6008 return addr;
6009 }
6010 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6011 index 45ba99f..8e22c33 100644
6012 --- a/arch/parisc/kernel/traps.c
6013 +++ b/arch/parisc/kernel/traps.c
6014 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6015
6016 down_read(&current->mm->mmap_sem);
6017 vma = find_vma(current->mm,regs->iaoq[0]);
6018 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6019 - && (vma->vm_flags & VM_EXEC)) {
6020 -
6021 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6022 fault_address = regs->iaoq[0];
6023 fault_space = regs->iasq[0];
6024
6025 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6026 index 18162ce..94de376 100644
6027 --- a/arch/parisc/mm/fault.c
6028 +++ b/arch/parisc/mm/fault.c
6029 @@ -15,6 +15,7 @@
6030 #include <linux/sched.h>
6031 #include <linux/interrupt.h>
6032 #include <linux/module.h>
6033 +#include <linux/unistd.h>
6034
6035 #include <asm/uaccess.h>
6036 #include <asm/traps.h>
6037 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6038 static unsigned long
6039 parisc_acctyp(unsigned long code, unsigned int inst)
6040 {
6041 - if (code == 6 || code == 16)
6042 + if (code == 6 || code == 7 || code == 16)
6043 return VM_EXEC;
6044
6045 switch (inst & 0xf0000000) {
6046 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6047 }
6048 #endif
6049
6050 +#ifdef CONFIG_PAX_PAGEEXEC
6051 +/*
6052 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6053 + *
6054 + * returns 1 when task should be killed
6055 + * 2 when rt_sigreturn trampoline was detected
6056 + * 3 when unpatched PLT trampoline was detected
6057 + */
6058 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6059 +{
6060 +
6061 +#ifdef CONFIG_PAX_EMUPLT
6062 + int err;
6063 +
6064 + do { /* PaX: unpatched PLT emulation */
6065 + unsigned int bl, depwi;
6066 +
6067 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6068 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6069 +
6070 + if (err)
6071 + break;
6072 +
6073 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6074 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6075 +
6076 + err = get_user(ldw, (unsigned int *)addr);
6077 + err |= get_user(bv, (unsigned int *)(addr+4));
6078 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6079 +
6080 + if (err)
6081 + break;
6082 +
6083 + if (ldw == 0x0E801096U &&
6084 + bv == 0xEAC0C000U &&
6085 + ldw2 == 0x0E881095U)
6086 + {
6087 + unsigned int resolver, map;
6088 +
6089 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6090 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6091 + if (err)
6092 + break;
6093 +
6094 + regs->gr[20] = instruction_pointer(regs)+8;
6095 + regs->gr[21] = map;
6096 + regs->gr[22] = resolver;
6097 + regs->iaoq[0] = resolver | 3UL;
6098 + regs->iaoq[1] = regs->iaoq[0] + 4;
6099 + return 3;
6100 + }
6101 + }
6102 + } while (0);
6103 +#endif
6104 +
6105 +#ifdef CONFIG_PAX_EMUTRAMP
6106 +
6107 +#ifndef CONFIG_PAX_EMUSIGRT
6108 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6109 + return 1;
6110 +#endif
6111 +
6112 + do { /* PaX: rt_sigreturn emulation */
6113 + unsigned int ldi1, ldi2, bel, nop;
6114 +
6115 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6116 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6117 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6118 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6119 +
6120 + if (err)
6121 + break;
6122 +
6123 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6124 + ldi2 == 0x3414015AU &&
6125 + bel == 0xE4008200U &&
6126 + nop == 0x08000240U)
6127 + {
6128 + regs->gr[25] = (ldi1 & 2) >> 1;
6129 + regs->gr[20] = __NR_rt_sigreturn;
6130 + regs->gr[31] = regs->iaoq[1] + 16;
6131 + regs->sr[0] = regs->iasq[1];
6132 + regs->iaoq[0] = 0x100UL;
6133 + regs->iaoq[1] = regs->iaoq[0] + 4;
6134 + regs->iasq[0] = regs->sr[2];
6135 + regs->iasq[1] = regs->sr[2];
6136 + return 2;
6137 + }
6138 + } while (0);
6139 +#endif
6140 +
6141 + return 1;
6142 +}
6143 +
6144 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6145 +{
6146 + unsigned long i;
6147 +
6148 + printk(KERN_ERR "PAX: bytes at PC: ");
6149 + for (i = 0; i < 5; i++) {
6150 + unsigned int c;
6151 + if (get_user(c, (unsigned int *)pc+i))
6152 + printk(KERN_CONT "???????? ");
6153 + else
6154 + printk(KERN_CONT "%08x ", c);
6155 + }
6156 + printk("\n");
6157 +}
6158 +#endif
6159 +
6160 int fixup_exception(struct pt_regs *regs)
6161 {
6162 const struct exception_table_entry *fix;
6163 @@ -192,8 +303,33 @@ good_area:
6164
6165 acc_type = parisc_acctyp(code,regs->iir);
6166
6167 - if ((vma->vm_flags & acc_type) != acc_type)
6168 + if ((vma->vm_flags & acc_type) != acc_type) {
6169 +
6170 +#ifdef CONFIG_PAX_PAGEEXEC
6171 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6172 + (address & ~3UL) == instruction_pointer(regs))
6173 + {
6174 + up_read(&mm->mmap_sem);
6175 + switch (pax_handle_fetch_fault(regs)) {
6176 +
6177 +#ifdef CONFIG_PAX_EMUPLT
6178 + case 3:
6179 + return;
6180 +#endif
6181 +
6182 +#ifdef CONFIG_PAX_EMUTRAMP
6183 + case 2:
6184 + return;
6185 +#endif
6186 +
6187 + }
6188 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6189 + do_group_exit(SIGKILL);
6190 + }
6191 +#endif
6192 +
6193 goto bad_area;
6194 + }
6195
6196 /*
6197 * If for any reason at all we couldn't handle the fault, make
6198 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6199 index e3b1d41..8e81edf 100644
6200 --- a/arch/powerpc/include/asm/atomic.h
6201 +++ b/arch/powerpc/include/asm/atomic.h
6202 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6203 return t1;
6204 }
6205
6206 +#define atomic64_read_unchecked(v) atomic64_read(v)
6207 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6208 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6209 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6210 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6211 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6212 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6213 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6214 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6215 +
6216 #endif /* __powerpc64__ */
6217
6218 #endif /* __KERNEL__ */
6219 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6220 index 9e495c9..b6878e5 100644
6221 --- a/arch/powerpc/include/asm/cache.h
6222 +++ b/arch/powerpc/include/asm/cache.h
6223 @@ -3,6 +3,7 @@
6224
6225 #ifdef __KERNEL__
6226
6227 +#include <linux/const.h>
6228
6229 /* bytes per L1 cache line */
6230 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6231 @@ -22,7 +23,7 @@
6232 #define L1_CACHE_SHIFT 7
6233 #endif
6234
6235 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6236 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6237
6238 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6239
6240 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6241 index 6abf0a1..459d0f1 100644
6242 --- a/arch/powerpc/include/asm/elf.h
6243 +++ b/arch/powerpc/include/asm/elf.h
6244 @@ -28,8 +28,19 @@
6245 the loader. We need to make sure that it is out of the way of the program
6246 that it will "exec", and that there is sufficient room for the brk. */
6247
6248 -extern unsigned long randomize_et_dyn(unsigned long base);
6249 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6250 +#define ELF_ET_DYN_BASE (0x20000000)
6251 +
6252 +#ifdef CONFIG_PAX_ASLR
6253 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6254 +
6255 +#ifdef __powerpc64__
6256 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6257 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6258 +#else
6259 +#define PAX_DELTA_MMAP_LEN 15
6260 +#define PAX_DELTA_STACK_LEN 15
6261 +#endif
6262 +#endif
6263
6264 /*
6265 * Our registers are always unsigned longs, whether we're a 32 bit
6266 @@ -124,10 +135,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6267 (0x7ff >> (PAGE_SHIFT - 12)) : \
6268 (0x3ffff >> (PAGE_SHIFT - 12)))
6269
6270 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6271 -#define arch_randomize_brk arch_randomize_brk
6272 -
6273 -
6274 #ifdef CONFIG_SPU_BASE
6275 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6276 #define NT_SPU 1
6277 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6278 index 8196e9c..d83a9f3 100644
6279 --- a/arch/powerpc/include/asm/exec.h
6280 +++ b/arch/powerpc/include/asm/exec.h
6281 @@ -4,6 +4,6 @@
6282 #ifndef _ASM_POWERPC_EXEC_H
6283 #define _ASM_POWERPC_EXEC_H
6284
6285 -extern unsigned long arch_align_stack(unsigned long sp);
6286 +#define arch_align_stack(x) ((x) & ~0xfUL)
6287
6288 #endif /* _ASM_POWERPC_EXEC_H */
6289 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6290 index 5acabbd..7ea14fa 100644
6291 --- a/arch/powerpc/include/asm/kmap_types.h
6292 +++ b/arch/powerpc/include/asm/kmap_types.h
6293 @@ -10,7 +10,7 @@
6294 * 2 of the License, or (at your option) any later version.
6295 */
6296
6297 -#define KM_TYPE_NR 16
6298 +#define KM_TYPE_NR 17
6299
6300 #endif /* __KERNEL__ */
6301 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6302 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6303 index 8565c25..2865190 100644
6304 --- a/arch/powerpc/include/asm/mman.h
6305 +++ b/arch/powerpc/include/asm/mman.h
6306 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6307 }
6308 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6309
6310 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6311 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6312 {
6313 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6314 }
6315 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6316 index f072e97..b436dee 100644
6317 --- a/arch/powerpc/include/asm/page.h
6318 +++ b/arch/powerpc/include/asm/page.h
6319 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6320 * and needs to be executable. This means the whole heap ends
6321 * up being executable.
6322 */
6323 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6324 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6325 +#define VM_DATA_DEFAULT_FLAGS32 \
6326 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6327 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6328
6329 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6330 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6331 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6332 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6333 #endif
6334
6335 +#define ktla_ktva(addr) (addr)
6336 +#define ktva_ktla(addr) (addr)
6337 +
6338 /*
6339 * Use the top bit of the higher-level page table entries to indicate whether
6340 * the entries we point to contain hugepages. This works because we know that
6341 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6342 index cd915d6..c10cee8 100644
6343 --- a/arch/powerpc/include/asm/page_64.h
6344 +++ b/arch/powerpc/include/asm/page_64.h
6345 @@ -154,15 +154,18 @@ do { \
6346 * stack by default, so in the absence of a PT_GNU_STACK program header
6347 * we turn execute permission off.
6348 */
6349 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6350 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6351 +#define VM_STACK_DEFAULT_FLAGS32 \
6352 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6353 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6354
6355 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6356 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6357
6358 +#ifndef CONFIG_PAX_PAGEEXEC
6359 #define VM_STACK_DEFAULT_FLAGS \
6360 (is_32bit_task() ? \
6361 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6362 +#endif
6363
6364 #include <asm-generic/getorder.h>
6365
6366 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6367 index 292725c..f87ae14 100644
6368 --- a/arch/powerpc/include/asm/pgalloc-64.h
6369 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6370 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6371 #ifndef CONFIG_PPC_64K_PAGES
6372
6373 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6374 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6375
6376 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6377 {
6378 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6379 pud_set(pud, (unsigned long)pmd);
6380 }
6381
6382 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6383 +{
6384 + pud_populate(mm, pud, pmd);
6385 +}
6386 +
6387 #define pmd_populate(mm, pmd, pte_page) \
6388 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6389 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6390 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6391 #else /* CONFIG_PPC_64K_PAGES */
6392
6393 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6394 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6395
6396 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6397 pte_t *pte)
6398 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6399 index a9cbd3b..3b67efa 100644
6400 --- a/arch/powerpc/include/asm/pgtable.h
6401 +++ b/arch/powerpc/include/asm/pgtable.h
6402 @@ -2,6 +2,7 @@
6403 #define _ASM_POWERPC_PGTABLE_H
6404 #ifdef __KERNEL__
6405
6406 +#include <linux/const.h>
6407 #ifndef __ASSEMBLY__
6408 #include <asm/processor.h> /* For TASK_SIZE */
6409 #include <asm/mmu.h>
6410 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6411 index 4aad413..85d86bf 100644
6412 --- a/arch/powerpc/include/asm/pte-hash32.h
6413 +++ b/arch/powerpc/include/asm/pte-hash32.h
6414 @@ -21,6 +21,7 @@
6415 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6416 #define _PAGE_USER 0x004 /* usermode access allowed */
6417 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6418 +#define _PAGE_EXEC _PAGE_GUARDED
6419 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6420 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6421 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6422 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6423 index 3d5c9dc..62f8414 100644
6424 --- a/arch/powerpc/include/asm/reg.h
6425 +++ b/arch/powerpc/include/asm/reg.h
6426 @@ -215,6 +215,7 @@
6427 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6428 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6429 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6430 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6431 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6432 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6433 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6434 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6435 index 406b7b9..af63426 100644
6436 --- a/arch/powerpc/include/asm/thread_info.h
6437 +++ b/arch/powerpc/include/asm/thread_info.h
6438 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6439 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6440 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6441 #define TIF_SINGLESTEP 8 /* singlestepping active */
6442 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6443 #define TIF_SECCOMP 10 /* secure computing */
6444 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6445 #define TIF_NOERROR 12 /* Force successful syscall return */
6446 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6447 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6448 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6449 for stack store? */
6450 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6451 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6452 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6453
6454 /* as above, but as bit values */
6455 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6456 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6457 #define _TIF_UPROBE (1<<TIF_UPROBE)
6458 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6459 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6460 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6461 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6462 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6463 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6464 + _TIF_GRSEC_SETXID)
6465
6466 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6467 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6468 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6469 index 4db4959..335e00c 100644
6470 --- a/arch/powerpc/include/asm/uaccess.h
6471 +++ b/arch/powerpc/include/asm/uaccess.h
6472 @@ -13,6 +13,8 @@
6473 #define VERIFY_READ 0
6474 #define VERIFY_WRITE 1
6475
6476 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
6477 +
6478 /*
6479 * The fs value determines whether argument validity checking should be
6480 * performed or not. If get_fs() == USER_DS, checking is performed, with
6481 @@ -318,52 +320,6 @@ do { \
6482 extern unsigned long __copy_tofrom_user(void __user *to,
6483 const void __user *from, unsigned long size);
6484
6485 -#ifndef __powerpc64__
6486 -
6487 -static inline unsigned long copy_from_user(void *to,
6488 - const void __user *from, unsigned long n)
6489 -{
6490 - unsigned long over;
6491 -
6492 - if (access_ok(VERIFY_READ, from, n))
6493 - return __copy_tofrom_user((__force void __user *)to, from, n);
6494 - if ((unsigned long)from < TASK_SIZE) {
6495 - over = (unsigned long)from + n - TASK_SIZE;
6496 - return __copy_tofrom_user((__force void __user *)to, from,
6497 - n - over) + over;
6498 - }
6499 - return n;
6500 -}
6501 -
6502 -static inline unsigned long copy_to_user(void __user *to,
6503 - const void *from, unsigned long n)
6504 -{
6505 - unsigned long over;
6506 -
6507 - if (access_ok(VERIFY_WRITE, to, n))
6508 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6509 - if ((unsigned long)to < TASK_SIZE) {
6510 - over = (unsigned long)to + n - TASK_SIZE;
6511 - return __copy_tofrom_user(to, (__force void __user *)from,
6512 - n - over) + over;
6513 - }
6514 - return n;
6515 -}
6516 -
6517 -#else /* __powerpc64__ */
6518 -
6519 -#define __copy_in_user(to, from, size) \
6520 - __copy_tofrom_user((to), (from), (size))
6521 -
6522 -extern unsigned long copy_from_user(void *to, const void __user *from,
6523 - unsigned long n);
6524 -extern unsigned long copy_to_user(void __user *to, const void *from,
6525 - unsigned long n);
6526 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6527 - unsigned long n);
6528 -
6529 -#endif /* __powerpc64__ */
6530 -
6531 static inline unsigned long __copy_from_user_inatomic(void *to,
6532 const void __user *from, unsigned long n)
6533 {
6534 @@ -387,6 +343,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6535 if (ret == 0)
6536 return 0;
6537 }
6538 +
6539 + if (!__builtin_constant_p(n))
6540 + check_object_size(to, n, false);
6541 +
6542 return __copy_tofrom_user((__force void __user *)to, from, n);
6543 }
6544
6545 @@ -413,6 +373,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6546 if (ret == 0)
6547 return 0;
6548 }
6549 +
6550 + if (!__builtin_constant_p(n))
6551 + check_object_size(from, n, true);
6552 +
6553 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6554 }
6555
6556 @@ -430,6 +394,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6557 return __copy_to_user_inatomic(to, from, size);
6558 }
6559
6560 +#ifndef __powerpc64__
6561 +
6562 +static inline unsigned long __must_check copy_from_user(void *to,
6563 + const void __user *from, unsigned long n)
6564 +{
6565 + unsigned long over;
6566 +
6567 + if ((long)n < 0)
6568 + return n;
6569 +
6570 + if (access_ok(VERIFY_READ, from, n)) {
6571 + if (!__builtin_constant_p(n))
6572 + check_object_size(to, n, false);
6573 + return __copy_tofrom_user((__force void __user *)to, from, n);
6574 + }
6575 + if ((unsigned long)from < TASK_SIZE) {
6576 + over = (unsigned long)from + n - TASK_SIZE;
6577 + if (!__builtin_constant_p(n - over))
6578 + check_object_size(to, n - over, false);
6579 + return __copy_tofrom_user((__force void __user *)to, from,
6580 + n - over) + over;
6581 + }
6582 + return n;
6583 +}
6584 +
6585 +static inline unsigned long __must_check copy_to_user(void __user *to,
6586 + const void *from, unsigned long n)
6587 +{
6588 + unsigned long over;
6589 +
6590 + if ((long)n < 0)
6591 + return n;
6592 +
6593 + if (access_ok(VERIFY_WRITE, to, n)) {
6594 + if (!__builtin_constant_p(n))
6595 + check_object_size(from, n, true);
6596 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6597 + }
6598 + if ((unsigned long)to < TASK_SIZE) {
6599 + over = (unsigned long)to + n - TASK_SIZE;
6600 + if (!__builtin_constant_p(n))
6601 + check_object_size(from, n - over, true);
6602 + return __copy_tofrom_user(to, (__force void __user *)from,
6603 + n - over) + over;
6604 + }
6605 + return n;
6606 +}
6607 +
6608 +#else /* __powerpc64__ */
6609 +
6610 +#define __copy_in_user(to, from, size) \
6611 + __copy_tofrom_user((to), (from), (size))
6612 +
6613 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6614 +{
6615 + if ((long)n < 0 || n > INT_MAX)
6616 + return n;
6617 +
6618 + if (!__builtin_constant_p(n))
6619 + check_object_size(to, n, false);
6620 +
6621 + if (likely(access_ok(VERIFY_READ, from, n)))
6622 + n = __copy_from_user(to, from, n);
6623 + else
6624 + memset(to, 0, n);
6625 + return n;
6626 +}
6627 +
6628 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6629 +{
6630 + if ((long)n < 0 || n > INT_MAX)
6631 + return n;
6632 +
6633 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6634 + if (!__builtin_constant_p(n))
6635 + check_object_size(from, n, true);
6636 + n = __copy_to_user(to, from, n);
6637 + }
6638 + return n;
6639 +}
6640 +
6641 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6642 + unsigned long n);
6643 +
6644 +#endif /* __powerpc64__ */
6645 +
6646 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6647
6648 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6649 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6650 index 4684e33..acc4d19e 100644
6651 --- a/arch/powerpc/kernel/exceptions-64e.S
6652 +++ b/arch/powerpc/kernel/exceptions-64e.S
6653 @@ -715,6 +715,7 @@ storage_fault_common:
6654 std r14,_DAR(r1)
6655 std r15,_DSISR(r1)
6656 addi r3,r1,STACK_FRAME_OVERHEAD
6657 + bl .save_nvgprs
6658 mr r4,r14
6659 mr r5,r15
6660 ld r14,PACA_EXGEN+EX_R14(r13)
6661 @@ -723,8 +724,7 @@ storage_fault_common:
6662 cmpdi r3,0
6663 bne- 1f
6664 b .ret_from_except_lite
6665 -1: bl .save_nvgprs
6666 - mr r5,r3
6667 +1: mr r5,r3
6668 addi r3,r1,STACK_FRAME_OVERHEAD
6669 ld r4,_DAR(r1)
6670 bl .bad_page_fault
6671 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6672 index 3684cbd..bc89eab 100644
6673 --- a/arch/powerpc/kernel/exceptions-64s.S
6674 +++ b/arch/powerpc/kernel/exceptions-64s.S
6675 @@ -1206,10 +1206,10 @@ handle_page_fault:
6676 11: ld r4,_DAR(r1)
6677 ld r5,_DSISR(r1)
6678 addi r3,r1,STACK_FRAME_OVERHEAD
6679 + bl .save_nvgprs
6680 bl .do_page_fault
6681 cmpdi r3,0
6682 beq+ 12f
6683 - bl .save_nvgprs
6684 mr r5,r3
6685 addi r3,r1,STACK_FRAME_OVERHEAD
6686 lwz r4,_DAR(r1)
6687 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6688 index 2e3200c..72095ce 100644
6689 --- a/arch/powerpc/kernel/module_32.c
6690 +++ b/arch/powerpc/kernel/module_32.c
6691 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6692 me->arch.core_plt_section = i;
6693 }
6694 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6695 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6696 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6697 return -ENOEXEC;
6698 }
6699
6700 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6701
6702 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6703 /* Init, or core PLT? */
6704 - if (location >= mod->module_core
6705 - && location < mod->module_core + mod->core_size)
6706 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6707 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6708 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6709 - else
6710 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6711 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6712 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6713 + else {
6714 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6715 + return ~0UL;
6716 + }
6717
6718 /* Find this entry, or if that fails, the next avail. entry */
6719 while (entry->jump[0]) {
6720 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6721 index 8143067..21ae55b 100644
6722 --- a/arch/powerpc/kernel/process.c
6723 +++ b/arch/powerpc/kernel/process.c
6724 @@ -680,8 +680,8 @@ void show_regs(struct pt_regs * regs)
6725 * Lookup NIP late so we have the best change of getting the
6726 * above info out without failing
6727 */
6728 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6729 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6730 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6731 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6732 #endif
6733 show_stack(current, (unsigned long *) regs->gpr[1]);
6734 if (!user_mode(regs))
6735 @@ -1129,10 +1129,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6736 newsp = stack[0];
6737 ip = stack[STACK_FRAME_LR_SAVE];
6738 if (!firstframe || ip != lr) {
6739 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6740 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6741 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6742 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6743 - printk(" (%pS)",
6744 + printk(" (%pA)",
6745 (void *)current->ret_stack[curr_frame].ret);
6746 curr_frame--;
6747 }
6748 @@ -1152,7 +1152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6749 struct pt_regs *regs = (struct pt_regs *)
6750 (sp + STACK_FRAME_OVERHEAD);
6751 lr = regs->link;
6752 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6753 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6754 regs->trap, (void *)regs->nip, (void *)lr);
6755 firstframe = 1;
6756 }
6757 @@ -1194,58 +1194,3 @@ void __ppc64_runlatch_off(void)
6758 mtspr(SPRN_CTRLT, ctrl);
6759 }
6760 #endif /* CONFIG_PPC64 */
6761 -
6762 -unsigned long arch_align_stack(unsigned long sp)
6763 -{
6764 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6765 - sp -= get_random_int() & ~PAGE_MASK;
6766 - return sp & ~0xf;
6767 -}
6768 -
6769 -static inline unsigned long brk_rnd(void)
6770 -{
6771 - unsigned long rnd = 0;
6772 -
6773 - /* 8MB for 32bit, 1GB for 64bit */
6774 - if (is_32bit_task())
6775 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6776 - else
6777 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6778 -
6779 - return rnd << PAGE_SHIFT;
6780 -}
6781 -
6782 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6783 -{
6784 - unsigned long base = mm->brk;
6785 - unsigned long ret;
6786 -
6787 -#ifdef CONFIG_PPC_STD_MMU_64
6788 - /*
6789 - * If we are using 1TB segments and we are allowed to randomise
6790 - * the heap, we can put it above 1TB so it is backed by a 1TB
6791 - * segment. Otherwise the heap will be in the bottom 1TB
6792 - * which always uses 256MB segments and this may result in a
6793 - * performance penalty.
6794 - */
6795 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6796 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6797 -#endif
6798 -
6799 - ret = PAGE_ALIGN(base + brk_rnd());
6800 -
6801 - if (ret < mm->brk)
6802 - return mm->brk;
6803 -
6804 - return ret;
6805 -}
6806 -
6807 -unsigned long randomize_et_dyn(unsigned long base)
6808 -{
6809 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6810 -
6811 - if (ret < base)
6812 - return base;
6813 -
6814 - return ret;
6815 -}
6816 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6817 index c497000..8fde506 100644
6818 --- a/arch/powerpc/kernel/ptrace.c
6819 +++ b/arch/powerpc/kernel/ptrace.c
6820 @@ -1737,6 +1737,10 @@ long arch_ptrace(struct task_struct *child, long request,
6821 return ret;
6822 }
6823
6824 +#ifdef CONFIG_GRKERNSEC_SETXID
6825 +extern void gr_delayed_cred_worker(void);
6826 +#endif
6827 +
6828 /*
6829 * We must return the syscall number to actually look up in the table.
6830 * This can be -1L to skip running any syscall at all.
6831 @@ -1747,6 +1751,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6832
6833 secure_computing_strict(regs->gpr[0]);
6834
6835 +#ifdef CONFIG_GRKERNSEC_SETXID
6836 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6837 + gr_delayed_cred_worker();
6838 +#endif
6839 +
6840 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6841 tracehook_report_syscall_entry(regs))
6842 /*
6843 @@ -1781,6 +1790,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6844 {
6845 int step;
6846
6847 +#ifdef CONFIG_GRKERNSEC_SETXID
6848 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6849 + gr_delayed_cred_worker();
6850 +#endif
6851 +
6852 audit_syscall_exit(regs);
6853
6854 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6855 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6856 index 804e323..79181c1 100644
6857 --- a/arch/powerpc/kernel/signal_32.c
6858 +++ b/arch/powerpc/kernel/signal_32.c
6859 @@ -851,7 +851,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6860 /* Save user registers on the stack */
6861 frame = &rt_sf->uc.uc_mcontext;
6862 addr = frame;
6863 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6864 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6865 if (save_user_regs(regs, frame, 0, 1))
6866 goto badframe;
6867 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6868 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6869 index 1ca045d..139c3f7 100644
6870 --- a/arch/powerpc/kernel/signal_64.c
6871 +++ b/arch/powerpc/kernel/signal_64.c
6872 @@ -430,7 +430,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6873 current->thread.fpscr.val = 0;
6874
6875 /* Set up to return from userspace. */
6876 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6877 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6878 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6879 } else {
6880 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6881 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6882 index 3ce1f86..c30e629 100644
6883 --- a/arch/powerpc/kernel/sysfs.c
6884 +++ b/arch/powerpc/kernel/sysfs.c
6885 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6886 return NOTIFY_OK;
6887 }
6888
6889 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6890 +static struct notifier_block sysfs_cpu_nb = {
6891 .notifier_call = sysfs_cpu_notify,
6892 };
6893
6894 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6895 index 3251840..3f7c77a 100644
6896 --- a/arch/powerpc/kernel/traps.c
6897 +++ b/arch/powerpc/kernel/traps.c
6898 @@ -133,6 +133,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6899 return flags;
6900 }
6901
6902 +extern void gr_handle_kernel_exploit(void);
6903 +
6904 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6905 int signr)
6906 {
6907 @@ -182,6 +184,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6908 panic("Fatal exception in interrupt");
6909 if (panic_on_oops)
6910 panic("Fatal exception");
6911 +
6912 + gr_handle_kernel_exploit();
6913 +
6914 do_exit(signr);
6915 }
6916
6917 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6918 index 1b2076f..835e4be 100644
6919 --- a/arch/powerpc/kernel/vdso.c
6920 +++ b/arch/powerpc/kernel/vdso.c
6921 @@ -34,6 +34,7 @@
6922 #include <asm/firmware.h>
6923 #include <asm/vdso.h>
6924 #include <asm/vdso_datapage.h>
6925 +#include <asm/mman.h>
6926
6927 #include "setup.h"
6928
6929 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6930 vdso_base = VDSO32_MBASE;
6931 #endif
6932
6933 - current->mm->context.vdso_base = 0;
6934 + current->mm->context.vdso_base = ~0UL;
6935
6936 /* vDSO has a problem and was disabled, just don't "enable" it for the
6937 * process
6938 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6939 vdso_base = get_unmapped_area(NULL, vdso_base,
6940 (vdso_pages << PAGE_SHIFT) +
6941 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6942 - 0, 0);
6943 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6944 if (IS_ERR_VALUE(vdso_base)) {
6945 rc = vdso_base;
6946 goto fail_mmapsem;
6947 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6948 index 5eea6f3..5d10396 100644
6949 --- a/arch/powerpc/lib/usercopy_64.c
6950 +++ b/arch/powerpc/lib/usercopy_64.c
6951 @@ -9,22 +9,6 @@
6952 #include <linux/module.h>
6953 #include <asm/uaccess.h>
6954
6955 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6956 -{
6957 - if (likely(access_ok(VERIFY_READ, from, n)))
6958 - n = __copy_from_user(to, from, n);
6959 - else
6960 - memset(to, 0, n);
6961 - return n;
6962 -}
6963 -
6964 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6965 -{
6966 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6967 - n = __copy_to_user(to, from, n);
6968 - return n;
6969 -}
6970 -
6971 unsigned long copy_in_user(void __user *to, const void __user *from,
6972 unsigned long n)
6973 {
6974 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6975 return n;
6976 }
6977
6978 -EXPORT_SYMBOL(copy_from_user);
6979 -EXPORT_SYMBOL(copy_to_user);
6980 EXPORT_SYMBOL(copy_in_user);
6981
6982 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6983 index 3a8489a..6a63b3b 100644
6984 --- a/arch/powerpc/mm/fault.c
6985 +++ b/arch/powerpc/mm/fault.c
6986 @@ -32,6 +32,10 @@
6987 #include <linux/perf_event.h>
6988 #include <linux/magic.h>
6989 #include <linux/ratelimit.h>
6990 +#include <linux/slab.h>
6991 +#include <linux/pagemap.h>
6992 +#include <linux/compiler.h>
6993 +#include <linux/unistd.h>
6994
6995 #include <asm/firmware.h>
6996 #include <asm/page.h>
6997 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
6998 }
6999 #endif
7000
7001 +#ifdef CONFIG_PAX_PAGEEXEC
7002 +/*
7003 + * PaX: decide what to do with offenders (regs->nip = fault address)
7004 + *
7005 + * returns 1 when task should be killed
7006 + */
7007 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7008 +{
7009 + return 1;
7010 +}
7011 +
7012 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7013 +{
7014 + unsigned long i;
7015 +
7016 + printk(KERN_ERR "PAX: bytes at PC: ");
7017 + for (i = 0; i < 5; i++) {
7018 + unsigned int c;
7019 + if (get_user(c, (unsigned int __user *)pc+i))
7020 + printk(KERN_CONT "???????? ");
7021 + else
7022 + printk(KERN_CONT "%08x ", c);
7023 + }
7024 + printk("\n");
7025 +}
7026 +#endif
7027 +
7028 /*
7029 * Check whether the instruction at regs->nip is a store using
7030 * an update addressing form which will update r1.
7031 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7032 * indicate errors in DSISR but can validly be set in SRR1.
7033 */
7034 if (trap == 0x400)
7035 - error_code &= 0x48200000;
7036 + error_code &= 0x58200000;
7037 else
7038 is_write = error_code & DSISR_ISSTORE;
7039 #else
7040 @@ -364,7 +395,7 @@ good_area:
7041 * "undefined". Of those that can be set, this is the only
7042 * one which seems bad.
7043 */
7044 - if (error_code & 0x10000000)
7045 + if (error_code & DSISR_GUARDED)
7046 /* Guarded storage error. */
7047 goto bad_area;
7048 #endif /* CONFIG_8xx */
7049 @@ -379,7 +410,7 @@ good_area:
7050 * processors use the same I/D cache coherency mechanism
7051 * as embedded.
7052 */
7053 - if (error_code & DSISR_PROTFAULT)
7054 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7055 goto bad_area;
7056 #endif /* CONFIG_PPC_STD_MMU */
7057
7058 @@ -462,6 +493,23 @@ bad_area:
7059 bad_area_nosemaphore:
7060 /* User mode accesses cause a SIGSEGV */
7061 if (user_mode(regs)) {
7062 +
7063 +#ifdef CONFIG_PAX_PAGEEXEC
7064 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7065 +#ifdef CONFIG_PPC_STD_MMU
7066 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7067 +#else
7068 + if (is_exec && regs->nip == address) {
7069 +#endif
7070 + switch (pax_handle_fetch_fault(regs)) {
7071 + }
7072 +
7073 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7074 + do_group_exit(SIGKILL);
7075 + }
7076 + }
7077 +#endif
7078 +
7079 _exception(SIGSEGV, regs, code, address);
7080 return 0;
7081 }
7082 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7083 index 67a42ed..cd463e0 100644
7084 --- a/arch/powerpc/mm/mmap_64.c
7085 +++ b/arch/powerpc/mm/mmap_64.c
7086 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7087 {
7088 unsigned long rnd = 0;
7089
7090 +#ifdef CONFIG_PAX_RANDMMAP
7091 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7092 +#endif
7093 +
7094 if (current->flags & PF_RANDOMIZE) {
7095 /* 8MB for 32bit, 1GB for 64bit */
7096 if (is_32bit_task())
7097 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7098 */
7099 if (mmap_is_legacy()) {
7100 mm->mmap_base = TASK_UNMAPPED_BASE;
7101 +
7102 +#ifdef CONFIG_PAX_RANDMMAP
7103 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7104 + mm->mmap_base += mm->delta_mmap;
7105 +#endif
7106 +
7107 mm->get_unmapped_area = arch_get_unmapped_area;
7108 mm->unmap_area = arch_unmap_area;
7109 } else {
7110 mm->mmap_base = mmap_base();
7111 +
7112 +#ifdef CONFIG_PAX_RANDMMAP
7113 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7114 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7115 +#endif
7116 +
7117 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7118 mm->unmap_area = arch_unmap_area_topdown;
7119 }
7120 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7121 index e779642..e5bb889 100644
7122 --- a/arch/powerpc/mm/mmu_context_nohash.c
7123 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7124 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7125 return NOTIFY_OK;
7126 }
7127
7128 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7129 +static struct notifier_block mmu_context_cpu_nb = {
7130 .notifier_call = mmu_context_cpu_notify,
7131 };
7132
7133 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7134 index bba87ca..c346a33 100644
7135 --- a/arch/powerpc/mm/numa.c
7136 +++ b/arch/powerpc/mm/numa.c
7137 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7138 return ret;
7139 }
7140
7141 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7142 +static struct notifier_block ppc64_numa_nb = {
7143 .notifier_call = cpu_numa_callback,
7144 .priority = 1 /* Must run before sched domains notifier. */
7145 };
7146 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7147 index cf9dada..241529f 100644
7148 --- a/arch/powerpc/mm/slice.c
7149 +++ b/arch/powerpc/mm/slice.c
7150 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7151 if ((mm->task_size - len) < addr)
7152 return 0;
7153 vma = find_vma(mm, addr);
7154 - return (!vma || (addr + len) <= vma->vm_start);
7155 + return check_heap_stack_gap(vma, addr, len, 0);
7156 }
7157
7158 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7159 @@ -272,7 +272,7 @@ full_search:
7160 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7161 continue;
7162 }
7163 - if (!vma || addr + len <= vma->vm_start) {
7164 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7165 /*
7166 * Remember the place where we stopped the search:
7167 */
7168 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7169 }
7170 }
7171
7172 - addr = mm->mmap_base;
7173 - while (addr > len) {
7174 + if (mm->mmap_base < len)
7175 + addr = -ENOMEM;
7176 + else
7177 + addr = mm->mmap_base - len;
7178 +
7179 + while (!IS_ERR_VALUE(addr)) {
7180 /* Go down by chunk size */
7181 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7182 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7183
7184 /* Check for hit with different page size */
7185 mask = slice_range_to_mask(addr, len);
7186 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7187 * return with success:
7188 */
7189 vma = find_vma(mm, addr);
7190 - if (!vma || (addr + len) <= vma->vm_start) {
7191 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7192 /* remember the address as a hint for next time */
7193 if (use_cache)
7194 mm->free_area_cache = addr;
7195 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7196 mm->cached_hole_size = vma->vm_start - addr;
7197
7198 /* try just below the current vma->vm_start */
7199 - addr = vma->vm_start;
7200 + addr = skip_heap_stack_gap(vma, len, 0);
7201 }
7202
7203 /*
7204 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7205 if (fixed && addr > (mm->task_size - len))
7206 return -EINVAL;
7207
7208 +#ifdef CONFIG_PAX_RANDMMAP
7209 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7210 + addr = 0;
7211 +#endif
7212 +
7213 /* If hint, make sure it matches our alignment restrictions */
7214 if (!fixed && addr) {
7215 addr = _ALIGN_UP(addr, 1ul << pshift);
7216 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7217 index bdb738a..49c9f95 100644
7218 --- a/arch/powerpc/platforms/powermac/smp.c
7219 +++ b/arch/powerpc/platforms/powermac/smp.c
7220 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7221 return NOTIFY_OK;
7222 }
7223
7224 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7225 +static struct notifier_block smp_core99_cpu_nb = {
7226 .notifier_call = smp_core99_cpu_notify,
7227 };
7228 #endif /* CONFIG_HOTPLUG_CPU */
7229 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7230 index c797832..ce575c8 100644
7231 --- a/arch/s390/include/asm/atomic.h
7232 +++ b/arch/s390/include/asm/atomic.h
7233 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7234 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7235 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7236
7237 +#define atomic64_read_unchecked(v) atomic64_read(v)
7238 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7239 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7240 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7241 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7242 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7243 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7244 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7245 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7246 +
7247 #define smp_mb__before_atomic_dec() smp_mb()
7248 #define smp_mb__after_atomic_dec() smp_mb()
7249 #define smp_mb__before_atomic_inc() smp_mb()
7250 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7251 index 4d7ccac..d03d0ad 100644
7252 --- a/arch/s390/include/asm/cache.h
7253 +++ b/arch/s390/include/asm/cache.h
7254 @@ -9,8 +9,10 @@
7255 #ifndef __ARCH_S390_CACHE_H
7256 #define __ARCH_S390_CACHE_H
7257
7258 -#define L1_CACHE_BYTES 256
7259 +#include <linux/const.h>
7260 +
7261 #define L1_CACHE_SHIFT 8
7262 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7263 #define NET_SKB_PAD 32
7264
7265 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7266 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7267 index 178ff96..8c93bd1 100644
7268 --- a/arch/s390/include/asm/elf.h
7269 +++ b/arch/s390/include/asm/elf.h
7270 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7271 the loader. We need to make sure that it is out of the way of the program
7272 that it will "exec", and that there is sufficient room for the brk. */
7273
7274 -extern unsigned long randomize_et_dyn(unsigned long base);
7275 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7276 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7277 +
7278 +#ifdef CONFIG_PAX_ASLR
7279 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7280 +
7281 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7282 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7283 +#endif
7284
7285 /* This yields a mask that user programs can use to figure out what
7286 instruction set this CPU supports. */
7287 @@ -210,9 +216,6 @@ struct linux_binprm;
7288 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7289 int arch_setup_additional_pages(struct linux_binprm *, int);
7290
7291 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7292 -#define arch_randomize_brk arch_randomize_brk
7293 -
7294 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7295
7296 #endif
7297 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7298 index c4a93d6..4d2a9b4 100644
7299 --- a/arch/s390/include/asm/exec.h
7300 +++ b/arch/s390/include/asm/exec.h
7301 @@ -7,6 +7,6 @@
7302 #ifndef __ASM_EXEC_H
7303 #define __ASM_EXEC_H
7304
7305 -extern unsigned long arch_align_stack(unsigned long sp);
7306 +#define arch_align_stack(x) ((x) & ~0xfUL)
7307
7308 #endif /* __ASM_EXEC_H */
7309 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7310 index 34268df..ea97318 100644
7311 --- a/arch/s390/include/asm/uaccess.h
7312 +++ b/arch/s390/include/asm/uaccess.h
7313 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7314 copy_to_user(void __user *to, const void *from, unsigned long n)
7315 {
7316 might_fault();
7317 +
7318 + if ((long)n < 0)
7319 + return n;
7320 +
7321 if (access_ok(VERIFY_WRITE, to, n))
7322 n = __copy_to_user(to, from, n);
7323 return n;
7324 @@ -277,6 +281,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7325 static inline unsigned long __must_check
7326 __copy_from_user(void *to, const void __user *from, unsigned long n)
7327 {
7328 + if ((long)n < 0)
7329 + return n;
7330 +
7331 if (__builtin_constant_p(n) && (n <= 256))
7332 return uaccess.copy_from_user_small(n, from, to);
7333 else
7334 @@ -308,10 +315,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7335 static inline unsigned long __must_check
7336 copy_from_user(void *to, const void __user *from, unsigned long n)
7337 {
7338 - unsigned int sz = __compiletime_object_size(to);
7339 + size_t sz = __compiletime_object_size(to);
7340
7341 might_fault();
7342 - if (unlikely(sz != -1 && sz < n)) {
7343 +
7344 + if ((long)n < 0)
7345 + return n;
7346 +
7347 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7348 copy_from_user_overflow();
7349 return n;
7350 }
7351 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7352 index 4610dea..cf0af21 100644
7353 --- a/arch/s390/kernel/module.c
7354 +++ b/arch/s390/kernel/module.c
7355 @@ -171,11 +171,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7356
7357 /* Increase core size by size of got & plt and set start
7358 offsets for got and plt. */
7359 - me->core_size = ALIGN(me->core_size, 4);
7360 - me->arch.got_offset = me->core_size;
7361 - me->core_size += me->arch.got_size;
7362 - me->arch.plt_offset = me->core_size;
7363 - me->core_size += me->arch.plt_size;
7364 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7365 + me->arch.got_offset = me->core_size_rw;
7366 + me->core_size_rw += me->arch.got_size;
7367 + me->arch.plt_offset = me->core_size_rx;
7368 + me->core_size_rx += me->arch.plt_size;
7369 return 0;
7370 }
7371
7372 @@ -252,7 +252,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7373 if (info->got_initialized == 0) {
7374 Elf_Addr *gotent;
7375
7376 - gotent = me->module_core + me->arch.got_offset +
7377 + gotent = me->module_core_rw + me->arch.got_offset +
7378 info->got_offset;
7379 *gotent = val;
7380 info->got_initialized = 1;
7381 @@ -276,7 +276,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7382 else if (r_type == R_390_GOTENT ||
7383 r_type == R_390_GOTPLTENT)
7384 *(unsigned int *) loc =
7385 - (val + (Elf_Addr) me->module_core - loc) >> 1;
7386 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
7387 else if (r_type == R_390_GOT64 ||
7388 r_type == R_390_GOTPLT64)
7389 *(unsigned long *) loc = val;
7390 @@ -290,7 +290,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7391 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7392 if (info->plt_initialized == 0) {
7393 unsigned int *ip;
7394 - ip = me->module_core + me->arch.plt_offset +
7395 + ip = me->module_core_rx + me->arch.plt_offset +
7396 info->plt_offset;
7397 #ifndef CONFIG_64BIT
7398 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7399 @@ -315,7 +315,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7400 val - loc + 0xffffUL < 0x1ffffeUL) ||
7401 (r_type == R_390_PLT32DBL &&
7402 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7403 - val = (Elf_Addr) me->module_core +
7404 + val = (Elf_Addr) me->module_core_rx +
7405 me->arch.plt_offset +
7406 info->plt_offset;
7407 val += rela->r_addend - loc;
7408 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7409 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7410 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7411 val = val + rela->r_addend -
7412 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7413 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7414 if (r_type == R_390_GOTOFF16)
7415 *(unsigned short *) loc = val;
7416 else if (r_type == R_390_GOTOFF32)
7417 @@ -347,7 +347,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7418 break;
7419 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7420 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7421 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7422 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7423 rela->r_addend - loc;
7424 if (r_type == R_390_GOTPC)
7425 *(unsigned int *) loc = val;
7426 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7427 index 536d645..4a5bd9e 100644
7428 --- a/arch/s390/kernel/process.c
7429 +++ b/arch/s390/kernel/process.c
7430 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7431 }
7432 return 0;
7433 }
7434 -
7435 -unsigned long arch_align_stack(unsigned long sp)
7436 -{
7437 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7438 - sp -= get_random_int() & ~PAGE_MASK;
7439 - return sp & ~0xf;
7440 -}
7441 -
7442 -static inline unsigned long brk_rnd(void)
7443 -{
7444 - /* 8MB for 32bit, 1GB for 64bit */
7445 - if (is_32bit_task())
7446 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7447 - else
7448 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7449 -}
7450 -
7451 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7452 -{
7453 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7454 -
7455 - if (ret < mm->brk)
7456 - return mm->brk;
7457 - return ret;
7458 -}
7459 -
7460 -unsigned long randomize_et_dyn(unsigned long base)
7461 -{
7462 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7463 -
7464 - if (!(current->flags & PF_RANDOMIZE))
7465 - return base;
7466 - if (ret < base)
7467 - return base;
7468 - return ret;
7469 -}
7470 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7471 index c59a5ef..3fae59c 100644
7472 --- a/arch/s390/mm/mmap.c
7473 +++ b/arch/s390/mm/mmap.c
7474 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7475 */
7476 if (mmap_is_legacy()) {
7477 mm->mmap_base = TASK_UNMAPPED_BASE;
7478 +
7479 +#ifdef CONFIG_PAX_RANDMMAP
7480 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7481 + mm->mmap_base += mm->delta_mmap;
7482 +#endif
7483 +
7484 mm->get_unmapped_area = arch_get_unmapped_area;
7485 mm->unmap_area = arch_unmap_area;
7486 } else {
7487 mm->mmap_base = mmap_base();
7488 +
7489 +#ifdef CONFIG_PAX_RANDMMAP
7490 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7491 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7492 +#endif
7493 +
7494 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7495 mm->unmap_area = arch_unmap_area_topdown;
7496 }
7497 @@ -172,10 +184,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7498 */
7499 if (mmap_is_legacy()) {
7500 mm->mmap_base = TASK_UNMAPPED_BASE;
7501 +
7502 +#ifdef CONFIG_PAX_RANDMMAP
7503 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7504 + mm->mmap_base += mm->delta_mmap;
7505 +#endif
7506 +
7507 mm->get_unmapped_area = s390_get_unmapped_area;
7508 mm->unmap_area = arch_unmap_area;
7509 } else {
7510 mm->mmap_base = mmap_base();
7511 +
7512 +#ifdef CONFIG_PAX_RANDMMAP
7513 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7514 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7515 +#endif
7516 +
7517 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7518 mm->unmap_area = arch_unmap_area_topdown;
7519 }
7520 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7521 index ae3d59f..f65f075 100644
7522 --- a/arch/score/include/asm/cache.h
7523 +++ b/arch/score/include/asm/cache.h
7524 @@ -1,7 +1,9 @@
7525 #ifndef _ASM_SCORE_CACHE_H
7526 #define _ASM_SCORE_CACHE_H
7527
7528 +#include <linux/const.h>
7529 +
7530 #define L1_CACHE_SHIFT 4
7531 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7532 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7533
7534 #endif /* _ASM_SCORE_CACHE_H */
7535 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7536 index f9f3cd5..58ff438 100644
7537 --- a/arch/score/include/asm/exec.h
7538 +++ b/arch/score/include/asm/exec.h
7539 @@ -1,6 +1,6 @@
7540 #ifndef _ASM_SCORE_EXEC_H
7541 #define _ASM_SCORE_EXEC_H
7542
7543 -extern unsigned long arch_align_stack(unsigned long sp);
7544 +#define arch_align_stack(x) (x)
7545
7546 #endif /* _ASM_SCORE_EXEC_H */
7547 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7548 index 7956846..5f37677 100644
7549 --- a/arch/score/kernel/process.c
7550 +++ b/arch/score/kernel/process.c
7551 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7552
7553 return task_pt_regs(task)->cp0_epc;
7554 }
7555 -
7556 -unsigned long arch_align_stack(unsigned long sp)
7557 -{
7558 - return sp;
7559 -}
7560 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7561 index ef9e555..331bd29 100644
7562 --- a/arch/sh/include/asm/cache.h
7563 +++ b/arch/sh/include/asm/cache.h
7564 @@ -9,10 +9,11 @@
7565 #define __ASM_SH_CACHE_H
7566 #ifdef __KERNEL__
7567
7568 +#include <linux/const.h>
7569 #include <linux/init.h>
7570 #include <cpu/cache.h>
7571
7572 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7573 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7574
7575 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7576
7577 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7578 index 03f2b55..b027032 100644
7579 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7580 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7581 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7582 return NOTIFY_OK;
7583 }
7584
7585 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7586 +static struct notifier_block shx3_cpu_notifier = {
7587 .notifier_call = shx3_cpu_callback,
7588 };
7589
7590 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7591 index 6777177..cb5e44f 100644
7592 --- a/arch/sh/mm/mmap.c
7593 +++ b/arch/sh/mm/mmap.c
7594 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7595 struct mm_struct *mm = current->mm;
7596 struct vm_area_struct *vma;
7597 int do_colour_align;
7598 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7599 struct vm_unmapped_area_info info;
7600
7601 if (flags & MAP_FIXED) {
7602 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7603 if (filp || (flags & MAP_SHARED))
7604 do_colour_align = 1;
7605
7606 +#ifdef CONFIG_PAX_RANDMMAP
7607 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7608 +#endif
7609 +
7610 if (addr) {
7611 if (do_colour_align)
7612 addr = COLOUR_ALIGN(addr, pgoff);
7613 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7614 addr = PAGE_ALIGN(addr);
7615
7616 vma = find_vma(mm, addr);
7617 - if (TASK_SIZE - len >= addr &&
7618 - (!vma || addr + len <= vma->vm_start))
7619 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7620 return addr;
7621 }
7622
7623 info.flags = 0;
7624 info.length = len;
7625 - info.low_limit = TASK_UNMAPPED_BASE;
7626 + info.low_limit = mm->mmap_base;
7627 info.high_limit = TASK_SIZE;
7628 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7629 info.align_offset = pgoff << PAGE_SHIFT;
7630 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7631 struct mm_struct *mm = current->mm;
7632 unsigned long addr = addr0;
7633 int do_colour_align;
7634 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7635 struct vm_unmapped_area_info info;
7636
7637 if (flags & MAP_FIXED) {
7638 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7639 if (filp || (flags & MAP_SHARED))
7640 do_colour_align = 1;
7641
7642 +#ifdef CONFIG_PAX_RANDMMAP
7643 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7644 +#endif
7645 +
7646 /* requesting a specific address */
7647 if (addr) {
7648 if (do_colour_align)
7649 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7650 addr = PAGE_ALIGN(addr);
7651
7652 vma = find_vma(mm, addr);
7653 - if (TASK_SIZE - len >= addr &&
7654 - (!vma || addr + len <= vma->vm_start))
7655 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7656 return addr;
7657 }
7658
7659 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7660 VM_BUG_ON(addr != -ENOMEM);
7661 info.flags = 0;
7662 info.low_limit = TASK_UNMAPPED_BASE;
7663 +
7664 +#ifdef CONFIG_PAX_RANDMMAP
7665 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7666 + info.low_limit += mm->delta_mmap;
7667 +#endif
7668 +
7669 info.high_limit = TASK_SIZE;
7670 addr = vm_unmapped_area(&info);
7671 }
7672 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7673 index be56a24..443328f 100644
7674 --- a/arch/sparc/include/asm/atomic_64.h
7675 +++ b/arch/sparc/include/asm/atomic_64.h
7676 @@ -14,18 +14,40 @@
7677 #define ATOMIC64_INIT(i) { (i) }
7678
7679 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7680 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7681 +{
7682 + return v->counter;
7683 +}
7684 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7685 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7686 +{
7687 + return v->counter;
7688 +}
7689
7690 #define atomic_set(v, i) (((v)->counter) = i)
7691 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7692 +{
7693 + v->counter = i;
7694 +}
7695 #define atomic64_set(v, i) (((v)->counter) = i)
7696 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7697 +{
7698 + v->counter = i;
7699 +}
7700
7701 extern void atomic_add(int, atomic_t *);
7702 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7703 extern void atomic64_add(long, atomic64_t *);
7704 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7705 extern void atomic_sub(int, atomic_t *);
7706 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7707 extern void atomic64_sub(long, atomic64_t *);
7708 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7709
7710 extern int atomic_add_ret(int, atomic_t *);
7711 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7712 extern long atomic64_add_ret(long, atomic64_t *);
7713 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7714 extern int atomic_sub_ret(int, atomic_t *);
7715 extern long atomic64_sub_ret(long, atomic64_t *);
7716
7717 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7718 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7719
7720 #define atomic_inc_return(v) atomic_add_ret(1, v)
7721 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7722 +{
7723 + return atomic_add_ret_unchecked(1, v);
7724 +}
7725 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7726 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7727 +{
7728 + return atomic64_add_ret_unchecked(1, v);
7729 +}
7730
7731 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7732 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7733
7734 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7735 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7736 +{
7737 + return atomic_add_ret_unchecked(i, v);
7738 +}
7739 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7740 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7741 +{
7742 + return atomic64_add_ret_unchecked(i, v);
7743 +}
7744
7745 /*
7746 * atomic_inc_and_test - increment and test
7747 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7748 * other cases.
7749 */
7750 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7751 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7752 +{
7753 + return atomic_inc_return_unchecked(v) == 0;
7754 +}
7755 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7756
7757 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7758 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7759 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7760
7761 #define atomic_inc(v) atomic_add(1, v)
7762 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7763 +{
7764 + atomic_add_unchecked(1, v);
7765 +}
7766 #define atomic64_inc(v) atomic64_add(1, v)
7767 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7768 +{
7769 + atomic64_add_unchecked(1, v);
7770 +}
7771
7772 #define atomic_dec(v) atomic_sub(1, v)
7773 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7774 +{
7775 + atomic_sub_unchecked(1, v);
7776 +}
7777 #define atomic64_dec(v) atomic64_sub(1, v)
7778 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7779 +{
7780 + atomic64_sub_unchecked(1, v);
7781 +}
7782
7783 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7784 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7785
7786 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7787 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7788 +{
7789 + return cmpxchg(&v->counter, old, new);
7790 +}
7791 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7792 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7793 +{
7794 + return xchg(&v->counter, new);
7795 +}
7796
7797 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7798 {
7799 - int c, old;
7800 + int c, old, new;
7801 c = atomic_read(v);
7802 for (;;) {
7803 - if (unlikely(c == (u)))
7804 + if (unlikely(c == u))
7805 break;
7806 - old = atomic_cmpxchg((v), c, c + (a));
7807 +
7808 + asm volatile("addcc %2, %0, %0\n"
7809 +
7810 +#ifdef CONFIG_PAX_REFCOUNT
7811 + "tvs %%icc, 6\n"
7812 +#endif
7813 +
7814 + : "=r" (new)
7815 + : "0" (c), "ir" (a)
7816 + : "cc");
7817 +
7818 + old = atomic_cmpxchg(v, c, new);
7819 if (likely(old == c))
7820 break;
7821 c = old;
7822 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7823 #define atomic64_cmpxchg(v, o, n) \
7824 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7825 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7826 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7827 +{
7828 + return xchg(&v->counter, new);
7829 +}
7830
7831 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7832 {
7833 - long c, old;
7834 + long c, old, new;
7835 c = atomic64_read(v);
7836 for (;;) {
7837 - if (unlikely(c == (u)))
7838 + if (unlikely(c == u))
7839 break;
7840 - old = atomic64_cmpxchg((v), c, c + (a));
7841 +
7842 + asm volatile("addcc %2, %0, %0\n"
7843 +
7844 +#ifdef CONFIG_PAX_REFCOUNT
7845 + "tvs %%xcc, 6\n"
7846 +#endif
7847 +
7848 + : "=r" (new)
7849 + : "0" (c), "ir" (a)
7850 + : "cc");
7851 +
7852 + old = atomic64_cmpxchg(v, c, new);
7853 if (likely(old == c))
7854 break;
7855 c = old;
7856 }
7857 - return c != (u);
7858 + return c != u;
7859 }
7860
7861 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7862 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7863 index 5bb6991..5c2132e 100644
7864 --- a/arch/sparc/include/asm/cache.h
7865 +++ b/arch/sparc/include/asm/cache.h
7866 @@ -7,10 +7,12 @@
7867 #ifndef _SPARC_CACHE_H
7868 #define _SPARC_CACHE_H
7869
7870 +#include <linux/const.h>
7871 +
7872 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7873
7874 #define L1_CACHE_SHIFT 5
7875 -#define L1_CACHE_BYTES 32
7876 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7877
7878 #ifdef CONFIG_SPARC32
7879 #define SMP_CACHE_BYTES_SHIFT 5
7880 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7881 index ac74a2c..a9e58af 100644
7882 --- a/arch/sparc/include/asm/elf_32.h
7883 +++ b/arch/sparc/include/asm/elf_32.h
7884 @@ -114,6 +114,13 @@ typedef struct {
7885
7886 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7887
7888 +#ifdef CONFIG_PAX_ASLR
7889 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7890 +
7891 +#define PAX_DELTA_MMAP_LEN 16
7892 +#define PAX_DELTA_STACK_LEN 16
7893 +#endif
7894 +
7895 /* This yields a mask that user programs can use to figure out what
7896 instruction set this cpu supports. This can NOT be done in userspace
7897 on Sparc. */
7898 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7899 index 370ca1e..d4f4a98 100644
7900 --- a/arch/sparc/include/asm/elf_64.h
7901 +++ b/arch/sparc/include/asm/elf_64.h
7902 @@ -189,6 +189,13 @@ typedef struct {
7903 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7904 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7905
7906 +#ifdef CONFIG_PAX_ASLR
7907 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7908 +
7909 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7910 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7911 +#endif
7912 +
7913 extern unsigned long sparc64_elf_hwcap;
7914 #define ELF_HWCAP sparc64_elf_hwcap
7915
7916 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7917 index 9b1c36d..209298b 100644
7918 --- a/arch/sparc/include/asm/pgalloc_32.h
7919 +++ b/arch/sparc/include/asm/pgalloc_32.h
7920 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7921 }
7922
7923 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7924 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7925
7926 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7927 unsigned long address)
7928 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7929 index bcfe063..b333142 100644
7930 --- a/arch/sparc/include/asm/pgalloc_64.h
7931 +++ b/arch/sparc/include/asm/pgalloc_64.h
7932 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7933 }
7934
7935 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7936 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7937
7938 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7939 {
7940 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7941 index 6fc1348..390c50a 100644
7942 --- a/arch/sparc/include/asm/pgtable_32.h
7943 +++ b/arch/sparc/include/asm/pgtable_32.h
7944 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7945 #define PAGE_SHARED SRMMU_PAGE_SHARED
7946 #define PAGE_COPY SRMMU_PAGE_COPY
7947 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7948 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7949 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7950 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7951 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7952
7953 /* Top-level page directory - dummy used by init-mm.
7954 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7955
7956 /* xwr */
7957 #define __P000 PAGE_NONE
7958 -#define __P001 PAGE_READONLY
7959 -#define __P010 PAGE_COPY
7960 -#define __P011 PAGE_COPY
7961 +#define __P001 PAGE_READONLY_NOEXEC
7962 +#define __P010 PAGE_COPY_NOEXEC
7963 +#define __P011 PAGE_COPY_NOEXEC
7964 #define __P100 PAGE_READONLY
7965 #define __P101 PAGE_READONLY
7966 #define __P110 PAGE_COPY
7967 #define __P111 PAGE_COPY
7968
7969 #define __S000 PAGE_NONE
7970 -#define __S001 PAGE_READONLY
7971 -#define __S010 PAGE_SHARED
7972 -#define __S011 PAGE_SHARED
7973 +#define __S001 PAGE_READONLY_NOEXEC
7974 +#define __S010 PAGE_SHARED_NOEXEC
7975 +#define __S011 PAGE_SHARED_NOEXEC
7976 #define __S100 PAGE_READONLY
7977 #define __S101 PAGE_READONLY
7978 #define __S110 PAGE_SHARED
7979 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7980 index 79da178..c2eede8 100644
7981 --- a/arch/sparc/include/asm/pgtsrmmu.h
7982 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7983 @@ -115,6 +115,11 @@
7984 SRMMU_EXEC | SRMMU_REF)
7985 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7986 SRMMU_EXEC | SRMMU_REF)
7987 +
7988 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7989 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7990 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7991 +
7992 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7993 SRMMU_DIRTY | SRMMU_REF)
7994
7995 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7996 index 9689176..63c18ea 100644
7997 --- a/arch/sparc/include/asm/spinlock_64.h
7998 +++ b/arch/sparc/include/asm/spinlock_64.h
7999 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8000
8001 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8002
8003 -static void inline arch_read_lock(arch_rwlock_t *lock)
8004 +static inline void arch_read_lock(arch_rwlock_t *lock)
8005 {
8006 unsigned long tmp1, tmp2;
8007
8008 __asm__ __volatile__ (
8009 "1: ldsw [%2], %0\n"
8010 " brlz,pn %0, 2f\n"
8011 -"4: add %0, 1, %1\n"
8012 +"4: addcc %0, 1, %1\n"
8013 +
8014 +#ifdef CONFIG_PAX_REFCOUNT
8015 +" tvs %%icc, 6\n"
8016 +#endif
8017 +
8018 " cas [%2], %0, %1\n"
8019 " cmp %0, %1\n"
8020 " bne,pn %%icc, 1b\n"
8021 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8022 " .previous"
8023 : "=&r" (tmp1), "=&r" (tmp2)
8024 : "r" (lock)
8025 - : "memory");
8026 + : "memory", "cc");
8027 }
8028
8029 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8030 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8031 {
8032 int tmp1, tmp2;
8033
8034 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8035 "1: ldsw [%2], %0\n"
8036 " brlz,a,pn %0, 2f\n"
8037 " mov 0, %0\n"
8038 -" add %0, 1, %1\n"
8039 +" addcc %0, 1, %1\n"
8040 +
8041 +#ifdef CONFIG_PAX_REFCOUNT
8042 +" tvs %%icc, 6\n"
8043 +#endif
8044 +
8045 " cas [%2], %0, %1\n"
8046 " cmp %0, %1\n"
8047 " bne,pn %%icc, 1b\n"
8048 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8049 return tmp1;
8050 }
8051
8052 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8053 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8054 {
8055 unsigned long tmp1, tmp2;
8056
8057 __asm__ __volatile__(
8058 "1: lduw [%2], %0\n"
8059 -" sub %0, 1, %1\n"
8060 +" subcc %0, 1, %1\n"
8061 +
8062 +#ifdef CONFIG_PAX_REFCOUNT
8063 +" tvs %%icc, 6\n"
8064 +#endif
8065 +
8066 " cas [%2], %0, %1\n"
8067 " cmp %0, %1\n"
8068 " bne,pn %%xcc, 1b\n"
8069 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8070 : "memory");
8071 }
8072
8073 -static void inline arch_write_lock(arch_rwlock_t *lock)
8074 +static inline void arch_write_lock(arch_rwlock_t *lock)
8075 {
8076 unsigned long mask, tmp1, tmp2;
8077
8078 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8079 : "memory");
8080 }
8081
8082 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8083 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8084 {
8085 __asm__ __volatile__(
8086 " stw %%g0, [%0]"
8087 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8088 : "memory");
8089 }
8090
8091 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8092 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8093 {
8094 unsigned long mask, tmp1, tmp2, result;
8095
8096 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8097 index 25849ae..924c54b 100644
8098 --- a/arch/sparc/include/asm/thread_info_32.h
8099 +++ b/arch/sparc/include/asm/thread_info_32.h
8100 @@ -49,6 +49,8 @@ struct thread_info {
8101 unsigned long w_saved;
8102
8103 struct restart_block restart_block;
8104 +
8105 + unsigned long lowest_stack;
8106 };
8107
8108 /*
8109 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8110 index 269bd92..e46a9b8 100644
8111 --- a/arch/sparc/include/asm/thread_info_64.h
8112 +++ b/arch/sparc/include/asm/thread_info_64.h
8113 @@ -63,6 +63,8 @@ struct thread_info {
8114 struct pt_regs *kern_una_regs;
8115 unsigned int kern_una_insn;
8116
8117 + unsigned long lowest_stack;
8118 +
8119 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8120 };
8121
8122 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8123 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8124 /* flag bit 6 is available */
8125 #define TIF_32BIT 7 /* 32-bit binary */
8126 -/* flag bit 8 is available */
8127 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8128 #define TIF_SECCOMP 9 /* secure computing */
8129 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8130 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8131 +
8132 /* NOTE: Thread flags >= 12 should be ones we have no interest
8133 * in using in assembly, else we can't use the mask as
8134 * an immediate value in instructions such as andcc.
8135 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8136 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8137 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8138 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8139 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8140
8141 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8142 _TIF_DO_NOTIFY_RESUME_MASK | \
8143 _TIF_NEED_RESCHED)
8144 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8145
8146 +#define _TIF_WORK_SYSCALL \
8147 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8148 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8149 +
8150 +
8151 /*
8152 * Thread-synchronous status.
8153 *
8154 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8155 index 0167d26..9acd8ed 100644
8156 --- a/arch/sparc/include/asm/uaccess.h
8157 +++ b/arch/sparc/include/asm/uaccess.h
8158 @@ -1,5 +1,13 @@
8159 #ifndef ___ASM_SPARC_UACCESS_H
8160 #define ___ASM_SPARC_UACCESS_H
8161 +
8162 +#ifdef __KERNEL__
8163 +#ifndef __ASSEMBLY__
8164 +#include <linux/types.h>
8165 +extern void check_object_size(const void *ptr, unsigned long n, bool to);
8166 +#endif
8167 +#endif
8168 +
8169 #if defined(__sparc__) && defined(__arch64__)
8170 #include <asm/uaccess_64.h>
8171 #else
8172 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8173 index 53a28dd..50c38c3 100644
8174 --- a/arch/sparc/include/asm/uaccess_32.h
8175 +++ b/arch/sparc/include/asm/uaccess_32.h
8176 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8177
8178 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8179 {
8180 - if (n && __access_ok((unsigned long) to, n))
8181 + if ((long)n < 0)
8182 + return n;
8183 +
8184 + if (n && __access_ok((unsigned long) to, n)) {
8185 + if (!__builtin_constant_p(n))
8186 + check_object_size(from, n, true);
8187 return __copy_user(to, (__force void __user *) from, n);
8188 - else
8189 + } else
8190 return n;
8191 }
8192
8193 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8194 {
8195 + if ((long)n < 0)
8196 + return n;
8197 +
8198 + if (!__builtin_constant_p(n))
8199 + check_object_size(from, n, true);
8200 +
8201 return __copy_user(to, (__force void __user *) from, n);
8202 }
8203
8204 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8205 {
8206 - if (n && __access_ok((unsigned long) from, n))
8207 + if ((long)n < 0)
8208 + return n;
8209 +
8210 + if (n && __access_ok((unsigned long) from, n)) {
8211 + if (!__builtin_constant_p(n))
8212 + check_object_size(to, n, false);
8213 return __copy_user((__force void __user *) to, from, n);
8214 - else
8215 + } else
8216 return n;
8217 }
8218
8219 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8220 {
8221 + if ((long)n < 0)
8222 + return n;
8223 +
8224 return __copy_user((__force void __user *) to, from, n);
8225 }
8226
8227 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8228 index e562d3c..191f176 100644
8229 --- a/arch/sparc/include/asm/uaccess_64.h
8230 +++ b/arch/sparc/include/asm/uaccess_64.h
8231 @@ -10,6 +10,7 @@
8232 #include <linux/compiler.h>
8233 #include <linux/string.h>
8234 #include <linux/thread_info.h>
8235 +#include <linux/kernel.h>
8236 #include <asm/asi.h>
8237 #include <asm/spitfire.h>
8238 #include <asm-generic/uaccess-unaligned.h>
8239 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8240 static inline unsigned long __must_check
8241 copy_from_user(void *to, const void __user *from, unsigned long size)
8242 {
8243 - unsigned long ret = ___copy_from_user(to, from, size);
8244 + unsigned long ret;
8245
8246 + if ((long)size < 0 || size > INT_MAX)
8247 + return size;
8248 +
8249 + if (!__builtin_constant_p(size))
8250 + check_object_size(to, size, false);
8251 +
8252 + ret = ___copy_from_user(to, from, size);
8253 if (unlikely(ret))
8254 ret = copy_from_user_fixup(to, from, size);
8255
8256 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8257 static inline unsigned long __must_check
8258 copy_to_user(void __user *to, const void *from, unsigned long size)
8259 {
8260 - unsigned long ret = ___copy_to_user(to, from, size);
8261 + unsigned long ret;
8262
8263 + if ((long)size < 0 || size > INT_MAX)
8264 + return size;
8265 +
8266 + if (!__builtin_constant_p(size))
8267 + check_object_size(from, size, true);
8268 +
8269 + ret = ___copy_to_user(to, from, size);
8270 if (unlikely(ret))
8271 ret = copy_to_user_fixup(to, from, size);
8272 return ret;
8273 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8274 index 6cf591b..b49e65a 100644
8275 --- a/arch/sparc/kernel/Makefile
8276 +++ b/arch/sparc/kernel/Makefile
8277 @@ -3,7 +3,7 @@
8278 #
8279
8280 asflags-y := -ansi
8281 -ccflags-y := -Werror
8282 +#ccflags-y := -Werror
8283
8284 extra-y := head_$(BITS).o
8285
8286 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8287 index be8e862..5b50b12 100644
8288 --- a/arch/sparc/kernel/process_32.c
8289 +++ b/arch/sparc/kernel/process_32.c
8290 @@ -126,14 +126,14 @@ void show_regs(struct pt_regs *r)
8291
8292 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8293 r->psr, r->pc, r->npc, r->y, print_tainted());
8294 - printk("PC: <%pS>\n", (void *) r->pc);
8295 + printk("PC: <%pA>\n", (void *) r->pc);
8296 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8297 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8298 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8299 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8300 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8301 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8302 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8303 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8304
8305 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8306 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8307 @@ -168,7 +168,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8308 rw = (struct reg_window32 *) fp;
8309 pc = rw->ins[7];
8310 printk("[%08lx : ", pc);
8311 - printk("%pS ] ", (void *) pc);
8312 + printk("%pA ] ", (void *) pc);
8313 fp = rw->ins[6];
8314 } while (++count < 16);
8315 printk("\n");
8316 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8317 index cdb80b2..5ca141d 100644
8318 --- a/arch/sparc/kernel/process_64.c
8319 +++ b/arch/sparc/kernel/process_64.c
8320 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8321 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8322 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8323 if (regs->tstate & TSTATE_PRIV)
8324 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8325 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8326 }
8327
8328 void show_regs(struct pt_regs *regs)
8329 {
8330 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8331 regs->tpc, regs->tnpc, regs->y, print_tainted());
8332 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8333 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8334 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8335 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8336 regs->u_regs[3]);
8337 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8338 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8339 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8340 regs->u_regs[15]);
8341 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8342 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8343 show_regwindow(regs);
8344 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8345 }
8346 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8347 ((tp && tp->task) ? tp->task->pid : -1));
8348
8349 if (gp->tstate & TSTATE_PRIV) {
8350 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8351 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8352 (void *) gp->tpc,
8353 (void *) gp->o7,
8354 (void *) gp->i7,
8355 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8356 index 7ff45e4..a58f271 100644
8357 --- a/arch/sparc/kernel/ptrace_64.c
8358 +++ b/arch/sparc/kernel/ptrace_64.c
8359 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8360 return ret;
8361 }
8362
8363 +#ifdef CONFIG_GRKERNSEC_SETXID
8364 +extern void gr_delayed_cred_worker(void);
8365 +#endif
8366 +
8367 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8368 {
8369 int ret = 0;
8370 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8371 /* do the secure computing check first */
8372 secure_computing_strict(regs->u_regs[UREG_G1]);
8373
8374 +#ifdef CONFIG_GRKERNSEC_SETXID
8375 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8376 + gr_delayed_cred_worker();
8377 +#endif
8378 +
8379 if (test_thread_flag(TIF_SYSCALL_TRACE))
8380 ret = tracehook_report_syscall_entry(regs);
8381
8382 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8383
8384 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8385 {
8386 +#ifdef CONFIG_GRKERNSEC_SETXID
8387 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8388 + gr_delayed_cred_worker();
8389 +#endif
8390 +
8391 audit_syscall_exit(regs);
8392
8393 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8394 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8395 index 2da0bdc..79128d2 100644
8396 --- a/arch/sparc/kernel/sys_sparc_32.c
8397 +++ b/arch/sparc/kernel/sys_sparc_32.c
8398 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8399 if (len > TASK_SIZE - PAGE_SIZE)
8400 return -ENOMEM;
8401 if (!addr)
8402 - addr = TASK_UNMAPPED_BASE;
8403 + addr = current->mm->mmap_base;
8404
8405 info.flags = 0;
8406 info.length = len;
8407 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8408 index 708bc29..f0129cb 100644
8409 --- a/arch/sparc/kernel/sys_sparc_64.c
8410 +++ b/arch/sparc/kernel/sys_sparc_64.c
8411 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8412 struct vm_area_struct * vma;
8413 unsigned long task_size = TASK_SIZE;
8414 int do_color_align;
8415 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8416 struct vm_unmapped_area_info info;
8417
8418 if (flags & MAP_FIXED) {
8419 /* We do not accept a shared mapping if it would violate
8420 * cache aliasing constraints.
8421 */
8422 - if ((flags & MAP_SHARED) &&
8423 + if ((filp || (flags & MAP_SHARED)) &&
8424 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8425 return -EINVAL;
8426 return addr;
8427 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8428 if (filp || (flags & MAP_SHARED))
8429 do_color_align = 1;
8430
8431 +#ifdef CONFIG_PAX_RANDMMAP
8432 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8433 +#endif
8434 +
8435 if (addr) {
8436 if (do_color_align)
8437 addr = COLOR_ALIGN(addr, pgoff);
8438 @@ -118,14 +123,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8439 addr = PAGE_ALIGN(addr);
8440
8441 vma = find_vma(mm, addr);
8442 - if (task_size - len >= addr &&
8443 - (!vma || addr + len <= vma->vm_start))
8444 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8445 return addr;
8446 }
8447
8448 info.flags = 0;
8449 info.length = len;
8450 - info.low_limit = TASK_UNMAPPED_BASE;
8451 + info.low_limit = mm->mmap_base;
8452 info.high_limit = min(task_size, VA_EXCLUDE_START);
8453 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8454 info.align_offset = pgoff << PAGE_SHIFT;
8455 @@ -134,6 +138,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8456 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8457 VM_BUG_ON(addr != -ENOMEM);
8458 info.low_limit = VA_EXCLUDE_END;
8459 +
8460 +#ifdef CONFIG_PAX_RANDMMAP
8461 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8462 + info.low_limit += mm->delta_mmap;
8463 +#endif
8464 +
8465 info.high_limit = task_size;
8466 addr = vm_unmapped_area(&info);
8467 }
8468 @@ -151,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8469 unsigned long task_size = STACK_TOP32;
8470 unsigned long addr = addr0;
8471 int do_color_align;
8472 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8473 struct vm_unmapped_area_info info;
8474
8475 /* This should only ever run for 32-bit processes. */
8476 @@ -160,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8477 /* We do not accept a shared mapping if it would violate
8478 * cache aliasing constraints.
8479 */
8480 - if ((flags & MAP_SHARED) &&
8481 + if ((filp || (flags & MAP_SHARED)) &&
8482 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8483 return -EINVAL;
8484 return addr;
8485 @@ -173,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8486 if (filp || (flags & MAP_SHARED))
8487 do_color_align = 1;
8488
8489 +#ifdef CONFIG_PAX_RANDMMAP
8490 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8491 +#endif
8492 +
8493 /* requesting a specific address */
8494 if (addr) {
8495 if (do_color_align)
8496 @@ -181,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8497 addr = PAGE_ALIGN(addr);
8498
8499 vma = find_vma(mm, addr);
8500 - if (task_size - len >= addr &&
8501 - (!vma || addr + len <= vma->vm_start))
8502 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8503 return addr;
8504 }
8505
8506 @@ -204,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8507 VM_BUG_ON(addr != -ENOMEM);
8508 info.flags = 0;
8509 info.low_limit = TASK_UNMAPPED_BASE;
8510 +
8511 +#ifdef CONFIG_PAX_RANDMMAP
8512 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8513 + info.low_limit += mm->delta_mmap;
8514 +#endif
8515 +
8516 info.high_limit = STACK_TOP32;
8517 addr = vm_unmapped_area(&info);
8518 }
8519 @@ -264,6 +284,10 @@ static unsigned long mmap_rnd(void)
8520 {
8521 unsigned long rnd = 0UL;
8522
8523 +#ifdef CONFIG_PAX_RANDMMAP
8524 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8525 +#endif
8526 +
8527 if (current->flags & PF_RANDOMIZE) {
8528 unsigned long val = get_random_int();
8529 if (test_thread_flag(TIF_32BIT))
8530 @@ -289,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8531 gap == RLIM_INFINITY ||
8532 sysctl_legacy_va_layout) {
8533 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8534 +
8535 +#ifdef CONFIG_PAX_RANDMMAP
8536 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8537 + mm->mmap_base += mm->delta_mmap;
8538 +#endif
8539 +
8540 mm->get_unmapped_area = arch_get_unmapped_area;
8541 mm->unmap_area = arch_unmap_area;
8542 } else {
8543 @@ -301,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8544 gap = (task_size / 6 * 5);
8545
8546 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8547 +
8548 +#ifdef CONFIG_PAX_RANDMMAP
8549 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8550 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8551 +#endif
8552 +
8553 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8554 mm->unmap_area = arch_unmap_area_topdown;
8555 }
8556 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8557 index e0fed77..604a7e5 100644
8558 --- a/arch/sparc/kernel/syscalls.S
8559 +++ b/arch/sparc/kernel/syscalls.S
8560 @@ -58,7 +58,7 @@ sys32_rt_sigreturn:
8561 #endif
8562 .align 32
8563 1: ldx [%g6 + TI_FLAGS], %l5
8564 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8565 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8566 be,pt %icc, rtrap
8567 nop
8568 call syscall_trace_leave
8569 @@ -190,7 +190,7 @@ linux_sparc_syscall32:
8570
8571 srl %i5, 0, %o5 ! IEU1
8572 srl %i2, 0, %o2 ! IEU0 Group
8573 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8574 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8575 bne,pn %icc, linux_syscall_trace32 ! CTI
8576 mov %i0, %l5 ! IEU1
8577 call %l7 ! CTI Group brk forced
8578 @@ -213,7 +213,7 @@ linux_sparc_syscall:
8579
8580 mov %i3, %o3 ! IEU1
8581 mov %i4, %o4 ! IEU0 Group
8582 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8583 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8584 bne,pn %icc, linux_syscall_trace ! CTI Group
8585 mov %i0, %l5 ! IEU0
8586 2: call %l7 ! CTI Group brk forced
8587 @@ -229,7 +229,7 @@ ret_sys_call:
8588
8589 cmp %o0, -ERESTART_RESTARTBLOCK
8590 bgeu,pn %xcc, 1f
8591 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8592 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8593 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8594
8595 2:
8596 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8597 index 654e8aa..45f431b 100644
8598 --- a/arch/sparc/kernel/sysfs.c
8599 +++ b/arch/sparc/kernel/sysfs.c
8600 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8601 return NOTIFY_OK;
8602 }
8603
8604 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8605 +static struct notifier_block sysfs_cpu_nb = {
8606 .notifier_call = sysfs_cpu_notify,
8607 };
8608
8609 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8610 index a5785ea..405c5f7 100644
8611 --- a/arch/sparc/kernel/traps_32.c
8612 +++ b/arch/sparc/kernel/traps_32.c
8613 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8614 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8615 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8616
8617 +extern void gr_handle_kernel_exploit(void);
8618 +
8619 void die_if_kernel(char *str, struct pt_regs *regs)
8620 {
8621 static int die_counter;
8622 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8623 count++ < 30 &&
8624 (((unsigned long) rw) >= PAGE_OFFSET) &&
8625 !(((unsigned long) rw) & 0x7)) {
8626 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8627 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8628 (void *) rw->ins[7]);
8629 rw = (struct reg_window32 *)rw->ins[6];
8630 }
8631 }
8632 printk("Instruction DUMP:");
8633 instruction_dump ((unsigned long *) regs->pc);
8634 - if(regs->psr & PSR_PS)
8635 + if(regs->psr & PSR_PS) {
8636 + gr_handle_kernel_exploit();
8637 do_exit(SIGKILL);
8638 + }
8639 do_exit(SIGSEGV);
8640 }
8641
8642 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8643 index e7ecf15..6520e65 100644
8644 --- a/arch/sparc/kernel/traps_64.c
8645 +++ b/arch/sparc/kernel/traps_64.c
8646 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8647 i + 1,
8648 p->trapstack[i].tstate, p->trapstack[i].tpc,
8649 p->trapstack[i].tnpc, p->trapstack[i].tt);
8650 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8651 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8652 }
8653 }
8654
8655 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8656
8657 lvl -= 0x100;
8658 if (regs->tstate & TSTATE_PRIV) {
8659 +
8660 +#ifdef CONFIG_PAX_REFCOUNT
8661 + if (lvl == 6)
8662 + pax_report_refcount_overflow(regs);
8663 +#endif
8664 +
8665 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8666 die_if_kernel(buffer, regs);
8667 }
8668 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8669 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8670 {
8671 char buffer[32];
8672 -
8673 +
8674 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8675 0, lvl, SIGTRAP) == NOTIFY_STOP)
8676 return;
8677
8678 +#ifdef CONFIG_PAX_REFCOUNT
8679 + if (lvl == 6)
8680 + pax_report_refcount_overflow(regs);
8681 +#endif
8682 +
8683 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8684
8685 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8686 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8687 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8688 printk("%s" "ERROR(%d): ",
8689 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8690 - printk("TPC<%pS>\n", (void *) regs->tpc);
8691 + printk("TPC<%pA>\n", (void *) regs->tpc);
8692 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8693 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8694 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8695 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8696 smp_processor_id(),
8697 (type & 0x1) ? 'I' : 'D',
8698 regs->tpc);
8699 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8700 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8701 panic("Irrecoverable Cheetah+ parity error.");
8702 }
8703
8704 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8705 smp_processor_id(),
8706 (type & 0x1) ? 'I' : 'D',
8707 regs->tpc);
8708 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8709 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8710 }
8711
8712 struct sun4v_error_entry {
8713 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8714
8715 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8716 regs->tpc, tl);
8717 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8718 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8719 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8720 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8721 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8722 (void *) regs->u_regs[UREG_I7]);
8723 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8724 "pte[%lx] error[%lx]\n",
8725 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8726
8727 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8728 regs->tpc, tl);
8729 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8730 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8731 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8732 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8733 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8734 (void *) regs->u_regs[UREG_I7]);
8735 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8736 "pte[%lx] error[%lx]\n",
8737 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8738 fp = (unsigned long)sf->fp + STACK_BIAS;
8739 }
8740
8741 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8742 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8743 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8744 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8745 int index = tsk->curr_ret_stack;
8746 if (tsk->ret_stack && index >= graph) {
8747 pc = tsk->ret_stack[index - graph].ret;
8748 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8749 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8750 graph++;
8751 }
8752 }
8753 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8754 return (struct reg_window *) (fp + STACK_BIAS);
8755 }
8756
8757 +extern void gr_handle_kernel_exploit(void);
8758 +
8759 void die_if_kernel(char *str, struct pt_regs *regs)
8760 {
8761 static int die_counter;
8762 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8763 while (rw &&
8764 count++ < 30 &&
8765 kstack_valid(tp, (unsigned long) rw)) {
8766 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8767 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8768 (void *) rw->ins[7]);
8769
8770 rw = kernel_stack_up(rw);
8771 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8772 }
8773 user_instruction_dump ((unsigned int __user *) regs->tpc);
8774 }
8775 - if (regs->tstate & TSTATE_PRIV)
8776 + if (regs->tstate & TSTATE_PRIV) {
8777 + gr_handle_kernel_exploit();
8778 do_exit(SIGKILL);
8779 + }
8780 do_exit(SIGSEGV);
8781 }
8782 EXPORT_SYMBOL(die_if_kernel);
8783 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8784 index 8201c25e..072a2a7 100644
8785 --- a/arch/sparc/kernel/unaligned_64.c
8786 +++ b/arch/sparc/kernel/unaligned_64.c
8787 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8788 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8789
8790 if (__ratelimit(&ratelimit)) {
8791 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8792 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8793 regs->tpc, (void *) regs->tpc);
8794 }
8795 }
8796 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8797 index 8410065f2..4fd4ca22 100644
8798 --- a/arch/sparc/lib/Makefile
8799 +++ b/arch/sparc/lib/Makefile
8800 @@ -2,7 +2,7 @@
8801 #
8802
8803 asflags-y := -ansi -DST_DIV0=0x02
8804 -ccflags-y := -Werror
8805 +#ccflags-y := -Werror
8806
8807 lib-$(CONFIG_SPARC32) += ashrdi3.o
8808 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8809 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8810 index 85c233d..68500e0 100644
8811 --- a/arch/sparc/lib/atomic_64.S
8812 +++ b/arch/sparc/lib/atomic_64.S
8813 @@ -17,7 +17,12 @@
8814 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8815 BACKOFF_SETUP(%o2)
8816 1: lduw [%o1], %g1
8817 - add %g1, %o0, %g7
8818 + addcc %g1, %o0, %g7
8819 +
8820 +#ifdef CONFIG_PAX_REFCOUNT
8821 + tvs %icc, 6
8822 +#endif
8823 +
8824 cas [%o1], %g1, %g7
8825 cmp %g1, %g7
8826 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8827 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8828 2: BACKOFF_SPIN(%o2, %o3, 1b)
8829 ENDPROC(atomic_add)
8830
8831 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8832 + BACKOFF_SETUP(%o2)
8833 +1: lduw [%o1], %g1
8834 + add %g1, %o0, %g7
8835 + cas [%o1], %g1, %g7
8836 + cmp %g1, %g7
8837 + bne,pn %icc, 2f
8838 + nop
8839 + retl
8840 + nop
8841 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8842 +ENDPROC(atomic_add_unchecked)
8843 +
8844 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8845 BACKOFF_SETUP(%o2)
8846 1: lduw [%o1], %g1
8847 - sub %g1, %o0, %g7
8848 + subcc %g1, %o0, %g7
8849 +
8850 +#ifdef CONFIG_PAX_REFCOUNT
8851 + tvs %icc, 6
8852 +#endif
8853 +
8854 cas [%o1], %g1, %g7
8855 cmp %g1, %g7
8856 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8857 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8858 2: BACKOFF_SPIN(%o2, %o3, 1b)
8859 ENDPROC(atomic_sub)
8860
8861 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8862 + BACKOFF_SETUP(%o2)
8863 +1: lduw [%o1], %g1
8864 + sub %g1, %o0, %g7
8865 + cas [%o1], %g1, %g7
8866 + cmp %g1, %g7
8867 + bne,pn %icc, 2f
8868 + nop
8869 + retl
8870 + nop
8871 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8872 +ENDPROC(atomic_sub_unchecked)
8873 +
8874 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8875 BACKOFF_SETUP(%o2)
8876 1: lduw [%o1], %g1
8877 - add %g1, %o0, %g7
8878 + addcc %g1, %o0, %g7
8879 +
8880 +#ifdef CONFIG_PAX_REFCOUNT
8881 + tvs %icc, 6
8882 +#endif
8883 +
8884 cas [%o1], %g1, %g7
8885 cmp %g1, %g7
8886 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8887 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8888 2: BACKOFF_SPIN(%o2, %o3, 1b)
8889 ENDPROC(atomic_add_ret)
8890
8891 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8892 + BACKOFF_SETUP(%o2)
8893 +1: lduw [%o1], %g1
8894 + addcc %g1, %o0, %g7
8895 + cas [%o1], %g1, %g7
8896 + cmp %g1, %g7
8897 + bne,pn %icc, 2f
8898 + add %g7, %o0, %g7
8899 + sra %g7, 0, %o0
8900 + retl
8901 + nop
8902 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8903 +ENDPROC(atomic_add_ret_unchecked)
8904 +
8905 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
8906 BACKOFF_SETUP(%o2)
8907 1: lduw [%o1], %g1
8908 - sub %g1, %o0, %g7
8909 + subcc %g1, %o0, %g7
8910 +
8911 +#ifdef CONFIG_PAX_REFCOUNT
8912 + tvs %icc, 6
8913 +#endif
8914 +
8915 cas [%o1], %g1, %g7
8916 cmp %g1, %g7
8917 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8918 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8919 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8920 BACKOFF_SETUP(%o2)
8921 1: ldx [%o1], %g1
8922 - add %g1, %o0, %g7
8923 + addcc %g1, %o0, %g7
8924 +
8925 +#ifdef CONFIG_PAX_REFCOUNT
8926 + tvs %xcc, 6
8927 +#endif
8928 +
8929 casx [%o1], %g1, %g7
8930 cmp %g1, %g7
8931 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8932 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8933 2: BACKOFF_SPIN(%o2, %o3, 1b)
8934 ENDPROC(atomic64_add)
8935
8936 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8937 + BACKOFF_SETUP(%o2)
8938 +1: ldx [%o1], %g1
8939 + addcc %g1, %o0, %g7
8940 + casx [%o1], %g1, %g7
8941 + cmp %g1, %g7
8942 + bne,pn %xcc, 2f
8943 + nop
8944 + retl
8945 + nop
8946 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8947 +ENDPROC(atomic64_add_unchecked)
8948 +
8949 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8950 BACKOFF_SETUP(%o2)
8951 1: ldx [%o1], %g1
8952 - sub %g1, %o0, %g7
8953 + subcc %g1, %o0, %g7
8954 +
8955 +#ifdef CONFIG_PAX_REFCOUNT
8956 + tvs %xcc, 6
8957 +#endif
8958 +
8959 casx [%o1], %g1, %g7
8960 cmp %g1, %g7
8961 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8962 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8963 2: BACKOFF_SPIN(%o2, %o3, 1b)
8964 ENDPROC(atomic64_sub)
8965
8966 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8967 + BACKOFF_SETUP(%o2)
8968 +1: ldx [%o1], %g1
8969 + subcc %g1, %o0, %g7
8970 + casx [%o1], %g1, %g7
8971 + cmp %g1, %g7
8972 + bne,pn %xcc, 2f
8973 + nop
8974 + retl
8975 + nop
8976 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8977 +ENDPROC(atomic64_sub_unchecked)
8978 +
8979 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8980 BACKOFF_SETUP(%o2)
8981 1: ldx [%o1], %g1
8982 - add %g1, %o0, %g7
8983 + addcc %g1, %o0, %g7
8984 +
8985 +#ifdef CONFIG_PAX_REFCOUNT
8986 + tvs %xcc, 6
8987 +#endif
8988 +
8989 casx [%o1], %g1, %g7
8990 cmp %g1, %g7
8991 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8992 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8993 2: BACKOFF_SPIN(%o2, %o3, 1b)
8994 ENDPROC(atomic64_add_ret)
8995
8996 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8997 + BACKOFF_SETUP(%o2)
8998 +1: ldx [%o1], %g1
8999 + addcc %g1, %o0, %g7
9000 + casx [%o1], %g1, %g7
9001 + cmp %g1, %g7
9002 + bne,pn %xcc, 2f
9003 + add %g7, %o0, %g7
9004 + mov %g7, %o0
9005 + retl
9006 + nop
9007 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9008 +ENDPROC(atomic64_add_ret_unchecked)
9009 +
9010 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9011 BACKOFF_SETUP(%o2)
9012 1: ldx [%o1], %g1
9013 - sub %g1, %o0, %g7
9014 + subcc %g1, %o0, %g7
9015 +
9016 +#ifdef CONFIG_PAX_REFCOUNT
9017 + tvs %xcc, 6
9018 +#endif
9019 +
9020 casx [%o1], %g1, %g7
9021 cmp %g1, %g7
9022 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9023 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9024 index 0c4e35e..745d3e4 100644
9025 --- a/arch/sparc/lib/ksyms.c
9026 +++ b/arch/sparc/lib/ksyms.c
9027 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9028
9029 /* Atomic counter implementation. */
9030 EXPORT_SYMBOL(atomic_add);
9031 +EXPORT_SYMBOL(atomic_add_unchecked);
9032 EXPORT_SYMBOL(atomic_add_ret);
9033 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9034 EXPORT_SYMBOL(atomic_sub);
9035 +EXPORT_SYMBOL(atomic_sub_unchecked);
9036 EXPORT_SYMBOL(atomic_sub_ret);
9037 EXPORT_SYMBOL(atomic64_add);
9038 +EXPORT_SYMBOL(atomic64_add_unchecked);
9039 EXPORT_SYMBOL(atomic64_add_ret);
9040 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9041 EXPORT_SYMBOL(atomic64_sub);
9042 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9043 EXPORT_SYMBOL(atomic64_sub_ret);
9044 EXPORT_SYMBOL(atomic64_dec_if_positive);
9045
9046 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9047 index 30c3ecc..736f015 100644
9048 --- a/arch/sparc/mm/Makefile
9049 +++ b/arch/sparc/mm/Makefile
9050 @@ -2,7 +2,7 @@
9051 #
9052
9053 asflags-y := -ansi
9054 -ccflags-y := -Werror
9055 +#ccflags-y := -Werror
9056
9057 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9058 obj-y += fault_$(BITS).o
9059 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9060 index e98bfda..ea8d221 100644
9061 --- a/arch/sparc/mm/fault_32.c
9062 +++ b/arch/sparc/mm/fault_32.c
9063 @@ -21,6 +21,9 @@
9064 #include <linux/perf_event.h>
9065 #include <linux/interrupt.h>
9066 #include <linux/kdebug.h>
9067 +#include <linux/slab.h>
9068 +#include <linux/pagemap.h>
9069 +#include <linux/compiler.h>
9070
9071 #include <asm/page.h>
9072 #include <asm/pgtable.h>
9073 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9074 return safe_compute_effective_address(regs, insn);
9075 }
9076
9077 +#ifdef CONFIG_PAX_PAGEEXEC
9078 +#ifdef CONFIG_PAX_DLRESOLVE
9079 +static void pax_emuplt_close(struct vm_area_struct *vma)
9080 +{
9081 + vma->vm_mm->call_dl_resolve = 0UL;
9082 +}
9083 +
9084 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9085 +{
9086 + unsigned int *kaddr;
9087 +
9088 + vmf->page = alloc_page(GFP_HIGHUSER);
9089 + if (!vmf->page)
9090 + return VM_FAULT_OOM;
9091 +
9092 + kaddr = kmap(vmf->page);
9093 + memset(kaddr, 0, PAGE_SIZE);
9094 + kaddr[0] = 0x9DE3BFA8U; /* save */
9095 + flush_dcache_page(vmf->page);
9096 + kunmap(vmf->page);
9097 + return VM_FAULT_MAJOR;
9098 +}
9099 +
9100 +static const struct vm_operations_struct pax_vm_ops = {
9101 + .close = pax_emuplt_close,
9102 + .fault = pax_emuplt_fault
9103 +};
9104 +
9105 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9106 +{
9107 + int ret;
9108 +
9109 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9110 + vma->vm_mm = current->mm;
9111 + vma->vm_start = addr;
9112 + vma->vm_end = addr + PAGE_SIZE;
9113 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9114 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9115 + vma->vm_ops = &pax_vm_ops;
9116 +
9117 + ret = insert_vm_struct(current->mm, vma);
9118 + if (ret)
9119 + return ret;
9120 +
9121 + ++current->mm->total_vm;
9122 + return 0;
9123 +}
9124 +#endif
9125 +
9126 +/*
9127 + * PaX: decide what to do with offenders (regs->pc = fault address)
9128 + *
9129 + * returns 1 when task should be killed
9130 + * 2 when patched PLT trampoline was detected
9131 + * 3 when unpatched PLT trampoline was detected
9132 + */
9133 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9134 +{
9135 +
9136 +#ifdef CONFIG_PAX_EMUPLT
9137 + int err;
9138 +
9139 + do { /* PaX: patched PLT emulation #1 */
9140 + unsigned int sethi1, sethi2, jmpl;
9141 +
9142 + err = get_user(sethi1, (unsigned int *)regs->pc);
9143 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9144 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9145 +
9146 + if (err)
9147 + break;
9148 +
9149 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9150 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9151 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9152 + {
9153 + unsigned int addr;
9154 +
9155 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9156 + addr = regs->u_regs[UREG_G1];
9157 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9158 + regs->pc = addr;
9159 + regs->npc = addr+4;
9160 + return 2;
9161 + }
9162 + } while (0);
9163 +
9164 + do { /* PaX: patched PLT emulation #2 */
9165 + unsigned int ba;
9166 +
9167 + err = get_user(ba, (unsigned int *)regs->pc);
9168 +
9169 + if (err)
9170 + break;
9171 +
9172 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9173 + unsigned int addr;
9174 +
9175 + if ((ba & 0xFFC00000U) == 0x30800000U)
9176 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9177 + else
9178 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9179 + regs->pc = addr;
9180 + regs->npc = addr+4;
9181 + return 2;
9182 + }
9183 + } while (0);
9184 +
9185 + do { /* PaX: patched PLT emulation #3 */
9186 + unsigned int sethi, bajmpl, nop;
9187 +
9188 + err = get_user(sethi, (unsigned int *)regs->pc);
9189 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9190 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9191 +
9192 + if (err)
9193 + break;
9194 +
9195 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9196 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9197 + nop == 0x01000000U)
9198 + {
9199 + unsigned int addr;
9200 +
9201 + addr = (sethi & 0x003FFFFFU) << 10;
9202 + regs->u_regs[UREG_G1] = addr;
9203 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9204 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9205 + else
9206 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9207 + regs->pc = addr;
9208 + regs->npc = addr+4;
9209 + return 2;
9210 + }
9211 + } while (0);
9212 +
9213 + do { /* PaX: unpatched PLT emulation step 1 */
9214 + unsigned int sethi, ba, nop;
9215 +
9216 + err = get_user(sethi, (unsigned int *)regs->pc);
9217 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9218 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9219 +
9220 + if (err)
9221 + break;
9222 +
9223 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9224 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9225 + nop == 0x01000000U)
9226 + {
9227 + unsigned int addr, save, call;
9228 +
9229 + if ((ba & 0xFFC00000U) == 0x30800000U)
9230 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9231 + else
9232 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9233 +
9234 + err = get_user(save, (unsigned int *)addr);
9235 + err |= get_user(call, (unsigned int *)(addr+4));
9236 + err |= get_user(nop, (unsigned int *)(addr+8));
9237 + if (err)
9238 + break;
9239 +
9240 +#ifdef CONFIG_PAX_DLRESOLVE
9241 + if (save == 0x9DE3BFA8U &&
9242 + (call & 0xC0000000U) == 0x40000000U &&
9243 + nop == 0x01000000U)
9244 + {
9245 + struct vm_area_struct *vma;
9246 + unsigned long call_dl_resolve;
9247 +
9248 + down_read(&current->mm->mmap_sem);
9249 + call_dl_resolve = current->mm->call_dl_resolve;
9250 + up_read(&current->mm->mmap_sem);
9251 + if (likely(call_dl_resolve))
9252 + goto emulate;
9253 +
9254 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9255 +
9256 + down_write(&current->mm->mmap_sem);
9257 + if (current->mm->call_dl_resolve) {
9258 + call_dl_resolve = current->mm->call_dl_resolve;
9259 + up_write(&current->mm->mmap_sem);
9260 + if (vma)
9261 + kmem_cache_free(vm_area_cachep, vma);
9262 + goto emulate;
9263 + }
9264 +
9265 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9266 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9267 + up_write(&current->mm->mmap_sem);
9268 + if (vma)
9269 + kmem_cache_free(vm_area_cachep, vma);
9270 + return 1;
9271 + }
9272 +
9273 + if (pax_insert_vma(vma, call_dl_resolve)) {
9274 + up_write(&current->mm->mmap_sem);
9275 + kmem_cache_free(vm_area_cachep, vma);
9276 + return 1;
9277 + }
9278 +
9279 + current->mm->call_dl_resolve = call_dl_resolve;
9280 + up_write(&current->mm->mmap_sem);
9281 +
9282 +emulate:
9283 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9284 + regs->pc = call_dl_resolve;
9285 + regs->npc = addr+4;
9286 + return 3;
9287 + }
9288 +#endif
9289 +
9290 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9291 + if ((save & 0xFFC00000U) == 0x05000000U &&
9292 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9293 + nop == 0x01000000U)
9294 + {
9295 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9296 + regs->u_regs[UREG_G2] = addr + 4;
9297 + addr = (save & 0x003FFFFFU) << 10;
9298 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9299 + regs->pc = addr;
9300 + regs->npc = addr+4;
9301 + return 3;
9302 + }
9303 + }
9304 + } while (0);
9305 +
9306 + do { /* PaX: unpatched PLT emulation step 2 */
9307 + unsigned int save, call, nop;
9308 +
9309 + err = get_user(save, (unsigned int *)(regs->pc-4));
9310 + err |= get_user(call, (unsigned int *)regs->pc);
9311 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9312 + if (err)
9313 + break;
9314 +
9315 + if (save == 0x9DE3BFA8U &&
9316 + (call & 0xC0000000U) == 0x40000000U &&
9317 + nop == 0x01000000U)
9318 + {
9319 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9320 +
9321 + regs->u_regs[UREG_RETPC] = regs->pc;
9322 + regs->pc = dl_resolve;
9323 + regs->npc = dl_resolve+4;
9324 + return 3;
9325 + }
9326 + } while (0);
9327 +#endif
9328 +
9329 + return 1;
9330 +}
9331 +
9332 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9333 +{
9334 + unsigned long i;
9335 +
9336 + printk(KERN_ERR "PAX: bytes at PC: ");
9337 + for (i = 0; i < 8; i++) {
9338 + unsigned int c;
9339 + if (get_user(c, (unsigned int *)pc+i))
9340 + printk(KERN_CONT "???????? ");
9341 + else
9342 + printk(KERN_CONT "%08x ", c);
9343 + }
9344 + printk("\n");
9345 +}
9346 +#endif
9347 +
9348 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9349 int text_fault)
9350 {
9351 @@ -230,6 +504,24 @@ good_area:
9352 if (!(vma->vm_flags & VM_WRITE))
9353 goto bad_area;
9354 } else {
9355 +
9356 +#ifdef CONFIG_PAX_PAGEEXEC
9357 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9358 + up_read(&mm->mmap_sem);
9359 + switch (pax_handle_fetch_fault(regs)) {
9360 +
9361 +#ifdef CONFIG_PAX_EMUPLT
9362 + case 2:
9363 + case 3:
9364 + return;
9365 +#endif
9366 +
9367 + }
9368 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9369 + do_group_exit(SIGKILL);
9370 + }
9371 +#endif
9372 +
9373 /* Allow reads even for write-only mappings */
9374 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9375 goto bad_area;
9376 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9377 index 5062ff3..e0b75f3 100644
9378 --- a/arch/sparc/mm/fault_64.c
9379 +++ b/arch/sparc/mm/fault_64.c
9380 @@ -21,6 +21,9 @@
9381 #include <linux/kprobes.h>
9382 #include <linux/kdebug.h>
9383 #include <linux/percpu.h>
9384 +#include <linux/slab.h>
9385 +#include <linux/pagemap.h>
9386 +#include <linux/compiler.h>
9387
9388 #include <asm/page.h>
9389 #include <asm/pgtable.h>
9390 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9391 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9392 regs->tpc);
9393 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9394 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9395 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9396 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9397 dump_stack();
9398 unhandled_fault(regs->tpc, current, regs);
9399 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9400 show_regs(regs);
9401 }
9402
9403 +#ifdef CONFIG_PAX_PAGEEXEC
9404 +#ifdef CONFIG_PAX_DLRESOLVE
9405 +static void pax_emuplt_close(struct vm_area_struct *vma)
9406 +{
9407 + vma->vm_mm->call_dl_resolve = 0UL;
9408 +}
9409 +
9410 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9411 +{
9412 + unsigned int *kaddr;
9413 +
9414 + vmf->page = alloc_page(GFP_HIGHUSER);
9415 + if (!vmf->page)
9416 + return VM_FAULT_OOM;
9417 +
9418 + kaddr = kmap(vmf->page);
9419 + memset(kaddr, 0, PAGE_SIZE);
9420 + kaddr[0] = 0x9DE3BFA8U; /* save */
9421 + flush_dcache_page(vmf->page);
9422 + kunmap(vmf->page);
9423 + return VM_FAULT_MAJOR;
9424 +}
9425 +
9426 +static const struct vm_operations_struct pax_vm_ops = {
9427 + .close = pax_emuplt_close,
9428 + .fault = pax_emuplt_fault
9429 +};
9430 +
9431 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9432 +{
9433 + int ret;
9434 +
9435 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9436 + vma->vm_mm = current->mm;
9437 + vma->vm_start = addr;
9438 + vma->vm_end = addr + PAGE_SIZE;
9439 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9440 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9441 + vma->vm_ops = &pax_vm_ops;
9442 +
9443 + ret = insert_vm_struct(current->mm, vma);
9444 + if (ret)
9445 + return ret;
9446 +
9447 + ++current->mm->total_vm;
9448 + return 0;
9449 +}
9450 +#endif
9451 +
9452 +/*
9453 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9454 + *
9455 + * returns 1 when task should be killed
9456 + * 2 when patched PLT trampoline was detected
9457 + * 3 when unpatched PLT trampoline was detected
9458 + */
9459 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9460 +{
9461 +
9462 +#ifdef CONFIG_PAX_EMUPLT
9463 + int err;
9464 +
9465 + do { /* PaX: patched PLT emulation #1 */
9466 + unsigned int sethi1, sethi2, jmpl;
9467 +
9468 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9469 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9470 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9471 +
9472 + if (err)
9473 + break;
9474 +
9475 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9476 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9477 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9478 + {
9479 + unsigned long addr;
9480 +
9481 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9482 + addr = regs->u_regs[UREG_G1];
9483 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9484 +
9485 + if (test_thread_flag(TIF_32BIT))
9486 + addr &= 0xFFFFFFFFUL;
9487 +
9488 + regs->tpc = addr;
9489 + regs->tnpc = addr+4;
9490 + return 2;
9491 + }
9492 + } while (0);
9493 +
9494 + do { /* PaX: patched PLT emulation #2 */
9495 + unsigned int ba;
9496 +
9497 + err = get_user(ba, (unsigned int *)regs->tpc);
9498 +
9499 + if (err)
9500 + break;
9501 +
9502 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9503 + unsigned long addr;
9504 +
9505 + if ((ba & 0xFFC00000U) == 0x30800000U)
9506 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9507 + else
9508 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9509 +
9510 + if (test_thread_flag(TIF_32BIT))
9511 + addr &= 0xFFFFFFFFUL;
9512 +
9513 + regs->tpc = addr;
9514 + regs->tnpc = addr+4;
9515 + return 2;
9516 + }
9517 + } while (0);
9518 +
9519 + do { /* PaX: patched PLT emulation #3 */
9520 + unsigned int sethi, bajmpl, nop;
9521 +
9522 + err = get_user(sethi, (unsigned int *)regs->tpc);
9523 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9524 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9525 +
9526 + if (err)
9527 + break;
9528 +
9529 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9530 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9531 + nop == 0x01000000U)
9532 + {
9533 + unsigned long addr;
9534 +
9535 + addr = (sethi & 0x003FFFFFU) << 10;
9536 + regs->u_regs[UREG_G1] = addr;
9537 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9538 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9539 + else
9540 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9541 +
9542 + if (test_thread_flag(TIF_32BIT))
9543 + addr &= 0xFFFFFFFFUL;
9544 +
9545 + regs->tpc = addr;
9546 + regs->tnpc = addr+4;
9547 + return 2;
9548 + }
9549 + } while (0);
9550 +
9551 + do { /* PaX: patched PLT emulation #4 */
9552 + unsigned int sethi, mov1, call, mov2;
9553 +
9554 + err = get_user(sethi, (unsigned int *)regs->tpc);
9555 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9556 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9557 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9558 +
9559 + if (err)
9560 + break;
9561 +
9562 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9563 + mov1 == 0x8210000FU &&
9564 + (call & 0xC0000000U) == 0x40000000U &&
9565 + mov2 == 0x9E100001U)
9566 + {
9567 + unsigned long addr;
9568 +
9569 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9570 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9571 +
9572 + if (test_thread_flag(TIF_32BIT))
9573 + addr &= 0xFFFFFFFFUL;
9574 +
9575 + regs->tpc = addr;
9576 + regs->tnpc = addr+4;
9577 + return 2;
9578 + }
9579 + } while (0);
9580 +
9581 + do { /* PaX: patched PLT emulation #5 */
9582 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9583 +
9584 + err = get_user(sethi, (unsigned int *)regs->tpc);
9585 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9586 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9587 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9588 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9589 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9590 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9591 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9592 +
9593 + if (err)
9594 + break;
9595 +
9596 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9597 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9598 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9599 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9600 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9601 + sllx == 0x83287020U &&
9602 + jmpl == 0x81C04005U &&
9603 + nop == 0x01000000U)
9604 + {
9605 + unsigned long addr;
9606 +
9607 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9608 + regs->u_regs[UREG_G1] <<= 32;
9609 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9610 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9611 + regs->tpc = addr;
9612 + regs->tnpc = addr+4;
9613 + return 2;
9614 + }
9615 + } while (0);
9616 +
9617 + do { /* PaX: patched PLT emulation #6 */
9618 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9619 +
9620 + err = get_user(sethi, (unsigned int *)regs->tpc);
9621 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9622 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9623 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9624 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9625 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9626 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9627 +
9628 + if (err)
9629 + break;
9630 +
9631 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9632 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9633 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9634 + sllx == 0x83287020U &&
9635 + (or & 0xFFFFE000U) == 0x8A116000U &&
9636 + jmpl == 0x81C04005U &&
9637 + nop == 0x01000000U)
9638 + {
9639 + unsigned long addr;
9640 +
9641 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9642 + regs->u_regs[UREG_G1] <<= 32;
9643 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9644 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9645 + regs->tpc = addr;
9646 + regs->tnpc = addr+4;
9647 + return 2;
9648 + }
9649 + } while (0);
9650 +
9651 + do { /* PaX: unpatched PLT emulation step 1 */
9652 + unsigned int sethi, ba, nop;
9653 +
9654 + err = get_user(sethi, (unsigned int *)regs->tpc);
9655 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9656 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9657 +
9658 + if (err)
9659 + break;
9660 +
9661 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9662 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9663 + nop == 0x01000000U)
9664 + {
9665 + unsigned long addr;
9666 + unsigned int save, call;
9667 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9668 +
9669 + if ((ba & 0xFFC00000U) == 0x30800000U)
9670 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9671 + else
9672 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9673 +
9674 + if (test_thread_flag(TIF_32BIT))
9675 + addr &= 0xFFFFFFFFUL;
9676 +
9677 + err = get_user(save, (unsigned int *)addr);
9678 + err |= get_user(call, (unsigned int *)(addr+4));
9679 + err |= get_user(nop, (unsigned int *)(addr+8));
9680 + if (err)
9681 + break;
9682 +
9683 +#ifdef CONFIG_PAX_DLRESOLVE
9684 + if (save == 0x9DE3BFA8U &&
9685 + (call & 0xC0000000U) == 0x40000000U &&
9686 + nop == 0x01000000U)
9687 + {
9688 + struct vm_area_struct *vma;
9689 + unsigned long call_dl_resolve;
9690 +
9691 + down_read(&current->mm->mmap_sem);
9692 + call_dl_resolve = current->mm->call_dl_resolve;
9693 + up_read(&current->mm->mmap_sem);
9694 + if (likely(call_dl_resolve))
9695 + goto emulate;
9696 +
9697 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9698 +
9699 + down_write(&current->mm->mmap_sem);
9700 + if (current->mm->call_dl_resolve) {
9701 + call_dl_resolve = current->mm->call_dl_resolve;
9702 + up_write(&current->mm->mmap_sem);
9703 + if (vma)
9704 + kmem_cache_free(vm_area_cachep, vma);
9705 + goto emulate;
9706 + }
9707 +
9708 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9709 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9710 + up_write(&current->mm->mmap_sem);
9711 + if (vma)
9712 + kmem_cache_free(vm_area_cachep, vma);
9713 + return 1;
9714 + }
9715 +
9716 + if (pax_insert_vma(vma, call_dl_resolve)) {
9717 + up_write(&current->mm->mmap_sem);
9718 + kmem_cache_free(vm_area_cachep, vma);
9719 + return 1;
9720 + }
9721 +
9722 + current->mm->call_dl_resolve = call_dl_resolve;
9723 + up_write(&current->mm->mmap_sem);
9724 +
9725 +emulate:
9726 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9727 + regs->tpc = call_dl_resolve;
9728 + regs->tnpc = addr+4;
9729 + return 3;
9730 + }
9731 +#endif
9732 +
9733 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9734 + if ((save & 0xFFC00000U) == 0x05000000U &&
9735 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9736 + nop == 0x01000000U)
9737 + {
9738 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9739 + regs->u_regs[UREG_G2] = addr + 4;
9740 + addr = (save & 0x003FFFFFU) << 10;
9741 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9742 +
9743 + if (test_thread_flag(TIF_32BIT))
9744 + addr &= 0xFFFFFFFFUL;
9745 +
9746 + regs->tpc = addr;
9747 + regs->tnpc = addr+4;
9748 + return 3;
9749 + }
9750 +
9751 + /* PaX: 64-bit PLT stub */
9752 + err = get_user(sethi1, (unsigned int *)addr);
9753 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9754 + err |= get_user(or1, (unsigned int *)(addr+8));
9755 + err |= get_user(or2, (unsigned int *)(addr+12));
9756 + err |= get_user(sllx, (unsigned int *)(addr+16));
9757 + err |= get_user(add, (unsigned int *)(addr+20));
9758 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9759 + err |= get_user(nop, (unsigned int *)(addr+28));
9760 + if (err)
9761 + break;
9762 +
9763 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9764 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9765 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9766 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9767 + sllx == 0x89293020U &&
9768 + add == 0x8A010005U &&
9769 + jmpl == 0x89C14000U &&
9770 + nop == 0x01000000U)
9771 + {
9772 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9773 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9774 + regs->u_regs[UREG_G4] <<= 32;
9775 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9776 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9777 + regs->u_regs[UREG_G4] = addr + 24;
9778 + addr = regs->u_regs[UREG_G5];
9779 + regs->tpc = addr;
9780 + regs->tnpc = addr+4;
9781 + return 3;
9782 + }
9783 + }
9784 + } while (0);
9785 +
9786 +#ifdef CONFIG_PAX_DLRESOLVE
9787 + do { /* PaX: unpatched PLT emulation step 2 */
9788 + unsigned int save, call, nop;
9789 +
9790 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9791 + err |= get_user(call, (unsigned int *)regs->tpc);
9792 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9793 + if (err)
9794 + break;
9795 +
9796 + if (save == 0x9DE3BFA8U &&
9797 + (call & 0xC0000000U) == 0x40000000U &&
9798 + nop == 0x01000000U)
9799 + {
9800 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9801 +
9802 + if (test_thread_flag(TIF_32BIT))
9803 + dl_resolve &= 0xFFFFFFFFUL;
9804 +
9805 + regs->u_regs[UREG_RETPC] = regs->tpc;
9806 + regs->tpc = dl_resolve;
9807 + regs->tnpc = dl_resolve+4;
9808 + return 3;
9809 + }
9810 + } while (0);
9811 +#endif
9812 +
9813 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9814 + unsigned int sethi, ba, nop;
9815 +
9816 + err = get_user(sethi, (unsigned int *)regs->tpc);
9817 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9818 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9819 +
9820 + if (err)
9821 + break;
9822 +
9823 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9824 + (ba & 0xFFF00000U) == 0x30600000U &&
9825 + nop == 0x01000000U)
9826 + {
9827 + unsigned long addr;
9828 +
9829 + addr = (sethi & 0x003FFFFFU) << 10;
9830 + regs->u_regs[UREG_G1] = addr;
9831 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9832 +
9833 + if (test_thread_flag(TIF_32BIT))
9834 + addr &= 0xFFFFFFFFUL;
9835 +
9836 + regs->tpc = addr;
9837 + regs->tnpc = addr+4;
9838 + return 2;
9839 + }
9840 + } while (0);
9841 +
9842 +#endif
9843 +
9844 + return 1;
9845 +}
9846 +
9847 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9848 +{
9849 + unsigned long i;
9850 +
9851 + printk(KERN_ERR "PAX: bytes at PC: ");
9852 + for (i = 0; i < 8; i++) {
9853 + unsigned int c;
9854 + if (get_user(c, (unsigned int *)pc+i))
9855 + printk(KERN_CONT "???????? ");
9856 + else
9857 + printk(KERN_CONT "%08x ", c);
9858 + }
9859 + printk("\n");
9860 +}
9861 +#endif
9862 +
9863 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9864 {
9865 struct mm_struct *mm = current->mm;
9866 @@ -341,6 +804,29 @@ retry:
9867 if (!vma)
9868 goto bad_area;
9869
9870 +#ifdef CONFIG_PAX_PAGEEXEC
9871 + /* PaX: detect ITLB misses on non-exec pages */
9872 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9873 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9874 + {
9875 + if (address != regs->tpc)
9876 + goto good_area;
9877 +
9878 + up_read(&mm->mmap_sem);
9879 + switch (pax_handle_fetch_fault(regs)) {
9880 +
9881 +#ifdef CONFIG_PAX_EMUPLT
9882 + case 2:
9883 + case 3:
9884 + return;
9885 +#endif
9886 +
9887 + }
9888 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9889 + do_group_exit(SIGKILL);
9890 + }
9891 +#endif
9892 +
9893 /* Pure DTLB misses do not tell us whether the fault causing
9894 * load/store/atomic was a write or not, it only says that there
9895 * was no match. So in such a case we (carefully) read the
9896 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9897 index d2b5944..bd813f2 100644
9898 --- a/arch/sparc/mm/hugetlbpage.c
9899 +++ b/arch/sparc/mm/hugetlbpage.c
9900 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9901
9902 info.flags = 0;
9903 info.length = len;
9904 - info.low_limit = TASK_UNMAPPED_BASE;
9905 + info.low_limit = mm->mmap_base;
9906 info.high_limit = min(task_size, VA_EXCLUDE_START);
9907 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9908 info.align_offset = 0;
9909 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9910 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9911 VM_BUG_ON(addr != -ENOMEM);
9912 info.low_limit = VA_EXCLUDE_END;
9913 +
9914 +#ifdef CONFIG_PAX_RANDMMAP
9915 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9916 + info.low_limit += mm->delta_mmap;
9917 +#endif
9918 +
9919 info.high_limit = task_size;
9920 addr = vm_unmapped_area(&info);
9921 }
9922 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9923 VM_BUG_ON(addr != -ENOMEM);
9924 info.flags = 0;
9925 info.low_limit = TASK_UNMAPPED_BASE;
9926 +
9927 +#ifdef CONFIG_PAX_RANDMMAP
9928 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9929 + info.low_limit += mm->delta_mmap;
9930 +#endif
9931 +
9932 info.high_limit = STACK_TOP32;
9933 addr = vm_unmapped_area(&info);
9934 }
9935 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9936 struct mm_struct *mm = current->mm;
9937 struct vm_area_struct *vma;
9938 unsigned long task_size = TASK_SIZE;
9939 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
9940
9941 if (test_thread_flag(TIF_32BIT))
9942 task_size = STACK_TOP32;
9943 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9944 return addr;
9945 }
9946
9947 +#ifdef CONFIG_PAX_RANDMMAP
9948 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9949 +#endif
9950 +
9951 if (addr) {
9952 addr = ALIGN(addr, HPAGE_SIZE);
9953 vma = find_vma(mm, addr);
9954 - if (task_size - len >= addr &&
9955 - (!vma || addr + len <= vma->vm_start))
9956 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9957 return addr;
9958 }
9959 if (mm->get_unmapped_area == arch_get_unmapped_area)
9960 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
9961 index f4500c6..889656c 100644
9962 --- a/arch/tile/include/asm/atomic_64.h
9963 +++ b/arch/tile/include/asm/atomic_64.h
9964 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9965
9966 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9967
9968 +#define atomic64_read_unchecked(v) atomic64_read(v)
9969 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
9970 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
9971 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
9972 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
9973 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
9974 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
9975 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
9976 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
9977 +
9978 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
9979 #define smp_mb__before_atomic_dec() smp_mb()
9980 #define smp_mb__after_atomic_dec() smp_mb()
9981 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
9982 index a9a5299..0fce79e 100644
9983 --- a/arch/tile/include/asm/cache.h
9984 +++ b/arch/tile/include/asm/cache.h
9985 @@ -15,11 +15,12 @@
9986 #ifndef _ASM_TILE_CACHE_H
9987 #define _ASM_TILE_CACHE_H
9988
9989 +#include <linux/const.h>
9990 #include <arch/chip.h>
9991
9992 /* bytes per L1 data cache line */
9993 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
9994 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9995 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9996
9997 /* bytes per L2 cache line */
9998 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
9999 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10000 index 9ab078a..d6635c2 100644
10001 --- a/arch/tile/include/asm/uaccess.h
10002 +++ b/arch/tile/include/asm/uaccess.h
10003 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10004 const void __user *from,
10005 unsigned long n)
10006 {
10007 - int sz = __compiletime_object_size(to);
10008 + size_t sz = __compiletime_object_size(to);
10009
10010 - if (likely(sz == -1 || sz >= n))
10011 + if (likely(sz == (size_t)-1 || sz >= n))
10012 n = _copy_from_user(to, from, n);
10013 else
10014 copy_from_user_overflow();
10015 diff --git a/arch/um/Makefile b/arch/um/Makefile
10016 index 133f7de..1d6f2f1 100644
10017 --- a/arch/um/Makefile
10018 +++ b/arch/um/Makefile
10019 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10020 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10021 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10022
10023 +ifdef CONSTIFY_PLUGIN
10024 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10025 +endif
10026 +
10027 #This will adjust *FLAGS accordingly to the platform.
10028 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10029
10030 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10031 index 19e1bdd..3665b77 100644
10032 --- a/arch/um/include/asm/cache.h
10033 +++ b/arch/um/include/asm/cache.h
10034 @@ -1,6 +1,7 @@
10035 #ifndef __UM_CACHE_H
10036 #define __UM_CACHE_H
10037
10038 +#include <linux/const.h>
10039
10040 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10041 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10042 @@ -12,6 +13,6 @@
10043 # define L1_CACHE_SHIFT 5
10044 #endif
10045
10046 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10047 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10048
10049 #endif
10050 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10051 index 2e0a6b1..a64d0f5 100644
10052 --- a/arch/um/include/asm/kmap_types.h
10053 +++ b/arch/um/include/asm/kmap_types.h
10054 @@ -8,6 +8,6 @@
10055
10056 /* No more #include "asm/arch/kmap_types.h" ! */
10057
10058 -#define KM_TYPE_NR 14
10059 +#define KM_TYPE_NR 15
10060
10061 #endif
10062 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10063 index 5ff53d9..5850cdf 100644
10064 --- a/arch/um/include/asm/page.h
10065 +++ b/arch/um/include/asm/page.h
10066 @@ -14,6 +14,9 @@
10067 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10068 #define PAGE_MASK (~(PAGE_SIZE-1))
10069
10070 +#define ktla_ktva(addr) (addr)
10071 +#define ktva_ktla(addr) (addr)
10072 +
10073 #ifndef __ASSEMBLY__
10074
10075 struct page;
10076 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10077 index 0032f92..cd151e0 100644
10078 --- a/arch/um/include/asm/pgtable-3level.h
10079 +++ b/arch/um/include/asm/pgtable-3level.h
10080 @@ -58,6 +58,7 @@
10081 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10082 #define pud_populate(mm, pud, pmd) \
10083 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10084 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10085
10086 #ifdef CONFIG_64BIT
10087 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10088 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10089 index b462b13..e7a19aa 100644
10090 --- a/arch/um/kernel/process.c
10091 +++ b/arch/um/kernel/process.c
10092 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10093 return 2;
10094 }
10095
10096 -/*
10097 - * Only x86 and x86_64 have an arch_align_stack().
10098 - * All other arches have "#define arch_align_stack(x) (x)"
10099 - * in their asm/system.h
10100 - * As this is included in UML from asm-um/system-generic.h,
10101 - * we can use it to behave as the subarch does.
10102 - */
10103 -#ifndef arch_align_stack
10104 -unsigned long arch_align_stack(unsigned long sp)
10105 -{
10106 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10107 - sp -= get_random_int() % 8192;
10108 - return sp & ~0xf;
10109 -}
10110 -#endif
10111 -
10112 unsigned long get_wchan(struct task_struct *p)
10113 {
10114 unsigned long stack_page, sp, ip;
10115 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10116 index ad8f795..2c7eec6 100644
10117 --- a/arch/unicore32/include/asm/cache.h
10118 +++ b/arch/unicore32/include/asm/cache.h
10119 @@ -12,8 +12,10 @@
10120 #ifndef __UNICORE_CACHE_H__
10121 #define __UNICORE_CACHE_H__
10122
10123 -#define L1_CACHE_SHIFT (5)
10124 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10125 +#include <linux/const.h>
10126 +
10127 +#define L1_CACHE_SHIFT 5
10128 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10129
10130 /*
10131 * Memory returned by kmalloc() may be used for DMA, so we must make
10132 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10133 index 0694d09..b58b3aa 100644
10134 --- a/arch/x86/Kconfig
10135 +++ b/arch/x86/Kconfig
10136 @@ -238,7 +238,7 @@ config X86_HT
10137
10138 config X86_32_LAZY_GS
10139 def_bool y
10140 - depends on X86_32 && !CC_STACKPROTECTOR
10141 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10142
10143 config ARCH_HWEIGHT_CFLAGS
10144 string
10145 @@ -1031,6 +1031,7 @@ config MICROCODE_OLD_INTERFACE
10146
10147 config X86_MSR
10148 tristate "/dev/cpu/*/msr - Model-specific register support"
10149 + depends on !GRKERNSEC_KMEM
10150 ---help---
10151 This device gives privileged processes access to the x86
10152 Model-Specific Registers (MSRs). It is a character device with
10153 @@ -1054,7 +1055,7 @@ choice
10154
10155 config NOHIGHMEM
10156 bool "off"
10157 - depends on !X86_NUMAQ
10158 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10159 ---help---
10160 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10161 However, the address space of 32-bit x86 processors is only 4
10162 @@ -1091,7 +1092,7 @@ config NOHIGHMEM
10163
10164 config HIGHMEM4G
10165 bool "4GB"
10166 - depends on !X86_NUMAQ
10167 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10168 ---help---
10169 Select this if you have a 32-bit processor and between 1 and 4
10170 gigabytes of physical RAM.
10171 @@ -1145,7 +1146,7 @@ config PAGE_OFFSET
10172 hex
10173 default 0xB0000000 if VMSPLIT_3G_OPT
10174 default 0x80000000 if VMSPLIT_2G
10175 - default 0x78000000 if VMSPLIT_2G_OPT
10176 + default 0x70000000 if VMSPLIT_2G_OPT
10177 default 0x40000000 if VMSPLIT_1G
10178 default 0xC0000000
10179 depends on X86_32
10180 @@ -1542,6 +1543,7 @@ config SECCOMP
10181
10182 config CC_STACKPROTECTOR
10183 bool "Enable -fstack-protector buffer overflow detection"
10184 + depends on X86_64 || !PAX_MEMORY_UDEREF
10185 ---help---
10186 This option turns on the -fstack-protector GCC feature. This
10187 feature puts, at the beginning of functions, a canary value on
10188 @@ -1599,6 +1601,7 @@ config KEXEC_JUMP
10189 config PHYSICAL_START
10190 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
10191 default "0x1000000"
10192 + range 0x400000 0x40000000
10193 ---help---
10194 This gives the physical address where the kernel is loaded.
10195
10196 @@ -1662,6 +1665,7 @@ config X86_NEED_RELOCS
10197 config PHYSICAL_ALIGN
10198 hex "Alignment value to which kernel should be aligned" if X86_32
10199 default "0x1000000"
10200 + range 0x400000 0x1000000 if PAX_KERNEXEC
10201 range 0x2000 0x1000000
10202 ---help---
10203 This value puts the alignment restrictions on physical address
10204 @@ -1737,9 +1741,10 @@ config DEBUG_HOTPLUG_CPU0
10205 If unsure, say N.
10206
10207 config COMPAT_VDSO
10208 - def_bool y
10209 + def_bool n
10210 prompt "Compat VDSO support"
10211 depends on X86_32 || IA32_EMULATION
10212 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10213 ---help---
10214 Map the 32-bit VDSO to the predictable old-style address too.
10215
10216 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10217 index c026cca..14657ae 100644
10218 --- a/arch/x86/Kconfig.cpu
10219 +++ b/arch/x86/Kconfig.cpu
10220 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10221
10222 config X86_F00F_BUG
10223 def_bool y
10224 - depends on M586MMX || M586TSC || M586 || M486
10225 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10226
10227 config X86_INVD_BUG
10228 def_bool y
10229 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10230
10231 config X86_ALIGNMENT_16
10232 def_bool y
10233 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10234 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10235
10236 config X86_INTEL_USERCOPY
10237 def_bool y
10238 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10239 # generates cmov.
10240 config X86_CMOV
10241 def_bool y
10242 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10243 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10244
10245 config X86_MINIMUM_CPU_FAMILY
10246 int
10247 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10248 index b322f12..652d0d9 100644
10249 --- a/arch/x86/Kconfig.debug
10250 +++ b/arch/x86/Kconfig.debug
10251 @@ -84,7 +84,7 @@ config X86_PTDUMP
10252 config DEBUG_RODATA
10253 bool "Write protect kernel read-only data structures"
10254 default y
10255 - depends on DEBUG_KERNEL
10256 + depends on DEBUG_KERNEL && BROKEN
10257 ---help---
10258 Mark the kernel read-only data as write-protected in the pagetables,
10259 in order to catch accidental (and incorrect) writes to such const
10260 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10261
10262 config DEBUG_SET_MODULE_RONX
10263 bool "Set loadable kernel module data as NX and text as RO"
10264 - depends on MODULES
10265 + depends on MODULES && BROKEN
10266 ---help---
10267 This option helps catch unintended modifications to loadable
10268 kernel module's text and read-only data. It also prevents execution
10269 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10270
10271 config DEBUG_STRICT_USER_COPY_CHECKS
10272 bool "Strict copy size checks"
10273 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10274 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10275 ---help---
10276 Enabling this option turns a certain set of sanity checks for user
10277 copy operations into compile time failures.
10278 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10279 index e71fc42..7829607 100644
10280 --- a/arch/x86/Makefile
10281 +++ b/arch/x86/Makefile
10282 @@ -50,6 +50,7 @@ else
10283 UTS_MACHINE := x86_64
10284 CHECKFLAGS += -D__x86_64__ -m64
10285
10286 + biarch := $(call cc-option,-m64)
10287 KBUILD_AFLAGS += -m64
10288 KBUILD_CFLAGS += -m64
10289
10290 @@ -230,3 +231,12 @@ define archhelp
10291 echo ' FDARGS="..." arguments for the booted kernel'
10292 echo ' FDINITRD=file initrd for the booted kernel'
10293 endef
10294 +
10295 +define OLD_LD
10296 +
10297 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10298 +*** Please upgrade your binutils to 2.18 or newer
10299 +endef
10300 +
10301 +archprepare:
10302 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10303 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10304 index 379814b..add62ce 100644
10305 --- a/arch/x86/boot/Makefile
10306 +++ b/arch/x86/boot/Makefile
10307 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10308 $(call cc-option, -fno-stack-protector) \
10309 $(call cc-option, -mpreferred-stack-boundary=2)
10310 KBUILD_CFLAGS += $(call cc-option, -m32)
10311 +ifdef CONSTIFY_PLUGIN
10312 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10313 +endif
10314 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10315 GCOV_PROFILE := n
10316
10317 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10318 index 878e4b9..20537ab 100644
10319 --- a/arch/x86/boot/bitops.h
10320 +++ b/arch/x86/boot/bitops.h
10321 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10322 u8 v;
10323 const u32 *p = (const u32 *)addr;
10324
10325 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10326 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10327 return v;
10328 }
10329
10330 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10331
10332 static inline void set_bit(int nr, void *addr)
10333 {
10334 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10335 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10336 }
10337
10338 #endif /* BOOT_BITOPS_H */
10339 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10340 index 18997e5..83d9c67 100644
10341 --- a/arch/x86/boot/boot.h
10342 +++ b/arch/x86/boot/boot.h
10343 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10344 static inline u16 ds(void)
10345 {
10346 u16 seg;
10347 - asm("movw %%ds,%0" : "=rm" (seg));
10348 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10349 return seg;
10350 }
10351
10352 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10353 static inline int memcmp(const void *s1, const void *s2, size_t len)
10354 {
10355 u8 diff;
10356 - asm("repe; cmpsb; setnz %0"
10357 + asm volatile("repe; cmpsb; setnz %0"
10358 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10359 return diff;
10360 }
10361 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10362 index 8a84501..b2d165f 100644
10363 --- a/arch/x86/boot/compressed/Makefile
10364 +++ b/arch/x86/boot/compressed/Makefile
10365 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10366 KBUILD_CFLAGS += $(cflags-y)
10367 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10368 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10369 +ifdef CONSTIFY_PLUGIN
10370 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10371 +endif
10372
10373 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10374 GCOV_PROFILE := n
10375 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10376 index c205035..5853587 100644
10377 --- a/arch/x86/boot/compressed/eboot.c
10378 +++ b/arch/x86/boot/compressed/eboot.c
10379 @@ -150,7 +150,6 @@ again:
10380 *addr = max_addr;
10381 }
10382
10383 -free_pool:
10384 efi_call_phys1(sys_table->boottime->free_pool, map);
10385
10386 fail:
10387 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10388 if (i == map_size / desc_size)
10389 status = EFI_NOT_FOUND;
10390
10391 -free_pool:
10392 efi_call_phys1(sys_table->boottime->free_pool, map);
10393 fail:
10394 return status;
10395 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10396 index 1e3184f..0d11e2e 100644
10397 --- a/arch/x86/boot/compressed/head_32.S
10398 +++ b/arch/x86/boot/compressed/head_32.S
10399 @@ -118,7 +118,7 @@ preferred_addr:
10400 notl %eax
10401 andl %eax, %ebx
10402 #else
10403 - movl $LOAD_PHYSICAL_ADDR, %ebx
10404 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10405 #endif
10406
10407 /* Target address to relocate to for decompression */
10408 @@ -204,7 +204,7 @@ relocated:
10409 * and where it was actually loaded.
10410 */
10411 movl %ebp, %ebx
10412 - subl $LOAD_PHYSICAL_ADDR, %ebx
10413 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10414 jz 2f /* Nothing to be done if loaded at compiled addr. */
10415 /*
10416 * Process relocations.
10417 @@ -212,8 +212,7 @@ relocated:
10418
10419 1: subl $4, %edi
10420 movl (%edi), %ecx
10421 - testl %ecx, %ecx
10422 - jz 2f
10423 + jecxz 2f
10424 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10425 jmp 1b
10426 2:
10427 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10428 index f5d1aaa..cce11dc 100644
10429 --- a/arch/x86/boot/compressed/head_64.S
10430 +++ b/arch/x86/boot/compressed/head_64.S
10431 @@ -91,7 +91,7 @@ ENTRY(startup_32)
10432 notl %eax
10433 andl %eax, %ebx
10434 #else
10435 - movl $LOAD_PHYSICAL_ADDR, %ebx
10436 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10437 #endif
10438
10439 /* Target address to relocate to for decompression */
10440 @@ -273,7 +273,7 @@ preferred_addr:
10441 notq %rax
10442 andq %rax, %rbp
10443 #else
10444 - movq $LOAD_PHYSICAL_ADDR, %rbp
10445 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10446 #endif
10447
10448 /* Target address to relocate to for decompression */
10449 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10450 index 88f7ff6..ed695dd 100644
10451 --- a/arch/x86/boot/compressed/misc.c
10452 +++ b/arch/x86/boot/compressed/misc.c
10453 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10454 case PT_LOAD:
10455 #ifdef CONFIG_RELOCATABLE
10456 dest = output;
10457 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10458 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10459 #else
10460 dest = (void *)(phdr->p_paddr);
10461 #endif
10462 @@ -352,7 +352,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10463 error("Destination address too large");
10464 #endif
10465 #ifndef CONFIG_RELOCATABLE
10466 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10467 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10468 error("Wrong destination address");
10469 #endif
10470
10471 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10472 index 4d3ff03..e4972ff 100644
10473 --- a/arch/x86/boot/cpucheck.c
10474 +++ b/arch/x86/boot/cpucheck.c
10475 @@ -74,7 +74,7 @@ static int has_fpu(void)
10476 u16 fcw = -1, fsw = -1;
10477 u32 cr0;
10478
10479 - asm("movl %%cr0,%0" : "=r" (cr0));
10480 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10481 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10482 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10483 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10484 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10485 {
10486 u32 f0, f1;
10487
10488 - asm("pushfl ; "
10489 + asm volatile("pushfl ; "
10490 "pushfl ; "
10491 "popl %0 ; "
10492 "movl %0,%1 ; "
10493 @@ -115,7 +115,7 @@ static void get_flags(void)
10494 set_bit(X86_FEATURE_FPU, cpu.flags);
10495
10496 if (has_eflag(X86_EFLAGS_ID)) {
10497 - asm("cpuid"
10498 + asm volatile("cpuid"
10499 : "=a" (max_intel_level),
10500 "=b" (cpu_vendor[0]),
10501 "=d" (cpu_vendor[1]),
10502 @@ -124,7 +124,7 @@ static void get_flags(void)
10503
10504 if (max_intel_level >= 0x00000001 &&
10505 max_intel_level <= 0x0000ffff) {
10506 - asm("cpuid"
10507 + asm volatile("cpuid"
10508 : "=a" (tfms),
10509 "=c" (cpu.flags[4]),
10510 "=d" (cpu.flags[0])
10511 @@ -136,7 +136,7 @@ static void get_flags(void)
10512 cpu.model += ((tfms >> 16) & 0xf) << 4;
10513 }
10514
10515 - asm("cpuid"
10516 + asm volatile("cpuid"
10517 : "=a" (max_amd_level)
10518 : "a" (0x80000000)
10519 : "ebx", "ecx", "edx");
10520 @@ -144,7 +144,7 @@ static void get_flags(void)
10521 if (max_amd_level >= 0x80000001 &&
10522 max_amd_level <= 0x8000ffff) {
10523 u32 eax = 0x80000001;
10524 - asm("cpuid"
10525 + asm volatile("cpuid"
10526 : "+a" (eax),
10527 "=c" (cpu.flags[6]),
10528 "=d" (cpu.flags[1])
10529 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10530 u32 ecx = MSR_K7_HWCR;
10531 u32 eax, edx;
10532
10533 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10534 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10535 eax &= ~(1 << 15);
10536 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10537 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10538
10539 get_flags(); /* Make sure it really did something */
10540 err = check_flags();
10541 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10542 u32 ecx = MSR_VIA_FCR;
10543 u32 eax, edx;
10544
10545 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10546 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10547 eax |= (1<<1)|(1<<7);
10548 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10549 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10550
10551 set_bit(X86_FEATURE_CX8, cpu.flags);
10552 err = check_flags();
10553 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10554 u32 eax, edx;
10555 u32 level = 1;
10556
10557 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10558 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10559 - asm("cpuid"
10560 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10561 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10562 + asm volatile("cpuid"
10563 : "+a" (level), "=d" (cpu.flags[0])
10564 : : "ecx", "ebx");
10565 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10566 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10567
10568 err = check_flags();
10569 }
10570 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10571 index 944ce59..87ee37a 100644
10572 --- a/arch/x86/boot/header.S
10573 +++ b/arch/x86/boot/header.S
10574 @@ -401,10 +401,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10575 # single linked list of
10576 # struct setup_data
10577
10578 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10579 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10580
10581 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10582 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10583 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10584 +#else
10585 #define VO_INIT_SIZE (VO__end - VO__text)
10586 +#endif
10587 #if ZO_INIT_SIZE > VO_INIT_SIZE
10588 #define INIT_SIZE ZO_INIT_SIZE
10589 #else
10590 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10591 index db75d07..8e6d0af 100644
10592 --- a/arch/x86/boot/memory.c
10593 +++ b/arch/x86/boot/memory.c
10594 @@ -19,7 +19,7 @@
10595
10596 static int detect_memory_e820(void)
10597 {
10598 - int count = 0;
10599 + unsigned int count = 0;
10600 struct biosregs ireg, oreg;
10601 struct e820entry *desc = boot_params.e820_map;
10602 static struct e820entry buf; /* static so it is zeroed */
10603 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10604 index 11e8c6e..fdbb1ed 100644
10605 --- a/arch/x86/boot/video-vesa.c
10606 +++ b/arch/x86/boot/video-vesa.c
10607 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10608
10609 boot_params.screen_info.vesapm_seg = oreg.es;
10610 boot_params.screen_info.vesapm_off = oreg.di;
10611 + boot_params.screen_info.vesapm_size = oreg.cx;
10612 }
10613
10614 /*
10615 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10616 index 43eda28..5ab5fdb 100644
10617 --- a/arch/x86/boot/video.c
10618 +++ b/arch/x86/boot/video.c
10619 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10620 static unsigned int get_entry(void)
10621 {
10622 char entry_buf[4];
10623 - int i, len = 0;
10624 + unsigned int i, len = 0;
10625 int key;
10626 unsigned int v;
10627
10628 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10629 index 5b577d5..3c1fed4 100644
10630 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10631 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10632 @@ -8,6 +8,8 @@
10633 * including this sentence is retained in full.
10634 */
10635
10636 +#include <asm/alternative-asm.h>
10637 +
10638 .extern crypto_ft_tab
10639 .extern crypto_it_tab
10640 .extern crypto_fl_tab
10641 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
10642 je B192; \
10643 leaq 32(r9),r9;
10644
10645 +#define ret pax_force_retaddr 0, 1; ret
10646 +
10647 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10648 movq r1,r2; \
10649 movq r3,r4; \
10650 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10651 index 3470624..201259d 100644
10652 --- a/arch/x86/crypto/aesni-intel_asm.S
10653 +++ b/arch/x86/crypto/aesni-intel_asm.S
10654 @@ -31,6 +31,7 @@
10655
10656 #include <linux/linkage.h>
10657 #include <asm/inst.h>
10658 +#include <asm/alternative-asm.h>
10659
10660 #ifdef __x86_64__
10661 .data
10662 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
10663 pop %r14
10664 pop %r13
10665 pop %r12
10666 + pax_force_retaddr 0, 1
10667 ret
10668 +ENDPROC(aesni_gcm_dec)
10669
10670
10671 /*****************************************************************************
10672 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
10673 pop %r14
10674 pop %r13
10675 pop %r12
10676 + pax_force_retaddr 0, 1
10677 ret
10678 +ENDPROC(aesni_gcm_enc)
10679
10680 #endif
10681
10682 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
10683 pxor %xmm1, %xmm0
10684 movaps %xmm0, (TKEYP)
10685 add $0x10, TKEYP
10686 + pax_force_retaddr_bts
10687 ret
10688
10689 .align 4
10690 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
10691 shufps $0b01001110, %xmm2, %xmm1
10692 movaps %xmm1, 0x10(TKEYP)
10693 add $0x20, TKEYP
10694 + pax_force_retaddr_bts
10695 ret
10696
10697 .align 4
10698 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
10699
10700 movaps %xmm0, (TKEYP)
10701 add $0x10, TKEYP
10702 + pax_force_retaddr_bts
10703 ret
10704
10705 .align 4
10706 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
10707 pxor %xmm1, %xmm2
10708 movaps %xmm2, (TKEYP)
10709 add $0x10, TKEYP
10710 + pax_force_retaddr_bts
10711 ret
10712
10713 /*
10714 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
10715 #ifndef __x86_64__
10716 popl KEYP
10717 #endif
10718 + pax_force_retaddr 0, 1
10719 ret
10720 +ENDPROC(aesni_set_key)
10721
10722 /*
10723 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
10724 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
10725 popl KLEN
10726 popl KEYP
10727 #endif
10728 + pax_force_retaddr 0, 1
10729 ret
10730 +ENDPROC(aesni_enc)
10731
10732 /*
10733 * _aesni_enc1: internal ABI
10734 @@ -1959,6 +1972,7 @@ _aesni_enc1:
10735 AESENC KEY STATE
10736 movaps 0x70(TKEYP), KEY
10737 AESENCLAST KEY STATE
10738 + pax_force_retaddr_bts
10739 ret
10740
10741 /*
10742 @@ -2067,6 +2081,7 @@ _aesni_enc4:
10743 AESENCLAST KEY STATE2
10744 AESENCLAST KEY STATE3
10745 AESENCLAST KEY STATE4
10746 + pax_force_retaddr_bts
10747 ret
10748
10749 /*
10750 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
10751 popl KLEN
10752 popl KEYP
10753 #endif
10754 + pax_force_retaddr 0, 1
10755 ret
10756 +ENDPROC(aesni_dec)
10757
10758 /*
10759 * _aesni_dec1: internal ABI
10760 @@ -2146,6 +2163,7 @@ _aesni_dec1:
10761 AESDEC KEY STATE
10762 movaps 0x70(TKEYP), KEY
10763 AESDECLAST KEY STATE
10764 + pax_force_retaddr_bts
10765 ret
10766
10767 /*
10768 @@ -2254,6 +2272,7 @@ _aesni_dec4:
10769 AESDECLAST KEY STATE2
10770 AESDECLAST KEY STATE3
10771 AESDECLAST KEY STATE4
10772 + pax_force_retaddr_bts
10773 ret
10774
10775 /*
10776 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
10777 popl KEYP
10778 popl LEN
10779 #endif
10780 + pax_force_retaddr 0, 1
10781 ret
10782 +ENDPROC(aesni_ecb_enc)
10783
10784 /*
10785 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
10786 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
10787 popl KEYP
10788 popl LEN
10789 #endif
10790 + pax_force_retaddr 0, 1
10791 ret
10792 +ENDPROC(aesni_ecb_dec)
10793
10794 /*
10795 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
10796 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
10797 popl LEN
10798 popl IVP
10799 #endif
10800 + pax_force_retaddr 0, 1
10801 ret
10802 +ENDPROC(aesni_cbc_enc)
10803
10804 /*
10805 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
10806 @@ -2500,7 +2525,9 @@ ENTRY(aesni_cbc_dec)
10807 popl LEN
10808 popl IVP
10809 #endif
10810 + pax_force_retaddr 0, 1
10811 ret
10812 +ENDPROC(aesni_cbc_dec)
10813
10814 #ifdef __x86_64__
10815 .align 16
10816 @@ -2526,6 +2553,7 @@ _aesni_inc_init:
10817 mov $1, TCTR_LOW
10818 MOVQ_R64_XMM TCTR_LOW INC
10819 MOVQ_R64_XMM CTR TCTR_LOW
10820 + pax_force_retaddr_bts
10821 ret
10822
10823 /*
10824 @@ -2554,6 +2582,7 @@ _aesni_inc:
10825 .Linc_low:
10826 movaps CTR, IV
10827 PSHUFB_XMM BSWAP_MASK IV
10828 + pax_force_retaddr_bts
10829 ret
10830
10831 /*
10832 @@ -2614,5 +2643,7 @@ ENTRY(aesni_ctr_enc)
10833 .Lctr_enc_ret:
10834 movups IV, (IVP)
10835 .Lctr_enc_just_ret:
10836 + pax_force_retaddr 0, 1
10837 ret
10838 +ENDPROC(aesni_ctr_enc)
10839 #endif
10840 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10841 index 391d245..67f35c2 100644
10842 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10843 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10844 @@ -20,6 +20,8 @@
10845 *
10846 */
10847
10848 +#include <asm/alternative-asm.h>
10849 +
10850 .file "blowfish-x86_64-asm.S"
10851 .text
10852
10853 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
10854 jnz __enc_xor;
10855
10856 write_block();
10857 + pax_force_retaddr 0, 1
10858 ret;
10859 __enc_xor:
10860 xor_block();
10861 + pax_force_retaddr 0, 1
10862 ret;
10863
10864 .align 8
10865 @@ -188,6 +192,7 @@ blowfish_dec_blk:
10866
10867 movq %r11, %rbp;
10868
10869 + pax_force_retaddr 0, 1
10870 ret;
10871
10872 /**********************************************************************
10873 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
10874
10875 popq %rbx;
10876 popq %rbp;
10877 + pax_force_retaddr 0, 1
10878 ret;
10879
10880 __enc_xor4:
10881 @@ -349,6 +355,7 @@ __enc_xor4:
10882
10883 popq %rbx;
10884 popq %rbp;
10885 + pax_force_retaddr 0, 1
10886 ret;
10887
10888 .align 8
10889 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
10890 popq %rbx;
10891 popq %rbp;
10892
10893 + pax_force_retaddr 0, 1
10894 ret;
10895
10896 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
10897 index 0b33743..7a56206 100644
10898 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
10899 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
10900 @@ -20,6 +20,8 @@
10901 *
10902 */
10903
10904 +#include <asm/alternative-asm.h>
10905 +
10906 .file "camellia-x86_64-asm_64.S"
10907 .text
10908
10909 @@ -229,12 +231,14 @@ __enc_done:
10910 enc_outunpack(mov, RT1);
10911
10912 movq RRBP, %rbp;
10913 + pax_force_retaddr 0, 1
10914 ret;
10915
10916 __enc_xor:
10917 enc_outunpack(xor, RT1);
10918
10919 movq RRBP, %rbp;
10920 + pax_force_retaddr 0, 1
10921 ret;
10922
10923 .global camellia_dec_blk;
10924 @@ -275,6 +279,7 @@ __dec_rounds16:
10925 dec_outunpack();
10926
10927 movq RRBP, %rbp;
10928 + pax_force_retaddr 0, 1
10929 ret;
10930
10931 /**********************************************************************
10932 @@ -468,6 +473,7 @@ __enc2_done:
10933
10934 movq RRBP, %rbp;
10935 popq %rbx;
10936 + pax_force_retaddr 0, 1
10937 ret;
10938
10939 __enc2_xor:
10940 @@ -475,6 +481,7 @@ __enc2_xor:
10941
10942 movq RRBP, %rbp;
10943 popq %rbx;
10944 + pax_force_retaddr 0, 1
10945 ret;
10946
10947 .global camellia_dec_blk_2way;
10948 @@ -517,4 +524,5 @@ __dec2_rounds16:
10949
10950 movq RRBP, %rbp;
10951 movq RXOR, %rbx;
10952 + pax_force_retaddr 0, 1
10953 ret;
10954 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
10955 index 15b00ac..2071784 100644
10956 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
10957 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
10958 @@ -23,6 +23,8 @@
10959 *
10960 */
10961
10962 +#include <asm/alternative-asm.h>
10963 +
10964 .file "cast5-avx-x86_64-asm_64.S"
10965
10966 .extern cast_s1
10967 @@ -281,6 +283,7 @@ __skip_enc:
10968 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
10969 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
10970
10971 + pax_force_retaddr 0, 1
10972 ret;
10973
10974 .align 16
10975 @@ -353,6 +356,7 @@ __dec_tail:
10976 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
10977 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
10978
10979 + pax_force_retaddr 0, 1
10980 ret;
10981
10982 __skip_dec:
10983 @@ -392,6 +396,7 @@ cast5_ecb_enc_16way:
10984 vmovdqu RR4, (6*4*4)(%r11);
10985 vmovdqu RL4, (7*4*4)(%r11);
10986
10987 + pax_force_retaddr
10988 ret;
10989
10990 .align 16
10991 @@ -427,6 +432,7 @@ cast5_ecb_dec_16way:
10992 vmovdqu RR4, (6*4*4)(%r11);
10993 vmovdqu RL4, (7*4*4)(%r11);
10994
10995 + pax_force_retaddr
10996 ret;
10997
10998 .align 16
10999 @@ -479,6 +485,7 @@ cast5_cbc_dec_16way:
11000
11001 popq %r12;
11002
11003 + pax_force_retaddr
11004 ret;
11005
11006 .align 16
11007 @@ -555,4 +562,5 @@ cast5_ctr_16way:
11008
11009 popq %r12;
11010
11011 + pax_force_retaddr
11012 ret;
11013 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11014 index 2569d0d..637c289 100644
11015 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11016 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11017 @@ -23,6 +23,8 @@
11018 *
11019 */
11020
11021 +#include <asm/alternative-asm.h>
11022 +
11023 #include "glue_helper-asm-avx.S"
11024
11025 .file "cast6-avx-x86_64-asm_64.S"
11026 @@ -294,6 +296,7 @@ __cast6_enc_blk8:
11027 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11028 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11029
11030 + pax_force_retaddr 0, 1
11031 ret;
11032
11033 .align 8
11034 @@ -340,6 +343,7 @@ __cast6_dec_blk8:
11035 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11036 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11037
11038 + pax_force_retaddr 0, 1
11039 ret;
11040
11041 .align 8
11042 @@ -361,6 +365,7 @@ cast6_ecb_enc_8way:
11043
11044 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11045
11046 + pax_force_retaddr
11047 ret;
11048
11049 .align 8
11050 @@ -382,6 +387,7 @@ cast6_ecb_dec_8way:
11051
11052 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11053
11054 + pax_force_retaddr
11055 ret;
11056
11057 .align 8
11058 @@ -408,6 +414,7 @@ cast6_cbc_dec_8way:
11059
11060 popq %r12;
11061
11062 + pax_force_retaddr
11063 ret;
11064
11065 .align 8
11066 @@ -436,4 +443,5 @@ cast6_ctr_8way:
11067
11068 popq %r12;
11069
11070 + pax_force_retaddr
11071 ret;
11072 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11073 index 6214a9b..1f4fc9a 100644
11074 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11075 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11076 @@ -1,3 +1,5 @@
11077 +#include <asm/alternative-asm.h>
11078 +
11079 # enter ECRYPT_encrypt_bytes
11080 .text
11081 .p2align 5
11082 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
11083 add %r11,%rsp
11084 mov %rdi,%rax
11085 mov %rsi,%rdx
11086 + pax_force_retaddr 0, 1
11087 ret
11088 # bytesatleast65:
11089 ._bytesatleast65:
11090 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
11091 add %r11,%rsp
11092 mov %rdi,%rax
11093 mov %rsi,%rdx
11094 + pax_force_retaddr
11095 ret
11096 # enter ECRYPT_ivsetup
11097 .text
11098 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
11099 add %r11,%rsp
11100 mov %rdi,%rax
11101 mov %rsi,%rdx
11102 + pax_force_retaddr
11103 ret
11104 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11105 index 02b0e9f..cf4cf5c 100644
11106 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11107 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11108 @@ -24,6 +24,8 @@
11109 *
11110 */
11111
11112 +#include <asm/alternative-asm.h>
11113 +
11114 #include "glue_helper-asm-avx.S"
11115
11116 .file "serpent-avx-x86_64-asm_64.S"
11117 @@ -618,6 +620,7 @@ __serpent_enc_blk8_avx:
11118 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11119 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11120
11121 + pax_force_retaddr
11122 ret;
11123
11124 .align 8
11125 @@ -673,6 +676,7 @@ __serpent_dec_blk8_avx:
11126 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11127 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11128
11129 + pax_force_retaddr
11130 ret;
11131
11132 .align 8
11133 @@ -692,6 +696,7 @@ serpent_ecb_enc_8way_avx:
11134
11135 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11136
11137 + pax_force_retaddr
11138 ret;
11139
11140 .align 8
11141 @@ -711,6 +716,7 @@ serpent_ecb_dec_8way_avx:
11142
11143 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11144
11145 + pax_force_retaddr
11146 ret;
11147
11148 .align 8
11149 @@ -730,6 +736,7 @@ serpent_cbc_dec_8way_avx:
11150
11151 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11152
11153 + pax_force_retaddr
11154 ret;
11155
11156 .align 8
11157 @@ -751,4 +758,5 @@ serpent_ctr_8way_avx:
11158
11159 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11160
11161 + pax_force_retaddr
11162 ret;
11163 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11164 index 3ee1ff0..cbc568b 100644
11165 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11166 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11167 @@ -24,6 +24,8 @@
11168 *
11169 */
11170
11171 +#include <asm/alternative-asm.h>
11172 +
11173 .file "serpent-sse2-x86_64-asm_64.S"
11174 .text
11175
11176 @@ -692,12 +694,14 @@ __serpent_enc_blk_8way:
11177 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11178 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11179
11180 + pax_force_retaddr
11181 ret;
11182
11183 __enc_xor8:
11184 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11185 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11186
11187 + pax_force_retaddr
11188 ret;
11189
11190 .align 8
11191 @@ -755,4 +759,5 @@ serpent_dec_blk_8way:
11192 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11193 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11194
11195 + pax_force_retaddr
11196 ret;
11197 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11198 index 49d6987..df66bd4 100644
11199 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11200 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11201 @@ -28,6 +28,8 @@
11202 * (at your option) any later version.
11203 */
11204
11205 +#include <asm/alternative-asm.h>
11206 +
11207 #define CTX %rdi // arg1
11208 #define BUF %rsi // arg2
11209 #define CNT %rdx // arg3
11210 @@ -104,6 +106,7 @@
11211 pop %r12
11212 pop %rbp
11213 pop %rbx
11214 + pax_force_retaddr 0, 1
11215 ret
11216
11217 .size \name, .-\name
11218 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11219 index ebac16b..8092eb9 100644
11220 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11221 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11222 @@ -23,6 +23,8 @@
11223 *
11224 */
11225
11226 +#include <asm/alternative-asm.h>
11227 +
11228 #include "glue_helper-asm-avx.S"
11229
11230 .file "twofish-avx-x86_64-asm_64.S"
11231 @@ -283,6 +285,7 @@ __twofish_enc_blk8:
11232 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11233 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11234
11235 + pax_force_retaddr 0, 1
11236 ret;
11237
11238 .align 8
11239 @@ -324,6 +327,7 @@ __twofish_dec_blk8:
11240 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11241 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11242
11243 + pax_force_retaddr 0, 1
11244 ret;
11245
11246 .align 8
11247 @@ -345,6 +349,7 @@ twofish_ecb_enc_8way:
11248
11249 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11250
11251 + pax_force_retaddr 0, 1
11252 ret;
11253
11254 .align 8
11255 @@ -366,6 +371,7 @@ twofish_ecb_dec_8way:
11256
11257 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11258
11259 + pax_force_retaddr 0, 1
11260 ret;
11261
11262 .align 8
11263 @@ -392,6 +398,7 @@ twofish_cbc_dec_8way:
11264
11265 popq %r12;
11266
11267 + pax_force_retaddr 0, 1
11268 ret;
11269
11270 .align 8
11271 @@ -420,4 +427,5 @@ twofish_ctr_8way:
11272
11273 popq %r12;
11274
11275 + pax_force_retaddr 0, 1
11276 ret;
11277 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11278 index 5b012a2..36d5364 100644
11279 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11280 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11281 @@ -20,6 +20,8 @@
11282 *
11283 */
11284
11285 +#include <asm/alternative-asm.h>
11286 +
11287 .file "twofish-x86_64-asm-3way.S"
11288 .text
11289
11290 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
11291 popq %r13;
11292 popq %r14;
11293 popq %r15;
11294 + pax_force_retaddr 0, 1
11295 ret;
11296
11297 __enc_xor3:
11298 @@ -271,6 +274,7 @@ __enc_xor3:
11299 popq %r13;
11300 popq %r14;
11301 popq %r15;
11302 + pax_force_retaddr 0, 1
11303 ret;
11304
11305 .global twofish_dec_blk_3way
11306 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
11307 popq %r13;
11308 popq %r14;
11309 popq %r15;
11310 + pax_force_retaddr 0, 1
11311 ret;
11312
11313 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11314 index 7bcf3fc..f53832f 100644
11315 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11316 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11317 @@ -21,6 +21,7 @@
11318 .text
11319
11320 #include <asm/asm-offsets.h>
11321 +#include <asm/alternative-asm.h>
11322
11323 #define a_offset 0
11324 #define b_offset 4
11325 @@ -268,6 +269,7 @@ twofish_enc_blk:
11326
11327 popq R1
11328 movq $1,%rax
11329 + pax_force_retaddr 0, 1
11330 ret
11331
11332 twofish_dec_blk:
11333 @@ -319,4 +321,5 @@ twofish_dec_blk:
11334
11335 popq R1
11336 movq $1,%rax
11337 + pax_force_retaddr 0, 1
11338 ret
11339 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11340 index a703af1..f5b9c36 100644
11341 --- a/arch/x86/ia32/ia32_aout.c
11342 +++ b/arch/x86/ia32/ia32_aout.c
11343 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11344 unsigned long dump_start, dump_size;
11345 struct user32 dump;
11346
11347 + memset(&dump, 0, sizeof(dump));
11348 +
11349 fs = get_fs();
11350 set_fs(KERNEL_DS);
11351 has_dumped = 1;
11352 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11353 index a1daf4a..f8c4537 100644
11354 --- a/arch/x86/ia32/ia32_signal.c
11355 +++ b/arch/x86/ia32/ia32_signal.c
11356 @@ -348,7 +348,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
11357 sp -= frame_size;
11358 /* Align the stack pointer according to the i386 ABI,
11359 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11360 - sp = ((sp + 4) & -16ul) - 4;
11361 + sp = ((sp - 12) & -16ul) - 4;
11362 return (void __user *) sp;
11363 }
11364
11365 @@ -406,7 +406,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
11366 * These are actually not used anymore, but left because some
11367 * gdb versions depend on them as a marker.
11368 */
11369 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11370 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11371 } put_user_catch(err);
11372
11373 if (err)
11374 @@ -448,7 +448,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11375 0xb8,
11376 __NR_ia32_rt_sigreturn,
11377 0x80cd,
11378 - 0,
11379 + 0
11380 };
11381
11382 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
11383 @@ -471,16 +471,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11384
11385 if (ka->sa.sa_flags & SA_RESTORER)
11386 restorer = ka->sa.sa_restorer;
11387 + else if (current->mm->context.vdso)
11388 + /* Return stub is in 32bit vsyscall page */
11389 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11390 else
11391 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11392 - rt_sigreturn);
11393 + restorer = &frame->retcode;
11394 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11395
11396 /*
11397 * Not actually used anymore, but left because some gdb
11398 * versions need it.
11399 */
11400 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11401 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11402 } put_user_catch(err);
11403
11404 err |= copy_siginfo_to_user32(&frame->info, info);
11405 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11406 index 142c4ce..19b683f 100644
11407 --- a/arch/x86/ia32/ia32entry.S
11408 +++ b/arch/x86/ia32/ia32entry.S
11409 @@ -15,8 +15,10 @@
11410 #include <asm/irqflags.h>
11411 #include <asm/asm.h>
11412 #include <asm/smap.h>
11413 +#include <asm/pgtable.h>
11414 #include <linux/linkage.h>
11415 #include <linux/err.h>
11416 +#include <asm/alternative-asm.h>
11417
11418 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11419 #include <linux/elf-em.h>
11420 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11421 ENDPROC(native_irq_enable_sysexit)
11422 #endif
11423
11424 + .macro pax_enter_kernel_user
11425 + pax_set_fptr_mask
11426 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11427 + call pax_enter_kernel_user
11428 +#endif
11429 + .endm
11430 +
11431 + .macro pax_exit_kernel_user
11432 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11433 + call pax_exit_kernel_user
11434 +#endif
11435 +#ifdef CONFIG_PAX_RANDKSTACK
11436 + pushq %rax
11437 + pushq %r11
11438 + call pax_randomize_kstack
11439 + popq %r11
11440 + popq %rax
11441 +#endif
11442 + .endm
11443 +
11444 +.macro pax_erase_kstack
11445 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11446 + call pax_erase_kstack
11447 +#endif
11448 +.endm
11449 +
11450 /*
11451 * 32bit SYSENTER instruction entry.
11452 *
11453 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11454 CFI_REGISTER rsp,rbp
11455 SWAPGS_UNSAFE_STACK
11456 movq PER_CPU_VAR(kernel_stack), %rsp
11457 - addq $(KERNEL_STACK_OFFSET),%rsp
11458 - /*
11459 - * No need to follow this irqs on/off section: the syscall
11460 - * disabled irqs, here we enable it straight after entry:
11461 - */
11462 - ENABLE_INTERRUPTS(CLBR_NONE)
11463 movl %ebp,%ebp /* zero extension */
11464 pushq_cfi $__USER32_DS
11465 /*CFI_REL_OFFSET ss,0*/
11466 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11467 CFI_REL_OFFSET rsp,0
11468 pushfq_cfi
11469 /*CFI_REL_OFFSET rflags,0*/
11470 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11471 - CFI_REGISTER rip,r10
11472 + orl $X86_EFLAGS_IF,(%rsp)
11473 + GET_THREAD_INFO(%r11)
11474 + movl TI_sysenter_return(%r11), %r11d
11475 + CFI_REGISTER rip,r11
11476 pushq_cfi $__USER32_CS
11477 /*CFI_REL_OFFSET cs,0*/
11478 movl %eax, %eax
11479 - pushq_cfi %r10
11480 + pushq_cfi %r11
11481 CFI_REL_OFFSET rip,0
11482 pushq_cfi %rax
11483 cld
11484 SAVE_ARGS 0,1,0
11485 + pax_enter_kernel_user
11486 +
11487 +#ifdef CONFIG_PAX_RANDKSTACK
11488 + pax_erase_kstack
11489 +#endif
11490 +
11491 + /*
11492 + * No need to follow this irqs on/off section: the syscall
11493 + * disabled irqs, here we enable it straight after entry:
11494 + */
11495 + ENABLE_INTERRUPTS(CLBR_NONE)
11496 /* no need to do an access_ok check here because rbp has been
11497 32bit zero extended */
11498 +
11499 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11500 + mov $PAX_USER_SHADOW_BASE,%r11
11501 + add %r11,%rbp
11502 +#endif
11503 +
11504 ASM_STAC
11505 1: movl (%rbp),%ebp
11506 _ASM_EXTABLE(1b,ia32_badarg)
11507 ASM_CLAC
11508 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11509 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11510 + GET_THREAD_INFO(%r11)
11511 + orl $TS_COMPAT,TI_status(%r11)
11512 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11513 CFI_REMEMBER_STATE
11514 jnz sysenter_tracesys
11515 cmpq $(IA32_NR_syscalls-1),%rax
11516 @@ -162,12 +204,15 @@ sysenter_do_call:
11517 sysenter_dispatch:
11518 call *ia32_sys_call_table(,%rax,8)
11519 movq %rax,RAX-ARGOFFSET(%rsp)
11520 + GET_THREAD_INFO(%r11)
11521 DISABLE_INTERRUPTS(CLBR_NONE)
11522 TRACE_IRQS_OFF
11523 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11524 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11525 jnz sysexit_audit
11526 sysexit_from_sys_call:
11527 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11528 + pax_exit_kernel_user
11529 + pax_erase_kstack
11530 + andl $~TS_COMPAT,TI_status(%r11)
11531 /* clear IF, that popfq doesn't enable interrupts early */
11532 andl $~0x200,EFLAGS-R11(%rsp)
11533 movl RIP-R11(%rsp),%edx /* User %eip */
11534 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11535 movl %eax,%esi /* 2nd arg: syscall number */
11536 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11537 call __audit_syscall_entry
11538 +
11539 + pax_erase_kstack
11540 +
11541 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11542 cmpq $(IA32_NR_syscalls-1),%rax
11543 ja ia32_badsys
11544 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11545 .endm
11546
11547 .macro auditsys_exit exit
11548 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11549 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11550 jnz ia32_ret_from_sys_call
11551 TRACE_IRQS_ON
11552 ENABLE_INTERRUPTS(CLBR_NONE)
11553 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11554 1: setbe %al /* 1 if error, 0 if not */
11555 movzbl %al,%edi /* zero-extend that into %edi */
11556 call __audit_syscall_exit
11557 + GET_THREAD_INFO(%r11)
11558 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11559 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11560 DISABLE_INTERRUPTS(CLBR_NONE)
11561 TRACE_IRQS_OFF
11562 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11563 + testl %edi,TI_flags(%r11)
11564 jz \exit
11565 CLEAR_RREGS -ARGOFFSET
11566 jmp int_with_check
11567 @@ -237,7 +286,7 @@ sysexit_audit:
11568
11569 sysenter_tracesys:
11570 #ifdef CONFIG_AUDITSYSCALL
11571 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11572 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11573 jz sysenter_auditsys
11574 #endif
11575 SAVE_REST
11576 @@ -249,6 +298,9 @@ sysenter_tracesys:
11577 RESTORE_REST
11578 cmpq $(IA32_NR_syscalls-1),%rax
11579 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11580 +
11581 + pax_erase_kstack
11582 +
11583 jmp sysenter_do_call
11584 CFI_ENDPROC
11585 ENDPROC(ia32_sysenter_target)
11586 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11587 ENTRY(ia32_cstar_target)
11588 CFI_STARTPROC32 simple
11589 CFI_SIGNAL_FRAME
11590 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11591 + CFI_DEF_CFA rsp,0
11592 CFI_REGISTER rip,rcx
11593 /*CFI_REGISTER rflags,r11*/
11594 SWAPGS_UNSAFE_STACK
11595 movl %esp,%r8d
11596 CFI_REGISTER rsp,r8
11597 movq PER_CPU_VAR(kernel_stack),%rsp
11598 + SAVE_ARGS 8*6,0,0
11599 + pax_enter_kernel_user
11600 +
11601 +#ifdef CONFIG_PAX_RANDKSTACK
11602 + pax_erase_kstack
11603 +#endif
11604 +
11605 /*
11606 * No need to follow this irqs on/off section: the syscall
11607 * disabled irqs and here we enable it straight after entry:
11608 */
11609 ENABLE_INTERRUPTS(CLBR_NONE)
11610 - SAVE_ARGS 8,0,0
11611 movl %eax,%eax /* zero extension */
11612 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11613 movq %rcx,RIP-ARGOFFSET(%rsp)
11614 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11615 /* no need to do an access_ok check here because r8 has been
11616 32bit zero extended */
11617 /* hardware stack frame is complete now */
11618 +
11619 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11620 + mov $PAX_USER_SHADOW_BASE,%r11
11621 + add %r11,%r8
11622 +#endif
11623 +
11624 ASM_STAC
11625 1: movl (%r8),%r9d
11626 _ASM_EXTABLE(1b,ia32_badarg)
11627 ASM_CLAC
11628 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11629 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11630 + GET_THREAD_INFO(%r11)
11631 + orl $TS_COMPAT,TI_status(%r11)
11632 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11633 CFI_REMEMBER_STATE
11634 jnz cstar_tracesys
11635 cmpq $IA32_NR_syscalls-1,%rax
11636 @@ -319,12 +384,15 @@ cstar_do_call:
11637 cstar_dispatch:
11638 call *ia32_sys_call_table(,%rax,8)
11639 movq %rax,RAX-ARGOFFSET(%rsp)
11640 + GET_THREAD_INFO(%r11)
11641 DISABLE_INTERRUPTS(CLBR_NONE)
11642 TRACE_IRQS_OFF
11643 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11644 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11645 jnz sysretl_audit
11646 sysretl_from_sys_call:
11647 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11648 + pax_exit_kernel_user
11649 + pax_erase_kstack
11650 + andl $~TS_COMPAT,TI_status(%r11)
11651 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11652 movl RIP-ARGOFFSET(%rsp),%ecx
11653 CFI_REGISTER rip,rcx
11654 @@ -352,7 +420,7 @@ sysretl_audit:
11655
11656 cstar_tracesys:
11657 #ifdef CONFIG_AUDITSYSCALL
11658 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11659 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11660 jz cstar_auditsys
11661 #endif
11662 xchgl %r9d,%ebp
11663 @@ -366,6 +434,9 @@ cstar_tracesys:
11664 xchgl %ebp,%r9d
11665 cmpq $(IA32_NR_syscalls-1),%rax
11666 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11667 +
11668 + pax_erase_kstack
11669 +
11670 jmp cstar_do_call
11671 END(ia32_cstar_target)
11672
11673 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11674 CFI_REL_OFFSET rip,RIP-RIP
11675 PARAVIRT_ADJUST_EXCEPTION_FRAME
11676 SWAPGS
11677 - /*
11678 - * No need to follow this irqs on/off section: the syscall
11679 - * disabled irqs and here we enable it straight after entry:
11680 - */
11681 - ENABLE_INTERRUPTS(CLBR_NONE)
11682 movl %eax,%eax
11683 pushq_cfi %rax
11684 cld
11685 /* note the registers are not zero extended to the sf.
11686 this could be a problem. */
11687 SAVE_ARGS 0,1,0
11688 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11689 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11690 + pax_enter_kernel_user
11691 +
11692 +#ifdef CONFIG_PAX_RANDKSTACK
11693 + pax_erase_kstack
11694 +#endif
11695 +
11696 + /*
11697 + * No need to follow this irqs on/off section: the syscall
11698 + * disabled irqs and here we enable it straight after entry:
11699 + */
11700 + ENABLE_INTERRUPTS(CLBR_NONE)
11701 + GET_THREAD_INFO(%r11)
11702 + orl $TS_COMPAT,TI_status(%r11)
11703 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11704 jnz ia32_tracesys
11705 cmpq $(IA32_NR_syscalls-1),%rax
11706 ja ia32_badsys
11707 @@ -442,6 +520,9 @@ ia32_tracesys:
11708 RESTORE_REST
11709 cmpq $(IA32_NR_syscalls-1),%rax
11710 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11711 +
11712 + pax_erase_kstack
11713 +
11714 jmp ia32_do_call
11715 END(ia32_syscall)
11716
11717 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11718 index d0b689b..6811ddc 100644
11719 --- a/arch/x86/ia32/sys_ia32.c
11720 +++ b/arch/x86/ia32/sys_ia32.c
11721 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11722 */
11723 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11724 {
11725 - typeof(ubuf->st_uid) uid = 0;
11726 - typeof(ubuf->st_gid) gid = 0;
11727 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11728 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11729 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11730 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11731 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11732 @@ -303,7 +303,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
11733 mm_segment_t old_fs = get_fs();
11734
11735 set_fs(KERNEL_DS);
11736 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
11737 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
11738 set_fs(old_fs);
11739 if (put_compat_timespec(&t, interval))
11740 return -EFAULT;
11741 @@ -313,13 +313,13 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
11742 asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
11743 compat_size_t sigsetsize)
11744 {
11745 - sigset_t s;
11746 + sigset_t s = { };
11747 compat_sigset_t s32;
11748 int ret;
11749 mm_segment_t old_fs = get_fs();
11750
11751 set_fs(KERNEL_DS);
11752 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
11753 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
11754 set_fs(old_fs);
11755 if (!ret) {
11756 switch (_NSIG_WORDS) {
11757 @@ -344,7 +344,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
11758 if (copy_siginfo_from_user32(&info, uinfo))
11759 return -EFAULT;
11760 set_fs(KERNEL_DS);
11761 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
11762 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
11763 set_fs(old_fs);
11764 return ret;
11765 }
11766 @@ -376,7 +376,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
11767 return -EFAULT;
11768
11769 set_fs(KERNEL_DS);
11770 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
11771 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
11772 count);
11773 set_fs(old_fs);
11774
11775 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11776 index 372231c..a5aa1a1 100644
11777 --- a/arch/x86/include/asm/alternative-asm.h
11778 +++ b/arch/x86/include/asm/alternative-asm.h
11779 @@ -18,6 +18,45 @@
11780 .endm
11781 #endif
11782
11783 +#ifdef KERNEXEC_PLUGIN
11784 + .macro pax_force_retaddr_bts rip=0
11785 + btsq $63,\rip(%rsp)
11786 + .endm
11787 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11788 + .macro pax_force_retaddr rip=0, reload=0
11789 + btsq $63,\rip(%rsp)
11790 + .endm
11791 + .macro pax_force_fptr ptr
11792 + btsq $63,\ptr
11793 + .endm
11794 + .macro pax_set_fptr_mask
11795 + .endm
11796 +#endif
11797 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11798 + .macro pax_force_retaddr rip=0, reload=0
11799 + .if \reload
11800 + pax_set_fptr_mask
11801 + .endif
11802 + orq %r10,\rip(%rsp)
11803 + .endm
11804 + .macro pax_force_fptr ptr
11805 + orq %r10,\ptr
11806 + .endm
11807 + .macro pax_set_fptr_mask
11808 + movabs $0x8000000000000000,%r10
11809 + .endm
11810 +#endif
11811 +#else
11812 + .macro pax_force_retaddr rip=0, reload=0
11813 + .endm
11814 + .macro pax_force_fptr ptr
11815 + .endm
11816 + .macro pax_force_retaddr_bts rip=0
11817 + .endm
11818 + .macro pax_set_fptr_mask
11819 + .endm
11820 +#endif
11821 +
11822 .macro altinstruction_entry orig alt feature orig_len alt_len
11823 .long \orig - .
11824 .long \alt - .
11825 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11826 index 58ed6d9..f1cbe58 100644
11827 --- a/arch/x86/include/asm/alternative.h
11828 +++ b/arch/x86/include/asm/alternative.h
11829 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11830 ".pushsection .discard,\"aw\",@progbits\n" \
11831 DISCARD_ENTRY(1) \
11832 ".popsection\n" \
11833 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11834 + ".pushsection .altinstr_replacement, \"a\"\n" \
11835 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11836 ".popsection"
11837
11838 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11839 DISCARD_ENTRY(1) \
11840 DISCARD_ENTRY(2) \
11841 ".popsection\n" \
11842 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11843 + ".pushsection .altinstr_replacement, \"a\"\n" \
11844 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11845 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11846 ".popsection"
11847 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11848 index 3388034..050f0b9 100644
11849 --- a/arch/x86/include/asm/apic.h
11850 +++ b/arch/x86/include/asm/apic.h
11851 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11852
11853 #ifdef CONFIG_X86_LOCAL_APIC
11854
11855 -extern unsigned int apic_verbosity;
11856 +extern int apic_verbosity;
11857 extern int local_apic_timer_c2_ok;
11858
11859 extern int disable_apic;
11860 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11861 index 20370c6..a2eb9b0 100644
11862 --- a/arch/x86/include/asm/apm.h
11863 +++ b/arch/x86/include/asm/apm.h
11864 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11865 __asm__ __volatile__(APM_DO_ZERO_SEGS
11866 "pushl %%edi\n\t"
11867 "pushl %%ebp\n\t"
11868 - "lcall *%%cs:apm_bios_entry\n\t"
11869 + "lcall *%%ss:apm_bios_entry\n\t"
11870 "setc %%al\n\t"
11871 "popl %%ebp\n\t"
11872 "popl %%edi\n\t"
11873 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11874 __asm__ __volatile__(APM_DO_ZERO_SEGS
11875 "pushl %%edi\n\t"
11876 "pushl %%ebp\n\t"
11877 - "lcall *%%cs:apm_bios_entry\n\t"
11878 + "lcall *%%ss:apm_bios_entry\n\t"
11879 "setc %%bl\n\t"
11880 "popl %%ebp\n\t"
11881 "popl %%edi\n\t"
11882 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11883 index 722aa3b..3a0bb27 100644
11884 --- a/arch/x86/include/asm/atomic.h
11885 +++ b/arch/x86/include/asm/atomic.h
11886 @@ -22,7 +22,18 @@
11887 */
11888 static inline int atomic_read(const atomic_t *v)
11889 {
11890 - return (*(volatile int *)&(v)->counter);
11891 + return (*(volatile const int *)&(v)->counter);
11892 +}
11893 +
11894 +/**
11895 + * atomic_read_unchecked - read atomic variable
11896 + * @v: pointer of type atomic_unchecked_t
11897 + *
11898 + * Atomically reads the value of @v.
11899 + */
11900 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
11901 +{
11902 + return (*(volatile const int *)&(v)->counter);
11903 }
11904
11905 /**
11906 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
11907 }
11908
11909 /**
11910 + * atomic_set_unchecked - set atomic variable
11911 + * @v: pointer of type atomic_unchecked_t
11912 + * @i: required value
11913 + *
11914 + * Atomically sets the value of @v to @i.
11915 + */
11916 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
11917 +{
11918 + v->counter = i;
11919 +}
11920 +
11921 +/**
11922 * atomic_add - add integer to atomic variable
11923 * @i: integer value to add
11924 * @v: pointer of type atomic_t
11925 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
11926 */
11927 static inline void atomic_add(int i, atomic_t *v)
11928 {
11929 - asm volatile(LOCK_PREFIX "addl %1,%0"
11930 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
11931 +
11932 +#ifdef CONFIG_PAX_REFCOUNT
11933 + "jno 0f\n"
11934 + LOCK_PREFIX "subl %1,%0\n"
11935 + "int $4\n0:\n"
11936 + _ASM_EXTABLE(0b, 0b)
11937 +#endif
11938 +
11939 + : "+m" (v->counter)
11940 + : "ir" (i));
11941 +}
11942 +
11943 +/**
11944 + * atomic_add_unchecked - add integer to atomic variable
11945 + * @i: integer value to add
11946 + * @v: pointer of type atomic_unchecked_t
11947 + *
11948 + * Atomically adds @i to @v.
11949 + */
11950 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
11951 +{
11952 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
11953 : "+m" (v->counter)
11954 : "ir" (i));
11955 }
11956 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
11957 */
11958 static inline void atomic_sub(int i, atomic_t *v)
11959 {
11960 - asm volatile(LOCK_PREFIX "subl %1,%0"
11961 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
11962 +
11963 +#ifdef CONFIG_PAX_REFCOUNT
11964 + "jno 0f\n"
11965 + LOCK_PREFIX "addl %1,%0\n"
11966 + "int $4\n0:\n"
11967 + _ASM_EXTABLE(0b, 0b)
11968 +#endif
11969 +
11970 + : "+m" (v->counter)
11971 + : "ir" (i));
11972 +}
11973 +
11974 +/**
11975 + * atomic_sub_unchecked - subtract integer from atomic variable
11976 + * @i: integer value to subtract
11977 + * @v: pointer of type atomic_unchecked_t
11978 + *
11979 + * Atomically subtracts @i from @v.
11980 + */
11981 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
11982 +{
11983 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
11984 : "+m" (v->counter)
11985 : "ir" (i));
11986 }
11987 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
11988 {
11989 unsigned char c;
11990
11991 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
11992 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
11993 +
11994 +#ifdef CONFIG_PAX_REFCOUNT
11995 + "jno 0f\n"
11996 + LOCK_PREFIX "addl %2,%0\n"
11997 + "int $4\n0:\n"
11998 + _ASM_EXTABLE(0b, 0b)
11999 +#endif
12000 +
12001 + "sete %1\n"
12002 : "+m" (v->counter), "=qm" (c)
12003 : "ir" (i) : "memory");
12004 return c;
12005 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12006 */
12007 static inline void atomic_inc(atomic_t *v)
12008 {
12009 - asm volatile(LOCK_PREFIX "incl %0"
12010 + asm volatile(LOCK_PREFIX "incl %0\n"
12011 +
12012 +#ifdef CONFIG_PAX_REFCOUNT
12013 + "jno 0f\n"
12014 + LOCK_PREFIX "decl %0\n"
12015 + "int $4\n0:\n"
12016 + _ASM_EXTABLE(0b, 0b)
12017 +#endif
12018 +
12019 + : "+m" (v->counter));
12020 +}
12021 +
12022 +/**
12023 + * atomic_inc_unchecked - increment atomic variable
12024 + * @v: pointer of type atomic_unchecked_t
12025 + *
12026 + * Atomically increments @v by 1.
12027 + */
12028 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12029 +{
12030 + asm volatile(LOCK_PREFIX "incl %0\n"
12031 : "+m" (v->counter));
12032 }
12033
12034 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12035 */
12036 static inline void atomic_dec(atomic_t *v)
12037 {
12038 - asm volatile(LOCK_PREFIX "decl %0"
12039 + asm volatile(LOCK_PREFIX "decl %0\n"
12040 +
12041 +#ifdef CONFIG_PAX_REFCOUNT
12042 + "jno 0f\n"
12043 + LOCK_PREFIX "incl %0\n"
12044 + "int $4\n0:\n"
12045 + _ASM_EXTABLE(0b, 0b)
12046 +#endif
12047 +
12048 + : "+m" (v->counter));
12049 +}
12050 +
12051 +/**
12052 + * atomic_dec_unchecked - decrement atomic variable
12053 + * @v: pointer of type atomic_unchecked_t
12054 + *
12055 + * Atomically decrements @v by 1.
12056 + */
12057 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12058 +{
12059 + asm volatile(LOCK_PREFIX "decl %0\n"
12060 : "+m" (v->counter));
12061 }
12062
12063 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12064 {
12065 unsigned char c;
12066
12067 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12068 + asm volatile(LOCK_PREFIX "decl %0\n"
12069 +
12070 +#ifdef CONFIG_PAX_REFCOUNT
12071 + "jno 0f\n"
12072 + LOCK_PREFIX "incl %0\n"
12073 + "int $4\n0:\n"
12074 + _ASM_EXTABLE(0b, 0b)
12075 +#endif
12076 +
12077 + "sete %1\n"
12078 : "+m" (v->counter), "=qm" (c)
12079 : : "memory");
12080 return c != 0;
12081 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12082 {
12083 unsigned char c;
12084
12085 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12086 + asm volatile(LOCK_PREFIX "incl %0\n"
12087 +
12088 +#ifdef CONFIG_PAX_REFCOUNT
12089 + "jno 0f\n"
12090 + LOCK_PREFIX "decl %0\n"
12091 + "int $4\n0:\n"
12092 + _ASM_EXTABLE(0b, 0b)
12093 +#endif
12094 +
12095 + "sete %1\n"
12096 + : "+m" (v->counter), "=qm" (c)
12097 + : : "memory");
12098 + return c != 0;
12099 +}
12100 +
12101 +/**
12102 + * atomic_inc_and_test_unchecked - increment and test
12103 + * @v: pointer of type atomic_unchecked_t
12104 + *
12105 + * Atomically increments @v by 1
12106 + * and returns true if the result is zero, or false for all
12107 + * other cases.
12108 + */
12109 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12110 +{
12111 + unsigned char c;
12112 +
12113 + asm volatile(LOCK_PREFIX "incl %0\n"
12114 + "sete %1\n"
12115 : "+m" (v->counter), "=qm" (c)
12116 : : "memory");
12117 return c != 0;
12118 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12119 {
12120 unsigned char c;
12121
12122 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12123 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12124 +
12125 +#ifdef CONFIG_PAX_REFCOUNT
12126 + "jno 0f\n"
12127 + LOCK_PREFIX "subl %2,%0\n"
12128 + "int $4\n0:\n"
12129 + _ASM_EXTABLE(0b, 0b)
12130 +#endif
12131 +
12132 + "sets %1\n"
12133 : "+m" (v->counter), "=qm" (c)
12134 : "ir" (i) : "memory");
12135 return c;
12136 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12137 */
12138 static inline int atomic_add_return(int i, atomic_t *v)
12139 {
12140 + return i + xadd_check_overflow(&v->counter, i);
12141 +}
12142 +
12143 +/**
12144 + * atomic_add_return_unchecked - add integer and return
12145 + * @i: integer value to add
12146 + * @v: pointer of type atomic_unchecked_t
12147 + *
12148 + * Atomically adds @i to @v and returns @i + @v
12149 + */
12150 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12151 +{
12152 return i + xadd(&v->counter, i);
12153 }
12154
12155 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12156 }
12157
12158 #define atomic_inc_return(v) (atomic_add_return(1, v))
12159 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12160 +{
12161 + return atomic_add_return_unchecked(1, v);
12162 +}
12163 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12164
12165 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12166 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12167 return cmpxchg(&v->counter, old, new);
12168 }
12169
12170 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12171 +{
12172 + return cmpxchg(&v->counter, old, new);
12173 +}
12174 +
12175 static inline int atomic_xchg(atomic_t *v, int new)
12176 {
12177 return xchg(&v->counter, new);
12178 }
12179
12180 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12181 +{
12182 + return xchg(&v->counter, new);
12183 +}
12184 +
12185 /**
12186 * __atomic_add_unless - add unless the number is already a given value
12187 * @v: pointer of type atomic_t
12188 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12189 */
12190 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12191 {
12192 - int c, old;
12193 + int c, old, new;
12194 c = atomic_read(v);
12195 for (;;) {
12196 - if (unlikely(c == (u)))
12197 + if (unlikely(c == u))
12198 break;
12199 - old = atomic_cmpxchg((v), c, c + (a));
12200 +
12201 + asm volatile("addl %2,%0\n"
12202 +
12203 +#ifdef CONFIG_PAX_REFCOUNT
12204 + "jno 0f\n"
12205 + "subl %2,%0\n"
12206 + "int $4\n0:\n"
12207 + _ASM_EXTABLE(0b, 0b)
12208 +#endif
12209 +
12210 + : "=r" (new)
12211 + : "0" (c), "ir" (a));
12212 +
12213 + old = atomic_cmpxchg(v, c, new);
12214 if (likely(old == c))
12215 break;
12216 c = old;
12217 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12218 }
12219
12220 /**
12221 + * atomic_inc_not_zero_hint - increment if not null
12222 + * @v: pointer of type atomic_t
12223 + * @hint: probable value of the atomic before the increment
12224 + *
12225 + * This version of atomic_inc_not_zero() gives a hint of probable
12226 + * value of the atomic. This helps processor to not read the memory
12227 + * before doing the atomic read/modify/write cycle, lowering
12228 + * number of bus transactions on some arches.
12229 + *
12230 + * Returns: 0 if increment was not done, 1 otherwise.
12231 + */
12232 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12233 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12234 +{
12235 + int val, c = hint, new;
12236 +
12237 + /* sanity test, should be removed by compiler if hint is a constant */
12238 + if (!hint)
12239 + return __atomic_add_unless(v, 1, 0);
12240 +
12241 + do {
12242 + asm volatile("incl %0\n"
12243 +
12244 +#ifdef CONFIG_PAX_REFCOUNT
12245 + "jno 0f\n"
12246 + "decl %0\n"
12247 + "int $4\n0:\n"
12248 + _ASM_EXTABLE(0b, 0b)
12249 +#endif
12250 +
12251 + : "=r" (new)
12252 + : "0" (c));
12253 +
12254 + val = atomic_cmpxchg(v, c, new);
12255 + if (val == c)
12256 + return 1;
12257 + c = val;
12258 + } while (c);
12259 +
12260 + return 0;
12261 +}
12262 +
12263 +/**
12264 * atomic_inc_short - increment of a short integer
12265 * @v: pointer to type int
12266 *
12267 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12268 #endif
12269
12270 /* These are x86-specific, used by some header files */
12271 -#define atomic_clear_mask(mask, addr) \
12272 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12273 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12274 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12275 +{
12276 + asm volatile(LOCK_PREFIX "andl %1,%0"
12277 + : "+m" (v->counter)
12278 + : "r" (~(mask))
12279 + : "memory");
12280 +}
12281
12282 -#define atomic_set_mask(mask, addr) \
12283 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12284 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12285 - : "memory")
12286 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12287 +{
12288 + asm volatile(LOCK_PREFIX "andl %1,%0"
12289 + : "+m" (v->counter)
12290 + : "r" (~(mask))
12291 + : "memory");
12292 +}
12293 +
12294 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12295 +{
12296 + asm volatile(LOCK_PREFIX "orl %1,%0"
12297 + : "+m" (v->counter)
12298 + : "r" (mask)
12299 + : "memory");
12300 +}
12301 +
12302 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12303 +{
12304 + asm volatile(LOCK_PREFIX "orl %1,%0"
12305 + : "+m" (v->counter)
12306 + : "r" (mask)
12307 + : "memory");
12308 +}
12309
12310 /* Atomic operations are already serializing on x86 */
12311 #define smp_mb__before_atomic_dec() barrier()
12312 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12313 index b154de7..aadebd8 100644
12314 --- a/arch/x86/include/asm/atomic64_32.h
12315 +++ b/arch/x86/include/asm/atomic64_32.h
12316 @@ -12,6 +12,14 @@ typedef struct {
12317 u64 __aligned(8) counter;
12318 } atomic64_t;
12319
12320 +#ifdef CONFIG_PAX_REFCOUNT
12321 +typedef struct {
12322 + u64 __aligned(8) counter;
12323 +} atomic64_unchecked_t;
12324 +#else
12325 +typedef atomic64_t atomic64_unchecked_t;
12326 +#endif
12327 +
12328 #define ATOMIC64_INIT(val) { (val) }
12329
12330 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12331 @@ -37,21 +45,31 @@ typedef struct {
12332 ATOMIC64_DECL_ONE(sym##_386)
12333
12334 ATOMIC64_DECL_ONE(add_386);
12335 +ATOMIC64_DECL_ONE(add_unchecked_386);
12336 ATOMIC64_DECL_ONE(sub_386);
12337 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12338 ATOMIC64_DECL_ONE(inc_386);
12339 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12340 ATOMIC64_DECL_ONE(dec_386);
12341 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12342 #endif
12343
12344 #define alternative_atomic64(f, out, in...) \
12345 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12346
12347 ATOMIC64_DECL(read);
12348 +ATOMIC64_DECL(read_unchecked);
12349 ATOMIC64_DECL(set);
12350 +ATOMIC64_DECL(set_unchecked);
12351 ATOMIC64_DECL(xchg);
12352 ATOMIC64_DECL(add_return);
12353 +ATOMIC64_DECL(add_return_unchecked);
12354 ATOMIC64_DECL(sub_return);
12355 +ATOMIC64_DECL(sub_return_unchecked);
12356 ATOMIC64_DECL(inc_return);
12357 +ATOMIC64_DECL(inc_return_unchecked);
12358 ATOMIC64_DECL(dec_return);
12359 +ATOMIC64_DECL(dec_return_unchecked);
12360 ATOMIC64_DECL(dec_if_positive);
12361 ATOMIC64_DECL(inc_not_zero);
12362 ATOMIC64_DECL(add_unless);
12363 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12364 }
12365
12366 /**
12367 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12368 + * @p: pointer to type atomic64_unchecked_t
12369 + * @o: expected value
12370 + * @n: new value
12371 + *
12372 + * Atomically sets @v to @n if it was equal to @o and returns
12373 + * the old value.
12374 + */
12375 +
12376 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12377 +{
12378 + return cmpxchg64(&v->counter, o, n);
12379 +}
12380 +
12381 +/**
12382 * atomic64_xchg - xchg atomic64 variable
12383 * @v: pointer to type atomic64_t
12384 * @n: value to assign
12385 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12386 }
12387
12388 /**
12389 + * atomic64_set_unchecked - set atomic64 variable
12390 + * @v: pointer to type atomic64_unchecked_t
12391 + * @n: value to assign
12392 + *
12393 + * Atomically sets the value of @v to @n.
12394 + */
12395 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12396 +{
12397 + unsigned high = (unsigned)(i >> 32);
12398 + unsigned low = (unsigned)i;
12399 + alternative_atomic64(set, /* no output */,
12400 + "S" (v), "b" (low), "c" (high)
12401 + : "eax", "edx", "memory");
12402 +}
12403 +
12404 +/**
12405 * atomic64_read - read atomic64 variable
12406 * @v: pointer to type atomic64_t
12407 *
12408 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12409 }
12410
12411 /**
12412 + * atomic64_read_unchecked - read atomic64 variable
12413 + * @v: pointer to type atomic64_unchecked_t
12414 + *
12415 + * Atomically reads the value of @v and returns it.
12416 + */
12417 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12418 +{
12419 + long long r;
12420 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12421 + return r;
12422 + }
12423 +
12424 +/**
12425 * atomic64_add_return - add and return
12426 * @i: integer value to add
12427 * @v: pointer to type atomic64_t
12428 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12429 return i;
12430 }
12431
12432 +/**
12433 + * atomic64_add_return_unchecked - add and return
12434 + * @i: integer value to add
12435 + * @v: pointer to type atomic64_unchecked_t
12436 + *
12437 + * Atomically adds @i to @v and returns @i + *@v
12438 + */
12439 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12440 +{
12441 + alternative_atomic64(add_return_unchecked,
12442 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12443 + ASM_NO_INPUT_CLOBBER("memory"));
12444 + return i;
12445 +}
12446 +
12447 /*
12448 * Other variants with different arithmetic operators:
12449 */
12450 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12451 return a;
12452 }
12453
12454 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12455 +{
12456 + long long a;
12457 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12458 + "S" (v) : "memory", "ecx");
12459 + return a;
12460 +}
12461 +
12462 static inline long long atomic64_dec_return(atomic64_t *v)
12463 {
12464 long long a;
12465 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12466 }
12467
12468 /**
12469 + * atomic64_add_unchecked - add integer to atomic64 variable
12470 + * @i: integer value to add
12471 + * @v: pointer to type atomic64_unchecked_t
12472 + *
12473 + * Atomically adds @i to @v.
12474 + */
12475 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12476 +{
12477 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12478 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12479 + ASM_NO_INPUT_CLOBBER("memory"));
12480 + return i;
12481 +}
12482 +
12483 +/**
12484 * atomic64_sub - subtract the atomic64 variable
12485 * @i: integer value to subtract
12486 * @v: pointer to type atomic64_t
12487 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12488 index 0e1cbfc..5623683 100644
12489 --- a/arch/x86/include/asm/atomic64_64.h
12490 +++ b/arch/x86/include/asm/atomic64_64.h
12491 @@ -18,7 +18,19 @@
12492 */
12493 static inline long atomic64_read(const atomic64_t *v)
12494 {
12495 - return (*(volatile long *)&(v)->counter);
12496 + return (*(volatile const long *)&(v)->counter);
12497 +}
12498 +
12499 +/**
12500 + * atomic64_read_unchecked - read atomic64 variable
12501 + * @v: pointer of type atomic64_unchecked_t
12502 + *
12503 + * Atomically reads the value of @v.
12504 + * Doesn't imply a read memory barrier.
12505 + */
12506 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12507 +{
12508 + return (*(volatile const long *)&(v)->counter);
12509 }
12510
12511 /**
12512 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12513 }
12514
12515 /**
12516 + * atomic64_set_unchecked - set atomic64 variable
12517 + * @v: pointer to type atomic64_unchecked_t
12518 + * @i: required value
12519 + *
12520 + * Atomically sets the value of @v to @i.
12521 + */
12522 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12523 +{
12524 + v->counter = i;
12525 +}
12526 +
12527 +/**
12528 * atomic64_add - add integer to atomic64 variable
12529 * @i: integer value to add
12530 * @v: pointer to type atomic64_t
12531 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12532 */
12533 static inline void atomic64_add(long i, atomic64_t *v)
12534 {
12535 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12536 +
12537 +#ifdef CONFIG_PAX_REFCOUNT
12538 + "jno 0f\n"
12539 + LOCK_PREFIX "subq %1,%0\n"
12540 + "int $4\n0:\n"
12541 + _ASM_EXTABLE(0b, 0b)
12542 +#endif
12543 +
12544 + : "=m" (v->counter)
12545 + : "er" (i), "m" (v->counter));
12546 +}
12547 +
12548 +/**
12549 + * atomic64_add_unchecked - add integer to atomic64 variable
12550 + * @i: integer value to add
12551 + * @v: pointer to type atomic64_unchecked_t
12552 + *
12553 + * Atomically adds @i to @v.
12554 + */
12555 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12556 +{
12557 asm volatile(LOCK_PREFIX "addq %1,%0"
12558 : "=m" (v->counter)
12559 : "er" (i), "m" (v->counter));
12560 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12561 */
12562 static inline void atomic64_sub(long i, atomic64_t *v)
12563 {
12564 - asm volatile(LOCK_PREFIX "subq %1,%0"
12565 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12566 +
12567 +#ifdef CONFIG_PAX_REFCOUNT
12568 + "jno 0f\n"
12569 + LOCK_PREFIX "addq %1,%0\n"
12570 + "int $4\n0:\n"
12571 + _ASM_EXTABLE(0b, 0b)
12572 +#endif
12573 +
12574 + : "=m" (v->counter)
12575 + : "er" (i), "m" (v->counter));
12576 +}
12577 +
12578 +/**
12579 + * atomic64_sub_unchecked - subtract the atomic64 variable
12580 + * @i: integer value to subtract
12581 + * @v: pointer to type atomic64_unchecked_t
12582 + *
12583 + * Atomically subtracts @i from @v.
12584 + */
12585 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12586 +{
12587 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12588 : "=m" (v->counter)
12589 : "er" (i), "m" (v->counter));
12590 }
12591 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12592 {
12593 unsigned char c;
12594
12595 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12596 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12597 +
12598 +#ifdef CONFIG_PAX_REFCOUNT
12599 + "jno 0f\n"
12600 + LOCK_PREFIX "addq %2,%0\n"
12601 + "int $4\n0:\n"
12602 + _ASM_EXTABLE(0b, 0b)
12603 +#endif
12604 +
12605 + "sete %1\n"
12606 : "=m" (v->counter), "=qm" (c)
12607 : "er" (i), "m" (v->counter) : "memory");
12608 return c;
12609 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12610 */
12611 static inline void atomic64_inc(atomic64_t *v)
12612 {
12613 + asm volatile(LOCK_PREFIX "incq %0\n"
12614 +
12615 +#ifdef CONFIG_PAX_REFCOUNT
12616 + "jno 0f\n"
12617 + LOCK_PREFIX "decq %0\n"
12618 + "int $4\n0:\n"
12619 + _ASM_EXTABLE(0b, 0b)
12620 +#endif
12621 +
12622 + : "=m" (v->counter)
12623 + : "m" (v->counter));
12624 +}
12625 +
12626 +/**
12627 + * atomic64_inc_unchecked - increment atomic64 variable
12628 + * @v: pointer to type atomic64_unchecked_t
12629 + *
12630 + * Atomically increments @v by 1.
12631 + */
12632 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12633 +{
12634 asm volatile(LOCK_PREFIX "incq %0"
12635 : "=m" (v->counter)
12636 : "m" (v->counter));
12637 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12638 */
12639 static inline void atomic64_dec(atomic64_t *v)
12640 {
12641 - asm volatile(LOCK_PREFIX "decq %0"
12642 + asm volatile(LOCK_PREFIX "decq %0\n"
12643 +
12644 +#ifdef CONFIG_PAX_REFCOUNT
12645 + "jno 0f\n"
12646 + LOCK_PREFIX "incq %0\n"
12647 + "int $4\n0:\n"
12648 + _ASM_EXTABLE(0b, 0b)
12649 +#endif
12650 +
12651 + : "=m" (v->counter)
12652 + : "m" (v->counter));
12653 +}
12654 +
12655 +/**
12656 + * atomic64_dec_unchecked - decrement atomic64 variable
12657 + * @v: pointer to type atomic64_t
12658 + *
12659 + * Atomically decrements @v by 1.
12660 + */
12661 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12662 +{
12663 + asm volatile(LOCK_PREFIX "decq %0\n"
12664 : "=m" (v->counter)
12665 : "m" (v->counter));
12666 }
12667 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12668 {
12669 unsigned char c;
12670
12671 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12672 + asm volatile(LOCK_PREFIX "decq %0\n"
12673 +
12674 +#ifdef CONFIG_PAX_REFCOUNT
12675 + "jno 0f\n"
12676 + LOCK_PREFIX "incq %0\n"
12677 + "int $4\n0:\n"
12678 + _ASM_EXTABLE(0b, 0b)
12679 +#endif
12680 +
12681 + "sete %1\n"
12682 : "=m" (v->counter), "=qm" (c)
12683 : "m" (v->counter) : "memory");
12684 return c != 0;
12685 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12686 {
12687 unsigned char c;
12688
12689 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12690 + asm volatile(LOCK_PREFIX "incq %0\n"
12691 +
12692 +#ifdef CONFIG_PAX_REFCOUNT
12693 + "jno 0f\n"
12694 + LOCK_PREFIX "decq %0\n"
12695 + "int $4\n0:\n"
12696 + _ASM_EXTABLE(0b, 0b)
12697 +#endif
12698 +
12699 + "sete %1\n"
12700 : "=m" (v->counter), "=qm" (c)
12701 : "m" (v->counter) : "memory");
12702 return c != 0;
12703 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12704 {
12705 unsigned char c;
12706
12707 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12708 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12709 +
12710 +#ifdef CONFIG_PAX_REFCOUNT
12711 + "jno 0f\n"
12712 + LOCK_PREFIX "subq %2,%0\n"
12713 + "int $4\n0:\n"
12714 + _ASM_EXTABLE(0b, 0b)
12715 +#endif
12716 +
12717 + "sets %1\n"
12718 : "=m" (v->counter), "=qm" (c)
12719 : "er" (i), "m" (v->counter) : "memory");
12720 return c;
12721 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12722 */
12723 static inline long atomic64_add_return(long i, atomic64_t *v)
12724 {
12725 + return i + xadd_check_overflow(&v->counter, i);
12726 +}
12727 +
12728 +/**
12729 + * atomic64_add_return_unchecked - add and return
12730 + * @i: integer value to add
12731 + * @v: pointer to type atomic64_unchecked_t
12732 + *
12733 + * Atomically adds @i to @v and returns @i + @v
12734 + */
12735 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12736 +{
12737 return i + xadd(&v->counter, i);
12738 }
12739
12740 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12741 }
12742
12743 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12744 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12745 +{
12746 + return atomic64_add_return_unchecked(1, v);
12747 +}
12748 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12749
12750 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12751 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12752 return cmpxchg(&v->counter, old, new);
12753 }
12754
12755 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12756 +{
12757 + return cmpxchg(&v->counter, old, new);
12758 +}
12759 +
12760 static inline long atomic64_xchg(atomic64_t *v, long new)
12761 {
12762 return xchg(&v->counter, new);
12763 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12764 */
12765 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12766 {
12767 - long c, old;
12768 + long c, old, new;
12769 c = atomic64_read(v);
12770 for (;;) {
12771 - if (unlikely(c == (u)))
12772 + if (unlikely(c == u))
12773 break;
12774 - old = atomic64_cmpxchg((v), c, c + (a));
12775 +
12776 + asm volatile("add %2,%0\n"
12777 +
12778 +#ifdef CONFIG_PAX_REFCOUNT
12779 + "jno 0f\n"
12780 + "sub %2,%0\n"
12781 + "int $4\n0:\n"
12782 + _ASM_EXTABLE(0b, 0b)
12783 +#endif
12784 +
12785 + : "=r" (new)
12786 + : "0" (c), "ir" (a));
12787 +
12788 + old = atomic64_cmpxchg(v, c, new);
12789 if (likely(old == c))
12790 break;
12791 c = old;
12792 }
12793 - return c != (u);
12794 + return c != u;
12795 }
12796
12797 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12798 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12799 index 6dfd019..28e188d 100644
12800 --- a/arch/x86/include/asm/bitops.h
12801 +++ b/arch/x86/include/asm/bitops.h
12802 @@ -40,7 +40,7 @@
12803 * a mask operation on a byte.
12804 */
12805 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12806 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12807 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12808 #define CONST_MASK(nr) (1 << ((nr) & 7))
12809
12810 /**
12811 @@ -486,7 +486,7 @@ static inline int fls(int x)
12812 * at position 64.
12813 */
12814 #ifdef CONFIG_X86_64
12815 -static __always_inline int fls64(__u64 x)
12816 +static __always_inline long fls64(__u64 x)
12817 {
12818 int bitpos = -1;
12819 /*
12820 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12821 index 4fa687a..60f2d39 100644
12822 --- a/arch/x86/include/asm/boot.h
12823 +++ b/arch/x86/include/asm/boot.h
12824 @@ -6,10 +6,15 @@
12825 #include <uapi/asm/boot.h>
12826
12827 /* Physical address where kernel should be loaded. */
12828 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12829 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12830 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12831 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12832
12833 +#ifndef __ASSEMBLY__
12834 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12835 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12836 +#endif
12837 +
12838 /* Minimum kernel alignment, as a power of two */
12839 #ifdef CONFIG_X86_64
12840 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12841 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12842 index 48f99f1..d78ebf9 100644
12843 --- a/arch/x86/include/asm/cache.h
12844 +++ b/arch/x86/include/asm/cache.h
12845 @@ -5,12 +5,13 @@
12846
12847 /* L1 cache line size */
12848 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12849 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12850 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12851
12852 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12853 +#define __read_only __attribute__((__section__(".data..read_only")))
12854
12855 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12856 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12857 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12858
12859 #ifdef CONFIG_X86_VSMP
12860 #ifdef CONFIG_SMP
12861 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12862 index 9863ee3..4a1f8e1 100644
12863 --- a/arch/x86/include/asm/cacheflush.h
12864 +++ b/arch/x86/include/asm/cacheflush.h
12865 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12866 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12867
12868 if (pg_flags == _PGMT_DEFAULT)
12869 - return -1;
12870 + return ~0UL;
12871 else if (pg_flags == _PGMT_WC)
12872 return _PAGE_CACHE_WC;
12873 else if (pg_flags == _PGMT_UC_MINUS)
12874 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12875 index 46fc474..b02b0f9 100644
12876 --- a/arch/x86/include/asm/checksum_32.h
12877 +++ b/arch/x86/include/asm/checksum_32.h
12878 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12879 int len, __wsum sum,
12880 int *src_err_ptr, int *dst_err_ptr);
12881
12882 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12883 + int len, __wsum sum,
12884 + int *src_err_ptr, int *dst_err_ptr);
12885 +
12886 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12887 + int len, __wsum sum,
12888 + int *src_err_ptr, int *dst_err_ptr);
12889 +
12890 /*
12891 * Note: when you get a NULL pointer exception here this means someone
12892 * passed in an incorrect kernel address to one of these functions.
12893 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
12894 int *err_ptr)
12895 {
12896 might_sleep();
12897 - return csum_partial_copy_generic((__force void *)src, dst,
12898 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
12899 len, sum, err_ptr, NULL);
12900 }
12901
12902 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
12903 {
12904 might_sleep();
12905 if (access_ok(VERIFY_WRITE, dst, len))
12906 - return csum_partial_copy_generic(src, (__force void *)dst,
12907 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
12908 len, sum, NULL, err_ptr);
12909
12910 if (len)
12911 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
12912 index 8d871ea..c1a0dc9 100644
12913 --- a/arch/x86/include/asm/cmpxchg.h
12914 +++ b/arch/x86/include/asm/cmpxchg.h
12915 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
12916 __compiletime_error("Bad argument size for cmpxchg");
12917 extern void __xadd_wrong_size(void)
12918 __compiletime_error("Bad argument size for xadd");
12919 +extern void __xadd_check_overflow_wrong_size(void)
12920 + __compiletime_error("Bad argument size for xadd_check_overflow");
12921 extern void __add_wrong_size(void)
12922 __compiletime_error("Bad argument size for add");
12923 +extern void __add_check_overflow_wrong_size(void)
12924 + __compiletime_error("Bad argument size for add_check_overflow");
12925
12926 /*
12927 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
12928 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
12929 __ret; \
12930 })
12931
12932 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
12933 + ({ \
12934 + __typeof__ (*(ptr)) __ret = (arg); \
12935 + switch (sizeof(*(ptr))) { \
12936 + case __X86_CASE_L: \
12937 + asm volatile (lock #op "l %0, %1\n" \
12938 + "jno 0f\n" \
12939 + "mov %0,%1\n" \
12940 + "int $4\n0:\n" \
12941 + _ASM_EXTABLE(0b, 0b) \
12942 + : "+r" (__ret), "+m" (*(ptr)) \
12943 + : : "memory", "cc"); \
12944 + break; \
12945 + case __X86_CASE_Q: \
12946 + asm volatile (lock #op "q %q0, %1\n" \
12947 + "jno 0f\n" \
12948 + "mov %0,%1\n" \
12949 + "int $4\n0:\n" \
12950 + _ASM_EXTABLE(0b, 0b) \
12951 + : "+r" (__ret), "+m" (*(ptr)) \
12952 + : : "memory", "cc"); \
12953 + break; \
12954 + default: \
12955 + __ ## op ## _check_overflow_wrong_size(); \
12956 + } \
12957 + __ret; \
12958 + })
12959 +
12960 /*
12961 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
12962 * Since this is generally used to protect other memory information, we
12963 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
12964 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
12965 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
12966
12967 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
12968 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
12969 +
12970 #define __add(ptr, inc, lock) \
12971 ({ \
12972 __typeof__ (*(ptr)) __ret = (inc); \
12973 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
12974 index 59c6c40..5e0b22c 100644
12975 --- a/arch/x86/include/asm/compat.h
12976 +++ b/arch/x86/include/asm/compat.h
12977 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
12978 typedef u32 compat_uint_t;
12979 typedef u32 compat_ulong_t;
12980 typedef u64 __attribute__((aligned(4))) compat_u64;
12981 -typedef u32 compat_uptr_t;
12982 +typedef u32 __user compat_uptr_t;
12983
12984 struct compat_timespec {
12985 compat_time_t tv_sec;
12986 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
12987 index 2d9075e..b75a844 100644
12988 --- a/arch/x86/include/asm/cpufeature.h
12989 +++ b/arch/x86/include/asm/cpufeature.h
12990 @@ -206,7 +206,7 @@
12991 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
12992 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
12993 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
12994 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
12995 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
12996 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
12997 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
12998 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
12999 @@ -375,7 +375,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13000 ".section .discard,\"aw\",@progbits\n"
13001 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13002 ".previous\n"
13003 - ".section .altinstr_replacement,\"ax\"\n"
13004 + ".section .altinstr_replacement,\"a\"\n"
13005 "3: movb $1,%0\n"
13006 "4:\n"
13007 ".previous\n"
13008 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13009 index 8bf1c06..b6ae785 100644
13010 --- a/arch/x86/include/asm/desc.h
13011 +++ b/arch/x86/include/asm/desc.h
13012 @@ -4,6 +4,7 @@
13013 #include <asm/desc_defs.h>
13014 #include <asm/ldt.h>
13015 #include <asm/mmu.h>
13016 +#include <asm/pgtable.h>
13017
13018 #include <linux/smp.h>
13019 #include <linux/percpu.h>
13020 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13021
13022 desc->type = (info->read_exec_only ^ 1) << 1;
13023 desc->type |= info->contents << 2;
13024 + desc->type |= info->seg_not_present ^ 1;
13025
13026 desc->s = 1;
13027 desc->dpl = 0x3;
13028 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13029 }
13030
13031 extern struct desc_ptr idt_descr;
13032 -extern gate_desc idt_table[];
13033 extern struct desc_ptr nmi_idt_descr;
13034 -extern gate_desc nmi_idt_table[];
13035 -
13036 -struct gdt_page {
13037 - struct desc_struct gdt[GDT_ENTRIES];
13038 -} __attribute__((aligned(PAGE_SIZE)));
13039 -
13040 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13041 +extern gate_desc idt_table[256];
13042 +extern gate_desc nmi_idt_table[256];
13043
13044 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13045 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13046 {
13047 - return per_cpu(gdt_page, cpu).gdt;
13048 + return cpu_gdt_table[cpu];
13049 }
13050
13051 #ifdef CONFIG_X86_64
13052 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13053 unsigned long base, unsigned dpl, unsigned flags,
13054 unsigned short seg)
13055 {
13056 - gate->a = (seg << 16) | (base & 0xffff);
13057 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13058 + gate->gate.offset_low = base;
13059 + gate->gate.seg = seg;
13060 + gate->gate.reserved = 0;
13061 + gate->gate.type = type;
13062 + gate->gate.s = 0;
13063 + gate->gate.dpl = dpl;
13064 + gate->gate.p = 1;
13065 + gate->gate.offset_high = base >> 16;
13066 }
13067
13068 #endif
13069 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13070
13071 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13072 {
13073 + pax_open_kernel();
13074 memcpy(&idt[entry], gate, sizeof(*gate));
13075 + pax_close_kernel();
13076 }
13077
13078 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13079 {
13080 + pax_open_kernel();
13081 memcpy(&ldt[entry], desc, 8);
13082 + pax_close_kernel();
13083 }
13084
13085 static inline void
13086 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13087 default: size = sizeof(*gdt); break;
13088 }
13089
13090 + pax_open_kernel();
13091 memcpy(&gdt[entry], desc, size);
13092 + pax_close_kernel();
13093 }
13094
13095 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13096 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13097
13098 static inline void native_load_tr_desc(void)
13099 {
13100 + pax_open_kernel();
13101 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13102 + pax_close_kernel();
13103 }
13104
13105 static inline void native_load_gdt(const struct desc_ptr *dtr)
13106 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13107 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13108 unsigned int i;
13109
13110 + pax_open_kernel();
13111 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13112 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13113 + pax_close_kernel();
13114 }
13115
13116 #define _LDT_empty(info) \
13117 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13118 preempt_enable();
13119 }
13120
13121 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13122 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13123 {
13124 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13125 }
13126 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13127 }
13128
13129 #ifdef CONFIG_X86_64
13130 -static inline void set_nmi_gate(int gate, void *addr)
13131 +static inline void set_nmi_gate(int gate, const void *addr)
13132 {
13133 gate_desc s;
13134
13135 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13136 }
13137 #endif
13138
13139 -static inline void _set_gate(int gate, unsigned type, void *addr,
13140 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13141 unsigned dpl, unsigned ist, unsigned seg)
13142 {
13143 gate_desc s;
13144 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13145 * Pentium F0 0F bugfix can have resulted in the mapped
13146 * IDT being write-protected.
13147 */
13148 -static inline void set_intr_gate(unsigned int n, void *addr)
13149 +static inline void set_intr_gate(unsigned int n, const void *addr)
13150 {
13151 BUG_ON((unsigned)n > 0xFF);
13152 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13153 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13154 /*
13155 * This routine sets up an interrupt gate at directory privilege level 3.
13156 */
13157 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13158 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13159 {
13160 BUG_ON((unsigned)n > 0xFF);
13161 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13162 }
13163
13164 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13165 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13166 {
13167 BUG_ON((unsigned)n > 0xFF);
13168 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13169 }
13170
13171 -static inline void set_trap_gate(unsigned int n, void *addr)
13172 +static inline void set_trap_gate(unsigned int n, const void *addr)
13173 {
13174 BUG_ON((unsigned)n > 0xFF);
13175 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13176 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13177 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13178 {
13179 BUG_ON((unsigned)n > 0xFF);
13180 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13181 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13182 }
13183
13184 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13185 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13186 {
13187 BUG_ON((unsigned)n > 0xFF);
13188 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13189 }
13190
13191 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13192 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13193 {
13194 BUG_ON((unsigned)n > 0xFF);
13195 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13196 }
13197
13198 +#ifdef CONFIG_X86_32
13199 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13200 +{
13201 + struct desc_struct d;
13202 +
13203 + if (likely(limit))
13204 + limit = (limit - 1UL) >> PAGE_SHIFT;
13205 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13206 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13207 +}
13208 +#endif
13209 +
13210 #endif /* _ASM_X86_DESC_H */
13211 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13212 index 278441f..b95a174 100644
13213 --- a/arch/x86/include/asm/desc_defs.h
13214 +++ b/arch/x86/include/asm/desc_defs.h
13215 @@ -31,6 +31,12 @@ struct desc_struct {
13216 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13217 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13218 };
13219 + struct {
13220 + u16 offset_low;
13221 + u16 seg;
13222 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13223 + unsigned offset_high: 16;
13224 + } gate;
13225 };
13226 } __attribute__((packed));
13227
13228 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13229 index ced283a..ffe04cc 100644
13230 --- a/arch/x86/include/asm/div64.h
13231 +++ b/arch/x86/include/asm/div64.h
13232 @@ -39,7 +39,7 @@
13233 __mod; \
13234 })
13235
13236 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13237 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13238 {
13239 union {
13240 u64 v64;
13241 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13242 index 9c999c1..3860cb8 100644
13243 --- a/arch/x86/include/asm/elf.h
13244 +++ b/arch/x86/include/asm/elf.h
13245 @@ -243,7 +243,25 @@ extern int force_personality32;
13246 the loader. We need to make sure that it is out of the way of the program
13247 that it will "exec", and that there is sufficient room for the brk. */
13248
13249 +#ifdef CONFIG_PAX_SEGMEXEC
13250 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13251 +#else
13252 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13253 +#endif
13254 +
13255 +#ifdef CONFIG_PAX_ASLR
13256 +#ifdef CONFIG_X86_32
13257 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13258 +
13259 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13260 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13261 +#else
13262 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13263 +
13264 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13265 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13266 +#endif
13267 +#endif
13268
13269 /* This yields a mask that user programs can use to figure out what
13270 instruction set this CPU supports. This could be done in user space,
13271 @@ -296,16 +314,12 @@ do { \
13272
13273 #define ARCH_DLINFO \
13274 do { \
13275 - if (vdso_enabled) \
13276 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13277 - (unsigned long)current->mm->context.vdso); \
13278 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13279 } while (0)
13280
13281 #define ARCH_DLINFO_X32 \
13282 do { \
13283 - if (vdso_enabled) \
13284 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13285 - (unsigned long)current->mm->context.vdso); \
13286 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13287 } while (0)
13288
13289 #define AT_SYSINFO 32
13290 @@ -320,7 +334,7 @@ else \
13291
13292 #endif /* !CONFIG_X86_32 */
13293
13294 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13295 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13296
13297 #define VDSO_ENTRY \
13298 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13299 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13300 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13301 #define compat_arch_setup_additional_pages syscall32_setup_pages
13302
13303 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13304 -#define arch_randomize_brk arch_randomize_brk
13305 -
13306 /*
13307 * True on X86_32 or when emulating IA32 on X86_64
13308 */
13309 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13310 index 75ce3f4..882e801 100644
13311 --- a/arch/x86/include/asm/emergency-restart.h
13312 +++ b/arch/x86/include/asm/emergency-restart.h
13313 @@ -13,6 +13,6 @@ enum reboot_type {
13314
13315 extern enum reboot_type reboot_type;
13316
13317 -extern void machine_emergency_restart(void);
13318 +extern void machine_emergency_restart(void) __noreturn;
13319
13320 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13321 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13322 index 41ab26e..a88c9e6 100644
13323 --- a/arch/x86/include/asm/fpu-internal.h
13324 +++ b/arch/x86/include/asm/fpu-internal.h
13325 @@ -126,7 +126,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13326 ({ \
13327 int err; \
13328 asm volatile(ASM_STAC "\n" \
13329 - "1:" #insn "\n\t" \
13330 + "1:" \
13331 + __copyuser_seg \
13332 + #insn "\n\t" \
13333 "2: " ASM_CLAC "\n" \
13334 ".section .fixup,\"ax\"\n" \
13335 "3: movl $-1,%[err]\n" \
13336 @@ -299,7 +301,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13337 "emms\n\t" /* clear stack tags */
13338 "fildl %P[addr]", /* set F?P to defined value */
13339 X86_FEATURE_FXSAVE_LEAK,
13340 - [addr] "m" (tsk->thread.fpu.has_fpu));
13341 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13342
13343 return fpu_restore_checking(&tsk->thread.fpu);
13344 }
13345 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13346 index be27ba1..8f13ff9 100644
13347 --- a/arch/x86/include/asm/futex.h
13348 +++ b/arch/x86/include/asm/futex.h
13349 @@ -12,6 +12,7 @@
13350 #include <asm/smap.h>
13351
13352 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13353 + typecheck(u32 __user *, uaddr); \
13354 asm volatile("\t" ASM_STAC "\n" \
13355 "1:\t" insn "\n" \
13356 "2:\t" ASM_CLAC "\n" \
13357 @@ -20,15 +21,16 @@
13358 "\tjmp\t2b\n" \
13359 "\t.previous\n" \
13360 _ASM_EXTABLE(1b, 3b) \
13361 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13362 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13363 : "i" (-EFAULT), "0" (oparg), "1" (0))
13364
13365 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13366 + typecheck(u32 __user *, uaddr); \
13367 asm volatile("\t" ASM_STAC "\n" \
13368 "1:\tmovl %2, %0\n" \
13369 "\tmovl\t%0, %3\n" \
13370 "\t" insn "\n" \
13371 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13372 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13373 "\tjnz\t1b\n" \
13374 "3:\t" ASM_CLAC "\n" \
13375 "\t.section .fixup,\"ax\"\n" \
13376 @@ -38,7 +40,7 @@
13377 _ASM_EXTABLE(1b, 4b) \
13378 _ASM_EXTABLE(2b, 4b) \
13379 : "=&a" (oldval), "=&r" (ret), \
13380 - "+m" (*uaddr), "=&r" (tem) \
13381 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13382 : "r" (oparg), "i" (-EFAULT), "1" (0))
13383
13384 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13385 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13386
13387 switch (op) {
13388 case FUTEX_OP_SET:
13389 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13390 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13391 break;
13392 case FUTEX_OP_ADD:
13393 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13394 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13395 uaddr, oparg);
13396 break;
13397 case FUTEX_OP_OR:
13398 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13399 return -EFAULT;
13400
13401 asm volatile("\t" ASM_STAC "\n"
13402 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13403 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13404 "2:\t" ASM_CLAC "\n"
13405 "\t.section .fixup, \"ax\"\n"
13406 "3:\tmov %3, %0\n"
13407 "\tjmp 2b\n"
13408 "\t.previous\n"
13409 _ASM_EXTABLE(1b, 3b)
13410 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13411 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13412 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13413 : "memory"
13414 );
13415 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13416 index eb92a6e..b98b2f4 100644
13417 --- a/arch/x86/include/asm/hw_irq.h
13418 +++ b/arch/x86/include/asm/hw_irq.h
13419 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
13420 extern void enable_IO_APIC(void);
13421
13422 /* Statistics */
13423 -extern atomic_t irq_err_count;
13424 -extern atomic_t irq_mis_count;
13425 +extern atomic_unchecked_t irq_err_count;
13426 +extern atomic_unchecked_t irq_mis_count;
13427
13428 /* EISA */
13429 extern void eisa_set_level_irq(unsigned int irq);
13430 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13431 index a203659..9889f1c 100644
13432 --- a/arch/x86/include/asm/i8259.h
13433 +++ b/arch/x86/include/asm/i8259.h
13434 @@ -62,7 +62,7 @@ struct legacy_pic {
13435 void (*init)(int auto_eoi);
13436 int (*irq_pending)(unsigned int irq);
13437 void (*make_irq)(unsigned int irq);
13438 -};
13439 +} __do_const;
13440
13441 extern struct legacy_pic *legacy_pic;
13442 extern struct legacy_pic null_legacy_pic;
13443 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13444 index d8e8eef..1765f78 100644
13445 --- a/arch/x86/include/asm/io.h
13446 +++ b/arch/x86/include/asm/io.h
13447 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13448 "m" (*(volatile type __force *)addr) barrier); }
13449
13450 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13451 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13452 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13453 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13454 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13455
13456 build_mmio_read(__readb, "b", unsigned char, "=q", )
13457 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13458 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13459 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13460 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13461
13462 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13463 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13464 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13465 return ioremap_nocache(offset, size);
13466 }
13467
13468 -extern void iounmap(volatile void __iomem *addr);
13469 +extern void iounmap(const volatile void __iomem *addr);
13470
13471 extern void set_iounmap_nonlazy(void);
13472
13473 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13474
13475 #include <linux/vmalloc.h>
13476
13477 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13478 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13479 +{
13480 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13481 +}
13482 +
13483 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13484 +{
13485 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13486 +}
13487 +
13488 /*
13489 * Convert a virtual cached pointer to an uncached pointer
13490 */
13491 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13492 index bba3cf8..06bc8da 100644
13493 --- a/arch/x86/include/asm/irqflags.h
13494 +++ b/arch/x86/include/asm/irqflags.h
13495 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13496 sti; \
13497 sysexit
13498
13499 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13500 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13501 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13502 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13503 +
13504 #else
13505 #define INTERRUPT_RETURN iret
13506 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13507 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13508 index d3ddd17..c9fb0cc 100644
13509 --- a/arch/x86/include/asm/kprobes.h
13510 +++ b/arch/x86/include/asm/kprobes.h
13511 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13512 #define RELATIVEJUMP_SIZE 5
13513 #define RELATIVECALL_OPCODE 0xe8
13514 #define RELATIVE_ADDR_SIZE 4
13515 -#define MAX_STACK_SIZE 64
13516 -#define MIN_STACK_SIZE(ADDR) \
13517 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13518 - THREAD_SIZE - (unsigned long)(ADDR))) \
13519 - ? (MAX_STACK_SIZE) \
13520 - : (((unsigned long)current_thread_info()) + \
13521 - THREAD_SIZE - (unsigned long)(ADDR)))
13522 +#define MAX_STACK_SIZE 64UL
13523 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13524
13525 #define flush_insn_slot(p) do { } while (0)
13526
13527 diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
13528 index dc87b65..85039f9 100644
13529 --- a/arch/x86/include/asm/kvm_host.h
13530 +++ b/arch/x86/include/asm/kvm_host.h
13531 @@ -419,8 +419,8 @@ struct kvm_vcpu_arch {
13532 gpa_t time;
13533 struct pvclock_vcpu_time_info hv_clock;
13534 unsigned int hw_tsc_khz;
13535 - unsigned int time_offset;
13536 - struct page *time_page;
13537 + struct gfn_to_hva_cache pv_time;
13538 + bool pv_time_enabled;
13539 /* set guest stopped flag in pvclock flags field */
13540 bool pvclock_set_guest_stopped_request;
13541
13542 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13543 index 2d89e39..baee879 100644
13544 --- a/arch/x86/include/asm/local.h
13545 +++ b/arch/x86/include/asm/local.h
13546 @@ -10,33 +10,97 @@ typedef struct {
13547 atomic_long_t a;
13548 } local_t;
13549
13550 +typedef struct {
13551 + atomic_long_unchecked_t a;
13552 +} local_unchecked_t;
13553 +
13554 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13555
13556 #define local_read(l) atomic_long_read(&(l)->a)
13557 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13558 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13559 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13560
13561 static inline void local_inc(local_t *l)
13562 {
13563 - asm volatile(_ASM_INC "%0"
13564 + asm volatile(_ASM_INC "%0\n"
13565 +
13566 +#ifdef CONFIG_PAX_REFCOUNT
13567 + "jno 0f\n"
13568 + _ASM_DEC "%0\n"
13569 + "int $4\n0:\n"
13570 + _ASM_EXTABLE(0b, 0b)
13571 +#endif
13572 +
13573 + : "+m" (l->a.counter));
13574 +}
13575 +
13576 +static inline void local_inc_unchecked(local_unchecked_t *l)
13577 +{
13578 + asm volatile(_ASM_INC "%0\n"
13579 : "+m" (l->a.counter));
13580 }
13581
13582 static inline void local_dec(local_t *l)
13583 {
13584 - asm volatile(_ASM_DEC "%0"
13585 + asm volatile(_ASM_DEC "%0\n"
13586 +
13587 +#ifdef CONFIG_PAX_REFCOUNT
13588 + "jno 0f\n"
13589 + _ASM_INC "%0\n"
13590 + "int $4\n0:\n"
13591 + _ASM_EXTABLE(0b, 0b)
13592 +#endif
13593 +
13594 + : "+m" (l->a.counter));
13595 +}
13596 +
13597 +static inline void local_dec_unchecked(local_unchecked_t *l)
13598 +{
13599 + asm volatile(_ASM_DEC "%0\n"
13600 : "+m" (l->a.counter));
13601 }
13602
13603 static inline void local_add(long i, local_t *l)
13604 {
13605 - asm volatile(_ASM_ADD "%1,%0"
13606 + asm volatile(_ASM_ADD "%1,%0\n"
13607 +
13608 +#ifdef CONFIG_PAX_REFCOUNT
13609 + "jno 0f\n"
13610 + _ASM_SUB "%1,%0\n"
13611 + "int $4\n0:\n"
13612 + _ASM_EXTABLE(0b, 0b)
13613 +#endif
13614 +
13615 + : "+m" (l->a.counter)
13616 + : "ir" (i));
13617 +}
13618 +
13619 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13620 +{
13621 + asm volatile(_ASM_ADD "%1,%0\n"
13622 : "+m" (l->a.counter)
13623 : "ir" (i));
13624 }
13625
13626 static inline void local_sub(long i, local_t *l)
13627 {
13628 - asm volatile(_ASM_SUB "%1,%0"
13629 + asm volatile(_ASM_SUB "%1,%0\n"
13630 +
13631 +#ifdef CONFIG_PAX_REFCOUNT
13632 + "jno 0f\n"
13633 + _ASM_ADD "%1,%0\n"
13634 + "int $4\n0:\n"
13635 + _ASM_EXTABLE(0b, 0b)
13636 +#endif
13637 +
13638 + : "+m" (l->a.counter)
13639 + : "ir" (i));
13640 +}
13641 +
13642 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13643 +{
13644 + asm volatile(_ASM_SUB "%1,%0\n"
13645 : "+m" (l->a.counter)
13646 : "ir" (i));
13647 }
13648 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13649 {
13650 unsigned char c;
13651
13652 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13653 + asm volatile(_ASM_SUB "%2,%0\n"
13654 +
13655 +#ifdef CONFIG_PAX_REFCOUNT
13656 + "jno 0f\n"
13657 + _ASM_ADD "%2,%0\n"
13658 + "int $4\n0:\n"
13659 + _ASM_EXTABLE(0b, 0b)
13660 +#endif
13661 +
13662 + "sete %1\n"
13663 : "+m" (l->a.counter), "=qm" (c)
13664 : "ir" (i) : "memory");
13665 return c;
13666 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13667 {
13668 unsigned char c;
13669
13670 - asm volatile(_ASM_DEC "%0; sete %1"
13671 + asm volatile(_ASM_DEC "%0\n"
13672 +
13673 +#ifdef CONFIG_PAX_REFCOUNT
13674 + "jno 0f\n"
13675 + _ASM_INC "%0\n"
13676 + "int $4\n0:\n"
13677 + _ASM_EXTABLE(0b, 0b)
13678 +#endif
13679 +
13680 + "sete %1\n"
13681 : "+m" (l->a.counter), "=qm" (c)
13682 : : "memory");
13683 return c != 0;
13684 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13685 {
13686 unsigned char c;
13687
13688 - asm volatile(_ASM_INC "%0; sete %1"
13689 + asm volatile(_ASM_INC "%0\n"
13690 +
13691 +#ifdef CONFIG_PAX_REFCOUNT
13692 + "jno 0f\n"
13693 + _ASM_DEC "%0\n"
13694 + "int $4\n0:\n"
13695 + _ASM_EXTABLE(0b, 0b)
13696 +#endif
13697 +
13698 + "sete %1\n"
13699 : "+m" (l->a.counter), "=qm" (c)
13700 : : "memory");
13701 return c != 0;
13702 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13703 {
13704 unsigned char c;
13705
13706 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13707 + asm volatile(_ASM_ADD "%2,%0\n"
13708 +
13709 +#ifdef CONFIG_PAX_REFCOUNT
13710 + "jno 0f\n"
13711 + _ASM_SUB "%2,%0\n"
13712 + "int $4\n0:\n"
13713 + _ASM_EXTABLE(0b, 0b)
13714 +#endif
13715 +
13716 + "sets %1\n"
13717 : "+m" (l->a.counter), "=qm" (c)
13718 : "ir" (i) : "memory");
13719 return c;
13720 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13721 static inline long local_add_return(long i, local_t *l)
13722 {
13723 long __i = i;
13724 + asm volatile(_ASM_XADD "%0, %1\n"
13725 +
13726 +#ifdef CONFIG_PAX_REFCOUNT
13727 + "jno 0f\n"
13728 + _ASM_MOV "%0,%1\n"
13729 + "int $4\n0:\n"
13730 + _ASM_EXTABLE(0b, 0b)
13731 +#endif
13732 +
13733 + : "+r" (i), "+m" (l->a.counter)
13734 + : : "memory");
13735 + return i + __i;
13736 +}
13737 +
13738 +/**
13739 + * local_add_return_unchecked - add and return
13740 + * @i: integer value to add
13741 + * @l: pointer to type local_unchecked_t
13742 + *
13743 + * Atomically adds @i to @l and returns @i + @l
13744 + */
13745 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13746 +{
13747 + long __i = i;
13748 asm volatile(_ASM_XADD "%0, %1;"
13749 : "+r" (i), "+m" (l->a.counter)
13750 : : "memory");
13751 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13752
13753 #define local_cmpxchg(l, o, n) \
13754 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13755 +#define local_cmpxchg_unchecked(l, o, n) \
13756 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13757 /* Always has a lock prefix */
13758 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13759
13760 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13761 new file mode 100644
13762 index 0000000..2bfd3ba
13763 --- /dev/null
13764 +++ b/arch/x86/include/asm/mman.h
13765 @@ -0,0 +1,15 @@
13766 +#ifndef _X86_MMAN_H
13767 +#define _X86_MMAN_H
13768 +
13769 +#include <uapi/asm/mman.h>
13770 +
13771 +#ifdef __KERNEL__
13772 +#ifndef __ASSEMBLY__
13773 +#ifdef CONFIG_X86_32
13774 +#define arch_mmap_check i386_mmap_check
13775 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13776 +#endif
13777 +#endif
13778 +#endif
13779 +
13780 +#endif /* X86_MMAN_H */
13781 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13782 index 5f55e69..e20bfb1 100644
13783 --- a/arch/x86/include/asm/mmu.h
13784 +++ b/arch/x86/include/asm/mmu.h
13785 @@ -9,7 +9,7 @@
13786 * we put the segment information here.
13787 */
13788 typedef struct {
13789 - void *ldt;
13790 + struct desc_struct *ldt;
13791 int size;
13792
13793 #ifdef CONFIG_X86_64
13794 @@ -18,7 +18,19 @@ typedef struct {
13795 #endif
13796
13797 struct mutex lock;
13798 - void *vdso;
13799 + unsigned long vdso;
13800 +
13801 +#ifdef CONFIG_X86_32
13802 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13803 + unsigned long user_cs_base;
13804 + unsigned long user_cs_limit;
13805 +
13806 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13807 + cpumask_t cpu_user_cs_mask;
13808 +#endif
13809 +
13810 +#endif
13811 +#endif
13812 } mm_context_t;
13813
13814 #ifdef CONFIG_SMP
13815 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13816 index cdbf367..adb37ac 100644
13817 --- a/arch/x86/include/asm/mmu_context.h
13818 +++ b/arch/x86/include/asm/mmu_context.h
13819 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13820
13821 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13822 {
13823 +
13824 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13825 + unsigned int i;
13826 + pgd_t *pgd;
13827 +
13828 + pax_open_kernel();
13829 + pgd = get_cpu_pgd(smp_processor_id());
13830 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13831 + set_pgd_batched(pgd+i, native_make_pgd(0));
13832 + pax_close_kernel();
13833 +#endif
13834 +
13835 #ifdef CONFIG_SMP
13836 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13837 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13838 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13839 struct task_struct *tsk)
13840 {
13841 unsigned cpu = smp_processor_id();
13842 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13843 + int tlbstate = TLBSTATE_OK;
13844 +#endif
13845
13846 if (likely(prev != next)) {
13847 #ifdef CONFIG_SMP
13848 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13849 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13850 +#endif
13851 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13852 this_cpu_write(cpu_tlbstate.active_mm, next);
13853 #endif
13854 cpumask_set_cpu(cpu, mm_cpumask(next));
13855
13856 /* Re-load page tables */
13857 +#ifdef CONFIG_PAX_PER_CPU_PGD
13858 + pax_open_kernel();
13859 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13860 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13861 + pax_close_kernel();
13862 + load_cr3(get_cpu_pgd(cpu));
13863 +#else
13864 load_cr3(next->pgd);
13865 +#endif
13866
13867 /* stop flush ipis for the previous mm */
13868 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13869 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13870 */
13871 if (unlikely(prev->context.ldt != next->context.ldt))
13872 load_LDT_nolock(&next->context);
13873 - }
13874 +
13875 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13876 + if (!(__supported_pte_mask & _PAGE_NX)) {
13877 + smp_mb__before_clear_bit();
13878 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13879 + smp_mb__after_clear_bit();
13880 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13881 + }
13882 +#endif
13883 +
13884 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13885 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13886 + prev->context.user_cs_limit != next->context.user_cs_limit))
13887 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13888 #ifdef CONFIG_SMP
13889 + else if (unlikely(tlbstate != TLBSTATE_OK))
13890 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13891 +#endif
13892 +#endif
13893 +
13894 + }
13895 else {
13896 +
13897 +#ifdef CONFIG_PAX_PER_CPU_PGD
13898 + pax_open_kernel();
13899 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13900 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13901 + pax_close_kernel();
13902 + load_cr3(get_cpu_pgd(cpu));
13903 +#endif
13904 +
13905 +#ifdef CONFIG_SMP
13906 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13907 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
13908
13909 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13910 * tlb flush IPI delivery. We must reload CR3
13911 * to make sure to use no freed page tables.
13912 */
13913 +
13914 +#ifndef CONFIG_PAX_PER_CPU_PGD
13915 load_cr3(next->pgd);
13916 +#endif
13917 +
13918 load_LDT_nolock(&next->context);
13919 +
13920 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
13921 + if (!(__supported_pte_mask & _PAGE_NX))
13922 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13923 +#endif
13924 +
13925 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13926 +#ifdef CONFIG_PAX_PAGEEXEC
13927 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
13928 +#endif
13929 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13930 +#endif
13931 +
13932 }
13933 +#endif
13934 }
13935 -#endif
13936 }
13937
13938 #define activate_mm(prev, next) \
13939 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
13940 index e3b7819..b257c64 100644
13941 --- a/arch/x86/include/asm/module.h
13942 +++ b/arch/x86/include/asm/module.h
13943 @@ -5,6 +5,7 @@
13944
13945 #ifdef CONFIG_X86_64
13946 /* X86_64 does not define MODULE_PROC_FAMILY */
13947 +#define MODULE_PROC_FAMILY ""
13948 #elif defined CONFIG_M486
13949 #define MODULE_PROC_FAMILY "486 "
13950 #elif defined CONFIG_M586
13951 @@ -57,8 +58,20 @@
13952 #error unknown processor family
13953 #endif
13954
13955 -#ifdef CONFIG_X86_32
13956 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
13957 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13958 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
13959 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
13960 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
13961 +#else
13962 +#define MODULE_PAX_KERNEXEC ""
13963 #endif
13964
13965 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13966 +#define MODULE_PAX_UDEREF "UDEREF "
13967 +#else
13968 +#define MODULE_PAX_UDEREF ""
13969 +#endif
13970 +
13971 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
13972 +
13973 #endif /* _ASM_X86_MODULE_H */
13974 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
13975 index c0fa356..07a498a 100644
13976 --- a/arch/x86/include/asm/nmi.h
13977 +++ b/arch/x86/include/asm/nmi.h
13978 @@ -42,11 +42,11 @@ struct nmiaction {
13979 nmi_handler_t handler;
13980 unsigned long flags;
13981 const char *name;
13982 -};
13983 +} __do_const;
13984
13985 #define register_nmi_handler(t, fn, fg, n, init...) \
13986 ({ \
13987 - static struct nmiaction init fn##_na = { \
13988 + static const struct nmiaction init fn##_na = { \
13989 .handler = (fn), \
13990 .name = (n), \
13991 .flags = (fg), \
13992 @@ -54,7 +54,7 @@ struct nmiaction {
13993 __register_nmi_handler((t), &fn##_na); \
13994 })
13995
13996 -int __register_nmi_handler(unsigned int, struct nmiaction *);
13997 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
13998
13999 void unregister_nmi_handler(unsigned int, const char *);
14000
14001 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
14002 index 320f7bb..e89f8f8 100644
14003 --- a/arch/x86/include/asm/page_64_types.h
14004 +++ b/arch/x86/include/asm/page_64_types.h
14005 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
14006
14007 /* duplicated to the one in bootmem.h */
14008 extern unsigned long max_pfn;
14009 -extern unsigned long phys_base;
14010 +extern const unsigned long phys_base;
14011
14012 extern unsigned long __phys_addr(unsigned long);
14013 #define __phys_reloc_hide(x) (x)
14014 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14015 index 5edd174..c395822 100644
14016 --- a/arch/x86/include/asm/paravirt.h
14017 +++ b/arch/x86/include/asm/paravirt.h
14018 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14019 return (pmd_t) { ret };
14020 }
14021
14022 -static inline pmdval_t pmd_val(pmd_t pmd)
14023 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14024 {
14025 pmdval_t ret;
14026
14027 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14028 val);
14029 }
14030
14031 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14032 +{
14033 + pgdval_t val = native_pgd_val(pgd);
14034 +
14035 + if (sizeof(pgdval_t) > sizeof(long))
14036 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14037 + val, (u64)val >> 32);
14038 + else
14039 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14040 + val);
14041 +}
14042 +
14043 static inline void pgd_clear(pgd_t *pgdp)
14044 {
14045 set_pgd(pgdp, __pgd(0));
14046 @@ -711,6 +723,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14047 pv_mmu_ops.set_fixmap(idx, phys, flags);
14048 }
14049
14050 +#ifdef CONFIG_PAX_KERNEXEC
14051 +static inline unsigned long pax_open_kernel(void)
14052 +{
14053 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14054 +}
14055 +
14056 +static inline unsigned long pax_close_kernel(void)
14057 +{
14058 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14059 +}
14060 +#else
14061 +static inline unsigned long pax_open_kernel(void) { return 0; }
14062 +static inline unsigned long pax_close_kernel(void) { return 0; }
14063 +#endif
14064 +
14065 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14066
14067 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14068 @@ -927,7 +954,7 @@ extern void default_banner(void);
14069
14070 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14071 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14072 -#define PARA_INDIRECT(addr) *%cs:addr
14073 +#define PARA_INDIRECT(addr) *%ss:addr
14074 #endif
14075
14076 #define INTERRUPT_RETURN \
14077 @@ -1002,6 +1029,21 @@ extern void default_banner(void);
14078 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14079 CLBR_NONE, \
14080 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14081 +
14082 +#define GET_CR0_INTO_RDI \
14083 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14084 + mov %rax,%rdi
14085 +
14086 +#define SET_RDI_INTO_CR0 \
14087 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14088 +
14089 +#define GET_CR3_INTO_RDI \
14090 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14091 + mov %rax,%rdi
14092 +
14093 +#define SET_RDI_INTO_CR3 \
14094 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14095 +
14096 #endif /* CONFIG_X86_32 */
14097
14098 #endif /* __ASSEMBLY__ */
14099 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14100 index 142236e..5446ffbc 100644
14101 --- a/arch/x86/include/asm/paravirt_types.h
14102 +++ b/arch/x86/include/asm/paravirt_types.h
14103 @@ -84,7 +84,7 @@ struct pv_init_ops {
14104 */
14105 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14106 unsigned long addr, unsigned len);
14107 -};
14108 +} __no_const;
14109
14110
14111 struct pv_lazy_ops {
14112 @@ -97,7 +97,7 @@ struct pv_time_ops {
14113 unsigned long long (*sched_clock)(void);
14114 unsigned long long (*steal_clock)(int cpu);
14115 unsigned long (*get_tsc_khz)(void);
14116 -};
14117 +} __no_const;
14118
14119 struct pv_cpu_ops {
14120 /* hooks for various privileged instructions */
14121 @@ -191,7 +191,7 @@ struct pv_cpu_ops {
14122
14123 void (*start_context_switch)(struct task_struct *prev);
14124 void (*end_context_switch)(struct task_struct *next);
14125 -};
14126 +} __no_const;
14127
14128 struct pv_irq_ops {
14129 /*
14130 @@ -222,7 +222,7 @@ struct pv_apic_ops {
14131 unsigned long start_eip,
14132 unsigned long start_esp);
14133 #endif
14134 -};
14135 +} __no_const;
14136
14137 struct pv_mmu_ops {
14138 unsigned long (*read_cr2)(void);
14139 @@ -312,6 +312,7 @@ struct pv_mmu_ops {
14140 struct paravirt_callee_save make_pud;
14141
14142 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14143 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14144 #endif /* PAGETABLE_LEVELS == 4 */
14145 #endif /* PAGETABLE_LEVELS >= 3 */
14146
14147 @@ -323,6 +324,12 @@ struct pv_mmu_ops {
14148 an mfn. We can tell which is which from the index. */
14149 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14150 phys_addr_t phys, pgprot_t flags);
14151 +
14152 +#ifdef CONFIG_PAX_KERNEXEC
14153 + unsigned long (*pax_open_kernel)(void);
14154 + unsigned long (*pax_close_kernel)(void);
14155 +#endif
14156 +
14157 };
14158
14159 struct arch_spinlock;
14160 @@ -333,7 +340,7 @@ struct pv_lock_ops {
14161 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14162 int (*spin_trylock)(struct arch_spinlock *lock);
14163 void (*spin_unlock)(struct arch_spinlock *lock);
14164 -};
14165 +} __no_const;
14166
14167 /* This contains all the paravirt structures: we get a convenient
14168 * number for each function using the offset which we use to indicate
14169 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14170 index b4389a4..7024269 100644
14171 --- a/arch/x86/include/asm/pgalloc.h
14172 +++ b/arch/x86/include/asm/pgalloc.h
14173 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14174 pmd_t *pmd, pte_t *pte)
14175 {
14176 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14177 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14178 +}
14179 +
14180 +static inline void pmd_populate_user(struct mm_struct *mm,
14181 + pmd_t *pmd, pte_t *pte)
14182 +{
14183 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14184 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14185 }
14186
14187 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14188
14189 #ifdef CONFIG_X86_PAE
14190 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14191 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14192 +{
14193 + pud_populate(mm, pudp, pmd);
14194 +}
14195 #else /* !CONFIG_X86_PAE */
14196 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14197 {
14198 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14199 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14200 }
14201 +
14202 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14203 +{
14204 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14205 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14206 +}
14207 #endif /* CONFIG_X86_PAE */
14208
14209 #if PAGETABLE_LEVELS > 3
14210 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14211 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14212 }
14213
14214 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14215 +{
14216 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14217 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14218 +}
14219 +
14220 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14221 {
14222 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14223 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14224 index f2b489c..4f7e2e5 100644
14225 --- a/arch/x86/include/asm/pgtable-2level.h
14226 +++ b/arch/x86/include/asm/pgtable-2level.h
14227 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14228
14229 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14230 {
14231 + pax_open_kernel();
14232 *pmdp = pmd;
14233 + pax_close_kernel();
14234 }
14235
14236 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14237 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14238 index 4cc9f2b..5fd9226 100644
14239 --- a/arch/x86/include/asm/pgtable-3level.h
14240 +++ b/arch/x86/include/asm/pgtable-3level.h
14241 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14242
14243 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14244 {
14245 + pax_open_kernel();
14246 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14247 + pax_close_kernel();
14248 }
14249
14250 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14251 {
14252 + pax_open_kernel();
14253 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14254 + pax_close_kernel();
14255 }
14256
14257 /*
14258 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14259 index 1c1a955..50f828c 100644
14260 --- a/arch/x86/include/asm/pgtable.h
14261 +++ b/arch/x86/include/asm/pgtable.h
14262 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14263
14264 #ifndef __PAGETABLE_PUD_FOLDED
14265 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14266 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14267 #define pgd_clear(pgd) native_pgd_clear(pgd)
14268 #endif
14269
14270 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14271
14272 #define arch_end_context_switch(prev) do {} while(0)
14273
14274 +#define pax_open_kernel() native_pax_open_kernel()
14275 +#define pax_close_kernel() native_pax_close_kernel()
14276 #endif /* CONFIG_PARAVIRT */
14277
14278 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14279 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14280 +
14281 +#ifdef CONFIG_PAX_KERNEXEC
14282 +static inline unsigned long native_pax_open_kernel(void)
14283 +{
14284 + unsigned long cr0;
14285 +
14286 + preempt_disable();
14287 + barrier();
14288 + cr0 = read_cr0() ^ X86_CR0_WP;
14289 + BUG_ON(cr0 & X86_CR0_WP);
14290 + write_cr0(cr0);
14291 + return cr0 ^ X86_CR0_WP;
14292 +}
14293 +
14294 +static inline unsigned long native_pax_close_kernel(void)
14295 +{
14296 + unsigned long cr0;
14297 +
14298 + cr0 = read_cr0() ^ X86_CR0_WP;
14299 + BUG_ON(!(cr0 & X86_CR0_WP));
14300 + write_cr0(cr0);
14301 + barrier();
14302 + preempt_enable_no_resched();
14303 + return cr0 ^ X86_CR0_WP;
14304 +}
14305 +#else
14306 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14307 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14308 +#endif
14309 +
14310 /*
14311 * The following only work if pte_present() is true.
14312 * Undefined behaviour if not..
14313 */
14314 +static inline int pte_user(pte_t pte)
14315 +{
14316 + return pte_val(pte) & _PAGE_USER;
14317 +}
14318 +
14319 static inline int pte_dirty(pte_t pte)
14320 {
14321 return pte_flags(pte) & _PAGE_DIRTY;
14322 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14323 return pte_clear_flags(pte, _PAGE_RW);
14324 }
14325
14326 +static inline pte_t pte_mkread(pte_t pte)
14327 +{
14328 + return __pte(pte_val(pte) | _PAGE_USER);
14329 +}
14330 +
14331 static inline pte_t pte_mkexec(pte_t pte)
14332 {
14333 - return pte_clear_flags(pte, _PAGE_NX);
14334 +#ifdef CONFIG_X86_PAE
14335 + if (__supported_pte_mask & _PAGE_NX)
14336 + return pte_clear_flags(pte, _PAGE_NX);
14337 + else
14338 +#endif
14339 + return pte_set_flags(pte, _PAGE_USER);
14340 +}
14341 +
14342 +static inline pte_t pte_exprotect(pte_t pte)
14343 +{
14344 +#ifdef CONFIG_X86_PAE
14345 + if (__supported_pte_mask & _PAGE_NX)
14346 + return pte_set_flags(pte, _PAGE_NX);
14347 + else
14348 +#endif
14349 + return pte_clear_flags(pte, _PAGE_USER);
14350 }
14351
14352 static inline pte_t pte_mkdirty(pte_t pte)
14353 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14354 #endif
14355
14356 #ifndef __ASSEMBLY__
14357 +
14358 +#ifdef CONFIG_PAX_PER_CPU_PGD
14359 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14360 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14361 +{
14362 + return cpu_pgd[cpu];
14363 +}
14364 +#endif
14365 +
14366 #include <linux/mm_types.h>
14367
14368 static inline int pte_none(pte_t pte)
14369 @@ -583,7 +652,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14370
14371 static inline int pgd_bad(pgd_t pgd)
14372 {
14373 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14374 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14375 }
14376
14377 static inline int pgd_none(pgd_t pgd)
14378 @@ -606,7 +675,12 @@ static inline int pgd_none(pgd_t pgd)
14379 * pgd_offset() returns a (pgd_t *)
14380 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14381 */
14382 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14383 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14384 +
14385 +#ifdef CONFIG_PAX_PER_CPU_PGD
14386 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14387 +#endif
14388 +
14389 /*
14390 * a shortcut which implies the use of the kernel's pgd, instead
14391 * of a process's
14392 @@ -617,6 +691,20 @@ static inline int pgd_none(pgd_t pgd)
14393 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14394 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14395
14396 +#ifdef CONFIG_X86_32
14397 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14398 +#else
14399 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14400 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14401 +
14402 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14403 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
14404 +#else
14405 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
14406 +#endif
14407 +
14408 +#endif
14409 +
14410 #ifndef __ASSEMBLY__
14411
14412 extern int direct_gbpages;
14413 @@ -781,11 +869,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14414 * dst and src can be on the same page, but the range must not overlap,
14415 * and must not cross a page boundary.
14416 */
14417 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14418 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14419 {
14420 - memcpy(dst, src, count * sizeof(pgd_t));
14421 + pax_open_kernel();
14422 + while (count--)
14423 + *dst++ = *src++;
14424 + pax_close_kernel();
14425 }
14426
14427 +#ifdef CONFIG_PAX_PER_CPU_PGD
14428 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14429 +#endif
14430 +
14431 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14432 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14433 +#else
14434 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14435 +#endif
14436
14437 #include <asm-generic/pgtable.h>
14438 #endif /* __ASSEMBLY__ */
14439 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14440 index 8faa215..a8a17ea 100644
14441 --- a/arch/x86/include/asm/pgtable_32.h
14442 +++ b/arch/x86/include/asm/pgtable_32.h
14443 @@ -25,9 +25,6 @@
14444 struct mm_struct;
14445 struct vm_area_struct;
14446
14447 -extern pgd_t swapper_pg_dir[1024];
14448 -extern pgd_t initial_page_table[1024];
14449 -
14450 static inline void pgtable_cache_init(void) { }
14451 static inline void check_pgt_cache(void) { }
14452 void paging_init(void);
14453 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14454 # include <asm/pgtable-2level.h>
14455 #endif
14456
14457 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14458 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14459 +#ifdef CONFIG_X86_PAE
14460 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14461 +#endif
14462 +
14463 #if defined(CONFIG_HIGHPTE)
14464 #define pte_offset_map(dir, address) \
14465 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14466 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14467 /* Clear a kernel PTE and flush it from the TLB */
14468 #define kpte_clear_flush(ptep, vaddr) \
14469 do { \
14470 + pax_open_kernel(); \
14471 pte_clear(&init_mm, (vaddr), (ptep)); \
14472 + pax_close_kernel(); \
14473 __flush_tlb_one((vaddr)); \
14474 } while (0)
14475
14476 @@ -75,6 +80,9 @@ do { \
14477
14478 #endif /* !__ASSEMBLY__ */
14479
14480 +#define HAVE_ARCH_UNMAPPED_AREA
14481 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14482 +
14483 /*
14484 * kern_addr_valid() is (1) for FLATMEM and (0) for
14485 * SPARSEMEM and DISCONTIGMEM
14486 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14487 index ed5903b..c7fe163 100644
14488 --- a/arch/x86/include/asm/pgtable_32_types.h
14489 +++ b/arch/x86/include/asm/pgtable_32_types.h
14490 @@ -8,7 +8,7 @@
14491 */
14492 #ifdef CONFIG_X86_PAE
14493 # include <asm/pgtable-3level_types.h>
14494 -# define PMD_SIZE (1UL << PMD_SHIFT)
14495 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14496 # define PMD_MASK (~(PMD_SIZE - 1))
14497 #else
14498 # include <asm/pgtable-2level_types.h>
14499 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14500 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14501 #endif
14502
14503 +#ifdef CONFIG_PAX_KERNEXEC
14504 +#ifndef __ASSEMBLY__
14505 +extern unsigned char MODULES_EXEC_VADDR[];
14506 +extern unsigned char MODULES_EXEC_END[];
14507 +#endif
14508 +#include <asm/boot.h>
14509 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14510 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14511 +#else
14512 +#define ktla_ktva(addr) (addr)
14513 +#define ktva_ktla(addr) (addr)
14514 +#endif
14515 +
14516 #define MODULES_VADDR VMALLOC_START
14517 #define MODULES_END VMALLOC_END
14518 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14519 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14520 index 47356f9..deb94a2 100644
14521 --- a/arch/x86/include/asm/pgtable_64.h
14522 +++ b/arch/x86/include/asm/pgtable_64.h
14523 @@ -16,10 +16,14 @@
14524
14525 extern pud_t level3_kernel_pgt[512];
14526 extern pud_t level3_ident_pgt[512];
14527 +extern pud_t level3_vmalloc_start_pgt[512];
14528 +extern pud_t level3_vmalloc_end_pgt[512];
14529 +extern pud_t level3_vmemmap_pgt[512];
14530 +extern pud_t level2_vmemmap_pgt[512];
14531 extern pmd_t level2_kernel_pgt[512];
14532 extern pmd_t level2_fixmap_pgt[512];
14533 -extern pmd_t level2_ident_pgt[512];
14534 -extern pgd_t init_level4_pgt[];
14535 +extern pmd_t level2_ident_pgt[512*2];
14536 +extern pgd_t init_level4_pgt[512];
14537
14538 #define swapper_pg_dir init_level4_pgt
14539
14540 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14541
14542 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14543 {
14544 + pax_open_kernel();
14545 *pmdp = pmd;
14546 + pax_close_kernel();
14547 }
14548
14549 static inline void native_pmd_clear(pmd_t *pmd)
14550 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14551
14552 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14553 {
14554 + pax_open_kernel();
14555 *pudp = pud;
14556 + pax_close_kernel();
14557 }
14558
14559 static inline void native_pud_clear(pud_t *pud)
14560 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14561
14562 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14563 {
14564 + pax_open_kernel();
14565 + *pgdp = pgd;
14566 + pax_close_kernel();
14567 +}
14568 +
14569 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14570 +{
14571 *pgdp = pgd;
14572 }
14573
14574 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14575 index 766ea16..5b96cb3 100644
14576 --- a/arch/x86/include/asm/pgtable_64_types.h
14577 +++ b/arch/x86/include/asm/pgtable_64_types.h
14578 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
14579 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14580 #define MODULES_END _AC(0xffffffffff000000, UL)
14581 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14582 +#define MODULES_EXEC_VADDR MODULES_VADDR
14583 +#define MODULES_EXEC_END MODULES_END
14584 +
14585 +#define ktla_ktva(addr) (addr)
14586 +#define ktva_ktla(addr) (addr)
14587
14588 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
14589 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14590 index 3c32db8..1ddccf5 100644
14591 --- a/arch/x86/include/asm/pgtable_types.h
14592 +++ b/arch/x86/include/asm/pgtable_types.h
14593 @@ -16,13 +16,12 @@
14594 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14595 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14596 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14597 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14598 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14599 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14600 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14601 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14602 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14603 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14604 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14605 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14606 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14607 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14608
14609 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14610 @@ -40,7 +39,6 @@
14611 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14612 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14613 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14614 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14615 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14616 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14617 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14618 @@ -57,8 +55,10 @@
14619
14620 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14621 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14622 -#else
14623 +#elif defined(CONFIG_KMEMCHECK)
14624 #define _PAGE_NX (_AT(pteval_t, 0))
14625 +#else
14626 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14627 #endif
14628
14629 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14630 @@ -116,6 +116,9 @@
14631 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14632 _PAGE_ACCESSED)
14633
14634 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14635 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14636 +
14637 #define __PAGE_KERNEL_EXEC \
14638 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14639 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14640 @@ -126,7 +129,7 @@
14641 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14642 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14643 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14644 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14645 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14646 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14647 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14648 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14649 @@ -188,8 +191,8 @@
14650 * bits are combined, this will alow user to access the high address mapped
14651 * VDSO in the presence of CONFIG_COMPAT_VDSO
14652 */
14653 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14654 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14655 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14656 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14657 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14658 #endif
14659
14660 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14661 {
14662 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14663 }
14664 +#endif
14665
14666 +#if PAGETABLE_LEVELS == 3
14667 +#include <asm-generic/pgtable-nopud.h>
14668 +#endif
14669 +
14670 +#if PAGETABLE_LEVELS == 2
14671 +#include <asm-generic/pgtable-nopmd.h>
14672 +#endif
14673 +
14674 +#ifndef __ASSEMBLY__
14675 #if PAGETABLE_LEVELS > 3
14676 typedef struct { pudval_t pud; } pud_t;
14677
14678 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14679 return pud.pud;
14680 }
14681 #else
14682 -#include <asm-generic/pgtable-nopud.h>
14683 -
14684 static inline pudval_t native_pud_val(pud_t pud)
14685 {
14686 return native_pgd_val(pud.pgd);
14687 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14688 return pmd.pmd;
14689 }
14690 #else
14691 -#include <asm-generic/pgtable-nopmd.h>
14692 -
14693 static inline pmdval_t native_pmd_val(pmd_t pmd)
14694 {
14695 return native_pgd_val(pmd.pud.pgd);
14696 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14697
14698 extern pteval_t __supported_pte_mask;
14699 extern void set_nx(void);
14700 -extern int nx_enabled;
14701
14702 #define pgprot_writecombine pgprot_writecombine
14703 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14704 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14705 index 888184b..a07ac89 100644
14706 --- a/arch/x86/include/asm/processor.h
14707 +++ b/arch/x86/include/asm/processor.h
14708 @@ -287,7 +287,7 @@ struct tss_struct {
14709
14710 } ____cacheline_aligned;
14711
14712 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14713 +extern struct tss_struct init_tss[NR_CPUS];
14714
14715 /*
14716 * Save the original ist values for checking stack pointers during debugging
14717 @@ -827,11 +827,18 @@ static inline void spin_lock_prefetch(const void *x)
14718 */
14719 #define TASK_SIZE PAGE_OFFSET
14720 #define TASK_SIZE_MAX TASK_SIZE
14721 +
14722 +#ifdef CONFIG_PAX_SEGMEXEC
14723 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14724 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14725 +#else
14726 #define STACK_TOP TASK_SIZE
14727 -#define STACK_TOP_MAX STACK_TOP
14728 +#endif
14729 +
14730 +#define STACK_TOP_MAX TASK_SIZE
14731
14732 #define INIT_THREAD { \
14733 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14734 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14735 .vm86_info = NULL, \
14736 .sysenter_cs = __KERNEL_CS, \
14737 .io_bitmap_ptr = NULL, \
14738 @@ -845,7 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
14739 */
14740 #define INIT_TSS { \
14741 .x86_tss = { \
14742 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14743 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14744 .ss0 = __KERNEL_DS, \
14745 .ss1 = __KERNEL_CS, \
14746 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14747 @@ -856,11 +863,7 @@ static inline void spin_lock_prefetch(const void *x)
14748 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14749
14750 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14751 -#define KSTK_TOP(info) \
14752 -({ \
14753 - unsigned long *__ptr = (unsigned long *)(info); \
14754 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14755 -})
14756 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14757
14758 /*
14759 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14760 @@ -875,7 +878,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14761 #define task_pt_regs(task) \
14762 ({ \
14763 struct pt_regs *__regs__; \
14764 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14765 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14766 __regs__ - 1; \
14767 })
14768
14769 @@ -885,13 +888,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14770 /*
14771 * User space process size. 47bits minus one guard page.
14772 */
14773 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14774 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14775
14776 /* This decides where the kernel will search for a free chunk of vm
14777 * space during mmap's.
14778 */
14779 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14780 - 0xc0000000 : 0xFFFFe000)
14781 + 0xc0000000 : 0xFFFFf000)
14782
14783 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14784 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14785 @@ -902,11 +905,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14786 #define STACK_TOP_MAX TASK_SIZE_MAX
14787
14788 #define INIT_THREAD { \
14789 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14790 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14791 }
14792
14793 #define INIT_TSS { \
14794 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14795 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14796 }
14797
14798 /*
14799 @@ -934,6 +937,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14800 */
14801 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14802
14803 +#ifdef CONFIG_PAX_SEGMEXEC
14804 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14805 +#endif
14806 +
14807 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14808
14809 /* Get/set a process' ability to use the timestamp counter instruction */
14810 @@ -994,12 +1001,12 @@ extern bool cpu_has_amd_erratum(const int *);
14811 #define cpu_has_amd_erratum(x) (false)
14812 #endif /* CONFIG_CPU_SUP_AMD */
14813
14814 -extern unsigned long arch_align_stack(unsigned long sp);
14815 +#define arch_align_stack(x) ((x) & ~0xfUL)
14816 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14817
14818 void default_idle(void);
14819 bool set_pm_idle_to_default(void);
14820
14821 -void stop_this_cpu(void *dummy);
14822 +void stop_this_cpu(void *dummy) __noreturn;
14823
14824 #endif /* _ASM_X86_PROCESSOR_H */
14825 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14826 index 942a086..6c26446 100644
14827 --- a/arch/x86/include/asm/ptrace.h
14828 +++ b/arch/x86/include/asm/ptrace.h
14829 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14830 }
14831
14832 /*
14833 - * user_mode_vm(regs) determines whether a register set came from user mode.
14834 + * user_mode(regs) determines whether a register set came from user mode.
14835 * This is true if V8086 mode was enabled OR if the register set was from
14836 * protected mode with RPL-3 CS value. This tricky test checks that with
14837 * one comparison. Many places in the kernel can bypass this full check
14838 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14839 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14840 + * be used.
14841 */
14842 -static inline int user_mode(struct pt_regs *regs)
14843 +static inline int user_mode_novm(struct pt_regs *regs)
14844 {
14845 #ifdef CONFIG_X86_32
14846 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14847 #else
14848 - return !!(regs->cs & 3);
14849 + return !!(regs->cs & SEGMENT_RPL_MASK);
14850 #endif
14851 }
14852
14853 -static inline int user_mode_vm(struct pt_regs *regs)
14854 +static inline int user_mode(struct pt_regs *regs)
14855 {
14856 #ifdef CONFIG_X86_32
14857 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
14858 USER_RPL;
14859 #else
14860 - return user_mode(regs);
14861 + return user_mode_novm(regs);
14862 #endif
14863 }
14864
14865 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
14866 #ifdef CONFIG_X86_64
14867 static inline bool user_64bit_mode(struct pt_regs *regs)
14868 {
14869 + unsigned long cs = regs->cs & 0xffff;
14870 #ifndef CONFIG_PARAVIRT
14871 /*
14872 * On non-paravirt systems, this is the only long mode CPL 3
14873 * selector. We do not allow long mode selectors in the LDT.
14874 */
14875 - return regs->cs == __USER_CS;
14876 + return cs == __USER_CS;
14877 #else
14878 /* Headers are too twisted for this to go in paravirt.h. */
14879 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
14880 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
14881 #endif
14882 }
14883
14884 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
14885 * Traps from the kernel do not save sp and ss.
14886 * Use the helper function to retrieve sp.
14887 */
14888 - if (offset == offsetof(struct pt_regs, sp) &&
14889 - regs->cs == __KERNEL_CS)
14890 - return kernel_stack_pointer(regs);
14891 + if (offset == offsetof(struct pt_regs, sp)) {
14892 + unsigned long cs = regs->cs & 0xffff;
14893 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
14894 + return kernel_stack_pointer(regs);
14895 + }
14896 #endif
14897 return *(unsigned long *)((unsigned long)regs + offset);
14898 }
14899 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
14900 index fe1ec5b..dc5c3fe 100644
14901 --- a/arch/x86/include/asm/realmode.h
14902 +++ b/arch/x86/include/asm/realmode.h
14903 @@ -22,16 +22,14 @@ struct real_mode_header {
14904 #endif
14905 /* APM/BIOS reboot */
14906 u32 machine_real_restart_asm;
14907 -#ifdef CONFIG_X86_64
14908 u32 machine_real_restart_seg;
14909 -#endif
14910 };
14911
14912 /* This must match data at trampoline_32/64.S */
14913 struct trampoline_header {
14914 #ifdef CONFIG_X86_32
14915 u32 start;
14916 - u16 gdt_pad;
14917 + u16 boot_cs;
14918 u16 gdt_limit;
14919 u32 gdt_base;
14920 #else
14921 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
14922 index a82c4f1..ac45053 100644
14923 --- a/arch/x86/include/asm/reboot.h
14924 +++ b/arch/x86/include/asm/reboot.h
14925 @@ -6,13 +6,13 @@
14926 struct pt_regs;
14927
14928 struct machine_ops {
14929 - void (*restart)(char *cmd);
14930 - void (*halt)(void);
14931 - void (*power_off)(void);
14932 + void (* __noreturn restart)(char *cmd);
14933 + void (* __noreturn halt)(void);
14934 + void (* __noreturn power_off)(void);
14935 void (*shutdown)(void);
14936 void (*crash_shutdown)(struct pt_regs *);
14937 - void (*emergency_restart)(void);
14938 -};
14939 + void (* __noreturn emergency_restart)(void);
14940 +} __no_const;
14941
14942 extern struct machine_ops machine_ops;
14943
14944 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
14945 index 2dbe4a7..ce1db00 100644
14946 --- a/arch/x86/include/asm/rwsem.h
14947 +++ b/arch/x86/include/asm/rwsem.h
14948 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
14949 {
14950 asm volatile("# beginning down_read\n\t"
14951 LOCK_PREFIX _ASM_INC "(%1)\n\t"
14952 +
14953 +#ifdef CONFIG_PAX_REFCOUNT
14954 + "jno 0f\n"
14955 + LOCK_PREFIX _ASM_DEC "(%1)\n"
14956 + "int $4\n0:\n"
14957 + _ASM_EXTABLE(0b, 0b)
14958 +#endif
14959 +
14960 /* adds 0x00000001 */
14961 " jns 1f\n"
14962 " call call_rwsem_down_read_failed\n"
14963 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
14964 "1:\n\t"
14965 " mov %1,%2\n\t"
14966 " add %3,%2\n\t"
14967 +
14968 +#ifdef CONFIG_PAX_REFCOUNT
14969 + "jno 0f\n"
14970 + "sub %3,%2\n"
14971 + "int $4\n0:\n"
14972 + _ASM_EXTABLE(0b, 0b)
14973 +#endif
14974 +
14975 " jle 2f\n\t"
14976 LOCK_PREFIX " cmpxchg %2,%0\n\t"
14977 " jnz 1b\n\t"
14978 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
14979 long tmp;
14980 asm volatile("# beginning down_write\n\t"
14981 LOCK_PREFIX " xadd %1,(%2)\n\t"
14982 +
14983 +#ifdef CONFIG_PAX_REFCOUNT
14984 + "jno 0f\n"
14985 + "mov %1,(%2)\n"
14986 + "int $4\n0:\n"
14987 + _ASM_EXTABLE(0b, 0b)
14988 +#endif
14989 +
14990 /* adds 0xffff0001, returns the old value */
14991 " test %1,%1\n\t"
14992 /* was the count 0 before? */
14993 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
14994 long tmp;
14995 asm volatile("# beginning __up_read\n\t"
14996 LOCK_PREFIX " xadd %1,(%2)\n\t"
14997 +
14998 +#ifdef CONFIG_PAX_REFCOUNT
14999 + "jno 0f\n"
15000 + "mov %1,(%2)\n"
15001 + "int $4\n0:\n"
15002 + _ASM_EXTABLE(0b, 0b)
15003 +#endif
15004 +
15005 /* subtracts 1, returns the old value */
15006 " jns 1f\n\t"
15007 " call call_rwsem_wake\n" /* expects old value in %edx */
15008 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15009 long tmp;
15010 asm volatile("# beginning __up_write\n\t"
15011 LOCK_PREFIX " xadd %1,(%2)\n\t"
15012 +
15013 +#ifdef CONFIG_PAX_REFCOUNT
15014 + "jno 0f\n"
15015 + "mov %1,(%2)\n"
15016 + "int $4\n0:\n"
15017 + _ASM_EXTABLE(0b, 0b)
15018 +#endif
15019 +
15020 /* subtracts 0xffff0001, returns the old value */
15021 " jns 1f\n\t"
15022 " call call_rwsem_wake\n" /* expects old value in %edx */
15023 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15024 {
15025 asm volatile("# beginning __downgrade_write\n\t"
15026 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15027 +
15028 +#ifdef CONFIG_PAX_REFCOUNT
15029 + "jno 0f\n"
15030 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15031 + "int $4\n0:\n"
15032 + _ASM_EXTABLE(0b, 0b)
15033 +#endif
15034 +
15035 /*
15036 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15037 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15038 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15039 */
15040 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15041 {
15042 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15043 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15044 +
15045 +#ifdef CONFIG_PAX_REFCOUNT
15046 + "jno 0f\n"
15047 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15048 + "int $4\n0:\n"
15049 + _ASM_EXTABLE(0b, 0b)
15050 +#endif
15051 +
15052 : "+m" (sem->count)
15053 : "er" (delta));
15054 }
15055 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15056 */
15057 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15058 {
15059 - return delta + xadd(&sem->count, delta);
15060 + return delta + xadd_check_overflow(&sem->count, delta);
15061 }
15062
15063 #endif /* __KERNEL__ */
15064 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15065 index c48a950..c6d7468 100644
15066 --- a/arch/x86/include/asm/segment.h
15067 +++ b/arch/x86/include/asm/segment.h
15068 @@ -64,10 +64,15 @@
15069 * 26 - ESPFIX small SS
15070 * 27 - per-cpu [ offset to per-cpu data area ]
15071 * 28 - stack_canary-20 [ for stack protector ]
15072 - * 29 - unused
15073 - * 30 - unused
15074 + * 29 - PCI BIOS CS
15075 + * 30 - PCI BIOS DS
15076 * 31 - TSS for double fault handler
15077 */
15078 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15079 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15080 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15081 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15082 +
15083 #define GDT_ENTRY_TLS_MIN 6
15084 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15085
15086 @@ -79,6 +84,8 @@
15087
15088 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15089
15090 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15091 +
15092 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15093
15094 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15095 @@ -104,6 +111,12 @@
15096 #define __KERNEL_STACK_CANARY 0
15097 #endif
15098
15099 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15100 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15101 +
15102 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15103 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15104 +
15105 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15106
15107 /*
15108 @@ -141,7 +154,7 @@
15109 */
15110
15111 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15112 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15113 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15114
15115
15116 #else
15117 @@ -165,6 +178,8 @@
15118 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15119 #define __USER32_DS __USER_DS
15120
15121 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15122 +
15123 #define GDT_ENTRY_TSS 8 /* needs two entries */
15124 #define GDT_ENTRY_LDT 10 /* needs two entries */
15125 #define GDT_ENTRY_TLS_MIN 12
15126 @@ -185,6 +200,7 @@
15127 #endif
15128
15129 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15130 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15131 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15132 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15133 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15134 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15135 {
15136 unsigned long __limit;
15137 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15138 - return __limit + 1;
15139 + return __limit;
15140 }
15141
15142 #endif /* !__ASSEMBLY__ */
15143 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15144 index b073aae..39f9bdd 100644
15145 --- a/arch/x86/include/asm/smp.h
15146 +++ b/arch/x86/include/asm/smp.h
15147 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15148 /* cpus sharing the last level cache: */
15149 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15150 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15151 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15152 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15153
15154 static inline struct cpumask *cpu_sibling_mask(int cpu)
15155 {
15156 @@ -79,7 +79,7 @@ struct smp_ops {
15157
15158 void (*send_call_func_ipi)(const struct cpumask *mask);
15159 void (*send_call_func_single_ipi)(int cpu);
15160 -};
15161 +} __no_const;
15162
15163 /* Globals due to paravirt */
15164 extern void set_cpu_sibling_map(int cpu);
15165 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15166 extern int safe_smp_processor_id(void);
15167
15168 #elif defined(CONFIG_X86_64_SMP)
15169 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15170 -
15171 -#define stack_smp_processor_id() \
15172 -({ \
15173 - struct thread_info *ti; \
15174 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15175 - ti->cpu; \
15176 -})
15177 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15178 +#define stack_smp_processor_id() raw_smp_processor_id()
15179 #define safe_smp_processor_id() smp_processor_id()
15180
15181 #endif
15182 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15183 index 33692ea..350a534 100644
15184 --- a/arch/x86/include/asm/spinlock.h
15185 +++ b/arch/x86/include/asm/spinlock.h
15186 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15187 static inline void arch_read_lock(arch_rwlock_t *rw)
15188 {
15189 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15190 +
15191 +#ifdef CONFIG_PAX_REFCOUNT
15192 + "jno 0f\n"
15193 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15194 + "int $4\n0:\n"
15195 + _ASM_EXTABLE(0b, 0b)
15196 +#endif
15197 +
15198 "jns 1f\n"
15199 "call __read_lock_failed\n\t"
15200 "1:\n"
15201 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15202 static inline void arch_write_lock(arch_rwlock_t *rw)
15203 {
15204 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15205 +
15206 +#ifdef CONFIG_PAX_REFCOUNT
15207 + "jno 0f\n"
15208 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15209 + "int $4\n0:\n"
15210 + _ASM_EXTABLE(0b, 0b)
15211 +#endif
15212 +
15213 "jz 1f\n"
15214 "call __write_lock_failed\n\t"
15215 "1:\n"
15216 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15217
15218 static inline void arch_read_unlock(arch_rwlock_t *rw)
15219 {
15220 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15221 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15222 +
15223 +#ifdef CONFIG_PAX_REFCOUNT
15224 + "jno 0f\n"
15225 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15226 + "int $4\n0:\n"
15227 + _ASM_EXTABLE(0b, 0b)
15228 +#endif
15229 +
15230 :"+m" (rw->lock) : : "memory");
15231 }
15232
15233 static inline void arch_write_unlock(arch_rwlock_t *rw)
15234 {
15235 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15236 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15237 +
15238 +#ifdef CONFIG_PAX_REFCOUNT
15239 + "jno 0f\n"
15240 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15241 + "int $4\n0:\n"
15242 + _ASM_EXTABLE(0b, 0b)
15243 +#endif
15244 +
15245 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15246 }
15247
15248 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15249 index 6a99859..03cb807 100644
15250 --- a/arch/x86/include/asm/stackprotector.h
15251 +++ b/arch/x86/include/asm/stackprotector.h
15252 @@ -47,7 +47,7 @@
15253 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15254 */
15255 #define GDT_STACK_CANARY_INIT \
15256 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15257 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15258
15259 /*
15260 * Initialize the stackprotector canary value.
15261 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15262
15263 static inline void load_stack_canary_segment(void)
15264 {
15265 -#ifdef CONFIG_X86_32
15266 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15267 asm volatile ("mov %0, %%gs" : : "r" (0));
15268 #endif
15269 }
15270 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15271 index 70bbe39..4ae2bd4 100644
15272 --- a/arch/x86/include/asm/stacktrace.h
15273 +++ b/arch/x86/include/asm/stacktrace.h
15274 @@ -11,28 +11,20 @@
15275
15276 extern int kstack_depth_to_print;
15277
15278 -struct thread_info;
15279 +struct task_struct;
15280 struct stacktrace_ops;
15281
15282 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15283 - unsigned long *stack,
15284 - unsigned long bp,
15285 - const struct stacktrace_ops *ops,
15286 - void *data,
15287 - unsigned long *end,
15288 - int *graph);
15289 +typedef unsigned long walk_stack_t(struct task_struct *task,
15290 + void *stack_start,
15291 + unsigned long *stack,
15292 + unsigned long bp,
15293 + const struct stacktrace_ops *ops,
15294 + void *data,
15295 + unsigned long *end,
15296 + int *graph);
15297
15298 -extern unsigned long
15299 -print_context_stack(struct thread_info *tinfo,
15300 - unsigned long *stack, unsigned long bp,
15301 - const struct stacktrace_ops *ops, void *data,
15302 - unsigned long *end, int *graph);
15303 -
15304 -extern unsigned long
15305 -print_context_stack_bp(struct thread_info *tinfo,
15306 - unsigned long *stack, unsigned long bp,
15307 - const struct stacktrace_ops *ops, void *data,
15308 - unsigned long *end, int *graph);
15309 +extern walk_stack_t print_context_stack;
15310 +extern walk_stack_t print_context_stack_bp;
15311
15312 /* Generic stack tracer with callbacks */
15313
15314 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15315 void (*address)(void *data, unsigned long address, int reliable);
15316 /* On negative return stop dumping */
15317 int (*stack)(void *data, char *name);
15318 - walk_stack_t walk_stack;
15319 + walk_stack_t *walk_stack;
15320 };
15321
15322 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15323 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15324 index 4ec45b3..a4f0a8a 100644
15325 --- a/arch/x86/include/asm/switch_to.h
15326 +++ b/arch/x86/include/asm/switch_to.h
15327 @@ -108,7 +108,7 @@ do { \
15328 "call __switch_to\n\t" \
15329 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15330 __switch_canary \
15331 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15332 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15333 "movq %%rax,%%rdi\n\t" \
15334 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15335 "jnz ret_from_fork\n\t" \
15336 @@ -119,7 +119,7 @@ do { \
15337 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15338 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15339 [_tif_fork] "i" (_TIF_FORK), \
15340 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15341 + [thread_info] "m" (current_tinfo), \
15342 [current_task] "m" (current_task) \
15343 __switch_canary_iparam \
15344 : "memory", "cc" __EXTRA_CLOBBER)
15345 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15346 index 2d946e6..e453ec4 100644
15347 --- a/arch/x86/include/asm/thread_info.h
15348 +++ b/arch/x86/include/asm/thread_info.h
15349 @@ -10,6 +10,7 @@
15350 #include <linux/compiler.h>
15351 #include <asm/page.h>
15352 #include <asm/types.h>
15353 +#include <asm/percpu.h>
15354
15355 /*
15356 * low level task data that entry.S needs immediate access to
15357 @@ -24,7 +25,6 @@ struct exec_domain;
15358 #include <linux/atomic.h>
15359
15360 struct thread_info {
15361 - struct task_struct *task; /* main task structure */
15362 struct exec_domain *exec_domain; /* execution domain */
15363 __u32 flags; /* low level flags */
15364 __u32 status; /* thread synchronous flags */
15365 @@ -34,19 +34,13 @@ struct thread_info {
15366 mm_segment_t addr_limit;
15367 struct restart_block restart_block;
15368 void __user *sysenter_return;
15369 -#ifdef CONFIG_X86_32
15370 - unsigned long previous_esp; /* ESP of the previous stack in
15371 - case of nested (IRQ) stacks
15372 - */
15373 - __u8 supervisor_stack[0];
15374 -#endif
15375 + unsigned long lowest_stack;
15376 unsigned int sig_on_uaccess_error:1;
15377 unsigned int uaccess_err:1; /* uaccess failed */
15378 };
15379
15380 -#define INIT_THREAD_INFO(tsk) \
15381 +#define INIT_THREAD_INFO \
15382 { \
15383 - .task = &tsk, \
15384 .exec_domain = &default_exec_domain, \
15385 .flags = 0, \
15386 .cpu = 0, \
15387 @@ -57,7 +51,7 @@ struct thread_info {
15388 }, \
15389 }
15390
15391 -#define init_thread_info (init_thread_union.thread_info)
15392 +#define init_thread_info (init_thread_union.stack)
15393 #define init_stack (init_thread_union.stack)
15394
15395 #else /* !__ASSEMBLY__ */
15396 @@ -98,6 +92,7 @@ struct thread_info {
15397 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15398 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15399 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15400 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15401
15402 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15403 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15404 @@ -122,17 +117,18 @@ struct thread_info {
15405 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15406 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15407 #define _TIF_X32 (1 << TIF_X32)
15408 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15409
15410 /* work to do in syscall_trace_enter() */
15411 #define _TIF_WORK_SYSCALL_ENTRY \
15412 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15413 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15414 - _TIF_NOHZ)
15415 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15416
15417 /* work to do in syscall_trace_leave() */
15418 #define _TIF_WORK_SYSCALL_EXIT \
15419 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15420 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15421 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15422
15423 /* work to do on interrupt/exception return */
15424 #define _TIF_WORK_MASK \
15425 @@ -143,7 +139,7 @@ struct thread_info {
15426 /* work to do on any return to user space */
15427 #define _TIF_ALLWORK_MASK \
15428 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15429 - _TIF_NOHZ)
15430 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15431
15432 /* Only used for 64 bit */
15433 #define _TIF_DO_NOTIFY_MASK \
15434 @@ -159,45 +155,40 @@ struct thread_info {
15435
15436 #define PREEMPT_ACTIVE 0x10000000
15437
15438 -#ifdef CONFIG_X86_32
15439 -
15440 -#define STACK_WARN (THREAD_SIZE/8)
15441 -/*
15442 - * macros/functions for gaining access to the thread information structure
15443 - *
15444 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15445 - */
15446 -#ifndef __ASSEMBLY__
15447 -
15448 -
15449 -/* how to get the current stack pointer from C */
15450 -register unsigned long current_stack_pointer asm("esp") __used;
15451 -
15452 -/* how to get the thread information struct from C */
15453 -static inline struct thread_info *current_thread_info(void)
15454 -{
15455 - return (struct thread_info *)
15456 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15457 -}
15458 -
15459 -#else /* !__ASSEMBLY__ */
15460 -
15461 +#ifdef __ASSEMBLY__
15462 /* how to get the thread information struct from ASM */
15463 #define GET_THREAD_INFO(reg) \
15464 - movl $-THREAD_SIZE, reg; \
15465 - andl %esp, reg
15466 + mov PER_CPU_VAR(current_tinfo), reg
15467
15468 /* use this one if reg already contains %esp */
15469 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15470 - andl $-THREAD_SIZE, reg
15471 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15472 +#else
15473 +/* how to get the thread information struct from C */
15474 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15475 +
15476 +static __always_inline struct thread_info *current_thread_info(void)
15477 +{
15478 + return this_cpu_read_stable(current_tinfo);
15479 +}
15480 +#endif
15481 +
15482 +#ifdef CONFIG_X86_32
15483 +
15484 +#define STACK_WARN (THREAD_SIZE/8)
15485 +/*
15486 + * macros/functions for gaining access to the thread information structure
15487 + *
15488 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15489 + */
15490 +#ifndef __ASSEMBLY__
15491 +
15492 +/* how to get the current stack pointer from C */
15493 +register unsigned long current_stack_pointer asm("esp") __used;
15494
15495 #endif
15496
15497 #else /* X86_32 */
15498
15499 -#include <asm/percpu.h>
15500 -#define KERNEL_STACK_OFFSET (5*8)
15501 -
15502 /*
15503 * macros/functions for gaining access to the thread information structure
15504 * preempt_count needs to be 1 initially, until the scheduler is functional.
15505 @@ -205,27 +196,8 @@ static inline struct thread_info *current_thread_info(void)
15506 #ifndef __ASSEMBLY__
15507 DECLARE_PER_CPU(unsigned long, kernel_stack);
15508
15509 -static inline struct thread_info *current_thread_info(void)
15510 -{
15511 - struct thread_info *ti;
15512 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15513 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15514 - return ti;
15515 -}
15516 -
15517 -#else /* !__ASSEMBLY__ */
15518 -
15519 -/* how to get the thread information struct from ASM */
15520 -#define GET_THREAD_INFO(reg) \
15521 - movq PER_CPU_VAR(kernel_stack),reg ; \
15522 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15523 -
15524 -/*
15525 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15526 - * a certain register (to be used in assembler memory operands).
15527 - */
15528 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15529 -
15530 +/* how to get the current stack pointer from C */
15531 +register unsigned long current_stack_pointer asm("rsp") __used;
15532 #endif
15533
15534 #endif /* !X86_32 */
15535 @@ -286,5 +258,12 @@ static inline bool is_ia32_task(void)
15536 extern void arch_task_cache_init(void);
15537 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15538 extern void arch_release_task_struct(struct task_struct *tsk);
15539 +
15540 +#define __HAVE_THREAD_FUNCTIONS
15541 +#define task_thread_info(task) (&(task)->tinfo)
15542 +#define task_stack_page(task) ((task)->stack)
15543 +#define setup_thread_stack(p, org) do {} while (0)
15544 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15545 +
15546 #endif
15547 #endif /* _ASM_X86_THREAD_INFO_H */
15548 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15549 index 1709801..0a60f2f 100644
15550 --- a/arch/x86/include/asm/uaccess.h
15551 +++ b/arch/x86/include/asm/uaccess.h
15552 @@ -7,6 +7,7 @@
15553 #include <linux/compiler.h>
15554 #include <linux/thread_info.h>
15555 #include <linux/string.h>
15556 +#include <linux/sched.h>
15557 #include <asm/asm.h>
15558 #include <asm/page.h>
15559 #include <asm/smap.h>
15560 @@ -29,7 +30,12 @@
15561
15562 #define get_ds() (KERNEL_DS)
15563 #define get_fs() (current_thread_info()->addr_limit)
15564 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15565 +void __set_fs(mm_segment_t x);
15566 +void set_fs(mm_segment_t x);
15567 +#else
15568 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15569 +#endif
15570
15571 #define segment_eq(a, b) ((a).seg == (b).seg)
15572
15573 @@ -77,8 +83,33 @@
15574 * checks that the pointer is in the user space range - after calling
15575 * this function, memory access functions may still return -EFAULT.
15576 */
15577 -#define access_ok(type, addr, size) \
15578 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15579 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15580 +#define access_ok(type, addr, size) \
15581 +({ \
15582 + long __size = size; \
15583 + unsigned long __addr = (unsigned long)addr; \
15584 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15585 + unsigned long __end_ao = __addr + __size - 1; \
15586 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15587 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15588 + while(__addr_ao <= __end_ao) { \
15589 + char __c_ao; \
15590 + __addr_ao += PAGE_SIZE; \
15591 + if (__size > PAGE_SIZE) \
15592 + cond_resched(); \
15593 + if (__get_user(__c_ao, (char __user *)__addr)) \
15594 + break; \
15595 + if (type != VERIFY_WRITE) { \
15596 + __addr = __addr_ao; \
15597 + continue; \
15598 + } \
15599 + if (__put_user(__c_ao, (char __user *)__addr)) \
15600 + break; \
15601 + __addr = __addr_ao; \
15602 + } \
15603 + } \
15604 + __ret_ao; \
15605 +})
15606
15607 /*
15608 * The exception table consists of pairs of addresses relative to the
15609 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
15610 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15611 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15612
15613 -
15614 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15615 +#define __copyuser_seg "gs;"
15616 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15617 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15618 +#else
15619 +#define __copyuser_seg
15620 +#define __COPYUSER_SET_ES
15621 +#define __COPYUSER_RESTORE_ES
15622 +#endif
15623
15624 #ifdef CONFIG_X86_32
15625 #define __put_user_asm_u64(x, addr, err, errret) \
15626 asm volatile(ASM_STAC "\n" \
15627 - "1: movl %%eax,0(%2)\n" \
15628 - "2: movl %%edx,4(%2)\n" \
15629 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15630 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15631 "3: " ASM_CLAC "\n" \
15632 ".section .fixup,\"ax\"\n" \
15633 "4: movl %3,%0\n" \
15634 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
15635
15636 #define __put_user_asm_ex_u64(x, addr) \
15637 asm volatile(ASM_STAC "\n" \
15638 - "1: movl %%eax,0(%1)\n" \
15639 - "2: movl %%edx,4(%1)\n" \
15640 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15641 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15642 "3: " ASM_CLAC "\n" \
15643 _ASM_EXTABLE_EX(1b, 2b) \
15644 _ASM_EXTABLE_EX(2b, 3b) \
15645 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
15646 __typeof__(*(ptr)) __pu_val; \
15647 __chk_user_ptr(ptr); \
15648 might_fault(); \
15649 - __pu_val = x; \
15650 + __pu_val = (x); \
15651 switch (sizeof(*(ptr))) { \
15652 case 1: \
15653 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15654 @@ -358,7 +397,7 @@ do { \
15655
15656 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15657 asm volatile(ASM_STAC "\n" \
15658 - "1: mov"itype" %2,%"rtype"1\n" \
15659 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15660 "2: " ASM_CLAC "\n" \
15661 ".section .fixup,\"ax\"\n" \
15662 "3: mov %3,%0\n" \
15663 @@ -366,7 +405,7 @@ do { \
15664 " jmp 2b\n" \
15665 ".previous\n" \
15666 _ASM_EXTABLE(1b, 3b) \
15667 - : "=r" (err), ltype(x) \
15668 + : "=r" (err), ltype (x) \
15669 : "m" (__m(addr)), "i" (errret), "0" (err))
15670
15671 #define __get_user_size_ex(x, ptr, size) \
15672 @@ -391,7 +430,7 @@ do { \
15673 } while (0)
15674
15675 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15676 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15677 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15678 "2:\n" \
15679 _ASM_EXTABLE_EX(1b, 2b) \
15680 : ltype(x) : "m" (__m(addr)))
15681 @@ -408,13 +447,24 @@ do { \
15682 int __gu_err; \
15683 unsigned long __gu_val; \
15684 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15685 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15686 + (x) = (__typeof__(*(ptr)))__gu_val; \
15687 __gu_err; \
15688 })
15689
15690 /* FIXME: this hack is definitely wrong -AK */
15691 struct __large_struct { unsigned long buf[100]; };
15692 -#define __m(x) (*(struct __large_struct __user *)(x))
15693 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15694 +#define ____m(x) \
15695 +({ \
15696 + unsigned long ____x = (unsigned long)(x); \
15697 + if (____x < PAX_USER_SHADOW_BASE) \
15698 + ____x += PAX_USER_SHADOW_BASE; \
15699 + (void __user *)____x; \
15700 +})
15701 +#else
15702 +#define ____m(x) (x)
15703 +#endif
15704 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15705
15706 /*
15707 * Tell gcc we read from memory instead of writing: this is because
15708 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
15709 */
15710 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15711 asm volatile(ASM_STAC "\n" \
15712 - "1: mov"itype" %"rtype"1,%2\n" \
15713 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15714 "2: " ASM_CLAC "\n" \
15715 ".section .fixup,\"ax\"\n" \
15716 "3: mov %3,%0\n" \
15717 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
15718 ".previous\n" \
15719 _ASM_EXTABLE(1b, 3b) \
15720 : "=r"(err) \
15721 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15722 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15723
15724 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15725 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15726 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15727 "2:\n" \
15728 _ASM_EXTABLE_EX(1b, 2b) \
15729 : : ltype(x), "m" (__m(addr)))
15730 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
15731 * On error, the variable @x is set to zero.
15732 */
15733
15734 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15735 +#define __get_user(x, ptr) get_user((x), (ptr))
15736 +#else
15737 #define __get_user(x, ptr) \
15738 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15739 +#endif
15740
15741 /**
15742 * __put_user: - Write a simple value into user space, with less checking.
15743 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
15744 * Returns zero on success, or -EFAULT on error.
15745 */
15746
15747 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15748 +#define __put_user(x, ptr) put_user((x), (ptr))
15749 +#else
15750 #define __put_user(x, ptr) \
15751 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15752 +#endif
15753
15754 #define __get_user_unaligned __get_user
15755 #define __put_user_unaligned __put_user
15756 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
15757 #define get_user_ex(x, ptr) do { \
15758 unsigned long __gue_val; \
15759 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15760 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15761 + (x) = (__typeof__(*(ptr)))__gue_val; \
15762 } while (0)
15763
15764 #define put_user_try uaccess_try
15765 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15766 extern __must_check long strlen_user(const char __user *str);
15767 extern __must_check long strnlen_user(const char __user *str, long n);
15768
15769 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15770 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15771 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15772 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15773
15774 /*
15775 * movsl can be slow when source and dest are not both 8-byte aligned
15776 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15777 index 7f760a9..04b1c65 100644
15778 --- a/arch/x86/include/asm/uaccess_32.h
15779 +++ b/arch/x86/include/asm/uaccess_32.h
15780 @@ -11,15 +11,15 @@
15781 #include <asm/page.h>
15782
15783 unsigned long __must_check __copy_to_user_ll
15784 - (void __user *to, const void *from, unsigned long n);
15785 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15786 unsigned long __must_check __copy_from_user_ll
15787 - (void *to, const void __user *from, unsigned long n);
15788 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15789 unsigned long __must_check __copy_from_user_ll_nozero
15790 - (void *to, const void __user *from, unsigned long n);
15791 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15792 unsigned long __must_check __copy_from_user_ll_nocache
15793 - (void *to, const void __user *from, unsigned long n);
15794 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15795 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15796 - (void *to, const void __user *from, unsigned long n);
15797 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15798
15799 /**
15800 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15801 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15802 static __always_inline unsigned long __must_check
15803 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15804 {
15805 + if ((long)n < 0)
15806 + return n;
15807 +
15808 + check_object_size(from, n, true);
15809 +
15810 if (__builtin_constant_p(n)) {
15811 unsigned long ret;
15812
15813 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15814 __copy_to_user(void __user *to, const void *from, unsigned long n)
15815 {
15816 might_fault();
15817 +
15818 return __copy_to_user_inatomic(to, from, n);
15819 }
15820
15821 static __always_inline unsigned long
15822 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15823 {
15824 + if ((long)n < 0)
15825 + return n;
15826 +
15827 /* Avoid zeroing the tail if the copy fails..
15828 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15829 * but as the zeroing behaviour is only significant when n is not
15830 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15831 __copy_from_user(void *to, const void __user *from, unsigned long n)
15832 {
15833 might_fault();
15834 +
15835 + if ((long)n < 0)
15836 + return n;
15837 +
15838 + check_object_size(to, n, false);
15839 +
15840 if (__builtin_constant_p(n)) {
15841 unsigned long ret;
15842
15843 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15844 const void __user *from, unsigned long n)
15845 {
15846 might_fault();
15847 +
15848 + if ((long)n < 0)
15849 + return n;
15850 +
15851 if (__builtin_constant_p(n)) {
15852 unsigned long ret;
15853
15854 @@ -181,15 +200,19 @@ static __always_inline unsigned long
15855 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
15856 unsigned long n)
15857 {
15858 - return __copy_from_user_ll_nocache_nozero(to, from, n);
15859 + if ((long)n < 0)
15860 + return n;
15861 +
15862 + return __copy_from_user_ll_nocache_nozero(to, from, n);
15863 }
15864
15865 -unsigned long __must_check copy_to_user(void __user *to,
15866 - const void *from, unsigned long n);
15867 -unsigned long __must_check _copy_from_user(void *to,
15868 - const void __user *from,
15869 - unsigned long n);
15870 -
15871 +extern void copy_to_user_overflow(void)
15872 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15873 + __compiletime_error("copy_to_user() buffer size is not provably correct")
15874 +#else
15875 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
15876 +#endif
15877 +;
15878
15879 extern void copy_from_user_overflow(void)
15880 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15881 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
15882 #endif
15883 ;
15884
15885 -static inline unsigned long __must_check copy_from_user(void *to,
15886 - const void __user *from,
15887 - unsigned long n)
15888 +/**
15889 + * copy_to_user: - Copy a block of data into user space.
15890 + * @to: Destination address, in user space.
15891 + * @from: Source address, in kernel space.
15892 + * @n: Number of bytes to copy.
15893 + *
15894 + * Context: User context only. This function may sleep.
15895 + *
15896 + * Copy data from kernel space to user space.
15897 + *
15898 + * Returns number of bytes that could not be copied.
15899 + * On success, this will be zero.
15900 + */
15901 +static inline unsigned long __must_check
15902 +copy_to_user(void __user *to, const void *from, unsigned long n)
15903 {
15904 - int sz = __compiletime_object_size(to);
15905 + size_t sz = __compiletime_object_size(from);
15906
15907 - if (likely(sz == -1 || sz >= n))
15908 - n = _copy_from_user(to, from, n);
15909 - else
15910 + if (unlikely(sz != (size_t)-1 && sz < n))
15911 + copy_to_user_overflow();
15912 + else if (access_ok(VERIFY_WRITE, to, n))
15913 + n = __copy_to_user(to, from, n);
15914 + return n;
15915 +}
15916 +
15917 +/**
15918 + * copy_from_user: - Copy a block of data from user space.
15919 + * @to: Destination address, in kernel space.
15920 + * @from: Source address, in user space.
15921 + * @n: Number of bytes to copy.
15922 + *
15923 + * Context: User context only. This function may sleep.
15924 + *
15925 + * Copy data from user space to kernel space.
15926 + *
15927 + * Returns number of bytes that could not be copied.
15928 + * On success, this will be zero.
15929 + *
15930 + * If some data could not be copied, this function will pad the copied
15931 + * data to the requested size using zero bytes.
15932 + */
15933 +static inline unsigned long __must_check
15934 +copy_from_user(void *to, const void __user *from, unsigned long n)
15935 +{
15936 + size_t sz = __compiletime_object_size(to);
15937 +
15938 + check_object_size(to, n, false);
15939 +
15940 + if (unlikely(sz != (size_t)-1 && sz < n))
15941 copy_from_user_overflow();
15942 -
15943 + else if (access_ok(VERIFY_READ, from, n))
15944 + n = __copy_from_user(to, from, n);
15945 + else if ((long)n > 0)
15946 + memset(to, 0, n);
15947 return n;
15948 }
15949
15950 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
15951 index 142810c..1f2a0a7 100644
15952 --- a/arch/x86/include/asm/uaccess_64.h
15953 +++ b/arch/x86/include/asm/uaccess_64.h
15954 @@ -10,6 +10,9 @@
15955 #include <asm/alternative.h>
15956 #include <asm/cpufeature.h>
15957 #include <asm/page.h>
15958 +#include <asm/pgtable.h>
15959 +
15960 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
15961
15962 /*
15963 * Copy To/From Userspace
15964 @@ -17,13 +20,13 @@
15965
15966 /* Handles exceptions in both to and from, but doesn't do access_ok */
15967 __must_check unsigned long
15968 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
15969 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
15970 __must_check unsigned long
15971 -copy_user_generic_string(void *to, const void *from, unsigned len);
15972 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
15973 __must_check unsigned long
15974 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
15975 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
15976
15977 -static __always_inline __must_check unsigned long
15978 +static __always_inline __must_check __size_overflow(3) unsigned long
15979 copy_user_generic(void *to, const void *from, unsigned len)
15980 {
15981 unsigned ret;
15982 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
15983 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
15984 "=d" (len)),
15985 "1" (to), "2" (from), "3" (len)
15986 - : "memory", "rcx", "r8", "r9", "r10", "r11");
15987 + : "memory", "rcx", "r8", "r9", "r11");
15988 return ret;
15989 }
15990
15991 +static __always_inline __must_check unsigned long
15992 +__copy_to_user(void __user *to, const void *from, unsigned long len);
15993 +static __always_inline __must_check unsigned long
15994 +__copy_from_user(void *to, const void __user *from, unsigned long len);
15995 __must_check unsigned long
15996 -_copy_to_user(void __user *to, const void *from, unsigned len);
15997 -__must_check unsigned long
15998 -_copy_from_user(void *to, const void __user *from, unsigned len);
15999 -__must_check unsigned long
16000 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16001 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16002 +
16003 +extern void copy_to_user_overflow(void)
16004 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16005 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16006 +#else
16007 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16008 +#endif
16009 +;
16010 +
16011 +extern void copy_from_user_overflow(void)
16012 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16013 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16014 +#else
16015 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16016 +#endif
16017 +;
16018
16019 static inline unsigned long __must_check copy_from_user(void *to,
16020 const void __user *from,
16021 unsigned long n)
16022 {
16023 - int sz = __compiletime_object_size(to);
16024 -
16025 might_fault();
16026 - if (likely(sz == -1 || sz >= n))
16027 - n = _copy_from_user(to, from, n);
16028 -#ifdef CONFIG_DEBUG_VM
16029 - else
16030 - WARN(1, "Buffer overflow detected!\n");
16031 -#endif
16032 +
16033 + check_object_size(to, n, false);
16034 +
16035 + if (access_ok(VERIFY_READ, from, n))
16036 + n = __copy_from_user(to, from, n);
16037 + else if (n < INT_MAX)
16038 + memset(to, 0, n);
16039 return n;
16040 }
16041
16042 static __always_inline __must_check
16043 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16044 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16045 {
16046 might_fault();
16047
16048 - return _copy_to_user(dst, src, size);
16049 + if (access_ok(VERIFY_WRITE, dst, size))
16050 + size = __copy_to_user(dst, src, size);
16051 + return size;
16052 }
16053
16054 static __always_inline __must_check
16055 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16056 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16057 {
16058 - int ret = 0;
16059 + size_t sz = __compiletime_object_size(dst);
16060 + unsigned ret = 0;
16061
16062 might_fault();
16063 +
16064 + if (size > INT_MAX)
16065 + return size;
16066 +
16067 + check_object_size(dst, size, false);
16068 +
16069 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16070 + if (!__access_ok(VERIFY_READ, src, size))
16071 + return size;
16072 +#endif
16073 +
16074 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16075 + copy_from_user_overflow();
16076 + return size;
16077 + }
16078 +
16079 if (!__builtin_constant_p(size))
16080 - return copy_user_generic(dst, (__force void *)src, size);
16081 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16082 switch (size) {
16083 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16084 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16085 ret, "b", "b", "=q", 1);
16086 return ret;
16087 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16088 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16089 ret, "w", "w", "=r", 2);
16090 return ret;
16091 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16092 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16093 ret, "l", "k", "=r", 4);
16094 return ret;
16095 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16096 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16097 ret, "q", "", "=r", 8);
16098 return ret;
16099 case 10:
16100 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16101 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16102 ret, "q", "", "=r", 10);
16103 if (unlikely(ret))
16104 return ret;
16105 __get_user_asm(*(u16 *)(8 + (char *)dst),
16106 - (u16 __user *)(8 + (char __user *)src),
16107 + (const u16 __user *)(8 + (const char __user *)src),
16108 ret, "w", "w", "=r", 2);
16109 return ret;
16110 case 16:
16111 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16112 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16113 ret, "q", "", "=r", 16);
16114 if (unlikely(ret))
16115 return ret;
16116 __get_user_asm(*(u64 *)(8 + (char *)dst),
16117 - (u64 __user *)(8 + (char __user *)src),
16118 + (const u64 __user *)(8 + (const char __user *)src),
16119 ret, "q", "", "=r", 8);
16120 return ret;
16121 default:
16122 - return copy_user_generic(dst, (__force void *)src, size);
16123 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16124 }
16125 }
16126
16127 static __always_inline __must_check
16128 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16129 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16130 {
16131 - int ret = 0;
16132 + size_t sz = __compiletime_object_size(src);
16133 + unsigned ret = 0;
16134
16135 might_fault();
16136 +
16137 + if (size > INT_MAX)
16138 + return size;
16139 +
16140 + check_object_size(src, size, true);
16141 +
16142 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16143 + if (!__access_ok(VERIFY_WRITE, dst, size))
16144 + return size;
16145 +#endif
16146 +
16147 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16148 + copy_to_user_overflow();
16149 + return size;
16150 + }
16151 +
16152 if (!__builtin_constant_p(size))
16153 - return copy_user_generic((__force void *)dst, src, size);
16154 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16155 switch (size) {
16156 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16157 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16158 ret, "b", "b", "iq", 1);
16159 return ret;
16160 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16161 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16162 ret, "w", "w", "ir", 2);
16163 return ret;
16164 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16165 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16166 ret, "l", "k", "ir", 4);
16167 return ret;
16168 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16169 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16170 ret, "q", "", "er", 8);
16171 return ret;
16172 case 10:
16173 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16174 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16175 ret, "q", "", "er", 10);
16176 if (unlikely(ret))
16177 return ret;
16178 asm("":::"memory");
16179 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16180 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16181 ret, "w", "w", "ir", 2);
16182 return ret;
16183 case 16:
16184 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16185 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16186 ret, "q", "", "er", 16);
16187 if (unlikely(ret))
16188 return ret;
16189 asm("":::"memory");
16190 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16191 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16192 ret, "q", "", "er", 8);
16193 return ret;
16194 default:
16195 - return copy_user_generic((__force void *)dst, src, size);
16196 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16197 }
16198 }
16199
16200 static __always_inline __must_check
16201 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16202 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16203 {
16204 - int ret = 0;
16205 + unsigned ret = 0;
16206
16207 might_fault();
16208 +
16209 + if (size > INT_MAX)
16210 + return size;
16211 +
16212 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16213 + if (!__access_ok(VERIFY_READ, src, size))
16214 + return size;
16215 + if (!__access_ok(VERIFY_WRITE, dst, size))
16216 + return size;
16217 +#endif
16218 +
16219 if (!__builtin_constant_p(size))
16220 - return copy_user_generic((__force void *)dst,
16221 - (__force void *)src, size);
16222 + return copy_user_generic((__force_kernel void *)____m(dst),
16223 + (__force_kernel const void *)____m(src), size);
16224 switch (size) {
16225 case 1: {
16226 u8 tmp;
16227 - __get_user_asm(tmp, (u8 __user *)src,
16228 + __get_user_asm(tmp, (const u8 __user *)src,
16229 ret, "b", "b", "=q", 1);
16230 if (likely(!ret))
16231 __put_user_asm(tmp, (u8 __user *)dst,
16232 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16233 }
16234 case 2: {
16235 u16 tmp;
16236 - __get_user_asm(tmp, (u16 __user *)src,
16237 + __get_user_asm(tmp, (const u16 __user *)src,
16238 ret, "w", "w", "=r", 2);
16239 if (likely(!ret))
16240 __put_user_asm(tmp, (u16 __user *)dst,
16241 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16242
16243 case 4: {
16244 u32 tmp;
16245 - __get_user_asm(tmp, (u32 __user *)src,
16246 + __get_user_asm(tmp, (const u32 __user *)src,
16247 ret, "l", "k", "=r", 4);
16248 if (likely(!ret))
16249 __put_user_asm(tmp, (u32 __user *)dst,
16250 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16251 }
16252 case 8: {
16253 u64 tmp;
16254 - __get_user_asm(tmp, (u64 __user *)src,
16255 + __get_user_asm(tmp, (const u64 __user *)src,
16256 ret, "q", "", "=r", 8);
16257 if (likely(!ret))
16258 __put_user_asm(tmp, (u64 __user *)dst,
16259 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16260 return ret;
16261 }
16262 default:
16263 - return copy_user_generic((__force void *)dst,
16264 - (__force void *)src, size);
16265 + return copy_user_generic((__force_kernel void *)____m(dst),
16266 + (__force_kernel const void *)____m(src), size);
16267 }
16268 }
16269
16270 static __must_check __always_inline int
16271 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16272 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16273 {
16274 - return copy_user_generic(dst, (__force const void *)src, size);
16275 + if (size > INT_MAX)
16276 + return size;
16277 +
16278 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16279 + if (!__access_ok(VERIFY_READ, src, size))
16280 + return size;
16281 +#endif
16282 +
16283 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16284 }
16285
16286 -static __must_check __always_inline int
16287 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16288 +static __must_check __always_inline unsigned long
16289 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16290 {
16291 - return copy_user_generic((__force void *)dst, src, size);
16292 + if (size > INT_MAX)
16293 + return size;
16294 +
16295 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16296 + if (!__access_ok(VERIFY_WRITE, dst, size))
16297 + return size;
16298 +#endif
16299 +
16300 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16301 }
16302
16303 -extern long __copy_user_nocache(void *dst, const void __user *src,
16304 - unsigned size, int zerorest);
16305 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16306 + unsigned long size, int zerorest) __size_overflow(3);
16307
16308 -static inline int
16309 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16310 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16311 {
16312 might_sleep();
16313 +
16314 + if (size > INT_MAX)
16315 + return size;
16316 +
16317 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16318 + if (!__access_ok(VERIFY_READ, src, size))
16319 + return size;
16320 +#endif
16321 +
16322 return __copy_user_nocache(dst, src, size, 1);
16323 }
16324
16325 -static inline int
16326 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16327 - unsigned size)
16328 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16329 + unsigned long size)
16330 {
16331 + if (size > INT_MAX)
16332 + return size;
16333 +
16334 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16335 + if (!__access_ok(VERIFY_READ, src, size))
16336 + return size;
16337 +#endif
16338 +
16339 return __copy_user_nocache(dst, src, size, 0);
16340 }
16341
16342 -unsigned long
16343 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16344 +extern unsigned long
16345 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16346
16347 #endif /* _ASM_X86_UACCESS_64_H */
16348 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16349 index 5b238981..77fdd78 100644
16350 --- a/arch/x86/include/asm/word-at-a-time.h
16351 +++ b/arch/x86/include/asm/word-at-a-time.h
16352 @@ -11,7 +11,7 @@
16353 * and shift, for example.
16354 */
16355 struct word_at_a_time {
16356 - const unsigned long one_bits, high_bits;
16357 + unsigned long one_bits, high_bits;
16358 };
16359
16360 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16361 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16362 index 5769349..a3d3e2a 100644
16363 --- a/arch/x86/include/asm/x86_init.h
16364 +++ b/arch/x86/include/asm/x86_init.h
16365 @@ -141,7 +141,7 @@ struct x86_init_ops {
16366 struct x86_init_timers timers;
16367 struct x86_init_iommu iommu;
16368 struct x86_init_pci pci;
16369 -};
16370 +} __no_const;
16371
16372 /**
16373 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16374 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
16375 void (*setup_percpu_clockev)(void);
16376 void (*early_percpu_clock_init)(void);
16377 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16378 -};
16379 +} __no_const;
16380
16381 /**
16382 * struct x86_platform_ops - platform specific runtime functions
16383 @@ -178,7 +178,7 @@ struct x86_platform_ops {
16384 void (*save_sched_clock_state)(void);
16385 void (*restore_sched_clock_state)(void);
16386 void (*apic_post_init)(void);
16387 -};
16388 +} __no_const;
16389
16390 struct pci_dev;
16391
16392 @@ -187,14 +187,14 @@ struct x86_msi_ops {
16393 void (*teardown_msi_irq)(unsigned int irq);
16394 void (*teardown_msi_irqs)(struct pci_dev *dev);
16395 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16396 -};
16397 +} __no_const;
16398
16399 struct x86_io_apic_ops {
16400 void (*init) (void);
16401 unsigned int (*read) (unsigned int apic, unsigned int reg);
16402 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
16403 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
16404 -};
16405 +} __no_const;
16406
16407 extern struct x86_init_ops x86_init;
16408 extern struct x86_cpuinit_ops x86_cpuinit;
16409 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16410 index 0415cda..b43d877 100644
16411 --- a/arch/x86/include/asm/xsave.h
16412 +++ b/arch/x86/include/asm/xsave.h
16413 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16414 return -EFAULT;
16415
16416 __asm__ __volatile__(ASM_STAC "\n"
16417 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16418 + "1:"
16419 + __copyuser_seg
16420 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16421 "2: " ASM_CLAC "\n"
16422 ".section .fixup,\"ax\"\n"
16423 "3: movl $-1,%[err]\n"
16424 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16425 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16426 {
16427 int err;
16428 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16429 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16430 u32 lmask = mask;
16431 u32 hmask = mask >> 32;
16432
16433 __asm__ __volatile__(ASM_STAC "\n"
16434 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16435 + "1:"
16436 + __copyuser_seg
16437 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16438 "2: " ASM_CLAC "\n"
16439 ".section .fixup,\"ax\"\n"
16440 "3: movl $-1,%[err]\n"
16441 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16442 index bbae024..e1528f9 100644
16443 --- a/arch/x86/include/uapi/asm/e820.h
16444 +++ b/arch/x86/include/uapi/asm/e820.h
16445 @@ -63,7 +63,7 @@ struct e820map {
16446 #define ISA_START_ADDRESS 0xa0000
16447 #define ISA_END_ADDRESS 0x100000
16448
16449 -#define BIOS_BEGIN 0x000a0000
16450 +#define BIOS_BEGIN 0x000c0000
16451 #define BIOS_END 0x00100000
16452
16453 #define BIOS_ROM_BASE 0xffe00000
16454 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16455 index 34e923a..0c6bb6e 100644
16456 --- a/arch/x86/kernel/Makefile
16457 +++ b/arch/x86/kernel/Makefile
16458 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16459 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16460 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16461 obj-y += probe_roms.o
16462 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16463 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16464 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16465 obj-y += syscall_$(BITS).o
16466 obj-$(CONFIG_X86_64) += vsyscall_64.o
16467 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16468 index bacf4b0..4ede72e 100644
16469 --- a/arch/x86/kernel/acpi/boot.c
16470 +++ b/arch/x86/kernel/acpi/boot.c
16471 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16472 * If your system is blacklisted here, but you find that acpi=force
16473 * works for you, please contact linux-acpi@vger.kernel.org
16474 */
16475 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16476 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16477 /*
16478 * Boxes that need ACPI disabled
16479 */
16480 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16481 };
16482
16483 /* second table for DMI checks that should run after early-quirks */
16484 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16485 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16486 /*
16487 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16488 * which includes some code which overrides all temperature
16489 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16490 index d5e0d71..6533e08 100644
16491 --- a/arch/x86/kernel/acpi/sleep.c
16492 +++ b/arch/x86/kernel/acpi/sleep.c
16493 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16494 #else /* CONFIG_64BIT */
16495 #ifdef CONFIG_SMP
16496 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16497 +
16498 + pax_open_kernel();
16499 early_gdt_descr.address =
16500 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16501 + pax_close_kernel();
16502 +
16503 initial_gs = per_cpu_offset(smp_processor_id());
16504 #endif
16505 initial_code = (unsigned long)wakeup_long64;
16506 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16507 index 13ab720..95d5442 100644
16508 --- a/arch/x86/kernel/acpi/wakeup_32.S
16509 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16510 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16511 # and restore the stack ... but you need gdt for this to work
16512 movl saved_context_esp, %esp
16513
16514 - movl %cs:saved_magic, %eax
16515 - cmpl $0x12345678, %eax
16516 + cmpl $0x12345678, saved_magic
16517 jne bogus_magic
16518
16519 # jump to place where we left off
16520 - movl saved_eip, %eax
16521 - jmp *%eax
16522 + jmp *(saved_eip)
16523
16524 bogus_magic:
16525 jmp bogus_magic
16526 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16527 index ef5ccca..bd83949 100644
16528 --- a/arch/x86/kernel/alternative.c
16529 +++ b/arch/x86/kernel/alternative.c
16530 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16531 */
16532 for (a = start; a < end; a++) {
16533 instr = (u8 *)&a->instr_offset + a->instr_offset;
16534 +
16535 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16536 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16537 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16538 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16539 +#endif
16540 +
16541 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16542 BUG_ON(a->replacementlen > a->instrlen);
16543 BUG_ON(a->instrlen > sizeof(insnbuf));
16544 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16545 for (poff = start; poff < end; poff++) {
16546 u8 *ptr = (u8 *)poff + *poff;
16547
16548 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16549 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16550 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16551 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16552 +#endif
16553 +
16554 if (!*poff || ptr < text || ptr >= text_end)
16555 continue;
16556 /* turn DS segment override prefix into lock prefix */
16557 - if (*ptr == 0x3e)
16558 + if (*ktla_ktva(ptr) == 0x3e)
16559 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16560 }
16561 mutex_unlock(&text_mutex);
16562 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16563 for (poff = start; poff < end; poff++) {
16564 u8 *ptr = (u8 *)poff + *poff;
16565
16566 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16567 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16568 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16569 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16570 +#endif
16571 +
16572 if (!*poff || ptr < text || ptr >= text_end)
16573 continue;
16574 /* turn lock prefix into DS segment override prefix */
16575 - if (*ptr == 0xf0)
16576 + if (*ktla_ktva(ptr) == 0xf0)
16577 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16578 }
16579 mutex_unlock(&text_mutex);
16580 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16581
16582 BUG_ON(p->len > MAX_PATCH_LEN);
16583 /* prep the buffer with the original instructions */
16584 - memcpy(insnbuf, p->instr, p->len);
16585 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16586 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16587 (unsigned long)p->instr, p->len);
16588
16589 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16590 if (!uniproc_patched || num_possible_cpus() == 1)
16591 free_init_pages("SMP alternatives",
16592 (unsigned long)__smp_locks,
16593 - (unsigned long)__smp_locks_end);
16594 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16595 #endif
16596
16597 apply_paravirt(__parainstructions, __parainstructions_end);
16598 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16599 * instructions. And on the local CPU you need to be protected again NMI or MCE
16600 * handlers seeing an inconsistent instruction while you patch.
16601 */
16602 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16603 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16604 size_t len)
16605 {
16606 unsigned long flags;
16607 local_irq_save(flags);
16608 - memcpy(addr, opcode, len);
16609 +
16610 + pax_open_kernel();
16611 + memcpy(ktla_ktva(addr), opcode, len);
16612 sync_core();
16613 + pax_close_kernel();
16614 +
16615 local_irq_restore(flags);
16616 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16617 that causes hangs on some VIA CPUs. */
16618 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16619 */
16620 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16621 {
16622 - unsigned long flags;
16623 - char *vaddr;
16624 + unsigned char *vaddr = ktla_ktva(addr);
16625 struct page *pages[2];
16626 - int i;
16627 + size_t i;
16628
16629 if (!core_kernel_text((unsigned long)addr)) {
16630 - pages[0] = vmalloc_to_page(addr);
16631 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16632 + pages[0] = vmalloc_to_page(vaddr);
16633 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16634 } else {
16635 - pages[0] = virt_to_page(addr);
16636 + pages[0] = virt_to_page(vaddr);
16637 WARN_ON(!PageReserved(pages[0]));
16638 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16639 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16640 }
16641 BUG_ON(!pages[0]);
16642 - local_irq_save(flags);
16643 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16644 - if (pages[1])
16645 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16646 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16647 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16648 - clear_fixmap(FIX_TEXT_POKE0);
16649 - if (pages[1])
16650 - clear_fixmap(FIX_TEXT_POKE1);
16651 - local_flush_tlb();
16652 - sync_core();
16653 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16654 - that causes hangs on some VIA CPUs. */
16655 + text_poke_early(addr, opcode, len);
16656 for (i = 0; i < len; i++)
16657 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16658 - local_irq_restore(flags);
16659 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16660 return addr;
16661 }
16662
16663 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16664 index cbf5121..812b537 100644
16665 --- a/arch/x86/kernel/apic/apic.c
16666 +++ b/arch/x86/kernel/apic/apic.c
16667 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16668 /*
16669 * Debug level, exported for io_apic.c
16670 */
16671 -unsigned int apic_verbosity;
16672 +int apic_verbosity;
16673
16674 int pic_mode;
16675
16676 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16677 apic_write(APIC_ESR, 0);
16678 v1 = apic_read(APIC_ESR);
16679 ack_APIC_irq();
16680 - atomic_inc(&irq_err_count);
16681 + atomic_inc_unchecked(&irq_err_count);
16682
16683 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16684 smp_processor_id(), v0 , v1);
16685 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16686 index 00c77cf..2dc6a2d 100644
16687 --- a/arch/x86/kernel/apic/apic_flat_64.c
16688 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16689 @@ -157,7 +157,7 @@ static int flat_probe(void)
16690 return 1;
16691 }
16692
16693 -static struct apic apic_flat = {
16694 +static struct apic apic_flat __read_only = {
16695 .name = "flat",
16696 .probe = flat_probe,
16697 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16698 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16699 return 0;
16700 }
16701
16702 -static struct apic apic_physflat = {
16703 +static struct apic apic_physflat __read_only = {
16704
16705 .name = "physical flat",
16706 .probe = physflat_probe,
16707 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16708 index e145f28..2752888 100644
16709 --- a/arch/x86/kernel/apic/apic_noop.c
16710 +++ b/arch/x86/kernel/apic/apic_noop.c
16711 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16712 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16713 }
16714
16715 -struct apic apic_noop = {
16716 +struct apic apic_noop __read_only = {
16717 .name = "noop",
16718 .probe = noop_probe,
16719 .acpi_madt_oem_check = NULL,
16720 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16721 index d50e364..543bee3 100644
16722 --- a/arch/x86/kernel/apic/bigsmp_32.c
16723 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16724 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16725 return dmi_bigsmp;
16726 }
16727
16728 -static struct apic apic_bigsmp = {
16729 +static struct apic apic_bigsmp __read_only = {
16730
16731 .name = "bigsmp",
16732 .probe = probe_bigsmp,
16733 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16734 index 0874799..a7a7892 100644
16735 --- a/arch/x86/kernel/apic/es7000_32.c
16736 +++ b/arch/x86/kernel/apic/es7000_32.c
16737 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16738 return ret && es7000_apic_is_cluster();
16739 }
16740
16741 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16742 -static struct apic __refdata apic_es7000_cluster = {
16743 +static struct apic apic_es7000_cluster __read_only = {
16744
16745 .name = "es7000",
16746 .probe = probe_es7000,
16747 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16748 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16749 };
16750
16751 -static struct apic __refdata apic_es7000 = {
16752 +static struct apic apic_es7000 __read_only = {
16753
16754 .name = "es7000",
16755 .probe = probe_es7000,
16756 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16757 index b739d39..aebc14c 100644
16758 --- a/arch/x86/kernel/apic/io_apic.c
16759 +++ b/arch/x86/kernel/apic/io_apic.c
16760 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16761 }
16762 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16763
16764 -void lock_vector_lock(void)
16765 +void lock_vector_lock(void) __acquires(vector_lock)
16766 {
16767 /* Used to the online set of cpus does not change
16768 * during assign_irq_vector.
16769 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
16770 raw_spin_lock(&vector_lock);
16771 }
16772
16773 -void unlock_vector_lock(void)
16774 +void unlock_vector_lock(void) __releases(vector_lock)
16775 {
16776 raw_spin_unlock(&vector_lock);
16777 }
16778 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
16779 ack_APIC_irq();
16780 }
16781
16782 -atomic_t irq_mis_count;
16783 +atomic_unchecked_t irq_mis_count;
16784
16785 #ifdef CONFIG_GENERIC_PENDING_IRQ
16786 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16787 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
16788 * at the cpu.
16789 */
16790 if (!(v & (1 << (i & 0x1f)))) {
16791 - atomic_inc(&irq_mis_count);
16792 + atomic_inc_unchecked(&irq_mis_count);
16793
16794 eoi_ioapic_irq(irq, cfg);
16795 }
16796 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
16797
16798 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
16799 {
16800 - chip->irq_print_chip = ir_print_prefix;
16801 - chip->irq_ack = ir_ack_apic_edge;
16802 - chip->irq_eoi = ir_ack_apic_level;
16803 + pax_open_kernel();
16804 + *(void **)&chip->irq_print_chip = ir_print_prefix;
16805 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
16806 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
16807
16808 - chip->irq_set_affinity = set_remapped_irq_affinity;
16809 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
16810 + pax_close_kernel();
16811 }
16812 #endif /* CONFIG_IRQ_REMAP */
16813
16814 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16815 index d661ee9..791fd33 100644
16816 --- a/arch/x86/kernel/apic/numaq_32.c
16817 +++ b/arch/x86/kernel/apic/numaq_32.c
16818 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16819 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16820 }
16821
16822 -/* Use __refdata to keep false positive warning calm. */
16823 -static struct apic __refdata apic_numaq = {
16824 +static struct apic apic_numaq __read_only = {
16825
16826 .name = "NUMAQ",
16827 .probe = probe_numaq,
16828 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16829 index eb35ef9..f184a21 100644
16830 --- a/arch/x86/kernel/apic/probe_32.c
16831 +++ b/arch/x86/kernel/apic/probe_32.c
16832 @@ -72,7 +72,7 @@ static int probe_default(void)
16833 return 1;
16834 }
16835
16836 -static struct apic apic_default = {
16837 +static struct apic apic_default __read_only = {
16838
16839 .name = "default",
16840 .probe = probe_default,
16841 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16842 index 77c95c0..434f8a4 100644
16843 --- a/arch/x86/kernel/apic/summit_32.c
16844 +++ b/arch/x86/kernel/apic/summit_32.c
16845 @@ -486,7 +486,7 @@ void setup_summit(void)
16846 }
16847 #endif
16848
16849 -static struct apic apic_summit = {
16850 +static struct apic apic_summit __read_only = {
16851
16852 .name = "summit",
16853 .probe = probe_summit,
16854 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16855 index c88baa4..757aee1 100644
16856 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16857 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16858 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16859 return notifier_from_errno(err);
16860 }
16861
16862 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16863 +static struct notifier_block x2apic_cpu_notifier = {
16864 .notifier_call = update_clusterinfo,
16865 };
16866
16867 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16868 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16869 }
16870
16871 -static struct apic apic_x2apic_cluster = {
16872 +static struct apic apic_x2apic_cluster __read_only = {
16873
16874 .name = "cluster x2apic",
16875 .probe = x2apic_cluster_probe,
16876 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
16877 index 562a76d..a003c0f 100644
16878 --- a/arch/x86/kernel/apic/x2apic_phys.c
16879 +++ b/arch/x86/kernel/apic/x2apic_phys.c
16880 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
16881 return apic == &apic_x2apic_phys;
16882 }
16883
16884 -static struct apic apic_x2apic_phys = {
16885 +static struct apic apic_x2apic_phys __read_only = {
16886
16887 .name = "physical x2apic",
16888 .probe = x2apic_phys_probe,
16889 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
16890 index 8cfade9..b9d04fc 100644
16891 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
16892 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
16893 @@ -333,7 +333,7 @@ static int uv_probe(void)
16894 return apic == &apic_x2apic_uv_x;
16895 }
16896
16897 -static struct apic __refdata apic_x2apic_uv_x = {
16898 +static struct apic apic_x2apic_uv_x __read_only = {
16899
16900 .name = "UV large system",
16901 .probe = uv_probe,
16902 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
16903 index d65464e..1035d31 100644
16904 --- a/arch/x86/kernel/apm_32.c
16905 +++ b/arch/x86/kernel/apm_32.c
16906 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
16907 * This is for buggy BIOS's that refer to (real mode) segment 0x40
16908 * even though they are called in protected mode.
16909 */
16910 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
16911 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
16912 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
16913
16914 static const char driver_version[] = "1.16ac"; /* no spaces */
16915 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
16916 BUG_ON(cpu != 0);
16917 gdt = get_cpu_gdt_table(cpu);
16918 save_desc_40 = gdt[0x40 / 8];
16919 +
16920 + pax_open_kernel();
16921 gdt[0x40 / 8] = bad_bios_desc;
16922 + pax_close_kernel();
16923
16924 apm_irq_save(flags);
16925 APM_DO_SAVE_SEGS;
16926 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
16927 &call->esi);
16928 APM_DO_RESTORE_SEGS;
16929 apm_irq_restore(flags);
16930 +
16931 + pax_open_kernel();
16932 gdt[0x40 / 8] = save_desc_40;
16933 + pax_close_kernel();
16934 +
16935 put_cpu();
16936
16937 return call->eax & 0xff;
16938 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
16939 BUG_ON(cpu != 0);
16940 gdt = get_cpu_gdt_table(cpu);
16941 save_desc_40 = gdt[0x40 / 8];
16942 +
16943 + pax_open_kernel();
16944 gdt[0x40 / 8] = bad_bios_desc;
16945 + pax_close_kernel();
16946
16947 apm_irq_save(flags);
16948 APM_DO_SAVE_SEGS;
16949 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
16950 &call->eax);
16951 APM_DO_RESTORE_SEGS;
16952 apm_irq_restore(flags);
16953 +
16954 + pax_open_kernel();
16955 gdt[0x40 / 8] = save_desc_40;
16956 + pax_close_kernel();
16957 +
16958 put_cpu();
16959 return error;
16960 }
16961 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
16962 * code to that CPU.
16963 */
16964 gdt = get_cpu_gdt_table(0);
16965 +
16966 + pax_open_kernel();
16967 set_desc_base(&gdt[APM_CS >> 3],
16968 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
16969 set_desc_base(&gdt[APM_CS_16 >> 3],
16970 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
16971 set_desc_base(&gdt[APM_DS >> 3],
16972 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
16973 + pax_close_kernel();
16974
16975 proc_create("apm", 0, NULL, &apm_file_ops);
16976
16977 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
16978 index 2861082..6d4718e 100644
16979 --- a/arch/x86/kernel/asm-offsets.c
16980 +++ b/arch/x86/kernel/asm-offsets.c
16981 @@ -33,6 +33,8 @@ void common(void) {
16982 OFFSET(TI_status, thread_info, status);
16983 OFFSET(TI_addr_limit, thread_info, addr_limit);
16984 OFFSET(TI_preempt_count, thread_info, preempt_count);
16985 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
16986 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
16987
16988 BLANK();
16989 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
16990 @@ -53,8 +55,26 @@ void common(void) {
16991 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
16992 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
16993 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
16994 +
16995 +#ifdef CONFIG_PAX_KERNEXEC
16996 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
16997 #endif
16998
16999 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17000 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17001 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17002 +#ifdef CONFIG_X86_64
17003 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17004 +#endif
17005 +#endif
17006 +
17007 +#endif
17008 +
17009 + BLANK();
17010 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17011 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17012 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17013 +
17014 #ifdef CONFIG_XEN
17015 BLANK();
17016 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17017 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17018 index 1b4754f..fbb4227 100644
17019 --- a/arch/x86/kernel/asm-offsets_64.c
17020 +++ b/arch/x86/kernel/asm-offsets_64.c
17021 @@ -76,6 +76,7 @@ int main(void)
17022 BLANK();
17023 #undef ENTRY
17024
17025 + DEFINE(TSS_size, sizeof(struct tss_struct));
17026 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17027 BLANK();
17028
17029 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17030 index a0e067d..9c7db16 100644
17031 --- a/arch/x86/kernel/cpu/Makefile
17032 +++ b/arch/x86/kernel/cpu/Makefile
17033 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17034 CFLAGS_REMOVE_perf_event.o = -pg
17035 endif
17036
17037 -# Make sure load_percpu_segment has no stackprotector
17038 -nostackp := $(call cc-option, -fno-stack-protector)
17039 -CFLAGS_common.o := $(nostackp)
17040 -
17041 obj-y := intel_cacheinfo.o scattered.o topology.o
17042 obj-y += proc.o capflags.o powerflags.o common.o
17043 obj-y += vmware.o hypervisor.o mshyperv.o
17044 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17045 index 15239ff..e23e04e 100644
17046 --- a/arch/x86/kernel/cpu/amd.c
17047 +++ b/arch/x86/kernel/cpu/amd.c
17048 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17049 unsigned int size)
17050 {
17051 /* AMD errata T13 (order #21922) */
17052 - if ((c->x86 == 6)) {
17053 + if (c->x86 == 6) {
17054 /* Duron Rev A0 */
17055 if (c->x86_model == 3 && c->x86_mask == 0)
17056 size = 64;
17057 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17058 index 9c3ab43..51e6366 100644
17059 --- a/arch/x86/kernel/cpu/common.c
17060 +++ b/arch/x86/kernel/cpu/common.c
17061 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17062
17063 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17064
17065 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17066 -#ifdef CONFIG_X86_64
17067 - /*
17068 - * We need valid kernel segments for data and code in long mode too
17069 - * IRET will check the segment types kkeil 2000/10/28
17070 - * Also sysret mandates a special GDT layout
17071 - *
17072 - * TLS descriptors are currently at a different place compared to i386.
17073 - * Hopefully nobody expects them at a fixed place (Wine?)
17074 - */
17075 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17076 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17077 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17078 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17079 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17080 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17081 -#else
17082 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17083 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17084 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17085 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17086 - /*
17087 - * Segments used for calling PnP BIOS have byte granularity.
17088 - * They code segments and data segments have fixed 64k limits,
17089 - * the transfer segment sizes are set at run time.
17090 - */
17091 - /* 32-bit code */
17092 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17093 - /* 16-bit code */
17094 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17095 - /* 16-bit data */
17096 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17097 - /* 16-bit data */
17098 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17099 - /* 16-bit data */
17100 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17101 - /*
17102 - * The APM segments have byte granularity and their bases
17103 - * are set at run time. All have 64k limits.
17104 - */
17105 - /* 32-bit code */
17106 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17107 - /* 16-bit code */
17108 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17109 - /* data */
17110 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17111 -
17112 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17113 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17114 - GDT_STACK_CANARY_INIT
17115 -#endif
17116 -} };
17117 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17118 -
17119 static int __init x86_xsave_setup(char *s)
17120 {
17121 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17122 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
17123 {
17124 struct desc_ptr gdt_descr;
17125
17126 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17127 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17128 gdt_descr.size = GDT_SIZE - 1;
17129 load_gdt(&gdt_descr);
17130 /* Reload the per-cpu base */
17131 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17132 /* Filter out anything that depends on CPUID levels we don't have */
17133 filter_cpuid_features(c, true);
17134
17135 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17136 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17137 +#endif
17138 +
17139 /* If the model name is still unset, do table lookup. */
17140 if (!c->x86_model_id[0]) {
17141 const char *p;
17142 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
17143 }
17144 __setup("clearcpuid=", setup_disablecpuid);
17145
17146 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17147 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17148 +
17149 #ifdef CONFIG_X86_64
17150 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17151 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17152 - (unsigned long) nmi_idt_table };
17153 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17154
17155 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17156 irq_stack_union) __aligned(PAGE_SIZE);
17157 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17158 EXPORT_PER_CPU_SYMBOL(current_task);
17159
17160 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17161 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17162 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17163 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17164
17165 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17166 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
17167 int i;
17168
17169 cpu = stack_smp_processor_id();
17170 - t = &per_cpu(init_tss, cpu);
17171 + t = init_tss + cpu;
17172 oist = &per_cpu(orig_ist, cpu);
17173
17174 #ifdef CONFIG_NUMA
17175 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
17176 switch_to_new_gdt(cpu);
17177 loadsegment(fs, 0);
17178
17179 - load_idt((const struct desc_ptr *)&idt_descr);
17180 + load_idt(&idt_descr);
17181
17182 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17183 syscall_init();
17184 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
17185 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17186 barrier();
17187
17188 - x86_configure_nx();
17189 enable_x2apic();
17190
17191 /*
17192 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
17193 {
17194 int cpu = smp_processor_id();
17195 struct task_struct *curr = current;
17196 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17197 + struct tss_struct *t = init_tss + cpu;
17198 struct thread_struct *thread = &curr->thread;
17199
17200 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
17201 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17202 index fcaabd0..7b55a26 100644
17203 --- a/arch/x86/kernel/cpu/intel.c
17204 +++ b/arch/x86/kernel/cpu/intel.c
17205 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17206 * Update the IDT descriptor and reload the IDT so that
17207 * it uses the read-only mapped virtual address.
17208 */
17209 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17210 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17211 load_idt(&idt_descr);
17212 }
17213 #endif
17214 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17215 index 84c1309..39b7224 100644
17216 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17217 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17218 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17219 };
17220
17221 #ifdef CONFIG_AMD_NB
17222 +static struct attribute *default_attrs_amd_nb[] = {
17223 + &type.attr,
17224 + &level.attr,
17225 + &coherency_line_size.attr,
17226 + &physical_line_partition.attr,
17227 + &ways_of_associativity.attr,
17228 + &number_of_sets.attr,
17229 + &size.attr,
17230 + &shared_cpu_map.attr,
17231 + &shared_cpu_list.attr,
17232 + NULL,
17233 + NULL,
17234 + NULL,
17235 + NULL
17236 +};
17237 +
17238 static struct attribute ** __cpuinit amd_l3_attrs(void)
17239 {
17240 static struct attribute **attrs;
17241 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17242
17243 n = ARRAY_SIZE(default_attrs);
17244
17245 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17246 - n += 2;
17247 -
17248 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17249 - n += 1;
17250 -
17251 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17252 - if (attrs == NULL)
17253 - return attrs = default_attrs;
17254 -
17255 - for (n = 0; default_attrs[n]; n++)
17256 - attrs[n] = default_attrs[n];
17257 + attrs = default_attrs_amd_nb;
17258
17259 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17260 attrs[n++] = &cache_disable_0.attr;
17261 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17262 .default_attrs = default_attrs,
17263 };
17264
17265 +#ifdef CONFIG_AMD_NB
17266 +static struct kobj_type ktype_cache_amd_nb = {
17267 + .sysfs_ops = &sysfs_ops,
17268 + .default_attrs = default_attrs_amd_nb,
17269 +};
17270 +#endif
17271 +
17272 static struct kobj_type ktype_percpu_entry = {
17273 .sysfs_ops = &sysfs_ops,
17274 };
17275 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17276 return retval;
17277 }
17278
17279 +#ifdef CONFIG_AMD_NB
17280 + amd_l3_attrs();
17281 +#endif
17282 +
17283 for (i = 0; i < num_cache_leaves; i++) {
17284 + struct kobj_type *ktype;
17285 +
17286 this_object = INDEX_KOBJECT_PTR(cpu, i);
17287 this_object->cpu = cpu;
17288 this_object->index = i;
17289
17290 this_leaf = CPUID4_INFO_IDX(cpu, i);
17291
17292 - ktype_cache.default_attrs = default_attrs;
17293 + ktype = &ktype_cache;
17294 #ifdef CONFIG_AMD_NB
17295 if (this_leaf->base.nb)
17296 - ktype_cache.default_attrs = amd_l3_attrs();
17297 + ktype = &ktype_cache_amd_nb;
17298 #endif
17299 retval = kobject_init_and_add(&(this_object->kobj),
17300 - &ktype_cache,
17301 + ktype,
17302 per_cpu(ici_cache_kobject, cpu),
17303 "index%1lu", i);
17304 if (unlikely(retval)) {
17305 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17306 return NOTIFY_OK;
17307 }
17308
17309 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17310 +static struct notifier_block cacheinfo_cpu_notifier = {
17311 .notifier_call = cacheinfo_cpu_callback,
17312 };
17313
17314 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17315 index 80dbda8..be16652 100644
17316 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17317 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17318 @@ -45,6 +45,7 @@
17319 #include <asm/processor.h>
17320 #include <asm/mce.h>
17321 #include <asm/msr.h>
17322 +#include <asm/local.h>
17323
17324 #include "mce-internal.h"
17325
17326 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17327 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17328 m->cs, m->ip);
17329
17330 - if (m->cs == __KERNEL_CS)
17331 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17332 print_symbol("{%s}", m->ip);
17333 pr_cont("\n");
17334 }
17335 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17336
17337 #define PANIC_TIMEOUT 5 /* 5 seconds */
17338
17339 -static atomic_t mce_paniced;
17340 +static atomic_unchecked_t mce_paniced;
17341
17342 static int fake_panic;
17343 -static atomic_t mce_fake_paniced;
17344 +static atomic_unchecked_t mce_fake_paniced;
17345
17346 /* Panic in progress. Enable interrupts and wait for final IPI */
17347 static void wait_for_panic(void)
17348 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17349 /*
17350 * Make sure only one CPU runs in machine check panic
17351 */
17352 - if (atomic_inc_return(&mce_paniced) > 1)
17353 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17354 wait_for_panic();
17355 barrier();
17356
17357 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17358 console_verbose();
17359 } else {
17360 /* Don't log too much for fake panic */
17361 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17362 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17363 return;
17364 }
17365 /* First print corrected ones that are still unlogged */
17366 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
17367 * might have been modified by someone else.
17368 */
17369 rmb();
17370 - if (atomic_read(&mce_paniced))
17371 + if (atomic_read_unchecked(&mce_paniced))
17372 wait_for_panic();
17373 if (!mca_cfg.monarch_timeout)
17374 goto out;
17375 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17376 }
17377
17378 /* Call the installed machine check handler for this CPU setup. */
17379 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17380 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17381 unexpected_machine_check;
17382
17383 /*
17384 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17385 return;
17386 }
17387
17388 + pax_open_kernel();
17389 machine_check_vector = do_machine_check;
17390 + pax_close_kernel();
17391
17392 __mcheck_cpu_init_generic();
17393 __mcheck_cpu_init_vendor(c);
17394 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17395 */
17396
17397 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17398 -static int mce_chrdev_open_count; /* #times opened */
17399 +static local_t mce_chrdev_open_count; /* #times opened */
17400 static int mce_chrdev_open_exclu; /* already open exclusive? */
17401
17402 static int mce_chrdev_open(struct inode *inode, struct file *file)
17403 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17404 spin_lock(&mce_chrdev_state_lock);
17405
17406 if (mce_chrdev_open_exclu ||
17407 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17408 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17409 spin_unlock(&mce_chrdev_state_lock);
17410
17411 return -EBUSY;
17412 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17413
17414 if (file->f_flags & O_EXCL)
17415 mce_chrdev_open_exclu = 1;
17416 - mce_chrdev_open_count++;
17417 + local_inc(&mce_chrdev_open_count);
17418
17419 spin_unlock(&mce_chrdev_state_lock);
17420
17421 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17422 {
17423 spin_lock(&mce_chrdev_state_lock);
17424
17425 - mce_chrdev_open_count--;
17426 + local_dec(&mce_chrdev_open_count);
17427 mce_chrdev_open_exclu = 0;
17428
17429 spin_unlock(&mce_chrdev_state_lock);
17430 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17431 return NOTIFY_OK;
17432 }
17433
17434 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17435 +static struct notifier_block mce_cpu_notifier = {
17436 .notifier_call = mce_cpu_callback,
17437 };
17438
17439 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
17440
17441 for (i = 0; i < mca_cfg.banks; i++) {
17442 struct mce_bank *b = &mce_banks[i];
17443 - struct device_attribute *a = &b->attr;
17444 + device_attribute_no_const *a = &b->attr;
17445
17446 sysfs_attr_init(&a->attr);
17447 a->attr.name = b->attrname;
17448 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
17449 static void mce_reset(void)
17450 {
17451 cpu_missing = 0;
17452 - atomic_set(&mce_fake_paniced, 0);
17453 + atomic_set_unchecked(&mce_fake_paniced, 0);
17454 atomic_set(&mce_executing, 0);
17455 atomic_set(&mce_callin, 0);
17456 atomic_set(&global_nwo, 0);
17457 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17458 index 2d5454c..51987eb 100644
17459 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17460 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17461 @@ -11,6 +11,7 @@
17462 #include <asm/processor.h>
17463 #include <asm/mce.h>
17464 #include <asm/msr.h>
17465 +#include <asm/pgtable.h>
17466
17467 /* By default disabled */
17468 int mce_p5_enabled __read_mostly;
17469 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17470 if (!cpu_has(c, X86_FEATURE_MCE))
17471 return;
17472
17473 + pax_open_kernel();
17474 machine_check_vector = pentium_machine_check;
17475 + pax_close_kernel();
17476 /* Make sure the vector pointer is visible before we enable MCEs: */
17477 wmb();
17478
17479 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17480 index 47a1870..8c019a7 100644
17481 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17482 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17483 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17484 return notifier_from_errno(err);
17485 }
17486
17487 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17488 +static struct notifier_block thermal_throttle_cpu_notifier =
17489 {
17490 .notifier_call = thermal_throttle_cpu_callback,
17491 };
17492 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17493 index 2d7998f..17c9de1 100644
17494 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17495 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17496 @@ -10,6 +10,7 @@
17497 #include <asm/processor.h>
17498 #include <asm/mce.h>
17499 #include <asm/msr.h>
17500 +#include <asm/pgtable.h>
17501
17502 /* Machine check handler for WinChip C6: */
17503 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17504 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17505 {
17506 u32 lo, hi;
17507
17508 + pax_open_kernel();
17509 machine_check_vector = winchip_machine_check;
17510 + pax_close_kernel();
17511 /* Make sure the vector pointer is visible before we enable MCEs: */
17512 wmb();
17513
17514 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17515 index 726bf96..81f0526 100644
17516 --- a/arch/x86/kernel/cpu/mtrr/main.c
17517 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17518 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17519 u64 size_or_mask, size_and_mask;
17520 static bool mtrr_aps_delayed_init;
17521
17522 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17523 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17524
17525 const struct mtrr_ops *mtrr_if;
17526
17527 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17528 index df5e41f..816c719 100644
17529 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17530 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17531 @@ -25,7 +25,7 @@ struct mtrr_ops {
17532 int (*validate_add_page)(unsigned long base, unsigned long size,
17533 unsigned int type);
17534 int (*have_wrcomb)(void);
17535 -};
17536 +} __do_const;
17537
17538 extern int generic_get_free_region(unsigned long base, unsigned long size,
17539 int replace_reg);
17540 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17541 index 6774c17..72c1b22 100644
17542 --- a/arch/x86/kernel/cpu/perf_event.c
17543 +++ b/arch/x86/kernel/cpu/perf_event.c
17544 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17545 pr_info("no hardware sampling interrupt available.\n");
17546 }
17547
17548 -static struct attribute_group x86_pmu_format_group = {
17549 +static attribute_group_no_const x86_pmu_format_group = {
17550 .name = "format",
17551 .attrs = NULL,
17552 };
17553 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
17554 struct perf_pmu_events_attr {
17555 struct device_attribute attr;
17556 u64 id;
17557 -};
17558 +} __do_const;
17559
17560 /*
17561 * Remove all undefined events (x86_pmu.event_map(id) == 0)
17562 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
17563 NULL,
17564 };
17565
17566 -static struct attribute_group x86_pmu_events_group = {
17567 +static attribute_group_no_const x86_pmu_events_group = {
17568 .name = "events",
17569 .attrs = events_attr,
17570 };
17571 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
17572 if (idx > GDT_ENTRIES)
17573 return 0;
17574
17575 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17576 + desc = get_cpu_gdt_table(smp_processor_id());
17577 }
17578
17579 return get_desc_base(desc + idx);
17580 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17581 break;
17582
17583 perf_callchain_store(entry, frame.return_address);
17584 - fp = frame.next_frame;
17585 + fp = (const void __force_user *)frame.next_frame;
17586 }
17587 }
17588
17589 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17590 index 4914e94..60b06e3 100644
17591 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17592 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17593 @@ -1958,10 +1958,10 @@ __init int intel_pmu_init(void)
17594 * v2 and above have a perf capabilities MSR
17595 */
17596 if (version > 1) {
17597 - u64 capabilities;
17598 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17599
17600 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17601 - x86_pmu.intel_cap.capabilities = capabilities;
17602 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17603 + x86_pmu.intel_cap.capabilities = capabilities;
17604 }
17605
17606 intel_ds_init();
17607 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17608 index b43200d..d235b3e 100644
17609 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17610 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17611 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17612 static int __init uncore_type_init(struct intel_uncore_type *type)
17613 {
17614 struct intel_uncore_pmu *pmus;
17615 - struct attribute_group *events_group;
17616 + attribute_group_no_const *attr_group;
17617 struct attribute **attrs;
17618 int i, j;
17619
17620 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
17621 while (type->event_descs[i].attr.attr.name)
17622 i++;
17623
17624 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17625 - sizeof(*events_group), GFP_KERNEL);
17626 - if (!events_group)
17627 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17628 + sizeof(*attr_group), GFP_KERNEL);
17629 + if (!attr_group)
17630 goto fail;
17631
17632 - attrs = (struct attribute **)(events_group + 1);
17633 - events_group->name = "events";
17634 - events_group->attrs = attrs;
17635 + attrs = (struct attribute **)(attr_group + 1);
17636 + attr_group->name = "events";
17637 + attr_group->attrs = attrs;
17638
17639 for (j = 0; j < i; j++)
17640 attrs[j] = &type->event_descs[j].attr.attr;
17641
17642 - type->events_group = events_group;
17643 + type->events_group = attr_group;
17644 }
17645
17646 type->pmu_group = &uncore_pmu_attr_group;
17647 @@ -2826,7 +2826,7 @@ static int
17648 return NOTIFY_OK;
17649 }
17650
17651 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17652 +static struct notifier_block uncore_cpu_nb = {
17653 .notifier_call = uncore_cpu_notifier,
17654 /*
17655 * to migrate uncore events, our notifier should be executed
17656 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17657 index e68a455..975a932 100644
17658 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17659 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17660 @@ -428,7 +428,7 @@ struct intel_uncore_box {
17661 struct uncore_event_desc {
17662 struct kobj_attribute attr;
17663 const char *config;
17664 -};
17665 +} __do_const;
17666
17667 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17668 { \
17669 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17670 index 60c7891..9e911d3 100644
17671 --- a/arch/x86/kernel/cpuid.c
17672 +++ b/arch/x86/kernel/cpuid.c
17673 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17674 return notifier_from_errno(err);
17675 }
17676
17677 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17678 +static struct notifier_block cpuid_class_cpu_notifier =
17679 {
17680 .notifier_call = cpuid_class_cpu_callback,
17681 };
17682 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17683 index 74467fe..18793d5 100644
17684 --- a/arch/x86/kernel/crash.c
17685 +++ b/arch/x86/kernel/crash.c
17686 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17687 {
17688 #ifdef CONFIG_X86_32
17689 struct pt_regs fixed_regs;
17690 -#endif
17691
17692 -#ifdef CONFIG_X86_32
17693 - if (!user_mode_vm(regs)) {
17694 + if (!user_mode(regs)) {
17695 crash_fixup_ss_esp(&fixed_regs, regs);
17696 regs = &fixed_regs;
17697 }
17698 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17699 index 37250fe..bf2ec74 100644
17700 --- a/arch/x86/kernel/doublefault_32.c
17701 +++ b/arch/x86/kernel/doublefault_32.c
17702 @@ -11,7 +11,7 @@
17703
17704 #define DOUBLEFAULT_STACKSIZE (1024)
17705 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17706 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17707 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17708
17709 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17710
17711 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17712 unsigned long gdt, tss;
17713
17714 store_gdt(&gdt_desc);
17715 - gdt = gdt_desc.address;
17716 + gdt = (unsigned long)gdt_desc.address;
17717
17718 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17719
17720 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17721 /* 0x2 bit is always set */
17722 .flags = X86_EFLAGS_SF | 0x2,
17723 .sp = STACK_START,
17724 - .es = __USER_DS,
17725 + .es = __KERNEL_DS,
17726 .cs = __KERNEL_CS,
17727 .ss = __KERNEL_DS,
17728 - .ds = __USER_DS,
17729 + .ds = __KERNEL_DS,
17730 .fs = __KERNEL_PERCPU,
17731
17732 .__cr3 = __pa_nodebug(swapper_pg_dir),
17733 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17734 index ae42418b..787c16b 100644
17735 --- a/arch/x86/kernel/dumpstack.c
17736 +++ b/arch/x86/kernel/dumpstack.c
17737 @@ -2,6 +2,9 @@
17738 * Copyright (C) 1991, 1992 Linus Torvalds
17739 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17740 */
17741 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17742 +#define __INCLUDED_BY_HIDESYM 1
17743 +#endif
17744 #include <linux/kallsyms.h>
17745 #include <linux/kprobes.h>
17746 #include <linux/uaccess.h>
17747 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17748 static void
17749 print_ftrace_graph_addr(unsigned long addr, void *data,
17750 const struct stacktrace_ops *ops,
17751 - struct thread_info *tinfo, int *graph)
17752 + struct task_struct *task, int *graph)
17753 {
17754 - struct task_struct *task;
17755 unsigned long ret_addr;
17756 int index;
17757
17758 if (addr != (unsigned long)return_to_handler)
17759 return;
17760
17761 - task = tinfo->task;
17762 index = task->curr_ret_stack;
17763
17764 if (!task->ret_stack || index < *graph)
17765 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17766 static inline void
17767 print_ftrace_graph_addr(unsigned long addr, void *data,
17768 const struct stacktrace_ops *ops,
17769 - struct thread_info *tinfo, int *graph)
17770 + struct task_struct *task, int *graph)
17771 { }
17772 #endif
17773
17774 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17775 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17776 */
17777
17778 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17779 - void *p, unsigned int size, void *end)
17780 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17781 {
17782 - void *t = tinfo;
17783 if (end) {
17784 if (p < end && p >= (end-THREAD_SIZE))
17785 return 1;
17786 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17787 }
17788
17789 unsigned long
17790 -print_context_stack(struct thread_info *tinfo,
17791 +print_context_stack(struct task_struct *task, void *stack_start,
17792 unsigned long *stack, unsigned long bp,
17793 const struct stacktrace_ops *ops, void *data,
17794 unsigned long *end, int *graph)
17795 {
17796 struct stack_frame *frame = (struct stack_frame *)bp;
17797
17798 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17799 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17800 unsigned long addr;
17801
17802 addr = *stack;
17803 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17804 } else {
17805 ops->address(data, addr, 0);
17806 }
17807 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17808 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17809 }
17810 stack++;
17811 }
17812 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17813 EXPORT_SYMBOL_GPL(print_context_stack);
17814
17815 unsigned long
17816 -print_context_stack_bp(struct thread_info *tinfo,
17817 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17818 unsigned long *stack, unsigned long bp,
17819 const struct stacktrace_ops *ops, void *data,
17820 unsigned long *end, int *graph)
17821 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17822 struct stack_frame *frame = (struct stack_frame *)bp;
17823 unsigned long *ret_addr = &frame->return_address;
17824
17825 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17826 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17827 unsigned long addr = *ret_addr;
17828
17829 if (!__kernel_text_address(addr))
17830 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17831 ops->address(data, addr, 1);
17832 frame = frame->next_frame;
17833 ret_addr = &frame->return_address;
17834 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17835 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17836 }
17837
17838 return (unsigned long)frame;
17839 @@ -189,7 +188,7 @@ void dump_stack(void)
17840
17841 bp = stack_frame(current, NULL);
17842 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
17843 - current->pid, current->comm, print_tainted(),
17844 + task_pid_nr(current), current->comm, print_tainted(),
17845 init_utsname()->release,
17846 (int)strcspn(init_utsname()->version, " "),
17847 init_utsname()->version);
17848 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
17849 }
17850 EXPORT_SYMBOL_GPL(oops_begin);
17851
17852 +extern void gr_handle_kernel_exploit(void);
17853 +
17854 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17855 {
17856 if (regs && kexec_should_crash(current))
17857 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17858 panic("Fatal exception in interrupt");
17859 if (panic_on_oops)
17860 panic("Fatal exception");
17861 - do_exit(signr);
17862 +
17863 + gr_handle_kernel_exploit();
17864 +
17865 + do_group_exit(signr);
17866 }
17867
17868 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17869 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17870 print_modules();
17871 show_regs(regs);
17872 #ifdef CONFIG_X86_32
17873 - if (user_mode_vm(regs)) {
17874 + if (user_mode(regs)) {
17875 sp = regs->sp;
17876 ss = regs->ss & 0xffff;
17877 } else {
17878 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17879 unsigned long flags = oops_begin();
17880 int sig = SIGSEGV;
17881
17882 - if (!user_mode_vm(regs))
17883 + if (!user_mode(regs))
17884 report_bug(regs->ip, regs);
17885
17886 if (__die(str, regs, err))
17887 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17888 index 1038a41..db2c12b 100644
17889 --- a/arch/x86/kernel/dumpstack_32.c
17890 +++ b/arch/x86/kernel/dumpstack_32.c
17891 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17892 bp = stack_frame(task, regs);
17893
17894 for (;;) {
17895 - struct thread_info *context;
17896 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17897
17898 - context = (struct thread_info *)
17899 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17900 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17901 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17902
17903 - stack = (unsigned long *)context->previous_esp;
17904 - if (!stack)
17905 + if (stack_start == task_stack_page(task))
17906 break;
17907 + stack = *(unsigned long **)stack_start;
17908 if (ops->stack(data, "IRQ") < 0)
17909 break;
17910 touch_nmi_watchdog();
17911 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
17912 {
17913 int i;
17914
17915 - __show_regs(regs, !user_mode_vm(regs));
17916 + __show_regs(regs, !user_mode(regs));
17917
17918 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
17919 TASK_COMM_LEN, current->comm, task_pid_nr(current),
17920 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
17921 * When in-kernel, we also print out the stack and code at the
17922 * time of the fault..
17923 */
17924 - if (!user_mode_vm(regs)) {
17925 + if (!user_mode(regs)) {
17926 unsigned int code_prologue = code_bytes * 43 / 64;
17927 unsigned int code_len = code_bytes;
17928 unsigned char c;
17929 u8 *ip;
17930 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
17931
17932 pr_emerg("Stack:\n");
17933 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
17934
17935 pr_emerg("Code:");
17936
17937 - ip = (u8 *)regs->ip - code_prologue;
17938 + ip = (u8 *)regs->ip - code_prologue + cs_base;
17939 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
17940 /* try starting at IP */
17941 - ip = (u8 *)regs->ip;
17942 + ip = (u8 *)regs->ip + cs_base;
17943 code_len = code_len - code_prologue + 1;
17944 }
17945 for (i = 0; i < code_len; i++, ip++) {
17946 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
17947 pr_cont(" Bad EIP value.");
17948 break;
17949 }
17950 - if (ip == (u8 *)regs->ip)
17951 + if (ip == (u8 *)regs->ip + cs_base)
17952 pr_cont(" <%02x>", c);
17953 else
17954 pr_cont(" %02x", c);
17955 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
17956 {
17957 unsigned short ud2;
17958
17959 + ip = ktla_ktva(ip);
17960 if (ip < PAGE_OFFSET)
17961 return 0;
17962 if (probe_kernel_address((unsigned short *)ip, ud2))
17963 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
17964
17965 return ud2 == 0x0b0f;
17966 }
17967 +
17968 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
17969 +void pax_check_alloca(unsigned long size)
17970 +{
17971 + unsigned long sp = (unsigned long)&sp, stack_left;
17972 +
17973 + /* all kernel stacks are of the same size */
17974 + stack_left = sp & (THREAD_SIZE - 1);
17975 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
17976 +}
17977 +EXPORT_SYMBOL(pax_check_alloca);
17978 +#endif
17979 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
17980 index b653675..51cc8c0 100644
17981 --- a/arch/x86/kernel/dumpstack_64.c
17982 +++ b/arch/x86/kernel/dumpstack_64.c
17983 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17984 unsigned long *irq_stack_end =
17985 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
17986 unsigned used = 0;
17987 - struct thread_info *tinfo;
17988 int graph = 0;
17989 unsigned long dummy;
17990 + void *stack_start;
17991
17992 if (!task)
17993 task = current;
17994 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17995 * current stack address. If the stacks consist of nested
17996 * exceptions
17997 */
17998 - tinfo = task_thread_info(task);
17999 for (;;) {
18000 char *id;
18001 unsigned long *estack_end;
18002 +
18003 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18004 &used, &id);
18005
18006 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18007 if (ops->stack(data, id) < 0)
18008 break;
18009
18010 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18011 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18012 data, estack_end, &graph);
18013 ops->stack(data, "<EOE>");
18014 /*
18015 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18016 * second-to-last pointer (index -2 to end) in the
18017 * exception stack:
18018 */
18019 + if ((u16)estack_end[-1] != __KERNEL_DS)
18020 + goto out;
18021 stack = (unsigned long *) estack_end[-2];
18022 continue;
18023 }
18024 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18025 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18026 if (ops->stack(data, "IRQ") < 0)
18027 break;
18028 - bp = ops->walk_stack(tinfo, stack, bp,
18029 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18030 ops, data, irq_stack_end, &graph);
18031 /*
18032 * We link to the next stack (which would be
18033 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18034 /*
18035 * This handles the process stack:
18036 */
18037 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18038 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18039 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18040 +out:
18041 put_cpu();
18042 }
18043 EXPORT_SYMBOL(dump_trace);
18044 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18045 {
18046 int i;
18047 unsigned long sp;
18048 - const int cpu = smp_processor_id();
18049 + const int cpu = raw_smp_processor_id();
18050 struct task_struct *cur = current;
18051
18052 sp = regs->sp;
18053 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18054
18055 return ud2 == 0x0b0f;
18056 }
18057 +
18058 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18059 +void pax_check_alloca(unsigned long size)
18060 +{
18061 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18062 + unsigned cpu, used;
18063 + char *id;
18064 +
18065 + /* check the process stack first */
18066 + stack_start = (unsigned long)task_stack_page(current);
18067 + stack_end = stack_start + THREAD_SIZE;
18068 + if (likely(stack_start <= sp && sp < stack_end)) {
18069 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18070 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18071 + return;
18072 + }
18073 +
18074 + cpu = get_cpu();
18075 +
18076 + /* check the irq stacks */
18077 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18078 + stack_start = stack_end - IRQ_STACK_SIZE;
18079 + if (stack_start <= sp && sp < stack_end) {
18080 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18081 + put_cpu();
18082 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18083 + return;
18084 + }
18085 +
18086 + /* check the exception stacks */
18087 + used = 0;
18088 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18089 + stack_start = stack_end - EXCEPTION_STKSZ;
18090 + if (stack_end && stack_start <= sp && sp < stack_end) {
18091 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18092 + put_cpu();
18093 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18094 + return;
18095 + }
18096 +
18097 + put_cpu();
18098 +
18099 + /* unknown stack */
18100 + BUG();
18101 +}
18102 +EXPORT_SYMBOL(pax_check_alloca);
18103 +#endif
18104 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18105 index 9b9f18b..9fcaa04 100644
18106 --- a/arch/x86/kernel/early_printk.c
18107 +++ b/arch/x86/kernel/early_printk.c
18108 @@ -7,6 +7,7 @@
18109 #include <linux/pci_regs.h>
18110 #include <linux/pci_ids.h>
18111 #include <linux/errno.h>
18112 +#include <linux/sched.h>
18113 #include <asm/io.h>
18114 #include <asm/processor.h>
18115 #include <asm/fcntl.h>
18116 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18117 index 6ed91d9..6cc365b 100644
18118 --- a/arch/x86/kernel/entry_32.S
18119 +++ b/arch/x86/kernel/entry_32.S
18120 @@ -177,13 +177,153 @@
18121 /*CFI_REL_OFFSET gs, PT_GS*/
18122 .endm
18123 .macro SET_KERNEL_GS reg
18124 +
18125 +#ifdef CONFIG_CC_STACKPROTECTOR
18126 movl $(__KERNEL_STACK_CANARY), \reg
18127 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18128 + movl $(__USER_DS), \reg
18129 +#else
18130 + xorl \reg, \reg
18131 +#endif
18132 +
18133 movl \reg, %gs
18134 .endm
18135
18136 #endif /* CONFIG_X86_32_LAZY_GS */
18137
18138 -.macro SAVE_ALL
18139 +.macro pax_enter_kernel
18140 +#ifdef CONFIG_PAX_KERNEXEC
18141 + call pax_enter_kernel
18142 +#endif
18143 +.endm
18144 +
18145 +.macro pax_exit_kernel
18146 +#ifdef CONFIG_PAX_KERNEXEC
18147 + call pax_exit_kernel
18148 +#endif
18149 +.endm
18150 +
18151 +#ifdef CONFIG_PAX_KERNEXEC
18152 +ENTRY(pax_enter_kernel)
18153 +#ifdef CONFIG_PARAVIRT
18154 + pushl %eax
18155 + pushl %ecx
18156 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18157 + mov %eax, %esi
18158 +#else
18159 + mov %cr0, %esi
18160 +#endif
18161 + bts $16, %esi
18162 + jnc 1f
18163 + mov %cs, %esi
18164 + cmp $__KERNEL_CS, %esi
18165 + jz 3f
18166 + ljmp $__KERNEL_CS, $3f
18167 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18168 +2:
18169 +#ifdef CONFIG_PARAVIRT
18170 + mov %esi, %eax
18171 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18172 +#else
18173 + mov %esi, %cr0
18174 +#endif
18175 +3:
18176 +#ifdef CONFIG_PARAVIRT
18177 + popl %ecx
18178 + popl %eax
18179 +#endif
18180 + ret
18181 +ENDPROC(pax_enter_kernel)
18182 +
18183 +ENTRY(pax_exit_kernel)
18184 +#ifdef CONFIG_PARAVIRT
18185 + pushl %eax
18186 + pushl %ecx
18187 +#endif
18188 + mov %cs, %esi
18189 + cmp $__KERNEXEC_KERNEL_CS, %esi
18190 + jnz 2f
18191 +#ifdef CONFIG_PARAVIRT
18192 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18193 + mov %eax, %esi
18194 +#else
18195 + mov %cr0, %esi
18196 +#endif
18197 + btr $16, %esi
18198 + ljmp $__KERNEL_CS, $1f
18199 +1:
18200 +#ifdef CONFIG_PARAVIRT
18201 + mov %esi, %eax
18202 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18203 +#else
18204 + mov %esi, %cr0
18205 +#endif
18206 +2:
18207 +#ifdef CONFIG_PARAVIRT
18208 + popl %ecx
18209 + popl %eax
18210 +#endif
18211 + ret
18212 +ENDPROC(pax_exit_kernel)
18213 +#endif
18214 +
18215 +.macro pax_erase_kstack
18216 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18217 + call pax_erase_kstack
18218 +#endif
18219 +.endm
18220 +
18221 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18222 +/*
18223 + * ebp: thread_info
18224 + */
18225 +ENTRY(pax_erase_kstack)
18226 + pushl %edi
18227 + pushl %ecx
18228 + pushl %eax
18229 +
18230 + mov TI_lowest_stack(%ebp), %edi
18231 + mov $-0xBEEF, %eax
18232 + std
18233 +
18234 +1: mov %edi, %ecx
18235 + and $THREAD_SIZE_asm - 1, %ecx
18236 + shr $2, %ecx
18237 + repne scasl
18238 + jecxz 2f
18239 +
18240 + cmp $2*16, %ecx
18241 + jc 2f
18242 +
18243 + mov $2*16, %ecx
18244 + repe scasl
18245 + jecxz 2f
18246 + jne 1b
18247 +
18248 +2: cld
18249 + mov %esp, %ecx
18250 + sub %edi, %ecx
18251 +
18252 + cmp $THREAD_SIZE_asm, %ecx
18253 + jb 3f
18254 + ud2
18255 +3:
18256 +
18257 + shr $2, %ecx
18258 + rep stosl
18259 +
18260 + mov TI_task_thread_sp0(%ebp), %edi
18261 + sub $128, %edi
18262 + mov %edi, TI_lowest_stack(%ebp)
18263 +
18264 + popl %eax
18265 + popl %ecx
18266 + popl %edi
18267 + ret
18268 +ENDPROC(pax_erase_kstack)
18269 +#endif
18270 +
18271 +.macro __SAVE_ALL _DS
18272 cld
18273 PUSH_GS
18274 pushl_cfi %fs
18275 @@ -206,7 +346,7 @@
18276 CFI_REL_OFFSET ecx, 0
18277 pushl_cfi %ebx
18278 CFI_REL_OFFSET ebx, 0
18279 - movl $(__USER_DS), %edx
18280 + movl $\_DS, %edx
18281 movl %edx, %ds
18282 movl %edx, %es
18283 movl $(__KERNEL_PERCPU), %edx
18284 @@ -214,6 +354,15 @@
18285 SET_KERNEL_GS %edx
18286 .endm
18287
18288 +.macro SAVE_ALL
18289 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18290 + __SAVE_ALL __KERNEL_DS
18291 + pax_enter_kernel
18292 +#else
18293 + __SAVE_ALL __USER_DS
18294 +#endif
18295 +.endm
18296 +
18297 .macro RESTORE_INT_REGS
18298 popl_cfi %ebx
18299 CFI_RESTORE ebx
18300 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18301 popfl_cfi
18302 jmp syscall_exit
18303 CFI_ENDPROC
18304 -END(ret_from_fork)
18305 +ENDPROC(ret_from_fork)
18306
18307 ENTRY(ret_from_kernel_thread)
18308 CFI_STARTPROC
18309 @@ -344,7 +493,15 @@ ret_from_intr:
18310 andl $SEGMENT_RPL_MASK, %eax
18311 #endif
18312 cmpl $USER_RPL, %eax
18313 +
18314 +#ifdef CONFIG_PAX_KERNEXEC
18315 + jae resume_userspace
18316 +
18317 + pax_exit_kernel
18318 + jmp resume_kernel
18319 +#else
18320 jb resume_kernel # not returning to v8086 or userspace
18321 +#endif
18322
18323 ENTRY(resume_userspace)
18324 LOCKDEP_SYS_EXIT
18325 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18326 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18327 # int/exception return?
18328 jne work_pending
18329 - jmp restore_all
18330 -END(ret_from_exception)
18331 + jmp restore_all_pax
18332 +ENDPROC(ret_from_exception)
18333
18334 #ifdef CONFIG_PREEMPT
18335 ENTRY(resume_kernel)
18336 @@ -372,7 +529,7 @@ need_resched:
18337 jz restore_all
18338 call preempt_schedule_irq
18339 jmp need_resched
18340 -END(resume_kernel)
18341 +ENDPROC(resume_kernel)
18342 #endif
18343 CFI_ENDPROC
18344 /*
18345 @@ -406,30 +563,45 @@ sysenter_past_esp:
18346 /*CFI_REL_OFFSET cs, 0*/
18347 /*
18348 * Push current_thread_info()->sysenter_return to the stack.
18349 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18350 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18351 */
18352 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18353 + pushl_cfi $0
18354 CFI_REL_OFFSET eip, 0
18355
18356 pushl_cfi %eax
18357 SAVE_ALL
18358 + GET_THREAD_INFO(%ebp)
18359 + movl TI_sysenter_return(%ebp),%ebp
18360 + movl %ebp,PT_EIP(%esp)
18361 ENABLE_INTERRUPTS(CLBR_NONE)
18362
18363 /*
18364 * Load the potential sixth argument from user stack.
18365 * Careful about security.
18366 */
18367 + movl PT_OLDESP(%esp),%ebp
18368 +
18369 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18370 + mov PT_OLDSS(%esp),%ds
18371 +1: movl %ds:(%ebp),%ebp
18372 + push %ss
18373 + pop %ds
18374 +#else
18375 cmpl $__PAGE_OFFSET-3,%ebp
18376 jae syscall_fault
18377 ASM_STAC
18378 1: movl (%ebp),%ebp
18379 ASM_CLAC
18380 +#endif
18381 +
18382 movl %ebp,PT_EBP(%esp)
18383 _ASM_EXTABLE(1b,syscall_fault)
18384
18385 GET_THREAD_INFO(%ebp)
18386
18387 +#ifdef CONFIG_PAX_RANDKSTACK
18388 + pax_erase_kstack
18389 +#endif
18390 +
18391 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18392 jnz sysenter_audit
18393 sysenter_do_call:
18394 @@ -444,12 +616,24 @@ sysenter_do_call:
18395 testl $_TIF_ALLWORK_MASK, %ecx
18396 jne sysexit_audit
18397 sysenter_exit:
18398 +
18399 +#ifdef CONFIG_PAX_RANDKSTACK
18400 + pushl_cfi %eax
18401 + movl %esp, %eax
18402 + call pax_randomize_kstack
18403 + popl_cfi %eax
18404 +#endif
18405 +
18406 + pax_erase_kstack
18407 +
18408 /* if something modifies registers it must also disable sysexit */
18409 movl PT_EIP(%esp), %edx
18410 movl PT_OLDESP(%esp), %ecx
18411 xorl %ebp,%ebp
18412 TRACE_IRQS_ON
18413 1: mov PT_FS(%esp), %fs
18414 +2: mov PT_DS(%esp), %ds
18415 +3: mov PT_ES(%esp), %es
18416 PTGS_TO_GS
18417 ENABLE_INTERRUPTS_SYSEXIT
18418
18419 @@ -466,6 +650,9 @@ sysenter_audit:
18420 movl %eax,%edx /* 2nd arg: syscall number */
18421 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18422 call __audit_syscall_entry
18423 +
18424 + pax_erase_kstack
18425 +
18426 pushl_cfi %ebx
18427 movl PT_EAX(%esp),%eax /* reload syscall number */
18428 jmp sysenter_do_call
18429 @@ -491,10 +678,16 @@ sysexit_audit:
18430
18431 CFI_ENDPROC
18432 .pushsection .fixup,"ax"
18433 -2: movl $0,PT_FS(%esp)
18434 +4: movl $0,PT_FS(%esp)
18435 + jmp 1b
18436 +5: movl $0,PT_DS(%esp)
18437 + jmp 1b
18438 +6: movl $0,PT_ES(%esp)
18439 jmp 1b
18440 .popsection
18441 - _ASM_EXTABLE(1b,2b)
18442 + _ASM_EXTABLE(1b,4b)
18443 + _ASM_EXTABLE(2b,5b)
18444 + _ASM_EXTABLE(3b,6b)
18445 PTGS_TO_GS_EX
18446 ENDPROC(ia32_sysenter_target)
18447
18448 @@ -509,6 +702,11 @@ ENTRY(system_call)
18449 pushl_cfi %eax # save orig_eax
18450 SAVE_ALL
18451 GET_THREAD_INFO(%ebp)
18452 +
18453 +#ifdef CONFIG_PAX_RANDKSTACK
18454 + pax_erase_kstack
18455 +#endif
18456 +
18457 # system call tracing in operation / emulation
18458 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18459 jnz syscall_trace_entry
18460 @@ -527,6 +725,15 @@ syscall_exit:
18461 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18462 jne syscall_exit_work
18463
18464 +restore_all_pax:
18465 +
18466 +#ifdef CONFIG_PAX_RANDKSTACK
18467 + movl %esp, %eax
18468 + call pax_randomize_kstack
18469 +#endif
18470 +
18471 + pax_erase_kstack
18472 +
18473 restore_all:
18474 TRACE_IRQS_IRET
18475 restore_all_notrace:
18476 @@ -583,14 +790,34 @@ ldt_ss:
18477 * compensating for the offset by changing to the ESPFIX segment with
18478 * a base address that matches for the difference.
18479 */
18480 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18481 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18482 mov %esp, %edx /* load kernel esp */
18483 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18484 mov %dx, %ax /* eax: new kernel esp */
18485 sub %eax, %edx /* offset (low word is 0) */
18486 +#ifdef CONFIG_SMP
18487 + movl PER_CPU_VAR(cpu_number), %ebx
18488 + shll $PAGE_SHIFT_asm, %ebx
18489 + addl $cpu_gdt_table, %ebx
18490 +#else
18491 + movl $cpu_gdt_table, %ebx
18492 +#endif
18493 shr $16, %edx
18494 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18495 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18496 +
18497 +#ifdef CONFIG_PAX_KERNEXEC
18498 + mov %cr0, %esi
18499 + btr $16, %esi
18500 + mov %esi, %cr0
18501 +#endif
18502 +
18503 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18504 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18505 +
18506 +#ifdef CONFIG_PAX_KERNEXEC
18507 + bts $16, %esi
18508 + mov %esi, %cr0
18509 +#endif
18510 +
18511 pushl_cfi $__ESPFIX_SS
18512 pushl_cfi %eax /* new kernel esp */
18513 /* Disable interrupts, but do not irqtrace this section: we
18514 @@ -619,20 +846,18 @@ work_resched:
18515 movl TI_flags(%ebp), %ecx
18516 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18517 # than syscall tracing?
18518 - jz restore_all
18519 + jz restore_all_pax
18520 testb $_TIF_NEED_RESCHED, %cl
18521 jnz work_resched
18522
18523 work_notifysig: # deal with pending signals and
18524 # notify-resume requests
18525 + movl %esp, %eax
18526 #ifdef CONFIG_VM86
18527 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18528 - movl %esp, %eax
18529 jne work_notifysig_v86 # returning to kernel-space or
18530 # vm86-space
18531 1:
18532 -#else
18533 - movl %esp, %eax
18534 #endif
18535 TRACE_IRQS_ON
18536 ENABLE_INTERRUPTS(CLBR_NONE)
18537 @@ -653,7 +878,7 @@ work_notifysig_v86:
18538 movl %eax, %esp
18539 jmp 1b
18540 #endif
18541 -END(work_pending)
18542 +ENDPROC(work_pending)
18543
18544 # perform syscall exit tracing
18545 ALIGN
18546 @@ -661,11 +886,14 @@ syscall_trace_entry:
18547 movl $-ENOSYS,PT_EAX(%esp)
18548 movl %esp, %eax
18549 call syscall_trace_enter
18550 +
18551 + pax_erase_kstack
18552 +
18553 /* What it returned is what we'll actually use. */
18554 cmpl $(NR_syscalls), %eax
18555 jnae syscall_call
18556 jmp syscall_exit
18557 -END(syscall_trace_entry)
18558 +ENDPROC(syscall_trace_entry)
18559
18560 # perform syscall exit tracing
18561 ALIGN
18562 @@ -678,21 +906,25 @@ syscall_exit_work:
18563 movl %esp, %eax
18564 call syscall_trace_leave
18565 jmp resume_userspace
18566 -END(syscall_exit_work)
18567 +ENDPROC(syscall_exit_work)
18568 CFI_ENDPROC
18569
18570 RING0_INT_FRAME # can't unwind into user space anyway
18571 syscall_fault:
18572 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18573 + push %ss
18574 + pop %ds
18575 +#endif
18576 ASM_CLAC
18577 GET_THREAD_INFO(%ebp)
18578 movl $-EFAULT,PT_EAX(%esp)
18579 jmp resume_userspace
18580 -END(syscall_fault)
18581 +ENDPROC(syscall_fault)
18582
18583 syscall_badsys:
18584 movl $-ENOSYS,PT_EAX(%esp)
18585 jmp resume_userspace
18586 -END(syscall_badsys)
18587 +ENDPROC(syscall_badsys)
18588 CFI_ENDPROC
18589 /*
18590 * End of kprobes section
18591 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
18592 * normal stack and adjusts ESP with the matching offset.
18593 */
18594 /* fixup the stack */
18595 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18596 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18597 +#ifdef CONFIG_SMP
18598 + movl PER_CPU_VAR(cpu_number), %ebx
18599 + shll $PAGE_SHIFT_asm, %ebx
18600 + addl $cpu_gdt_table, %ebx
18601 +#else
18602 + movl $cpu_gdt_table, %ebx
18603 +#endif
18604 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18605 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18606 shl $16, %eax
18607 addl %esp, %eax /* the adjusted stack pointer */
18608 pushl_cfi $__KERNEL_DS
18609 @@ -807,7 +1046,7 @@ vector=vector+1
18610 .endr
18611 2: jmp common_interrupt
18612 .endr
18613 -END(irq_entries_start)
18614 +ENDPROC(irq_entries_start)
18615
18616 .previous
18617 END(interrupt)
18618 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
18619 pushl_cfi $do_coprocessor_error
18620 jmp error_code
18621 CFI_ENDPROC
18622 -END(coprocessor_error)
18623 +ENDPROC(coprocessor_error)
18624
18625 ENTRY(simd_coprocessor_error)
18626 RING0_INT_FRAME
18627 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
18628 #endif
18629 jmp error_code
18630 CFI_ENDPROC
18631 -END(simd_coprocessor_error)
18632 +ENDPROC(simd_coprocessor_error)
18633
18634 ENTRY(device_not_available)
18635 RING0_INT_FRAME
18636 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
18637 pushl_cfi $do_device_not_available
18638 jmp error_code
18639 CFI_ENDPROC
18640 -END(device_not_available)
18641 +ENDPROC(device_not_available)
18642
18643 #ifdef CONFIG_PARAVIRT
18644 ENTRY(native_iret)
18645 iret
18646 _ASM_EXTABLE(native_iret, iret_exc)
18647 -END(native_iret)
18648 +ENDPROC(native_iret)
18649
18650 ENTRY(native_irq_enable_sysexit)
18651 sti
18652 sysexit
18653 -END(native_irq_enable_sysexit)
18654 +ENDPROC(native_irq_enable_sysexit)
18655 #endif
18656
18657 ENTRY(overflow)
18658 @@ -910,7 +1149,7 @@ ENTRY(overflow)
18659 pushl_cfi $do_overflow
18660 jmp error_code
18661 CFI_ENDPROC
18662 -END(overflow)
18663 +ENDPROC(overflow)
18664
18665 ENTRY(bounds)
18666 RING0_INT_FRAME
18667 @@ -919,7 +1158,7 @@ ENTRY(bounds)
18668 pushl_cfi $do_bounds
18669 jmp error_code
18670 CFI_ENDPROC
18671 -END(bounds)
18672 +ENDPROC(bounds)
18673
18674 ENTRY(invalid_op)
18675 RING0_INT_FRAME
18676 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
18677 pushl_cfi $do_invalid_op
18678 jmp error_code
18679 CFI_ENDPROC
18680 -END(invalid_op)
18681 +ENDPROC(invalid_op)
18682
18683 ENTRY(coprocessor_segment_overrun)
18684 RING0_INT_FRAME
18685 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
18686 pushl_cfi $do_coprocessor_segment_overrun
18687 jmp error_code
18688 CFI_ENDPROC
18689 -END(coprocessor_segment_overrun)
18690 +ENDPROC(coprocessor_segment_overrun)
18691
18692 ENTRY(invalid_TSS)
18693 RING0_EC_FRAME
18694 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
18695 pushl_cfi $do_invalid_TSS
18696 jmp error_code
18697 CFI_ENDPROC
18698 -END(invalid_TSS)
18699 +ENDPROC(invalid_TSS)
18700
18701 ENTRY(segment_not_present)
18702 RING0_EC_FRAME
18703 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
18704 pushl_cfi $do_segment_not_present
18705 jmp error_code
18706 CFI_ENDPROC
18707 -END(segment_not_present)
18708 +ENDPROC(segment_not_present)
18709
18710 ENTRY(stack_segment)
18711 RING0_EC_FRAME
18712 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
18713 pushl_cfi $do_stack_segment
18714 jmp error_code
18715 CFI_ENDPROC
18716 -END(stack_segment)
18717 +ENDPROC(stack_segment)
18718
18719 ENTRY(alignment_check)
18720 RING0_EC_FRAME
18721 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
18722 pushl_cfi $do_alignment_check
18723 jmp error_code
18724 CFI_ENDPROC
18725 -END(alignment_check)
18726 +ENDPROC(alignment_check)
18727
18728 ENTRY(divide_error)
18729 RING0_INT_FRAME
18730 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
18731 pushl_cfi $do_divide_error
18732 jmp error_code
18733 CFI_ENDPROC
18734 -END(divide_error)
18735 +ENDPROC(divide_error)
18736
18737 #ifdef CONFIG_X86_MCE
18738 ENTRY(machine_check)
18739 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
18740 pushl_cfi machine_check_vector
18741 jmp error_code
18742 CFI_ENDPROC
18743 -END(machine_check)
18744 +ENDPROC(machine_check)
18745 #endif
18746
18747 ENTRY(spurious_interrupt_bug)
18748 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
18749 pushl_cfi $do_spurious_interrupt_bug
18750 jmp error_code
18751 CFI_ENDPROC
18752 -END(spurious_interrupt_bug)
18753 +ENDPROC(spurious_interrupt_bug)
18754 /*
18755 * End of kprobes section
18756 */
18757 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
18758
18759 ENTRY(mcount)
18760 ret
18761 -END(mcount)
18762 +ENDPROC(mcount)
18763
18764 ENTRY(ftrace_caller)
18765 cmpl $0, function_trace_stop
18766 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
18767 .globl ftrace_stub
18768 ftrace_stub:
18769 ret
18770 -END(ftrace_caller)
18771 +ENDPROC(ftrace_caller)
18772
18773 ENTRY(ftrace_regs_caller)
18774 pushf /* push flags before compare (in cs location) */
18775 @@ -1235,7 +1474,7 @@ trace:
18776 popl %ecx
18777 popl %eax
18778 jmp ftrace_stub
18779 -END(mcount)
18780 +ENDPROC(mcount)
18781 #endif /* CONFIG_DYNAMIC_FTRACE */
18782 #endif /* CONFIG_FUNCTION_TRACER */
18783
18784 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
18785 popl %ecx
18786 popl %eax
18787 ret
18788 -END(ftrace_graph_caller)
18789 +ENDPROC(ftrace_graph_caller)
18790
18791 .globl return_to_handler
18792 return_to_handler:
18793 @@ -1309,15 +1548,18 @@ error_code:
18794 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18795 REG_TO_PTGS %ecx
18796 SET_KERNEL_GS %ecx
18797 - movl $(__USER_DS), %ecx
18798 + movl $(__KERNEL_DS), %ecx
18799 movl %ecx, %ds
18800 movl %ecx, %es
18801 +
18802 + pax_enter_kernel
18803 +
18804 TRACE_IRQS_OFF
18805 movl %esp,%eax # pt_regs pointer
18806 call *%edi
18807 jmp ret_from_exception
18808 CFI_ENDPROC
18809 -END(page_fault)
18810 +ENDPROC(page_fault)
18811
18812 /*
18813 * Debug traps and NMI can happen at the one SYSENTER instruction
18814 @@ -1360,7 +1602,7 @@ debug_stack_correct:
18815 call do_debug
18816 jmp ret_from_exception
18817 CFI_ENDPROC
18818 -END(debug)
18819 +ENDPROC(debug)
18820
18821 /*
18822 * NMI is doubly nasty. It can happen _while_ we're handling
18823 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
18824 xorl %edx,%edx # zero error code
18825 movl %esp,%eax # pt_regs pointer
18826 call do_nmi
18827 +
18828 + pax_exit_kernel
18829 +
18830 jmp restore_all_notrace
18831 CFI_ENDPROC
18832
18833 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
18834 FIXUP_ESPFIX_STACK # %eax == %esp
18835 xorl %edx,%edx # zero error code
18836 call do_nmi
18837 +
18838 + pax_exit_kernel
18839 +
18840 RESTORE_REGS
18841 lss 12+4(%esp), %esp # back to espfix stack
18842 CFI_ADJUST_CFA_OFFSET -24
18843 jmp irq_return
18844 CFI_ENDPROC
18845 -END(nmi)
18846 +ENDPROC(nmi)
18847
18848 ENTRY(int3)
18849 RING0_INT_FRAME
18850 @@ -1452,14 +1700,14 @@ ENTRY(int3)
18851 call do_int3
18852 jmp ret_from_exception
18853 CFI_ENDPROC
18854 -END(int3)
18855 +ENDPROC(int3)
18856
18857 ENTRY(general_protection)
18858 RING0_EC_FRAME
18859 pushl_cfi $do_general_protection
18860 jmp error_code
18861 CFI_ENDPROC
18862 -END(general_protection)
18863 +ENDPROC(general_protection)
18864
18865 #ifdef CONFIG_KVM_GUEST
18866 ENTRY(async_page_fault)
18867 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
18868 pushl_cfi $do_async_page_fault
18869 jmp error_code
18870 CFI_ENDPROC
18871 -END(async_page_fault)
18872 +ENDPROC(async_page_fault)
18873 #endif
18874
18875 /*
18876 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18877 index cb3c591..bc63707 100644
18878 --- a/arch/x86/kernel/entry_64.S
18879 +++ b/arch/x86/kernel/entry_64.S
18880 @@ -59,6 +59,8 @@
18881 #include <asm/context_tracking.h>
18882 #include <asm/smap.h>
18883 #include <linux/err.h>
18884 +#include <asm/pgtable.h>
18885 +#include <asm/alternative-asm.h>
18886
18887 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18888 #include <linux/elf-em.h>
18889 @@ -80,8 +82,9 @@
18890 #ifdef CONFIG_DYNAMIC_FTRACE
18891
18892 ENTRY(function_hook)
18893 + pax_force_retaddr
18894 retq
18895 -END(function_hook)
18896 +ENDPROC(function_hook)
18897
18898 /* skip is set if stack has been adjusted */
18899 .macro ftrace_caller_setup skip=0
18900 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18901 #endif
18902
18903 GLOBAL(ftrace_stub)
18904 + pax_force_retaddr
18905 retq
18906 -END(ftrace_caller)
18907 +ENDPROC(ftrace_caller)
18908
18909 ENTRY(ftrace_regs_caller)
18910 /* Save the current flags before compare (in SS location)*/
18911 @@ -191,7 +195,7 @@ ftrace_restore_flags:
18912 popfq
18913 jmp ftrace_stub
18914
18915 -END(ftrace_regs_caller)
18916 +ENDPROC(ftrace_regs_caller)
18917
18918
18919 #else /* ! CONFIG_DYNAMIC_FTRACE */
18920 @@ -212,6 +216,7 @@ ENTRY(function_hook)
18921 #endif
18922
18923 GLOBAL(ftrace_stub)
18924 + pax_force_retaddr
18925 retq
18926
18927 trace:
18928 @@ -225,12 +230,13 @@ trace:
18929 #endif
18930 subq $MCOUNT_INSN_SIZE, %rdi
18931
18932 + pax_force_fptr ftrace_trace_function
18933 call *ftrace_trace_function
18934
18935 MCOUNT_RESTORE_FRAME
18936
18937 jmp ftrace_stub
18938 -END(function_hook)
18939 +ENDPROC(function_hook)
18940 #endif /* CONFIG_DYNAMIC_FTRACE */
18941 #endif /* CONFIG_FUNCTION_TRACER */
18942
18943 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
18944
18945 MCOUNT_RESTORE_FRAME
18946
18947 + pax_force_retaddr
18948 retq
18949 -END(ftrace_graph_caller)
18950 +ENDPROC(ftrace_graph_caller)
18951
18952 GLOBAL(return_to_handler)
18953 subq $24, %rsp
18954 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
18955 movq 8(%rsp), %rdx
18956 movq (%rsp), %rax
18957 addq $24, %rsp
18958 + pax_force_fptr %rdi
18959 jmp *%rdi
18960 +ENDPROC(return_to_handler)
18961 #endif
18962
18963
18964 @@ -284,6 +293,273 @@ ENTRY(native_usergs_sysret64)
18965 ENDPROC(native_usergs_sysret64)
18966 #endif /* CONFIG_PARAVIRT */
18967
18968 + .macro ljmpq sel, off
18969 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
18970 + .byte 0x48; ljmp *1234f(%rip)
18971 + .pushsection .rodata
18972 + .align 16
18973 + 1234: .quad \off; .word \sel
18974 + .popsection
18975 +#else
18976 + pushq $\sel
18977 + pushq $\off
18978 + lretq
18979 +#endif
18980 + .endm
18981 +
18982 + .macro pax_enter_kernel
18983 + pax_set_fptr_mask
18984 +#ifdef CONFIG_PAX_KERNEXEC
18985 + call pax_enter_kernel
18986 +#endif
18987 + .endm
18988 +
18989 + .macro pax_exit_kernel
18990 +#ifdef CONFIG_PAX_KERNEXEC
18991 + call pax_exit_kernel
18992 +#endif
18993 + .endm
18994 +
18995 +#ifdef CONFIG_PAX_KERNEXEC
18996 +ENTRY(pax_enter_kernel)
18997 + pushq %rdi
18998 +
18999 +#ifdef CONFIG_PARAVIRT
19000 + PV_SAVE_REGS(CLBR_RDI)
19001 +#endif
19002 +
19003 + GET_CR0_INTO_RDI
19004 + bts $16,%rdi
19005 + jnc 3f
19006 + mov %cs,%edi
19007 + cmp $__KERNEL_CS,%edi
19008 + jnz 2f
19009 +1:
19010 +
19011 +#ifdef CONFIG_PARAVIRT
19012 + PV_RESTORE_REGS(CLBR_RDI)
19013 +#endif
19014 +
19015 + popq %rdi
19016 + pax_force_retaddr
19017 + retq
19018 +
19019 +2: ljmpq __KERNEL_CS,1f
19020 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19021 +4: SET_RDI_INTO_CR0
19022 + jmp 1b
19023 +ENDPROC(pax_enter_kernel)
19024 +
19025 +ENTRY(pax_exit_kernel)
19026 + pushq %rdi
19027 +
19028 +#ifdef CONFIG_PARAVIRT
19029 + PV_SAVE_REGS(CLBR_RDI)
19030 +#endif
19031 +
19032 + mov %cs,%rdi
19033 + cmp $__KERNEXEC_KERNEL_CS,%edi
19034 + jz 2f
19035 +1:
19036 +
19037 +#ifdef CONFIG_PARAVIRT
19038 + PV_RESTORE_REGS(CLBR_RDI);
19039 +#endif
19040 +
19041 + popq %rdi
19042 + pax_force_retaddr
19043 + retq
19044 +
19045 +2: GET_CR0_INTO_RDI
19046 + btr $16,%rdi
19047 + ljmpq __KERNEL_CS,3f
19048 +3: SET_RDI_INTO_CR0
19049 + jmp 1b
19050 +ENDPROC(pax_exit_kernel)
19051 +#endif
19052 +
19053 + .macro pax_enter_kernel_user
19054 + pax_set_fptr_mask
19055 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19056 + call pax_enter_kernel_user
19057 +#endif
19058 + .endm
19059 +
19060 + .macro pax_exit_kernel_user
19061 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19062 + call pax_exit_kernel_user
19063 +#endif
19064 +#ifdef CONFIG_PAX_RANDKSTACK
19065 + pushq %rax
19066 + call pax_randomize_kstack
19067 + popq %rax
19068 +#endif
19069 + .endm
19070 +
19071 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19072 +ENTRY(pax_enter_kernel_user)
19073 + pushq %rdi
19074 + pushq %rbx
19075 +
19076 +#ifdef CONFIG_PARAVIRT
19077 + PV_SAVE_REGS(CLBR_RDI)
19078 +#endif
19079 +
19080 + GET_CR3_INTO_RDI
19081 + mov %rdi,%rbx
19082 + add $__START_KERNEL_map,%rbx
19083 + sub phys_base(%rip),%rbx
19084 +
19085 +#ifdef CONFIG_PARAVIRT
19086 + pushq %rdi
19087 + cmpl $0, pv_info+PARAVIRT_enabled
19088 + jz 1f
19089 + i = 0
19090 + .rept USER_PGD_PTRS
19091 + mov i*8(%rbx),%rsi
19092 + mov $0,%sil
19093 + lea i*8(%rbx),%rdi
19094 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19095 + i = i + 1
19096 + .endr
19097 + jmp 2f
19098 +1:
19099 +#endif
19100 +
19101 + i = 0
19102 + .rept USER_PGD_PTRS
19103 + movb $0,i*8(%rbx)
19104 + i = i + 1
19105 + .endr
19106 +
19107 +#ifdef CONFIG_PARAVIRT
19108 +2: popq %rdi
19109 +#endif
19110 + SET_RDI_INTO_CR3
19111 +
19112 +#ifdef CONFIG_PAX_KERNEXEC
19113 + GET_CR0_INTO_RDI
19114 + bts $16,%rdi
19115 + SET_RDI_INTO_CR0
19116 +#endif
19117 +
19118 +#ifdef CONFIG_PARAVIRT
19119 + PV_RESTORE_REGS(CLBR_RDI)
19120 +#endif
19121 +
19122 + popq %rbx
19123 + popq %rdi
19124 + pax_force_retaddr
19125 + retq
19126 +ENDPROC(pax_enter_kernel_user)
19127 +
19128 +ENTRY(pax_exit_kernel_user)
19129 + push %rdi
19130 +
19131 +#ifdef CONFIG_PARAVIRT
19132 + pushq %rbx
19133 + PV_SAVE_REGS(CLBR_RDI)
19134 +#endif
19135 +
19136 +#ifdef CONFIG_PAX_KERNEXEC
19137 + GET_CR0_INTO_RDI
19138 + btr $16,%rdi
19139 + SET_RDI_INTO_CR0
19140 +#endif
19141 +
19142 + GET_CR3_INTO_RDI
19143 + add $__START_KERNEL_map,%rdi
19144 + sub phys_base(%rip),%rdi
19145 +
19146 +#ifdef CONFIG_PARAVIRT
19147 + cmpl $0, pv_info+PARAVIRT_enabled
19148 + jz 1f
19149 + mov %rdi,%rbx
19150 + i = 0
19151 + .rept USER_PGD_PTRS
19152 + mov i*8(%rbx),%rsi
19153 + mov $0x67,%sil
19154 + lea i*8(%rbx),%rdi
19155 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19156 + i = i + 1
19157 + .endr
19158 + jmp 2f
19159 +1:
19160 +#endif
19161 +
19162 + i = 0
19163 + .rept USER_PGD_PTRS
19164 + movb $0x67,i*8(%rdi)
19165 + i = i + 1
19166 + .endr
19167 +
19168 +#ifdef CONFIG_PARAVIRT
19169 +2: PV_RESTORE_REGS(CLBR_RDI)
19170 + popq %rbx
19171 +#endif
19172 +
19173 + popq %rdi
19174 + pax_force_retaddr
19175 + retq
19176 +ENDPROC(pax_exit_kernel_user)
19177 +#endif
19178 +
19179 +.macro pax_erase_kstack
19180 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19181 + call pax_erase_kstack
19182 +#endif
19183 +.endm
19184 +
19185 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19186 +ENTRY(pax_erase_kstack)
19187 + pushq %rdi
19188 + pushq %rcx
19189 + pushq %rax
19190 + pushq %r11
19191 +
19192 + GET_THREAD_INFO(%r11)
19193 + mov TI_lowest_stack(%r11), %rdi
19194 + mov $-0xBEEF, %rax
19195 + std
19196 +
19197 +1: mov %edi, %ecx
19198 + and $THREAD_SIZE_asm - 1, %ecx
19199 + shr $3, %ecx
19200 + repne scasq
19201 + jecxz 2f
19202 +
19203 + cmp $2*8, %ecx
19204 + jc 2f
19205 +
19206 + mov $2*8, %ecx
19207 + repe scasq
19208 + jecxz 2f
19209 + jne 1b
19210 +
19211 +2: cld
19212 + mov %esp, %ecx
19213 + sub %edi, %ecx
19214 +
19215 + cmp $THREAD_SIZE_asm, %rcx
19216 + jb 3f
19217 + ud2
19218 +3:
19219 +
19220 + shr $3, %ecx
19221 + rep stosq
19222 +
19223 + mov TI_task_thread_sp0(%r11), %rdi
19224 + sub $256, %rdi
19225 + mov %rdi, TI_lowest_stack(%r11)
19226 +
19227 + popq %r11
19228 + popq %rax
19229 + popq %rcx
19230 + popq %rdi
19231 + pax_force_retaddr
19232 + ret
19233 +ENDPROC(pax_erase_kstack)
19234 +#endif
19235
19236 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19237 #ifdef CONFIG_TRACE_IRQFLAGS
19238 @@ -375,8 +651,8 @@ ENDPROC(native_usergs_sysret64)
19239 .endm
19240
19241 .macro UNFAKE_STACK_FRAME
19242 - addq $8*6, %rsp
19243 - CFI_ADJUST_CFA_OFFSET -(6*8)
19244 + addq $8*6 + ARG_SKIP, %rsp
19245 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19246 .endm
19247
19248 /*
19249 @@ -463,7 +739,7 @@ ENDPROC(native_usergs_sysret64)
19250 movq %rsp, %rsi
19251
19252 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19253 - testl $3, CS-RBP(%rsi)
19254 + testb $3, CS-RBP(%rsi)
19255 je 1f
19256 SWAPGS
19257 /*
19258 @@ -498,9 +774,10 @@ ENTRY(save_rest)
19259 movq_cfi r15, R15+16
19260 movq %r11, 8(%rsp) /* return address */
19261 FIXUP_TOP_OF_STACK %r11, 16
19262 + pax_force_retaddr
19263 ret
19264 CFI_ENDPROC
19265 -END(save_rest)
19266 +ENDPROC(save_rest)
19267
19268 /* save complete stack frame */
19269 .pushsection .kprobes.text, "ax"
19270 @@ -529,9 +806,10 @@ ENTRY(save_paranoid)
19271 js 1f /* negative -> in kernel */
19272 SWAPGS
19273 xorl %ebx,%ebx
19274 -1: ret
19275 +1: pax_force_retaddr_bts
19276 + ret
19277 CFI_ENDPROC
19278 -END(save_paranoid)
19279 +ENDPROC(save_paranoid)
19280 .popsection
19281
19282 /*
19283 @@ -553,7 +831,7 @@ ENTRY(ret_from_fork)
19284
19285 RESTORE_REST
19286
19287 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19288 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19289 jz 1f
19290
19291 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19292 @@ -571,7 +849,7 @@ ENTRY(ret_from_fork)
19293 RESTORE_REST
19294 jmp int_ret_from_sys_call
19295 CFI_ENDPROC
19296 -END(ret_from_fork)
19297 +ENDPROC(ret_from_fork)
19298
19299 /*
19300 * System call entry. Up to 6 arguments in registers are supported.
19301 @@ -608,7 +886,7 @@ END(ret_from_fork)
19302 ENTRY(system_call)
19303 CFI_STARTPROC simple
19304 CFI_SIGNAL_FRAME
19305 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19306 + CFI_DEF_CFA rsp,0
19307 CFI_REGISTER rip,rcx
19308 /*CFI_REGISTER rflags,r11*/
19309 SWAPGS_UNSAFE_STACK
19310 @@ -621,16 +899,23 @@ GLOBAL(system_call_after_swapgs)
19311
19312 movq %rsp,PER_CPU_VAR(old_rsp)
19313 movq PER_CPU_VAR(kernel_stack),%rsp
19314 + SAVE_ARGS 8*6,0
19315 + pax_enter_kernel_user
19316 +
19317 +#ifdef CONFIG_PAX_RANDKSTACK
19318 + pax_erase_kstack
19319 +#endif
19320 +
19321 /*
19322 * No need to follow this irqs off/on section - it's straight
19323 * and short:
19324 */
19325 ENABLE_INTERRUPTS(CLBR_NONE)
19326 - SAVE_ARGS 8,0
19327 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19328 movq %rcx,RIP-ARGOFFSET(%rsp)
19329 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19330 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19331 + GET_THREAD_INFO(%rcx)
19332 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19333 jnz tracesys
19334 system_call_fastpath:
19335 #if __SYSCALL_MASK == ~0
19336 @@ -640,7 +925,7 @@ system_call_fastpath:
19337 cmpl $__NR_syscall_max,%eax
19338 #endif
19339 ja badsys
19340 - movq %r10,%rcx
19341 + movq R10-ARGOFFSET(%rsp),%rcx
19342 call *sys_call_table(,%rax,8) # XXX: rip relative
19343 movq %rax,RAX-ARGOFFSET(%rsp)
19344 /*
19345 @@ -654,10 +939,13 @@ sysret_check:
19346 LOCKDEP_SYS_EXIT
19347 DISABLE_INTERRUPTS(CLBR_NONE)
19348 TRACE_IRQS_OFF
19349 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19350 + GET_THREAD_INFO(%rcx)
19351 + movl TI_flags(%rcx),%edx
19352 andl %edi,%edx
19353 jnz sysret_careful
19354 CFI_REMEMBER_STATE
19355 + pax_exit_kernel_user
19356 + pax_erase_kstack
19357 /*
19358 * sysretq will re-enable interrupts:
19359 */
19360 @@ -709,14 +997,18 @@ badsys:
19361 * jump back to the normal fast path.
19362 */
19363 auditsys:
19364 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19365 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19366 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19367 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19368 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19369 movq %rax,%rsi /* 2nd arg: syscall number */
19370 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19371 call __audit_syscall_entry
19372 +
19373 + pax_erase_kstack
19374 +
19375 LOAD_ARGS 0 /* reload call-clobbered registers */
19376 + pax_set_fptr_mask
19377 jmp system_call_fastpath
19378
19379 /*
19380 @@ -737,7 +1029,7 @@ sysret_audit:
19381 /* Do syscall tracing */
19382 tracesys:
19383 #ifdef CONFIG_AUDITSYSCALL
19384 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19385 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19386 jz auditsys
19387 #endif
19388 SAVE_REST
19389 @@ -745,12 +1037,16 @@ tracesys:
19390 FIXUP_TOP_OF_STACK %rdi
19391 movq %rsp,%rdi
19392 call syscall_trace_enter
19393 +
19394 + pax_erase_kstack
19395 +
19396 /*
19397 * Reload arg registers from stack in case ptrace changed them.
19398 * We don't reload %rax because syscall_trace_enter() returned
19399 * the value it wants us to use in the table lookup.
19400 */
19401 LOAD_ARGS ARGOFFSET, 1
19402 + pax_set_fptr_mask
19403 RESTORE_REST
19404 #if __SYSCALL_MASK == ~0
19405 cmpq $__NR_syscall_max,%rax
19406 @@ -759,7 +1055,7 @@ tracesys:
19407 cmpl $__NR_syscall_max,%eax
19408 #endif
19409 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19410 - movq %r10,%rcx /* fixup for C */
19411 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19412 call *sys_call_table(,%rax,8)
19413 movq %rax,RAX-ARGOFFSET(%rsp)
19414 /* Use IRET because user could have changed frame */
19415 @@ -780,7 +1076,9 @@ GLOBAL(int_with_check)
19416 andl %edi,%edx
19417 jnz int_careful
19418 andl $~TS_COMPAT,TI_status(%rcx)
19419 - jmp retint_swapgs
19420 + pax_exit_kernel_user
19421 + pax_erase_kstack
19422 + jmp retint_swapgs_pax
19423
19424 /* Either reschedule or signal or syscall exit tracking needed. */
19425 /* First do a reschedule test. */
19426 @@ -826,7 +1124,7 @@ int_restore_rest:
19427 TRACE_IRQS_OFF
19428 jmp int_with_check
19429 CFI_ENDPROC
19430 -END(system_call)
19431 +ENDPROC(system_call)
19432
19433 /*
19434 * Certain special system calls that need to save a complete full stack frame.
19435 @@ -842,7 +1140,7 @@ ENTRY(\label)
19436 call \func
19437 jmp ptregscall_common
19438 CFI_ENDPROC
19439 -END(\label)
19440 +ENDPROC(\label)
19441 .endm
19442
19443 .macro FORK_LIKE func
19444 @@ -856,9 +1154,10 @@ ENTRY(stub_\func)
19445 DEFAULT_FRAME 0 8 /* offset 8: return address */
19446 call sys_\func
19447 RESTORE_TOP_OF_STACK %r11, 8
19448 + pax_force_retaddr
19449 ret $REST_SKIP /* pop extended registers */
19450 CFI_ENDPROC
19451 -END(stub_\func)
19452 +ENDPROC(stub_\func)
19453 .endm
19454
19455 FORK_LIKE clone
19456 @@ -875,9 +1174,10 @@ ENTRY(ptregscall_common)
19457 movq_cfi_restore R12+8, r12
19458 movq_cfi_restore RBP+8, rbp
19459 movq_cfi_restore RBX+8, rbx
19460 + pax_force_retaddr
19461 ret $REST_SKIP /* pop extended registers */
19462 CFI_ENDPROC
19463 -END(ptregscall_common)
19464 +ENDPROC(ptregscall_common)
19465
19466 ENTRY(stub_execve)
19467 CFI_STARTPROC
19468 @@ -891,7 +1191,7 @@ ENTRY(stub_execve)
19469 RESTORE_REST
19470 jmp int_ret_from_sys_call
19471 CFI_ENDPROC
19472 -END(stub_execve)
19473 +ENDPROC(stub_execve)
19474
19475 /*
19476 * sigreturn is special because it needs to restore all registers on return.
19477 @@ -909,7 +1209,7 @@ ENTRY(stub_rt_sigreturn)
19478 RESTORE_REST
19479 jmp int_ret_from_sys_call
19480 CFI_ENDPROC
19481 -END(stub_rt_sigreturn)
19482 +ENDPROC(stub_rt_sigreturn)
19483
19484 #ifdef CONFIG_X86_X32_ABI
19485 ENTRY(stub_x32_rt_sigreturn)
19486 @@ -975,7 +1275,7 @@ vector=vector+1
19487 2: jmp common_interrupt
19488 .endr
19489 CFI_ENDPROC
19490 -END(irq_entries_start)
19491 +ENDPROC(irq_entries_start)
19492
19493 .previous
19494 END(interrupt)
19495 @@ -995,6 +1295,16 @@ END(interrupt)
19496 subq $ORIG_RAX-RBP, %rsp
19497 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19498 SAVE_ARGS_IRQ
19499 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19500 + testb $3, CS(%rdi)
19501 + jnz 1f
19502 + pax_enter_kernel
19503 + jmp 2f
19504 +1: pax_enter_kernel_user
19505 +2:
19506 +#else
19507 + pax_enter_kernel
19508 +#endif
19509 call \func
19510 .endm
19511
19512 @@ -1027,7 +1337,7 @@ ret_from_intr:
19513
19514 exit_intr:
19515 GET_THREAD_INFO(%rcx)
19516 - testl $3,CS-ARGOFFSET(%rsp)
19517 + testb $3,CS-ARGOFFSET(%rsp)
19518 je retint_kernel
19519
19520 /* Interrupt came from user space */
19521 @@ -1049,12 +1359,16 @@ retint_swapgs: /* return to user-space */
19522 * The iretq could re-enable interrupts:
19523 */
19524 DISABLE_INTERRUPTS(CLBR_ANY)
19525 + pax_exit_kernel_user
19526 +retint_swapgs_pax:
19527 TRACE_IRQS_IRETQ
19528 SWAPGS
19529 jmp restore_args
19530
19531 retint_restore_args: /* return to kernel space */
19532 DISABLE_INTERRUPTS(CLBR_ANY)
19533 + pax_exit_kernel
19534 + pax_force_retaddr (RIP-ARGOFFSET)
19535 /*
19536 * The iretq could re-enable interrupts:
19537 */
19538 @@ -1137,7 +1451,7 @@ ENTRY(retint_kernel)
19539 #endif
19540
19541 CFI_ENDPROC
19542 -END(common_interrupt)
19543 +ENDPROC(common_interrupt)
19544 /*
19545 * End of kprobes section
19546 */
19547 @@ -1155,7 +1469,7 @@ ENTRY(\sym)
19548 interrupt \do_sym
19549 jmp ret_from_intr
19550 CFI_ENDPROC
19551 -END(\sym)
19552 +ENDPROC(\sym)
19553 .endm
19554
19555 #ifdef CONFIG_SMP
19556 @@ -1211,12 +1525,22 @@ ENTRY(\sym)
19557 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19558 call error_entry
19559 DEFAULT_FRAME 0
19560 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19561 + testb $3, CS(%rsp)
19562 + jnz 1f
19563 + pax_enter_kernel
19564 + jmp 2f
19565 +1: pax_enter_kernel_user
19566 +2:
19567 +#else
19568 + pax_enter_kernel
19569 +#endif
19570 movq %rsp,%rdi /* pt_regs pointer */
19571 xorl %esi,%esi /* no error code */
19572 call \do_sym
19573 jmp error_exit /* %ebx: no swapgs flag */
19574 CFI_ENDPROC
19575 -END(\sym)
19576 +ENDPROC(\sym)
19577 .endm
19578
19579 .macro paranoidzeroentry sym do_sym
19580 @@ -1229,15 +1553,25 @@ ENTRY(\sym)
19581 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19582 call save_paranoid
19583 TRACE_IRQS_OFF
19584 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19585 + testb $3, CS(%rsp)
19586 + jnz 1f
19587 + pax_enter_kernel
19588 + jmp 2f
19589 +1: pax_enter_kernel_user
19590 +2:
19591 +#else
19592 + pax_enter_kernel
19593 +#endif
19594 movq %rsp,%rdi /* pt_regs pointer */
19595 xorl %esi,%esi /* no error code */
19596 call \do_sym
19597 jmp paranoid_exit /* %ebx: no swapgs flag */
19598 CFI_ENDPROC
19599 -END(\sym)
19600 +ENDPROC(\sym)
19601 .endm
19602
19603 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19604 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19605 .macro paranoidzeroentry_ist sym do_sym ist
19606 ENTRY(\sym)
19607 INTR_FRAME
19608 @@ -1248,14 +1582,30 @@ ENTRY(\sym)
19609 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19610 call save_paranoid
19611 TRACE_IRQS_OFF_DEBUG
19612 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19613 + testb $3, CS(%rsp)
19614 + jnz 1f
19615 + pax_enter_kernel
19616 + jmp 2f
19617 +1: pax_enter_kernel_user
19618 +2:
19619 +#else
19620 + pax_enter_kernel
19621 +#endif
19622 movq %rsp,%rdi /* pt_regs pointer */
19623 xorl %esi,%esi /* no error code */
19624 +#ifdef CONFIG_SMP
19625 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19626 + lea init_tss(%r12), %r12
19627 +#else
19628 + lea init_tss(%rip), %r12
19629 +#endif
19630 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19631 call \do_sym
19632 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19633 jmp paranoid_exit /* %ebx: no swapgs flag */
19634 CFI_ENDPROC
19635 -END(\sym)
19636 +ENDPROC(\sym)
19637 .endm
19638
19639 .macro errorentry sym do_sym
19640 @@ -1267,13 +1617,23 @@ ENTRY(\sym)
19641 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19642 call error_entry
19643 DEFAULT_FRAME 0
19644 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19645 + testb $3, CS(%rsp)
19646 + jnz 1f
19647 + pax_enter_kernel
19648 + jmp 2f
19649 +1: pax_enter_kernel_user
19650 +2:
19651 +#else
19652 + pax_enter_kernel
19653 +#endif
19654 movq %rsp,%rdi /* pt_regs pointer */
19655 movq ORIG_RAX(%rsp),%rsi /* get error code */
19656 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19657 call \do_sym
19658 jmp error_exit /* %ebx: no swapgs flag */
19659 CFI_ENDPROC
19660 -END(\sym)
19661 +ENDPROC(\sym)
19662 .endm
19663
19664 /* error code is on the stack already */
19665 @@ -1287,13 +1647,23 @@ ENTRY(\sym)
19666 call save_paranoid
19667 DEFAULT_FRAME 0
19668 TRACE_IRQS_OFF
19669 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19670 + testb $3, CS(%rsp)
19671 + jnz 1f
19672 + pax_enter_kernel
19673 + jmp 2f
19674 +1: pax_enter_kernel_user
19675 +2:
19676 +#else
19677 + pax_enter_kernel
19678 +#endif
19679 movq %rsp,%rdi /* pt_regs pointer */
19680 movq ORIG_RAX(%rsp),%rsi /* get error code */
19681 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19682 call \do_sym
19683 jmp paranoid_exit /* %ebx: no swapgs flag */
19684 CFI_ENDPROC
19685 -END(\sym)
19686 +ENDPROC(\sym)
19687 .endm
19688
19689 zeroentry divide_error do_divide_error
19690 @@ -1323,9 +1693,10 @@ gs_change:
19691 2: mfence /* workaround */
19692 SWAPGS
19693 popfq_cfi
19694 + pax_force_retaddr
19695 ret
19696 CFI_ENDPROC
19697 -END(native_load_gs_index)
19698 +ENDPROC(native_load_gs_index)
19699
19700 _ASM_EXTABLE(gs_change,bad_gs)
19701 .section .fixup,"ax"
19702 @@ -1353,9 +1724,10 @@ ENTRY(call_softirq)
19703 CFI_DEF_CFA_REGISTER rsp
19704 CFI_ADJUST_CFA_OFFSET -8
19705 decl PER_CPU_VAR(irq_count)
19706 + pax_force_retaddr
19707 ret
19708 CFI_ENDPROC
19709 -END(call_softirq)
19710 +ENDPROC(call_softirq)
19711
19712 #ifdef CONFIG_XEN
19713 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19714 @@ -1393,7 +1765,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19715 decl PER_CPU_VAR(irq_count)
19716 jmp error_exit
19717 CFI_ENDPROC
19718 -END(xen_do_hypervisor_callback)
19719 +ENDPROC(xen_do_hypervisor_callback)
19720
19721 /*
19722 * Hypervisor uses this for application faults while it executes.
19723 @@ -1452,7 +1824,7 @@ ENTRY(xen_failsafe_callback)
19724 SAVE_ALL
19725 jmp error_exit
19726 CFI_ENDPROC
19727 -END(xen_failsafe_callback)
19728 +ENDPROC(xen_failsafe_callback)
19729
19730 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
19731 xen_hvm_callback_vector xen_evtchn_do_upcall
19732 @@ -1501,16 +1873,31 @@ ENTRY(paranoid_exit)
19733 TRACE_IRQS_OFF_DEBUG
19734 testl %ebx,%ebx /* swapgs needed? */
19735 jnz paranoid_restore
19736 - testl $3,CS(%rsp)
19737 + testb $3,CS(%rsp)
19738 jnz paranoid_userspace
19739 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19740 + pax_exit_kernel
19741 + TRACE_IRQS_IRETQ 0
19742 + SWAPGS_UNSAFE_STACK
19743 + RESTORE_ALL 8
19744 + pax_force_retaddr_bts
19745 + jmp irq_return
19746 +#endif
19747 paranoid_swapgs:
19748 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19749 + pax_exit_kernel_user
19750 +#else
19751 + pax_exit_kernel
19752 +#endif
19753 TRACE_IRQS_IRETQ 0
19754 SWAPGS_UNSAFE_STACK
19755 RESTORE_ALL 8
19756 jmp irq_return
19757 paranoid_restore:
19758 + pax_exit_kernel
19759 TRACE_IRQS_IRETQ_DEBUG 0
19760 RESTORE_ALL 8
19761 + pax_force_retaddr_bts
19762 jmp irq_return
19763 paranoid_userspace:
19764 GET_THREAD_INFO(%rcx)
19765 @@ -1539,7 +1926,7 @@ paranoid_schedule:
19766 TRACE_IRQS_OFF
19767 jmp paranoid_userspace
19768 CFI_ENDPROC
19769 -END(paranoid_exit)
19770 +ENDPROC(paranoid_exit)
19771
19772 /*
19773 * Exception entry point. This expects an error code/orig_rax on the stack.
19774 @@ -1566,12 +1953,13 @@ ENTRY(error_entry)
19775 movq_cfi r14, R14+8
19776 movq_cfi r15, R15+8
19777 xorl %ebx,%ebx
19778 - testl $3,CS+8(%rsp)
19779 + testb $3,CS+8(%rsp)
19780 je error_kernelspace
19781 error_swapgs:
19782 SWAPGS
19783 error_sti:
19784 TRACE_IRQS_OFF
19785 + pax_force_retaddr_bts
19786 ret
19787
19788 /*
19789 @@ -1598,7 +1986,7 @@ bstep_iret:
19790 movq %rcx,RIP+8(%rsp)
19791 jmp error_swapgs
19792 CFI_ENDPROC
19793 -END(error_entry)
19794 +ENDPROC(error_entry)
19795
19796
19797 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19798 @@ -1618,7 +2006,7 @@ ENTRY(error_exit)
19799 jnz retint_careful
19800 jmp retint_swapgs
19801 CFI_ENDPROC
19802 -END(error_exit)
19803 +ENDPROC(error_exit)
19804
19805 /*
19806 * Test if a given stack is an NMI stack or not.
19807 @@ -1676,9 +2064,11 @@ ENTRY(nmi)
19808 * If %cs was not the kernel segment, then the NMI triggered in user
19809 * space, which means it is definitely not nested.
19810 */
19811 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19812 + je 1f
19813 cmpl $__KERNEL_CS, 16(%rsp)
19814 jne first_nmi
19815 -
19816 +1:
19817 /*
19818 * Check the special variable on the stack to see if NMIs are
19819 * executing.
19820 @@ -1847,6 +2237,17 @@ end_repeat_nmi:
19821 */
19822 movq %cr2, %r12
19823
19824 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19825 + testb $3, CS(%rsp)
19826 + jnz 1f
19827 + pax_enter_kernel
19828 + jmp 2f
19829 +1: pax_enter_kernel_user
19830 +2:
19831 +#else
19832 + pax_enter_kernel
19833 +#endif
19834 +
19835 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
19836 movq %rsp,%rdi
19837 movq $-1,%rsi
19838 @@ -1862,23 +2263,34 @@ end_repeat_nmi:
19839 testl %ebx,%ebx /* swapgs needed? */
19840 jnz nmi_restore
19841 nmi_swapgs:
19842 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19843 + pax_exit_kernel_user
19844 +#else
19845 + pax_exit_kernel
19846 +#endif
19847 SWAPGS_UNSAFE_STACK
19848 + RESTORE_ALL 6*8
19849 + /* Clear the NMI executing stack variable */
19850 + movq $0, 5*8(%rsp)
19851 + jmp irq_return
19852 nmi_restore:
19853 + pax_exit_kernel
19854 /* Pop the extra iret frame at once */
19855 RESTORE_ALL 6*8
19856 + pax_force_retaddr_bts
19857
19858 /* Clear the NMI executing stack variable */
19859 movq $0, 5*8(%rsp)
19860 jmp irq_return
19861 CFI_ENDPROC
19862 -END(nmi)
19863 +ENDPROC(nmi)
19864
19865 ENTRY(ignore_sysret)
19866 CFI_STARTPROC
19867 mov $-ENOSYS,%eax
19868 sysret
19869 CFI_ENDPROC
19870 -END(ignore_sysret)
19871 +ENDPROC(ignore_sysret)
19872
19873 /*
19874 * End of kprobes section
19875 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
19876 index 1d41402..af9a46a 100644
19877 --- a/arch/x86/kernel/ftrace.c
19878 +++ b/arch/x86/kernel/ftrace.c
19879 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
19880 {
19881 unsigned char replaced[MCOUNT_INSN_SIZE];
19882
19883 + ip = ktla_ktva(ip);
19884 +
19885 /*
19886 * Note: Due to modules and __init, code can
19887 * disappear and change, we need to protect against faulting
19888 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19889 unsigned char old[MCOUNT_INSN_SIZE], *new;
19890 int ret;
19891
19892 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
19893 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
19894 new = ftrace_call_replace(ip, (unsigned long)func);
19895
19896 /* See comment above by declaration of modifying_ftrace_code */
19897 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19898 /* Also update the regs callback function */
19899 if (!ret) {
19900 ip = (unsigned long)(&ftrace_regs_call);
19901 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
19902 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
19903 new = ftrace_call_replace(ip, (unsigned long)func);
19904 ret = ftrace_modify_code(ip, old, new);
19905 }
19906 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
19907 * kernel identity mapping to modify code.
19908 */
19909 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
19910 - ip = (unsigned long)__va(__pa(ip));
19911 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
19912
19913 return probe_kernel_write((void *)ip, val, size);
19914 }
19915 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
19916 unsigned char replaced[MCOUNT_INSN_SIZE];
19917 unsigned char brk = BREAKPOINT_INSTRUCTION;
19918
19919 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
19920 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
19921 return -EFAULT;
19922
19923 /* Make sure it is what we expect it to be */
19924 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
19925 return ret;
19926
19927 fail_update:
19928 - probe_kernel_write((void *)ip, &old_code[0], 1);
19929 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
19930 goto out;
19931 }
19932
19933 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
19934 {
19935 unsigned char code[MCOUNT_INSN_SIZE];
19936
19937 + ip = ktla_ktva(ip);
19938 +
19939 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
19940 return -EFAULT;
19941
19942 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
19943 index c18f59d..9c0c9f6 100644
19944 --- a/arch/x86/kernel/head32.c
19945 +++ b/arch/x86/kernel/head32.c
19946 @@ -18,6 +18,7 @@
19947 #include <asm/io_apic.h>
19948 #include <asm/bios_ebda.h>
19949 #include <asm/tlbflush.h>
19950 +#include <asm/boot.h>
19951
19952 static void __init i386_default_early_setup(void)
19953 {
19954 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
19955
19956 void __init i386_start_kernel(void)
19957 {
19958 - memblock_reserve(__pa_symbol(&_text),
19959 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
19960 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
19961
19962 #ifdef CONFIG_BLK_DEV_INITRD
19963 /* Reserve INITRD */
19964 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
19965 index c8932c7..d56b622 100644
19966 --- a/arch/x86/kernel/head_32.S
19967 +++ b/arch/x86/kernel/head_32.S
19968 @@ -26,6 +26,12 @@
19969 /* Physical address */
19970 #define pa(X) ((X) - __PAGE_OFFSET)
19971
19972 +#ifdef CONFIG_PAX_KERNEXEC
19973 +#define ta(X) (X)
19974 +#else
19975 +#define ta(X) ((X) - __PAGE_OFFSET)
19976 +#endif
19977 +
19978 /*
19979 * References to members of the new_cpu_data structure.
19980 */
19981 @@ -55,11 +61,7 @@
19982 * and small than max_low_pfn, otherwise will waste some page table entries
19983 */
19984
19985 -#if PTRS_PER_PMD > 1
19986 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
19987 -#else
19988 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
19989 -#endif
19990 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
19991
19992 /* Number of possible pages in the lowmem region */
19993 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
19994 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
19995 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
19996
19997 /*
19998 + * Real beginning of normal "text" segment
19999 + */
20000 +ENTRY(stext)
20001 +ENTRY(_stext)
20002 +
20003 +/*
20004 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20005 * %esi points to the real-mode code as a 32-bit pointer.
20006 * CS and DS must be 4 GB flat segments, but we don't depend on
20007 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20008 * can.
20009 */
20010 __HEAD
20011 +
20012 +#ifdef CONFIG_PAX_KERNEXEC
20013 + jmp startup_32
20014 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20015 +.fill PAGE_SIZE-5,1,0xcc
20016 +#endif
20017 +
20018 ENTRY(startup_32)
20019 movl pa(stack_start),%ecx
20020
20021 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20022 2:
20023 leal -__PAGE_OFFSET(%ecx),%esp
20024
20025 +#ifdef CONFIG_SMP
20026 + movl $pa(cpu_gdt_table),%edi
20027 + movl $__per_cpu_load,%eax
20028 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20029 + rorl $16,%eax
20030 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20031 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20032 + movl $__per_cpu_end - 1,%eax
20033 + subl $__per_cpu_start,%eax
20034 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20035 +#endif
20036 +
20037 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20038 + movl $NR_CPUS,%ecx
20039 + movl $pa(cpu_gdt_table),%edi
20040 +1:
20041 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20042 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20043 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20044 + addl $PAGE_SIZE_asm,%edi
20045 + loop 1b
20046 +#endif
20047 +
20048 +#ifdef CONFIG_PAX_KERNEXEC
20049 + movl $pa(boot_gdt),%edi
20050 + movl $__LOAD_PHYSICAL_ADDR,%eax
20051 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20052 + rorl $16,%eax
20053 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20054 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20055 + rorl $16,%eax
20056 +
20057 + ljmp $(__BOOT_CS),$1f
20058 +1:
20059 +
20060 + movl $NR_CPUS,%ecx
20061 + movl $pa(cpu_gdt_table),%edi
20062 + addl $__PAGE_OFFSET,%eax
20063 +1:
20064 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20065 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20066 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20067 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20068 + rorl $16,%eax
20069 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20070 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20071 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20072 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20073 + rorl $16,%eax
20074 + addl $PAGE_SIZE_asm,%edi
20075 + loop 1b
20076 +#endif
20077 +
20078 /*
20079 * Clear BSS first so that there are no surprises...
20080 */
20081 @@ -196,8 +264,11 @@ ENTRY(startup_32)
20082 movl %eax, pa(max_pfn_mapped)
20083
20084 /* Do early initialization of the fixmap area */
20085 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20086 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20087 +#ifdef CONFIG_COMPAT_VDSO
20088 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20089 +#else
20090 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20091 +#endif
20092 #else /* Not PAE */
20093
20094 page_pde_offset = (__PAGE_OFFSET >> 20);
20095 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20096 movl %eax, pa(max_pfn_mapped)
20097
20098 /* Do early initialization of the fixmap area */
20099 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20100 - movl %eax,pa(initial_page_table+0xffc)
20101 +#ifdef CONFIG_COMPAT_VDSO
20102 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20103 +#else
20104 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20105 +#endif
20106 #endif
20107
20108 #ifdef CONFIG_PARAVIRT
20109 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20110 cmpl $num_subarch_entries, %eax
20111 jae bad_subarch
20112
20113 - movl pa(subarch_entries)(,%eax,4), %eax
20114 - subl $__PAGE_OFFSET, %eax
20115 - jmp *%eax
20116 + jmp *pa(subarch_entries)(,%eax,4)
20117
20118 bad_subarch:
20119 WEAK(lguest_entry)
20120 @@ -256,10 +328,10 @@ WEAK(xen_entry)
20121 __INITDATA
20122
20123 subarch_entries:
20124 - .long default_entry /* normal x86/PC */
20125 - .long lguest_entry /* lguest hypervisor */
20126 - .long xen_entry /* Xen hypervisor */
20127 - .long default_entry /* Moorestown MID */
20128 + .long ta(default_entry) /* normal x86/PC */
20129 + .long ta(lguest_entry) /* lguest hypervisor */
20130 + .long ta(xen_entry) /* Xen hypervisor */
20131 + .long ta(default_entry) /* Moorestown MID */
20132 num_subarch_entries = (. - subarch_entries) / 4
20133 .previous
20134 #else
20135 @@ -335,6 +407,7 @@ default_entry:
20136 movl pa(mmu_cr4_features),%eax
20137 movl %eax,%cr4
20138
20139 +#ifdef CONFIG_X86_PAE
20140 testb $X86_CR4_PAE, %al # check if PAE is enabled
20141 jz 6f
20142
20143 @@ -363,6 +436,9 @@ default_entry:
20144 /* Make changes effective */
20145 wrmsr
20146
20147 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20148 +#endif
20149 +
20150 6:
20151
20152 /*
20153 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
20154 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20155 movl %eax,%ss # after changing gdt.
20156
20157 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20158 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20159 movl %eax,%ds
20160 movl %eax,%es
20161
20162 movl $(__KERNEL_PERCPU), %eax
20163 movl %eax,%fs # set this cpu's percpu
20164
20165 +#ifdef CONFIG_CC_STACKPROTECTOR
20166 movl $(__KERNEL_STACK_CANARY),%eax
20167 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20168 + movl $(__USER_DS),%eax
20169 +#else
20170 + xorl %eax,%eax
20171 +#endif
20172 movl %eax,%gs
20173
20174 xorl %eax,%eax # Clear LDT
20175 @@ -544,8 +626,11 @@ setup_once:
20176 * relocation. Manually set base address in stack canary
20177 * segment descriptor.
20178 */
20179 - movl $gdt_page,%eax
20180 + movl $cpu_gdt_table,%eax
20181 movl $stack_canary,%ecx
20182 +#ifdef CONFIG_SMP
20183 + addl $__per_cpu_load,%ecx
20184 +#endif
20185 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20186 shrl $16, %ecx
20187 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20188 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
20189 /* This is global to keep gas from relaxing the jumps */
20190 ENTRY(early_idt_handler)
20191 cld
20192 - cmpl $2,%ss:early_recursion_flag
20193 + cmpl $1,%ss:early_recursion_flag
20194 je hlt_loop
20195 incl %ss:early_recursion_flag
20196
20197 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
20198 pushl (20+6*4)(%esp) /* trapno */
20199 pushl $fault_msg
20200 call printk
20201 -#endif
20202 call dump_stack
20203 +#endif
20204 hlt_loop:
20205 hlt
20206 jmp hlt_loop
20207 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
20208 /* This is the default interrupt "handler" :-) */
20209 ALIGN
20210 ignore_int:
20211 - cld
20212 #ifdef CONFIG_PRINTK
20213 + cmpl $2,%ss:early_recursion_flag
20214 + je hlt_loop
20215 + incl %ss:early_recursion_flag
20216 + cld
20217 pushl %eax
20218 pushl %ecx
20219 pushl %edx
20220 @@ -644,9 +732,6 @@ ignore_int:
20221 movl $(__KERNEL_DS),%eax
20222 movl %eax,%ds
20223 movl %eax,%es
20224 - cmpl $2,early_recursion_flag
20225 - je hlt_loop
20226 - incl early_recursion_flag
20227 pushl 16(%esp)
20228 pushl 24(%esp)
20229 pushl 32(%esp)
20230 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
20231 /*
20232 * BSS section
20233 */
20234 -__PAGE_ALIGNED_BSS
20235 - .align PAGE_SIZE
20236 #ifdef CONFIG_X86_PAE
20237 +.section .initial_pg_pmd,"a",@progbits
20238 initial_pg_pmd:
20239 .fill 1024*KPMDS,4,0
20240 #else
20241 +.section .initial_page_table,"a",@progbits
20242 ENTRY(initial_page_table)
20243 .fill 1024,4,0
20244 #endif
20245 +.section .initial_pg_fixmap,"a",@progbits
20246 initial_pg_fixmap:
20247 .fill 1024,4,0
20248 +.section .empty_zero_page,"a",@progbits
20249 ENTRY(empty_zero_page)
20250 .fill 4096,1,0
20251 +.section .swapper_pg_dir,"a",@progbits
20252 ENTRY(swapper_pg_dir)
20253 +#ifdef CONFIG_X86_PAE
20254 + .fill 4,8,0
20255 +#else
20256 .fill 1024,4,0
20257 +#endif
20258 +
20259 +/*
20260 + * The IDT has to be page-aligned to simplify the Pentium
20261 + * F0 0F bug workaround.. We have a special link segment
20262 + * for this.
20263 + */
20264 +.section .idt,"a",@progbits
20265 +ENTRY(idt_table)
20266 + .fill 256,8,0
20267
20268 /*
20269 * This starts the data section.
20270 */
20271 #ifdef CONFIG_X86_PAE
20272 -__PAGE_ALIGNED_DATA
20273 - /* Page-aligned for the benefit of paravirt? */
20274 - .align PAGE_SIZE
20275 +.section .initial_page_table,"a",@progbits
20276 ENTRY(initial_page_table)
20277 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20278 # if KPMDS == 3
20279 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
20280 # error "Kernel PMDs should be 1, 2 or 3"
20281 # endif
20282 .align PAGE_SIZE /* needs to be page-sized too */
20283 +
20284 +#ifdef CONFIG_PAX_PER_CPU_PGD
20285 +ENTRY(cpu_pgd)
20286 + .rept NR_CPUS
20287 + .fill 4,8,0
20288 + .endr
20289 +#endif
20290 +
20291 #endif
20292
20293 .data
20294 .balign 4
20295 ENTRY(stack_start)
20296 - .long init_thread_union+THREAD_SIZE
20297 + .long init_thread_union+THREAD_SIZE-8
20298
20299 __INITRODATA
20300 int_msg:
20301 @@ -754,7 +861,7 @@ fault_msg:
20302 * segment size, and 32-bit linear address value:
20303 */
20304
20305 - .data
20306 +.section .rodata,"a",@progbits
20307 .globl boot_gdt_descr
20308 .globl idt_descr
20309
20310 @@ -763,7 +870,7 @@ fault_msg:
20311 .word 0 # 32 bit align gdt_desc.address
20312 boot_gdt_descr:
20313 .word __BOOT_DS+7
20314 - .long boot_gdt - __PAGE_OFFSET
20315 + .long pa(boot_gdt)
20316
20317 .word 0 # 32-bit align idt_desc.address
20318 idt_descr:
20319 @@ -774,7 +881,7 @@ idt_descr:
20320 .word 0 # 32 bit align gdt_desc.address
20321 ENTRY(early_gdt_descr)
20322 .word GDT_ENTRIES*8-1
20323 - .long gdt_page /* Overwritten for secondary CPUs */
20324 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20325
20326 /*
20327 * The boot_gdt must mirror the equivalent in setup.S and is
20328 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
20329 .align L1_CACHE_BYTES
20330 ENTRY(boot_gdt)
20331 .fill GDT_ENTRY_BOOT_CS,8,0
20332 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20333 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20334 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20335 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20336 +
20337 + .align PAGE_SIZE_asm
20338 +ENTRY(cpu_gdt_table)
20339 + .rept NR_CPUS
20340 + .quad 0x0000000000000000 /* NULL descriptor */
20341 + .quad 0x0000000000000000 /* 0x0b reserved */
20342 + .quad 0x0000000000000000 /* 0x13 reserved */
20343 + .quad 0x0000000000000000 /* 0x1b reserved */
20344 +
20345 +#ifdef CONFIG_PAX_KERNEXEC
20346 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20347 +#else
20348 + .quad 0x0000000000000000 /* 0x20 unused */
20349 +#endif
20350 +
20351 + .quad 0x0000000000000000 /* 0x28 unused */
20352 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20353 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20354 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20355 + .quad 0x0000000000000000 /* 0x4b reserved */
20356 + .quad 0x0000000000000000 /* 0x53 reserved */
20357 + .quad 0x0000000000000000 /* 0x5b reserved */
20358 +
20359 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20360 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20361 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20362 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20363 +
20364 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20365 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20366 +
20367 + /*
20368 + * Segments used for calling PnP BIOS have byte granularity.
20369 + * The code segments and data segments have fixed 64k limits,
20370 + * the transfer segment sizes are set at run time.
20371 + */
20372 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20373 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20374 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20375 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20376 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20377 +
20378 + /*
20379 + * The APM segments have byte granularity and their bases
20380 + * are set at run time. All have 64k limits.
20381 + */
20382 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20383 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20384 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20385 +
20386 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20387 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20388 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20389 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20390 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20391 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20392 +
20393 + /* Be sure this is zeroed to avoid false validations in Xen */
20394 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20395 + .endr
20396 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20397 index 980053c..74d3b44 100644
20398 --- a/arch/x86/kernel/head_64.S
20399 +++ b/arch/x86/kernel/head_64.S
20400 @@ -20,6 +20,8 @@
20401 #include <asm/processor-flags.h>
20402 #include <asm/percpu.h>
20403 #include <asm/nops.h>
20404 +#include <asm/cpufeature.h>
20405 +#include <asm/alternative-asm.h>
20406
20407 #ifdef CONFIG_PARAVIRT
20408 #include <asm/asm-offsets.h>
20409 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20410 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20411 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20412 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20413 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20414 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20415 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20416 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20417 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20418 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20419
20420 .text
20421 __HEAD
20422 @@ -88,35 +96,23 @@ startup_64:
20423 */
20424 addq %rbp, init_level4_pgt + 0(%rip)
20425 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20426 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20427 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20428 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20429 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20430
20431 addq %rbp, level3_ident_pgt + 0(%rip)
20432 +#ifndef CONFIG_XEN
20433 + addq %rbp, level3_ident_pgt + 8(%rip)
20434 +#endif
20435
20436 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20437 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20438 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20439 +
20440 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20441 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
20442
20443 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20444 -
20445 - /* Add an Identity mapping if I am above 1G */
20446 - leaq _text(%rip), %rdi
20447 - andq $PMD_PAGE_MASK, %rdi
20448 -
20449 - movq %rdi, %rax
20450 - shrq $PUD_SHIFT, %rax
20451 - andq $(PTRS_PER_PUD - 1), %rax
20452 - jz ident_complete
20453 -
20454 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
20455 - leaq level3_ident_pgt(%rip), %rbx
20456 - movq %rdx, 0(%rbx, %rax, 8)
20457 -
20458 - movq %rdi, %rax
20459 - shrq $PMD_SHIFT, %rax
20460 - andq $(PTRS_PER_PMD - 1), %rax
20461 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
20462 - leaq level2_spare_pgt(%rip), %rbx
20463 - movq %rdx, 0(%rbx, %rax, 8)
20464 -ident_complete:
20465 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20466
20467 /*
20468 * Fixup the kernel text+data virtual addresses. Note that
20469 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
20470 * after the boot processor executes this code.
20471 */
20472
20473 - /* Enable PAE mode and PGE */
20474 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
20475 + /* Enable PAE mode and PSE/PGE */
20476 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
20477 movq %rax, %cr4
20478
20479 /* Setup early boot stage 4 level pagetables. */
20480 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
20481 movl $MSR_EFER, %ecx
20482 rdmsr
20483 btsl $_EFER_SCE, %eax /* Enable System Call */
20484 - btl $20,%edi /* No Execute supported? */
20485 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20486 jnc 1f
20487 btsl $_EFER_NX, %eax
20488 + leaq init_level4_pgt(%rip), %rdi
20489 +#ifndef CONFIG_EFI
20490 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20491 +#endif
20492 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20493 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20494 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20495 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20496 1: wrmsr /* Make changes effective */
20497
20498 /* Setup cr0 */
20499 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
20500 * jump. In addition we need to ensure %cs is set so we make this
20501 * a far return.
20502 */
20503 + pax_set_fptr_mask
20504 movq initial_code(%rip),%rax
20505 pushq $0 # fake return address to stop unwinder
20506 pushq $__KERNEL_CS # set correct cs
20507 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
20508 bad_address:
20509 jmp bad_address
20510
20511 - .section ".init.text","ax"
20512 + __INIT
20513 .globl early_idt_handlers
20514 early_idt_handlers:
20515 # 104(%rsp) %rflags
20516 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
20517 call dump_stack
20518 #ifdef CONFIG_KALLSYMS
20519 leaq early_idt_ripmsg(%rip),%rdi
20520 - movq 40(%rsp),%rsi # %rip again
20521 + movq 88(%rsp),%rsi # %rip again
20522 call __print_symbol
20523 #endif
20524 #endif /* EARLY_PRINTK */
20525 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
20526 addq $16,%rsp # drop vector number and error code
20527 decl early_recursion_flag(%rip)
20528 INTERRUPT_RETURN
20529 + .previous
20530
20531 + __INITDATA
20532 .balign 4
20533 early_recursion_flag:
20534 .long 0
20535 + .previous
20536
20537 + .section .rodata,"a",@progbits
20538 #ifdef CONFIG_EARLY_PRINTK
20539 early_idt_msg:
20540 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20541 @@ -376,6 +385,7 @@ early_idt_ripmsg:
20542 #endif /* CONFIG_EARLY_PRINTK */
20543 .previous
20544
20545 + .section .rodata,"a",@progbits
20546 #define NEXT_PAGE(name) \
20547 .balign PAGE_SIZE; \
20548 ENTRY(name)
20549 @@ -388,7 +398,6 @@ ENTRY(name)
20550 i = i + 1 ; \
20551 .endr
20552
20553 - .data
20554 /*
20555 * This default setting generates an ident mapping at address 0x100000
20556 * and a mapping for the kernel that precisely maps virtual address
20557 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
20558 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20559 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20560 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20561 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20562 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20563 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20564 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20565 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20566 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20567 .org init_level4_pgt + L4_START_KERNEL*8, 0
20568 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20569 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20570
20571 +#ifdef CONFIG_PAX_PER_CPU_PGD
20572 +NEXT_PAGE(cpu_pgd)
20573 + .rept NR_CPUS
20574 + .fill 512,8,0
20575 + .endr
20576 +#endif
20577 +
20578 NEXT_PAGE(level3_ident_pgt)
20579 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20580 +#ifdef CONFIG_XEN
20581 .fill 511,8,0
20582 +#else
20583 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20584 + .fill 510,8,0
20585 +#endif
20586 +
20587 +NEXT_PAGE(level3_vmalloc_start_pgt)
20588 + .fill 512,8,0
20589 +
20590 +NEXT_PAGE(level3_vmalloc_end_pgt)
20591 + .fill 512,8,0
20592 +
20593 +NEXT_PAGE(level3_vmemmap_pgt)
20594 + .fill L3_VMEMMAP_START,8,0
20595 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20596
20597 NEXT_PAGE(level3_kernel_pgt)
20598 .fill L3_START_KERNEL,8,0
20599 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
20600 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20601 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20602
20603 +NEXT_PAGE(level2_vmemmap_pgt)
20604 + .fill 512,8,0
20605 +
20606 NEXT_PAGE(level2_fixmap_pgt)
20607 - .fill 506,8,0
20608 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20609 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20610 - .fill 5,8,0
20611 + .fill 507,8,0
20612 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20613 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20614 + .fill 4,8,0
20615
20616 -NEXT_PAGE(level1_fixmap_pgt)
20617 +NEXT_PAGE(level1_vsyscall_pgt)
20618 .fill 512,8,0
20619
20620 -NEXT_PAGE(level2_ident_pgt)
20621 - /* Since I easily can, map the first 1G.
20622 + /* Since I easily can, map the first 2G.
20623 * Don't set NX because code runs from these pages.
20624 */
20625 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20626 +NEXT_PAGE(level2_ident_pgt)
20627 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20628
20629 NEXT_PAGE(level2_kernel_pgt)
20630 /*
20631 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
20632 * If you want to increase this then increase MODULES_VADDR
20633 * too.)
20634 */
20635 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
20636 - KERNEL_IMAGE_SIZE/PMD_SIZE)
20637 -
20638 -NEXT_PAGE(level2_spare_pgt)
20639 - .fill 512, 8, 0
20640 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
20641
20642 #undef PMDS
20643 #undef NEXT_PAGE
20644
20645 - .data
20646 + .align PAGE_SIZE
20647 +ENTRY(cpu_gdt_table)
20648 + .rept NR_CPUS
20649 + .quad 0x0000000000000000 /* NULL descriptor */
20650 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20651 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20652 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20653 + .quad 0x00cffb000000ffff /* __USER32_CS */
20654 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20655 + .quad 0x00affb000000ffff /* __USER_CS */
20656 +
20657 +#ifdef CONFIG_PAX_KERNEXEC
20658 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20659 +#else
20660 + .quad 0x0 /* unused */
20661 +#endif
20662 +
20663 + .quad 0,0 /* TSS */
20664 + .quad 0,0 /* LDT */
20665 + .quad 0,0,0 /* three TLS descriptors */
20666 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20667 + /* asm/segment.h:GDT_ENTRIES must match this */
20668 +
20669 + /* zero the remaining page */
20670 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20671 + .endr
20672 +
20673 .align 16
20674 .globl early_gdt_descr
20675 early_gdt_descr:
20676 .word GDT_ENTRIES*8-1
20677 early_gdt_descr_base:
20678 - .quad INIT_PER_CPU_VAR(gdt_page)
20679 + .quad cpu_gdt_table
20680
20681 ENTRY(phys_base)
20682 /* This must match the first entry in level2_kernel_pgt */
20683 .quad 0x0000000000000000
20684
20685 #include "../../x86/xen/xen-head.S"
20686 -
20687 - .section .bss, "aw", @nobits
20688 +
20689 + .section .rodata,"a",@progbits
20690 .align L1_CACHE_BYTES
20691 ENTRY(idt_table)
20692 - .skip IDT_ENTRIES * 16
20693 + .fill 512,8,0
20694
20695 .align L1_CACHE_BYTES
20696 ENTRY(nmi_idt_table)
20697 - .skip IDT_ENTRIES * 16
20698 + .fill 512,8,0
20699
20700 __PAGE_ALIGNED_BSS
20701 .align PAGE_SIZE
20702 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20703 index 9c3bd4a..e1d9b35 100644
20704 --- a/arch/x86/kernel/i386_ksyms_32.c
20705 +++ b/arch/x86/kernel/i386_ksyms_32.c
20706 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20707 EXPORT_SYMBOL(cmpxchg8b_emu);
20708 #endif
20709
20710 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20711 +
20712 /* Networking helper routines. */
20713 EXPORT_SYMBOL(csum_partial_copy_generic);
20714 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20715 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20716
20717 EXPORT_SYMBOL(__get_user_1);
20718 EXPORT_SYMBOL(__get_user_2);
20719 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
20720
20721 EXPORT_SYMBOL(csum_partial);
20722 EXPORT_SYMBOL(empty_zero_page);
20723 +
20724 +#ifdef CONFIG_PAX_KERNEXEC
20725 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20726 +#endif
20727 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20728 index 245a71d..89d9ce4 100644
20729 --- a/arch/x86/kernel/i387.c
20730 +++ b/arch/x86/kernel/i387.c
20731 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20732 static inline bool interrupted_user_mode(void)
20733 {
20734 struct pt_regs *regs = get_irq_regs();
20735 - return regs && user_mode_vm(regs);
20736 + return regs && user_mode(regs);
20737 }
20738
20739 /*
20740 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20741 index 9a5c460..b332a4b 100644
20742 --- a/arch/x86/kernel/i8259.c
20743 +++ b/arch/x86/kernel/i8259.c
20744 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20745 "spurious 8259A interrupt: IRQ%d.\n", irq);
20746 spurious_irq_mask |= irqmask;
20747 }
20748 - atomic_inc(&irq_err_count);
20749 + atomic_inc_unchecked(&irq_err_count);
20750 /*
20751 * Theoretically we do not have to handle this IRQ,
20752 * but in Linux this does not cause problems and is
20753 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20754 /* (slave's support for AEOI in flat mode is to be investigated) */
20755 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20756
20757 + pax_open_kernel();
20758 if (auto_eoi)
20759 /*
20760 * In AEOI mode we just have to mask the interrupt
20761 * when acking.
20762 */
20763 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20764 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20765 else
20766 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20767 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20768 + pax_close_kernel();
20769
20770 udelay(100); /* wait for 8259A to initialize */
20771
20772 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20773 index a979b5b..1d6db75 100644
20774 --- a/arch/x86/kernel/io_delay.c
20775 +++ b/arch/x86/kernel/io_delay.c
20776 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20777 * Quirk table for systems that misbehave (lock up, etc.) if port
20778 * 0x80 is used:
20779 */
20780 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20781 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20782 {
20783 .callback = dmi_io_delay_0xed_port,
20784 .ident = "Compaq Presario V6000",
20785 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20786 index 8c96897..be66bfa 100644
20787 --- a/arch/x86/kernel/ioport.c
20788 +++ b/arch/x86/kernel/ioport.c
20789 @@ -6,6 +6,7 @@
20790 #include <linux/sched.h>
20791 #include <linux/kernel.h>
20792 #include <linux/capability.h>
20793 +#include <linux/security.h>
20794 #include <linux/errno.h>
20795 #include <linux/types.h>
20796 #include <linux/ioport.h>
20797 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20798
20799 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20800 return -EINVAL;
20801 +#ifdef CONFIG_GRKERNSEC_IO
20802 + if (turn_on && grsec_disable_privio) {
20803 + gr_handle_ioperm();
20804 + return -EPERM;
20805 + }
20806 +#endif
20807 if (turn_on && !capable(CAP_SYS_RAWIO))
20808 return -EPERM;
20809
20810 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20811 * because the ->io_bitmap_max value must match the bitmap
20812 * contents:
20813 */
20814 - tss = &per_cpu(init_tss, get_cpu());
20815 + tss = init_tss + get_cpu();
20816
20817 if (turn_on)
20818 bitmap_clear(t->io_bitmap_ptr, from, num);
20819 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
20820 return -EINVAL;
20821 /* Trying to gain more privileges? */
20822 if (level > old) {
20823 +#ifdef CONFIG_GRKERNSEC_IO
20824 + if (grsec_disable_privio) {
20825 + gr_handle_iopl();
20826 + return -EPERM;
20827 + }
20828 +#endif
20829 if (!capable(CAP_SYS_RAWIO))
20830 return -EPERM;
20831 }
20832 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20833 index e4595f1..ee3bfb8 100644
20834 --- a/arch/x86/kernel/irq.c
20835 +++ b/arch/x86/kernel/irq.c
20836 @@ -18,7 +18,7 @@
20837 #include <asm/mce.h>
20838 #include <asm/hw_irq.h>
20839
20840 -atomic_t irq_err_count;
20841 +atomic_unchecked_t irq_err_count;
20842
20843 /* Function pointer for generic interrupt vector handling */
20844 void (*x86_platform_ipi_callback)(void) = NULL;
20845 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20846 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20847 seq_printf(p, " Machine check polls\n");
20848 #endif
20849 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20850 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20851 #if defined(CONFIG_X86_IO_APIC)
20852 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20853 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20854 #endif
20855 return 0;
20856 }
20857 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
20858
20859 u64 arch_irq_stat(void)
20860 {
20861 - u64 sum = atomic_read(&irq_err_count);
20862 + u64 sum = atomic_read_unchecked(&irq_err_count);
20863
20864 #ifdef CONFIG_X86_IO_APIC
20865 - sum += atomic_read(&irq_mis_count);
20866 + sum += atomic_read_unchecked(&irq_mis_count);
20867 #endif
20868 return sum;
20869 }
20870 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
20871 index 344faf8..355f60d 100644
20872 --- a/arch/x86/kernel/irq_32.c
20873 +++ b/arch/x86/kernel/irq_32.c
20874 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
20875 __asm__ __volatile__("andl %%esp,%0" :
20876 "=r" (sp) : "0" (THREAD_SIZE - 1));
20877
20878 - return sp < (sizeof(struct thread_info) + STACK_WARN);
20879 + return sp < STACK_WARN;
20880 }
20881
20882 static void print_stack_overflow(void)
20883 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
20884 * per-CPU IRQ handling contexts (thread information and stack)
20885 */
20886 union irq_ctx {
20887 - struct thread_info tinfo;
20888 - u32 stack[THREAD_SIZE/sizeof(u32)];
20889 + unsigned long previous_esp;
20890 + u32 stack[THREAD_SIZE/sizeof(u32)];
20891 } __attribute__((aligned(THREAD_SIZE)));
20892
20893 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
20894 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
20895 static inline int
20896 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20897 {
20898 - union irq_ctx *curctx, *irqctx;
20899 + union irq_ctx *irqctx;
20900 u32 *isp, arg1, arg2;
20901
20902 - curctx = (union irq_ctx *) current_thread_info();
20903 irqctx = __this_cpu_read(hardirq_ctx);
20904
20905 /*
20906 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20907 * handler) we can't do that and just have to keep using the
20908 * current stack (which is the irq stack already after all)
20909 */
20910 - if (unlikely(curctx == irqctx))
20911 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
20912 return 0;
20913
20914 /* build the stack frame on the IRQ stack */
20915 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20916 - irqctx->tinfo.task = curctx->tinfo.task;
20917 - irqctx->tinfo.previous_esp = current_stack_pointer;
20918 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20919 + irqctx->previous_esp = current_stack_pointer;
20920
20921 - /* Copy the preempt_count so that the [soft]irq checks work. */
20922 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
20923 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20924 + __set_fs(MAKE_MM_SEG(0));
20925 +#endif
20926
20927 if (unlikely(overflow))
20928 call_on_stack(print_stack_overflow, isp);
20929 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20930 : "0" (irq), "1" (desc), "2" (isp),
20931 "D" (desc->handle_irq)
20932 : "memory", "cc", "ecx");
20933 +
20934 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20935 + __set_fs(current_thread_info()->addr_limit);
20936 +#endif
20937 +
20938 return 1;
20939 }
20940
20941 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20942 */
20943 void __cpuinit irq_ctx_init(int cpu)
20944 {
20945 - union irq_ctx *irqctx;
20946 -
20947 if (per_cpu(hardirq_ctx, cpu))
20948 return;
20949
20950 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20951 - THREADINFO_GFP,
20952 - THREAD_SIZE_ORDER));
20953 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20954 - irqctx->tinfo.cpu = cpu;
20955 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
20956 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20957 -
20958 - per_cpu(hardirq_ctx, cpu) = irqctx;
20959 -
20960 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20961 - THREADINFO_GFP,
20962 - THREAD_SIZE_ORDER));
20963 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20964 - irqctx->tinfo.cpu = cpu;
20965 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20966 -
20967 - per_cpu(softirq_ctx, cpu) = irqctx;
20968 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20969 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20970 +
20971 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20972 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20973
20974 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20975 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20976 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
20977 asmlinkage void do_softirq(void)
20978 {
20979 unsigned long flags;
20980 - struct thread_info *curctx;
20981 union irq_ctx *irqctx;
20982 u32 *isp;
20983
20984 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
20985 local_irq_save(flags);
20986
20987 if (local_softirq_pending()) {
20988 - curctx = current_thread_info();
20989 irqctx = __this_cpu_read(softirq_ctx);
20990 - irqctx->tinfo.task = curctx->task;
20991 - irqctx->tinfo.previous_esp = current_stack_pointer;
20992 + irqctx->previous_esp = current_stack_pointer;
20993
20994 /* build the stack frame on the softirq stack */
20995 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20996 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20997 +
20998 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20999 + __set_fs(MAKE_MM_SEG(0));
21000 +#endif
21001
21002 call_on_stack(__do_softirq, isp);
21003 +
21004 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21005 + __set_fs(current_thread_info()->addr_limit);
21006 +#endif
21007 +
21008 /*
21009 * Shouldn't happen, we returned above if in_interrupt():
21010 */
21011 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21012 if (unlikely(!desc))
21013 return false;
21014
21015 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21016 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21017 if (unlikely(overflow))
21018 print_stack_overflow();
21019 desc->handle_irq(irq, desc);
21020 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21021 index d04d3ec..ea4b374 100644
21022 --- a/arch/x86/kernel/irq_64.c
21023 +++ b/arch/x86/kernel/irq_64.c
21024 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21025 u64 estack_top, estack_bottom;
21026 u64 curbase = (u64)task_stack_page(current);
21027
21028 - if (user_mode_vm(regs))
21029 + if (user_mode(regs))
21030 return;
21031
21032 if (regs->sp >= curbase + sizeof(struct thread_info) +
21033 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21034 index dc1404b..bbc43e7 100644
21035 --- a/arch/x86/kernel/kdebugfs.c
21036 +++ b/arch/x86/kernel/kdebugfs.c
21037 @@ -27,7 +27,7 @@ struct setup_data_node {
21038 u32 len;
21039 };
21040
21041 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21042 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21043 size_t count, loff_t *ppos)
21044 {
21045 struct setup_data_node *node = file->private_data;
21046 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21047 index 836f832..a8bda67 100644
21048 --- a/arch/x86/kernel/kgdb.c
21049 +++ b/arch/x86/kernel/kgdb.c
21050 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21051 #ifdef CONFIG_X86_32
21052 switch (regno) {
21053 case GDB_SS:
21054 - if (!user_mode_vm(regs))
21055 + if (!user_mode(regs))
21056 *(unsigned long *)mem = __KERNEL_DS;
21057 break;
21058 case GDB_SP:
21059 - if (!user_mode_vm(regs))
21060 + if (!user_mode(regs))
21061 *(unsigned long *)mem = kernel_stack_pointer(regs);
21062 break;
21063 case GDB_GS:
21064 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21065 bp->attr.bp_addr = breakinfo[breakno].addr;
21066 bp->attr.bp_len = breakinfo[breakno].len;
21067 bp->attr.bp_type = breakinfo[breakno].type;
21068 - info->address = breakinfo[breakno].addr;
21069 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21070 + info->address = ktla_ktva(breakinfo[breakno].addr);
21071 + else
21072 + info->address = breakinfo[breakno].addr;
21073 info->len = breakinfo[breakno].len;
21074 info->type = breakinfo[breakno].type;
21075 val = arch_install_hw_breakpoint(bp);
21076 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21077 case 'k':
21078 /* clear the trace bit */
21079 linux_regs->flags &= ~X86_EFLAGS_TF;
21080 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21081 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21082
21083 /* set the trace bit if we're stepping */
21084 if (remcomInBuffer[0] == 's') {
21085 linux_regs->flags |= X86_EFLAGS_TF;
21086 - atomic_set(&kgdb_cpu_doing_single_step,
21087 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21088 raw_smp_processor_id());
21089 }
21090
21091 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21092
21093 switch (cmd) {
21094 case DIE_DEBUG:
21095 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21096 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21097 if (user_mode(regs))
21098 return single_step_cont(regs, args);
21099 break;
21100 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21101 #endif /* CONFIG_DEBUG_RODATA */
21102
21103 bpt->type = BP_BREAKPOINT;
21104 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21105 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21106 BREAK_INSTR_SIZE);
21107 if (err)
21108 return err;
21109 - err = probe_kernel_write((char *)bpt->bpt_addr,
21110 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21111 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21112 #ifdef CONFIG_DEBUG_RODATA
21113 if (!err)
21114 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21115 return -EBUSY;
21116 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21117 BREAK_INSTR_SIZE);
21118 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21119 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21120 if (err)
21121 return err;
21122 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21123 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21124 if (mutex_is_locked(&text_mutex))
21125 goto knl_write;
21126 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21127 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21128 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21129 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21130 goto knl_write;
21131 return err;
21132 knl_write:
21133 #endif /* CONFIG_DEBUG_RODATA */
21134 - return probe_kernel_write((char *)bpt->bpt_addr,
21135 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21136 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21137 }
21138
21139 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
21140 index c5e410e..ed5a7f0 100644
21141 --- a/arch/x86/kernel/kprobes-opt.c
21142 +++ b/arch/x86/kernel/kprobes-opt.c
21143 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21144 * Verify if the address gap is in 2GB range, because this uses
21145 * a relative jump.
21146 */
21147 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21148 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21149 if (abs(rel) > 0x7fffffff)
21150 return -ERANGE;
21151
21152 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21153 op->optinsn.size = ret;
21154
21155 /* Copy arch-dep-instance from template */
21156 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21157 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21158
21159 /* Set probe information */
21160 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21161
21162 /* Set probe function call */
21163 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21164 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21165
21166 /* Set returning jmp instruction at the tail of out-of-line buffer */
21167 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21168 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21169 (u8 *)op->kp.addr + op->optinsn.size);
21170
21171 flush_icache_range((unsigned long) buf,
21172 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21173 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21174
21175 /* Backup instructions which will be replaced by jump address */
21176 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21177 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21178 RELATIVE_ADDR_SIZE);
21179
21180 insn_buf[0] = RELATIVEJUMP_OPCODE;
21181 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21182 /* This kprobe is really able to run optimized path. */
21183 op = container_of(p, struct optimized_kprobe, kp);
21184 /* Detour through copied instructions */
21185 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21186 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21187 if (!reenter)
21188 reset_current_kprobe();
21189 preempt_enable_no_resched();
21190 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
21191 index 57916c0..9e0b9d0 100644
21192 --- a/arch/x86/kernel/kprobes.c
21193 +++ b/arch/x86/kernel/kprobes.c
21194 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21195 s32 raddr;
21196 } __attribute__((packed)) *insn;
21197
21198 - insn = (struct __arch_relative_insn *)from;
21199 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21200 +
21201 + pax_open_kernel();
21202 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21203 insn->op = op;
21204 + pax_close_kernel();
21205 }
21206
21207 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21208 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21209 kprobe_opcode_t opcode;
21210 kprobe_opcode_t *orig_opcodes = opcodes;
21211
21212 - if (search_exception_tables((unsigned long)opcodes))
21213 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21214 return 0; /* Page fault may occur on this address. */
21215
21216 retry:
21217 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21218 * for the first byte, we can recover the original instruction
21219 * from it and kp->opcode.
21220 */
21221 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21222 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21223 buf[0] = kp->opcode;
21224 - return (unsigned long)buf;
21225 + return ktva_ktla((unsigned long)buf);
21226 }
21227
21228 /*
21229 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21230 /* Another subsystem puts a breakpoint, failed to recover */
21231 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21232 return 0;
21233 + pax_open_kernel();
21234 memcpy(dest, insn.kaddr, insn.length);
21235 + pax_close_kernel();
21236
21237 #ifdef CONFIG_X86_64
21238 if (insn_rip_relative(&insn)) {
21239 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21240 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21241 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21242 disp = (u8 *) dest + insn_offset_displacement(&insn);
21243 + pax_open_kernel();
21244 *(s32 *) disp = (s32) newdisp;
21245 + pax_close_kernel();
21246 }
21247 #endif
21248 return insn.length;
21249 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21250 * nor set current_kprobe, because it doesn't use single
21251 * stepping.
21252 */
21253 - regs->ip = (unsigned long)p->ainsn.insn;
21254 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21255 preempt_enable_no_resched();
21256 return;
21257 }
21258 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21259 regs->flags &= ~X86_EFLAGS_IF;
21260 /* single step inline if the instruction is an int3 */
21261 if (p->opcode == BREAKPOINT_INSTRUCTION)
21262 - regs->ip = (unsigned long)p->addr;
21263 + regs->ip = ktla_ktva((unsigned long)p->addr);
21264 else
21265 - regs->ip = (unsigned long)p->ainsn.insn;
21266 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21267 }
21268
21269 /*
21270 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21271 setup_singlestep(p, regs, kcb, 0);
21272 return 1;
21273 }
21274 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21275 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21276 /*
21277 * The breakpoint instruction was removed right
21278 * after we hit it. Another cpu has removed
21279 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21280 " movq %rax, 152(%rsp)\n"
21281 RESTORE_REGS_STRING
21282 " popfq\n"
21283 +#ifdef KERNEXEC_PLUGIN
21284 + " btsq $63,(%rsp)\n"
21285 +#endif
21286 #else
21287 " pushf\n"
21288 SAVE_REGS_STRING
21289 @@ -788,7 +798,7 @@ static void __kprobes
21290 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21291 {
21292 unsigned long *tos = stack_addr(regs);
21293 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21294 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21295 unsigned long orig_ip = (unsigned long)p->addr;
21296 kprobe_opcode_t *insn = p->ainsn.insn;
21297
21298 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21299 struct die_args *args = data;
21300 int ret = NOTIFY_DONE;
21301
21302 - if (args->regs && user_mode_vm(args->regs))
21303 + if (args->regs && user_mode(args->regs))
21304 return ret;
21305
21306 switch (val) {
21307 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21308 index 9c2bd8b..bb1131c 100644
21309 --- a/arch/x86/kernel/kvm.c
21310 +++ b/arch/x86/kernel/kvm.c
21311 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21312 return NOTIFY_OK;
21313 }
21314
21315 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21316 +static struct notifier_block kvm_cpu_notifier = {
21317 .notifier_call = kvm_cpu_notify,
21318 };
21319 #endif
21320 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21321 index ebc9873..1b9724b 100644
21322 --- a/arch/x86/kernel/ldt.c
21323 +++ b/arch/x86/kernel/ldt.c
21324 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21325 if (reload) {
21326 #ifdef CONFIG_SMP
21327 preempt_disable();
21328 - load_LDT(pc);
21329 + load_LDT_nolock(pc);
21330 if (!cpumask_equal(mm_cpumask(current->mm),
21331 cpumask_of(smp_processor_id())))
21332 smp_call_function(flush_ldt, current->mm, 1);
21333 preempt_enable();
21334 #else
21335 - load_LDT(pc);
21336 + load_LDT_nolock(pc);
21337 #endif
21338 }
21339 if (oldsize) {
21340 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21341 return err;
21342
21343 for (i = 0; i < old->size; i++)
21344 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21345 + write_ldt_entry(new->ldt, i, old->ldt + i);
21346 return 0;
21347 }
21348
21349 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21350 retval = copy_ldt(&mm->context, &old_mm->context);
21351 mutex_unlock(&old_mm->context.lock);
21352 }
21353 +
21354 + if (tsk == current) {
21355 + mm->context.vdso = 0;
21356 +
21357 +#ifdef CONFIG_X86_32
21358 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21359 + mm->context.user_cs_base = 0UL;
21360 + mm->context.user_cs_limit = ~0UL;
21361 +
21362 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21363 + cpus_clear(mm->context.cpu_user_cs_mask);
21364 +#endif
21365 +
21366 +#endif
21367 +#endif
21368 +
21369 + }
21370 +
21371 return retval;
21372 }
21373
21374 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21375 }
21376 }
21377
21378 +#ifdef CONFIG_PAX_SEGMEXEC
21379 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21380 + error = -EINVAL;
21381 + goto out_unlock;
21382 + }
21383 +#endif
21384 +
21385 fill_ldt(&ldt, &ldt_info);
21386 if (oldmode)
21387 ldt.avl = 0;
21388 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21389 index 5b19e4d..6476a76 100644
21390 --- a/arch/x86/kernel/machine_kexec_32.c
21391 +++ b/arch/x86/kernel/machine_kexec_32.c
21392 @@ -26,7 +26,7 @@
21393 #include <asm/cacheflush.h>
21394 #include <asm/debugreg.h>
21395
21396 -static void set_idt(void *newidt, __u16 limit)
21397 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21398 {
21399 struct desc_ptr curidt;
21400
21401 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21402 }
21403
21404
21405 -static void set_gdt(void *newgdt, __u16 limit)
21406 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21407 {
21408 struct desc_ptr curgdt;
21409
21410 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21411 }
21412
21413 control_page = page_address(image->control_code_page);
21414 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21415 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21416
21417 relocate_kernel_ptr = control_page;
21418 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21419 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21420 index 3a04b22..1d2eb09 100644
21421 --- a/arch/x86/kernel/microcode_core.c
21422 +++ b/arch/x86/kernel/microcode_core.c
21423 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21424 return NOTIFY_OK;
21425 }
21426
21427 -static struct notifier_block __refdata mc_cpu_notifier = {
21428 +static struct notifier_block mc_cpu_notifier = {
21429 .notifier_call = mc_cpu_callback,
21430 };
21431
21432 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21433 index 3544aed..01ddc1c 100644
21434 --- a/arch/x86/kernel/microcode_intel.c
21435 +++ b/arch/x86/kernel/microcode_intel.c
21436 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21437
21438 static int get_ucode_user(void *to, const void *from, size_t n)
21439 {
21440 - return copy_from_user(to, from, n);
21441 + return copy_from_user(to, (const void __force_user *)from, n);
21442 }
21443
21444 static enum ucode_state
21445 request_microcode_user(int cpu, const void __user *buf, size_t size)
21446 {
21447 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21448 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21449 }
21450
21451 static void microcode_fini_cpu(int cpu)
21452 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21453 index 216a4d7..228255a 100644
21454 --- a/arch/x86/kernel/module.c
21455 +++ b/arch/x86/kernel/module.c
21456 @@ -43,15 +43,60 @@ do { \
21457 } while (0)
21458 #endif
21459
21460 -void *module_alloc(unsigned long size)
21461 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21462 {
21463 - if (PAGE_ALIGN(size) > MODULES_LEN)
21464 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21465 return NULL;
21466 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21467 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21468 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21469 -1, __builtin_return_address(0));
21470 }
21471
21472 +void *module_alloc(unsigned long size)
21473 +{
21474 +
21475 +#ifdef CONFIG_PAX_KERNEXEC
21476 + return __module_alloc(size, PAGE_KERNEL);
21477 +#else
21478 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21479 +#endif
21480 +
21481 +}
21482 +
21483 +#ifdef CONFIG_PAX_KERNEXEC
21484 +#ifdef CONFIG_X86_32
21485 +void *module_alloc_exec(unsigned long size)
21486 +{
21487 + struct vm_struct *area;
21488 +
21489 + if (size == 0)
21490 + return NULL;
21491 +
21492 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21493 + return area ? area->addr : NULL;
21494 +}
21495 +EXPORT_SYMBOL(module_alloc_exec);
21496 +
21497 +void module_free_exec(struct module *mod, void *module_region)
21498 +{
21499 + vunmap(module_region);
21500 +}
21501 +EXPORT_SYMBOL(module_free_exec);
21502 +#else
21503 +void module_free_exec(struct module *mod, void *module_region)
21504 +{
21505 + module_free(mod, module_region);
21506 +}
21507 +EXPORT_SYMBOL(module_free_exec);
21508 +
21509 +void *module_alloc_exec(unsigned long size)
21510 +{
21511 + return __module_alloc(size, PAGE_KERNEL_RX);
21512 +}
21513 +EXPORT_SYMBOL(module_alloc_exec);
21514 +#endif
21515 +#endif
21516 +
21517 #ifdef CONFIG_X86_32
21518 int apply_relocate(Elf32_Shdr *sechdrs,
21519 const char *strtab,
21520 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21521 unsigned int i;
21522 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21523 Elf32_Sym *sym;
21524 - uint32_t *location;
21525 + uint32_t *plocation, location;
21526
21527 DEBUGP("Applying relocate section %u to %u\n",
21528 relsec, sechdrs[relsec].sh_info);
21529 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21530 /* This is where to make the change */
21531 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21532 - + rel[i].r_offset;
21533 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21534 + location = (uint32_t)plocation;
21535 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21536 + plocation = ktla_ktva((void *)plocation);
21537 /* This is the symbol it is referring to. Note that all
21538 undefined symbols have been resolved. */
21539 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21540 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21541 switch (ELF32_R_TYPE(rel[i].r_info)) {
21542 case R_386_32:
21543 /* We add the value into the location given */
21544 - *location += sym->st_value;
21545 + pax_open_kernel();
21546 + *plocation += sym->st_value;
21547 + pax_close_kernel();
21548 break;
21549 case R_386_PC32:
21550 /* Add the value, subtract its position */
21551 - *location += sym->st_value - (uint32_t)location;
21552 + pax_open_kernel();
21553 + *plocation += sym->st_value - location;
21554 + pax_close_kernel();
21555 break;
21556 default:
21557 pr_err("%s: Unknown relocation: %u\n",
21558 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21559 case R_X86_64_NONE:
21560 break;
21561 case R_X86_64_64:
21562 + pax_open_kernel();
21563 *(u64 *)loc = val;
21564 + pax_close_kernel();
21565 break;
21566 case R_X86_64_32:
21567 + pax_open_kernel();
21568 *(u32 *)loc = val;
21569 + pax_close_kernel();
21570 if (val != *(u32 *)loc)
21571 goto overflow;
21572 break;
21573 case R_X86_64_32S:
21574 + pax_open_kernel();
21575 *(s32 *)loc = val;
21576 + pax_close_kernel();
21577 if ((s64)val != *(s32 *)loc)
21578 goto overflow;
21579 break;
21580 case R_X86_64_PC32:
21581 val -= (u64)loc;
21582 + pax_open_kernel();
21583 *(u32 *)loc = val;
21584 + pax_close_kernel();
21585 +
21586 #if 0
21587 if ((s64)val != *(s32 *)loc)
21588 goto overflow;
21589 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21590 index 4929502..686c291 100644
21591 --- a/arch/x86/kernel/msr.c
21592 +++ b/arch/x86/kernel/msr.c
21593 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21594 return notifier_from_errno(err);
21595 }
21596
21597 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21598 +static struct notifier_block msr_class_cpu_notifier = {
21599 .notifier_call = msr_class_cpu_callback,
21600 };
21601
21602 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21603 index f84f5c5..f404e81 100644
21604 --- a/arch/x86/kernel/nmi.c
21605 +++ b/arch/x86/kernel/nmi.c
21606 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21607 return handled;
21608 }
21609
21610 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21611 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21612 {
21613 struct nmi_desc *desc = nmi_to_desc(type);
21614 unsigned long flags;
21615 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21616 * event confuses some handlers (kdump uses this flag)
21617 */
21618 if (action->flags & NMI_FLAG_FIRST)
21619 - list_add_rcu(&action->list, &desc->head);
21620 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21621 else
21622 - list_add_tail_rcu(&action->list, &desc->head);
21623 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21624
21625 spin_unlock_irqrestore(&desc->lock, flags);
21626 return 0;
21627 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21628 if (!strcmp(n->name, name)) {
21629 WARN(in_nmi(),
21630 "Trying to free NMI (%s) from NMI context!\n", n->name);
21631 - list_del_rcu(&n->list);
21632 + pax_list_del_rcu((struct list_head *)&n->list);
21633 break;
21634 }
21635 }
21636 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21637 dotraplinkage notrace __kprobes void
21638 do_nmi(struct pt_regs *regs, long error_code)
21639 {
21640 +
21641 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21642 + if (!user_mode(regs)) {
21643 + unsigned long cs = regs->cs & 0xFFFF;
21644 + unsigned long ip = ktva_ktla(regs->ip);
21645 +
21646 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21647 + regs->ip = ip;
21648 + }
21649 +#endif
21650 +
21651 nmi_nesting_preprocess(regs);
21652
21653 nmi_enter();
21654 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21655 index 6d9582e..f746287 100644
21656 --- a/arch/x86/kernel/nmi_selftest.c
21657 +++ b/arch/x86/kernel/nmi_selftest.c
21658 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21659 {
21660 /* trap all the unknown NMIs we may generate */
21661 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21662 - __initdata);
21663 + __initconst);
21664 }
21665
21666 static void __init cleanup_nmi_testsuite(void)
21667 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21668 unsigned long timeout;
21669
21670 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21671 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21672 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21673 nmi_fail = FAILURE;
21674 return;
21675 }
21676 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21677 index 676b8c7..870ba04 100644
21678 --- a/arch/x86/kernel/paravirt-spinlocks.c
21679 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21680 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21681 arch_spin_lock(lock);
21682 }
21683
21684 -struct pv_lock_ops pv_lock_ops = {
21685 +struct pv_lock_ops pv_lock_ops __read_only = {
21686 #ifdef CONFIG_SMP
21687 .spin_is_locked = __ticket_spin_is_locked,
21688 .spin_is_contended = __ticket_spin_is_contended,
21689 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21690 index 17fff18..5cfa0f4 100644
21691 --- a/arch/x86/kernel/paravirt.c
21692 +++ b/arch/x86/kernel/paravirt.c
21693 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21694 {
21695 return x;
21696 }
21697 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21698 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21699 +#endif
21700
21701 void __init default_banner(void)
21702 {
21703 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21704 if (opfunc == NULL)
21705 /* If there's no function, patch it with a ud2a (BUG) */
21706 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21707 - else if (opfunc == _paravirt_nop)
21708 + else if (opfunc == (void *)_paravirt_nop)
21709 /* If the operation is a nop, then nop the callsite */
21710 ret = paravirt_patch_nop();
21711
21712 /* identity functions just return their single argument */
21713 - else if (opfunc == _paravirt_ident_32)
21714 + else if (opfunc == (void *)_paravirt_ident_32)
21715 ret = paravirt_patch_ident_32(insnbuf, len);
21716 - else if (opfunc == _paravirt_ident_64)
21717 + else if (opfunc == (void *)_paravirt_ident_64)
21718 ret = paravirt_patch_ident_64(insnbuf, len);
21719 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21720 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21721 + ret = paravirt_patch_ident_64(insnbuf, len);
21722 +#endif
21723
21724 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21725 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21726 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21727 if (insn_len > len || start == NULL)
21728 insn_len = len;
21729 else
21730 - memcpy(insnbuf, start, insn_len);
21731 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21732
21733 return insn_len;
21734 }
21735 @@ -304,7 +311,7 @@ void arch_flush_lazy_mmu_mode(void)
21736 preempt_enable();
21737 }
21738
21739 -struct pv_info pv_info = {
21740 +struct pv_info pv_info __read_only = {
21741 .name = "bare hardware",
21742 .paravirt_enabled = 0,
21743 .kernel_rpl = 0,
21744 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21745 #endif
21746 };
21747
21748 -struct pv_init_ops pv_init_ops = {
21749 +struct pv_init_ops pv_init_ops __read_only = {
21750 .patch = native_patch,
21751 };
21752
21753 -struct pv_time_ops pv_time_ops = {
21754 +struct pv_time_ops pv_time_ops __read_only = {
21755 .sched_clock = native_sched_clock,
21756 .steal_clock = native_steal_clock,
21757 };
21758
21759 -struct pv_irq_ops pv_irq_ops = {
21760 +struct pv_irq_ops pv_irq_ops __read_only = {
21761 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21762 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21763 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21764 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21765 #endif
21766 };
21767
21768 -struct pv_cpu_ops pv_cpu_ops = {
21769 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21770 .cpuid = native_cpuid,
21771 .get_debugreg = native_get_debugreg,
21772 .set_debugreg = native_set_debugreg,
21773 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21774 .end_context_switch = paravirt_nop,
21775 };
21776
21777 -struct pv_apic_ops pv_apic_ops = {
21778 +struct pv_apic_ops pv_apic_ops __read_only= {
21779 #ifdef CONFIG_X86_LOCAL_APIC
21780 .startup_ipi_hook = paravirt_nop,
21781 #endif
21782 };
21783
21784 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21785 +#ifdef CONFIG_X86_32
21786 +#ifdef CONFIG_X86_PAE
21787 +/* 64-bit pagetable entries */
21788 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21789 +#else
21790 /* 32-bit pagetable entries */
21791 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21792 +#endif
21793 #else
21794 /* 64-bit pagetable entries */
21795 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21796 #endif
21797
21798 -struct pv_mmu_ops pv_mmu_ops = {
21799 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21800
21801 .read_cr2 = native_read_cr2,
21802 .write_cr2 = native_write_cr2,
21803 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21804 .make_pud = PTE_IDENT,
21805
21806 .set_pgd = native_set_pgd,
21807 + .set_pgd_batched = native_set_pgd_batched,
21808 #endif
21809 #endif /* PAGETABLE_LEVELS >= 3 */
21810
21811 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21812 },
21813
21814 .set_fixmap = native_set_fixmap,
21815 +
21816 +#ifdef CONFIG_PAX_KERNEXEC
21817 + .pax_open_kernel = native_pax_open_kernel,
21818 + .pax_close_kernel = native_pax_close_kernel,
21819 +#endif
21820 +
21821 };
21822
21823 EXPORT_SYMBOL_GPL(pv_time_ops);
21824 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21825 index 35ccf75..7a15747 100644
21826 --- a/arch/x86/kernel/pci-iommu_table.c
21827 +++ b/arch/x86/kernel/pci-iommu_table.c
21828 @@ -2,7 +2,7 @@
21829 #include <asm/iommu_table.h>
21830 #include <linux/string.h>
21831 #include <linux/kallsyms.h>
21832 -
21833 +#include <linux/sched.h>
21834
21835 #define DEBUG 1
21836
21837 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
21838 index 6c483ba..d10ce2f 100644
21839 --- a/arch/x86/kernel/pci-swiotlb.c
21840 +++ b/arch/x86/kernel/pci-swiotlb.c
21841 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
21842 void *vaddr, dma_addr_t dma_addr,
21843 struct dma_attrs *attrs)
21844 {
21845 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
21846 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
21847 }
21848
21849 static struct dma_map_ops swiotlb_dma_ops = {
21850 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
21851 index 2ed787f..f70c9f6 100644
21852 --- a/arch/x86/kernel/process.c
21853 +++ b/arch/x86/kernel/process.c
21854 @@ -36,7 +36,8 @@
21855 * section. Since TSS's are completely CPU-local, we want them
21856 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
21857 */
21858 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
21859 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
21860 +EXPORT_SYMBOL(init_tss);
21861
21862 #ifdef CONFIG_X86_64
21863 static DEFINE_PER_CPU(unsigned char, is_idle);
21864 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
21865 task_xstate_cachep =
21866 kmem_cache_create("task_xstate", xstate_size,
21867 __alignof__(union thread_xstate),
21868 - SLAB_PANIC | SLAB_NOTRACK, NULL);
21869 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
21870 }
21871
21872 /*
21873 @@ -105,7 +106,7 @@ void exit_thread(void)
21874 unsigned long *bp = t->io_bitmap_ptr;
21875
21876 if (bp) {
21877 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
21878 + struct tss_struct *tss = init_tss + get_cpu();
21879
21880 t->io_bitmap_ptr = NULL;
21881 clear_thread_flag(TIF_IO_BITMAP);
21882 @@ -136,7 +137,7 @@ void show_regs_common(void)
21883 board = dmi_get_system_info(DMI_BOARD_NAME);
21884
21885 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
21886 - current->pid, current->comm, print_tainted(),
21887 + task_pid_nr(current), current->comm, print_tainted(),
21888 init_utsname()->release,
21889 (int)strcspn(init_utsname()->version, " "),
21890 init_utsname()->version,
21891 @@ -149,6 +150,9 @@ void flush_thread(void)
21892 {
21893 struct task_struct *tsk = current;
21894
21895 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21896 + loadsegment(gs, 0);
21897 +#endif
21898 flush_ptrace_hw_breakpoint(tsk);
21899 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
21900 drop_init_fpu(tsk);
21901 @@ -301,7 +305,7 @@ static void __exit_idle(void)
21902 void exit_idle(void)
21903 {
21904 /* idle loop has pid 0 */
21905 - if (current->pid)
21906 + if (task_pid_nr(current))
21907 return;
21908 __exit_idle();
21909 }
21910 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
21911
21912 return ret;
21913 }
21914 -void stop_this_cpu(void *dummy)
21915 +__noreturn void stop_this_cpu(void *dummy)
21916 {
21917 local_irq_disable();
21918 /*
21919 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
21920 }
21921 early_param("idle", idle_setup);
21922
21923 -unsigned long arch_align_stack(unsigned long sp)
21924 +#ifdef CONFIG_PAX_RANDKSTACK
21925 +void pax_randomize_kstack(struct pt_regs *regs)
21926 {
21927 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
21928 - sp -= get_random_int() % 8192;
21929 - return sp & ~0xf;
21930 -}
21931 + struct thread_struct *thread = &current->thread;
21932 + unsigned long time;
21933
21934 -unsigned long arch_randomize_brk(struct mm_struct *mm)
21935 -{
21936 - unsigned long range_end = mm->brk + 0x02000000;
21937 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
21938 -}
21939 + if (!randomize_va_space)
21940 + return;
21941 +
21942 + if (v8086_mode(regs))
21943 + return;
21944
21945 + rdtscl(time);
21946 +
21947 + /* P4 seems to return a 0 LSB, ignore it */
21948 +#ifdef CONFIG_MPENTIUM4
21949 + time &= 0x3EUL;
21950 + time <<= 2;
21951 +#elif defined(CONFIG_X86_64)
21952 + time &= 0xFUL;
21953 + time <<= 4;
21954 +#else
21955 + time &= 0x1FUL;
21956 + time <<= 3;
21957 +#endif
21958 +
21959 + thread->sp0 ^= time;
21960 + load_sp0(init_tss + smp_processor_id(), thread);
21961 +
21962 +#ifdef CONFIG_X86_64
21963 + this_cpu_write(kernel_stack, thread->sp0);
21964 +#endif
21965 +}
21966 +#endif
21967 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
21968 index b5a8905..d9cacac 100644
21969 --- a/arch/x86/kernel/process_32.c
21970 +++ b/arch/x86/kernel/process_32.c
21971 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
21972 unsigned long thread_saved_pc(struct task_struct *tsk)
21973 {
21974 return ((unsigned long *)tsk->thread.sp)[3];
21975 +//XXX return tsk->thread.eip;
21976 }
21977
21978 void __show_regs(struct pt_regs *regs, int all)
21979 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
21980 unsigned long sp;
21981 unsigned short ss, gs;
21982
21983 - if (user_mode_vm(regs)) {
21984 + if (user_mode(regs)) {
21985 sp = regs->sp;
21986 ss = regs->ss & 0xffff;
21987 - gs = get_user_gs(regs);
21988 } else {
21989 sp = kernel_stack_pointer(regs);
21990 savesegment(ss, ss);
21991 - savesegment(gs, gs);
21992 }
21993 + gs = get_user_gs(regs);
21994
21995 show_regs_common();
21996
21997 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
21998 (u16)regs->cs, regs->ip, regs->flags,
21999 - smp_processor_id());
22000 + raw_smp_processor_id());
22001 print_symbol("EIP is at %s\n", regs->ip);
22002
22003 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22004 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22005 int copy_thread(unsigned long clone_flags, unsigned long sp,
22006 unsigned long arg, struct task_struct *p)
22007 {
22008 - struct pt_regs *childregs = task_pt_regs(p);
22009 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22010 struct task_struct *tsk;
22011 int err;
22012
22013 p->thread.sp = (unsigned long) childregs;
22014 p->thread.sp0 = (unsigned long) (childregs+1);
22015 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22016
22017 if (unlikely(p->flags & PF_KTHREAD)) {
22018 /* kernel thread */
22019 memset(childregs, 0, sizeof(struct pt_regs));
22020 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22021 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22022 - childregs->ds = __USER_DS;
22023 - childregs->es = __USER_DS;
22024 + savesegment(gs, childregs->gs);
22025 + childregs->ds = __KERNEL_DS;
22026 + childregs->es = __KERNEL_DS;
22027 childregs->fs = __KERNEL_PERCPU;
22028 childregs->bx = sp; /* function */
22029 childregs->bp = arg;
22030 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22031 struct thread_struct *prev = &prev_p->thread,
22032 *next = &next_p->thread;
22033 int cpu = smp_processor_id();
22034 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22035 + struct tss_struct *tss = init_tss + cpu;
22036 fpu_switch_t fpu;
22037
22038 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22039 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22040 */
22041 lazy_save_gs(prev->gs);
22042
22043 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22044 + __set_fs(task_thread_info(next_p)->addr_limit);
22045 +#endif
22046 +
22047 /*
22048 * Load the per-thread Thread-Local Storage descriptor.
22049 */
22050 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22051 */
22052 arch_end_context_switch(next_p);
22053
22054 + this_cpu_write(current_task, next_p);
22055 + this_cpu_write(current_tinfo, &next_p->tinfo);
22056 +
22057 /*
22058 * Restore %gs if needed (which is common)
22059 */
22060 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22061
22062 switch_fpu_finish(next_p, fpu);
22063
22064 - this_cpu_write(current_task, next_p);
22065 -
22066 return prev_p;
22067 }
22068
22069 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22070 } while (count++ < 16);
22071 return 0;
22072 }
22073 -
22074 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22075 index 6e68a61..955a9a5 100644
22076 --- a/arch/x86/kernel/process_64.c
22077 +++ b/arch/x86/kernel/process_64.c
22078 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22079 struct pt_regs *childregs;
22080 struct task_struct *me = current;
22081
22082 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22083 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22084 childregs = task_pt_regs(p);
22085 p->thread.sp = (unsigned long) childregs;
22086 p->thread.usersp = me->thread.usersp;
22087 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22088 set_tsk_thread_flag(p, TIF_FORK);
22089 p->fpu_counter = 0;
22090 p->thread.io_bitmap_ptr = NULL;
22091 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22092 struct thread_struct *prev = &prev_p->thread;
22093 struct thread_struct *next = &next_p->thread;
22094 int cpu = smp_processor_id();
22095 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22096 + struct tss_struct *tss = init_tss + cpu;
22097 unsigned fsindex, gsindex;
22098 fpu_switch_t fpu;
22099
22100 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22101 prev->usersp = this_cpu_read(old_rsp);
22102 this_cpu_write(old_rsp, next->usersp);
22103 this_cpu_write(current_task, next_p);
22104 + this_cpu_write(current_tinfo, &next_p->tinfo);
22105
22106 - this_cpu_write(kernel_stack,
22107 - (unsigned long)task_stack_page(next_p) +
22108 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22109 + this_cpu_write(kernel_stack, next->sp0);
22110
22111 /*
22112 * Now maybe reload the debug registers and handle I/O bitmaps
22113 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22114 if (!p || p == current || p->state == TASK_RUNNING)
22115 return 0;
22116 stack = (unsigned long)task_stack_page(p);
22117 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22118 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22119 return 0;
22120 fp = *(u64 *)(p->thread.sp);
22121 do {
22122 - if (fp < (unsigned long)stack ||
22123 - fp >= (unsigned long)stack+THREAD_SIZE)
22124 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22125 return 0;
22126 ip = *(u64 *)(fp+8);
22127 if (!in_sched_functions(ip))
22128 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22129 index b629bbe..0fa615a 100644
22130 --- a/arch/x86/kernel/ptrace.c
22131 +++ b/arch/x86/kernel/ptrace.c
22132 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22133 {
22134 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22135 unsigned long sp = (unsigned long)&regs->sp;
22136 - struct thread_info *tinfo;
22137
22138 - if (context == (sp & ~(THREAD_SIZE - 1)))
22139 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22140 return sp;
22141
22142 - tinfo = (struct thread_info *)context;
22143 - if (tinfo->previous_esp)
22144 - return tinfo->previous_esp;
22145 + sp = *(unsigned long *)context;
22146 + if (sp)
22147 + return sp;
22148
22149 return (unsigned long)regs;
22150 }
22151 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22152 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22153 {
22154 int i;
22155 - int dr7 = 0;
22156 + unsigned long dr7 = 0;
22157 struct arch_hw_breakpoint *info;
22158
22159 for (i = 0; i < HBP_NUM; i++) {
22160 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22161 unsigned long addr, unsigned long data)
22162 {
22163 int ret;
22164 - unsigned long __user *datap = (unsigned long __user *)data;
22165 + unsigned long __user *datap = (__force unsigned long __user *)data;
22166
22167 switch (request) {
22168 /* read the word at location addr in the USER area. */
22169 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22170 if ((int) addr < 0)
22171 return -EIO;
22172 ret = do_get_thread_area(child, addr,
22173 - (struct user_desc __user *)data);
22174 + (__force struct user_desc __user *) data);
22175 break;
22176
22177 case PTRACE_SET_THREAD_AREA:
22178 if ((int) addr < 0)
22179 return -EIO;
22180 ret = do_set_thread_area(child, addr,
22181 - (struct user_desc __user *)data, 0);
22182 + (__force struct user_desc __user *) data, 0);
22183 break;
22184 #endif
22185
22186 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22187
22188 #ifdef CONFIG_X86_64
22189
22190 -static struct user_regset x86_64_regsets[] __read_mostly = {
22191 +static user_regset_no_const x86_64_regsets[] __read_only = {
22192 [REGSET_GENERAL] = {
22193 .core_note_type = NT_PRSTATUS,
22194 .n = sizeof(struct user_regs_struct) / sizeof(long),
22195 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22196 #endif /* CONFIG_X86_64 */
22197
22198 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22199 -static struct user_regset x86_32_regsets[] __read_mostly = {
22200 +static user_regset_no_const x86_32_regsets[] __read_only = {
22201 [REGSET_GENERAL] = {
22202 .core_note_type = NT_PRSTATUS,
22203 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22204 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22205 */
22206 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22207
22208 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22209 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22210 {
22211 #ifdef CONFIG_X86_64
22212 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22213 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22214 memset(info, 0, sizeof(*info));
22215 info->si_signo = SIGTRAP;
22216 info->si_code = si_code;
22217 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22218 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22219 }
22220
22221 void user_single_step_siginfo(struct task_struct *tsk,
22222 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22223 # define IS_IA32 0
22224 #endif
22225
22226 +#ifdef CONFIG_GRKERNSEC_SETXID
22227 +extern void gr_delayed_cred_worker(void);
22228 +#endif
22229 +
22230 /*
22231 * We must return the syscall number to actually look up in the table.
22232 * This can be -1L to skip running any syscall at all.
22233 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22234
22235 user_exit();
22236
22237 +#ifdef CONFIG_GRKERNSEC_SETXID
22238 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22239 + gr_delayed_cred_worker();
22240 +#endif
22241 +
22242 /*
22243 * If we stepped into a sysenter/syscall insn, it trapped in
22244 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22245 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22246 */
22247 user_exit();
22248
22249 +#ifdef CONFIG_GRKERNSEC_SETXID
22250 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22251 + gr_delayed_cred_worker();
22252 +#endif
22253 +
22254 audit_syscall_exit(regs);
22255
22256 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22257 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22258 index 2cb9470..ff1fd80 100644
22259 --- a/arch/x86/kernel/pvclock.c
22260 +++ b/arch/x86/kernel/pvclock.c
22261 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22262 return pv_tsc_khz;
22263 }
22264
22265 -static atomic64_t last_value = ATOMIC64_INIT(0);
22266 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22267
22268 void pvclock_resume(void)
22269 {
22270 - atomic64_set(&last_value, 0);
22271 + atomic64_set_unchecked(&last_value, 0);
22272 }
22273
22274 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22275 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22276 * updating at the same time, and one of them could be slightly behind,
22277 * making the assumption that last_value always go forward fail to hold.
22278 */
22279 - last = atomic64_read(&last_value);
22280 + last = atomic64_read_unchecked(&last_value);
22281 do {
22282 if (ret < last)
22283 return last;
22284 - last = atomic64_cmpxchg(&last_value, last, ret);
22285 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22286 } while (unlikely(last != ret));
22287
22288 return ret;
22289 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22290 index 76fa1e9..abf09ea 100644
22291 --- a/arch/x86/kernel/reboot.c
22292 +++ b/arch/x86/kernel/reboot.c
22293 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22294 EXPORT_SYMBOL(pm_power_off);
22295
22296 static const struct desc_ptr no_idt = {};
22297 -static int reboot_mode;
22298 +static unsigned short reboot_mode;
22299 enum reboot_type reboot_type = BOOT_ACPI;
22300 int reboot_force;
22301
22302 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22303
22304 void __noreturn machine_real_restart(unsigned int type)
22305 {
22306 +
22307 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22308 + struct desc_struct *gdt;
22309 +#endif
22310 +
22311 local_irq_disable();
22312
22313 /*
22314 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22315
22316 /* Jump to the identity-mapped low memory code */
22317 #ifdef CONFIG_X86_32
22318 - asm volatile("jmpl *%0" : :
22319 +
22320 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22321 + gdt = get_cpu_gdt_table(smp_processor_id());
22322 + pax_open_kernel();
22323 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22324 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22325 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22326 + loadsegment(ds, __KERNEL_DS);
22327 + loadsegment(es, __KERNEL_DS);
22328 + loadsegment(ss, __KERNEL_DS);
22329 +#endif
22330 +#ifdef CONFIG_PAX_KERNEXEC
22331 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22332 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22333 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22334 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22335 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22336 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22337 +#endif
22338 + pax_close_kernel();
22339 +#endif
22340 +
22341 + asm volatile("ljmpl *%0" : :
22342 "rm" (real_mode_header->machine_real_restart_asm),
22343 "a" (type));
22344 #else
22345 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22346 * try to force a triple fault and then cycle between hitting the keyboard
22347 * controller and doing that
22348 */
22349 -static void native_machine_emergency_restart(void)
22350 +static void __noreturn native_machine_emergency_restart(void)
22351 {
22352 int i;
22353 int attempt = 0;
22354 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22355 #endif
22356 }
22357
22358 -static void __machine_emergency_restart(int emergency)
22359 +static void __noreturn __machine_emergency_restart(int emergency)
22360 {
22361 reboot_emergency = emergency;
22362 machine_ops.emergency_restart();
22363 }
22364
22365 -static void native_machine_restart(char *__unused)
22366 +static void __noreturn native_machine_restart(char *__unused)
22367 {
22368 pr_notice("machine restart\n");
22369
22370 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22371 __machine_emergency_restart(0);
22372 }
22373
22374 -static void native_machine_halt(void)
22375 +static void __noreturn native_machine_halt(void)
22376 {
22377 /* Stop other cpus and apics */
22378 machine_shutdown();
22379 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22380 stop_this_cpu(NULL);
22381 }
22382
22383 -static void native_machine_power_off(void)
22384 +static void __noreturn native_machine_power_off(void)
22385 {
22386 if (pm_power_off) {
22387 if (!reboot_force)
22388 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22389 }
22390 /* A fallback in case there is no PM info available */
22391 tboot_shutdown(TB_SHUTDOWN_HALT);
22392 + unreachable();
22393 }
22394
22395 -struct machine_ops machine_ops = {
22396 +struct machine_ops machine_ops __read_only = {
22397 .power_off = native_machine_power_off,
22398 .shutdown = native_machine_shutdown,
22399 .emergency_restart = native_machine_emergency_restart,
22400 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22401 index 7a6f3b3..bed145d7 100644
22402 --- a/arch/x86/kernel/relocate_kernel_64.S
22403 +++ b/arch/x86/kernel/relocate_kernel_64.S
22404 @@ -11,6 +11,7 @@
22405 #include <asm/kexec.h>
22406 #include <asm/processor-flags.h>
22407 #include <asm/pgtable_types.h>
22408 +#include <asm/alternative-asm.h>
22409
22410 /*
22411 * Must be relocatable PIC code callable as a C function
22412 @@ -160,13 +161,14 @@ identity_mapped:
22413 xorq %rbp, %rbp
22414 xorq %r8, %r8
22415 xorq %r9, %r9
22416 - xorq %r10, %r9
22417 + xorq %r10, %r10
22418 xorq %r11, %r11
22419 xorq %r12, %r12
22420 xorq %r13, %r13
22421 xorq %r14, %r14
22422 xorq %r15, %r15
22423
22424 + pax_force_retaddr 0, 1
22425 ret
22426
22427 1:
22428 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22429 index 8b24289..d37b58b 100644
22430 --- a/arch/x86/kernel/setup.c
22431 +++ b/arch/x86/kernel/setup.c
22432 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
22433
22434 switch (data->type) {
22435 case SETUP_E820_EXT:
22436 - parse_e820_ext(data);
22437 + parse_e820_ext((struct setup_data __force_kernel *)data);
22438 break;
22439 case SETUP_DTB:
22440 add_dtb(pa_data);
22441 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
22442 * area (640->1Mb) as ram even though it is not.
22443 * take them out.
22444 */
22445 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22446 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22447
22448 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22449 }
22450 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
22451
22452 if (!boot_params.hdr.root_flags)
22453 root_mountflags &= ~MS_RDONLY;
22454 - init_mm.start_code = (unsigned long) _text;
22455 - init_mm.end_code = (unsigned long) _etext;
22456 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22457 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22458 init_mm.end_data = (unsigned long) _edata;
22459 init_mm.brk = _brk_end;
22460
22461 - code_resource.start = virt_to_phys(_text);
22462 - code_resource.end = virt_to_phys(_etext)-1;
22463 - data_resource.start = virt_to_phys(_etext);
22464 + code_resource.start = virt_to_phys(ktla_ktva(_text));
22465 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
22466 + data_resource.start = virt_to_phys(_sdata);
22467 data_resource.end = virt_to_phys(_edata)-1;
22468 bss_resource.start = virt_to_phys(&__bss_start);
22469 bss_resource.end = virt_to_phys(&__bss_stop)-1;
22470 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22471 index 5cdff03..80fa283 100644
22472 --- a/arch/x86/kernel/setup_percpu.c
22473 +++ b/arch/x86/kernel/setup_percpu.c
22474 @@ -21,19 +21,17 @@
22475 #include <asm/cpu.h>
22476 #include <asm/stackprotector.h>
22477
22478 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22479 +#ifdef CONFIG_SMP
22480 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22481 EXPORT_PER_CPU_SYMBOL(cpu_number);
22482 +#endif
22483
22484 -#ifdef CONFIG_X86_64
22485 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22486 -#else
22487 -#define BOOT_PERCPU_OFFSET 0
22488 -#endif
22489
22490 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22491 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22492
22493 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22494 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22495 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22496 };
22497 EXPORT_SYMBOL(__per_cpu_offset);
22498 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22499 {
22500 #ifdef CONFIG_NEED_MULTIPLE_NODES
22501 pg_data_t *last = NULL;
22502 - unsigned int cpu;
22503 + int cpu;
22504
22505 for_each_possible_cpu(cpu) {
22506 int node = early_cpu_to_node(cpu);
22507 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22508 {
22509 #ifdef CONFIG_X86_32
22510 struct desc_struct gdt;
22511 + unsigned long base = per_cpu_offset(cpu);
22512
22513 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22514 - 0x2 | DESCTYPE_S, 0x8);
22515 - gdt.s = 1;
22516 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22517 + 0x83 | DESCTYPE_S, 0xC);
22518 write_gdt_entry(get_cpu_gdt_table(cpu),
22519 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22520 #endif
22521 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22522 /* alrighty, percpu areas up and running */
22523 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22524 for_each_possible_cpu(cpu) {
22525 +#ifdef CONFIG_CC_STACKPROTECTOR
22526 +#ifdef CONFIG_X86_32
22527 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22528 +#endif
22529 +#endif
22530 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22531 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22532 per_cpu(cpu_number, cpu) = cpu;
22533 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22534 */
22535 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22536 #endif
22537 +#ifdef CONFIG_CC_STACKPROTECTOR
22538 +#ifdef CONFIG_X86_32
22539 + if (!cpu)
22540 + per_cpu(stack_canary.canary, cpu) = canary;
22541 +#endif
22542 +#endif
22543 /*
22544 * Up to this point, the boot CPU has been using .init.data
22545 * area. Reload any changed state for the boot CPU.
22546 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22547 index d6bf1f3..3ffce5a 100644
22548 --- a/arch/x86/kernel/signal.c
22549 +++ b/arch/x86/kernel/signal.c
22550 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22551 * Align the stack pointer according to the i386 ABI,
22552 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22553 */
22554 - sp = ((sp + 4) & -16ul) - 4;
22555 + sp = ((sp - 12) & -16ul) - 4;
22556 #else /* !CONFIG_X86_32 */
22557 sp = round_down(sp, 16) - 8;
22558 #endif
22559 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22560 }
22561
22562 if (current->mm->context.vdso)
22563 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22564 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22565 else
22566 - restorer = &frame->retcode;
22567 + restorer = (void __user *)&frame->retcode;
22568 if (ka->sa.sa_flags & SA_RESTORER)
22569 restorer = ka->sa.sa_restorer;
22570
22571 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22572 * reasons and because gdb uses it as a signature to notice
22573 * signal handler stack frames.
22574 */
22575 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22576 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22577
22578 if (err)
22579 return -EFAULT;
22580 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22581 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22582
22583 /* Set up to return from userspace. */
22584 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22585 + if (current->mm->context.vdso)
22586 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22587 + else
22588 + restorer = (void __user *)&frame->retcode;
22589 if (ka->sa.sa_flags & SA_RESTORER)
22590 restorer = ka->sa.sa_restorer;
22591 put_user_ex(restorer, &frame->pretcode);
22592 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22593 * reasons and because gdb uses it as a signature to notice
22594 * signal handler stack frames.
22595 */
22596 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22597 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22598 } put_user_catch(err);
22599
22600 err |= copy_siginfo_to_user(&frame->info, info);
22601 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22602 index 48d2b7d..90d328a 100644
22603 --- a/arch/x86/kernel/smp.c
22604 +++ b/arch/x86/kernel/smp.c
22605 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22606
22607 __setup("nonmi_ipi", nonmi_ipi_setup);
22608
22609 -struct smp_ops smp_ops = {
22610 +struct smp_ops smp_ops __read_only = {
22611 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22612 .smp_prepare_cpus = native_smp_prepare_cpus,
22613 .smp_cpus_done = native_smp_cpus_done,
22614 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22615 index ed0fe38..87fc692 100644
22616 --- a/arch/x86/kernel/smpboot.c
22617 +++ b/arch/x86/kernel/smpboot.c
22618 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22619 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22620 (THREAD_SIZE + task_stack_page(idle))) - 1);
22621 per_cpu(current_task, cpu) = idle;
22622 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22623
22624 #ifdef CONFIG_X86_32
22625 /* Stack for startup_32 can be just as for start_secondary onwards */
22626 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22627 #else
22628 clear_tsk_thread_flag(idle, TIF_FORK);
22629 initial_gs = per_cpu_offset(cpu);
22630 - per_cpu(kernel_stack, cpu) =
22631 - (unsigned long)task_stack_page(idle) -
22632 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22633 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22634 #endif
22635 +
22636 + pax_open_kernel();
22637 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22638 + pax_close_kernel();
22639 +
22640 initial_code = (unsigned long)start_secondary;
22641 stack_start = idle->thread.sp;
22642
22643 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22644 /* the FPU context is blank, nobody can own it */
22645 __cpu_disable_lazy_restore(cpu);
22646
22647 +#ifdef CONFIG_PAX_PER_CPU_PGD
22648 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22649 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22650 + KERNEL_PGD_PTRS);
22651 +#endif
22652 +
22653 + /* the FPU context is blank, nobody can own it */
22654 + __cpu_disable_lazy_restore(cpu);
22655 +
22656 err = do_boot_cpu(apicid, cpu, tidle);
22657 if (err) {
22658 pr_debug("do_boot_cpu failed %d\n", err);
22659 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22660 index 9b4d51d..5d28b58 100644
22661 --- a/arch/x86/kernel/step.c
22662 +++ b/arch/x86/kernel/step.c
22663 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22664 struct desc_struct *desc;
22665 unsigned long base;
22666
22667 - seg &= ~7UL;
22668 + seg >>= 3;
22669
22670 mutex_lock(&child->mm->context.lock);
22671 - if (unlikely((seg >> 3) >= child->mm->context.size))
22672 + if (unlikely(seg >= child->mm->context.size))
22673 addr = -1L; /* bogus selector, access would fault */
22674 else {
22675 desc = child->mm->context.ldt + seg;
22676 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22677 addr += base;
22678 }
22679 mutex_unlock(&child->mm->context.lock);
22680 - }
22681 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22682 + addr = ktla_ktva(addr);
22683
22684 return addr;
22685 }
22686 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22687 unsigned char opcode[15];
22688 unsigned long addr = convert_ip_to_linear(child, regs);
22689
22690 + if (addr == -EINVAL)
22691 + return 0;
22692 +
22693 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22694 for (i = 0; i < copied; i++) {
22695 switch (opcode[i]) {
22696 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22697 new file mode 100644
22698 index 0000000..207bec6
22699 --- /dev/null
22700 +++ b/arch/x86/kernel/sys_i386_32.c
22701 @@ -0,0 +1,250 @@
22702 +/*
22703 + * This file contains various random system calls that
22704 + * have a non-standard calling sequence on the Linux/i386
22705 + * platform.
22706 + */
22707 +
22708 +#include <linux/errno.h>
22709 +#include <linux/sched.h>
22710 +#include <linux/mm.h>
22711 +#include <linux/fs.h>
22712 +#include <linux/smp.h>
22713 +#include <linux/sem.h>
22714 +#include <linux/msg.h>
22715 +#include <linux/shm.h>
22716 +#include <linux/stat.h>
22717 +#include <linux/syscalls.h>
22718 +#include <linux/mman.h>
22719 +#include <linux/file.h>
22720 +#include <linux/utsname.h>
22721 +#include <linux/ipc.h>
22722 +
22723 +#include <linux/uaccess.h>
22724 +#include <linux/unistd.h>
22725 +
22726 +#include <asm/syscalls.h>
22727 +
22728 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22729 +{
22730 + unsigned long pax_task_size = TASK_SIZE;
22731 +
22732 +#ifdef CONFIG_PAX_SEGMEXEC
22733 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22734 + pax_task_size = SEGMEXEC_TASK_SIZE;
22735 +#endif
22736 +
22737 + if (flags & MAP_FIXED)
22738 + if (len > pax_task_size || addr > pax_task_size - len)
22739 + return -EINVAL;
22740 +
22741 + return 0;
22742 +}
22743 +
22744 +unsigned long
22745 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22746 + unsigned long len, unsigned long pgoff, unsigned long flags)
22747 +{
22748 + struct mm_struct *mm = current->mm;
22749 + struct vm_area_struct *vma;
22750 + unsigned long start_addr, pax_task_size = TASK_SIZE;
22751 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22752 +
22753 +#ifdef CONFIG_PAX_SEGMEXEC
22754 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22755 + pax_task_size = SEGMEXEC_TASK_SIZE;
22756 +#endif
22757 +
22758 + pax_task_size -= PAGE_SIZE;
22759 +
22760 + if (len > pax_task_size)
22761 + return -ENOMEM;
22762 +
22763 + if (flags & MAP_FIXED)
22764 + return addr;
22765 +
22766 +#ifdef CONFIG_PAX_RANDMMAP
22767 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22768 +#endif
22769 +
22770 + if (addr) {
22771 + addr = PAGE_ALIGN(addr);
22772 + if (pax_task_size - len >= addr) {
22773 + vma = find_vma(mm, addr);
22774 + if (check_heap_stack_gap(vma, addr, len, offset))
22775 + return addr;
22776 + }
22777 + }
22778 + if (len > mm->cached_hole_size) {
22779 + start_addr = addr = mm->free_area_cache;
22780 + } else {
22781 + start_addr = addr = mm->mmap_base;
22782 + mm->cached_hole_size = 0;
22783 + }
22784 +
22785 +#ifdef CONFIG_PAX_PAGEEXEC
22786 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
22787 + start_addr = 0x00110000UL;
22788 +
22789 +#ifdef CONFIG_PAX_RANDMMAP
22790 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22791 + start_addr += mm->delta_mmap & 0x03FFF000UL;
22792 +#endif
22793 +
22794 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
22795 + start_addr = addr = mm->mmap_base;
22796 + else
22797 + addr = start_addr;
22798 + }
22799 +#endif
22800 +
22801 +full_search:
22802 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
22803 + /* At this point: (!vma || addr < vma->vm_end). */
22804 + if (pax_task_size - len < addr) {
22805 + /*
22806 + * Start a new search - just in case we missed
22807 + * some holes.
22808 + */
22809 + if (start_addr != mm->mmap_base) {
22810 + start_addr = addr = mm->mmap_base;
22811 + mm->cached_hole_size = 0;
22812 + goto full_search;
22813 + }
22814 + return -ENOMEM;
22815 + }
22816 + if (check_heap_stack_gap(vma, addr, len, offset))
22817 + break;
22818 + if (addr + mm->cached_hole_size < vma->vm_start)
22819 + mm->cached_hole_size = vma->vm_start - addr;
22820 + addr = vma->vm_end;
22821 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
22822 + start_addr = addr = mm->mmap_base;
22823 + mm->cached_hole_size = 0;
22824 + goto full_search;
22825 + }
22826 + }
22827 +
22828 + /*
22829 + * Remember the place where we stopped the search:
22830 + */
22831 + mm->free_area_cache = addr + len;
22832 + return addr;
22833 +}
22834 +
22835 +unsigned long
22836 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
22837 + const unsigned long len, const unsigned long pgoff,
22838 + const unsigned long flags)
22839 +{
22840 + struct vm_area_struct *vma;
22841 + struct mm_struct *mm = current->mm;
22842 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
22843 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22844 +
22845 +#ifdef CONFIG_PAX_SEGMEXEC
22846 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22847 + pax_task_size = SEGMEXEC_TASK_SIZE;
22848 +#endif
22849 +
22850 + pax_task_size -= PAGE_SIZE;
22851 +
22852 + /* requested length too big for entire address space */
22853 + if (len > pax_task_size)
22854 + return -ENOMEM;
22855 +
22856 + if (flags & MAP_FIXED)
22857 + return addr;
22858 +
22859 +#ifdef CONFIG_PAX_PAGEEXEC
22860 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
22861 + goto bottomup;
22862 +#endif
22863 +
22864 +#ifdef CONFIG_PAX_RANDMMAP
22865 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22866 +#endif
22867 +
22868 + /* requesting a specific address */
22869 + if (addr) {
22870 + addr = PAGE_ALIGN(addr);
22871 + if (pax_task_size - len >= addr) {
22872 + vma = find_vma(mm, addr);
22873 + if (check_heap_stack_gap(vma, addr, len, offset))
22874 + return addr;
22875 + }
22876 + }
22877 +
22878 + /* check if free_area_cache is useful for us */
22879 + if (len <= mm->cached_hole_size) {
22880 + mm->cached_hole_size = 0;
22881 + mm->free_area_cache = mm->mmap_base;
22882 + }
22883 +
22884 + /* either no address requested or can't fit in requested address hole */
22885 + addr = mm->free_area_cache;
22886 +
22887 + /* make sure it can fit in the remaining address space */
22888 + if (addr > len) {
22889 + vma = find_vma(mm, addr-len);
22890 + if (check_heap_stack_gap(vma, addr - len, len, offset))
22891 + /* remember the address as a hint for next time */
22892 + return (mm->free_area_cache = addr-len);
22893 + }
22894 +
22895 + if (mm->mmap_base < len)
22896 + goto bottomup;
22897 +
22898 + addr = mm->mmap_base-len;
22899 +
22900 + do {
22901 + /*
22902 + * Lookup failure means no vma is above this address,
22903 + * else if new region fits below vma->vm_start,
22904 + * return with success:
22905 + */
22906 + vma = find_vma(mm, addr);
22907 + if (check_heap_stack_gap(vma, addr, len, offset))
22908 + /* remember the address as a hint for next time */
22909 + return (mm->free_area_cache = addr);
22910 +
22911 + /* remember the largest hole we saw so far */
22912 + if (addr + mm->cached_hole_size < vma->vm_start)
22913 + mm->cached_hole_size = vma->vm_start - addr;
22914 +
22915 + /* try just below the current vma->vm_start */
22916 + addr = skip_heap_stack_gap(vma, len, offset);
22917 + } while (!IS_ERR_VALUE(addr));
22918 +
22919 +bottomup:
22920 + /*
22921 + * A failed mmap() very likely causes application failure,
22922 + * so fall back to the bottom-up function here. This scenario
22923 + * can happen with large stack limits and large mmap()
22924 + * allocations.
22925 + */
22926 +
22927 +#ifdef CONFIG_PAX_SEGMEXEC
22928 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22929 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
22930 + else
22931 +#endif
22932 +
22933 + mm->mmap_base = TASK_UNMAPPED_BASE;
22934 +
22935 +#ifdef CONFIG_PAX_RANDMMAP
22936 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22937 + mm->mmap_base += mm->delta_mmap;
22938 +#endif
22939 +
22940 + mm->free_area_cache = mm->mmap_base;
22941 + mm->cached_hole_size = ~0UL;
22942 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
22943 + /*
22944 + * Restore the topdown base:
22945 + */
22946 + mm->mmap_base = base;
22947 + mm->free_area_cache = base;
22948 + mm->cached_hole_size = ~0UL;
22949 +
22950 + return addr;
22951 +}
22952 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
22953 index 97ef74b..57a1882 100644
22954 --- a/arch/x86/kernel/sys_x86_64.c
22955 +++ b/arch/x86/kernel/sys_x86_64.c
22956 @@ -81,8 +81,8 @@ out:
22957 return error;
22958 }
22959
22960 -static void find_start_end(unsigned long flags, unsigned long *begin,
22961 - unsigned long *end)
22962 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
22963 + unsigned long *begin, unsigned long *end)
22964 {
22965 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
22966 unsigned long new_begin;
22967 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
22968 *begin = new_begin;
22969 }
22970 } else {
22971 - *begin = TASK_UNMAPPED_BASE;
22972 + *begin = mm->mmap_base;
22973 *end = TASK_SIZE;
22974 }
22975 }
22976 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
22977 struct vm_area_struct *vma;
22978 struct vm_unmapped_area_info info;
22979 unsigned long begin, end;
22980 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22981
22982 if (flags & MAP_FIXED)
22983 return addr;
22984
22985 - find_start_end(flags, &begin, &end);
22986 + find_start_end(mm, flags, &begin, &end);
22987
22988 if (len > end)
22989 return -ENOMEM;
22990
22991 +#ifdef CONFIG_PAX_RANDMMAP
22992 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22993 +#endif
22994 +
22995 if (addr) {
22996 addr = PAGE_ALIGN(addr);
22997 vma = find_vma(mm, addr);
22998 - if (end - len >= addr &&
22999 - (!vma || addr + len <= vma->vm_start))
23000 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23001 return addr;
23002 }
23003
23004 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23005 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23006 goto bottomup;
23007
23008 +#ifdef CONFIG_PAX_RANDMMAP
23009 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23010 +#endif
23011 +
23012 /* requesting a specific address */
23013 if (addr) {
23014 addr = PAGE_ALIGN(addr);
23015 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23016 index f84fe00..f41d9f1 100644
23017 --- a/arch/x86/kernel/tboot.c
23018 +++ b/arch/x86/kernel/tboot.c
23019 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23020
23021 void tboot_shutdown(u32 shutdown_type)
23022 {
23023 - void (*shutdown)(void);
23024 + void (* __noreturn shutdown)(void);
23025
23026 if (!tboot_enabled())
23027 return;
23028 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23029
23030 switch_to_tboot_pt();
23031
23032 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23033 + shutdown = (void *)tboot->shutdown_entry;
23034 shutdown();
23035
23036 /* should not reach here */
23037 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23038 return 0;
23039 }
23040
23041 -static atomic_t ap_wfs_count;
23042 +static atomic_unchecked_t ap_wfs_count;
23043
23044 static int tboot_wait_for_aps(int num_aps)
23045 {
23046 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23047 {
23048 switch (action) {
23049 case CPU_DYING:
23050 - atomic_inc(&ap_wfs_count);
23051 + atomic_inc_unchecked(&ap_wfs_count);
23052 if (num_online_cpus() == 1)
23053 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23054 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23055 return NOTIFY_BAD;
23056 break;
23057 }
23058 return NOTIFY_OK;
23059 }
23060
23061 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23062 +static struct notifier_block tboot_cpu_notifier =
23063 {
23064 .notifier_call = tboot_cpu_callback,
23065 };
23066 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23067
23068 tboot_create_trampoline();
23069
23070 - atomic_set(&ap_wfs_count, 0);
23071 + atomic_set_unchecked(&ap_wfs_count, 0);
23072 register_hotcpu_notifier(&tboot_cpu_notifier);
23073
23074 acpi_os_set_prepare_sleep(&tboot_sleep);
23075 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23076 index 24d3c91..d06b473 100644
23077 --- a/arch/x86/kernel/time.c
23078 +++ b/arch/x86/kernel/time.c
23079 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23080 {
23081 unsigned long pc = instruction_pointer(regs);
23082
23083 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23084 + if (!user_mode(regs) && in_lock_functions(pc)) {
23085 #ifdef CONFIG_FRAME_POINTER
23086 - return *(unsigned long *)(regs->bp + sizeof(long));
23087 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23088 #else
23089 unsigned long *sp =
23090 (unsigned long *)kernel_stack_pointer(regs);
23091 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23092 * or above a saved flags. Eflags has bits 22-31 zero,
23093 * kernel addresses don't.
23094 */
23095 +
23096 +#ifdef CONFIG_PAX_KERNEXEC
23097 + return ktla_ktva(sp[0]);
23098 +#else
23099 if (sp[0] >> 22)
23100 return sp[0];
23101 if (sp[1] >> 22)
23102 return sp[1];
23103 #endif
23104 +
23105 +#endif
23106 }
23107 return pc;
23108 }
23109 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23110 index 9d9d2f9..cad418a 100644
23111 --- a/arch/x86/kernel/tls.c
23112 +++ b/arch/x86/kernel/tls.c
23113 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23114 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23115 return -EINVAL;
23116
23117 +#ifdef CONFIG_PAX_SEGMEXEC
23118 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23119 + return -EINVAL;
23120 +#endif
23121 +
23122 set_tls_desc(p, idx, &info, 1);
23123
23124 return 0;
23125 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23126
23127 if (kbuf)
23128 info = kbuf;
23129 - else if (__copy_from_user(infobuf, ubuf, count))
23130 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23131 return -EFAULT;
23132 else
23133 info = infobuf;
23134 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23135 index ecffca1..95c4d13 100644
23136 --- a/arch/x86/kernel/traps.c
23137 +++ b/arch/x86/kernel/traps.c
23138 @@ -68,12 +68,6 @@
23139 #include <asm/setup.h>
23140
23141 asmlinkage int system_call(void);
23142 -
23143 -/*
23144 - * The IDT has to be page-aligned to simplify the Pentium
23145 - * F0 0F bug workaround.
23146 - */
23147 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23148 #endif
23149
23150 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23151 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23152 }
23153
23154 static int __kprobes
23155 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23156 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23157 struct pt_regs *regs, long error_code)
23158 {
23159 #ifdef CONFIG_X86_32
23160 - if (regs->flags & X86_VM_MASK) {
23161 + if (v8086_mode(regs)) {
23162 /*
23163 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23164 * On nmi (interrupt 2), do_trap should not be called.
23165 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23166 return -1;
23167 }
23168 #endif
23169 - if (!user_mode(regs)) {
23170 + if (!user_mode_novm(regs)) {
23171 if (!fixup_exception(regs)) {
23172 tsk->thread.error_code = error_code;
23173 tsk->thread.trap_nr = trapnr;
23174 +
23175 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23176 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23177 + str = "PAX: suspicious stack segment fault";
23178 +#endif
23179 +
23180 die(str, regs, error_code);
23181 }
23182 +
23183 +#ifdef CONFIG_PAX_REFCOUNT
23184 + if (trapnr == 4)
23185 + pax_report_refcount_overflow(regs);
23186 +#endif
23187 +
23188 return 0;
23189 }
23190
23191 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23192 }
23193
23194 static void __kprobes
23195 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23196 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23197 long error_code, siginfo_t *info)
23198 {
23199 struct task_struct *tsk = current;
23200 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23201 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23202 printk_ratelimit()) {
23203 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23204 - tsk->comm, tsk->pid, str,
23205 + tsk->comm, task_pid_nr(tsk), str,
23206 regs->ip, regs->sp, error_code);
23207 print_vma_addr(" in ", regs->ip);
23208 pr_cont("\n");
23209 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23210 conditional_sti(regs);
23211
23212 #ifdef CONFIG_X86_32
23213 - if (regs->flags & X86_VM_MASK) {
23214 + if (v8086_mode(regs)) {
23215 local_irq_enable();
23216 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23217 goto exit;
23218 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23219 #endif
23220
23221 tsk = current;
23222 - if (!user_mode(regs)) {
23223 + if (!user_mode_novm(regs)) {
23224 if (fixup_exception(regs))
23225 goto exit;
23226
23227 tsk->thread.error_code = error_code;
23228 tsk->thread.trap_nr = X86_TRAP_GP;
23229 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23230 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23231 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23232 +
23233 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23234 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23235 + die("PAX: suspicious general protection fault", regs, error_code);
23236 + else
23237 +#endif
23238 +
23239 die("general protection fault", regs, error_code);
23240 + }
23241 goto exit;
23242 }
23243
23244 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23245 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23246 + struct mm_struct *mm = tsk->mm;
23247 + unsigned long limit;
23248 +
23249 + down_write(&mm->mmap_sem);
23250 + limit = mm->context.user_cs_limit;
23251 + if (limit < TASK_SIZE) {
23252 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23253 + up_write(&mm->mmap_sem);
23254 + return;
23255 + }
23256 + up_write(&mm->mmap_sem);
23257 + }
23258 +#endif
23259 +
23260 tsk->thread.error_code = error_code;
23261 tsk->thread.trap_nr = X86_TRAP_GP;
23262
23263 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23264 /* It's safe to allow irq's after DR6 has been saved */
23265 preempt_conditional_sti(regs);
23266
23267 - if (regs->flags & X86_VM_MASK) {
23268 + if (v8086_mode(regs)) {
23269 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23270 X86_TRAP_DB);
23271 preempt_conditional_cli(regs);
23272 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23273 * We already checked v86 mode above, so we can check for kernel mode
23274 * by just checking the CPL of CS.
23275 */
23276 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23277 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23278 tsk->thread.debugreg6 &= ~DR_STEP;
23279 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23280 regs->flags &= ~X86_EFLAGS_TF;
23281 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23282 return;
23283 conditional_sti(regs);
23284
23285 - if (!user_mode_vm(regs))
23286 + if (!user_mode(regs))
23287 {
23288 if (!fixup_exception(regs)) {
23289 task->thread.error_code = error_code;
23290 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23291 index c71025b..b117501 100644
23292 --- a/arch/x86/kernel/uprobes.c
23293 +++ b/arch/x86/kernel/uprobes.c
23294 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23295 int ret = NOTIFY_DONE;
23296
23297 /* We are only interested in userspace traps */
23298 - if (regs && !user_mode_vm(regs))
23299 + if (regs && !user_mode(regs))
23300 return NOTIFY_DONE;
23301
23302 switch (val) {
23303 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23304 index b9242ba..50c5edd 100644
23305 --- a/arch/x86/kernel/verify_cpu.S
23306 +++ b/arch/x86/kernel/verify_cpu.S
23307 @@ -20,6 +20,7 @@
23308 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23309 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23310 * arch/x86/kernel/head_32.S: processor startup
23311 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23312 *
23313 * verify_cpu, returns the status of longmode and SSE in register %eax.
23314 * 0: Success 1: Failure
23315 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23316 index 1dfe69c..a3df6f6 100644
23317 --- a/arch/x86/kernel/vm86_32.c
23318 +++ b/arch/x86/kernel/vm86_32.c
23319 @@ -43,6 +43,7 @@
23320 #include <linux/ptrace.h>
23321 #include <linux/audit.h>
23322 #include <linux/stddef.h>
23323 +#include <linux/grsecurity.h>
23324
23325 #include <asm/uaccess.h>
23326 #include <asm/io.h>
23327 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23328 do_exit(SIGSEGV);
23329 }
23330
23331 - tss = &per_cpu(init_tss, get_cpu());
23332 + tss = init_tss + get_cpu();
23333 current->thread.sp0 = current->thread.saved_sp0;
23334 current->thread.sysenter_cs = __KERNEL_CS;
23335 load_sp0(tss, &current->thread);
23336 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
23337 struct task_struct *tsk;
23338 int tmp, ret = -EPERM;
23339
23340 +#ifdef CONFIG_GRKERNSEC_VM86
23341 + if (!capable(CAP_SYS_RAWIO)) {
23342 + gr_handle_vm86();
23343 + goto out;
23344 + }
23345 +#endif
23346 +
23347 tsk = current;
23348 if (tsk->thread.saved_sp0)
23349 goto out;
23350 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
23351 int tmp, ret;
23352 struct vm86plus_struct __user *v86;
23353
23354 +#ifdef CONFIG_GRKERNSEC_VM86
23355 + if (!capable(CAP_SYS_RAWIO)) {
23356 + gr_handle_vm86();
23357 + ret = -EPERM;
23358 + goto out;
23359 + }
23360 +#endif
23361 +
23362 tsk = current;
23363 switch (cmd) {
23364 case VM86_REQUEST_IRQ:
23365 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23366 tsk->thread.saved_fs = info->regs32->fs;
23367 tsk->thread.saved_gs = get_user_gs(info->regs32);
23368
23369 - tss = &per_cpu(init_tss, get_cpu());
23370 + tss = init_tss + get_cpu();
23371 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23372 if (cpu_has_sep)
23373 tsk->thread.sysenter_cs = 0;
23374 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23375 goto cannot_handle;
23376 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23377 goto cannot_handle;
23378 - intr_ptr = (unsigned long __user *) (i << 2);
23379 + intr_ptr = (__force unsigned long __user *) (i << 2);
23380 if (get_user(segoffs, intr_ptr))
23381 goto cannot_handle;
23382 if ((segoffs >> 16) == BIOSSEG)
23383 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23384 index 22a1530..8fbaaad 100644
23385 --- a/arch/x86/kernel/vmlinux.lds.S
23386 +++ b/arch/x86/kernel/vmlinux.lds.S
23387 @@ -26,6 +26,13 @@
23388 #include <asm/page_types.h>
23389 #include <asm/cache.h>
23390 #include <asm/boot.h>
23391 +#include <asm/segment.h>
23392 +
23393 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23394 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23395 +#else
23396 +#define __KERNEL_TEXT_OFFSET 0
23397 +#endif
23398
23399 #undef i386 /* in case the preprocessor is a 32bit one */
23400
23401 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23402
23403 PHDRS {
23404 text PT_LOAD FLAGS(5); /* R_E */
23405 +#ifdef CONFIG_X86_32
23406 + module PT_LOAD FLAGS(5); /* R_E */
23407 +#endif
23408 +#ifdef CONFIG_XEN
23409 + rodata PT_LOAD FLAGS(5); /* R_E */
23410 +#else
23411 + rodata PT_LOAD FLAGS(4); /* R__ */
23412 +#endif
23413 data PT_LOAD FLAGS(6); /* RW_ */
23414 -#ifdef CONFIG_X86_64
23415 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23416 #ifdef CONFIG_SMP
23417 percpu PT_LOAD FLAGS(6); /* RW_ */
23418 #endif
23419 + text.init PT_LOAD FLAGS(5); /* R_E */
23420 + text.exit PT_LOAD FLAGS(5); /* R_E */
23421 init PT_LOAD FLAGS(7); /* RWE */
23422 -#endif
23423 note PT_NOTE FLAGS(0); /* ___ */
23424 }
23425
23426 SECTIONS
23427 {
23428 #ifdef CONFIG_X86_32
23429 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23430 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23431 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23432 #else
23433 - . = __START_KERNEL;
23434 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23435 + . = __START_KERNEL;
23436 #endif
23437
23438 /* Text and read-only data */
23439 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23440 - _text = .;
23441 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23442 /* bootstrapping code */
23443 +#ifdef CONFIG_X86_32
23444 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23445 +#else
23446 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23447 +#endif
23448 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23449 + _text = .;
23450 HEAD_TEXT
23451 #ifdef CONFIG_X86_32
23452 . = ALIGN(PAGE_SIZE);
23453 @@ -108,13 +128,48 @@ SECTIONS
23454 IRQENTRY_TEXT
23455 *(.fixup)
23456 *(.gnu.warning)
23457 - /* End of text section */
23458 - _etext = .;
23459 } :text = 0x9090
23460
23461 - NOTES :text :note
23462 + . += __KERNEL_TEXT_OFFSET;
23463
23464 - EXCEPTION_TABLE(16) :text = 0x9090
23465 +#ifdef CONFIG_X86_32
23466 + . = ALIGN(PAGE_SIZE);
23467 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23468 +
23469 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23470 + MODULES_EXEC_VADDR = .;
23471 + BYTE(0)
23472 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23473 + . = ALIGN(HPAGE_SIZE) - 1;
23474 + MODULES_EXEC_END = .;
23475 +#endif
23476 +
23477 + } :module
23478 +#endif
23479 +
23480 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23481 + /* End of text section */
23482 + BYTE(0)
23483 + _etext = . - __KERNEL_TEXT_OFFSET;
23484 + }
23485 +
23486 +#ifdef CONFIG_X86_32
23487 + . = ALIGN(PAGE_SIZE);
23488 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23489 + *(.idt)
23490 + . = ALIGN(PAGE_SIZE);
23491 + *(.empty_zero_page)
23492 + *(.initial_pg_fixmap)
23493 + *(.initial_pg_pmd)
23494 + *(.initial_page_table)
23495 + *(.swapper_pg_dir)
23496 + } :rodata
23497 +#endif
23498 +
23499 + . = ALIGN(PAGE_SIZE);
23500 + NOTES :rodata :note
23501 +
23502 + EXCEPTION_TABLE(16) :rodata
23503
23504 #if defined(CONFIG_DEBUG_RODATA)
23505 /* .text should occupy whole number of pages */
23506 @@ -126,16 +181,20 @@ SECTIONS
23507
23508 /* Data */
23509 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23510 +
23511 +#ifdef CONFIG_PAX_KERNEXEC
23512 + . = ALIGN(HPAGE_SIZE);
23513 +#else
23514 + . = ALIGN(PAGE_SIZE);
23515 +#endif
23516 +
23517 /* Start of data section */
23518 _sdata = .;
23519
23520 /* init_task */
23521 INIT_TASK_DATA(THREAD_SIZE)
23522
23523 -#ifdef CONFIG_X86_32
23524 - /* 32 bit has nosave before _edata */
23525 NOSAVE_DATA
23526 -#endif
23527
23528 PAGE_ALIGNED_DATA(PAGE_SIZE)
23529
23530 @@ -176,12 +235,19 @@ SECTIONS
23531 #endif /* CONFIG_X86_64 */
23532
23533 /* Init code and data - will be freed after init */
23534 - . = ALIGN(PAGE_SIZE);
23535 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23536 + BYTE(0)
23537 +
23538 +#ifdef CONFIG_PAX_KERNEXEC
23539 + . = ALIGN(HPAGE_SIZE);
23540 +#else
23541 + . = ALIGN(PAGE_SIZE);
23542 +#endif
23543 +
23544 __init_begin = .; /* paired with __init_end */
23545 - }
23546 + } :init.begin
23547
23548 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23549 +#ifdef CONFIG_SMP
23550 /*
23551 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23552 * output PHDR, so the next output section - .init.text - should
23553 @@ -190,12 +256,27 @@ SECTIONS
23554 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23555 #endif
23556
23557 - INIT_TEXT_SECTION(PAGE_SIZE)
23558 -#ifdef CONFIG_X86_64
23559 - :init
23560 -#endif
23561 + . = ALIGN(PAGE_SIZE);
23562 + init_begin = .;
23563 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23564 + VMLINUX_SYMBOL(_sinittext) = .;
23565 + INIT_TEXT
23566 + VMLINUX_SYMBOL(_einittext) = .;
23567 + . = ALIGN(PAGE_SIZE);
23568 + } :text.init
23569
23570 - INIT_DATA_SECTION(16)
23571 + /*
23572 + * .exit.text is discard at runtime, not link time, to deal with
23573 + * references from .altinstructions and .eh_frame
23574 + */
23575 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23576 + EXIT_TEXT
23577 + . = ALIGN(16);
23578 + } :text.exit
23579 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23580 +
23581 + . = ALIGN(PAGE_SIZE);
23582 + INIT_DATA_SECTION(16) :init
23583
23584 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23585 __x86_cpu_dev_start = .;
23586 @@ -257,19 +338,12 @@ SECTIONS
23587 }
23588
23589 . = ALIGN(8);
23590 - /*
23591 - * .exit.text is discard at runtime, not link time, to deal with
23592 - * references from .altinstructions and .eh_frame
23593 - */
23594 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23595 - EXIT_TEXT
23596 - }
23597
23598 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23599 EXIT_DATA
23600 }
23601
23602 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23603 +#ifndef CONFIG_SMP
23604 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23605 #endif
23606
23607 @@ -288,16 +362,10 @@ SECTIONS
23608 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23609 __smp_locks = .;
23610 *(.smp_locks)
23611 - . = ALIGN(PAGE_SIZE);
23612 __smp_locks_end = .;
23613 + . = ALIGN(PAGE_SIZE);
23614 }
23615
23616 -#ifdef CONFIG_X86_64
23617 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23618 - NOSAVE_DATA
23619 - }
23620 -#endif
23621 -
23622 /* BSS */
23623 . = ALIGN(PAGE_SIZE);
23624 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23625 @@ -313,6 +381,7 @@ SECTIONS
23626 __brk_base = .;
23627 . += 64 * 1024; /* 64k alignment slop space */
23628 *(.brk_reservation) /* areas brk users have reserved */
23629 + . = ALIGN(HPAGE_SIZE);
23630 __brk_limit = .;
23631 }
23632
23633 @@ -339,13 +408,12 @@ SECTIONS
23634 * for the boot processor.
23635 */
23636 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23637 -INIT_PER_CPU(gdt_page);
23638 INIT_PER_CPU(irq_stack_union);
23639
23640 /*
23641 * Build-time check on the image size:
23642 */
23643 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23644 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23645 "kernel image bigger than KERNEL_IMAGE_SIZE");
23646
23647 #ifdef CONFIG_SMP
23648 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23649 index 9a907a6..f83f921 100644
23650 --- a/arch/x86/kernel/vsyscall_64.c
23651 +++ b/arch/x86/kernel/vsyscall_64.c
23652 @@ -56,15 +56,13 @@
23653 DEFINE_VVAR(int, vgetcpu_mode);
23654 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23655
23656 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23657 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23658
23659 static int __init vsyscall_setup(char *str)
23660 {
23661 if (str) {
23662 if (!strcmp("emulate", str))
23663 vsyscall_mode = EMULATE;
23664 - else if (!strcmp("native", str))
23665 - vsyscall_mode = NATIVE;
23666 else if (!strcmp("none", str))
23667 vsyscall_mode = NONE;
23668 else
23669 @@ -323,8 +321,7 @@ do_ret:
23670 return true;
23671
23672 sigsegv:
23673 - force_sig(SIGSEGV, current);
23674 - return true;
23675 + do_group_exit(SIGKILL);
23676 }
23677
23678 /*
23679 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23680 extern char __vvar_page;
23681 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23682
23683 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23684 - vsyscall_mode == NATIVE
23685 - ? PAGE_KERNEL_VSYSCALL
23686 - : PAGE_KERNEL_VVAR);
23687 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23688 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23689 (unsigned long)VSYSCALL_START);
23690
23691 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23692 index 1330dd1..d220b99 100644
23693 --- a/arch/x86/kernel/x8664_ksyms_64.c
23694 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23695 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23696 EXPORT_SYMBOL(copy_user_generic_unrolled);
23697 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23698 EXPORT_SYMBOL(__copy_user_nocache);
23699 -EXPORT_SYMBOL(_copy_from_user);
23700 -EXPORT_SYMBOL(_copy_to_user);
23701
23702 EXPORT_SYMBOL(copy_page);
23703 EXPORT_SYMBOL(clear_page);
23704 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23705 index 7a3d075..6cb373d 100644
23706 --- a/arch/x86/kernel/x86_init.c
23707 +++ b/arch/x86/kernel/x86_init.c
23708 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
23709 },
23710 };
23711
23712 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23713 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23714 .early_percpu_clock_init = x86_init_noop,
23715 .setup_percpu_clockev = setup_secondary_APIC_clock,
23716 };
23717 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23718 static void default_nmi_init(void) { };
23719 static int default_i8042_detect(void) { return 1; };
23720
23721 -struct x86_platform_ops x86_platform = {
23722 +struct x86_platform_ops x86_platform __read_only = {
23723 .calibrate_tsc = native_calibrate_tsc,
23724 .get_wallclock = mach_get_cmos_time,
23725 .set_wallclock = mach_set_rtc_mmss,
23726 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
23727 };
23728
23729 EXPORT_SYMBOL_GPL(x86_platform);
23730 -struct x86_msi_ops x86_msi = {
23731 +struct x86_msi_ops x86_msi __read_only = {
23732 .setup_msi_irqs = native_setup_msi_irqs,
23733 .teardown_msi_irq = native_teardown_msi_irq,
23734 .teardown_msi_irqs = default_teardown_msi_irqs,
23735 .restore_msi_irqs = default_restore_msi_irqs,
23736 };
23737
23738 -struct x86_io_apic_ops x86_io_apic_ops = {
23739 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23740 .init = native_io_apic_init_mappings,
23741 .read = native_io_apic_read,
23742 .write = native_io_apic_write,
23743 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23744 index ada87a3..afea76d 100644
23745 --- a/arch/x86/kernel/xsave.c
23746 +++ b/arch/x86/kernel/xsave.c
23747 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23748 {
23749 int err;
23750
23751 + buf = (struct xsave_struct __user *)____m(buf);
23752 if (use_xsave())
23753 err = xsave_user(buf);
23754 else if (use_fxsr())
23755 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23756 */
23757 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23758 {
23759 + buf = (void __user *)____m(buf);
23760 if (use_xsave()) {
23761 if ((unsigned long)buf % 64 || fx_only) {
23762 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23763 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23764 index a20ecb5..d0e2194 100644
23765 --- a/arch/x86/kvm/cpuid.c
23766 +++ b/arch/x86/kvm/cpuid.c
23767 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23768 struct kvm_cpuid2 *cpuid,
23769 struct kvm_cpuid_entry2 __user *entries)
23770 {
23771 - int r;
23772 + int r, i;
23773
23774 r = -E2BIG;
23775 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23776 goto out;
23777 r = -EFAULT;
23778 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23779 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23780 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23781 goto out;
23782 + for (i = 0; i < cpuid->nent; ++i) {
23783 + struct kvm_cpuid_entry2 cpuid_entry;
23784 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23785 + goto out;
23786 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23787 + }
23788 vcpu->arch.cpuid_nent = cpuid->nent;
23789 kvm_apic_set_version(vcpu);
23790 kvm_x86_ops->cpuid_update(vcpu);
23791 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23792 struct kvm_cpuid2 *cpuid,
23793 struct kvm_cpuid_entry2 __user *entries)
23794 {
23795 - int r;
23796 + int r, i;
23797
23798 r = -E2BIG;
23799 if (cpuid->nent < vcpu->arch.cpuid_nent)
23800 goto out;
23801 r = -EFAULT;
23802 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23803 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23804 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23805 goto out;
23806 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23807 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23808 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23809 + goto out;
23810 + }
23811 return 0;
23812
23813 out:
23814 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
23815 index a27e763..54bfe43 100644
23816 --- a/arch/x86/kvm/emulate.c
23817 +++ b/arch/x86/kvm/emulate.c
23818 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23819
23820 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
23821 do { \
23822 + unsigned long _tmp; \
23823 __asm__ __volatile__ ( \
23824 _PRE_EFLAGS("0", "4", "2") \
23825 _op _suffix " %"_x"3,%1; " \
23826 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23827 /* Raw emulation: instruction has two explicit operands. */
23828 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
23829 do { \
23830 - unsigned long _tmp; \
23831 - \
23832 switch ((ctxt)->dst.bytes) { \
23833 case 2: \
23834 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
23835 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23836
23837 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
23838 do { \
23839 - unsigned long _tmp; \
23840 switch ((ctxt)->dst.bytes) { \
23841 case 1: \
23842 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
23843 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
23844 index 9392f52..0e56d77 100644
23845 --- a/arch/x86/kvm/lapic.c
23846 +++ b/arch/x86/kvm/lapic.c
23847 @@ -55,7 +55,7 @@
23848 #define APIC_BUS_CYCLE_NS 1
23849
23850 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
23851 -#define apic_debug(fmt, arg...)
23852 +#define apic_debug(fmt, arg...) do {} while (0)
23853
23854 #define APIC_LVT_NUM 6
23855 /* 14 is the version for Xeon and Pentium 8.4.8*/
23856 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
23857 index 891eb6d..e027900 100644
23858 --- a/arch/x86/kvm/paging_tmpl.h
23859 +++ b/arch/x86/kvm/paging_tmpl.h
23860 @@ -208,7 +208,7 @@ retry_walk:
23861 if (unlikely(kvm_is_error_hva(host_addr)))
23862 goto error;
23863
23864 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
23865 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
23866 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
23867 goto error;
23868 walker->ptep_user[walker->level - 1] = ptep_user;
23869 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
23870 index d29d3cd..ec9d522 100644
23871 --- a/arch/x86/kvm/svm.c
23872 +++ b/arch/x86/kvm/svm.c
23873 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
23874 int cpu = raw_smp_processor_id();
23875
23876 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
23877 +
23878 + pax_open_kernel();
23879 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
23880 + pax_close_kernel();
23881 +
23882 load_TR_desc();
23883 }
23884
23885 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
23886 #endif
23887 #endif
23888
23889 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
23890 + __set_fs(current_thread_info()->addr_limit);
23891 +#endif
23892 +
23893 reload_tss(vcpu);
23894
23895 local_irq_disable();
23896 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
23897 index 9120ae1..238abc0 100644
23898 --- a/arch/x86/kvm/vmx.c
23899 +++ b/arch/x86/kvm/vmx.c
23900 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
23901 struct desc_struct *descs;
23902
23903 descs = (void *)gdt->address;
23904 +
23905 + pax_open_kernel();
23906 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
23907 + pax_close_kernel();
23908 +
23909 load_TR_desc();
23910 }
23911
23912 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
23913 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
23914 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
23915
23916 +#ifdef CONFIG_PAX_PER_CPU_PGD
23917 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
23918 +#endif
23919 +
23920 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
23921 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
23922 vmx->loaded_vmcs->cpu = cpu;
23923 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
23924 if (!cpu_has_vmx_flexpriority())
23925 flexpriority_enabled = 0;
23926
23927 - if (!cpu_has_vmx_tpr_shadow())
23928 - kvm_x86_ops->update_cr8_intercept = NULL;
23929 + if (!cpu_has_vmx_tpr_shadow()) {
23930 + pax_open_kernel();
23931 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
23932 + pax_close_kernel();
23933 + }
23934
23935 if (enable_ept && !cpu_has_vmx_ept_2m_page())
23936 kvm_disable_largepages();
23937 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
23938
23939 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
23940 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
23941 +
23942 +#ifndef CONFIG_PAX_PER_CPU_PGD
23943 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
23944 +#endif
23945
23946 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
23947 #ifdef CONFIG_X86_64
23948 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
23949 native_store_idt(&dt);
23950 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
23951
23952 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
23953 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
23954
23955 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
23956 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
23957 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23958 "jmp 2f \n\t"
23959 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
23960 "2: "
23961 +
23962 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23963 + "ljmp %[cs],$3f\n\t"
23964 + "3: "
23965 +#endif
23966 +
23967 /* Save guest registers, load host registers, keep flags */
23968 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
23969 "pop %0 \n\t"
23970 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23971 #endif
23972 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
23973 [wordsize]"i"(sizeof(ulong))
23974 +
23975 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23976 + ,[cs]"i"(__KERNEL_CS)
23977 +#endif
23978 +
23979 : "cc", "memory"
23980 #ifdef CONFIG_X86_64
23981 , "rax", "rbx", "rdi", "rsi"
23982 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23983 if (debugctlmsr)
23984 update_debugctlmsr(debugctlmsr);
23985
23986 -#ifndef CONFIG_X86_64
23987 +#ifdef CONFIG_X86_32
23988 /*
23989 * The sysexit path does not restore ds/es, so we must set them to
23990 * a reasonable value ourselves.
23991 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
23992 * may be executed in interrupt context, which saves and restore segments
23993 * around it, nullifying its effect.
23994 */
23995 - loadsegment(ds, __USER_DS);
23996 - loadsegment(es, __USER_DS);
23997 + loadsegment(ds, __KERNEL_DS);
23998 + loadsegment(es, __KERNEL_DS);
23999 + loadsegment(ss, __KERNEL_DS);
24000 +
24001 +#ifdef CONFIG_PAX_KERNEXEC
24002 + loadsegment(fs, __KERNEL_PERCPU);
24003 +#endif
24004 +
24005 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24006 + __set_fs(current_thread_info()->addr_limit);
24007 +#endif
24008 +
24009 #endif
24010
24011 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24012 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24013 index c243b81..b692af3 100644
24014 --- a/arch/x86/kvm/x86.c
24015 +++ b/arch/x86/kvm/x86.c
24016 @@ -1408,10 +1408,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24017 unsigned long flags, this_tsc_khz;
24018 struct kvm_vcpu_arch *vcpu = &v->arch;
24019 struct kvm_arch *ka = &v->kvm->arch;
24020 - void *shared_kaddr;
24021 s64 kernel_ns, max_kernel_ns;
24022 u64 tsc_timestamp, host_tsc;
24023 - struct pvclock_vcpu_time_info *guest_hv_clock;
24024 + struct pvclock_vcpu_time_info guest_hv_clock;
24025 u8 pvclock_flags;
24026 bool use_master_clock;
24027
24028 @@ -1465,7 +1464,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24029
24030 local_irq_restore(flags);
24031
24032 - if (!vcpu->time_page)
24033 + if (!vcpu->pv_time_enabled)
24034 return 0;
24035
24036 /*
24037 @@ -1527,12 +1526,12 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24038 */
24039 vcpu->hv_clock.version += 2;
24040
24041 - shared_kaddr = kmap_atomic(vcpu->time_page);
24042 -
24043 - guest_hv_clock = shared_kaddr + vcpu->time_offset;
24044 + if (unlikely(kvm_read_guest_cached(v->kvm, &vcpu->pv_time,
24045 + &guest_hv_clock, sizeof(guest_hv_clock))))
24046 + return 0;
24047
24048 /* retain PVCLOCK_GUEST_STOPPED if set in guest copy */
24049 - pvclock_flags = (guest_hv_clock->flags & PVCLOCK_GUEST_STOPPED);
24050 + pvclock_flags = (guest_hv_clock.flags & PVCLOCK_GUEST_STOPPED);
24051
24052 if (vcpu->pvclock_set_guest_stopped_request) {
24053 pvclock_flags |= PVCLOCK_GUEST_STOPPED;
24054 @@ -1545,12 +1544,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24055
24056 vcpu->hv_clock.flags = pvclock_flags;
24057
24058 - memcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock,
24059 - sizeof(vcpu->hv_clock));
24060 -
24061 - kunmap_atomic(shared_kaddr);
24062 -
24063 - mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT);
24064 + kvm_write_guest_cached(v->kvm, &vcpu->pv_time,
24065 + &vcpu->hv_clock,
24066 + sizeof(vcpu->hv_clock));
24067 return 0;
24068 }
24069
24070 @@ -1692,8 +1688,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24071 {
24072 struct kvm *kvm = vcpu->kvm;
24073 int lm = is_long_mode(vcpu);
24074 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24075 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24076 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24077 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24078 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24079 : kvm->arch.xen_hvm_config.blob_size_32;
24080 u32 page_num = data & ~PAGE_MASK;
24081 @@ -1839,10 +1835,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
24082
24083 static void kvmclock_reset(struct kvm_vcpu *vcpu)
24084 {
24085 - if (vcpu->arch.time_page) {
24086 - kvm_release_page_dirty(vcpu->arch.time_page);
24087 - vcpu->arch.time_page = NULL;
24088 - }
24089 + vcpu->arch.pv_time_enabled = false;
24090 }
24091
24092 static void accumulate_steal_time(struct kvm_vcpu *vcpu)
24093 @@ -1948,6 +1941,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24094 break;
24095 case MSR_KVM_SYSTEM_TIME_NEW:
24096 case MSR_KVM_SYSTEM_TIME: {
24097 + u64 gpa_offset;
24098 kvmclock_reset(vcpu);
24099
24100 vcpu->arch.time = data;
24101 @@ -1957,14 +1951,17 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24102 if (!(data & 1))
24103 break;
24104
24105 - /* ...but clean it before doing the actual write */
24106 - vcpu->arch.time_offset = data & ~(PAGE_MASK | 1);
24107 + gpa_offset = data & ~(PAGE_MASK | 1);
24108
24109 - vcpu->arch.time_page =
24110 - gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT);
24111 + /* Check that the address is 32-byte aligned. */
24112 + if (gpa_offset & (sizeof(struct pvclock_vcpu_time_info) - 1))
24113 + break;
24114
24115 - if (is_error_page(vcpu->arch.time_page))
24116 - vcpu->arch.time_page = NULL;
24117 + if (kvm_gfn_to_hva_cache_init(vcpu->kvm,
24118 + &vcpu->arch.pv_time, data & ~1ULL))
24119 + vcpu->arch.pv_time_enabled = false;
24120 + else
24121 + vcpu->arch.pv_time_enabled = true;
24122
24123 break;
24124 }
24125 @@ -2571,6 +2568,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24126 if (n < msr_list.nmsrs)
24127 goto out;
24128 r = -EFAULT;
24129 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24130 + goto out;
24131 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24132 num_msrs_to_save * sizeof(u32)))
24133 goto out;
24134 @@ -2700,7 +2699,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24135 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24136 struct kvm_interrupt *irq)
24137 {
24138 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24139 + if (irq->irq >= KVM_NR_INTERRUPTS)
24140 return -EINVAL;
24141 if (irqchip_in_kernel(vcpu->kvm))
24142 return -ENXIO;
24143 @@ -2967,7 +2966,7 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,
24144 */
24145 static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
24146 {
24147 - if (!vcpu->arch.time_page)
24148 + if (!vcpu->arch.pv_time_enabled)
24149 return -EINVAL;
24150 vcpu->arch.pvclock_set_guest_stopped_request = true;
24151 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
24152 @@ -5213,7 +5212,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24153 };
24154 #endif
24155
24156 -int kvm_arch_init(void *opaque)
24157 +int kvm_arch_init(const void *opaque)
24158 {
24159 int r;
24160 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24161 @@ -6661,6 +6660,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
24162 goto fail_free_wbinvd_dirty_mask;
24163
24164 vcpu->arch.ia32_tsc_adjust_msr = 0x0;
24165 + vcpu->arch.pv_time_enabled = false;
24166 kvm_async_pf_hash_reset(vcpu);
24167 kvm_pmu_init(vcpu);
24168
24169 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24170 index df4176c..23ce092 100644
24171 --- a/arch/x86/lguest/boot.c
24172 +++ b/arch/x86/lguest/boot.c
24173 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24174 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24175 * Launcher to reboot us.
24176 */
24177 -static void lguest_restart(char *reason)
24178 +static __noreturn void lguest_restart(char *reason)
24179 {
24180 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24181 + BUG();
24182 }
24183
24184 /*G:050
24185 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24186 index 00933d5..3a64af9 100644
24187 --- a/arch/x86/lib/atomic64_386_32.S
24188 +++ b/arch/x86/lib/atomic64_386_32.S
24189 @@ -48,6 +48,10 @@ BEGIN(read)
24190 movl (v), %eax
24191 movl 4(v), %edx
24192 RET_ENDP
24193 +BEGIN(read_unchecked)
24194 + movl (v), %eax
24195 + movl 4(v), %edx
24196 +RET_ENDP
24197 #undef v
24198
24199 #define v %esi
24200 @@ -55,6 +59,10 @@ BEGIN(set)
24201 movl %ebx, (v)
24202 movl %ecx, 4(v)
24203 RET_ENDP
24204 +BEGIN(set_unchecked)
24205 + movl %ebx, (v)
24206 + movl %ecx, 4(v)
24207 +RET_ENDP
24208 #undef v
24209
24210 #define v %esi
24211 @@ -70,6 +78,20 @@ RET_ENDP
24212 BEGIN(add)
24213 addl %eax, (v)
24214 adcl %edx, 4(v)
24215 +
24216 +#ifdef CONFIG_PAX_REFCOUNT
24217 + jno 0f
24218 + subl %eax, (v)
24219 + sbbl %edx, 4(v)
24220 + int $4
24221 +0:
24222 + _ASM_EXTABLE(0b, 0b)
24223 +#endif
24224 +
24225 +RET_ENDP
24226 +BEGIN(add_unchecked)
24227 + addl %eax, (v)
24228 + adcl %edx, 4(v)
24229 RET_ENDP
24230 #undef v
24231
24232 @@ -77,6 +99,24 @@ RET_ENDP
24233 BEGIN(add_return)
24234 addl (v), %eax
24235 adcl 4(v), %edx
24236 +
24237 +#ifdef CONFIG_PAX_REFCOUNT
24238 + into
24239 +1234:
24240 + _ASM_EXTABLE(1234b, 2f)
24241 +#endif
24242 +
24243 + movl %eax, (v)
24244 + movl %edx, 4(v)
24245 +
24246 +#ifdef CONFIG_PAX_REFCOUNT
24247 +2:
24248 +#endif
24249 +
24250 +RET_ENDP
24251 +BEGIN(add_return_unchecked)
24252 + addl (v), %eax
24253 + adcl 4(v), %edx
24254 movl %eax, (v)
24255 movl %edx, 4(v)
24256 RET_ENDP
24257 @@ -86,6 +126,20 @@ RET_ENDP
24258 BEGIN(sub)
24259 subl %eax, (v)
24260 sbbl %edx, 4(v)
24261 +
24262 +#ifdef CONFIG_PAX_REFCOUNT
24263 + jno 0f
24264 + addl %eax, (v)
24265 + adcl %edx, 4(v)
24266 + int $4
24267 +0:
24268 + _ASM_EXTABLE(0b, 0b)
24269 +#endif
24270 +
24271 +RET_ENDP
24272 +BEGIN(sub_unchecked)
24273 + subl %eax, (v)
24274 + sbbl %edx, 4(v)
24275 RET_ENDP
24276 #undef v
24277
24278 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24279 sbbl $0, %edx
24280 addl (v), %eax
24281 adcl 4(v), %edx
24282 +
24283 +#ifdef CONFIG_PAX_REFCOUNT
24284 + into
24285 +1234:
24286 + _ASM_EXTABLE(1234b, 2f)
24287 +#endif
24288 +
24289 + movl %eax, (v)
24290 + movl %edx, 4(v)
24291 +
24292 +#ifdef CONFIG_PAX_REFCOUNT
24293 +2:
24294 +#endif
24295 +
24296 +RET_ENDP
24297 +BEGIN(sub_return_unchecked)
24298 + negl %edx
24299 + negl %eax
24300 + sbbl $0, %edx
24301 + addl (v), %eax
24302 + adcl 4(v), %edx
24303 movl %eax, (v)
24304 movl %edx, 4(v)
24305 RET_ENDP
24306 @@ -105,6 +180,20 @@ RET_ENDP
24307 BEGIN(inc)
24308 addl $1, (v)
24309 adcl $0, 4(v)
24310 +
24311 +#ifdef CONFIG_PAX_REFCOUNT
24312 + jno 0f
24313 + subl $1, (v)
24314 + sbbl $0, 4(v)
24315 + int $4
24316 +0:
24317 + _ASM_EXTABLE(0b, 0b)
24318 +#endif
24319 +
24320 +RET_ENDP
24321 +BEGIN(inc_unchecked)
24322 + addl $1, (v)
24323 + adcl $0, 4(v)
24324 RET_ENDP
24325 #undef v
24326
24327 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24328 movl 4(v), %edx
24329 addl $1, %eax
24330 adcl $0, %edx
24331 +
24332 +#ifdef CONFIG_PAX_REFCOUNT
24333 + into
24334 +1234:
24335 + _ASM_EXTABLE(1234b, 2f)
24336 +#endif
24337 +
24338 + movl %eax, (v)
24339 + movl %edx, 4(v)
24340 +
24341 +#ifdef CONFIG_PAX_REFCOUNT
24342 +2:
24343 +#endif
24344 +
24345 +RET_ENDP
24346 +BEGIN(inc_return_unchecked)
24347 + movl (v), %eax
24348 + movl 4(v), %edx
24349 + addl $1, %eax
24350 + adcl $0, %edx
24351 movl %eax, (v)
24352 movl %edx, 4(v)
24353 RET_ENDP
24354 @@ -123,6 +232,20 @@ RET_ENDP
24355 BEGIN(dec)
24356 subl $1, (v)
24357 sbbl $0, 4(v)
24358 +
24359 +#ifdef CONFIG_PAX_REFCOUNT
24360 + jno 0f
24361 + addl $1, (v)
24362 + adcl $0, 4(v)
24363 + int $4
24364 +0:
24365 + _ASM_EXTABLE(0b, 0b)
24366 +#endif
24367 +
24368 +RET_ENDP
24369 +BEGIN(dec_unchecked)
24370 + subl $1, (v)
24371 + sbbl $0, 4(v)
24372 RET_ENDP
24373 #undef v
24374
24375 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24376 movl 4(v), %edx
24377 subl $1, %eax
24378 sbbl $0, %edx
24379 +
24380 +#ifdef CONFIG_PAX_REFCOUNT
24381 + into
24382 +1234:
24383 + _ASM_EXTABLE(1234b, 2f)
24384 +#endif
24385 +
24386 + movl %eax, (v)
24387 + movl %edx, 4(v)
24388 +
24389 +#ifdef CONFIG_PAX_REFCOUNT
24390 +2:
24391 +#endif
24392 +
24393 +RET_ENDP
24394 +BEGIN(dec_return_unchecked)
24395 + movl (v), %eax
24396 + movl 4(v), %edx
24397 + subl $1, %eax
24398 + sbbl $0, %edx
24399 movl %eax, (v)
24400 movl %edx, 4(v)
24401 RET_ENDP
24402 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24403 adcl %edx, %edi
24404 addl (v), %eax
24405 adcl 4(v), %edx
24406 +
24407 +#ifdef CONFIG_PAX_REFCOUNT
24408 + into
24409 +1234:
24410 + _ASM_EXTABLE(1234b, 2f)
24411 +#endif
24412 +
24413 cmpl %eax, %ecx
24414 je 3f
24415 1:
24416 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24417 1:
24418 addl $1, %eax
24419 adcl $0, %edx
24420 +
24421 +#ifdef CONFIG_PAX_REFCOUNT
24422 + into
24423 +1234:
24424 + _ASM_EXTABLE(1234b, 2f)
24425 +#endif
24426 +
24427 movl %eax, (v)
24428 movl %edx, 4(v)
24429 movl $1, %eax
24430 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24431 movl 4(v), %edx
24432 subl $1, %eax
24433 sbbl $0, %edx
24434 +
24435 +#ifdef CONFIG_PAX_REFCOUNT
24436 + into
24437 +1234:
24438 + _ASM_EXTABLE(1234b, 1f)
24439 +#endif
24440 +
24441 js 1f
24442 movl %eax, (v)
24443 movl %edx, 4(v)
24444 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24445 index f5cc9eb..51fa319 100644
24446 --- a/arch/x86/lib/atomic64_cx8_32.S
24447 +++ b/arch/x86/lib/atomic64_cx8_32.S
24448 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24449 CFI_STARTPROC
24450
24451 read64 %ecx
24452 + pax_force_retaddr
24453 ret
24454 CFI_ENDPROC
24455 ENDPROC(atomic64_read_cx8)
24456
24457 +ENTRY(atomic64_read_unchecked_cx8)
24458 + CFI_STARTPROC
24459 +
24460 + read64 %ecx
24461 + pax_force_retaddr
24462 + ret
24463 + CFI_ENDPROC
24464 +ENDPROC(atomic64_read_unchecked_cx8)
24465 +
24466 ENTRY(atomic64_set_cx8)
24467 CFI_STARTPROC
24468
24469 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24470 cmpxchg8b (%esi)
24471 jne 1b
24472
24473 + pax_force_retaddr
24474 ret
24475 CFI_ENDPROC
24476 ENDPROC(atomic64_set_cx8)
24477
24478 +ENTRY(atomic64_set_unchecked_cx8)
24479 + CFI_STARTPROC
24480 +
24481 +1:
24482 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24483 + * are atomic on 586 and newer */
24484 + cmpxchg8b (%esi)
24485 + jne 1b
24486 +
24487 + pax_force_retaddr
24488 + ret
24489 + CFI_ENDPROC
24490 +ENDPROC(atomic64_set_unchecked_cx8)
24491 +
24492 ENTRY(atomic64_xchg_cx8)
24493 CFI_STARTPROC
24494
24495 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24496 cmpxchg8b (%esi)
24497 jne 1b
24498
24499 + pax_force_retaddr
24500 ret
24501 CFI_ENDPROC
24502 ENDPROC(atomic64_xchg_cx8)
24503
24504 -.macro addsub_return func ins insc
24505 -ENTRY(atomic64_\func\()_return_cx8)
24506 +.macro addsub_return func ins insc unchecked=""
24507 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24508 CFI_STARTPROC
24509 SAVE ebp
24510 SAVE ebx
24511 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24512 movl %edx, %ecx
24513 \ins\()l %esi, %ebx
24514 \insc\()l %edi, %ecx
24515 +
24516 +.ifb \unchecked
24517 +#ifdef CONFIG_PAX_REFCOUNT
24518 + into
24519 +2:
24520 + _ASM_EXTABLE(2b, 3f)
24521 +#endif
24522 +.endif
24523 +
24524 LOCK_PREFIX
24525 cmpxchg8b (%ebp)
24526 jne 1b
24527 -
24528 -10:
24529 movl %ebx, %eax
24530 movl %ecx, %edx
24531 +
24532 +.ifb \unchecked
24533 +#ifdef CONFIG_PAX_REFCOUNT
24534 +3:
24535 +#endif
24536 +.endif
24537 +
24538 RESTORE edi
24539 RESTORE esi
24540 RESTORE ebx
24541 RESTORE ebp
24542 + pax_force_retaddr
24543 ret
24544 CFI_ENDPROC
24545 -ENDPROC(atomic64_\func\()_return_cx8)
24546 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24547 .endm
24548
24549 addsub_return add add adc
24550 addsub_return sub sub sbb
24551 +addsub_return add add adc _unchecked
24552 +addsub_return sub sub sbb _unchecked
24553
24554 -.macro incdec_return func ins insc
24555 -ENTRY(atomic64_\func\()_return_cx8)
24556 +.macro incdec_return func ins insc unchecked=""
24557 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24558 CFI_STARTPROC
24559 SAVE ebx
24560
24561 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24562 movl %edx, %ecx
24563 \ins\()l $1, %ebx
24564 \insc\()l $0, %ecx
24565 +
24566 +.ifb \unchecked
24567 +#ifdef CONFIG_PAX_REFCOUNT
24568 + into
24569 +2:
24570 + _ASM_EXTABLE(2b, 3f)
24571 +#endif
24572 +.endif
24573 +
24574 LOCK_PREFIX
24575 cmpxchg8b (%esi)
24576 jne 1b
24577
24578 -10:
24579 movl %ebx, %eax
24580 movl %ecx, %edx
24581 +
24582 +.ifb \unchecked
24583 +#ifdef CONFIG_PAX_REFCOUNT
24584 +3:
24585 +#endif
24586 +.endif
24587 +
24588 RESTORE ebx
24589 + pax_force_retaddr
24590 ret
24591 CFI_ENDPROC
24592 -ENDPROC(atomic64_\func\()_return_cx8)
24593 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24594 .endm
24595
24596 incdec_return inc add adc
24597 incdec_return dec sub sbb
24598 +incdec_return inc add adc _unchecked
24599 +incdec_return dec sub sbb _unchecked
24600
24601 ENTRY(atomic64_dec_if_positive_cx8)
24602 CFI_STARTPROC
24603 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24604 movl %edx, %ecx
24605 subl $1, %ebx
24606 sbb $0, %ecx
24607 +
24608 +#ifdef CONFIG_PAX_REFCOUNT
24609 + into
24610 +1234:
24611 + _ASM_EXTABLE(1234b, 2f)
24612 +#endif
24613 +
24614 js 2f
24615 LOCK_PREFIX
24616 cmpxchg8b (%esi)
24617 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24618 movl %ebx, %eax
24619 movl %ecx, %edx
24620 RESTORE ebx
24621 + pax_force_retaddr
24622 ret
24623 CFI_ENDPROC
24624 ENDPROC(atomic64_dec_if_positive_cx8)
24625 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24626 movl %edx, %ecx
24627 addl %ebp, %ebx
24628 adcl %edi, %ecx
24629 +
24630 +#ifdef CONFIG_PAX_REFCOUNT
24631 + into
24632 +1234:
24633 + _ASM_EXTABLE(1234b, 3f)
24634 +#endif
24635 +
24636 LOCK_PREFIX
24637 cmpxchg8b (%esi)
24638 jne 1b
24639 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24640 CFI_ADJUST_CFA_OFFSET -8
24641 RESTORE ebx
24642 RESTORE ebp
24643 + pax_force_retaddr
24644 ret
24645 4:
24646 cmpl %edx, 4(%esp)
24647 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24648 xorl %ecx, %ecx
24649 addl $1, %ebx
24650 adcl %edx, %ecx
24651 +
24652 +#ifdef CONFIG_PAX_REFCOUNT
24653 + into
24654 +1234:
24655 + _ASM_EXTABLE(1234b, 3f)
24656 +#endif
24657 +
24658 LOCK_PREFIX
24659 cmpxchg8b (%esi)
24660 jne 1b
24661 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24662 movl $1, %eax
24663 3:
24664 RESTORE ebx
24665 + pax_force_retaddr
24666 ret
24667 CFI_ENDPROC
24668 ENDPROC(atomic64_inc_not_zero_cx8)
24669 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24670 index 2af5df3..62b1a5a 100644
24671 --- a/arch/x86/lib/checksum_32.S
24672 +++ b/arch/x86/lib/checksum_32.S
24673 @@ -29,7 +29,8 @@
24674 #include <asm/dwarf2.h>
24675 #include <asm/errno.h>
24676 #include <asm/asm.h>
24677 -
24678 +#include <asm/segment.h>
24679 +
24680 /*
24681 * computes a partial checksum, e.g. for TCP/UDP fragments
24682 */
24683 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24684
24685 #define ARGBASE 16
24686 #define FP 12
24687 -
24688 -ENTRY(csum_partial_copy_generic)
24689 +
24690 +ENTRY(csum_partial_copy_generic_to_user)
24691 CFI_STARTPROC
24692 +
24693 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24694 + pushl_cfi %gs
24695 + popl_cfi %es
24696 + jmp csum_partial_copy_generic
24697 +#endif
24698 +
24699 +ENTRY(csum_partial_copy_generic_from_user)
24700 +
24701 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24702 + pushl_cfi %gs
24703 + popl_cfi %ds
24704 +#endif
24705 +
24706 +ENTRY(csum_partial_copy_generic)
24707 subl $4,%esp
24708 CFI_ADJUST_CFA_OFFSET 4
24709 pushl_cfi %edi
24710 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24711 jmp 4f
24712 SRC(1: movw (%esi), %bx )
24713 addl $2, %esi
24714 -DST( movw %bx, (%edi) )
24715 +DST( movw %bx, %es:(%edi) )
24716 addl $2, %edi
24717 addw %bx, %ax
24718 adcl $0, %eax
24719 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24720 SRC(1: movl (%esi), %ebx )
24721 SRC( movl 4(%esi), %edx )
24722 adcl %ebx, %eax
24723 -DST( movl %ebx, (%edi) )
24724 +DST( movl %ebx, %es:(%edi) )
24725 adcl %edx, %eax
24726 -DST( movl %edx, 4(%edi) )
24727 +DST( movl %edx, %es:4(%edi) )
24728
24729 SRC( movl 8(%esi), %ebx )
24730 SRC( movl 12(%esi), %edx )
24731 adcl %ebx, %eax
24732 -DST( movl %ebx, 8(%edi) )
24733 +DST( movl %ebx, %es:8(%edi) )
24734 adcl %edx, %eax
24735 -DST( movl %edx, 12(%edi) )
24736 +DST( movl %edx, %es:12(%edi) )
24737
24738 SRC( movl 16(%esi), %ebx )
24739 SRC( movl 20(%esi), %edx )
24740 adcl %ebx, %eax
24741 -DST( movl %ebx, 16(%edi) )
24742 +DST( movl %ebx, %es:16(%edi) )
24743 adcl %edx, %eax
24744 -DST( movl %edx, 20(%edi) )
24745 +DST( movl %edx, %es:20(%edi) )
24746
24747 SRC( movl 24(%esi), %ebx )
24748 SRC( movl 28(%esi), %edx )
24749 adcl %ebx, %eax
24750 -DST( movl %ebx, 24(%edi) )
24751 +DST( movl %ebx, %es:24(%edi) )
24752 adcl %edx, %eax
24753 -DST( movl %edx, 28(%edi) )
24754 +DST( movl %edx, %es:28(%edi) )
24755
24756 lea 32(%esi), %esi
24757 lea 32(%edi), %edi
24758 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24759 shrl $2, %edx # This clears CF
24760 SRC(3: movl (%esi), %ebx )
24761 adcl %ebx, %eax
24762 -DST( movl %ebx, (%edi) )
24763 +DST( movl %ebx, %es:(%edi) )
24764 lea 4(%esi), %esi
24765 lea 4(%edi), %edi
24766 dec %edx
24767 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24768 jb 5f
24769 SRC( movw (%esi), %cx )
24770 leal 2(%esi), %esi
24771 -DST( movw %cx, (%edi) )
24772 +DST( movw %cx, %es:(%edi) )
24773 leal 2(%edi), %edi
24774 je 6f
24775 shll $16,%ecx
24776 SRC(5: movb (%esi), %cl )
24777 -DST( movb %cl, (%edi) )
24778 +DST( movb %cl, %es:(%edi) )
24779 6: addl %ecx, %eax
24780 adcl $0, %eax
24781 7:
24782 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24783
24784 6001:
24785 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24786 - movl $-EFAULT, (%ebx)
24787 + movl $-EFAULT, %ss:(%ebx)
24788
24789 # zero the complete destination - computing the rest
24790 # is too much work
24791 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24792
24793 6002:
24794 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24795 - movl $-EFAULT,(%ebx)
24796 + movl $-EFAULT,%ss:(%ebx)
24797 jmp 5000b
24798
24799 .previous
24800
24801 + pushl_cfi %ss
24802 + popl_cfi %ds
24803 + pushl_cfi %ss
24804 + popl_cfi %es
24805 popl_cfi %ebx
24806 CFI_RESTORE ebx
24807 popl_cfi %esi
24808 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24809 popl_cfi %ecx # equivalent to addl $4,%esp
24810 ret
24811 CFI_ENDPROC
24812 -ENDPROC(csum_partial_copy_generic)
24813 +ENDPROC(csum_partial_copy_generic_to_user)
24814
24815 #else
24816
24817 /* Version for PentiumII/PPro */
24818
24819 #define ROUND1(x) \
24820 + nop; nop; nop; \
24821 SRC(movl x(%esi), %ebx ) ; \
24822 addl %ebx, %eax ; \
24823 - DST(movl %ebx, x(%edi) ) ;
24824 + DST(movl %ebx, %es:x(%edi)) ;
24825
24826 #define ROUND(x) \
24827 + nop; nop; nop; \
24828 SRC(movl x(%esi), %ebx ) ; \
24829 adcl %ebx, %eax ; \
24830 - DST(movl %ebx, x(%edi) ) ;
24831 + DST(movl %ebx, %es:x(%edi)) ;
24832
24833 #define ARGBASE 12
24834 -
24835 -ENTRY(csum_partial_copy_generic)
24836 +
24837 +ENTRY(csum_partial_copy_generic_to_user)
24838 CFI_STARTPROC
24839 +
24840 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24841 + pushl_cfi %gs
24842 + popl_cfi %es
24843 + jmp csum_partial_copy_generic
24844 +#endif
24845 +
24846 +ENTRY(csum_partial_copy_generic_from_user)
24847 +
24848 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24849 + pushl_cfi %gs
24850 + popl_cfi %ds
24851 +#endif
24852 +
24853 +ENTRY(csum_partial_copy_generic)
24854 pushl_cfi %ebx
24855 CFI_REL_OFFSET ebx, 0
24856 pushl_cfi %edi
24857 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24858 subl %ebx, %edi
24859 lea -1(%esi),%edx
24860 andl $-32,%edx
24861 - lea 3f(%ebx,%ebx), %ebx
24862 + lea 3f(%ebx,%ebx,2), %ebx
24863 testl %esi, %esi
24864 jmp *%ebx
24865 1: addl $64,%esi
24866 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24867 jb 5f
24868 SRC( movw (%esi), %dx )
24869 leal 2(%esi), %esi
24870 -DST( movw %dx, (%edi) )
24871 +DST( movw %dx, %es:(%edi) )
24872 leal 2(%edi), %edi
24873 je 6f
24874 shll $16,%edx
24875 5:
24876 SRC( movb (%esi), %dl )
24877 -DST( movb %dl, (%edi) )
24878 +DST( movb %dl, %es:(%edi) )
24879 6: addl %edx, %eax
24880 adcl $0, %eax
24881 7:
24882 .section .fixup, "ax"
24883 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24884 - movl $-EFAULT, (%ebx)
24885 + movl $-EFAULT, %ss:(%ebx)
24886 # zero the complete destination (computing the rest is too much work)
24887 movl ARGBASE+8(%esp),%edi # dst
24888 movl ARGBASE+12(%esp),%ecx # len
24889 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24890 rep; stosb
24891 jmp 7b
24892 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24893 - movl $-EFAULT, (%ebx)
24894 + movl $-EFAULT, %ss:(%ebx)
24895 jmp 7b
24896 .previous
24897
24898 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24899 + pushl_cfi %ss
24900 + popl_cfi %ds
24901 + pushl_cfi %ss
24902 + popl_cfi %es
24903 +#endif
24904 +
24905 popl_cfi %esi
24906 CFI_RESTORE esi
24907 popl_cfi %edi
24908 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
24909 CFI_RESTORE ebx
24910 ret
24911 CFI_ENDPROC
24912 -ENDPROC(csum_partial_copy_generic)
24913 +ENDPROC(csum_partial_copy_generic_to_user)
24914
24915 #undef ROUND
24916 #undef ROUND1
24917 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
24918 index f2145cf..cea889d 100644
24919 --- a/arch/x86/lib/clear_page_64.S
24920 +++ b/arch/x86/lib/clear_page_64.S
24921 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
24922 movl $4096/8,%ecx
24923 xorl %eax,%eax
24924 rep stosq
24925 + pax_force_retaddr
24926 ret
24927 CFI_ENDPROC
24928 ENDPROC(clear_page_c)
24929 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
24930 movl $4096,%ecx
24931 xorl %eax,%eax
24932 rep stosb
24933 + pax_force_retaddr
24934 ret
24935 CFI_ENDPROC
24936 ENDPROC(clear_page_c_e)
24937 @@ -43,6 +45,7 @@ ENTRY(clear_page)
24938 leaq 64(%rdi),%rdi
24939 jnz .Lloop
24940 nop
24941 + pax_force_retaddr
24942 ret
24943 CFI_ENDPROC
24944 .Lclear_page_end:
24945 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
24946
24947 #include <asm/cpufeature.h>
24948
24949 - .section .altinstr_replacement,"ax"
24950 + .section .altinstr_replacement,"a"
24951 1: .byte 0xeb /* jmp <disp8> */
24952 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
24953 2: .byte 0xeb /* jmp <disp8> */
24954 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
24955 index 1e572c5..2a162cd 100644
24956 --- a/arch/x86/lib/cmpxchg16b_emu.S
24957 +++ b/arch/x86/lib/cmpxchg16b_emu.S
24958 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
24959
24960 popf
24961 mov $1, %al
24962 + pax_force_retaddr
24963 ret
24964
24965 not_same:
24966 popf
24967 xor %al,%al
24968 + pax_force_retaddr
24969 ret
24970
24971 CFI_ENDPROC
24972 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
24973 index 176cca6..1166c50 100644
24974 --- a/arch/x86/lib/copy_page_64.S
24975 +++ b/arch/x86/lib/copy_page_64.S
24976 @@ -9,6 +9,7 @@ copy_page_rep:
24977 CFI_STARTPROC
24978 movl $4096/8, %ecx
24979 rep movsq
24980 + pax_force_retaddr
24981 ret
24982 CFI_ENDPROC
24983 ENDPROC(copy_page_rep)
24984 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
24985
24986 ENTRY(copy_page)
24987 CFI_STARTPROC
24988 - subq $2*8, %rsp
24989 - CFI_ADJUST_CFA_OFFSET 2*8
24990 + subq $3*8, %rsp
24991 + CFI_ADJUST_CFA_OFFSET 3*8
24992 movq %rbx, (%rsp)
24993 CFI_REL_OFFSET rbx, 0
24994 movq %r12, 1*8(%rsp)
24995 CFI_REL_OFFSET r12, 1*8
24996 + movq %r13, 2*8(%rsp)
24997 + CFI_REL_OFFSET r13, 2*8
24998
24999 movl $(4096/64)-5, %ecx
25000 .p2align 4
25001 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25002 movq 0x8*2(%rsi), %rdx
25003 movq 0x8*3(%rsi), %r8
25004 movq 0x8*4(%rsi), %r9
25005 - movq 0x8*5(%rsi), %r10
25006 + movq 0x8*5(%rsi), %r13
25007 movq 0x8*6(%rsi), %r11
25008 movq 0x8*7(%rsi), %r12
25009
25010 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25011 movq %rdx, 0x8*2(%rdi)
25012 movq %r8, 0x8*3(%rdi)
25013 movq %r9, 0x8*4(%rdi)
25014 - movq %r10, 0x8*5(%rdi)
25015 + movq %r13, 0x8*5(%rdi)
25016 movq %r11, 0x8*6(%rdi)
25017 movq %r12, 0x8*7(%rdi)
25018
25019 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25020 movq 0x8*2(%rsi), %rdx
25021 movq 0x8*3(%rsi), %r8
25022 movq 0x8*4(%rsi), %r9
25023 - movq 0x8*5(%rsi), %r10
25024 + movq 0x8*5(%rsi), %r13
25025 movq 0x8*6(%rsi), %r11
25026 movq 0x8*7(%rsi), %r12
25027
25028 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25029 movq %rdx, 0x8*2(%rdi)
25030 movq %r8, 0x8*3(%rdi)
25031 movq %r9, 0x8*4(%rdi)
25032 - movq %r10, 0x8*5(%rdi)
25033 + movq %r13, 0x8*5(%rdi)
25034 movq %r11, 0x8*6(%rdi)
25035 movq %r12, 0x8*7(%rdi)
25036
25037 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25038 CFI_RESTORE rbx
25039 movq 1*8(%rsp), %r12
25040 CFI_RESTORE r12
25041 - addq $2*8, %rsp
25042 - CFI_ADJUST_CFA_OFFSET -2*8
25043 + movq 2*8(%rsp), %r13
25044 + CFI_RESTORE r13
25045 + addq $3*8, %rsp
25046 + CFI_ADJUST_CFA_OFFSET -3*8
25047 + pax_force_retaddr
25048 ret
25049 .Lcopy_page_end:
25050 CFI_ENDPROC
25051 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25052
25053 #include <asm/cpufeature.h>
25054
25055 - .section .altinstr_replacement,"ax"
25056 + .section .altinstr_replacement,"a"
25057 1: .byte 0xeb /* jmp <disp8> */
25058 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25059 2:
25060 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25061 index a30ca15..d25fab6 100644
25062 --- a/arch/x86/lib/copy_user_64.S
25063 +++ b/arch/x86/lib/copy_user_64.S
25064 @@ -18,6 +18,7 @@
25065 #include <asm/alternative-asm.h>
25066 #include <asm/asm.h>
25067 #include <asm/smap.h>
25068 +#include <asm/pgtable.h>
25069
25070 /*
25071 * By placing feature2 after feature1 in altinstructions section, we logically
25072 @@ -31,7 +32,7 @@
25073 .byte 0xe9 /* 32bit jump */
25074 .long \orig-1f /* by default jump to orig */
25075 1:
25076 - .section .altinstr_replacement,"ax"
25077 + .section .altinstr_replacement,"a"
25078 2: .byte 0xe9 /* near jump with 32bit immediate */
25079 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25080 3: .byte 0xe9 /* near jump with 32bit immediate */
25081 @@ -70,47 +71,20 @@
25082 #endif
25083 .endm
25084
25085 -/* Standard copy_to_user with segment limit checking */
25086 -ENTRY(_copy_to_user)
25087 - CFI_STARTPROC
25088 - GET_THREAD_INFO(%rax)
25089 - movq %rdi,%rcx
25090 - addq %rdx,%rcx
25091 - jc bad_to_user
25092 - cmpq TI_addr_limit(%rax),%rcx
25093 - ja bad_to_user
25094 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25095 - copy_user_generic_unrolled,copy_user_generic_string, \
25096 - copy_user_enhanced_fast_string
25097 - CFI_ENDPROC
25098 -ENDPROC(_copy_to_user)
25099 -
25100 -/* Standard copy_from_user with segment limit checking */
25101 -ENTRY(_copy_from_user)
25102 - CFI_STARTPROC
25103 - GET_THREAD_INFO(%rax)
25104 - movq %rsi,%rcx
25105 - addq %rdx,%rcx
25106 - jc bad_from_user
25107 - cmpq TI_addr_limit(%rax),%rcx
25108 - ja bad_from_user
25109 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25110 - copy_user_generic_unrolled,copy_user_generic_string, \
25111 - copy_user_enhanced_fast_string
25112 - CFI_ENDPROC
25113 -ENDPROC(_copy_from_user)
25114 -
25115 .section .fixup,"ax"
25116 /* must zero dest */
25117 ENTRY(bad_from_user)
25118 bad_from_user:
25119 CFI_STARTPROC
25120 + testl %edx,%edx
25121 + js bad_to_user
25122 movl %edx,%ecx
25123 xorl %eax,%eax
25124 rep
25125 stosb
25126 bad_to_user:
25127 movl %edx,%eax
25128 + pax_force_retaddr
25129 ret
25130 CFI_ENDPROC
25131 ENDPROC(bad_from_user)
25132 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25133 jz 17f
25134 1: movq (%rsi),%r8
25135 2: movq 1*8(%rsi),%r9
25136 -3: movq 2*8(%rsi),%r10
25137 +3: movq 2*8(%rsi),%rax
25138 4: movq 3*8(%rsi),%r11
25139 5: movq %r8,(%rdi)
25140 6: movq %r9,1*8(%rdi)
25141 -7: movq %r10,2*8(%rdi)
25142 +7: movq %rax,2*8(%rdi)
25143 8: movq %r11,3*8(%rdi)
25144 9: movq 4*8(%rsi),%r8
25145 10: movq 5*8(%rsi),%r9
25146 -11: movq 6*8(%rsi),%r10
25147 +11: movq 6*8(%rsi),%rax
25148 12: movq 7*8(%rsi),%r11
25149 13: movq %r8,4*8(%rdi)
25150 14: movq %r9,5*8(%rdi)
25151 -15: movq %r10,6*8(%rdi)
25152 +15: movq %rax,6*8(%rdi)
25153 16: movq %r11,7*8(%rdi)
25154 leaq 64(%rsi),%rsi
25155 leaq 64(%rdi),%rdi
25156 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25157 jnz 21b
25158 23: xor %eax,%eax
25159 ASM_CLAC
25160 + pax_force_retaddr
25161 ret
25162
25163 .section .fixup,"ax"
25164 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25165 movsb
25166 4: xorl %eax,%eax
25167 ASM_CLAC
25168 + pax_force_retaddr
25169 ret
25170
25171 .section .fixup,"ax"
25172 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25173 movsb
25174 2: xorl %eax,%eax
25175 ASM_CLAC
25176 + pax_force_retaddr
25177 ret
25178
25179 .section .fixup,"ax"
25180 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25181 index 6a4f43c..f5f9e26 100644
25182 --- a/arch/x86/lib/copy_user_nocache_64.S
25183 +++ b/arch/x86/lib/copy_user_nocache_64.S
25184 @@ -8,6 +8,7 @@
25185
25186 #include <linux/linkage.h>
25187 #include <asm/dwarf2.h>
25188 +#include <asm/alternative-asm.h>
25189
25190 #define FIX_ALIGNMENT 1
25191
25192 @@ -16,6 +17,7 @@
25193 #include <asm/thread_info.h>
25194 #include <asm/asm.h>
25195 #include <asm/smap.h>
25196 +#include <asm/pgtable.h>
25197
25198 .macro ALIGN_DESTINATION
25199 #ifdef FIX_ALIGNMENT
25200 @@ -49,6 +51,15 @@
25201 */
25202 ENTRY(__copy_user_nocache)
25203 CFI_STARTPROC
25204 +
25205 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25206 + mov $PAX_USER_SHADOW_BASE,%rcx
25207 + cmp %rcx,%rsi
25208 + jae 1f
25209 + add %rcx,%rsi
25210 +1:
25211 +#endif
25212 +
25213 ASM_STAC
25214 cmpl $8,%edx
25215 jb 20f /* less then 8 bytes, go to byte copy loop */
25216 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25217 jz 17f
25218 1: movq (%rsi),%r8
25219 2: movq 1*8(%rsi),%r9
25220 -3: movq 2*8(%rsi),%r10
25221 +3: movq 2*8(%rsi),%rax
25222 4: movq 3*8(%rsi),%r11
25223 5: movnti %r8,(%rdi)
25224 6: movnti %r9,1*8(%rdi)
25225 -7: movnti %r10,2*8(%rdi)
25226 +7: movnti %rax,2*8(%rdi)
25227 8: movnti %r11,3*8(%rdi)
25228 9: movq 4*8(%rsi),%r8
25229 10: movq 5*8(%rsi),%r9
25230 -11: movq 6*8(%rsi),%r10
25231 +11: movq 6*8(%rsi),%rax
25232 12: movq 7*8(%rsi),%r11
25233 13: movnti %r8,4*8(%rdi)
25234 14: movnti %r9,5*8(%rdi)
25235 -15: movnti %r10,6*8(%rdi)
25236 +15: movnti %rax,6*8(%rdi)
25237 16: movnti %r11,7*8(%rdi)
25238 leaq 64(%rsi),%rsi
25239 leaq 64(%rdi),%rdi
25240 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25241 23: xorl %eax,%eax
25242 ASM_CLAC
25243 sfence
25244 + pax_force_retaddr
25245 ret
25246
25247 .section .fixup,"ax"
25248 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25249 index 2419d5f..953ee51 100644
25250 --- a/arch/x86/lib/csum-copy_64.S
25251 +++ b/arch/x86/lib/csum-copy_64.S
25252 @@ -9,6 +9,7 @@
25253 #include <asm/dwarf2.h>
25254 #include <asm/errno.h>
25255 #include <asm/asm.h>
25256 +#include <asm/alternative-asm.h>
25257
25258 /*
25259 * Checksum copy with exception handling.
25260 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25261 CFI_RESTORE rbp
25262 addq $7*8, %rsp
25263 CFI_ADJUST_CFA_OFFSET -7*8
25264 + pax_force_retaddr 0, 1
25265 ret
25266 CFI_RESTORE_STATE
25267
25268 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25269 index 25b7ae8..169fafc 100644
25270 --- a/arch/x86/lib/csum-wrappers_64.c
25271 +++ b/arch/x86/lib/csum-wrappers_64.c
25272 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25273 len -= 2;
25274 }
25275 }
25276 - isum = csum_partial_copy_generic((__force const void *)src,
25277 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25278 dst, len, isum, errp, NULL);
25279 if (unlikely(*errp))
25280 goto out_err;
25281 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25282 }
25283
25284 *errp = 0;
25285 - return csum_partial_copy_generic(src, (void __force *)dst,
25286 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25287 len, isum, NULL, errp);
25288 }
25289 EXPORT_SYMBOL(csum_partial_copy_to_user);
25290 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25291 index 156b9c8..b144132 100644
25292 --- a/arch/x86/lib/getuser.S
25293 +++ b/arch/x86/lib/getuser.S
25294 @@ -34,17 +34,40 @@
25295 #include <asm/thread_info.h>
25296 #include <asm/asm.h>
25297 #include <asm/smap.h>
25298 +#include <asm/segment.h>
25299 +#include <asm/pgtable.h>
25300 +#include <asm/alternative-asm.h>
25301 +
25302 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25303 +#define __copyuser_seg gs;
25304 +#else
25305 +#define __copyuser_seg
25306 +#endif
25307
25308 .text
25309 ENTRY(__get_user_1)
25310 CFI_STARTPROC
25311 +
25312 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25313 GET_THREAD_INFO(%_ASM_DX)
25314 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25315 jae bad_get_user
25316 ASM_STAC
25317 -1: movzb (%_ASM_AX),%edx
25318 +
25319 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25320 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25321 + cmp %_ASM_DX,%_ASM_AX
25322 + jae 1234f
25323 + add %_ASM_DX,%_ASM_AX
25324 +1234:
25325 +#endif
25326 +
25327 +#endif
25328 +
25329 +1: __copyuser_seg movzb (%_ASM_AX),%edx
25330 xor %eax,%eax
25331 ASM_CLAC
25332 + pax_force_retaddr
25333 ret
25334 CFI_ENDPROC
25335 ENDPROC(__get_user_1)
25336 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
25337 ENTRY(__get_user_2)
25338 CFI_STARTPROC
25339 add $1,%_ASM_AX
25340 +
25341 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25342 jc bad_get_user
25343 GET_THREAD_INFO(%_ASM_DX)
25344 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25345 jae bad_get_user
25346 ASM_STAC
25347 -2: movzwl -1(%_ASM_AX),%edx
25348 +
25349 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25350 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25351 + cmp %_ASM_DX,%_ASM_AX
25352 + jae 1234f
25353 + add %_ASM_DX,%_ASM_AX
25354 +1234:
25355 +#endif
25356 +
25357 +#endif
25358 +
25359 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25360 xor %eax,%eax
25361 ASM_CLAC
25362 + pax_force_retaddr
25363 ret
25364 CFI_ENDPROC
25365 ENDPROC(__get_user_2)
25366 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
25367 ENTRY(__get_user_4)
25368 CFI_STARTPROC
25369 add $3,%_ASM_AX
25370 +
25371 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25372 jc bad_get_user
25373 GET_THREAD_INFO(%_ASM_DX)
25374 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25375 jae bad_get_user
25376 ASM_STAC
25377 -3: mov -3(%_ASM_AX),%edx
25378 +
25379 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25380 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25381 + cmp %_ASM_DX,%_ASM_AX
25382 + jae 1234f
25383 + add %_ASM_DX,%_ASM_AX
25384 +1234:
25385 +#endif
25386 +
25387 +#endif
25388 +
25389 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
25390 xor %eax,%eax
25391 ASM_CLAC
25392 + pax_force_retaddr
25393 ret
25394 CFI_ENDPROC
25395 ENDPROC(__get_user_4)
25396 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
25397 GET_THREAD_INFO(%_ASM_DX)
25398 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25399 jae bad_get_user
25400 +
25401 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25402 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25403 + cmp %_ASM_DX,%_ASM_AX
25404 + jae 1234f
25405 + add %_ASM_DX,%_ASM_AX
25406 +1234:
25407 +#endif
25408 +
25409 ASM_STAC
25410 4: movq -7(%_ASM_AX),%_ASM_DX
25411 xor %eax,%eax
25412 ASM_CLAC
25413 + pax_force_retaddr
25414 ret
25415 CFI_ENDPROC
25416 ENDPROC(__get_user_8)
25417 @@ -101,6 +162,7 @@ bad_get_user:
25418 xor %edx,%edx
25419 mov $(-EFAULT),%_ASM_AX
25420 ASM_CLAC
25421 + pax_force_retaddr
25422 ret
25423 CFI_ENDPROC
25424 END(bad_get_user)
25425 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25426 index 54fcffe..7be149e 100644
25427 --- a/arch/x86/lib/insn.c
25428 +++ b/arch/x86/lib/insn.c
25429 @@ -20,8 +20,10 @@
25430
25431 #ifdef __KERNEL__
25432 #include <linux/string.h>
25433 +#include <asm/pgtable_types.h>
25434 #else
25435 #include <string.h>
25436 +#define ktla_ktva(addr) addr
25437 #endif
25438 #include <asm/inat.h>
25439 #include <asm/insn.h>
25440 @@ -53,8 +55,8 @@
25441 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25442 {
25443 memset(insn, 0, sizeof(*insn));
25444 - insn->kaddr = kaddr;
25445 - insn->next_byte = kaddr;
25446 + insn->kaddr = ktla_ktva(kaddr);
25447 + insn->next_byte = ktla_ktva(kaddr);
25448 insn->x86_64 = x86_64 ? 1 : 0;
25449 insn->opnd_bytes = 4;
25450 if (x86_64)
25451 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25452 index 05a95e7..326f2fa 100644
25453 --- a/arch/x86/lib/iomap_copy_64.S
25454 +++ b/arch/x86/lib/iomap_copy_64.S
25455 @@ -17,6 +17,7 @@
25456
25457 #include <linux/linkage.h>
25458 #include <asm/dwarf2.h>
25459 +#include <asm/alternative-asm.h>
25460
25461 /*
25462 * override generic version in lib/iomap_copy.c
25463 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25464 CFI_STARTPROC
25465 movl %edx,%ecx
25466 rep movsd
25467 + pax_force_retaddr
25468 ret
25469 CFI_ENDPROC
25470 ENDPROC(__iowrite32_copy)
25471 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25472 index 1c273be..da9cc0e 100644
25473 --- a/arch/x86/lib/memcpy_64.S
25474 +++ b/arch/x86/lib/memcpy_64.S
25475 @@ -33,6 +33,7 @@
25476 rep movsq
25477 movl %edx, %ecx
25478 rep movsb
25479 + pax_force_retaddr
25480 ret
25481 .Lmemcpy_e:
25482 .previous
25483 @@ -49,6 +50,7 @@
25484 movq %rdi, %rax
25485 movq %rdx, %rcx
25486 rep movsb
25487 + pax_force_retaddr
25488 ret
25489 .Lmemcpy_e_e:
25490 .previous
25491 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25492 */
25493 movq 0*8(%rsi), %r8
25494 movq 1*8(%rsi), %r9
25495 - movq 2*8(%rsi), %r10
25496 + movq 2*8(%rsi), %rcx
25497 movq 3*8(%rsi), %r11
25498 leaq 4*8(%rsi), %rsi
25499
25500 movq %r8, 0*8(%rdi)
25501 movq %r9, 1*8(%rdi)
25502 - movq %r10, 2*8(%rdi)
25503 + movq %rcx, 2*8(%rdi)
25504 movq %r11, 3*8(%rdi)
25505 leaq 4*8(%rdi), %rdi
25506 jae .Lcopy_forward_loop
25507 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25508 subq $0x20, %rdx
25509 movq -1*8(%rsi), %r8
25510 movq -2*8(%rsi), %r9
25511 - movq -3*8(%rsi), %r10
25512 + movq -3*8(%rsi), %rcx
25513 movq -4*8(%rsi), %r11
25514 leaq -4*8(%rsi), %rsi
25515 movq %r8, -1*8(%rdi)
25516 movq %r9, -2*8(%rdi)
25517 - movq %r10, -3*8(%rdi)
25518 + movq %rcx, -3*8(%rdi)
25519 movq %r11, -4*8(%rdi)
25520 leaq -4*8(%rdi), %rdi
25521 jae .Lcopy_backward_loop
25522 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25523 */
25524 movq 0*8(%rsi), %r8
25525 movq 1*8(%rsi), %r9
25526 - movq -2*8(%rsi, %rdx), %r10
25527 + movq -2*8(%rsi, %rdx), %rcx
25528 movq -1*8(%rsi, %rdx), %r11
25529 movq %r8, 0*8(%rdi)
25530 movq %r9, 1*8(%rdi)
25531 - movq %r10, -2*8(%rdi, %rdx)
25532 + movq %rcx, -2*8(%rdi, %rdx)
25533 movq %r11, -1*8(%rdi, %rdx)
25534 + pax_force_retaddr
25535 retq
25536 .p2align 4
25537 .Lless_16bytes:
25538 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25539 movq -1*8(%rsi, %rdx), %r9
25540 movq %r8, 0*8(%rdi)
25541 movq %r9, -1*8(%rdi, %rdx)
25542 + pax_force_retaddr
25543 retq
25544 .p2align 4
25545 .Lless_8bytes:
25546 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25547 movl -4(%rsi, %rdx), %r8d
25548 movl %ecx, (%rdi)
25549 movl %r8d, -4(%rdi, %rdx)
25550 + pax_force_retaddr
25551 retq
25552 .p2align 4
25553 .Lless_3bytes:
25554 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25555 movb %cl, (%rdi)
25556
25557 .Lend:
25558 + pax_force_retaddr
25559 retq
25560 CFI_ENDPROC
25561 ENDPROC(memcpy)
25562 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25563 index ee16461..c39c199 100644
25564 --- a/arch/x86/lib/memmove_64.S
25565 +++ b/arch/x86/lib/memmove_64.S
25566 @@ -61,13 +61,13 @@ ENTRY(memmove)
25567 5:
25568 sub $0x20, %rdx
25569 movq 0*8(%rsi), %r11
25570 - movq 1*8(%rsi), %r10
25571 + movq 1*8(%rsi), %rcx
25572 movq 2*8(%rsi), %r9
25573 movq 3*8(%rsi), %r8
25574 leaq 4*8(%rsi), %rsi
25575
25576 movq %r11, 0*8(%rdi)
25577 - movq %r10, 1*8(%rdi)
25578 + movq %rcx, 1*8(%rdi)
25579 movq %r9, 2*8(%rdi)
25580 movq %r8, 3*8(%rdi)
25581 leaq 4*8(%rdi), %rdi
25582 @@ -81,10 +81,10 @@ ENTRY(memmove)
25583 4:
25584 movq %rdx, %rcx
25585 movq -8(%rsi, %rdx), %r11
25586 - lea -8(%rdi, %rdx), %r10
25587 + lea -8(%rdi, %rdx), %r9
25588 shrq $3, %rcx
25589 rep movsq
25590 - movq %r11, (%r10)
25591 + movq %r11, (%r9)
25592 jmp 13f
25593 .Lmemmove_end_forward:
25594
25595 @@ -95,14 +95,14 @@ ENTRY(memmove)
25596 7:
25597 movq %rdx, %rcx
25598 movq (%rsi), %r11
25599 - movq %rdi, %r10
25600 + movq %rdi, %r9
25601 leaq -8(%rsi, %rdx), %rsi
25602 leaq -8(%rdi, %rdx), %rdi
25603 shrq $3, %rcx
25604 std
25605 rep movsq
25606 cld
25607 - movq %r11, (%r10)
25608 + movq %r11, (%r9)
25609 jmp 13f
25610
25611 /*
25612 @@ -127,13 +127,13 @@ ENTRY(memmove)
25613 8:
25614 subq $0x20, %rdx
25615 movq -1*8(%rsi), %r11
25616 - movq -2*8(%rsi), %r10
25617 + movq -2*8(%rsi), %rcx
25618 movq -3*8(%rsi), %r9
25619 movq -4*8(%rsi), %r8
25620 leaq -4*8(%rsi), %rsi
25621
25622 movq %r11, -1*8(%rdi)
25623 - movq %r10, -2*8(%rdi)
25624 + movq %rcx, -2*8(%rdi)
25625 movq %r9, -3*8(%rdi)
25626 movq %r8, -4*8(%rdi)
25627 leaq -4*8(%rdi), %rdi
25628 @@ -151,11 +151,11 @@ ENTRY(memmove)
25629 * Move data from 16 bytes to 31 bytes.
25630 */
25631 movq 0*8(%rsi), %r11
25632 - movq 1*8(%rsi), %r10
25633 + movq 1*8(%rsi), %rcx
25634 movq -2*8(%rsi, %rdx), %r9
25635 movq -1*8(%rsi, %rdx), %r8
25636 movq %r11, 0*8(%rdi)
25637 - movq %r10, 1*8(%rdi)
25638 + movq %rcx, 1*8(%rdi)
25639 movq %r9, -2*8(%rdi, %rdx)
25640 movq %r8, -1*8(%rdi, %rdx)
25641 jmp 13f
25642 @@ -167,9 +167,9 @@ ENTRY(memmove)
25643 * Move data from 8 bytes to 15 bytes.
25644 */
25645 movq 0*8(%rsi), %r11
25646 - movq -1*8(%rsi, %rdx), %r10
25647 + movq -1*8(%rsi, %rdx), %r9
25648 movq %r11, 0*8(%rdi)
25649 - movq %r10, -1*8(%rdi, %rdx)
25650 + movq %r9, -1*8(%rdi, %rdx)
25651 jmp 13f
25652 10:
25653 cmpq $4, %rdx
25654 @@ -178,9 +178,9 @@ ENTRY(memmove)
25655 * Move data from 4 bytes to 7 bytes.
25656 */
25657 movl (%rsi), %r11d
25658 - movl -4(%rsi, %rdx), %r10d
25659 + movl -4(%rsi, %rdx), %r9d
25660 movl %r11d, (%rdi)
25661 - movl %r10d, -4(%rdi, %rdx)
25662 + movl %r9d, -4(%rdi, %rdx)
25663 jmp 13f
25664 11:
25665 cmp $2, %rdx
25666 @@ -189,9 +189,9 @@ ENTRY(memmove)
25667 * Move data from 2 bytes to 3 bytes.
25668 */
25669 movw (%rsi), %r11w
25670 - movw -2(%rsi, %rdx), %r10w
25671 + movw -2(%rsi, %rdx), %r9w
25672 movw %r11w, (%rdi)
25673 - movw %r10w, -2(%rdi, %rdx)
25674 + movw %r9w, -2(%rdi, %rdx)
25675 jmp 13f
25676 12:
25677 cmp $1, %rdx
25678 @@ -202,6 +202,7 @@ ENTRY(memmove)
25679 movb (%rsi), %r11b
25680 movb %r11b, (%rdi)
25681 13:
25682 + pax_force_retaddr
25683 retq
25684 CFI_ENDPROC
25685
25686 @@ -210,6 +211,7 @@ ENTRY(memmove)
25687 /* Forward moving data. */
25688 movq %rdx, %rcx
25689 rep movsb
25690 + pax_force_retaddr
25691 retq
25692 .Lmemmove_end_forward_efs:
25693 .previous
25694 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25695 index 2dcb380..963660a 100644
25696 --- a/arch/x86/lib/memset_64.S
25697 +++ b/arch/x86/lib/memset_64.S
25698 @@ -30,6 +30,7 @@
25699 movl %edx,%ecx
25700 rep stosb
25701 movq %r9,%rax
25702 + pax_force_retaddr
25703 ret
25704 .Lmemset_e:
25705 .previous
25706 @@ -52,6 +53,7 @@
25707 movq %rdx,%rcx
25708 rep stosb
25709 movq %r9,%rax
25710 + pax_force_retaddr
25711 ret
25712 .Lmemset_e_e:
25713 .previous
25714 @@ -59,7 +61,7 @@
25715 ENTRY(memset)
25716 ENTRY(__memset)
25717 CFI_STARTPROC
25718 - movq %rdi,%r10
25719 + movq %rdi,%r11
25720
25721 /* expand byte value */
25722 movzbl %sil,%ecx
25723 @@ -117,7 +119,8 @@ ENTRY(__memset)
25724 jnz .Lloop_1
25725
25726 .Lende:
25727 - movq %r10,%rax
25728 + movq %r11,%rax
25729 + pax_force_retaddr
25730 ret
25731
25732 CFI_RESTORE_STATE
25733 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25734 index c9f2d9b..e7fd2c0 100644
25735 --- a/arch/x86/lib/mmx_32.c
25736 +++ b/arch/x86/lib/mmx_32.c
25737 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25738 {
25739 void *p;
25740 int i;
25741 + unsigned long cr0;
25742
25743 if (unlikely(in_interrupt()))
25744 return __memcpy(to, from, len);
25745 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25746 kernel_fpu_begin();
25747
25748 __asm__ __volatile__ (
25749 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25750 - " prefetch 64(%0)\n"
25751 - " prefetch 128(%0)\n"
25752 - " prefetch 192(%0)\n"
25753 - " prefetch 256(%0)\n"
25754 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25755 + " prefetch 64(%1)\n"
25756 + " prefetch 128(%1)\n"
25757 + " prefetch 192(%1)\n"
25758 + " prefetch 256(%1)\n"
25759 "2: \n"
25760 ".section .fixup, \"ax\"\n"
25761 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25762 + "3: \n"
25763 +
25764 +#ifdef CONFIG_PAX_KERNEXEC
25765 + " movl %%cr0, %0\n"
25766 + " movl %0, %%eax\n"
25767 + " andl $0xFFFEFFFF, %%eax\n"
25768 + " movl %%eax, %%cr0\n"
25769 +#endif
25770 +
25771 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25772 +
25773 +#ifdef CONFIG_PAX_KERNEXEC
25774 + " movl %0, %%cr0\n"
25775 +#endif
25776 +
25777 " jmp 2b\n"
25778 ".previous\n"
25779 _ASM_EXTABLE(1b, 3b)
25780 - : : "r" (from));
25781 + : "=&r" (cr0) : "r" (from) : "ax");
25782
25783 for ( ; i > 5; i--) {
25784 __asm__ __volatile__ (
25785 - "1: prefetch 320(%0)\n"
25786 - "2: movq (%0), %%mm0\n"
25787 - " movq 8(%0), %%mm1\n"
25788 - " movq 16(%0), %%mm2\n"
25789 - " movq 24(%0), %%mm3\n"
25790 - " movq %%mm0, (%1)\n"
25791 - " movq %%mm1, 8(%1)\n"
25792 - " movq %%mm2, 16(%1)\n"
25793 - " movq %%mm3, 24(%1)\n"
25794 - " movq 32(%0), %%mm0\n"
25795 - " movq 40(%0), %%mm1\n"
25796 - " movq 48(%0), %%mm2\n"
25797 - " movq 56(%0), %%mm3\n"
25798 - " movq %%mm0, 32(%1)\n"
25799 - " movq %%mm1, 40(%1)\n"
25800 - " movq %%mm2, 48(%1)\n"
25801 - " movq %%mm3, 56(%1)\n"
25802 + "1: prefetch 320(%1)\n"
25803 + "2: movq (%1), %%mm0\n"
25804 + " movq 8(%1), %%mm1\n"
25805 + " movq 16(%1), %%mm2\n"
25806 + " movq 24(%1), %%mm3\n"
25807 + " movq %%mm0, (%2)\n"
25808 + " movq %%mm1, 8(%2)\n"
25809 + " movq %%mm2, 16(%2)\n"
25810 + " movq %%mm3, 24(%2)\n"
25811 + " movq 32(%1), %%mm0\n"
25812 + " movq 40(%1), %%mm1\n"
25813 + " movq 48(%1), %%mm2\n"
25814 + " movq 56(%1), %%mm3\n"
25815 + " movq %%mm0, 32(%2)\n"
25816 + " movq %%mm1, 40(%2)\n"
25817 + " movq %%mm2, 48(%2)\n"
25818 + " movq %%mm3, 56(%2)\n"
25819 ".section .fixup, \"ax\"\n"
25820 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25821 + "3:\n"
25822 +
25823 +#ifdef CONFIG_PAX_KERNEXEC
25824 + " movl %%cr0, %0\n"
25825 + " movl %0, %%eax\n"
25826 + " andl $0xFFFEFFFF, %%eax\n"
25827 + " movl %%eax, %%cr0\n"
25828 +#endif
25829 +
25830 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25831 +
25832 +#ifdef CONFIG_PAX_KERNEXEC
25833 + " movl %0, %%cr0\n"
25834 +#endif
25835 +
25836 " jmp 2b\n"
25837 ".previous\n"
25838 _ASM_EXTABLE(1b, 3b)
25839 - : : "r" (from), "r" (to) : "memory");
25840 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25841
25842 from += 64;
25843 to += 64;
25844 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25845 static void fast_copy_page(void *to, void *from)
25846 {
25847 int i;
25848 + unsigned long cr0;
25849
25850 kernel_fpu_begin();
25851
25852 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25853 * but that is for later. -AV
25854 */
25855 __asm__ __volatile__(
25856 - "1: prefetch (%0)\n"
25857 - " prefetch 64(%0)\n"
25858 - " prefetch 128(%0)\n"
25859 - " prefetch 192(%0)\n"
25860 - " prefetch 256(%0)\n"
25861 + "1: prefetch (%1)\n"
25862 + " prefetch 64(%1)\n"
25863 + " prefetch 128(%1)\n"
25864 + " prefetch 192(%1)\n"
25865 + " prefetch 256(%1)\n"
25866 "2: \n"
25867 ".section .fixup, \"ax\"\n"
25868 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25869 + "3: \n"
25870 +
25871 +#ifdef CONFIG_PAX_KERNEXEC
25872 + " movl %%cr0, %0\n"
25873 + " movl %0, %%eax\n"
25874 + " andl $0xFFFEFFFF, %%eax\n"
25875 + " movl %%eax, %%cr0\n"
25876 +#endif
25877 +
25878 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25879 +
25880 +#ifdef CONFIG_PAX_KERNEXEC
25881 + " movl %0, %%cr0\n"
25882 +#endif
25883 +
25884 " jmp 2b\n"
25885 ".previous\n"
25886 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25887 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25888
25889 for (i = 0; i < (4096-320)/64; i++) {
25890 __asm__ __volatile__ (
25891 - "1: prefetch 320(%0)\n"
25892 - "2: movq (%0), %%mm0\n"
25893 - " movntq %%mm0, (%1)\n"
25894 - " movq 8(%0), %%mm1\n"
25895 - " movntq %%mm1, 8(%1)\n"
25896 - " movq 16(%0), %%mm2\n"
25897 - " movntq %%mm2, 16(%1)\n"
25898 - " movq 24(%0), %%mm3\n"
25899 - " movntq %%mm3, 24(%1)\n"
25900 - " movq 32(%0), %%mm4\n"
25901 - " movntq %%mm4, 32(%1)\n"
25902 - " movq 40(%0), %%mm5\n"
25903 - " movntq %%mm5, 40(%1)\n"
25904 - " movq 48(%0), %%mm6\n"
25905 - " movntq %%mm6, 48(%1)\n"
25906 - " movq 56(%0), %%mm7\n"
25907 - " movntq %%mm7, 56(%1)\n"
25908 + "1: prefetch 320(%1)\n"
25909 + "2: movq (%1), %%mm0\n"
25910 + " movntq %%mm0, (%2)\n"
25911 + " movq 8(%1), %%mm1\n"
25912 + " movntq %%mm1, 8(%2)\n"
25913 + " movq 16(%1), %%mm2\n"
25914 + " movntq %%mm2, 16(%2)\n"
25915 + " movq 24(%1), %%mm3\n"
25916 + " movntq %%mm3, 24(%2)\n"
25917 + " movq 32(%1), %%mm4\n"
25918 + " movntq %%mm4, 32(%2)\n"
25919 + " movq 40(%1), %%mm5\n"
25920 + " movntq %%mm5, 40(%2)\n"
25921 + " movq 48(%1), %%mm6\n"
25922 + " movntq %%mm6, 48(%2)\n"
25923 + " movq 56(%1), %%mm7\n"
25924 + " movntq %%mm7, 56(%2)\n"
25925 ".section .fixup, \"ax\"\n"
25926 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25927 + "3:\n"
25928 +
25929 +#ifdef CONFIG_PAX_KERNEXEC
25930 + " movl %%cr0, %0\n"
25931 + " movl %0, %%eax\n"
25932 + " andl $0xFFFEFFFF, %%eax\n"
25933 + " movl %%eax, %%cr0\n"
25934 +#endif
25935 +
25936 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25937 +
25938 +#ifdef CONFIG_PAX_KERNEXEC
25939 + " movl %0, %%cr0\n"
25940 +#endif
25941 +
25942 " jmp 2b\n"
25943 ".previous\n"
25944 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
25945 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25946
25947 from += 64;
25948 to += 64;
25949 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
25950 static void fast_copy_page(void *to, void *from)
25951 {
25952 int i;
25953 + unsigned long cr0;
25954
25955 kernel_fpu_begin();
25956
25957 __asm__ __volatile__ (
25958 - "1: prefetch (%0)\n"
25959 - " prefetch 64(%0)\n"
25960 - " prefetch 128(%0)\n"
25961 - " prefetch 192(%0)\n"
25962 - " prefetch 256(%0)\n"
25963 + "1: prefetch (%1)\n"
25964 + " prefetch 64(%1)\n"
25965 + " prefetch 128(%1)\n"
25966 + " prefetch 192(%1)\n"
25967 + " prefetch 256(%1)\n"
25968 "2: \n"
25969 ".section .fixup, \"ax\"\n"
25970 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25971 + "3: \n"
25972 +
25973 +#ifdef CONFIG_PAX_KERNEXEC
25974 + " movl %%cr0, %0\n"
25975 + " movl %0, %%eax\n"
25976 + " andl $0xFFFEFFFF, %%eax\n"
25977 + " movl %%eax, %%cr0\n"
25978 +#endif
25979 +
25980 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25981 +
25982 +#ifdef CONFIG_PAX_KERNEXEC
25983 + " movl %0, %%cr0\n"
25984 +#endif
25985 +
25986 " jmp 2b\n"
25987 ".previous\n"
25988 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25989 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25990
25991 for (i = 0; i < 4096/64; i++) {
25992 __asm__ __volatile__ (
25993 - "1: prefetch 320(%0)\n"
25994 - "2: movq (%0), %%mm0\n"
25995 - " movq 8(%0), %%mm1\n"
25996 - " movq 16(%0), %%mm2\n"
25997 - " movq 24(%0), %%mm3\n"
25998 - " movq %%mm0, (%1)\n"
25999 - " movq %%mm1, 8(%1)\n"
26000 - " movq %%mm2, 16(%1)\n"
26001 - " movq %%mm3, 24(%1)\n"
26002 - " movq 32(%0), %%mm0\n"
26003 - " movq 40(%0), %%mm1\n"
26004 - " movq 48(%0), %%mm2\n"
26005 - " movq 56(%0), %%mm3\n"
26006 - " movq %%mm0, 32(%1)\n"
26007 - " movq %%mm1, 40(%1)\n"
26008 - " movq %%mm2, 48(%1)\n"
26009 - " movq %%mm3, 56(%1)\n"
26010 + "1: prefetch 320(%1)\n"
26011 + "2: movq (%1), %%mm0\n"
26012 + " movq 8(%1), %%mm1\n"
26013 + " movq 16(%1), %%mm2\n"
26014 + " movq 24(%1), %%mm3\n"
26015 + " movq %%mm0, (%2)\n"
26016 + " movq %%mm1, 8(%2)\n"
26017 + " movq %%mm2, 16(%2)\n"
26018 + " movq %%mm3, 24(%2)\n"
26019 + " movq 32(%1), %%mm0\n"
26020 + " movq 40(%1), %%mm1\n"
26021 + " movq 48(%1), %%mm2\n"
26022 + " movq 56(%1), %%mm3\n"
26023 + " movq %%mm0, 32(%2)\n"
26024 + " movq %%mm1, 40(%2)\n"
26025 + " movq %%mm2, 48(%2)\n"
26026 + " movq %%mm3, 56(%2)\n"
26027 ".section .fixup, \"ax\"\n"
26028 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26029 + "3:\n"
26030 +
26031 +#ifdef CONFIG_PAX_KERNEXEC
26032 + " movl %%cr0, %0\n"
26033 + " movl %0, %%eax\n"
26034 + " andl $0xFFFEFFFF, %%eax\n"
26035 + " movl %%eax, %%cr0\n"
26036 +#endif
26037 +
26038 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26039 +
26040 +#ifdef CONFIG_PAX_KERNEXEC
26041 + " movl %0, %%cr0\n"
26042 +#endif
26043 +
26044 " jmp 2b\n"
26045 ".previous\n"
26046 _ASM_EXTABLE(1b, 3b)
26047 - : : "r" (from), "r" (to) : "memory");
26048 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26049
26050 from += 64;
26051 to += 64;
26052 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26053 index f6d13ee..aca5f0b 100644
26054 --- a/arch/x86/lib/msr-reg.S
26055 +++ b/arch/x86/lib/msr-reg.S
26056 @@ -3,6 +3,7 @@
26057 #include <asm/dwarf2.h>
26058 #include <asm/asm.h>
26059 #include <asm/msr.h>
26060 +#include <asm/alternative-asm.h>
26061
26062 #ifdef CONFIG_X86_64
26063 /*
26064 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26065 CFI_STARTPROC
26066 pushq_cfi %rbx
26067 pushq_cfi %rbp
26068 - movq %rdi, %r10 /* Save pointer */
26069 + movq %rdi, %r9 /* Save pointer */
26070 xorl %r11d, %r11d /* Return value */
26071 movl (%rdi), %eax
26072 movl 4(%rdi), %ecx
26073 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26074 movl 28(%rdi), %edi
26075 CFI_REMEMBER_STATE
26076 1: \op
26077 -2: movl %eax, (%r10)
26078 +2: movl %eax, (%r9)
26079 movl %r11d, %eax /* Return value */
26080 - movl %ecx, 4(%r10)
26081 - movl %edx, 8(%r10)
26082 - movl %ebx, 12(%r10)
26083 - movl %ebp, 20(%r10)
26084 - movl %esi, 24(%r10)
26085 - movl %edi, 28(%r10)
26086 + movl %ecx, 4(%r9)
26087 + movl %edx, 8(%r9)
26088 + movl %ebx, 12(%r9)
26089 + movl %ebp, 20(%r9)
26090 + movl %esi, 24(%r9)
26091 + movl %edi, 28(%r9)
26092 popq_cfi %rbp
26093 popq_cfi %rbx
26094 + pax_force_retaddr
26095 ret
26096 3:
26097 CFI_RESTORE_STATE
26098 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26099 index fc6ba17..04471c5 100644
26100 --- a/arch/x86/lib/putuser.S
26101 +++ b/arch/x86/lib/putuser.S
26102 @@ -16,7 +16,9 @@
26103 #include <asm/errno.h>
26104 #include <asm/asm.h>
26105 #include <asm/smap.h>
26106 -
26107 +#include <asm/segment.h>
26108 +#include <asm/pgtable.h>
26109 +#include <asm/alternative-asm.h>
26110
26111 /*
26112 * __put_user_X
26113 @@ -30,57 +32,125 @@
26114 * as they get called from within inline assembly.
26115 */
26116
26117 -#define ENTER CFI_STARTPROC ; \
26118 - GET_THREAD_INFO(%_ASM_BX)
26119 -#define EXIT ASM_CLAC ; \
26120 - ret ; \
26121 +#define ENTER CFI_STARTPROC
26122 +#define EXIT ASM_CLAC ; \
26123 + pax_force_retaddr ; \
26124 + ret ; \
26125 CFI_ENDPROC
26126
26127 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26128 +#define _DEST %_ASM_CX,%_ASM_BX
26129 +#else
26130 +#define _DEST %_ASM_CX
26131 +#endif
26132 +
26133 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26134 +#define __copyuser_seg gs;
26135 +#else
26136 +#define __copyuser_seg
26137 +#endif
26138 +
26139 .text
26140 ENTRY(__put_user_1)
26141 ENTER
26142 +
26143 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26144 + GET_THREAD_INFO(%_ASM_BX)
26145 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26146 jae bad_put_user
26147 ASM_STAC
26148 -1: movb %al,(%_ASM_CX)
26149 +
26150 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26151 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26152 + cmp %_ASM_BX,%_ASM_CX
26153 + jb 1234f
26154 + xor %ebx,%ebx
26155 +1234:
26156 +#endif
26157 +
26158 +#endif
26159 +
26160 +1: __copyuser_seg movb %al,(_DEST)
26161 xor %eax,%eax
26162 EXIT
26163 ENDPROC(__put_user_1)
26164
26165 ENTRY(__put_user_2)
26166 ENTER
26167 +
26168 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26169 + GET_THREAD_INFO(%_ASM_BX)
26170 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26171 sub $1,%_ASM_BX
26172 cmp %_ASM_BX,%_ASM_CX
26173 jae bad_put_user
26174 ASM_STAC
26175 -2: movw %ax,(%_ASM_CX)
26176 +
26177 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26178 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26179 + cmp %_ASM_BX,%_ASM_CX
26180 + jb 1234f
26181 + xor %ebx,%ebx
26182 +1234:
26183 +#endif
26184 +
26185 +#endif
26186 +
26187 +2: __copyuser_seg movw %ax,(_DEST)
26188 xor %eax,%eax
26189 EXIT
26190 ENDPROC(__put_user_2)
26191
26192 ENTRY(__put_user_4)
26193 ENTER
26194 +
26195 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26196 + GET_THREAD_INFO(%_ASM_BX)
26197 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26198 sub $3,%_ASM_BX
26199 cmp %_ASM_BX,%_ASM_CX
26200 jae bad_put_user
26201 ASM_STAC
26202 -3: movl %eax,(%_ASM_CX)
26203 +
26204 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26205 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26206 + cmp %_ASM_BX,%_ASM_CX
26207 + jb 1234f
26208 + xor %ebx,%ebx
26209 +1234:
26210 +#endif
26211 +
26212 +#endif
26213 +
26214 +3: __copyuser_seg movl %eax,(_DEST)
26215 xor %eax,%eax
26216 EXIT
26217 ENDPROC(__put_user_4)
26218
26219 ENTRY(__put_user_8)
26220 ENTER
26221 +
26222 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26223 + GET_THREAD_INFO(%_ASM_BX)
26224 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26225 sub $7,%_ASM_BX
26226 cmp %_ASM_BX,%_ASM_CX
26227 jae bad_put_user
26228 ASM_STAC
26229 -4: mov %_ASM_AX,(%_ASM_CX)
26230 +
26231 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26232 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26233 + cmp %_ASM_BX,%_ASM_CX
26234 + jb 1234f
26235 + xor %ebx,%ebx
26236 +1234:
26237 +#endif
26238 +
26239 +#endif
26240 +
26241 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26242 #ifdef CONFIG_X86_32
26243 -5: movl %edx,4(%_ASM_CX)
26244 +5: __copyuser_seg movl %edx,4(_DEST)
26245 #endif
26246 xor %eax,%eax
26247 EXIT
26248 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26249 index 1cad221..de671ee 100644
26250 --- a/arch/x86/lib/rwlock.S
26251 +++ b/arch/x86/lib/rwlock.S
26252 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26253 FRAME
26254 0: LOCK_PREFIX
26255 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26256 +
26257 +#ifdef CONFIG_PAX_REFCOUNT
26258 + jno 1234f
26259 + LOCK_PREFIX
26260 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26261 + int $4
26262 +1234:
26263 + _ASM_EXTABLE(1234b, 1234b)
26264 +#endif
26265 +
26266 1: rep; nop
26267 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26268 jne 1b
26269 LOCK_PREFIX
26270 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26271 +
26272 +#ifdef CONFIG_PAX_REFCOUNT
26273 + jno 1234f
26274 + LOCK_PREFIX
26275 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26276 + int $4
26277 +1234:
26278 + _ASM_EXTABLE(1234b, 1234b)
26279 +#endif
26280 +
26281 jnz 0b
26282 ENDFRAME
26283 + pax_force_retaddr
26284 ret
26285 CFI_ENDPROC
26286 END(__write_lock_failed)
26287 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26288 FRAME
26289 0: LOCK_PREFIX
26290 READ_LOCK_SIZE(inc) (%__lock_ptr)
26291 +
26292 +#ifdef CONFIG_PAX_REFCOUNT
26293 + jno 1234f
26294 + LOCK_PREFIX
26295 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26296 + int $4
26297 +1234:
26298 + _ASM_EXTABLE(1234b, 1234b)
26299 +#endif
26300 +
26301 1: rep; nop
26302 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26303 js 1b
26304 LOCK_PREFIX
26305 READ_LOCK_SIZE(dec) (%__lock_ptr)
26306 +
26307 +#ifdef CONFIG_PAX_REFCOUNT
26308 + jno 1234f
26309 + LOCK_PREFIX
26310 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26311 + int $4
26312 +1234:
26313 + _ASM_EXTABLE(1234b, 1234b)
26314 +#endif
26315 +
26316 js 0b
26317 ENDFRAME
26318 + pax_force_retaddr
26319 ret
26320 CFI_ENDPROC
26321 END(__read_lock_failed)
26322 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26323 index 5dff5f0..cadebf4 100644
26324 --- a/arch/x86/lib/rwsem.S
26325 +++ b/arch/x86/lib/rwsem.S
26326 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26327 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26328 CFI_RESTORE __ASM_REG(dx)
26329 restore_common_regs
26330 + pax_force_retaddr
26331 ret
26332 CFI_ENDPROC
26333 ENDPROC(call_rwsem_down_read_failed)
26334 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26335 movq %rax,%rdi
26336 call rwsem_down_write_failed
26337 restore_common_regs
26338 + pax_force_retaddr
26339 ret
26340 CFI_ENDPROC
26341 ENDPROC(call_rwsem_down_write_failed)
26342 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26343 movq %rax,%rdi
26344 call rwsem_wake
26345 restore_common_regs
26346 -1: ret
26347 +1: pax_force_retaddr
26348 + ret
26349 CFI_ENDPROC
26350 ENDPROC(call_rwsem_wake)
26351
26352 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26353 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26354 CFI_RESTORE __ASM_REG(dx)
26355 restore_common_regs
26356 + pax_force_retaddr
26357 ret
26358 CFI_ENDPROC
26359 ENDPROC(call_rwsem_downgrade_wake)
26360 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26361 index a63efd6..ccecad8 100644
26362 --- a/arch/x86/lib/thunk_64.S
26363 +++ b/arch/x86/lib/thunk_64.S
26364 @@ -8,6 +8,7 @@
26365 #include <linux/linkage.h>
26366 #include <asm/dwarf2.h>
26367 #include <asm/calling.h>
26368 +#include <asm/alternative-asm.h>
26369
26370 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26371 .macro THUNK name, func, put_ret_addr_in_rdi=0
26372 @@ -41,5 +42,6 @@
26373 SAVE_ARGS
26374 restore:
26375 RESTORE_ARGS
26376 + pax_force_retaddr
26377 ret
26378 CFI_ENDPROC
26379 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26380 index f0312d7..9c39d63 100644
26381 --- a/arch/x86/lib/usercopy_32.c
26382 +++ b/arch/x86/lib/usercopy_32.c
26383 @@ -42,11 +42,13 @@ do { \
26384 int __d0; \
26385 might_fault(); \
26386 __asm__ __volatile__( \
26387 + __COPYUSER_SET_ES \
26388 ASM_STAC "\n" \
26389 "0: rep; stosl\n" \
26390 " movl %2,%0\n" \
26391 "1: rep; stosb\n" \
26392 "2: " ASM_CLAC "\n" \
26393 + __COPYUSER_RESTORE_ES \
26394 ".section .fixup,\"ax\"\n" \
26395 "3: lea 0(%2,%0,4),%0\n" \
26396 " jmp 2b\n" \
26397 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26398
26399 #ifdef CONFIG_X86_INTEL_USERCOPY
26400 static unsigned long
26401 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26402 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26403 {
26404 int d0, d1;
26405 __asm__ __volatile__(
26406 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26407 " .align 2,0x90\n"
26408 "3: movl 0(%4), %%eax\n"
26409 "4: movl 4(%4), %%edx\n"
26410 - "5: movl %%eax, 0(%3)\n"
26411 - "6: movl %%edx, 4(%3)\n"
26412 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26413 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26414 "7: movl 8(%4), %%eax\n"
26415 "8: movl 12(%4),%%edx\n"
26416 - "9: movl %%eax, 8(%3)\n"
26417 - "10: movl %%edx, 12(%3)\n"
26418 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26419 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26420 "11: movl 16(%4), %%eax\n"
26421 "12: movl 20(%4), %%edx\n"
26422 - "13: movl %%eax, 16(%3)\n"
26423 - "14: movl %%edx, 20(%3)\n"
26424 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26425 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26426 "15: movl 24(%4), %%eax\n"
26427 "16: movl 28(%4), %%edx\n"
26428 - "17: movl %%eax, 24(%3)\n"
26429 - "18: movl %%edx, 28(%3)\n"
26430 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26431 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26432 "19: movl 32(%4), %%eax\n"
26433 "20: movl 36(%4), %%edx\n"
26434 - "21: movl %%eax, 32(%3)\n"
26435 - "22: movl %%edx, 36(%3)\n"
26436 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26437 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26438 "23: movl 40(%4), %%eax\n"
26439 "24: movl 44(%4), %%edx\n"
26440 - "25: movl %%eax, 40(%3)\n"
26441 - "26: movl %%edx, 44(%3)\n"
26442 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26443 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26444 "27: movl 48(%4), %%eax\n"
26445 "28: movl 52(%4), %%edx\n"
26446 - "29: movl %%eax, 48(%3)\n"
26447 - "30: movl %%edx, 52(%3)\n"
26448 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26449 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26450 "31: movl 56(%4), %%eax\n"
26451 "32: movl 60(%4), %%edx\n"
26452 - "33: movl %%eax, 56(%3)\n"
26453 - "34: movl %%edx, 60(%3)\n"
26454 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26455 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26456 " addl $-64, %0\n"
26457 " addl $64, %4\n"
26458 " addl $64, %3\n"
26459 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26460 " shrl $2, %0\n"
26461 " andl $3, %%eax\n"
26462 " cld\n"
26463 + __COPYUSER_SET_ES
26464 "99: rep; movsl\n"
26465 "36: movl %%eax, %0\n"
26466 "37: rep; movsb\n"
26467 "100:\n"
26468 + __COPYUSER_RESTORE_ES
26469 ".section .fixup,\"ax\"\n"
26470 "101: lea 0(%%eax,%0,4),%0\n"
26471 " jmp 100b\n"
26472 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26473 }
26474
26475 static unsigned long
26476 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26477 +{
26478 + int d0, d1;
26479 + __asm__ __volatile__(
26480 + " .align 2,0x90\n"
26481 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26482 + " cmpl $67, %0\n"
26483 + " jbe 3f\n"
26484 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26485 + " .align 2,0x90\n"
26486 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26487 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26488 + "5: movl %%eax, 0(%3)\n"
26489 + "6: movl %%edx, 4(%3)\n"
26490 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26491 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26492 + "9: movl %%eax, 8(%3)\n"
26493 + "10: movl %%edx, 12(%3)\n"
26494 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26495 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26496 + "13: movl %%eax, 16(%3)\n"
26497 + "14: movl %%edx, 20(%3)\n"
26498 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26499 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26500 + "17: movl %%eax, 24(%3)\n"
26501 + "18: movl %%edx, 28(%3)\n"
26502 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26503 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26504 + "21: movl %%eax, 32(%3)\n"
26505 + "22: movl %%edx, 36(%3)\n"
26506 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26507 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26508 + "25: movl %%eax, 40(%3)\n"
26509 + "26: movl %%edx, 44(%3)\n"
26510 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26511 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26512 + "29: movl %%eax, 48(%3)\n"
26513 + "30: movl %%edx, 52(%3)\n"
26514 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26515 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26516 + "33: movl %%eax, 56(%3)\n"
26517 + "34: movl %%edx, 60(%3)\n"
26518 + " addl $-64, %0\n"
26519 + " addl $64, %4\n"
26520 + " addl $64, %3\n"
26521 + " cmpl $63, %0\n"
26522 + " ja 1b\n"
26523 + "35: movl %0, %%eax\n"
26524 + " shrl $2, %0\n"
26525 + " andl $3, %%eax\n"
26526 + " cld\n"
26527 + "99: rep; "__copyuser_seg" movsl\n"
26528 + "36: movl %%eax, %0\n"
26529 + "37: rep; "__copyuser_seg" movsb\n"
26530 + "100:\n"
26531 + ".section .fixup,\"ax\"\n"
26532 + "101: lea 0(%%eax,%0,4),%0\n"
26533 + " jmp 100b\n"
26534 + ".previous\n"
26535 + _ASM_EXTABLE(1b,100b)
26536 + _ASM_EXTABLE(2b,100b)
26537 + _ASM_EXTABLE(3b,100b)
26538 + _ASM_EXTABLE(4b,100b)
26539 + _ASM_EXTABLE(5b,100b)
26540 + _ASM_EXTABLE(6b,100b)
26541 + _ASM_EXTABLE(7b,100b)
26542 + _ASM_EXTABLE(8b,100b)
26543 + _ASM_EXTABLE(9b,100b)
26544 + _ASM_EXTABLE(10b,100b)
26545 + _ASM_EXTABLE(11b,100b)
26546 + _ASM_EXTABLE(12b,100b)
26547 + _ASM_EXTABLE(13b,100b)
26548 + _ASM_EXTABLE(14b,100b)
26549 + _ASM_EXTABLE(15b,100b)
26550 + _ASM_EXTABLE(16b,100b)
26551 + _ASM_EXTABLE(17b,100b)
26552 + _ASM_EXTABLE(18b,100b)
26553 + _ASM_EXTABLE(19b,100b)
26554 + _ASM_EXTABLE(20b,100b)
26555 + _ASM_EXTABLE(21b,100b)
26556 + _ASM_EXTABLE(22b,100b)
26557 + _ASM_EXTABLE(23b,100b)
26558 + _ASM_EXTABLE(24b,100b)
26559 + _ASM_EXTABLE(25b,100b)
26560 + _ASM_EXTABLE(26b,100b)
26561 + _ASM_EXTABLE(27b,100b)
26562 + _ASM_EXTABLE(28b,100b)
26563 + _ASM_EXTABLE(29b,100b)
26564 + _ASM_EXTABLE(30b,100b)
26565 + _ASM_EXTABLE(31b,100b)
26566 + _ASM_EXTABLE(32b,100b)
26567 + _ASM_EXTABLE(33b,100b)
26568 + _ASM_EXTABLE(34b,100b)
26569 + _ASM_EXTABLE(35b,100b)
26570 + _ASM_EXTABLE(36b,100b)
26571 + _ASM_EXTABLE(37b,100b)
26572 + _ASM_EXTABLE(99b,101b)
26573 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26574 + : "1"(to), "2"(from), "0"(size)
26575 + : "eax", "edx", "memory");
26576 + return size;
26577 +}
26578 +
26579 +static unsigned long __size_overflow(3)
26580 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26581 {
26582 int d0, d1;
26583 __asm__ __volatile__(
26584 " .align 2,0x90\n"
26585 - "0: movl 32(%4), %%eax\n"
26586 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26587 " cmpl $67, %0\n"
26588 " jbe 2f\n"
26589 - "1: movl 64(%4), %%eax\n"
26590 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26591 " .align 2,0x90\n"
26592 - "2: movl 0(%4), %%eax\n"
26593 - "21: movl 4(%4), %%edx\n"
26594 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26595 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26596 " movl %%eax, 0(%3)\n"
26597 " movl %%edx, 4(%3)\n"
26598 - "3: movl 8(%4), %%eax\n"
26599 - "31: movl 12(%4),%%edx\n"
26600 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26601 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26602 " movl %%eax, 8(%3)\n"
26603 " movl %%edx, 12(%3)\n"
26604 - "4: movl 16(%4), %%eax\n"
26605 - "41: movl 20(%4), %%edx\n"
26606 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26607 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26608 " movl %%eax, 16(%3)\n"
26609 " movl %%edx, 20(%3)\n"
26610 - "10: movl 24(%4), %%eax\n"
26611 - "51: movl 28(%4), %%edx\n"
26612 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26613 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26614 " movl %%eax, 24(%3)\n"
26615 " movl %%edx, 28(%3)\n"
26616 - "11: movl 32(%4), %%eax\n"
26617 - "61: movl 36(%4), %%edx\n"
26618 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26619 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26620 " movl %%eax, 32(%3)\n"
26621 " movl %%edx, 36(%3)\n"
26622 - "12: movl 40(%4), %%eax\n"
26623 - "71: movl 44(%4), %%edx\n"
26624 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26625 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26626 " movl %%eax, 40(%3)\n"
26627 " movl %%edx, 44(%3)\n"
26628 - "13: movl 48(%4), %%eax\n"
26629 - "81: movl 52(%4), %%edx\n"
26630 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26631 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26632 " movl %%eax, 48(%3)\n"
26633 " movl %%edx, 52(%3)\n"
26634 - "14: movl 56(%4), %%eax\n"
26635 - "91: movl 60(%4), %%edx\n"
26636 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26637 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26638 " movl %%eax, 56(%3)\n"
26639 " movl %%edx, 60(%3)\n"
26640 " addl $-64, %0\n"
26641 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26642 " shrl $2, %0\n"
26643 " andl $3, %%eax\n"
26644 " cld\n"
26645 - "6: rep; movsl\n"
26646 + "6: rep; "__copyuser_seg" movsl\n"
26647 " movl %%eax,%0\n"
26648 - "7: rep; movsb\n"
26649 + "7: rep; "__copyuser_seg" movsb\n"
26650 "8:\n"
26651 ".section .fixup,\"ax\"\n"
26652 "9: lea 0(%%eax,%0,4),%0\n"
26653 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26654 * hyoshiok@miraclelinux.com
26655 */
26656
26657 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26658 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26659 const void __user *from, unsigned long size)
26660 {
26661 int d0, d1;
26662
26663 __asm__ __volatile__(
26664 " .align 2,0x90\n"
26665 - "0: movl 32(%4), %%eax\n"
26666 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26667 " cmpl $67, %0\n"
26668 " jbe 2f\n"
26669 - "1: movl 64(%4), %%eax\n"
26670 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26671 " .align 2,0x90\n"
26672 - "2: movl 0(%4), %%eax\n"
26673 - "21: movl 4(%4), %%edx\n"
26674 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26675 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26676 " movnti %%eax, 0(%3)\n"
26677 " movnti %%edx, 4(%3)\n"
26678 - "3: movl 8(%4), %%eax\n"
26679 - "31: movl 12(%4),%%edx\n"
26680 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26681 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26682 " movnti %%eax, 8(%3)\n"
26683 " movnti %%edx, 12(%3)\n"
26684 - "4: movl 16(%4), %%eax\n"
26685 - "41: movl 20(%4), %%edx\n"
26686 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26687 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26688 " movnti %%eax, 16(%3)\n"
26689 " movnti %%edx, 20(%3)\n"
26690 - "10: movl 24(%4), %%eax\n"
26691 - "51: movl 28(%4), %%edx\n"
26692 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26693 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26694 " movnti %%eax, 24(%3)\n"
26695 " movnti %%edx, 28(%3)\n"
26696 - "11: movl 32(%4), %%eax\n"
26697 - "61: movl 36(%4), %%edx\n"
26698 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26699 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26700 " movnti %%eax, 32(%3)\n"
26701 " movnti %%edx, 36(%3)\n"
26702 - "12: movl 40(%4), %%eax\n"
26703 - "71: movl 44(%4), %%edx\n"
26704 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26705 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26706 " movnti %%eax, 40(%3)\n"
26707 " movnti %%edx, 44(%3)\n"
26708 - "13: movl 48(%4), %%eax\n"
26709 - "81: movl 52(%4), %%edx\n"
26710 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26711 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26712 " movnti %%eax, 48(%3)\n"
26713 " movnti %%edx, 52(%3)\n"
26714 - "14: movl 56(%4), %%eax\n"
26715 - "91: movl 60(%4), %%edx\n"
26716 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26717 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26718 " movnti %%eax, 56(%3)\n"
26719 " movnti %%edx, 60(%3)\n"
26720 " addl $-64, %0\n"
26721 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26722 " shrl $2, %0\n"
26723 " andl $3, %%eax\n"
26724 " cld\n"
26725 - "6: rep; movsl\n"
26726 + "6: rep; "__copyuser_seg" movsl\n"
26727 " movl %%eax,%0\n"
26728 - "7: rep; movsb\n"
26729 + "7: rep; "__copyuser_seg" movsb\n"
26730 "8:\n"
26731 ".section .fixup,\"ax\"\n"
26732 "9: lea 0(%%eax,%0,4),%0\n"
26733 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26734 return size;
26735 }
26736
26737 -static unsigned long __copy_user_intel_nocache(void *to,
26738 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26739 const void __user *from, unsigned long size)
26740 {
26741 int d0, d1;
26742
26743 __asm__ __volatile__(
26744 " .align 2,0x90\n"
26745 - "0: movl 32(%4), %%eax\n"
26746 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26747 " cmpl $67, %0\n"
26748 " jbe 2f\n"
26749 - "1: movl 64(%4), %%eax\n"
26750 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26751 " .align 2,0x90\n"
26752 - "2: movl 0(%4), %%eax\n"
26753 - "21: movl 4(%4), %%edx\n"
26754 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26755 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26756 " movnti %%eax, 0(%3)\n"
26757 " movnti %%edx, 4(%3)\n"
26758 - "3: movl 8(%4), %%eax\n"
26759 - "31: movl 12(%4),%%edx\n"
26760 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26761 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26762 " movnti %%eax, 8(%3)\n"
26763 " movnti %%edx, 12(%3)\n"
26764 - "4: movl 16(%4), %%eax\n"
26765 - "41: movl 20(%4), %%edx\n"
26766 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26767 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26768 " movnti %%eax, 16(%3)\n"
26769 " movnti %%edx, 20(%3)\n"
26770 - "10: movl 24(%4), %%eax\n"
26771 - "51: movl 28(%4), %%edx\n"
26772 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26773 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26774 " movnti %%eax, 24(%3)\n"
26775 " movnti %%edx, 28(%3)\n"
26776 - "11: movl 32(%4), %%eax\n"
26777 - "61: movl 36(%4), %%edx\n"
26778 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26779 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26780 " movnti %%eax, 32(%3)\n"
26781 " movnti %%edx, 36(%3)\n"
26782 - "12: movl 40(%4), %%eax\n"
26783 - "71: movl 44(%4), %%edx\n"
26784 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26785 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26786 " movnti %%eax, 40(%3)\n"
26787 " movnti %%edx, 44(%3)\n"
26788 - "13: movl 48(%4), %%eax\n"
26789 - "81: movl 52(%4), %%edx\n"
26790 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26791 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26792 " movnti %%eax, 48(%3)\n"
26793 " movnti %%edx, 52(%3)\n"
26794 - "14: movl 56(%4), %%eax\n"
26795 - "91: movl 60(%4), %%edx\n"
26796 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26797 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26798 " movnti %%eax, 56(%3)\n"
26799 " movnti %%edx, 60(%3)\n"
26800 " addl $-64, %0\n"
26801 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26802 " shrl $2, %0\n"
26803 " andl $3, %%eax\n"
26804 " cld\n"
26805 - "6: rep; movsl\n"
26806 + "6: rep; "__copyuser_seg" movsl\n"
26807 " movl %%eax,%0\n"
26808 - "7: rep; movsb\n"
26809 + "7: rep; "__copyuser_seg" movsb\n"
26810 "8:\n"
26811 ".section .fixup,\"ax\"\n"
26812 "9: lea 0(%%eax,%0,4),%0\n"
26813 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26814 */
26815 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26816 unsigned long size);
26817 -unsigned long __copy_user_intel(void __user *to, const void *from,
26818 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26819 + unsigned long size);
26820 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26821 unsigned long size);
26822 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26823 const void __user *from, unsigned long size);
26824 #endif /* CONFIG_X86_INTEL_USERCOPY */
26825
26826 /* Generic arbitrary sized copy. */
26827 -#define __copy_user(to, from, size) \
26828 +#define __copy_user(to, from, size, prefix, set, restore) \
26829 do { \
26830 int __d0, __d1, __d2; \
26831 __asm__ __volatile__( \
26832 + set \
26833 " cmp $7,%0\n" \
26834 " jbe 1f\n" \
26835 " movl %1,%0\n" \
26836 " negl %0\n" \
26837 " andl $7,%0\n" \
26838 " subl %0,%3\n" \
26839 - "4: rep; movsb\n" \
26840 + "4: rep; "prefix"movsb\n" \
26841 " movl %3,%0\n" \
26842 " shrl $2,%0\n" \
26843 " andl $3,%3\n" \
26844 " .align 2,0x90\n" \
26845 - "0: rep; movsl\n" \
26846 + "0: rep; "prefix"movsl\n" \
26847 " movl %3,%0\n" \
26848 - "1: rep; movsb\n" \
26849 + "1: rep; "prefix"movsb\n" \
26850 "2:\n" \
26851 + restore \
26852 ".section .fixup,\"ax\"\n" \
26853 "5: addl %3,%0\n" \
26854 " jmp 2b\n" \
26855 @@ -538,14 +650,14 @@ do { \
26856 " negl %0\n" \
26857 " andl $7,%0\n" \
26858 " subl %0,%3\n" \
26859 - "4: rep; movsb\n" \
26860 + "4: rep; "__copyuser_seg"movsb\n" \
26861 " movl %3,%0\n" \
26862 " shrl $2,%0\n" \
26863 " andl $3,%3\n" \
26864 " .align 2,0x90\n" \
26865 - "0: rep; movsl\n" \
26866 + "0: rep; "__copyuser_seg"movsl\n" \
26867 " movl %3,%0\n" \
26868 - "1: rep; movsb\n" \
26869 + "1: rep; "__copyuser_seg"movsb\n" \
26870 "2:\n" \
26871 ".section .fixup,\"ax\"\n" \
26872 "5: addl %3,%0\n" \
26873 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26874 {
26875 stac();
26876 if (movsl_is_ok(to, from, n))
26877 - __copy_user(to, from, n);
26878 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26879 else
26880 - n = __copy_user_intel(to, from, n);
26881 + n = __generic_copy_to_user_intel(to, from, n);
26882 clac();
26883 return n;
26884 }
26885 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
26886 {
26887 stac();
26888 if (movsl_is_ok(to, from, n))
26889 - __copy_user(to, from, n);
26890 + __copy_user(to, from, n, __copyuser_seg, "", "");
26891 else
26892 - n = __copy_user_intel((void __user *)to,
26893 - (const void *)from, n);
26894 + n = __generic_copy_from_user_intel(to, from, n);
26895 clac();
26896 return n;
26897 }
26898 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
26899 if (n > 64 && cpu_has_xmm2)
26900 n = __copy_user_intel_nocache(to, from, n);
26901 else
26902 - __copy_user(to, from, n);
26903 + __copy_user(to, from, n, __copyuser_seg, "", "");
26904 #else
26905 - __copy_user(to, from, n);
26906 + __copy_user(to, from, n, __copyuser_seg, "", "");
26907 #endif
26908 clac();
26909 return n;
26910 }
26911 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
26912
26913 -/**
26914 - * copy_to_user: - Copy a block of data into user space.
26915 - * @to: Destination address, in user space.
26916 - * @from: Source address, in kernel space.
26917 - * @n: Number of bytes to copy.
26918 - *
26919 - * Context: User context only. This function may sleep.
26920 - *
26921 - * Copy data from kernel space to user space.
26922 - *
26923 - * Returns number of bytes that could not be copied.
26924 - * On success, this will be zero.
26925 - */
26926 -unsigned long
26927 -copy_to_user(void __user *to, const void *from, unsigned long n)
26928 -{
26929 - if (access_ok(VERIFY_WRITE, to, n))
26930 - n = __copy_to_user(to, from, n);
26931 - return n;
26932 -}
26933 -EXPORT_SYMBOL(copy_to_user);
26934 -
26935 -/**
26936 - * copy_from_user: - Copy a block of data from user space.
26937 - * @to: Destination address, in kernel space.
26938 - * @from: Source address, in user space.
26939 - * @n: Number of bytes to copy.
26940 - *
26941 - * Context: User context only. This function may sleep.
26942 - *
26943 - * Copy data from user space to kernel space.
26944 - *
26945 - * Returns number of bytes that could not be copied.
26946 - * On success, this will be zero.
26947 - *
26948 - * If some data could not be copied, this function will pad the copied
26949 - * data to the requested size using zero bytes.
26950 - */
26951 -unsigned long
26952 -_copy_from_user(void *to, const void __user *from, unsigned long n)
26953 -{
26954 - if (access_ok(VERIFY_READ, from, n))
26955 - n = __copy_from_user(to, from, n);
26956 - else
26957 - memset(to, 0, n);
26958 - return n;
26959 -}
26960 -EXPORT_SYMBOL(_copy_from_user);
26961 -
26962 void copy_from_user_overflow(void)
26963 {
26964 WARN(1, "Buffer overflow detected!\n");
26965 }
26966 EXPORT_SYMBOL(copy_from_user_overflow);
26967 +
26968 +void copy_to_user_overflow(void)
26969 +{
26970 + WARN(1, "Buffer overflow detected!\n");
26971 +}
26972 +EXPORT_SYMBOL(copy_to_user_overflow);
26973 +
26974 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26975 +void __set_fs(mm_segment_t x)
26976 +{
26977 + switch (x.seg) {
26978 + case 0:
26979 + loadsegment(gs, 0);
26980 + break;
26981 + case TASK_SIZE_MAX:
26982 + loadsegment(gs, __USER_DS);
26983 + break;
26984 + case -1UL:
26985 + loadsegment(gs, __KERNEL_DS);
26986 + break;
26987 + default:
26988 + BUG();
26989 + }
26990 + return;
26991 +}
26992 +EXPORT_SYMBOL(__set_fs);
26993 +
26994 +void set_fs(mm_segment_t x)
26995 +{
26996 + current_thread_info()->addr_limit = x;
26997 + __set_fs(x);
26998 +}
26999 +EXPORT_SYMBOL(set_fs);
27000 +#endif
27001 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27002 index 906fea3..ee8a097 100644
27003 --- a/arch/x86/lib/usercopy_64.c
27004 +++ b/arch/x86/lib/usercopy_64.c
27005 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27006 _ASM_EXTABLE(0b,3b)
27007 _ASM_EXTABLE(1b,2b)
27008 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27009 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27010 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27011 [zero] "r" (0UL), [eight] "r" (8UL));
27012 clac();
27013 return size;
27014 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27015 }
27016 EXPORT_SYMBOL(clear_user);
27017
27018 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27019 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27020 {
27021 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27022 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27023 - }
27024 - return len;
27025 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27026 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27027 + return len;
27028 }
27029 EXPORT_SYMBOL(copy_in_user);
27030
27031 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27032 * it is not necessary to optimize tail handling.
27033 */
27034 unsigned long
27035 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27036 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27037 {
27038 char c;
27039 unsigned zero_len;
27040 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27041 clac();
27042 return len;
27043 }
27044 +
27045 +void copy_from_user_overflow(void)
27046 +{
27047 + WARN(1, "Buffer overflow detected!\n");
27048 +}
27049 +EXPORT_SYMBOL(copy_from_user_overflow);
27050 +
27051 +void copy_to_user_overflow(void)
27052 +{
27053 + WARN(1, "Buffer overflow detected!\n");
27054 +}
27055 +EXPORT_SYMBOL(copy_to_user_overflow);
27056 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27057 index 903ec1e..c4166b2 100644
27058 --- a/arch/x86/mm/extable.c
27059 +++ b/arch/x86/mm/extable.c
27060 @@ -6,12 +6,24 @@
27061 static inline unsigned long
27062 ex_insn_addr(const struct exception_table_entry *x)
27063 {
27064 - return (unsigned long)&x->insn + x->insn;
27065 + unsigned long reloc = 0;
27066 +
27067 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27068 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27069 +#endif
27070 +
27071 + return (unsigned long)&x->insn + x->insn + reloc;
27072 }
27073 static inline unsigned long
27074 ex_fixup_addr(const struct exception_table_entry *x)
27075 {
27076 - return (unsigned long)&x->fixup + x->fixup;
27077 + unsigned long reloc = 0;
27078 +
27079 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27080 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27081 +#endif
27082 +
27083 + return (unsigned long)&x->fixup + x->fixup + reloc;
27084 }
27085
27086 int fixup_exception(struct pt_regs *regs)
27087 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27088 unsigned long new_ip;
27089
27090 #ifdef CONFIG_PNPBIOS
27091 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27092 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27093 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27094 extern u32 pnp_bios_is_utter_crap;
27095 pnp_bios_is_utter_crap = 1;
27096 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27097 i += 4;
27098 p->fixup -= i;
27099 i += 4;
27100 +
27101 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27102 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27103 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27104 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27105 +#endif
27106 +
27107 }
27108 }
27109
27110 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27111 index fb674fd..223a693 100644
27112 --- a/arch/x86/mm/fault.c
27113 +++ b/arch/x86/mm/fault.c
27114 @@ -13,12 +13,19 @@
27115 #include <linux/perf_event.h> /* perf_sw_event */
27116 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27117 #include <linux/prefetch.h> /* prefetchw */
27118 +#include <linux/unistd.h>
27119 +#include <linux/compiler.h>
27120
27121 #include <asm/traps.h> /* dotraplinkage, ... */
27122 #include <asm/pgalloc.h> /* pgd_*(), ... */
27123 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27124 #include <asm/fixmap.h> /* VSYSCALL_START */
27125 #include <asm/context_tracking.h> /* exception_enter(), ... */
27126 +#include <asm/tlbflush.h>
27127 +
27128 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27129 +#include <asm/stacktrace.h>
27130 +#endif
27131
27132 /*
27133 * Page fault error code bits:
27134 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27135 int ret = 0;
27136
27137 /* kprobe_running() needs smp_processor_id() */
27138 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27139 + if (kprobes_built_in() && !user_mode(regs)) {
27140 preempt_disable();
27141 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27142 ret = 1;
27143 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27144 return !instr_lo || (instr_lo>>1) == 1;
27145 case 0x00:
27146 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27147 - if (probe_kernel_address(instr, opcode))
27148 + if (user_mode(regs)) {
27149 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27150 + return 0;
27151 + } else if (probe_kernel_address(instr, opcode))
27152 return 0;
27153
27154 *prefetch = (instr_lo == 0xF) &&
27155 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27156 while (instr < max_instr) {
27157 unsigned char opcode;
27158
27159 - if (probe_kernel_address(instr, opcode))
27160 + if (user_mode(regs)) {
27161 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27162 + break;
27163 + } else if (probe_kernel_address(instr, opcode))
27164 break;
27165
27166 instr++;
27167 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27168 force_sig_info(si_signo, &info, tsk);
27169 }
27170
27171 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27172 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27173 +#endif
27174 +
27175 +#ifdef CONFIG_PAX_EMUTRAMP
27176 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27177 +#endif
27178 +
27179 +#ifdef CONFIG_PAX_PAGEEXEC
27180 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27181 +{
27182 + pgd_t *pgd;
27183 + pud_t *pud;
27184 + pmd_t *pmd;
27185 +
27186 + pgd = pgd_offset(mm, address);
27187 + if (!pgd_present(*pgd))
27188 + return NULL;
27189 + pud = pud_offset(pgd, address);
27190 + if (!pud_present(*pud))
27191 + return NULL;
27192 + pmd = pmd_offset(pud, address);
27193 + if (!pmd_present(*pmd))
27194 + return NULL;
27195 + return pmd;
27196 +}
27197 +#endif
27198 +
27199 DEFINE_SPINLOCK(pgd_lock);
27200 LIST_HEAD(pgd_list);
27201
27202 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27203 for (address = VMALLOC_START & PMD_MASK;
27204 address >= TASK_SIZE && address < FIXADDR_TOP;
27205 address += PMD_SIZE) {
27206 +
27207 +#ifdef CONFIG_PAX_PER_CPU_PGD
27208 + unsigned long cpu;
27209 +#else
27210 struct page *page;
27211 +#endif
27212
27213 spin_lock(&pgd_lock);
27214 +
27215 +#ifdef CONFIG_PAX_PER_CPU_PGD
27216 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27217 + pgd_t *pgd = get_cpu_pgd(cpu);
27218 + pmd_t *ret;
27219 +#else
27220 list_for_each_entry(page, &pgd_list, lru) {
27221 + pgd_t *pgd;
27222 spinlock_t *pgt_lock;
27223 pmd_t *ret;
27224
27225 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27226 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27227
27228 spin_lock(pgt_lock);
27229 - ret = vmalloc_sync_one(page_address(page), address);
27230 + pgd = page_address(page);
27231 +#endif
27232 +
27233 + ret = vmalloc_sync_one(pgd, address);
27234 +
27235 +#ifndef CONFIG_PAX_PER_CPU_PGD
27236 spin_unlock(pgt_lock);
27237 +#endif
27238
27239 if (!ret)
27240 break;
27241 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27242 * an interrupt in the middle of a task switch..
27243 */
27244 pgd_paddr = read_cr3();
27245 +
27246 +#ifdef CONFIG_PAX_PER_CPU_PGD
27247 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27248 +#endif
27249 +
27250 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27251 if (!pmd_k)
27252 return -1;
27253 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27254 * happen within a race in page table update. In the later
27255 * case just flush:
27256 */
27257 +
27258 +#ifdef CONFIG_PAX_PER_CPU_PGD
27259 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27260 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27261 +#else
27262 pgd = pgd_offset(current->active_mm, address);
27263 +#endif
27264 +
27265 pgd_ref = pgd_offset_k(address);
27266 if (pgd_none(*pgd_ref))
27267 return -1;
27268 @@ -541,7 +612,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27269 static int is_errata100(struct pt_regs *regs, unsigned long address)
27270 {
27271 #ifdef CONFIG_X86_64
27272 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27273 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27274 return 1;
27275 #endif
27276 return 0;
27277 @@ -568,7 +639,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27278 }
27279
27280 static const char nx_warning[] = KERN_CRIT
27281 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27282 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27283
27284 static void
27285 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27286 @@ -577,15 +648,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27287 if (!oops_may_print())
27288 return;
27289
27290 - if (error_code & PF_INSTR) {
27291 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27292 unsigned int level;
27293
27294 pte_t *pte = lookup_address(address, &level);
27295
27296 if (pte && pte_present(*pte) && !pte_exec(*pte))
27297 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27298 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27299 }
27300
27301 +#ifdef CONFIG_PAX_KERNEXEC
27302 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27303 + if (current->signal->curr_ip)
27304 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27305 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27306 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27307 + else
27308 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27309 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27310 + }
27311 +#endif
27312 +
27313 printk(KERN_ALERT "BUG: unable to handle kernel ");
27314 if (address < PAGE_SIZE)
27315 printk(KERN_CONT "NULL pointer dereference");
27316 @@ -748,6 +831,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27317 return;
27318 }
27319 #endif
27320 +
27321 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27322 + if (pax_is_fetch_fault(regs, error_code, address)) {
27323 +
27324 +#ifdef CONFIG_PAX_EMUTRAMP
27325 + switch (pax_handle_fetch_fault(regs)) {
27326 + case 2:
27327 + return;
27328 + }
27329 +#endif
27330 +
27331 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27332 + do_group_exit(SIGKILL);
27333 + }
27334 +#endif
27335 +
27336 /* Kernel addresses are always protection faults: */
27337 if (address >= TASK_SIZE)
27338 error_code |= PF_PROT;
27339 @@ -833,7 +932,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27340 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27341 printk(KERN_ERR
27342 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27343 - tsk->comm, tsk->pid, address);
27344 + tsk->comm, task_pid_nr(tsk), address);
27345 code = BUS_MCEERR_AR;
27346 }
27347 #endif
27348 @@ -896,6 +995,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27349 return 1;
27350 }
27351
27352 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27353 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27354 +{
27355 + pte_t *pte;
27356 + pmd_t *pmd;
27357 + spinlock_t *ptl;
27358 + unsigned char pte_mask;
27359 +
27360 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27361 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27362 + return 0;
27363 +
27364 + /* PaX: it's our fault, let's handle it if we can */
27365 +
27366 + /* PaX: take a look at read faults before acquiring any locks */
27367 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27368 + /* instruction fetch attempt from a protected page in user mode */
27369 + up_read(&mm->mmap_sem);
27370 +
27371 +#ifdef CONFIG_PAX_EMUTRAMP
27372 + switch (pax_handle_fetch_fault(regs)) {
27373 + case 2:
27374 + return 1;
27375 + }
27376 +#endif
27377 +
27378 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27379 + do_group_exit(SIGKILL);
27380 + }
27381 +
27382 + pmd = pax_get_pmd(mm, address);
27383 + if (unlikely(!pmd))
27384 + return 0;
27385 +
27386 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27387 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27388 + pte_unmap_unlock(pte, ptl);
27389 + return 0;
27390 + }
27391 +
27392 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27393 + /* write attempt to a protected page in user mode */
27394 + pte_unmap_unlock(pte, ptl);
27395 + return 0;
27396 + }
27397 +
27398 +#ifdef CONFIG_SMP
27399 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27400 +#else
27401 + if (likely(address > get_limit(regs->cs)))
27402 +#endif
27403 + {
27404 + set_pte(pte, pte_mkread(*pte));
27405 + __flush_tlb_one(address);
27406 + pte_unmap_unlock(pte, ptl);
27407 + up_read(&mm->mmap_sem);
27408 + return 1;
27409 + }
27410 +
27411 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27412 +
27413 + /*
27414 + * PaX: fill DTLB with user rights and retry
27415 + */
27416 + __asm__ __volatile__ (
27417 + "orb %2,(%1)\n"
27418 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27419 +/*
27420 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27421 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27422 + * page fault when examined during a TLB load attempt. this is true not only
27423 + * for PTEs holding a non-present entry but also present entries that will
27424 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27425 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27426 + * for our target pages since their PTEs are simply not in the TLBs at all.
27427 +
27428 + * the best thing in omitting it is that we gain around 15-20% speed in the
27429 + * fast path of the page fault handler and can get rid of tracing since we
27430 + * can no longer flush unintended entries.
27431 + */
27432 + "invlpg (%0)\n"
27433 +#endif
27434 + __copyuser_seg"testb $0,(%0)\n"
27435 + "xorb %3,(%1)\n"
27436 + :
27437 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27438 + : "memory", "cc");
27439 + pte_unmap_unlock(pte, ptl);
27440 + up_read(&mm->mmap_sem);
27441 + return 1;
27442 +}
27443 +#endif
27444 +
27445 /*
27446 * Handle a spurious fault caused by a stale TLB entry.
27447 *
27448 @@ -968,6 +1160,9 @@ int show_unhandled_signals = 1;
27449 static inline int
27450 access_error(unsigned long error_code, struct vm_area_struct *vma)
27451 {
27452 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27453 + return 1;
27454 +
27455 if (error_code & PF_WRITE) {
27456 /* write, present and write, not present: */
27457 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27458 @@ -996,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27459 if (error_code & PF_USER)
27460 return false;
27461
27462 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27463 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27464 return false;
27465
27466 return true;
27467 @@ -1012,18 +1207,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27468 {
27469 struct vm_area_struct *vma;
27470 struct task_struct *tsk;
27471 - unsigned long address;
27472 struct mm_struct *mm;
27473 int fault;
27474 int write = error_code & PF_WRITE;
27475 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27476 (write ? FAULT_FLAG_WRITE : 0);
27477
27478 - tsk = current;
27479 - mm = tsk->mm;
27480 -
27481 /* Get the faulting address: */
27482 - address = read_cr2();
27483 + unsigned long address = read_cr2();
27484 +
27485 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27486 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
27487 + if (!search_exception_tables(regs->ip)) {
27488 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27489 + bad_area_nosemaphore(regs, error_code, address);
27490 + return;
27491 + }
27492 + if (address < PAX_USER_SHADOW_BASE) {
27493 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27494 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27495 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27496 + } else
27497 + address -= PAX_USER_SHADOW_BASE;
27498 + }
27499 +#endif
27500 +
27501 + tsk = current;
27502 + mm = tsk->mm;
27503
27504 /*
27505 * Detect and handle instructions that would cause a page fault for
27506 @@ -1084,7 +1294,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27507 * User-mode registers count as a user access even for any
27508 * potential system fault or CPU buglet:
27509 */
27510 - if (user_mode_vm(regs)) {
27511 + if (user_mode(regs)) {
27512 local_irq_enable();
27513 error_code |= PF_USER;
27514 } else {
27515 @@ -1146,6 +1356,11 @@ retry:
27516 might_sleep();
27517 }
27518
27519 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27520 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27521 + return;
27522 +#endif
27523 +
27524 vma = find_vma(mm, address);
27525 if (unlikely(!vma)) {
27526 bad_area(regs, error_code, address);
27527 @@ -1157,18 +1372,24 @@ retry:
27528 bad_area(regs, error_code, address);
27529 return;
27530 }
27531 - if (error_code & PF_USER) {
27532 - /*
27533 - * Accessing the stack below %sp is always a bug.
27534 - * The large cushion allows instructions like enter
27535 - * and pusha to work. ("enter $65535, $31" pushes
27536 - * 32 pointers and then decrements %sp by 65535.)
27537 - */
27538 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27539 - bad_area(regs, error_code, address);
27540 - return;
27541 - }
27542 + /*
27543 + * Accessing the stack below %sp is always a bug.
27544 + * The large cushion allows instructions like enter
27545 + * and pusha to work. ("enter $65535, $31" pushes
27546 + * 32 pointers and then decrements %sp by 65535.)
27547 + */
27548 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27549 + bad_area(regs, error_code, address);
27550 + return;
27551 }
27552 +
27553 +#ifdef CONFIG_PAX_SEGMEXEC
27554 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27555 + bad_area(regs, error_code, address);
27556 + return;
27557 + }
27558 +#endif
27559 +
27560 if (unlikely(expand_stack(vma, address))) {
27561 bad_area(regs, error_code, address);
27562 return;
27563 @@ -1232,3 +1453,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27564 __do_page_fault(regs, error_code);
27565 exception_exit(regs);
27566 }
27567 +
27568 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27569 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27570 +{
27571 + struct mm_struct *mm = current->mm;
27572 + unsigned long ip = regs->ip;
27573 +
27574 + if (v8086_mode(regs))
27575 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27576 +
27577 +#ifdef CONFIG_PAX_PAGEEXEC
27578 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27579 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27580 + return true;
27581 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27582 + return true;
27583 + return false;
27584 + }
27585 +#endif
27586 +
27587 +#ifdef CONFIG_PAX_SEGMEXEC
27588 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27589 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27590 + return true;
27591 + return false;
27592 + }
27593 +#endif
27594 +
27595 + return false;
27596 +}
27597 +#endif
27598 +
27599 +#ifdef CONFIG_PAX_EMUTRAMP
27600 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27601 +{
27602 + int err;
27603 +
27604 + do { /* PaX: libffi trampoline emulation */
27605 + unsigned char mov, jmp;
27606 + unsigned int addr1, addr2;
27607 +
27608 +#ifdef CONFIG_X86_64
27609 + if ((regs->ip + 9) >> 32)
27610 + break;
27611 +#endif
27612 +
27613 + err = get_user(mov, (unsigned char __user *)regs->ip);
27614 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27615 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27616 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27617 +
27618 + if (err)
27619 + break;
27620 +
27621 + if (mov == 0xB8 && jmp == 0xE9) {
27622 + regs->ax = addr1;
27623 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27624 + return 2;
27625 + }
27626 + } while (0);
27627 +
27628 + do { /* PaX: gcc trampoline emulation #1 */
27629 + unsigned char mov1, mov2;
27630 + unsigned short jmp;
27631 + unsigned int addr1, addr2;
27632 +
27633 +#ifdef CONFIG_X86_64
27634 + if ((regs->ip + 11) >> 32)
27635 + break;
27636 +#endif
27637 +
27638 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27639 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27640 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27641 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27642 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27643 +
27644 + if (err)
27645 + break;
27646 +
27647 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27648 + regs->cx = addr1;
27649 + regs->ax = addr2;
27650 + regs->ip = addr2;
27651 + return 2;
27652 + }
27653 + } while (0);
27654 +
27655 + do { /* PaX: gcc trampoline emulation #2 */
27656 + unsigned char mov, jmp;
27657 + unsigned int addr1, addr2;
27658 +
27659 +#ifdef CONFIG_X86_64
27660 + if ((regs->ip + 9) >> 32)
27661 + break;
27662 +#endif
27663 +
27664 + err = get_user(mov, (unsigned char __user *)regs->ip);
27665 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27666 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27667 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27668 +
27669 + if (err)
27670 + break;
27671 +
27672 + if (mov == 0xB9 && jmp == 0xE9) {
27673 + regs->cx = addr1;
27674 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27675 + return 2;
27676 + }
27677 + } while (0);
27678 +
27679 + return 1; /* PaX in action */
27680 +}
27681 +
27682 +#ifdef CONFIG_X86_64
27683 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27684 +{
27685 + int err;
27686 +
27687 + do { /* PaX: libffi trampoline emulation */
27688 + unsigned short mov1, mov2, jmp1;
27689 + unsigned char stcclc, jmp2;
27690 + unsigned long addr1, addr2;
27691 +
27692 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27693 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27694 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27695 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27696 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27697 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27698 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27699 +
27700 + if (err)
27701 + break;
27702 +
27703 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27704 + regs->r11 = addr1;
27705 + regs->r10 = addr2;
27706 + if (stcclc == 0xF8)
27707 + regs->flags &= ~X86_EFLAGS_CF;
27708 + else
27709 + regs->flags |= X86_EFLAGS_CF;
27710 + regs->ip = addr1;
27711 + return 2;
27712 + }
27713 + } while (0);
27714 +
27715 + do { /* PaX: gcc trampoline emulation #1 */
27716 + unsigned short mov1, mov2, jmp1;
27717 + unsigned char jmp2;
27718 + unsigned int addr1;
27719 + unsigned long addr2;
27720 +
27721 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27722 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27723 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27724 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27725 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27726 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27727 +
27728 + if (err)
27729 + break;
27730 +
27731 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27732 + regs->r11 = addr1;
27733 + regs->r10 = addr2;
27734 + regs->ip = addr1;
27735 + return 2;
27736 + }
27737 + } while (0);
27738 +
27739 + do { /* PaX: gcc trampoline emulation #2 */
27740 + unsigned short mov1, mov2, jmp1;
27741 + unsigned char jmp2;
27742 + unsigned long addr1, addr2;
27743 +
27744 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27745 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27746 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27747 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27748 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27749 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27750 +
27751 + if (err)
27752 + break;
27753 +
27754 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27755 + regs->r11 = addr1;
27756 + regs->r10 = addr2;
27757 + regs->ip = addr1;
27758 + return 2;
27759 + }
27760 + } while (0);
27761 +
27762 + return 1; /* PaX in action */
27763 +}
27764 +#endif
27765 +
27766 +/*
27767 + * PaX: decide what to do with offenders (regs->ip = fault address)
27768 + *
27769 + * returns 1 when task should be killed
27770 + * 2 when gcc trampoline was detected
27771 + */
27772 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27773 +{
27774 + if (v8086_mode(regs))
27775 + return 1;
27776 +
27777 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27778 + return 1;
27779 +
27780 +#ifdef CONFIG_X86_32
27781 + return pax_handle_fetch_fault_32(regs);
27782 +#else
27783 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27784 + return pax_handle_fetch_fault_32(regs);
27785 + else
27786 + return pax_handle_fetch_fault_64(regs);
27787 +#endif
27788 +}
27789 +#endif
27790 +
27791 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27792 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27793 +{
27794 + long i;
27795 +
27796 + printk(KERN_ERR "PAX: bytes at PC: ");
27797 + for (i = 0; i < 20; i++) {
27798 + unsigned char c;
27799 + if (get_user(c, (unsigned char __force_user *)pc+i))
27800 + printk(KERN_CONT "?? ");
27801 + else
27802 + printk(KERN_CONT "%02x ", c);
27803 + }
27804 + printk("\n");
27805 +
27806 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27807 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27808 + unsigned long c;
27809 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27810 +#ifdef CONFIG_X86_32
27811 + printk(KERN_CONT "???????? ");
27812 +#else
27813 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27814 + printk(KERN_CONT "???????? ???????? ");
27815 + else
27816 + printk(KERN_CONT "???????????????? ");
27817 +#endif
27818 + } else {
27819 +#ifdef CONFIG_X86_64
27820 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27821 + printk(KERN_CONT "%08x ", (unsigned int)c);
27822 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27823 + } else
27824 +#endif
27825 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27826 + }
27827 + }
27828 + printk("\n");
27829 +}
27830 +#endif
27831 +
27832 +/**
27833 + * probe_kernel_write(): safely attempt to write to a location
27834 + * @dst: address to write to
27835 + * @src: pointer to the data that shall be written
27836 + * @size: size of the data chunk
27837 + *
27838 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27839 + * happens, handle that and return -EFAULT.
27840 + */
27841 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27842 +{
27843 + long ret;
27844 + mm_segment_t old_fs = get_fs();
27845 +
27846 + set_fs(KERNEL_DS);
27847 + pagefault_disable();
27848 + pax_open_kernel();
27849 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27850 + pax_close_kernel();
27851 + pagefault_enable();
27852 + set_fs(old_fs);
27853 +
27854 + return ret ? -EFAULT : 0;
27855 +}
27856 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27857 index dd74e46..7d26398 100644
27858 --- a/arch/x86/mm/gup.c
27859 +++ b/arch/x86/mm/gup.c
27860 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27861 addr = start;
27862 len = (unsigned long) nr_pages << PAGE_SHIFT;
27863 end = start + len;
27864 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27865 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27866 (void __user *)start, len)))
27867 return 0;
27868
27869 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27870 index 6f31ee5..8ee4164 100644
27871 --- a/arch/x86/mm/highmem_32.c
27872 +++ b/arch/x86/mm/highmem_32.c
27873 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27874 idx = type + KM_TYPE_NR*smp_processor_id();
27875 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27876 BUG_ON(!pte_none(*(kmap_pte-idx)));
27877 +
27878 + pax_open_kernel();
27879 set_pte(kmap_pte-idx, mk_pte(page, prot));
27880 + pax_close_kernel();
27881 +
27882 arch_flush_lazy_mmu_mode();
27883
27884 return (void *)vaddr;
27885 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27886 index ae1aa71..56316db 100644
27887 --- a/arch/x86/mm/hugetlbpage.c
27888 +++ b/arch/x86/mm/hugetlbpage.c
27889 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27890 info.flags = 0;
27891 info.length = len;
27892 info.low_limit = TASK_UNMAPPED_BASE;
27893 +
27894 +#ifdef CONFIG_PAX_RANDMMAP
27895 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27896 + info.low_limit += current->mm->delta_mmap;
27897 +#endif
27898 +
27899 info.high_limit = TASK_SIZE;
27900 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27901 info.align_offset = 0;
27902 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27903 VM_BUG_ON(addr != -ENOMEM);
27904 info.flags = 0;
27905 info.low_limit = TASK_UNMAPPED_BASE;
27906 +
27907 +#ifdef CONFIG_PAX_RANDMMAP
27908 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27909 + info.low_limit += current->mm->delta_mmap;
27910 +#endif
27911 +
27912 info.high_limit = TASK_SIZE;
27913 addr = vm_unmapped_area(&info);
27914 }
27915 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
27916 struct hstate *h = hstate_file(file);
27917 struct mm_struct *mm = current->mm;
27918 struct vm_area_struct *vma;
27919 + unsigned long pax_task_size = TASK_SIZE;
27920 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
27921
27922 if (len & ~huge_page_mask(h))
27923 return -EINVAL;
27924 - if (len > TASK_SIZE)
27925 +
27926 +#ifdef CONFIG_PAX_SEGMEXEC
27927 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
27928 + pax_task_size = SEGMEXEC_TASK_SIZE;
27929 +#endif
27930 +
27931 + pax_task_size -= PAGE_SIZE;
27932 +
27933 + if (len > pax_task_size)
27934 return -ENOMEM;
27935
27936 if (flags & MAP_FIXED) {
27937 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
27938 return addr;
27939 }
27940
27941 +#ifdef CONFIG_PAX_RANDMMAP
27942 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
27943 +#endif
27944 +
27945 if (addr) {
27946 addr = ALIGN(addr, huge_page_size(h));
27947 vma = find_vma(mm, addr);
27948 - if (TASK_SIZE - len >= addr &&
27949 - (!vma || addr + len <= vma->vm_start))
27950 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
27951 return addr;
27952 }
27953 if (mm->get_unmapped_area == arch_get_unmapped_area)
27954 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
27955 index d7aea41..0fc945b 100644
27956 --- a/arch/x86/mm/init.c
27957 +++ b/arch/x86/mm/init.c
27958 @@ -4,6 +4,7 @@
27959 #include <linux/swap.h>
27960 #include <linux/memblock.h>
27961 #include <linux/bootmem.h> /* for max_low_pfn */
27962 +#include <linux/tboot.h>
27963
27964 #include <asm/cacheflush.h>
27965 #include <asm/e820.h>
27966 @@ -16,6 +17,8 @@
27967 #include <asm/tlb.h>
27968 #include <asm/proto.h>
27969 #include <asm/dma.h> /* for MAX_DMA_PFN */
27970 +#include <asm/desc.h>
27971 +#include <asm/bios_ebda.h>
27972
27973 unsigned long __initdata pgt_buf_start;
27974 unsigned long __meminitdata pgt_buf_end;
27975 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
27976 {
27977 int i;
27978 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
27979 - unsigned long start = 0, good_end;
27980 + unsigned long start = 0x100000, good_end;
27981 phys_addr_t base;
27982
27983 for (i = 0; i < nr_range; i++) {
27984 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
27985 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
27986 * mmio resources as well as potential bios/acpi data regions.
27987 */
27988 +
27989 +#ifdef CONFIG_GRKERNSEC_KMEM
27990 +static unsigned int ebda_start __read_only;
27991 +static unsigned int ebda_end __read_only;
27992 +#endif
27993 +
27994 int devmem_is_allowed(unsigned long pagenr)
27995 {
27996 - if (pagenr < 256)
27997 +#ifdef CONFIG_GRKERNSEC_KMEM
27998 + /* allow BDA */
27999 + if (!pagenr)
28000 return 1;
28001 + /* allow EBDA */
28002 + if (pagenr >= ebda_start && pagenr < ebda_end)
28003 + return 1;
28004 + /* if tboot is in use, allow access to its hardcoded serial log range */
28005 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28006 + return 1;
28007 +#else
28008 + if (!pagenr)
28009 + return 1;
28010 +#ifdef CONFIG_VM86
28011 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28012 + return 1;
28013 +#endif
28014 +#endif
28015 +
28016 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28017 + return 1;
28018 +#ifdef CONFIG_GRKERNSEC_KMEM
28019 + /* throw out everything else below 1MB */
28020 + if (pagenr <= 256)
28021 + return 0;
28022 +#endif
28023 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28024 return 0;
28025 if (!page_is_ram(pagenr))
28026 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28027 #endif
28028 }
28029
28030 +#ifdef CONFIG_GRKERNSEC_KMEM
28031 +static inline void gr_init_ebda(void)
28032 +{
28033 + unsigned int ebda_addr;
28034 + unsigned int ebda_size = 0;
28035 +
28036 + ebda_addr = get_bios_ebda();
28037 + if (ebda_addr) {
28038 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28039 + ebda_size <<= 10;
28040 + }
28041 + if (ebda_addr && ebda_size) {
28042 + ebda_start = ebda_addr >> PAGE_SHIFT;
28043 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28044 + } else {
28045 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28046 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28047 + }
28048 +}
28049 +#else
28050 +static inline void gr_init_ebda(void) { }
28051 +#endif
28052 +
28053 void free_initmem(void)
28054 {
28055 +#ifdef CONFIG_PAX_KERNEXEC
28056 +#ifdef CONFIG_X86_32
28057 + /* PaX: limit KERNEL_CS to actual size */
28058 + unsigned long addr, limit;
28059 + struct desc_struct d;
28060 + int cpu;
28061 +#else
28062 + pgd_t *pgd;
28063 + pud_t *pud;
28064 + pmd_t *pmd;
28065 + unsigned long addr, end;
28066 +#endif
28067 +#endif
28068 +
28069 + gr_init_ebda();
28070 +
28071 +#ifdef CONFIG_PAX_KERNEXEC
28072 +#ifdef CONFIG_X86_32
28073 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28074 + limit = (limit - 1UL) >> PAGE_SHIFT;
28075 +
28076 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28077 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28078 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28079 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28080 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28081 + }
28082 +
28083 + /* PaX: make KERNEL_CS read-only */
28084 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28085 + if (!paravirt_enabled())
28086 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28087 +/*
28088 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28089 + pgd = pgd_offset_k(addr);
28090 + pud = pud_offset(pgd, addr);
28091 + pmd = pmd_offset(pud, addr);
28092 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28093 + }
28094 +*/
28095 +#ifdef CONFIG_X86_PAE
28096 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28097 +/*
28098 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28099 + pgd = pgd_offset_k(addr);
28100 + pud = pud_offset(pgd, addr);
28101 + pmd = pmd_offset(pud, addr);
28102 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28103 + }
28104 +*/
28105 +#endif
28106 +
28107 +#ifdef CONFIG_MODULES
28108 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28109 +#endif
28110 +
28111 +#else
28112 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28113 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28114 + pgd = pgd_offset_k(addr);
28115 + pud = pud_offset(pgd, addr);
28116 + pmd = pmd_offset(pud, addr);
28117 + if (!pmd_present(*pmd))
28118 + continue;
28119 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28120 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28121 + else
28122 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28123 + }
28124 +
28125 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28126 + end = addr + KERNEL_IMAGE_SIZE;
28127 + for (; addr < end; addr += PMD_SIZE) {
28128 + pgd = pgd_offset_k(addr);
28129 + pud = pud_offset(pgd, addr);
28130 + pmd = pmd_offset(pud, addr);
28131 + if (!pmd_present(*pmd))
28132 + continue;
28133 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28134 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28135 + }
28136 +#endif
28137 +
28138 + flush_tlb_all();
28139 +#endif
28140 +
28141 free_init_pages("unused kernel memory",
28142 (unsigned long)(&__init_begin),
28143 (unsigned long)(&__init_end));
28144 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28145 index 745d66b..56bf568 100644
28146 --- a/arch/x86/mm/init_32.c
28147 +++ b/arch/x86/mm/init_32.c
28148 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
28149 }
28150
28151 /*
28152 - * Creates a middle page table and puts a pointer to it in the
28153 - * given global directory entry. This only returns the gd entry
28154 - * in non-PAE compilation mode, since the middle layer is folded.
28155 - */
28156 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28157 -{
28158 - pud_t *pud;
28159 - pmd_t *pmd_table;
28160 -
28161 -#ifdef CONFIG_X86_PAE
28162 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28163 - if (after_bootmem)
28164 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
28165 - else
28166 - pmd_table = (pmd_t *)alloc_low_page();
28167 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28168 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28169 - pud = pud_offset(pgd, 0);
28170 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28171 -
28172 - return pmd_table;
28173 - }
28174 -#endif
28175 - pud = pud_offset(pgd, 0);
28176 - pmd_table = pmd_offset(pud, 0);
28177 -
28178 - return pmd_table;
28179 -}
28180 -
28181 -/*
28182 * Create a page table and place a pointer to it in a middle page
28183 * directory entry:
28184 */
28185 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28186 page_table = (pte_t *)alloc_low_page();
28187
28188 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28189 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28190 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28191 +#else
28192 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28193 +#endif
28194 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28195 }
28196
28197 return pte_offset_kernel(pmd, 0);
28198 }
28199
28200 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28201 +{
28202 + pud_t *pud;
28203 + pmd_t *pmd_table;
28204 +
28205 + pud = pud_offset(pgd, 0);
28206 + pmd_table = pmd_offset(pud, 0);
28207 +
28208 + return pmd_table;
28209 +}
28210 +
28211 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28212 {
28213 int pgd_idx = pgd_index(vaddr);
28214 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28215 int pgd_idx, pmd_idx;
28216 unsigned long vaddr;
28217 pgd_t *pgd;
28218 + pud_t *pud;
28219 pmd_t *pmd;
28220 pte_t *pte = NULL;
28221
28222 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28223 pgd = pgd_base + pgd_idx;
28224
28225 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28226 - pmd = one_md_table_init(pgd);
28227 - pmd = pmd + pmd_index(vaddr);
28228 + pud = pud_offset(pgd, vaddr);
28229 + pmd = pmd_offset(pud, vaddr);
28230 +
28231 +#ifdef CONFIG_X86_PAE
28232 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28233 +#endif
28234 +
28235 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28236 pmd++, pmd_idx++) {
28237 pte = page_table_kmap_check(one_page_table_init(pmd),
28238 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28239 }
28240 }
28241
28242 -static inline int is_kernel_text(unsigned long addr)
28243 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28244 {
28245 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28246 - return 1;
28247 - return 0;
28248 + if ((start > ktla_ktva((unsigned long)_etext) ||
28249 + end <= ktla_ktva((unsigned long)_stext)) &&
28250 + (start > ktla_ktva((unsigned long)_einittext) ||
28251 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28252 +
28253 +#ifdef CONFIG_ACPI_SLEEP
28254 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28255 +#endif
28256 +
28257 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28258 + return 0;
28259 + return 1;
28260 }
28261
28262 /*
28263 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
28264 unsigned long last_map_addr = end;
28265 unsigned long start_pfn, end_pfn;
28266 pgd_t *pgd_base = swapper_pg_dir;
28267 - int pgd_idx, pmd_idx, pte_ofs;
28268 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28269 unsigned long pfn;
28270 pgd_t *pgd;
28271 + pud_t *pud;
28272 pmd_t *pmd;
28273 pte_t *pte;
28274 unsigned pages_2m, pages_4k;
28275 @@ -280,8 +281,13 @@ repeat:
28276 pfn = start_pfn;
28277 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28278 pgd = pgd_base + pgd_idx;
28279 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28280 - pmd = one_md_table_init(pgd);
28281 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28282 + pud = pud_offset(pgd, 0);
28283 + pmd = pmd_offset(pud, 0);
28284 +
28285 +#ifdef CONFIG_X86_PAE
28286 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28287 +#endif
28288
28289 if (pfn >= end_pfn)
28290 continue;
28291 @@ -293,14 +299,13 @@ repeat:
28292 #endif
28293 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28294 pmd++, pmd_idx++) {
28295 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28296 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28297
28298 /*
28299 * Map with big pages if possible, otherwise
28300 * create normal page tables:
28301 */
28302 if (use_pse) {
28303 - unsigned int addr2;
28304 pgprot_t prot = PAGE_KERNEL_LARGE;
28305 /*
28306 * first pass will use the same initial
28307 @@ -310,11 +315,7 @@ repeat:
28308 __pgprot(PTE_IDENT_ATTR |
28309 _PAGE_PSE);
28310
28311 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28312 - PAGE_OFFSET + PAGE_SIZE-1;
28313 -
28314 - if (is_kernel_text(addr) ||
28315 - is_kernel_text(addr2))
28316 + if (is_kernel_text(address, address + PMD_SIZE))
28317 prot = PAGE_KERNEL_LARGE_EXEC;
28318
28319 pages_2m++;
28320 @@ -331,7 +332,7 @@ repeat:
28321 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28322 pte += pte_ofs;
28323 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28324 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28325 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28326 pgprot_t prot = PAGE_KERNEL;
28327 /*
28328 * first pass will use the same initial
28329 @@ -339,7 +340,7 @@ repeat:
28330 */
28331 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28332
28333 - if (is_kernel_text(addr))
28334 + if (is_kernel_text(address, address + PAGE_SIZE))
28335 prot = PAGE_KERNEL_EXEC;
28336
28337 pages_4k++;
28338 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
28339
28340 pud = pud_offset(pgd, va);
28341 pmd = pmd_offset(pud, va);
28342 - if (!pmd_present(*pmd))
28343 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
28344 break;
28345
28346 pte = pte_offset_kernel(pmd, va);
28347 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
28348
28349 static void __init pagetable_init(void)
28350 {
28351 - pgd_t *pgd_base = swapper_pg_dir;
28352 -
28353 - permanent_kmaps_init(pgd_base);
28354 + permanent_kmaps_init(swapper_pg_dir);
28355 }
28356
28357 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28358 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28359 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28360
28361 /* user-defined highmem size */
28362 @@ -728,6 +727,12 @@ void __init mem_init(void)
28363
28364 pci_iommu_alloc();
28365
28366 +#ifdef CONFIG_PAX_PER_CPU_PGD
28367 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28368 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28369 + KERNEL_PGD_PTRS);
28370 +#endif
28371 +
28372 #ifdef CONFIG_FLATMEM
28373 BUG_ON(!mem_map);
28374 #endif
28375 @@ -754,7 +759,7 @@ void __init mem_init(void)
28376 reservedpages++;
28377
28378 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28379 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28380 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28381 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28382
28383 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28384 @@ -795,10 +800,10 @@ void __init mem_init(void)
28385 ((unsigned long)&__init_end -
28386 (unsigned long)&__init_begin) >> 10,
28387
28388 - (unsigned long)&_etext, (unsigned long)&_edata,
28389 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28390 + (unsigned long)&_sdata, (unsigned long)&_edata,
28391 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28392
28393 - (unsigned long)&_text, (unsigned long)&_etext,
28394 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28395 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28396
28397 /*
28398 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
28399 if (!kernel_set_to_readonly)
28400 return;
28401
28402 + start = ktla_ktva(start);
28403 pr_debug("Set kernel text: %lx - %lx for read write\n",
28404 start, start+size);
28405
28406 @@ -890,6 +896,7 @@ void set_kernel_text_ro(void)
28407 if (!kernel_set_to_readonly)
28408 return;
28409
28410 + start = ktla_ktva(start);
28411 pr_debug("Set kernel text: %lx - %lx for read only\n",
28412 start, start+size);
28413
28414 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
28415 unsigned long start = PFN_ALIGN(_text);
28416 unsigned long size = PFN_ALIGN(_etext) - start;
28417
28418 + start = ktla_ktva(start);
28419 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28420 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28421 size >> 10);
28422 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28423 index 75c9a6a..498d677 100644
28424 --- a/arch/x86/mm/init_64.c
28425 +++ b/arch/x86/mm/init_64.c
28426 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28427 * around without checking the pgd every time.
28428 */
28429
28430 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28431 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28432 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28433
28434 int force_personality32;
28435 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28436
28437 for (address = start; address <= end; address += PGDIR_SIZE) {
28438 const pgd_t *pgd_ref = pgd_offset_k(address);
28439 +
28440 +#ifdef CONFIG_PAX_PER_CPU_PGD
28441 + unsigned long cpu;
28442 +#else
28443 struct page *page;
28444 +#endif
28445
28446 if (pgd_none(*pgd_ref))
28447 continue;
28448
28449 spin_lock(&pgd_lock);
28450 +
28451 +#ifdef CONFIG_PAX_PER_CPU_PGD
28452 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28453 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28454 +#else
28455 list_for_each_entry(page, &pgd_list, lru) {
28456 pgd_t *pgd;
28457 spinlock_t *pgt_lock;
28458 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28459 /* the pgt_lock only for Xen */
28460 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28461 spin_lock(pgt_lock);
28462 +#endif
28463
28464 if (pgd_none(*pgd))
28465 set_pgd(pgd, *pgd_ref);
28466 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28467 BUG_ON(pgd_page_vaddr(*pgd)
28468 != pgd_page_vaddr(*pgd_ref));
28469
28470 +#ifndef CONFIG_PAX_PER_CPU_PGD
28471 spin_unlock(pgt_lock);
28472 +#endif
28473 +
28474 }
28475 spin_unlock(&pgd_lock);
28476 }
28477 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28478 {
28479 if (pgd_none(*pgd)) {
28480 pud_t *pud = (pud_t *)spp_getpage();
28481 - pgd_populate(&init_mm, pgd, pud);
28482 + pgd_populate_kernel(&init_mm, pgd, pud);
28483 if (pud != pud_offset(pgd, 0))
28484 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28485 pud, pud_offset(pgd, 0));
28486 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28487 {
28488 if (pud_none(*pud)) {
28489 pmd_t *pmd = (pmd_t *) spp_getpage();
28490 - pud_populate(&init_mm, pud, pmd);
28491 + pud_populate_kernel(&init_mm, pud, pmd);
28492 if (pmd != pmd_offset(pud, 0))
28493 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28494 pmd, pmd_offset(pud, 0));
28495 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28496 pmd = fill_pmd(pud, vaddr);
28497 pte = fill_pte(pmd, vaddr);
28498
28499 + pax_open_kernel();
28500 set_pte(pte, new_pte);
28501 + pax_close_kernel();
28502
28503 /*
28504 * It's enough to flush this one mapping.
28505 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28506 pgd = pgd_offset_k((unsigned long)__va(phys));
28507 if (pgd_none(*pgd)) {
28508 pud = (pud_t *) spp_getpage();
28509 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28510 - _PAGE_USER));
28511 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28512 }
28513 pud = pud_offset(pgd, (unsigned long)__va(phys));
28514 if (pud_none(*pud)) {
28515 pmd = (pmd_t *) spp_getpage();
28516 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28517 - _PAGE_USER));
28518 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28519 }
28520 pmd = pmd_offset(pud, phys);
28521 BUG_ON(!pmd_none(*pmd));
28522 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
28523 if (pfn >= pgt_buf_top)
28524 panic("alloc_low_page: ran out of memory");
28525
28526 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28527 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28528 clear_page(adr);
28529 *phys = pfn * PAGE_SIZE;
28530 return adr;
28531 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
28532
28533 phys = __pa(virt);
28534 left = phys & (PAGE_SIZE - 1);
28535 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28536 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28537 adr = (void *)(((unsigned long)adr) | left);
28538
28539 return adr;
28540 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28541 unmap_low_page(pmd);
28542
28543 spin_lock(&init_mm.page_table_lock);
28544 - pud_populate(&init_mm, pud, __va(pmd_phys));
28545 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
28546 spin_unlock(&init_mm.page_table_lock);
28547 }
28548 __flush_tlb_all();
28549 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
28550 unmap_low_page(pud);
28551
28552 spin_lock(&init_mm.page_table_lock);
28553 - pgd_populate(&init_mm, pgd, __va(pud_phys));
28554 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
28555 spin_unlock(&init_mm.page_table_lock);
28556 pgd_changed = true;
28557 }
28558 @@ -693,6 +707,12 @@ void __init mem_init(void)
28559
28560 pci_iommu_alloc();
28561
28562 +#ifdef CONFIG_PAX_PER_CPU_PGD
28563 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28564 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28565 + KERNEL_PGD_PTRS);
28566 +#endif
28567 +
28568 /* clear_bss() already clear the empty_zero_page */
28569
28570 reservedpages = 0;
28571 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
28572 static struct vm_area_struct gate_vma = {
28573 .vm_start = VSYSCALL_START,
28574 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28575 - .vm_page_prot = PAGE_READONLY_EXEC,
28576 - .vm_flags = VM_READ | VM_EXEC
28577 + .vm_page_prot = PAGE_READONLY,
28578 + .vm_flags = VM_READ
28579 };
28580
28581 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28582 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
28583
28584 const char *arch_vma_name(struct vm_area_struct *vma)
28585 {
28586 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28587 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28588 return "[vdso]";
28589 if (vma == &gate_vma)
28590 return "[vsyscall]";
28591 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28592 index 7b179b4..6bd1777 100644
28593 --- a/arch/x86/mm/iomap_32.c
28594 +++ b/arch/x86/mm/iomap_32.c
28595 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28596 type = kmap_atomic_idx_push();
28597 idx = type + KM_TYPE_NR * smp_processor_id();
28598 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28599 +
28600 + pax_open_kernel();
28601 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28602 + pax_close_kernel();
28603 +
28604 arch_flush_lazy_mmu_mode();
28605
28606 return (void *)vaddr;
28607 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28608 index 78fe3f1..73b95e2 100644
28609 --- a/arch/x86/mm/ioremap.c
28610 +++ b/arch/x86/mm/ioremap.c
28611 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28612 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28613 int is_ram = page_is_ram(pfn);
28614
28615 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28616 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28617 return NULL;
28618 WARN_ON_ONCE(is_ram);
28619 }
28620 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28621 *
28622 * Caller must ensure there is only one unmapping for the same pointer.
28623 */
28624 -void iounmap(volatile void __iomem *addr)
28625 +void iounmap(const volatile void __iomem *addr)
28626 {
28627 struct vm_struct *p, *o;
28628
28629 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28630
28631 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28632 if (page_is_ram(start >> PAGE_SHIFT))
28633 +#ifdef CONFIG_HIGHMEM
28634 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28635 +#endif
28636 return __va(phys);
28637
28638 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28639 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28640 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28641 {
28642 if (page_is_ram(phys >> PAGE_SHIFT))
28643 +#ifdef CONFIG_HIGHMEM
28644 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28645 +#endif
28646 return;
28647
28648 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28649 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
28650 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28651
28652 static __initdata int after_paging_init;
28653 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28654 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28655
28656 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28657 {
28658 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
28659 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28660
28661 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28662 - memset(bm_pte, 0, sizeof(bm_pte));
28663 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28664 + pmd_populate_user(&init_mm, pmd, bm_pte);
28665
28666 /*
28667 * The boot-ioremap range spans multiple pmds, for which
28668 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28669 index d87dd6d..bf3fa66 100644
28670 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28671 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28672 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28673 * memory (e.g. tracked pages)? For now, we need this to avoid
28674 * invoking kmemcheck for PnP BIOS calls.
28675 */
28676 - if (regs->flags & X86_VM_MASK)
28677 + if (v8086_mode(regs))
28678 return false;
28679 - if (regs->cs != __KERNEL_CS)
28680 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28681 return false;
28682
28683 pte = kmemcheck_pte_lookup(address);
28684 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28685 index 845df68..1d8d29f 100644
28686 --- a/arch/x86/mm/mmap.c
28687 +++ b/arch/x86/mm/mmap.c
28688 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28689 * Leave an at least ~128 MB hole with possible stack randomization.
28690 */
28691 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28692 -#define MAX_GAP (TASK_SIZE/6*5)
28693 +#define MAX_GAP (pax_task_size/6*5)
28694
28695 static int mmap_is_legacy(void)
28696 {
28697 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28698 return rnd << PAGE_SHIFT;
28699 }
28700
28701 -static unsigned long mmap_base(void)
28702 +static unsigned long mmap_base(struct mm_struct *mm)
28703 {
28704 unsigned long gap = rlimit(RLIMIT_STACK);
28705 + unsigned long pax_task_size = TASK_SIZE;
28706 +
28707 +#ifdef CONFIG_PAX_SEGMEXEC
28708 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28709 + pax_task_size = SEGMEXEC_TASK_SIZE;
28710 +#endif
28711
28712 if (gap < MIN_GAP)
28713 gap = MIN_GAP;
28714 else if (gap > MAX_GAP)
28715 gap = MAX_GAP;
28716
28717 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28718 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28719 }
28720
28721 /*
28722 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28723 * does, but not when emulating X86_32
28724 */
28725 -static unsigned long mmap_legacy_base(void)
28726 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28727 {
28728 - if (mmap_is_ia32())
28729 + if (mmap_is_ia32()) {
28730 +
28731 +#ifdef CONFIG_PAX_SEGMEXEC
28732 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28733 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28734 + else
28735 +#endif
28736 +
28737 return TASK_UNMAPPED_BASE;
28738 - else
28739 + } else
28740 return TASK_UNMAPPED_BASE + mmap_rnd();
28741 }
28742
28743 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28744 void arch_pick_mmap_layout(struct mm_struct *mm)
28745 {
28746 if (mmap_is_legacy()) {
28747 - mm->mmap_base = mmap_legacy_base();
28748 + mm->mmap_base = mmap_legacy_base(mm);
28749 +
28750 +#ifdef CONFIG_PAX_RANDMMAP
28751 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28752 + mm->mmap_base += mm->delta_mmap;
28753 +#endif
28754 +
28755 mm->get_unmapped_area = arch_get_unmapped_area;
28756 mm->unmap_area = arch_unmap_area;
28757 } else {
28758 - mm->mmap_base = mmap_base();
28759 + mm->mmap_base = mmap_base(mm);
28760 +
28761 +#ifdef CONFIG_PAX_RANDMMAP
28762 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28763 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28764 +#endif
28765 +
28766 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28767 mm->unmap_area = arch_unmap_area_topdown;
28768 }
28769 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28770 index dc0b727..f612039 100644
28771 --- a/arch/x86/mm/mmio-mod.c
28772 +++ b/arch/x86/mm/mmio-mod.c
28773 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28774 break;
28775 default:
28776 {
28777 - unsigned char *ip = (unsigned char *)instptr;
28778 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28779 my_trace->opcode = MMIO_UNKNOWN_OP;
28780 my_trace->width = 0;
28781 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28782 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28783 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28784 void __iomem *addr)
28785 {
28786 - static atomic_t next_id;
28787 + static atomic_unchecked_t next_id;
28788 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28789 /* These are page-unaligned. */
28790 struct mmiotrace_map map = {
28791 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28792 .private = trace
28793 },
28794 .phys = offset,
28795 - .id = atomic_inc_return(&next_id)
28796 + .id = atomic_inc_return_unchecked(&next_id)
28797 };
28798 map.map_id = trace->id;
28799
28800 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28801 ioremap_trace_core(offset, size, addr);
28802 }
28803
28804 -static void iounmap_trace_core(volatile void __iomem *addr)
28805 +static void iounmap_trace_core(const volatile void __iomem *addr)
28806 {
28807 struct mmiotrace_map map = {
28808 .phys = 0,
28809 @@ -328,7 +328,7 @@ not_enabled:
28810 }
28811 }
28812
28813 -void mmiotrace_iounmap(volatile void __iomem *addr)
28814 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28815 {
28816 might_sleep();
28817 if (is_enabled()) /* recheck and proper locking in *_core() */
28818 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28819 index 8504f36..5fc68f2 100644
28820 --- a/arch/x86/mm/numa.c
28821 +++ b/arch/x86/mm/numa.c
28822 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28823 return true;
28824 }
28825
28826 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28827 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28828 {
28829 unsigned long uninitialized_var(pfn_align);
28830 int i, nid;
28831 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28832 index b008656..773eac2 100644
28833 --- a/arch/x86/mm/pageattr-test.c
28834 +++ b/arch/x86/mm/pageattr-test.c
28835 @@ -36,7 +36,7 @@ enum {
28836
28837 static int pte_testbit(pte_t pte)
28838 {
28839 - return pte_flags(pte) & _PAGE_UNUSED1;
28840 + return pte_flags(pte) & _PAGE_CPA_TEST;
28841 }
28842
28843 struct split_state {
28844 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28845 index a718e0d..77419bc 100644
28846 --- a/arch/x86/mm/pageattr.c
28847 +++ b/arch/x86/mm/pageattr.c
28848 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28849 */
28850 #ifdef CONFIG_PCI_BIOS
28851 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28852 - pgprot_val(forbidden) |= _PAGE_NX;
28853 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28854 #endif
28855
28856 /*
28857 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28858 * Does not cover __inittext since that is gone later on. On
28859 * 64bit we do not enforce !NX on the low mapping
28860 */
28861 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28862 - pgprot_val(forbidden) |= _PAGE_NX;
28863 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28864 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28865
28866 +#ifdef CONFIG_DEBUG_RODATA
28867 /*
28868 * The .rodata section needs to be read-only. Using the pfn
28869 * catches all aliases.
28870 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28871 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
28872 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
28873 pgprot_val(forbidden) |= _PAGE_RW;
28874 +#endif
28875
28876 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28877 /*
28878 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28879 }
28880 #endif
28881
28882 +#ifdef CONFIG_PAX_KERNEXEC
28883 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28884 + pgprot_val(forbidden) |= _PAGE_RW;
28885 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28886 + }
28887 +#endif
28888 +
28889 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28890
28891 return prot;
28892 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
28893 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28894 {
28895 /* change init_mm */
28896 + pax_open_kernel();
28897 set_pte_atomic(kpte, pte);
28898 +
28899 #ifdef CONFIG_X86_32
28900 if (!SHARED_KERNEL_PMD) {
28901 +
28902 +#ifdef CONFIG_PAX_PER_CPU_PGD
28903 + unsigned long cpu;
28904 +#else
28905 struct page *page;
28906 +#endif
28907
28908 +#ifdef CONFIG_PAX_PER_CPU_PGD
28909 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28910 + pgd_t *pgd = get_cpu_pgd(cpu);
28911 +#else
28912 list_for_each_entry(page, &pgd_list, lru) {
28913 - pgd_t *pgd;
28914 + pgd_t *pgd = (pgd_t *)page_address(page);
28915 +#endif
28916 +
28917 pud_t *pud;
28918 pmd_t *pmd;
28919
28920 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
28921 + pgd += pgd_index(address);
28922 pud = pud_offset(pgd, address);
28923 pmd = pmd_offset(pud, address);
28924 set_pte_atomic((pte_t *)pmd, pte);
28925 }
28926 }
28927 #endif
28928 + pax_close_kernel();
28929 }
28930
28931 static int
28932 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
28933 index 0eb572e..92f5c1e 100644
28934 --- a/arch/x86/mm/pat.c
28935 +++ b/arch/x86/mm/pat.c
28936 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
28937
28938 if (!entry) {
28939 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
28940 - current->comm, current->pid, start, end - 1);
28941 + current->comm, task_pid_nr(current), start, end - 1);
28942 return -EINVAL;
28943 }
28944
28945 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
28946
28947 while (cursor < to) {
28948 if (!devmem_is_allowed(pfn)) {
28949 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
28950 - current->comm, from, to - 1);
28951 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
28952 + current->comm, from, to - 1, cursor);
28953 return 0;
28954 }
28955 cursor += PAGE_SIZE;
28956 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
28957 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
28958 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
28959 "for [mem %#010Lx-%#010Lx]\n",
28960 - current->comm, current->pid,
28961 + current->comm, task_pid_nr(current),
28962 cattr_name(flags),
28963 base, (unsigned long long)(base + size-1));
28964 return -EINVAL;
28965 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
28966 flags = lookup_memtype(paddr);
28967 if (want_flags != flags) {
28968 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
28969 - current->comm, current->pid,
28970 + current->comm, task_pid_nr(current),
28971 cattr_name(want_flags),
28972 (unsigned long long)paddr,
28973 (unsigned long long)(paddr + size - 1),
28974 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
28975 free_memtype(paddr, paddr + size);
28976 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
28977 " for [mem %#010Lx-%#010Lx], got %s\n",
28978 - current->comm, current->pid,
28979 + current->comm, task_pid_nr(current),
28980 cattr_name(want_flags),
28981 (unsigned long long)paddr,
28982 (unsigned long long)(paddr + size - 1),
28983 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
28984 index 9f0614d..92ae64a 100644
28985 --- a/arch/x86/mm/pf_in.c
28986 +++ b/arch/x86/mm/pf_in.c
28987 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
28988 int i;
28989 enum reason_type rv = OTHERS;
28990
28991 - p = (unsigned char *)ins_addr;
28992 + p = (unsigned char *)ktla_ktva(ins_addr);
28993 p += skip_prefix(p, &prf);
28994 p += get_opcode(p, &opcode);
28995
28996 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
28997 struct prefix_bits prf;
28998 int i;
28999
29000 - p = (unsigned char *)ins_addr;
29001 + p = (unsigned char *)ktla_ktva(ins_addr);
29002 p += skip_prefix(p, &prf);
29003 p += get_opcode(p, &opcode);
29004
29005 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29006 struct prefix_bits prf;
29007 int i;
29008
29009 - p = (unsigned char *)ins_addr;
29010 + p = (unsigned char *)ktla_ktva(ins_addr);
29011 p += skip_prefix(p, &prf);
29012 p += get_opcode(p, &opcode);
29013
29014 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29015 struct prefix_bits prf;
29016 int i;
29017
29018 - p = (unsigned char *)ins_addr;
29019 + p = (unsigned char *)ktla_ktva(ins_addr);
29020 p += skip_prefix(p, &prf);
29021 p += get_opcode(p, &opcode);
29022 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29023 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29024 struct prefix_bits prf;
29025 int i;
29026
29027 - p = (unsigned char *)ins_addr;
29028 + p = (unsigned char *)ktla_ktva(ins_addr);
29029 p += skip_prefix(p, &prf);
29030 p += get_opcode(p, &opcode);
29031 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29032 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29033 index e27fbf8..8b56dc9 100644
29034 --- a/arch/x86/mm/pgtable.c
29035 +++ b/arch/x86/mm/pgtable.c
29036 @@ -84,10 +84,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29037 list_del(&page->lru);
29038 }
29039
29040 -#define UNSHARED_PTRS_PER_PGD \
29041 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29042 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29043 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29044
29045 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29046 +{
29047 + unsigned int count = USER_PGD_PTRS;
29048
29049 + while (count--)
29050 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29051 +}
29052 +#endif
29053 +
29054 +#ifdef CONFIG_PAX_PER_CPU_PGD
29055 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29056 +{
29057 + unsigned int count = USER_PGD_PTRS;
29058 +
29059 + while (count--) {
29060 + pgd_t pgd;
29061 +
29062 +#ifdef CONFIG_X86_64
29063 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29064 +#else
29065 + pgd = *src++;
29066 +#endif
29067 +
29068 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29069 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29070 +#endif
29071 +
29072 + *dst++ = pgd;
29073 + }
29074 +
29075 +}
29076 +#endif
29077 +
29078 +#ifdef CONFIG_X86_64
29079 +#define pxd_t pud_t
29080 +#define pyd_t pgd_t
29081 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29082 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29083 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29084 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29085 +#define PYD_SIZE PGDIR_SIZE
29086 +#else
29087 +#define pxd_t pmd_t
29088 +#define pyd_t pud_t
29089 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29090 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29091 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29092 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29093 +#define PYD_SIZE PUD_SIZE
29094 +#endif
29095 +
29096 +#ifdef CONFIG_PAX_PER_CPU_PGD
29097 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29098 +static inline void pgd_dtor(pgd_t *pgd) {}
29099 +#else
29100 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29101 {
29102 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29103 @@ -128,6 +182,7 @@ static void pgd_dtor(pgd_t *pgd)
29104 pgd_list_del(pgd);
29105 spin_unlock(&pgd_lock);
29106 }
29107 +#endif
29108
29109 /*
29110 * List of all pgd's needed for non-PAE so it can invalidate entries
29111 @@ -140,7 +195,7 @@ static void pgd_dtor(pgd_t *pgd)
29112 * -- nyc
29113 */
29114
29115 -#ifdef CONFIG_X86_PAE
29116 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29117 /*
29118 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29119 * updating the top-level pagetable entries to guarantee the
29120 @@ -152,7 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
29121 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29122 * and initialize the kernel pmds here.
29123 */
29124 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29125 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29126
29127 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29128 {
29129 @@ -170,36 +225,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29130 */
29131 flush_tlb_mm(mm);
29132 }
29133 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29134 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29135 #else /* !CONFIG_X86_PAE */
29136
29137 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29138 -#define PREALLOCATED_PMDS 0
29139 +#define PREALLOCATED_PXDS 0
29140
29141 #endif /* CONFIG_X86_PAE */
29142
29143 -static void free_pmds(pmd_t *pmds[])
29144 +static void free_pxds(pxd_t *pxds[])
29145 {
29146 int i;
29147
29148 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29149 - if (pmds[i])
29150 - free_page((unsigned long)pmds[i]);
29151 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29152 + if (pxds[i])
29153 + free_page((unsigned long)pxds[i]);
29154 }
29155
29156 -static int preallocate_pmds(pmd_t *pmds[])
29157 +static int preallocate_pxds(pxd_t *pxds[])
29158 {
29159 int i;
29160 bool failed = false;
29161
29162 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29163 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29164 - if (pmd == NULL)
29165 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29166 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29167 + if (pxd == NULL)
29168 failed = true;
29169 - pmds[i] = pmd;
29170 + pxds[i] = pxd;
29171 }
29172
29173 if (failed) {
29174 - free_pmds(pmds);
29175 + free_pxds(pxds);
29176 return -ENOMEM;
29177 }
29178
29179 @@ -212,51 +269,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29180 * preallocate which never got a corresponding vma will need to be
29181 * freed manually.
29182 */
29183 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29184 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29185 {
29186 int i;
29187
29188 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29189 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29190 pgd_t pgd = pgdp[i];
29191
29192 if (pgd_val(pgd) != 0) {
29193 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29194 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29195
29196 - pgdp[i] = native_make_pgd(0);
29197 + set_pgd(pgdp + i, native_make_pgd(0));
29198
29199 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29200 - pmd_free(mm, pmd);
29201 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29202 + pxd_free(mm, pxd);
29203 }
29204 }
29205 }
29206
29207 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29208 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29209 {
29210 - pud_t *pud;
29211 + pyd_t *pyd;
29212 unsigned long addr;
29213 int i;
29214
29215 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29216 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29217 return;
29218
29219 - pud = pud_offset(pgd, 0);
29220 +#ifdef CONFIG_X86_64
29221 + pyd = pyd_offset(mm, 0L);
29222 +#else
29223 + pyd = pyd_offset(pgd, 0L);
29224 +#endif
29225
29226 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29227 - i++, pud++, addr += PUD_SIZE) {
29228 - pmd_t *pmd = pmds[i];
29229 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29230 + i++, pyd++, addr += PYD_SIZE) {
29231 + pxd_t *pxd = pxds[i];
29232
29233 if (i >= KERNEL_PGD_BOUNDARY)
29234 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29235 - sizeof(pmd_t) * PTRS_PER_PMD);
29236 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29237 + sizeof(pxd_t) * PTRS_PER_PMD);
29238
29239 - pud_populate(mm, pud, pmd);
29240 + pyd_populate(mm, pyd, pxd);
29241 }
29242 }
29243
29244 pgd_t *pgd_alloc(struct mm_struct *mm)
29245 {
29246 pgd_t *pgd;
29247 - pmd_t *pmds[PREALLOCATED_PMDS];
29248 + pxd_t *pxds[PREALLOCATED_PXDS];
29249
29250 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29251
29252 @@ -265,11 +326,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29253
29254 mm->pgd = pgd;
29255
29256 - if (preallocate_pmds(pmds) != 0)
29257 + if (preallocate_pxds(pxds) != 0)
29258 goto out_free_pgd;
29259
29260 if (paravirt_pgd_alloc(mm) != 0)
29261 - goto out_free_pmds;
29262 + goto out_free_pxds;
29263
29264 /*
29265 * Make sure that pre-populating the pmds is atomic with
29266 @@ -279,14 +340,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29267 spin_lock(&pgd_lock);
29268
29269 pgd_ctor(mm, pgd);
29270 - pgd_prepopulate_pmd(mm, pgd, pmds);
29271 + pgd_prepopulate_pxd(mm, pgd, pxds);
29272
29273 spin_unlock(&pgd_lock);
29274
29275 return pgd;
29276
29277 -out_free_pmds:
29278 - free_pmds(pmds);
29279 +out_free_pxds:
29280 + free_pxds(pxds);
29281 out_free_pgd:
29282 free_page((unsigned long)pgd);
29283 out:
29284 @@ -295,7 +356,7 @@ out:
29285
29286 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29287 {
29288 - pgd_mop_up_pmds(mm, pgd);
29289 + pgd_mop_up_pxds(mm, pgd);
29290 pgd_dtor(pgd);
29291 paravirt_pgd_free(mm, pgd);
29292 free_page((unsigned long)pgd);
29293 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29294 index a69bcb8..19068ab 100644
29295 --- a/arch/x86/mm/pgtable_32.c
29296 +++ b/arch/x86/mm/pgtable_32.c
29297 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29298 return;
29299 }
29300 pte = pte_offset_kernel(pmd, vaddr);
29301 +
29302 + pax_open_kernel();
29303 if (pte_val(pteval))
29304 set_pte_at(&init_mm, vaddr, pte, pteval);
29305 else
29306 pte_clear(&init_mm, vaddr, pte);
29307 + pax_close_kernel();
29308
29309 /*
29310 * It's enough to flush this one mapping.
29311 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29312 index d2e2735..5c6586f 100644
29313 --- a/arch/x86/mm/physaddr.c
29314 +++ b/arch/x86/mm/physaddr.c
29315 @@ -8,7 +8,7 @@
29316
29317 #ifdef CONFIG_X86_64
29318
29319 -unsigned long __phys_addr(unsigned long x)
29320 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29321 {
29322 if (x >= __START_KERNEL_map) {
29323 x -= __START_KERNEL_map;
29324 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29325 #else
29326
29327 #ifdef CONFIG_DEBUG_VIRTUAL
29328 -unsigned long __phys_addr(unsigned long x)
29329 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29330 {
29331 /* VMALLOC_* aren't constants */
29332 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
29333 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29334 index 410531d..0f16030 100644
29335 --- a/arch/x86/mm/setup_nx.c
29336 +++ b/arch/x86/mm/setup_nx.c
29337 @@ -5,8 +5,10 @@
29338 #include <asm/pgtable.h>
29339 #include <asm/proto.h>
29340
29341 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29342 static int disable_nx __cpuinitdata;
29343
29344 +#ifndef CONFIG_PAX_PAGEEXEC
29345 /*
29346 * noexec = on|off
29347 *
29348 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29349 return 0;
29350 }
29351 early_param("noexec", noexec_setup);
29352 +#endif
29353 +
29354 +#endif
29355
29356 void __cpuinit x86_configure_nx(void)
29357 {
29358 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29359 if (cpu_has_nx && !disable_nx)
29360 __supported_pte_mask |= _PAGE_NX;
29361 else
29362 +#endif
29363 __supported_pte_mask &= ~_PAGE_NX;
29364 }
29365
29366 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29367 index 13a6b29..c2fff23 100644
29368 --- a/arch/x86/mm/tlb.c
29369 +++ b/arch/x86/mm/tlb.c
29370 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29371 BUG();
29372 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29373 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29374 +
29375 +#ifndef CONFIG_PAX_PER_CPU_PGD
29376 load_cr3(swapper_pg_dir);
29377 +#endif
29378 +
29379 }
29380 }
29381 EXPORT_SYMBOL_GPL(leave_mm);
29382 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29383 index 877b9a1..a8ecf42 100644
29384 --- a/arch/x86/net/bpf_jit.S
29385 +++ b/arch/x86/net/bpf_jit.S
29386 @@ -9,6 +9,7 @@
29387 */
29388 #include <linux/linkage.h>
29389 #include <asm/dwarf2.h>
29390 +#include <asm/alternative-asm.h>
29391
29392 /*
29393 * Calling convention :
29394 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29395 jle bpf_slow_path_word
29396 mov (SKBDATA,%rsi),%eax
29397 bswap %eax /* ntohl() */
29398 + pax_force_retaddr
29399 ret
29400
29401 sk_load_half:
29402 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29403 jle bpf_slow_path_half
29404 movzwl (SKBDATA,%rsi),%eax
29405 rol $8,%ax # ntohs()
29406 + pax_force_retaddr
29407 ret
29408
29409 sk_load_byte:
29410 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29411 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29412 jle bpf_slow_path_byte
29413 movzbl (SKBDATA,%rsi),%eax
29414 + pax_force_retaddr
29415 ret
29416
29417 /**
29418 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29419 movzbl (SKBDATA,%rsi),%ebx
29420 and $15,%bl
29421 shl $2,%bl
29422 + pax_force_retaddr
29423 ret
29424
29425 /* rsi contains offset and can be scratched */
29426 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29427 js bpf_error
29428 mov -12(%rbp),%eax
29429 bswap %eax
29430 + pax_force_retaddr
29431 ret
29432
29433 bpf_slow_path_half:
29434 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29435 mov -12(%rbp),%ax
29436 rol $8,%ax
29437 movzwl %ax,%eax
29438 + pax_force_retaddr
29439 ret
29440
29441 bpf_slow_path_byte:
29442 bpf_slow_path_common(1)
29443 js bpf_error
29444 movzbl -12(%rbp),%eax
29445 + pax_force_retaddr
29446 ret
29447
29448 bpf_slow_path_byte_msh:
29449 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29450 and $15,%al
29451 shl $2,%al
29452 xchg %eax,%ebx
29453 + pax_force_retaddr
29454 ret
29455
29456 #define sk_negative_common(SIZE) \
29457 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29458 sk_negative_common(4)
29459 mov (%rax), %eax
29460 bswap %eax
29461 + pax_force_retaddr
29462 ret
29463
29464 bpf_slow_path_half_neg:
29465 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29466 mov (%rax),%ax
29467 rol $8,%ax
29468 movzwl %ax,%eax
29469 + pax_force_retaddr
29470 ret
29471
29472 bpf_slow_path_byte_neg:
29473 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29474 .globl sk_load_byte_negative_offset
29475 sk_negative_common(1)
29476 movzbl (%rax), %eax
29477 + pax_force_retaddr
29478 ret
29479
29480 bpf_slow_path_byte_msh_neg:
29481 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29482 and $15,%al
29483 shl $2,%al
29484 xchg %eax,%ebx
29485 + pax_force_retaddr
29486 ret
29487
29488 bpf_error:
29489 @@ -197,4 +210,5 @@ bpf_error:
29490 xor %eax,%eax
29491 mov -8(%rbp),%rbx
29492 leaveq
29493 + pax_force_retaddr
29494 ret
29495 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29496 index d11a470..3f9adff3 100644
29497 --- a/arch/x86/net/bpf_jit_comp.c
29498 +++ b/arch/x86/net/bpf_jit_comp.c
29499 @@ -12,6 +12,7 @@
29500 #include <linux/netdevice.h>
29501 #include <linux/filter.h>
29502 #include <linux/if_vlan.h>
29503 +#include <linux/random.h>
29504
29505 /*
29506 * Conventions :
29507 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29508 return ptr + len;
29509 }
29510
29511 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29512 +#define MAX_INSTR_CODE_SIZE 96
29513 +#else
29514 +#define MAX_INSTR_CODE_SIZE 64
29515 +#endif
29516 +
29517 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29518
29519 #define EMIT1(b1) EMIT(b1, 1)
29520 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29521 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29522 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29523 +
29524 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29525 +/* original constant will appear in ecx */
29526 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29527 +do { \
29528 + /* mov ecx, randkey */ \
29529 + EMIT1(0xb9); \
29530 + EMIT(_key, 4); \
29531 + /* xor ecx, randkey ^ off */ \
29532 + EMIT2(0x81, 0xf1); \
29533 + EMIT((_key) ^ (_off), 4); \
29534 +} while (0)
29535 +
29536 +#define EMIT1_off32(b1, _off) \
29537 +do { \
29538 + switch (b1) { \
29539 + case 0x05: /* add eax, imm32 */ \
29540 + case 0x2d: /* sub eax, imm32 */ \
29541 + case 0x25: /* and eax, imm32 */ \
29542 + case 0x0d: /* or eax, imm32 */ \
29543 + case 0xb8: /* mov eax, imm32 */ \
29544 + case 0x3d: /* cmp eax, imm32 */ \
29545 + case 0xa9: /* test eax, imm32 */ \
29546 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29547 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29548 + break; \
29549 + case 0xbb: /* mov ebx, imm32 */ \
29550 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29551 + /* mov ebx, ecx */ \
29552 + EMIT2(0x89, 0xcb); \
29553 + break; \
29554 + case 0xbe: /* mov esi, imm32 */ \
29555 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29556 + /* mov esi, ecx */ \
29557 + EMIT2(0x89, 0xce); \
29558 + break; \
29559 + case 0xe9: /* jmp rel imm32 */ \
29560 + EMIT1(b1); \
29561 + EMIT(_off, 4); \
29562 + /* prevent fall-through, we're not called if off = 0 */ \
29563 + EMIT(0xcccccccc, 4); \
29564 + EMIT(0xcccccccc, 4); \
29565 + break; \
29566 + default: \
29567 + EMIT1(b1); \
29568 + EMIT(_off, 4); \
29569 + } \
29570 +} while (0)
29571 +
29572 +#define EMIT2_off32(b1, b2, _off) \
29573 +do { \
29574 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29575 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29576 + EMIT(randkey, 4); \
29577 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29578 + EMIT((_off) - randkey, 4); \
29579 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29580 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29581 + /* imul eax, ecx */ \
29582 + EMIT3(0x0f, 0xaf, 0xc1); \
29583 + } else { \
29584 + EMIT2(b1, b2); \
29585 + EMIT(_off, 4); \
29586 + } \
29587 +} while (0)
29588 +#else
29589 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29590 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29591 +#endif
29592
29593 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29594 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29595 @@ -90,6 +165,24 @@ do { \
29596 #define X86_JBE 0x76
29597 #define X86_JA 0x77
29598
29599 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29600 +#define APPEND_FLOW_VERIFY() \
29601 +do { \
29602 + /* mov ecx, randkey */ \
29603 + EMIT1(0xb9); \
29604 + EMIT(randkey, 4); \
29605 + /* cmp ecx, randkey */ \
29606 + EMIT2(0x81, 0xf9); \
29607 + EMIT(randkey, 4); \
29608 + /* jz after 8 int 3s */ \
29609 + EMIT2(0x74, 0x08); \
29610 + EMIT(0xcccccccc, 4); \
29611 + EMIT(0xcccccccc, 4); \
29612 +} while (0)
29613 +#else
29614 +#define APPEND_FLOW_VERIFY() do { } while (0)
29615 +#endif
29616 +
29617 #define EMIT_COND_JMP(op, offset) \
29618 do { \
29619 if (is_near(offset)) \
29620 @@ -97,6 +190,7 @@ do { \
29621 else { \
29622 EMIT2(0x0f, op + 0x10); \
29623 EMIT(offset, 4); /* jxx .+off32 */ \
29624 + APPEND_FLOW_VERIFY(); \
29625 } \
29626 } while (0)
29627
29628 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
29629 set_fs(old_fs);
29630 }
29631
29632 +struct bpf_jit_work {
29633 + struct work_struct work;
29634 + void *image;
29635 +};
29636 +
29637 #define CHOOSE_LOAD_FUNC(K, func) \
29638 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29639
29640 void bpf_jit_compile(struct sk_filter *fp)
29641 {
29642 - u8 temp[64];
29643 + u8 temp[MAX_INSTR_CODE_SIZE];
29644 u8 *prog;
29645 unsigned int proglen, oldproglen = 0;
29646 int ilen, i;
29647 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29648 unsigned int *addrs;
29649 const struct sock_filter *filter = fp->insns;
29650 int flen = fp->len;
29651 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29652 + unsigned int randkey;
29653 +#endif
29654
29655 if (!bpf_jit_enable)
29656 return;
29657 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29658 if (addrs == NULL)
29659 return;
29660
29661 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29662 + if (!fp->work)
29663 + goto out;
29664 +
29665 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29666 + randkey = get_random_int();
29667 +#endif
29668 +
29669 /* Before first pass, make a rough estimation of addrs[]
29670 - * each bpf instruction is translated to less than 64 bytes
29671 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29672 */
29673 for (proglen = 0, i = 0; i < flen; i++) {
29674 - proglen += 64;
29675 + proglen += MAX_INSTR_CODE_SIZE;
29676 addrs[i] = proglen;
29677 }
29678 cleanup_addr = proglen; /* epilogue address */
29679 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29680 case BPF_S_ALU_MUL_K: /* A *= K */
29681 if (is_imm8(K))
29682 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29683 - else {
29684 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29685 - EMIT(K, 4);
29686 - }
29687 + else
29688 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29689 break;
29690 case BPF_S_ALU_DIV_X: /* A /= X; */
29691 seen |= SEEN_XREG;
29692 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29693 break;
29694 case BPF_S_ALU_MOD_K: /* A %= K; */
29695 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29696 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29697 + DILUTE_CONST_SEQUENCE(K, randkey);
29698 +#else
29699 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29700 +#endif
29701 EMIT2(0xf7, 0xf1); /* div %ecx */
29702 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29703 break;
29704 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29705 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29706 + DILUTE_CONST_SEQUENCE(K, randkey);
29707 + // imul rax, rcx
29708 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29709 +#else
29710 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29711 EMIT(K, 4);
29712 +#endif
29713 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29714 break;
29715 case BPF_S_ALU_AND_X:
29716 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29717 if (is_imm8(K)) {
29718 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29719 } else {
29720 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29721 - EMIT(K, 4);
29722 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29723 }
29724 } else {
29725 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29726 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29727 break;
29728 default:
29729 /* hmm, too complex filter, give up with jit compiler */
29730 - goto out;
29731 + goto error;
29732 }
29733 ilen = prog - temp;
29734 if (image) {
29735 if (unlikely(proglen + ilen > oldproglen)) {
29736 pr_err("bpb_jit_compile fatal error\n");
29737 - kfree(addrs);
29738 - module_free(NULL, image);
29739 - return;
29740 + module_free_exec(NULL, image);
29741 + goto error;
29742 }
29743 + pax_open_kernel();
29744 memcpy(image + proglen, temp, ilen);
29745 + pax_close_kernel();
29746 }
29747 proglen += ilen;
29748 addrs[i] = proglen;
29749 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29750 break;
29751 }
29752 if (proglen == oldproglen) {
29753 - image = module_alloc(max_t(unsigned int,
29754 - proglen,
29755 - sizeof(struct work_struct)));
29756 + image = module_alloc_exec(proglen);
29757 if (!image)
29758 - goto out;
29759 + goto error;
29760 }
29761 oldproglen = proglen;
29762 }
29763 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29764 bpf_flush_icache(image, image + proglen);
29765
29766 fp->bpf_func = (void *)image;
29767 - }
29768 + } else
29769 +error:
29770 + kfree(fp->work);
29771 +
29772 out:
29773 kfree(addrs);
29774 return;
29775 @@ -707,18 +826,20 @@ out:
29776
29777 static void jit_free_defer(struct work_struct *arg)
29778 {
29779 - module_free(NULL, arg);
29780 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29781 + kfree(arg);
29782 }
29783
29784 /* run from softirq, we must use a work_struct to call
29785 - * module_free() from process context
29786 + * module_free_exec() from process context
29787 */
29788 void bpf_jit_free(struct sk_filter *fp)
29789 {
29790 if (fp->bpf_func != sk_run_filter) {
29791 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29792 + struct work_struct *work = &fp->work->work;
29793
29794 INIT_WORK(work, jit_free_defer);
29795 + fp->work->image = fp->bpf_func;
29796 schedule_work(work);
29797 }
29798 }
29799 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29800 index d6aa6e8..266395a 100644
29801 --- a/arch/x86/oprofile/backtrace.c
29802 +++ b/arch/x86/oprofile/backtrace.c
29803 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29804 struct stack_frame_ia32 *fp;
29805 unsigned long bytes;
29806
29807 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29808 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29809 if (bytes != sizeof(bufhead))
29810 return NULL;
29811
29812 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29813 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29814
29815 oprofile_add_trace(bufhead[0].return_address);
29816
29817 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29818 struct stack_frame bufhead[2];
29819 unsigned long bytes;
29820
29821 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29822 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29823 if (bytes != sizeof(bufhead))
29824 return NULL;
29825
29826 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29827 {
29828 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29829
29830 - if (!user_mode_vm(regs)) {
29831 + if (!user_mode(regs)) {
29832 unsigned long stack = kernel_stack_pointer(regs);
29833 if (depth)
29834 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29835 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29836 index 48768df..ba9143c 100644
29837 --- a/arch/x86/oprofile/nmi_int.c
29838 +++ b/arch/x86/oprofile/nmi_int.c
29839 @@ -23,6 +23,7 @@
29840 #include <asm/nmi.h>
29841 #include <asm/msr.h>
29842 #include <asm/apic.h>
29843 +#include <asm/pgtable.h>
29844
29845 #include "op_counter.h"
29846 #include "op_x86_model.h"
29847 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29848 if (ret)
29849 return ret;
29850
29851 - if (!model->num_virt_counters)
29852 - model->num_virt_counters = model->num_counters;
29853 + if (!model->num_virt_counters) {
29854 + pax_open_kernel();
29855 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29856 + pax_close_kernel();
29857 + }
29858
29859 mux_init(ops);
29860
29861 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29862 index b2b9443..be58856 100644
29863 --- a/arch/x86/oprofile/op_model_amd.c
29864 +++ b/arch/x86/oprofile/op_model_amd.c
29865 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29866 num_counters = AMD64_NUM_COUNTERS;
29867 }
29868
29869 - op_amd_spec.num_counters = num_counters;
29870 - op_amd_spec.num_controls = num_counters;
29871 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29872 + pax_open_kernel();
29873 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29874 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29875 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29876 + pax_close_kernel();
29877
29878 return 0;
29879 }
29880 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29881 index d90528e..0127e2b 100644
29882 --- a/arch/x86/oprofile/op_model_ppro.c
29883 +++ b/arch/x86/oprofile/op_model_ppro.c
29884 @@ -19,6 +19,7 @@
29885 #include <asm/msr.h>
29886 #include <asm/apic.h>
29887 #include <asm/nmi.h>
29888 +#include <asm/pgtable.h>
29889
29890 #include "op_x86_model.h"
29891 #include "op_counter.h"
29892 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29893
29894 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29895
29896 - op_arch_perfmon_spec.num_counters = num_counters;
29897 - op_arch_perfmon_spec.num_controls = num_counters;
29898 + pax_open_kernel();
29899 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
29900 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
29901 + pax_close_kernel();
29902 }
29903
29904 static int arch_perfmon_init(struct oprofile_operations *ignore)
29905 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
29906 index 71e8a67..6a313bb 100644
29907 --- a/arch/x86/oprofile/op_x86_model.h
29908 +++ b/arch/x86/oprofile/op_x86_model.h
29909 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
29910 void (*switch_ctrl)(struct op_x86_model_spec const *model,
29911 struct op_msrs const * const msrs);
29912 #endif
29913 -};
29914 +} __do_const;
29915
29916 struct op_counter_config;
29917
29918 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
29919 index e9e6ed5..e47ae67 100644
29920 --- a/arch/x86/pci/amd_bus.c
29921 +++ b/arch/x86/pci/amd_bus.c
29922 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
29923 return NOTIFY_OK;
29924 }
29925
29926 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
29927 +static struct notifier_block amd_cpu_notifier = {
29928 .notifier_call = amd_cpu_notify,
29929 };
29930
29931 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
29932 index 372e9b8..e775a6c 100644
29933 --- a/arch/x86/pci/irq.c
29934 +++ b/arch/x86/pci/irq.c
29935 @@ -50,7 +50,7 @@ struct irq_router {
29936 struct irq_router_handler {
29937 u16 vendor;
29938 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
29939 -};
29940 +} __do_const;
29941
29942 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
29943 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
29944 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
29945 return 0;
29946 }
29947
29948 -static __initdata struct irq_router_handler pirq_routers[] = {
29949 +static __initconst const struct irq_router_handler pirq_routers[] = {
29950 { PCI_VENDOR_ID_INTEL, intel_router_probe },
29951 { PCI_VENDOR_ID_AL, ali_router_probe },
29952 { PCI_VENDOR_ID_ITE, ite_router_probe },
29953 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
29954 static void __init pirq_find_router(struct irq_router *r)
29955 {
29956 struct irq_routing_table *rt = pirq_table;
29957 - struct irq_router_handler *h;
29958 + const struct irq_router_handler *h;
29959
29960 #ifdef CONFIG_PCI_BIOS
29961 if (!rt->signature) {
29962 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
29963 return 0;
29964 }
29965
29966 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
29967 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
29968 {
29969 .callback = fix_broken_hp_bios_irq9,
29970 .ident = "HP Pavilion N5400 Series Laptop",
29971 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
29972 index 6eb18c4..20d83de 100644
29973 --- a/arch/x86/pci/mrst.c
29974 +++ b/arch/x86/pci/mrst.c
29975 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
29976 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
29977 pci_mmcfg_late_init();
29978 pcibios_enable_irq = mrst_pci_irq_enable;
29979 - pci_root_ops = pci_mrst_ops;
29980 + pax_open_kernel();
29981 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
29982 + pax_close_kernel();
29983 pci_soc_mode = 1;
29984 /* Continue with standard init */
29985 return 1;
29986 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
29987 index c77b24a..c979855 100644
29988 --- a/arch/x86/pci/pcbios.c
29989 +++ b/arch/x86/pci/pcbios.c
29990 @@ -79,7 +79,7 @@ union bios32 {
29991 static struct {
29992 unsigned long address;
29993 unsigned short segment;
29994 -} bios32_indirect = { 0, __KERNEL_CS };
29995 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
29996
29997 /*
29998 * Returns the entry point for the given service, NULL on error
29999 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30000 unsigned long length; /* %ecx */
30001 unsigned long entry; /* %edx */
30002 unsigned long flags;
30003 + struct desc_struct d, *gdt;
30004
30005 local_irq_save(flags);
30006 - __asm__("lcall *(%%edi); cld"
30007 +
30008 + gdt = get_cpu_gdt_table(smp_processor_id());
30009 +
30010 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30011 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30012 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30013 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30014 +
30015 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30016 : "=a" (return_code),
30017 "=b" (address),
30018 "=c" (length),
30019 "=d" (entry)
30020 : "0" (service),
30021 "1" (0),
30022 - "D" (&bios32_indirect));
30023 + "D" (&bios32_indirect),
30024 + "r"(__PCIBIOS_DS)
30025 + : "memory");
30026 +
30027 + pax_open_kernel();
30028 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30029 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30030 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30031 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30032 + pax_close_kernel();
30033 +
30034 local_irq_restore(flags);
30035
30036 switch (return_code) {
30037 - case 0:
30038 - return address + entry;
30039 - case 0x80: /* Not present */
30040 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30041 - return 0;
30042 - default: /* Shouldn't happen */
30043 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30044 - service, return_code);
30045 + case 0: {
30046 + int cpu;
30047 + unsigned char flags;
30048 +
30049 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30050 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30051 + printk(KERN_WARNING "bios32_service: not valid\n");
30052 return 0;
30053 + }
30054 + address = address + PAGE_OFFSET;
30055 + length += 16UL; /* some BIOSs underreport this... */
30056 + flags = 4;
30057 + if (length >= 64*1024*1024) {
30058 + length >>= PAGE_SHIFT;
30059 + flags |= 8;
30060 + }
30061 +
30062 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30063 + gdt = get_cpu_gdt_table(cpu);
30064 + pack_descriptor(&d, address, length, 0x9b, flags);
30065 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30066 + pack_descriptor(&d, address, length, 0x93, flags);
30067 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30068 + }
30069 + return entry;
30070 + }
30071 + case 0x80: /* Not present */
30072 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30073 + return 0;
30074 + default: /* Shouldn't happen */
30075 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30076 + service, return_code);
30077 + return 0;
30078 }
30079 }
30080
30081 static struct {
30082 unsigned long address;
30083 unsigned short segment;
30084 -} pci_indirect = { 0, __KERNEL_CS };
30085 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30086
30087 -static int pci_bios_present;
30088 +static int pci_bios_present __read_only;
30089
30090 static int check_pcibios(void)
30091 {
30092 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30093 unsigned long flags, pcibios_entry;
30094
30095 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30096 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30097 + pci_indirect.address = pcibios_entry;
30098
30099 local_irq_save(flags);
30100 - __asm__(
30101 - "lcall *(%%edi); cld\n\t"
30102 + __asm__("movw %w6, %%ds\n\t"
30103 + "lcall *%%ss:(%%edi); cld\n\t"
30104 + "push %%ss\n\t"
30105 + "pop %%ds\n\t"
30106 "jc 1f\n\t"
30107 "xor %%ah, %%ah\n"
30108 "1:"
30109 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30110 "=b" (ebx),
30111 "=c" (ecx)
30112 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30113 - "D" (&pci_indirect)
30114 + "D" (&pci_indirect),
30115 + "r" (__PCIBIOS_DS)
30116 : "memory");
30117 local_irq_restore(flags);
30118
30119 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30120
30121 switch (len) {
30122 case 1:
30123 - __asm__("lcall *(%%esi); cld\n\t"
30124 + __asm__("movw %w6, %%ds\n\t"
30125 + "lcall *%%ss:(%%esi); cld\n\t"
30126 + "push %%ss\n\t"
30127 + "pop %%ds\n\t"
30128 "jc 1f\n\t"
30129 "xor %%ah, %%ah\n"
30130 "1:"
30131 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30132 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30133 "b" (bx),
30134 "D" ((long)reg),
30135 - "S" (&pci_indirect));
30136 + "S" (&pci_indirect),
30137 + "r" (__PCIBIOS_DS));
30138 /*
30139 * Zero-extend the result beyond 8 bits, do not trust the
30140 * BIOS having done it:
30141 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30142 *value &= 0xff;
30143 break;
30144 case 2:
30145 - __asm__("lcall *(%%esi); cld\n\t"
30146 + __asm__("movw %w6, %%ds\n\t"
30147 + "lcall *%%ss:(%%esi); cld\n\t"
30148 + "push %%ss\n\t"
30149 + "pop %%ds\n\t"
30150 "jc 1f\n\t"
30151 "xor %%ah, %%ah\n"
30152 "1:"
30153 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30154 : "1" (PCIBIOS_READ_CONFIG_WORD),
30155 "b" (bx),
30156 "D" ((long)reg),
30157 - "S" (&pci_indirect));
30158 + "S" (&pci_indirect),
30159 + "r" (__PCIBIOS_DS));
30160 /*
30161 * Zero-extend the result beyond 16 bits, do not trust the
30162 * BIOS having done it:
30163 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30164 *value &= 0xffff;
30165 break;
30166 case 4:
30167 - __asm__("lcall *(%%esi); cld\n\t"
30168 + __asm__("movw %w6, %%ds\n\t"
30169 + "lcall *%%ss:(%%esi); cld\n\t"
30170 + "push %%ss\n\t"
30171 + "pop %%ds\n\t"
30172 "jc 1f\n\t"
30173 "xor %%ah, %%ah\n"
30174 "1:"
30175 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30176 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30177 "b" (bx),
30178 "D" ((long)reg),
30179 - "S" (&pci_indirect));
30180 + "S" (&pci_indirect),
30181 + "r" (__PCIBIOS_DS));
30182 break;
30183 }
30184
30185 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30186
30187 switch (len) {
30188 case 1:
30189 - __asm__("lcall *(%%esi); cld\n\t"
30190 + __asm__("movw %w6, %%ds\n\t"
30191 + "lcall *%%ss:(%%esi); cld\n\t"
30192 + "push %%ss\n\t"
30193 + "pop %%ds\n\t"
30194 "jc 1f\n\t"
30195 "xor %%ah, %%ah\n"
30196 "1:"
30197 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30198 "c" (value),
30199 "b" (bx),
30200 "D" ((long)reg),
30201 - "S" (&pci_indirect));
30202 + "S" (&pci_indirect),
30203 + "r" (__PCIBIOS_DS));
30204 break;
30205 case 2:
30206 - __asm__("lcall *(%%esi); cld\n\t"
30207 + __asm__("movw %w6, %%ds\n\t"
30208 + "lcall *%%ss:(%%esi); cld\n\t"
30209 + "push %%ss\n\t"
30210 + "pop %%ds\n\t"
30211 "jc 1f\n\t"
30212 "xor %%ah, %%ah\n"
30213 "1:"
30214 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30215 "c" (value),
30216 "b" (bx),
30217 "D" ((long)reg),
30218 - "S" (&pci_indirect));
30219 + "S" (&pci_indirect),
30220 + "r" (__PCIBIOS_DS));
30221 break;
30222 case 4:
30223 - __asm__("lcall *(%%esi); cld\n\t"
30224 + __asm__("movw %w6, %%ds\n\t"
30225 + "lcall *%%ss:(%%esi); cld\n\t"
30226 + "push %%ss\n\t"
30227 + "pop %%ds\n\t"
30228 "jc 1f\n\t"
30229 "xor %%ah, %%ah\n"
30230 "1:"
30231 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30232 "c" (value),
30233 "b" (bx),
30234 "D" ((long)reg),
30235 - "S" (&pci_indirect));
30236 + "S" (&pci_indirect),
30237 + "r" (__PCIBIOS_DS));
30238 break;
30239 }
30240
30241 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30242
30243 DBG("PCI: Fetching IRQ routing table... ");
30244 __asm__("push %%es\n\t"
30245 + "movw %w8, %%ds\n\t"
30246 "push %%ds\n\t"
30247 "pop %%es\n\t"
30248 - "lcall *(%%esi); cld\n\t"
30249 + "lcall *%%ss:(%%esi); cld\n\t"
30250 "pop %%es\n\t"
30251 + "push %%ss\n\t"
30252 + "pop %%ds\n"
30253 "jc 1f\n\t"
30254 "xor %%ah, %%ah\n"
30255 "1:"
30256 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30257 "1" (0),
30258 "D" ((long) &opt),
30259 "S" (&pci_indirect),
30260 - "m" (opt)
30261 + "m" (opt),
30262 + "r" (__PCIBIOS_DS)
30263 : "memory");
30264 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30265 if (ret & 0xff00)
30266 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30267 {
30268 int ret;
30269
30270 - __asm__("lcall *(%%esi); cld\n\t"
30271 + __asm__("movw %w5, %%ds\n\t"
30272 + "lcall *%%ss:(%%esi); cld\n\t"
30273 + "push %%ss\n\t"
30274 + "pop %%ds\n"
30275 "jc 1f\n\t"
30276 "xor %%ah, %%ah\n"
30277 "1:"
30278 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30279 : "0" (PCIBIOS_SET_PCI_HW_INT),
30280 "b" ((dev->bus->number << 8) | dev->devfn),
30281 "c" ((irq << 8) | (pin + 10)),
30282 - "S" (&pci_indirect));
30283 + "S" (&pci_indirect),
30284 + "r" (__PCIBIOS_DS));
30285 return !(ret & 0xff00);
30286 }
30287 EXPORT_SYMBOL(pcibios_set_irq_routing);
30288 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30289 index 40e4469..1ab536e 100644
30290 --- a/arch/x86/platform/efi/efi_32.c
30291 +++ b/arch/x86/platform/efi/efi_32.c
30292 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30293 {
30294 struct desc_ptr gdt_descr;
30295
30296 +#ifdef CONFIG_PAX_KERNEXEC
30297 + struct desc_struct d;
30298 +#endif
30299 +
30300 local_irq_save(efi_rt_eflags);
30301
30302 load_cr3(initial_page_table);
30303 __flush_tlb_all();
30304
30305 +#ifdef CONFIG_PAX_KERNEXEC
30306 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30307 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30308 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30309 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30310 +#endif
30311 +
30312 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30313 gdt_descr.size = GDT_SIZE - 1;
30314 load_gdt(&gdt_descr);
30315 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30316 {
30317 struct desc_ptr gdt_descr;
30318
30319 +#ifdef CONFIG_PAX_KERNEXEC
30320 + struct desc_struct d;
30321 +
30322 + memset(&d, 0, sizeof d);
30323 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30324 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30325 +#endif
30326 +
30327 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30328 gdt_descr.size = GDT_SIZE - 1;
30329 load_gdt(&gdt_descr);
30330 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30331 index fbe66e6..eae5e38 100644
30332 --- a/arch/x86/platform/efi/efi_stub_32.S
30333 +++ b/arch/x86/platform/efi/efi_stub_32.S
30334 @@ -6,7 +6,9 @@
30335 */
30336
30337 #include <linux/linkage.h>
30338 +#include <linux/init.h>
30339 #include <asm/page_types.h>
30340 +#include <asm/segment.h>
30341
30342 /*
30343 * efi_call_phys(void *, ...) is a function with variable parameters.
30344 @@ -20,7 +22,7 @@
30345 * service functions will comply with gcc calling convention, too.
30346 */
30347
30348 -.text
30349 +__INIT
30350 ENTRY(efi_call_phys)
30351 /*
30352 * 0. The function can only be called in Linux kernel. So CS has been
30353 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30354 * The mapping of lower virtual memory has been created in prelog and
30355 * epilog.
30356 */
30357 - movl $1f, %edx
30358 - subl $__PAGE_OFFSET, %edx
30359 - jmp *%edx
30360 +#ifdef CONFIG_PAX_KERNEXEC
30361 + movl $(__KERNEXEC_EFI_DS), %edx
30362 + mov %edx, %ds
30363 + mov %edx, %es
30364 + mov %edx, %ss
30365 + addl $2f,(1f)
30366 + ljmp *(1f)
30367 +
30368 +__INITDATA
30369 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30370 +.previous
30371 +
30372 +2:
30373 + subl $2b,(1b)
30374 +#else
30375 + jmp 1f-__PAGE_OFFSET
30376 1:
30377 +#endif
30378
30379 /*
30380 * 2. Now on the top of stack is the return
30381 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30382 * parameter 2, ..., param n. To make things easy, we save the return
30383 * address of efi_call_phys in a global variable.
30384 */
30385 - popl %edx
30386 - movl %edx, saved_return_addr
30387 - /* get the function pointer into ECX*/
30388 - popl %ecx
30389 - movl %ecx, efi_rt_function_ptr
30390 - movl $2f, %edx
30391 - subl $__PAGE_OFFSET, %edx
30392 - pushl %edx
30393 + popl (saved_return_addr)
30394 + popl (efi_rt_function_ptr)
30395
30396 /*
30397 * 3. Clear PG bit in %CR0.
30398 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30399 /*
30400 * 5. Call the physical function.
30401 */
30402 - jmp *%ecx
30403 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30404
30405 -2:
30406 /*
30407 * 6. After EFI runtime service returns, control will return to
30408 * following instruction. We'd better readjust stack pointer first.
30409 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30410 movl %cr0, %edx
30411 orl $0x80000000, %edx
30412 movl %edx, %cr0
30413 - jmp 1f
30414 -1:
30415 +
30416 /*
30417 * 8. Now restore the virtual mode from flat mode by
30418 * adding EIP with PAGE_OFFSET.
30419 */
30420 - movl $1f, %edx
30421 - jmp *%edx
30422 +#ifdef CONFIG_PAX_KERNEXEC
30423 + movl $(__KERNEL_DS), %edx
30424 + mov %edx, %ds
30425 + mov %edx, %es
30426 + mov %edx, %ss
30427 + ljmp $(__KERNEL_CS),$1f
30428 +#else
30429 + jmp 1f+__PAGE_OFFSET
30430 +#endif
30431 1:
30432
30433 /*
30434 * 9. Balance the stack. And because EAX contain the return value,
30435 * we'd better not clobber it.
30436 */
30437 - leal efi_rt_function_ptr, %edx
30438 - movl (%edx), %ecx
30439 - pushl %ecx
30440 + pushl (efi_rt_function_ptr)
30441
30442 /*
30443 - * 10. Push the saved return address onto the stack and return.
30444 + * 10. Return to the saved return address.
30445 */
30446 - leal saved_return_addr, %edx
30447 - movl (%edx), %ecx
30448 - pushl %ecx
30449 - ret
30450 + jmpl *(saved_return_addr)
30451 ENDPROC(efi_call_phys)
30452 .previous
30453
30454 -.data
30455 +__INITDATA
30456 saved_return_addr:
30457 .long 0
30458 efi_rt_function_ptr:
30459 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30460 index 4c07cca..2c8427d 100644
30461 --- a/arch/x86/platform/efi/efi_stub_64.S
30462 +++ b/arch/x86/platform/efi/efi_stub_64.S
30463 @@ -7,6 +7,7 @@
30464 */
30465
30466 #include <linux/linkage.h>
30467 +#include <asm/alternative-asm.h>
30468
30469 #define SAVE_XMM \
30470 mov %rsp, %rax; \
30471 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30472 call *%rdi
30473 addq $32, %rsp
30474 RESTORE_XMM
30475 + pax_force_retaddr 0, 1
30476 ret
30477 ENDPROC(efi_call0)
30478
30479 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30480 call *%rdi
30481 addq $32, %rsp
30482 RESTORE_XMM
30483 + pax_force_retaddr 0, 1
30484 ret
30485 ENDPROC(efi_call1)
30486
30487 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30488 call *%rdi
30489 addq $32, %rsp
30490 RESTORE_XMM
30491 + pax_force_retaddr 0, 1
30492 ret
30493 ENDPROC(efi_call2)
30494
30495 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30496 call *%rdi
30497 addq $32, %rsp
30498 RESTORE_XMM
30499 + pax_force_retaddr 0, 1
30500 ret
30501 ENDPROC(efi_call3)
30502
30503 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30504 call *%rdi
30505 addq $32, %rsp
30506 RESTORE_XMM
30507 + pax_force_retaddr 0, 1
30508 ret
30509 ENDPROC(efi_call4)
30510
30511 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30512 call *%rdi
30513 addq $48, %rsp
30514 RESTORE_XMM
30515 + pax_force_retaddr 0, 1
30516 ret
30517 ENDPROC(efi_call5)
30518
30519 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30520 call *%rdi
30521 addq $48, %rsp
30522 RESTORE_XMM
30523 + pax_force_retaddr 0, 1
30524 ret
30525 ENDPROC(efi_call6)
30526 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30527 index e31bcd8..f12dc46 100644
30528 --- a/arch/x86/platform/mrst/mrst.c
30529 +++ b/arch/x86/platform/mrst/mrst.c
30530 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30531 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30532 int sfi_mrtc_num;
30533
30534 -static void mrst_power_off(void)
30535 +static __noreturn void mrst_power_off(void)
30536 {
30537 + BUG();
30538 }
30539
30540 -static void mrst_reboot(void)
30541 +static __noreturn void mrst_reboot(void)
30542 {
30543 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30544 + BUG();
30545 }
30546
30547 /* parse all the mtimer info to a static mtimer array */
30548 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30549 index d6ee929..3637cb5 100644
30550 --- a/arch/x86/platform/olpc/olpc_dt.c
30551 +++ b/arch/x86/platform/olpc/olpc_dt.c
30552 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30553 return res;
30554 }
30555
30556 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30557 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30558 .nextprop = olpc_dt_nextprop,
30559 .getproplen = olpc_dt_getproplen,
30560 .getproperty = olpc_dt_getproperty,
30561 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30562 index 3c68768..07e82b8 100644
30563 --- a/arch/x86/power/cpu.c
30564 +++ b/arch/x86/power/cpu.c
30565 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30566 static void fix_processor_context(void)
30567 {
30568 int cpu = smp_processor_id();
30569 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30570 + struct tss_struct *t = init_tss + cpu;
30571
30572 set_tss_desc(cpu, t); /*
30573 * This just modifies memory; should not be
30574 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30575 */
30576
30577 #ifdef CONFIG_X86_64
30578 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30579 -
30580 syscall_init(); /* This sets MSR_*STAR and related */
30581 #endif
30582 load_TR_desc(); /* This does ltr */
30583 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30584 index cbca565..bae7133 100644
30585 --- a/arch/x86/realmode/init.c
30586 +++ b/arch/x86/realmode/init.c
30587 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
30588 __va(real_mode_header->trampoline_header);
30589
30590 #ifdef CONFIG_X86_32
30591 - trampoline_header->start = __pa(startup_32_smp);
30592 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
30593 +
30594 +#ifdef CONFIG_PAX_KERNEXEC
30595 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30596 +#endif
30597 +
30598 + trampoline_header->boot_cs = __BOOT_CS;
30599 trampoline_header->gdt_limit = __BOOT_DS + 7;
30600 trampoline_header->gdt_base = __pa(boot_gdt);
30601 #else
30602 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30603 index 8869287..d577672 100644
30604 --- a/arch/x86/realmode/rm/Makefile
30605 +++ b/arch/x86/realmode/rm/Makefile
30606 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30607 $(call cc-option, -fno-unit-at-a-time)) \
30608 $(call cc-option, -fno-stack-protector) \
30609 $(call cc-option, -mpreferred-stack-boundary=2)
30610 +ifdef CONSTIFY_PLUGIN
30611 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30612 +endif
30613 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30614 GCOV_PROFILE := n
30615 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30616 index a28221d..93c40f1 100644
30617 --- a/arch/x86/realmode/rm/header.S
30618 +++ b/arch/x86/realmode/rm/header.S
30619 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30620 #endif
30621 /* APM/BIOS reboot */
30622 .long pa_machine_real_restart_asm
30623 -#ifdef CONFIG_X86_64
30624 +#ifdef CONFIG_X86_32
30625 + .long __KERNEL_CS
30626 +#else
30627 .long __KERNEL32_CS
30628 #endif
30629 END(real_mode_header)
30630 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30631 index c1b2791..f9e31c7 100644
30632 --- a/arch/x86/realmode/rm/trampoline_32.S
30633 +++ b/arch/x86/realmode/rm/trampoline_32.S
30634 @@ -25,6 +25,12 @@
30635 #include <asm/page_types.h>
30636 #include "realmode.h"
30637
30638 +#ifdef CONFIG_PAX_KERNEXEC
30639 +#define ta(X) (X)
30640 +#else
30641 +#define ta(X) (pa_ ## X)
30642 +#endif
30643 +
30644 .text
30645 .code16
30646
30647 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30648
30649 cli # We should be safe anyway
30650
30651 - movl tr_start, %eax # where we need to go
30652 -
30653 movl $0xA5A5A5A5, trampoline_status
30654 # write marker for master knows we're running
30655
30656 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30657 movw $1, %dx # protected mode (PE) bit
30658 lmsw %dx # into protected mode
30659
30660 - ljmpl $__BOOT_CS, $pa_startup_32
30661 + ljmpl *(trampoline_header)
30662
30663 .section ".text32","ax"
30664 .code32
30665 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30666 .balign 8
30667 GLOBAL(trampoline_header)
30668 tr_start: .space 4
30669 - tr_gdt_pad: .space 2
30670 + tr_boot_cs: .space 2
30671 tr_gdt: .space 6
30672 END(trampoline_header)
30673
30674 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30675 index bb360dc..3e5945f 100644
30676 --- a/arch/x86/realmode/rm/trampoline_64.S
30677 +++ b/arch/x86/realmode/rm/trampoline_64.S
30678 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30679 wrmsr
30680
30681 # Enable paging and in turn activate Long Mode
30682 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30683 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30684 movl %eax, %cr0
30685
30686 /*
30687 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30688 index 79d67bd..c7e1b90 100644
30689 --- a/arch/x86/tools/relocs.c
30690 +++ b/arch/x86/tools/relocs.c
30691 @@ -12,10 +12,13 @@
30692 #include <regex.h>
30693 #include <tools/le_byteshift.h>
30694
30695 +#include "../../../include/generated/autoconf.h"
30696 +
30697 static void die(char *fmt, ...);
30698
30699 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30700 static Elf32_Ehdr ehdr;
30701 +static Elf32_Phdr *phdr;
30702 static unsigned long reloc_count, reloc_idx;
30703 static unsigned long *relocs;
30704 static unsigned long reloc16_count, reloc16_idx;
30705 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30706 }
30707 }
30708
30709 +static void read_phdrs(FILE *fp)
30710 +{
30711 + unsigned int i;
30712 +
30713 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30714 + if (!phdr) {
30715 + die("Unable to allocate %d program headers\n",
30716 + ehdr.e_phnum);
30717 + }
30718 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30719 + die("Seek to %d failed: %s\n",
30720 + ehdr.e_phoff, strerror(errno));
30721 + }
30722 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30723 + die("Cannot read ELF program headers: %s\n",
30724 + strerror(errno));
30725 + }
30726 + for(i = 0; i < ehdr.e_phnum; i++) {
30727 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30728 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30729 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30730 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30731 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30732 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30733 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30734 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30735 + }
30736 +
30737 +}
30738 +
30739 static void read_shdrs(FILE *fp)
30740 {
30741 - int i;
30742 + unsigned int i;
30743 Elf32_Shdr shdr;
30744
30745 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30746 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
30747
30748 static void read_strtabs(FILE *fp)
30749 {
30750 - int i;
30751 + unsigned int i;
30752 for (i = 0; i < ehdr.e_shnum; i++) {
30753 struct section *sec = &secs[i];
30754 if (sec->shdr.sh_type != SHT_STRTAB) {
30755 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
30756
30757 static void read_symtabs(FILE *fp)
30758 {
30759 - int i,j;
30760 + unsigned int i,j;
30761 for (i = 0; i < ehdr.e_shnum; i++) {
30762 struct section *sec = &secs[i];
30763 if (sec->shdr.sh_type != SHT_SYMTAB) {
30764 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
30765 }
30766
30767
30768 -static void read_relocs(FILE *fp)
30769 +static void read_relocs(FILE *fp, int use_real_mode)
30770 {
30771 - int i,j;
30772 + unsigned int i,j;
30773 + uint32_t base;
30774 +
30775 for (i = 0; i < ehdr.e_shnum; i++) {
30776 struct section *sec = &secs[i];
30777 if (sec->shdr.sh_type != SHT_REL) {
30778 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
30779 die("Cannot read symbol table: %s\n",
30780 strerror(errno));
30781 }
30782 + base = 0;
30783 +
30784 +#ifdef CONFIG_X86_32
30785 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30786 + if (phdr[j].p_type != PT_LOAD )
30787 + continue;
30788 + 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)
30789 + continue;
30790 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30791 + break;
30792 + }
30793 +#endif
30794 +
30795 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
30796 Elf32_Rel *rel = &sec->reltab[j];
30797 - rel->r_offset = elf32_to_cpu(rel->r_offset);
30798 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
30799 rel->r_info = elf32_to_cpu(rel->r_info);
30800 }
30801 }
30802 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
30803
30804 static void print_absolute_symbols(void)
30805 {
30806 - int i;
30807 + unsigned int i;
30808 printf("Absolute symbols\n");
30809 printf(" Num: Value Size Type Bind Visibility Name\n");
30810 for (i = 0; i < ehdr.e_shnum; i++) {
30811 struct section *sec = &secs[i];
30812 char *sym_strtab;
30813 - int j;
30814 + unsigned int j;
30815
30816 if (sec->shdr.sh_type != SHT_SYMTAB) {
30817 continue;
30818 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
30819
30820 static void print_absolute_relocs(void)
30821 {
30822 - int i, printed = 0;
30823 + unsigned int i, printed = 0;
30824
30825 for (i = 0; i < ehdr.e_shnum; i++) {
30826 struct section *sec = &secs[i];
30827 struct section *sec_applies, *sec_symtab;
30828 char *sym_strtab;
30829 Elf32_Sym *sh_symtab;
30830 - int j;
30831 + unsigned int j;
30832 if (sec->shdr.sh_type != SHT_REL) {
30833 continue;
30834 }
30835 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
30836 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30837 int use_real_mode)
30838 {
30839 - int i;
30840 + unsigned int i;
30841 /* Walk through the relocations */
30842 for (i = 0; i < ehdr.e_shnum; i++) {
30843 char *sym_strtab;
30844 Elf32_Sym *sh_symtab;
30845 struct section *sec_applies, *sec_symtab;
30846 - int j;
30847 + unsigned int j;
30848 struct section *sec = &secs[i];
30849
30850 if (sec->shdr.sh_type != SHT_REL) {
30851 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30852 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
30853 r_type = ELF32_R_TYPE(rel->r_info);
30854
30855 + if (!use_real_mode) {
30856 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
30857 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
30858 + continue;
30859 +
30860 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
30861 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
30862 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
30863 + continue;
30864 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
30865 + continue;
30866 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
30867 + continue;
30868 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
30869 + continue;
30870 +#endif
30871 + }
30872 +
30873 shn_abs = sym->st_shndx == SHN_ABS;
30874
30875 switch (r_type) {
30876 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
30877
30878 static void emit_relocs(int as_text, int use_real_mode)
30879 {
30880 - int i;
30881 + unsigned int i;
30882 /* Count how many relocations I have and allocate space for them. */
30883 reloc_count = 0;
30884 walk_relocs(count_reloc, use_real_mode);
30885 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
30886 fname, strerror(errno));
30887 }
30888 read_ehdr(fp);
30889 + read_phdrs(fp);
30890 read_shdrs(fp);
30891 read_strtabs(fp);
30892 read_symtabs(fp);
30893 - read_relocs(fp);
30894 + read_relocs(fp, use_real_mode);
30895 if (show_absolute_syms) {
30896 print_absolute_symbols();
30897 goto out;
30898 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
30899 index fd14be1..e3c79c0 100644
30900 --- a/arch/x86/vdso/Makefile
30901 +++ b/arch/x86/vdso/Makefile
30902 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
30903 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
30904 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
30905
30906 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30907 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30908 GCOV_PROFILE := n
30909
30910 #
30911 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
30912 index 0faad64..39ef157 100644
30913 --- a/arch/x86/vdso/vdso32-setup.c
30914 +++ b/arch/x86/vdso/vdso32-setup.c
30915 @@ -25,6 +25,7 @@
30916 #include <asm/tlbflush.h>
30917 #include <asm/vdso.h>
30918 #include <asm/proto.h>
30919 +#include <asm/mman.h>
30920
30921 enum {
30922 VDSO_DISABLED = 0,
30923 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
30924 void enable_sep_cpu(void)
30925 {
30926 int cpu = get_cpu();
30927 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
30928 + struct tss_struct *tss = init_tss + cpu;
30929
30930 if (!boot_cpu_has(X86_FEATURE_SEP)) {
30931 put_cpu();
30932 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
30933 gate_vma.vm_start = FIXADDR_USER_START;
30934 gate_vma.vm_end = FIXADDR_USER_END;
30935 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
30936 - gate_vma.vm_page_prot = __P101;
30937 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
30938
30939 return 0;
30940 }
30941 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
30942 if (compat)
30943 addr = VDSO_HIGH_BASE;
30944 else {
30945 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
30946 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
30947 if (IS_ERR_VALUE(addr)) {
30948 ret = addr;
30949 goto up_fail;
30950 }
30951 }
30952
30953 - current->mm->context.vdso = (void *)addr;
30954 + current->mm->context.vdso = addr;
30955
30956 if (compat_uses_vma || !compat) {
30957 /*
30958 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
30959 }
30960
30961 current_thread_info()->sysenter_return =
30962 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
30963 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
30964
30965 up_fail:
30966 if (ret)
30967 - current->mm->context.vdso = NULL;
30968 + current->mm->context.vdso = 0;
30969
30970 up_write(&mm->mmap_sem);
30971
30972 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
30973
30974 const char *arch_vma_name(struct vm_area_struct *vma)
30975 {
30976 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
30977 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
30978 return "[vdso]";
30979 +
30980 +#ifdef CONFIG_PAX_SEGMEXEC
30981 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
30982 + return "[vdso]";
30983 +#endif
30984 +
30985 return NULL;
30986 }
30987
30988 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
30989 * Check to see if the corresponding task was created in compat vdso
30990 * mode.
30991 */
30992 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
30993 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
30994 return &gate_vma;
30995 return NULL;
30996 }
30997 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
30998 index 431e875..cbb23f3 100644
30999 --- a/arch/x86/vdso/vma.c
31000 +++ b/arch/x86/vdso/vma.c
31001 @@ -16,8 +16,6 @@
31002 #include <asm/vdso.h>
31003 #include <asm/page.h>
31004
31005 -unsigned int __read_mostly vdso_enabled = 1;
31006 -
31007 extern char vdso_start[], vdso_end[];
31008 extern unsigned short vdso_sync_cpuid;
31009
31010 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31011 * unaligned here as a result of stack start randomization.
31012 */
31013 addr = PAGE_ALIGN(addr);
31014 - addr = align_vdso_addr(addr);
31015
31016 return addr;
31017 }
31018 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31019 unsigned size)
31020 {
31021 struct mm_struct *mm = current->mm;
31022 - unsigned long addr;
31023 + unsigned long addr = 0;
31024 int ret;
31025
31026 - if (!vdso_enabled)
31027 - return 0;
31028 -
31029 down_write(&mm->mmap_sem);
31030 +
31031 +#ifdef CONFIG_PAX_RANDMMAP
31032 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31033 +#endif
31034 +
31035 addr = vdso_addr(mm->start_stack, size);
31036 + addr = align_vdso_addr(addr);
31037 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31038 if (IS_ERR_VALUE(addr)) {
31039 ret = addr;
31040 goto up_fail;
31041 }
31042
31043 - current->mm->context.vdso = (void *)addr;
31044 + mm->context.vdso = addr;
31045
31046 ret = install_special_mapping(mm, addr, size,
31047 VM_READ|VM_EXEC|
31048 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31049 pages);
31050 - if (ret) {
31051 - current->mm->context.vdso = NULL;
31052 - goto up_fail;
31053 - }
31054 + if (ret)
31055 + mm->context.vdso = 0;
31056
31057 up_fail:
31058 up_write(&mm->mmap_sem);
31059 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31060 vdsox32_size);
31061 }
31062 #endif
31063 -
31064 -static __init int vdso_setup(char *s)
31065 -{
31066 - vdso_enabled = simple_strtoul(s, NULL, 0);
31067 - return 0;
31068 -}
31069 -__setup("vdso=", vdso_setup);
31070 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31071 index 2262003..f229ced 100644
31072 --- a/arch/x86/xen/enlighten.c
31073 +++ b/arch/x86/xen/enlighten.c
31074 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31075
31076 struct shared_info xen_dummy_shared_info;
31077
31078 -void *xen_initial_gdt;
31079 -
31080 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31081 __read_mostly int xen_have_vector_callback;
31082 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31083 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31084 {
31085 unsigned long va = dtr->address;
31086 unsigned int size = dtr->size + 1;
31087 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31088 - unsigned long frames[pages];
31089 + unsigned long frames[65536 / PAGE_SIZE];
31090 int f;
31091
31092 /*
31093 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31094 {
31095 unsigned long va = dtr->address;
31096 unsigned int size = dtr->size + 1;
31097 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31098 - unsigned long frames[pages];
31099 + unsigned long frames[65536 / PAGE_SIZE];
31100 int f;
31101
31102 /*
31103 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31104 return 0;
31105 }
31106
31107 -static void set_xen_basic_apic_ops(void)
31108 +static void __init set_xen_basic_apic_ops(void)
31109 {
31110 apic->read = xen_apic_read;
31111 apic->write = xen_apic_write;
31112 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31113 #endif
31114 };
31115
31116 -static void xen_reboot(int reason)
31117 +static __noreturn void xen_reboot(int reason)
31118 {
31119 struct sched_shutdown r = { .reason = reason };
31120
31121 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31122 - BUG();
31123 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31124 + BUG();
31125 }
31126
31127 -static void xen_restart(char *msg)
31128 +static __noreturn void xen_restart(char *msg)
31129 {
31130 xen_reboot(SHUTDOWN_reboot);
31131 }
31132
31133 -static void xen_emergency_restart(void)
31134 +static __noreturn void xen_emergency_restart(void)
31135 {
31136 xen_reboot(SHUTDOWN_reboot);
31137 }
31138
31139 -static void xen_machine_halt(void)
31140 +static __noreturn void xen_machine_halt(void)
31141 {
31142 xen_reboot(SHUTDOWN_poweroff);
31143 }
31144
31145 -static void xen_machine_power_off(void)
31146 +static __noreturn void xen_machine_power_off(void)
31147 {
31148 if (pm_power_off)
31149 pm_power_off();
31150 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
31151 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31152
31153 /* Work out if we support NX */
31154 - x86_configure_nx();
31155 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31156 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31157 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31158 + unsigned l, h;
31159 +
31160 + __supported_pte_mask |= _PAGE_NX;
31161 + rdmsr(MSR_EFER, l, h);
31162 + l |= EFER_NX;
31163 + wrmsr(MSR_EFER, l, h);
31164 + }
31165 +#endif
31166
31167 xen_setup_features();
31168
31169 @@ -1399,14 +1405,7 @@ asmlinkage void __init xen_start_kernel(void)
31170 pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit;
31171 }
31172
31173 - machine_ops = xen_machine_ops;
31174 -
31175 - /*
31176 - * The only reliable way to retain the initial address of the
31177 - * percpu gdt_page is to remember it here, so we can go and
31178 - * mark it RW later, when the initial percpu area is freed.
31179 - */
31180 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31181 + memcpy((void *)&machine_ops, &xen_machine_ops, sizeof machine_ops);
31182
31183 xen_smp_init();
31184
31185 @@ -1598,7 +1597,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31186 return NOTIFY_OK;
31187 }
31188
31189 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31190 +static struct notifier_block xen_hvm_cpu_notifier = {
31191 .notifier_call = xen_hvm_cpu_notify,
31192 };
31193
31194 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31195 index 01de35c..0bda07b 100644
31196 --- a/arch/x86/xen/mmu.c
31197 +++ b/arch/x86/xen/mmu.c
31198 @@ -1881,6 +1881,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31199 /* L3_k[510] -> level2_kernel_pgt
31200 * L3_i[511] -> level2_fixmap_pgt */
31201 convert_pfn_mfn(level3_kernel_pgt);
31202 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31203 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31204 + convert_pfn_mfn(level3_vmemmap_pgt);
31205
31206 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31207 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31208 @@ -1910,8 +1913,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31209 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31210 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31211 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31212 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31213 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31214 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31215 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31216 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31217 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31218 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31219 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31220
31221 @@ -2097,6 +2104,7 @@ static void __init xen_post_allocator_init(void)
31222 pv_mmu_ops.set_pud = xen_set_pud;
31223 #if PAGETABLE_LEVELS == 4
31224 pv_mmu_ops.set_pgd = xen_set_pgd;
31225 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31226 #endif
31227
31228 /* This will work as long as patching hasn't happened yet
31229 @@ -2178,6 +2186,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31230 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31231 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31232 .set_pgd = xen_set_pgd_hyper,
31233 + .set_pgd_batched = xen_set_pgd_hyper,
31234
31235 .alloc_pud = xen_alloc_pmd_init,
31236 .release_pud = xen_release_pmd_init,
31237 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31238 index 34bc4ce..c34aa24 100644
31239 --- a/arch/x86/xen/smp.c
31240 +++ b/arch/x86/xen/smp.c
31241 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31242 {
31243 BUG_ON(smp_processor_id() != 0);
31244 native_smp_prepare_boot_cpu();
31245 -
31246 - /* We've switched to the "real" per-cpu gdt, so make sure the
31247 - old memory can be recycled */
31248 - make_lowmem_page_readwrite(xen_initial_gdt);
31249 -
31250 xen_filter_cpu_maps();
31251 xen_setup_vcpu_info_placement();
31252 }
31253 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31254 gdt = get_cpu_gdt_table(cpu);
31255
31256 ctxt->flags = VGCF_IN_KERNEL;
31257 - ctxt->user_regs.ds = __USER_DS;
31258 - ctxt->user_regs.es = __USER_DS;
31259 + ctxt->user_regs.ds = __KERNEL_DS;
31260 + ctxt->user_regs.es = __KERNEL_DS;
31261 ctxt->user_regs.ss = __KERNEL_DS;
31262 #ifdef CONFIG_X86_32
31263 ctxt->user_regs.fs = __KERNEL_PERCPU;
31264 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31265 + savesegment(gs, ctxt->user_regs.gs);
31266 #else
31267 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31268 #endif
31269 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31270 int rc;
31271
31272 per_cpu(current_task, cpu) = idle;
31273 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31274 #ifdef CONFIG_X86_32
31275 irq_ctx_init(cpu);
31276 #else
31277 clear_tsk_thread_flag(idle, TIF_FORK);
31278 - per_cpu(kernel_stack, cpu) =
31279 - (unsigned long)task_stack_page(idle) -
31280 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31281 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31282 #endif
31283 xen_setup_runstate_info(cpu);
31284 xen_setup_timer(cpu);
31285 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31286
31287 void __init xen_smp_init(void)
31288 {
31289 - smp_ops = xen_smp_ops;
31290 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31291 xen_fill_possible_map();
31292 xen_init_spinlocks();
31293 }
31294 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31295 index 33ca6e4..0ded929 100644
31296 --- a/arch/x86/xen/xen-asm_32.S
31297 +++ b/arch/x86/xen/xen-asm_32.S
31298 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31299 ESP_OFFSET=4 # bytes pushed onto stack
31300
31301 /*
31302 - * Store vcpu_info pointer for easy access. Do it this way to
31303 - * avoid having to reload %fs
31304 + * Store vcpu_info pointer for easy access.
31305 */
31306 #ifdef CONFIG_SMP
31307 - GET_THREAD_INFO(%eax)
31308 - movl %ss:TI_cpu(%eax), %eax
31309 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31310 - mov %ss:xen_vcpu(%eax), %eax
31311 + push %fs
31312 + mov $(__KERNEL_PERCPU), %eax
31313 + mov %eax, %fs
31314 + mov PER_CPU_VAR(xen_vcpu), %eax
31315 + pop %fs
31316 #else
31317 movl %ss:xen_vcpu, %eax
31318 #endif
31319 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31320 index 7faed58..ba4427c 100644
31321 --- a/arch/x86/xen/xen-head.S
31322 +++ b/arch/x86/xen/xen-head.S
31323 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31324 #ifdef CONFIG_X86_32
31325 mov %esi,xen_start_info
31326 mov $init_thread_union+THREAD_SIZE,%esp
31327 +#ifdef CONFIG_SMP
31328 + movl $cpu_gdt_table,%edi
31329 + movl $__per_cpu_load,%eax
31330 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31331 + rorl $16,%eax
31332 + movb %al,__KERNEL_PERCPU + 4(%edi)
31333 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31334 + movl $__per_cpu_end - 1,%eax
31335 + subl $__per_cpu_start,%eax
31336 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31337 +#endif
31338 #else
31339 mov %rsi,xen_start_info
31340 mov $init_thread_union+THREAD_SIZE,%rsp
31341 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31342 index a95b417..b6dbd0b 100644
31343 --- a/arch/x86/xen/xen-ops.h
31344 +++ b/arch/x86/xen/xen-ops.h
31345 @@ -10,8 +10,6 @@
31346 extern const char xen_hypervisor_callback[];
31347 extern const char xen_failsafe_callback[];
31348
31349 -extern void *xen_initial_gdt;
31350 -
31351 struct trap_info;
31352 void xen_copy_trap_info(struct trap_info *traps);
31353
31354 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31355 index 525bd3d..ef888b1 100644
31356 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31357 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31358 @@ -119,9 +119,9 @@
31359 ----------------------------------------------------------------------*/
31360
31361 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31362 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31363 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31364 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31365 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31366
31367 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31368 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31369 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31370 index 2f33760..835e50a 100644
31371 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31372 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31373 @@ -11,6 +11,7 @@
31374 #ifndef _XTENSA_CORE_H
31375 #define _XTENSA_CORE_H
31376
31377 +#include <linux/const.h>
31378
31379 /****************************************************************************
31380 Parameters Useful for Any Code, USER or PRIVILEGED
31381 @@ -112,9 +113,9 @@
31382 ----------------------------------------------------------------------*/
31383
31384 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31385 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31386 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31387 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31388 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31389
31390 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31391 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31392 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31393 index af00795..2bb8105 100644
31394 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31395 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31396 @@ -11,6 +11,7 @@
31397 #ifndef _XTENSA_CORE_CONFIGURATION_H
31398 #define _XTENSA_CORE_CONFIGURATION_H
31399
31400 +#include <linux/const.h>
31401
31402 /****************************************************************************
31403 Parameters Useful for Any Code, USER or PRIVILEGED
31404 @@ -118,9 +119,9 @@
31405 ----------------------------------------------------------------------*/
31406
31407 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31408 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31409 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31410 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31411 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31412
31413 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31414 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31415 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31416 index 58916af..eb9dbcf6 100644
31417 --- a/block/blk-iopoll.c
31418 +++ b/block/blk-iopoll.c
31419 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31420 }
31421 EXPORT_SYMBOL(blk_iopoll_complete);
31422
31423 -static void blk_iopoll_softirq(struct softirq_action *h)
31424 +static void blk_iopoll_softirq(void)
31425 {
31426 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31427 int rearm = 0, budget = blk_iopoll_budget;
31428 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31429 return NOTIFY_OK;
31430 }
31431
31432 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31433 +static struct notifier_block blk_iopoll_cpu_notifier = {
31434 .notifier_call = blk_iopoll_cpu_notify,
31435 };
31436
31437 diff --git a/block/blk-map.c b/block/blk-map.c
31438 index 623e1cd..ca1e109 100644
31439 --- a/block/blk-map.c
31440 +++ b/block/blk-map.c
31441 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31442 if (!len || !kbuf)
31443 return -EINVAL;
31444
31445 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31446 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31447 if (do_copy)
31448 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31449 else
31450 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31451 index 467c8de..f3628c5 100644
31452 --- a/block/blk-softirq.c
31453 +++ b/block/blk-softirq.c
31454 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31455 * Softirq action handler - move entries to local list and loop over them
31456 * while passing them to the queue registered handler.
31457 */
31458 -static void blk_done_softirq(struct softirq_action *h)
31459 +static void blk_done_softirq(void)
31460 {
31461 struct list_head *cpu_list, local_list;
31462
31463 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31464 return NOTIFY_OK;
31465 }
31466
31467 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31468 +static struct notifier_block blk_cpu_notifier = {
31469 .notifier_call = blk_cpu_notify,
31470 };
31471
31472 diff --git a/block/bsg.c b/block/bsg.c
31473 index ff64ae3..593560c 100644
31474 --- a/block/bsg.c
31475 +++ b/block/bsg.c
31476 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31477 struct sg_io_v4 *hdr, struct bsg_device *bd,
31478 fmode_t has_write_perm)
31479 {
31480 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31481 + unsigned char *cmdptr;
31482 +
31483 if (hdr->request_len > BLK_MAX_CDB) {
31484 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31485 if (!rq->cmd)
31486 return -ENOMEM;
31487 - }
31488 + cmdptr = rq->cmd;
31489 + } else
31490 + cmdptr = tmpcmd;
31491
31492 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31493 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31494 hdr->request_len))
31495 return -EFAULT;
31496
31497 + if (cmdptr != rq->cmd)
31498 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31499 +
31500 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31501 if (blk_verify_command(rq->cmd, has_write_perm))
31502 return -EPERM;
31503 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31504 index 7c668c8..db3521c 100644
31505 --- a/block/compat_ioctl.c
31506 +++ b/block/compat_ioctl.c
31507 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31508 err |= __get_user(f->spec1, &uf->spec1);
31509 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31510 err |= __get_user(name, &uf->name);
31511 - f->name = compat_ptr(name);
31512 + f->name = (void __force_kernel *)compat_ptr(name);
31513 if (err) {
31514 err = -EFAULT;
31515 goto out;
31516 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31517 index b62fb88..bdab4c4 100644
31518 --- a/block/partitions/efi.c
31519 +++ b/block/partitions/efi.c
31520 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31521 if (!gpt)
31522 return NULL;
31523
31524 + if (!le32_to_cpu(gpt->num_partition_entries))
31525 + return NULL;
31526 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31527 + if (!pte)
31528 + return NULL;
31529 +
31530 count = le32_to_cpu(gpt->num_partition_entries) *
31531 le32_to_cpu(gpt->sizeof_partition_entry);
31532 - if (!count)
31533 - return NULL;
31534 - pte = kzalloc(count, GFP_KERNEL);
31535 - if (!pte)
31536 - return NULL;
31537 -
31538 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31539 (u8 *) pte,
31540 count) < count) {
31541 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31542 index 9a87daa..fb17486 100644
31543 --- a/block/scsi_ioctl.c
31544 +++ b/block/scsi_ioctl.c
31545 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31546 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31547 struct sg_io_hdr *hdr, fmode_t mode)
31548 {
31549 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31550 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31551 + unsigned char *cmdptr;
31552 +
31553 + if (rq->cmd != rq->__cmd)
31554 + cmdptr = rq->cmd;
31555 + else
31556 + cmdptr = tmpcmd;
31557 +
31558 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31559 return -EFAULT;
31560 +
31561 + if (cmdptr != rq->cmd)
31562 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31563 +
31564 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31565 return -EPERM;
31566
31567 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31568 int err;
31569 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31570 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31571 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31572 + unsigned char *cmdptr;
31573
31574 if (!sic)
31575 return -EINVAL;
31576 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31577 */
31578 err = -EFAULT;
31579 rq->cmd_len = cmdlen;
31580 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31581 +
31582 + if (rq->cmd != rq->__cmd)
31583 + cmdptr = rq->cmd;
31584 + else
31585 + cmdptr = tmpcmd;
31586 +
31587 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31588 goto error;
31589
31590 + if (rq->cmd != cmdptr)
31591 + memcpy(rq->cmd, cmdptr, cmdlen);
31592 +
31593 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31594 goto error;
31595
31596 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31597 index 7bdd61b..afec999 100644
31598 --- a/crypto/cryptd.c
31599 +++ b/crypto/cryptd.c
31600 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31601
31602 struct cryptd_blkcipher_request_ctx {
31603 crypto_completion_t complete;
31604 -};
31605 +} __no_const;
31606
31607 struct cryptd_hash_ctx {
31608 struct crypto_shash *child;
31609 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31610
31611 struct cryptd_aead_request_ctx {
31612 crypto_completion_t complete;
31613 -};
31614 +} __no_const;
31615
31616 static void cryptd_queue_worker(struct work_struct *work);
31617
31618 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
31619 index f6d9baf..dfd511f 100644
31620 --- a/crypto/crypto_user.c
31621 +++ b/crypto/crypto_user.c
31622 @@ -30,6 +30,8 @@
31623
31624 #include "internal.h"
31625
31626 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
31627 +
31628 static DEFINE_MUTEX(crypto_cfg_mutex);
31629
31630 /* The crypto netlink socket */
31631 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
31632 struct crypto_dump_info info;
31633 int err;
31634
31635 - if (!p->cru_driver_name)
31636 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31637 + return -EINVAL;
31638 +
31639 + if (!p->cru_driver_name[0])
31640 return -EINVAL;
31641
31642 alg = crypto_alg_match(p, 1);
31643 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31644 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
31645 LIST_HEAD(list);
31646
31647 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31648 + return -EINVAL;
31649 +
31650 if (priority && !strlen(p->cru_driver_name))
31651 return -EINVAL;
31652
31653 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31654 struct crypto_alg *alg;
31655 struct crypto_user_alg *p = nlmsg_data(nlh);
31656
31657 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31658 + return -EINVAL;
31659 +
31660 alg = crypto_alg_match(p, 1);
31661 if (!alg)
31662 return -ENOENT;
31663 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
31664 struct crypto_user_alg *p = nlmsg_data(nlh);
31665 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
31666
31667 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
31668 + return -EINVAL;
31669 +
31670 if (strlen(p->cru_driver_name))
31671 exact = 1;
31672
31673 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31674 index f220d64..d359ad6 100644
31675 --- a/drivers/acpi/apei/apei-internal.h
31676 +++ b/drivers/acpi/apei/apei-internal.h
31677 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31678 struct apei_exec_ins_type {
31679 u32 flags;
31680 apei_exec_ins_func_t run;
31681 -};
31682 +} __do_const;
31683
31684 struct apei_exec_context {
31685 u32 ip;
31686 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31687 index e6defd8..c26a225 100644
31688 --- a/drivers/acpi/apei/cper.c
31689 +++ b/drivers/acpi/apei/cper.c
31690 @@ -38,12 +38,12 @@
31691 */
31692 u64 cper_next_record_id(void)
31693 {
31694 - static atomic64_t seq;
31695 + static atomic64_unchecked_t seq;
31696
31697 - if (!atomic64_read(&seq))
31698 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31699 + if (!atomic64_read_unchecked(&seq))
31700 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31701
31702 - return atomic64_inc_return(&seq);
31703 + return atomic64_inc_return_unchecked(&seq);
31704 }
31705 EXPORT_SYMBOL_GPL(cper_next_record_id);
31706
31707 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31708 index be60399..778b33e8 100644
31709 --- a/drivers/acpi/bgrt.c
31710 +++ b/drivers/acpi/bgrt.c
31711 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31712 return -ENODEV;
31713
31714 sysfs_bin_attr_init(&image_attr);
31715 - image_attr.private = bgrt_image;
31716 - image_attr.size = bgrt_image_size;
31717 + pax_open_kernel();
31718 + *(void **)&image_attr.private = bgrt_image;
31719 + *(size_t *)&image_attr.size = bgrt_image_size;
31720 + pax_close_kernel();
31721
31722 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31723 if (!bgrt_kobj)
31724 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31725 index cb96296..b81293b 100644
31726 --- a/drivers/acpi/blacklist.c
31727 +++ b/drivers/acpi/blacklist.c
31728 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31729 u32 is_critical_error;
31730 };
31731
31732 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31733 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31734
31735 /*
31736 * POLICY: If *anything* doesn't work, put it on the blacklist.
31737 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31738 return 0;
31739 }
31740
31741 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31742 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31743 {
31744 .callback = dmi_disable_osi_vista,
31745 .ident = "Fujitsu Siemens",
31746 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31747 index 7586544..636a2f0 100644
31748 --- a/drivers/acpi/ec_sys.c
31749 +++ b/drivers/acpi/ec_sys.c
31750 @@ -12,6 +12,7 @@
31751 #include <linux/acpi.h>
31752 #include <linux/debugfs.h>
31753 #include <linux/module.h>
31754 +#include <linux/uaccess.h>
31755 #include "internal.h"
31756
31757 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31758 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31759 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31760 */
31761 unsigned int size = EC_SPACE_SIZE;
31762 - u8 *data = (u8 *) buf;
31763 + u8 data;
31764 loff_t init_off = *off;
31765 int err = 0;
31766
31767 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31768 size = count;
31769
31770 while (size) {
31771 - err = ec_read(*off, &data[*off - init_off]);
31772 + err = ec_read(*off, &data);
31773 if (err)
31774 return err;
31775 + if (put_user(data, &buf[*off - init_off]))
31776 + return -EFAULT;
31777 *off += 1;
31778 size--;
31779 }
31780 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31781
31782 unsigned int size = count;
31783 loff_t init_off = *off;
31784 - u8 *data = (u8 *) buf;
31785 int err = 0;
31786
31787 if (*off >= EC_SPACE_SIZE)
31788 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31789 }
31790
31791 while (size) {
31792 - u8 byte_write = data[*off - init_off];
31793 + u8 byte_write;
31794 + if (get_user(byte_write, &buf[*off - init_off]))
31795 + return -EFAULT;
31796 err = ec_write(*off, byte_write);
31797 if (err)
31798 return err;
31799 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
31800 index e83311b..142b5cc 100644
31801 --- a/drivers/acpi/processor_driver.c
31802 +++ b/drivers/acpi/processor_driver.c
31803 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
31804 return 0;
31805 #endif
31806
31807 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
31808 + BUG_ON(pr->id >= nr_cpu_ids);
31809
31810 /*
31811 * Buggy BIOS check
31812 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31813 index ed9a1cc..f4a354c 100644
31814 --- a/drivers/acpi/processor_idle.c
31815 +++ b/drivers/acpi/processor_idle.c
31816 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
31817 {
31818 int i, count = CPUIDLE_DRIVER_STATE_START;
31819 struct acpi_processor_cx *cx;
31820 - struct cpuidle_state *state;
31821 + cpuidle_state_no_const *state;
31822 struct cpuidle_driver *drv = &acpi_idle_driver;
31823
31824 if (!pr->flags.power_setup_done)
31825 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
31826 index ea61ca9..3fdd70d 100644
31827 --- a/drivers/acpi/sysfs.c
31828 +++ b/drivers/acpi/sysfs.c
31829 @@ -420,11 +420,11 @@ static u32 num_counters;
31830 static struct attribute **all_attrs;
31831 static u32 acpi_gpe_count;
31832
31833 -static struct attribute_group interrupt_stats_attr_group = {
31834 +static attribute_group_no_const interrupt_stats_attr_group = {
31835 .name = "interrupts",
31836 };
31837
31838 -static struct kobj_attribute *counter_attrs;
31839 +static kobj_attribute_no_const *counter_attrs;
31840
31841 static void delete_gpe_attr_array(void)
31842 {
31843 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
31844 index 6cd7805..07facb3 100644
31845 --- a/drivers/ata/libahci.c
31846 +++ b/drivers/ata/libahci.c
31847 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
31848 }
31849 EXPORT_SYMBOL_GPL(ahci_kick_engine);
31850
31851 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31852 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31853 struct ata_taskfile *tf, int is_cmd, u16 flags,
31854 unsigned long timeout_msec)
31855 {
31856 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
31857 index 46cd3f4..0871ad0 100644
31858 --- a/drivers/ata/libata-core.c
31859 +++ b/drivers/ata/libata-core.c
31860 @@ -4780,7 +4780,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
31861 struct ata_port *ap;
31862 unsigned int tag;
31863
31864 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31865 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31866 ap = qc->ap;
31867
31868 qc->flags = 0;
31869 @@ -4796,7 +4796,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
31870 struct ata_port *ap;
31871 struct ata_link *link;
31872
31873 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31874 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31875 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
31876 ap = qc->ap;
31877 link = qc->dev->link;
31878 @@ -5892,6 +5892,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31879 return;
31880
31881 spin_lock(&lock);
31882 + pax_open_kernel();
31883
31884 for (cur = ops->inherits; cur; cur = cur->inherits) {
31885 void **inherit = (void **)cur;
31886 @@ -5905,8 +5906,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31887 if (IS_ERR(*pp))
31888 *pp = NULL;
31889
31890 - ops->inherits = NULL;
31891 + *(struct ata_port_operations **)&ops->inherits = NULL;
31892
31893 + pax_close_kernel();
31894 spin_unlock(&lock);
31895 }
31896
31897 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
31898 index 405022d..fb70e53 100644
31899 --- a/drivers/ata/pata_arasan_cf.c
31900 +++ b/drivers/ata/pata_arasan_cf.c
31901 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
31902 /* Handle platform specific quirks */
31903 if (pdata->quirk) {
31904 if (pdata->quirk & CF_BROKEN_PIO) {
31905 - ap->ops->set_piomode = NULL;
31906 + pax_open_kernel();
31907 + *(void **)&ap->ops->set_piomode = NULL;
31908 + pax_close_kernel();
31909 ap->pio_mask = 0;
31910 }
31911 if (pdata->quirk & CF_BROKEN_MWDMA)
31912 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
31913 index f9b983a..887b9d8 100644
31914 --- a/drivers/atm/adummy.c
31915 +++ b/drivers/atm/adummy.c
31916 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
31917 vcc->pop(vcc, skb);
31918 else
31919 dev_kfree_skb_any(skb);
31920 - atomic_inc(&vcc->stats->tx);
31921 + atomic_inc_unchecked(&vcc->stats->tx);
31922
31923 return 0;
31924 }
31925 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
31926 index 77a7480..05cde58 100644
31927 --- a/drivers/atm/ambassador.c
31928 +++ b/drivers/atm/ambassador.c
31929 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
31930 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
31931
31932 // VC layer stats
31933 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
31934 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
31935
31936 // free the descriptor
31937 kfree (tx_descr);
31938 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31939 dump_skb ("<<<", vc, skb);
31940
31941 // VC layer stats
31942 - atomic_inc(&atm_vcc->stats->rx);
31943 + atomic_inc_unchecked(&atm_vcc->stats->rx);
31944 __net_timestamp(skb);
31945 // end of our responsibility
31946 atm_vcc->push (atm_vcc, skb);
31947 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31948 } else {
31949 PRINTK (KERN_INFO, "dropped over-size frame");
31950 // should we count this?
31951 - atomic_inc(&atm_vcc->stats->rx_drop);
31952 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
31953 }
31954
31955 } else {
31956 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
31957 }
31958
31959 if (check_area (skb->data, skb->len)) {
31960 - atomic_inc(&atm_vcc->stats->tx_err);
31961 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
31962 return -ENOMEM; // ?
31963 }
31964
31965 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
31966 index b22d71c..d6e1049 100644
31967 --- a/drivers/atm/atmtcp.c
31968 +++ b/drivers/atm/atmtcp.c
31969 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31970 if (vcc->pop) vcc->pop(vcc,skb);
31971 else dev_kfree_skb(skb);
31972 if (dev_data) return 0;
31973 - atomic_inc(&vcc->stats->tx_err);
31974 + atomic_inc_unchecked(&vcc->stats->tx_err);
31975 return -ENOLINK;
31976 }
31977 size = skb->len+sizeof(struct atmtcp_hdr);
31978 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31979 if (!new_skb) {
31980 if (vcc->pop) vcc->pop(vcc,skb);
31981 else dev_kfree_skb(skb);
31982 - atomic_inc(&vcc->stats->tx_err);
31983 + atomic_inc_unchecked(&vcc->stats->tx_err);
31984 return -ENOBUFS;
31985 }
31986 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
31987 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31988 if (vcc->pop) vcc->pop(vcc,skb);
31989 else dev_kfree_skb(skb);
31990 out_vcc->push(out_vcc,new_skb);
31991 - atomic_inc(&vcc->stats->tx);
31992 - atomic_inc(&out_vcc->stats->rx);
31993 + atomic_inc_unchecked(&vcc->stats->tx);
31994 + atomic_inc_unchecked(&out_vcc->stats->rx);
31995 return 0;
31996 }
31997
31998 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
31999 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32000 read_unlock(&vcc_sklist_lock);
32001 if (!out_vcc) {
32002 - atomic_inc(&vcc->stats->tx_err);
32003 + atomic_inc_unchecked(&vcc->stats->tx_err);
32004 goto done;
32005 }
32006 skb_pull(skb,sizeof(struct atmtcp_hdr));
32007 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32008 __net_timestamp(new_skb);
32009 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32010 out_vcc->push(out_vcc,new_skb);
32011 - atomic_inc(&vcc->stats->tx);
32012 - atomic_inc(&out_vcc->stats->rx);
32013 + atomic_inc_unchecked(&vcc->stats->tx);
32014 + atomic_inc_unchecked(&out_vcc->stats->rx);
32015 done:
32016 if (vcc->pop) vcc->pop(vcc,skb);
32017 else dev_kfree_skb(skb);
32018 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32019 index c1eb6fa..4c71be9 100644
32020 --- a/drivers/atm/eni.c
32021 +++ b/drivers/atm/eni.c
32022 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32023 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32024 vcc->dev->number);
32025 length = 0;
32026 - atomic_inc(&vcc->stats->rx_err);
32027 + atomic_inc_unchecked(&vcc->stats->rx_err);
32028 }
32029 else {
32030 length = ATM_CELL_SIZE-1; /* no HEC */
32031 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32032 size);
32033 }
32034 eff = length = 0;
32035 - atomic_inc(&vcc->stats->rx_err);
32036 + atomic_inc_unchecked(&vcc->stats->rx_err);
32037 }
32038 else {
32039 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32040 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32041 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32042 vcc->dev->number,vcc->vci,length,size << 2,descr);
32043 length = eff = 0;
32044 - atomic_inc(&vcc->stats->rx_err);
32045 + atomic_inc_unchecked(&vcc->stats->rx_err);
32046 }
32047 }
32048 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32049 @@ -767,7 +767,7 @@ rx_dequeued++;
32050 vcc->push(vcc,skb);
32051 pushed++;
32052 }
32053 - atomic_inc(&vcc->stats->rx);
32054 + atomic_inc_unchecked(&vcc->stats->rx);
32055 }
32056 wake_up(&eni_dev->rx_wait);
32057 }
32058 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32059 PCI_DMA_TODEVICE);
32060 if (vcc->pop) vcc->pop(vcc,skb);
32061 else dev_kfree_skb_irq(skb);
32062 - atomic_inc(&vcc->stats->tx);
32063 + atomic_inc_unchecked(&vcc->stats->tx);
32064 wake_up(&eni_dev->tx_wait);
32065 dma_complete++;
32066 }
32067 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32068 index b41c948..a002b17 100644
32069 --- a/drivers/atm/firestream.c
32070 +++ b/drivers/atm/firestream.c
32071 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32072 }
32073 }
32074
32075 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32076 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32077
32078 fs_dprintk (FS_DEBUG_TXMEM, "i");
32079 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32080 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32081 #endif
32082 skb_put (skb, qe->p1 & 0xffff);
32083 ATM_SKB(skb)->vcc = atm_vcc;
32084 - atomic_inc(&atm_vcc->stats->rx);
32085 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32086 __net_timestamp(skb);
32087 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32088 atm_vcc->push (atm_vcc, skb);
32089 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32090 kfree (pe);
32091 }
32092 if (atm_vcc)
32093 - atomic_inc(&atm_vcc->stats->rx_drop);
32094 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32095 break;
32096 case 0x1f: /* Reassembly abort: no buffers. */
32097 /* Silently increment error counter. */
32098 if (atm_vcc)
32099 - atomic_inc(&atm_vcc->stats->rx_drop);
32100 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32101 break;
32102 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32103 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32104 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32105 index 204814e..cede831 100644
32106 --- a/drivers/atm/fore200e.c
32107 +++ b/drivers/atm/fore200e.c
32108 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32109 #endif
32110 /* check error condition */
32111 if (*entry->status & STATUS_ERROR)
32112 - atomic_inc(&vcc->stats->tx_err);
32113 + atomic_inc_unchecked(&vcc->stats->tx_err);
32114 else
32115 - atomic_inc(&vcc->stats->tx);
32116 + atomic_inc_unchecked(&vcc->stats->tx);
32117 }
32118 }
32119
32120 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32121 if (skb == NULL) {
32122 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32123
32124 - atomic_inc(&vcc->stats->rx_drop);
32125 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32126 return -ENOMEM;
32127 }
32128
32129 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32130
32131 dev_kfree_skb_any(skb);
32132
32133 - atomic_inc(&vcc->stats->rx_drop);
32134 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32135 return -ENOMEM;
32136 }
32137
32138 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32139
32140 vcc->push(vcc, skb);
32141 - atomic_inc(&vcc->stats->rx);
32142 + atomic_inc_unchecked(&vcc->stats->rx);
32143
32144 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32145
32146 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32147 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32148 fore200e->atm_dev->number,
32149 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32150 - atomic_inc(&vcc->stats->rx_err);
32151 + atomic_inc_unchecked(&vcc->stats->rx_err);
32152 }
32153 }
32154
32155 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32156 goto retry_here;
32157 }
32158
32159 - atomic_inc(&vcc->stats->tx_err);
32160 + atomic_inc_unchecked(&vcc->stats->tx_err);
32161
32162 fore200e->tx_sat++;
32163 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32164 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32165 index 72b6960..cf9167a 100644
32166 --- a/drivers/atm/he.c
32167 +++ b/drivers/atm/he.c
32168 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32169
32170 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32171 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32172 - atomic_inc(&vcc->stats->rx_drop);
32173 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32174 goto return_host_buffers;
32175 }
32176
32177 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32178 RBRQ_LEN_ERR(he_dev->rbrq_head)
32179 ? "LEN_ERR" : "",
32180 vcc->vpi, vcc->vci);
32181 - atomic_inc(&vcc->stats->rx_err);
32182 + atomic_inc_unchecked(&vcc->stats->rx_err);
32183 goto return_host_buffers;
32184 }
32185
32186 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32187 vcc->push(vcc, skb);
32188 spin_lock(&he_dev->global_lock);
32189
32190 - atomic_inc(&vcc->stats->rx);
32191 + atomic_inc_unchecked(&vcc->stats->rx);
32192
32193 return_host_buffers:
32194 ++pdus_assembled;
32195 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32196 tpd->vcc->pop(tpd->vcc, tpd->skb);
32197 else
32198 dev_kfree_skb_any(tpd->skb);
32199 - atomic_inc(&tpd->vcc->stats->tx_err);
32200 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32201 }
32202 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32203 return;
32204 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32205 vcc->pop(vcc, skb);
32206 else
32207 dev_kfree_skb_any(skb);
32208 - atomic_inc(&vcc->stats->tx_err);
32209 + atomic_inc_unchecked(&vcc->stats->tx_err);
32210 return -EINVAL;
32211 }
32212
32213 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32214 vcc->pop(vcc, skb);
32215 else
32216 dev_kfree_skb_any(skb);
32217 - atomic_inc(&vcc->stats->tx_err);
32218 + atomic_inc_unchecked(&vcc->stats->tx_err);
32219 return -EINVAL;
32220 }
32221 #endif
32222 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32223 vcc->pop(vcc, skb);
32224 else
32225 dev_kfree_skb_any(skb);
32226 - atomic_inc(&vcc->stats->tx_err);
32227 + atomic_inc_unchecked(&vcc->stats->tx_err);
32228 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32229 return -ENOMEM;
32230 }
32231 @@ -2581,7 +2581,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32232 vcc->pop(vcc, skb);
32233 else
32234 dev_kfree_skb_any(skb);
32235 - atomic_inc(&vcc->stats->tx_err);
32236 + atomic_inc_unchecked(&vcc->stats->tx_err);
32237 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32238 return -ENOMEM;
32239 }
32240 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32241 __enqueue_tpd(he_dev, tpd, cid);
32242 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32243
32244 - atomic_inc(&vcc->stats->tx);
32245 + atomic_inc_unchecked(&vcc->stats->tx);
32246
32247 return 0;
32248 }
32249 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32250 index 1dc0519..1aadaf7 100644
32251 --- a/drivers/atm/horizon.c
32252 +++ b/drivers/atm/horizon.c
32253 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32254 {
32255 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32256 // VC layer stats
32257 - atomic_inc(&vcc->stats->rx);
32258 + atomic_inc_unchecked(&vcc->stats->rx);
32259 __net_timestamp(skb);
32260 // end of our responsibility
32261 vcc->push (vcc, skb);
32262 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32263 dev->tx_iovec = NULL;
32264
32265 // VC layer stats
32266 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32267 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32268
32269 // free the skb
32270 hrz_kfree_skb (skb);
32271 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32272 index 272f009..a18ba55 100644
32273 --- a/drivers/atm/idt77252.c
32274 +++ b/drivers/atm/idt77252.c
32275 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32276 else
32277 dev_kfree_skb(skb);
32278
32279 - atomic_inc(&vcc->stats->tx);
32280 + atomic_inc_unchecked(&vcc->stats->tx);
32281 }
32282
32283 atomic_dec(&scq->used);
32284 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32285 if ((sb = dev_alloc_skb(64)) == NULL) {
32286 printk("%s: Can't allocate buffers for aal0.\n",
32287 card->name);
32288 - atomic_add(i, &vcc->stats->rx_drop);
32289 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32290 break;
32291 }
32292 if (!atm_charge(vcc, sb->truesize)) {
32293 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32294 card->name);
32295 - atomic_add(i - 1, &vcc->stats->rx_drop);
32296 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32297 dev_kfree_skb(sb);
32298 break;
32299 }
32300 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32301 ATM_SKB(sb)->vcc = vcc;
32302 __net_timestamp(sb);
32303 vcc->push(vcc, sb);
32304 - atomic_inc(&vcc->stats->rx);
32305 + atomic_inc_unchecked(&vcc->stats->rx);
32306
32307 cell += ATM_CELL_PAYLOAD;
32308 }
32309 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32310 "(CDC: %08x)\n",
32311 card->name, len, rpp->len, readl(SAR_REG_CDC));
32312 recycle_rx_pool_skb(card, rpp);
32313 - atomic_inc(&vcc->stats->rx_err);
32314 + atomic_inc_unchecked(&vcc->stats->rx_err);
32315 return;
32316 }
32317 if (stat & SAR_RSQE_CRC) {
32318 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32319 recycle_rx_pool_skb(card, rpp);
32320 - atomic_inc(&vcc->stats->rx_err);
32321 + atomic_inc_unchecked(&vcc->stats->rx_err);
32322 return;
32323 }
32324 if (skb_queue_len(&rpp->queue) > 1) {
32325 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32326 RXPRINTK("%s: Can't alloc RX skb.\n",
32327 card->name);
32328 recycle_rx_pool_skb(card, rpp);
32329 - atomic_inc(&vcc->stats->rx_err);
32330 + atomic_inc_unchecked(&vcc->stats->rx_err);
32331 return;
32332 }
32333 if (!atm_charge(vcc, skb->truesize)) {
32334 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32335 __net_timestamp(skb);
32336
32337 vcc->push(vcc, skb);
32338 - atomic_inc(&vcc->stats->rx);
32339 + atomic_inc_unchecked(&vcc->stats->rx);
32340
32341 return;
32342 }
32343 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32344 __net_timestamp(skb);
32345
32346 vcc->push(vcc, skb);
32347 - atomic_inc(&vcc->stats->rx);
32348 + atomic_inc_unchecked(&vcc->stats->rx);
32349
32350 if (skb->truesize > SAR_FB_SIZE_3)
32351 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32352 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32353 if (vcc->qos.aal != ATM_AAL0) {
32354 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32355 card->name, vpi, vci);
32356 - atomic_inc(&vcc->stats->rx_drop);
32357 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32358 goto drop;
32359 }
32360
32361 if ((sb = dev_alloc_skb(64)) == NULL) {
32362 printk("%s: Can't allocate buffers for AAL0.\n",
32363 card->name);
32364 - atomic_inc(&vcc->stats->rx_err);
32365 + atomic_inc_unchecked(&vcc->stats->rx_err);
32366 goto drop;
32367 }
32368
32369 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32370 ATM_SKB(sb)->vcc = vcc;
32371 __net_timestamp(sb);
32372 vcc->push(vcc, sb);
32373 - atomic_inc(&vcc->stats->rx);
32374 + atomic_inc_unchecked(&vcc->stats->rx);
32375
32376 drop:
32377 skb_pull(queue, 64);
32378 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32379
32380 if (vc == NULL) {
32381 printk("%s: NULL connection in send().\n", card->name);
32382 - atomic_inc(&vcc->stats->tx_err);
32383 + atomic_inc_unchecked(&vcc->stats->tx_err);
32384 dev_kfree_skb(skb);
32385 return -EINVAL;
32386 }
32387 if (!test_bit(VCF_TX, &vc->flags)) {
32388 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32389 - atomic_inc(&vcc->stats->tx_err);
32390 + atomic_inc_unchecked(&vcc->stats->tx_err);
32391 dev_kfree_skb(skb);
32392 return -EINVAL;
32393 }
32394 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32395 break;
32396 default:
32397 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32398 - atomic_inc(&vcc->stats->tx_err);
32399 + atomic_inc_unchecked(&vcc->stats->tx_err);
32400 dev_kfree_skb(skb);
32401 return -EINVAL;
32402 }
32403
32404 if (skb_shinfo(skb)->nr_frags != 0) {
32405 printk("%s: No scatter-gather yet.\n", card->name);
32406 - atomic_inc(&vcc->stats->tx_err);
32407 + atomic_inc_unchecked(&vcc->stats->tx_err);
32408 dev_kfree_skb(skb);
32409 return -EINVAL;
32410 }
32411 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32412
32413 err = queue_skb(card, vc, skb, oam);
32414 if (err) {
32415 - atomic_inc(&vcc->stats->tx_err);
32416 + atomic_inc_unchecked(&vcc->stats->tx_err);
32417 dev_kfree_skb(skb);
32418 return err;
32419 }
32420 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32421 skb = dev_alloc_skb(64);
32422 if (!skb) {
32423 printk("%s: Out of memory in send_oam().\n", card->name);
32424 - atomic_inc(&vcc->stats->tx_err);
32425 + atomic_inc_unchecked(&vcc->stats->tx_err);
32426 return -ENOMEM;
32427 }
32428 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32429 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32430 index 4217f29..88f547a 100644
32431 --- a/drivers/atm/iphase.c
32432 +++ b/drivers/atm/iphase.c
32433 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32434 status = (u_short) (buf_desc_ptr->desc_mode);
32435 if (status & (RX_CER | RX_PTE | RX_OFL))
32436 {
32437 - atomic_inc(&vcc->stats->rx_err);
32438 + atomic_inc_unchecked(&vcc->stats->rx_err);
32439 IF_ERR(printk("IA: bad packet, dropping it");)
32440 if (status & RX_CER) {
32441 IF_ERR(printk(" cause: packet CRC error\n");)
32442 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32443 len = dma_addr - buf_addr;
32444 if (len > iadev->rx_buf_sz) {
32445 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32446 - atomic_inc(&vcc->stats->rx_err);
32447 + atomic_inc_unchecked(&vcc->stats->rx_err);
32448 goto out_free_desc;
32449 }
32450
32451 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32452 ia_vcc = INPH_IA_VCC(vcc);
32453 if (ia_vcc == NULL)
32454 {
32455 - atomic_inc(&vcc->stats->rx_err);
32456 + atomic_inc_unchecked(&vcc->stats->rx_err);
32457 atm_return(vcc, skb->truesize);
32458 dev_kfree_skb_any(skb);
32459 goto INCR_DLE;
32460 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32461 if ((length > iadev->rx_buf_sz) || (length >
32462 (skb->len - sizeof(struct cpcs_trailer))))
32463 {
32464 - atomic_inc(&vcc->stats->rx_err);
32465 + atomic_inc_unchecked(&vcc->stats->rx_err);
32466 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32467 length, skb->len);)
32468 atm_return(vcc, skb->truesize);
32469 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32470
32471 IF_RX(printk("rx_dle_intr: skb push");)
32472 vcc->push(vcc,skb);
32473 - atomic_inc(&vcc->stats->rx);
32474 + atomic_inc_unchecked(&vcc->stats->rx);
32475 iadev->rx_pkt_cnt++;
32476 }
32477 INCR_DLE:
32478 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32479 {
32480 struct k_sonet_stats *stats;
32481 stats = &PRIV(_ia_dev[board])->sonet_stats;
32482 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32483 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32484 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32485 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32486 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32487 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32488 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32489 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32490 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32491 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32492 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32493 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32494 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32495 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32496 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32497 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32498 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32499 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32500 }
32501 ia_cmds.status = 0;
32502 break;
32503 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32504 if ((desc == 0) || (desc > iadev->num_tx_desc))
32505 {
32506 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32507 - atomic_inc(&vcc->stats->tx);
32508 + atomic_inc_unchecked(&vcc->stats->tx);
32509 if (vcc->pop)
32510 vcc->pop(vcc, skb);
32511 else
32512 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32513 ATM_DESC(skb) = vcc->vci;
32514 skb_queue_tail(&iadev->tx_dma_q, skb);
32515
32516 - atomic_inc(&vcc->stats->tx);
32517 + atomic_inc_unchecked(&vcc->stats->tx);
32518 iadev->tx_pkt_cnt++;
32519 /* Increment transaction counter */
32520 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32521
32522 #if 0
32523 /* add flow control logic */
32524 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32525 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32526 if (iavcc->vc_desc_cnt > 10) {
32527 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32528 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32529 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32530 index fa7d701..1e404c7 100644
32531 --- a/drivers/atm/lanai.c
32532 +++ b/drivers/atm/lanai.c
32533 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32534 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32535 lanai_endtx(lanai, lvcc);
32536 lanai_free_skb(lvcc->tx.atmvcc, skb);
32537 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32538 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32539 }
32540
32541 /* Try to fill the buffer - don't call unless there is backlog */
32542 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32543 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32544 __net_timestamp(skb);
32545 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32546 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32547 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32548 out:
32549 lvcc->rx.buf.ptr = end;
32550 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32551 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32552 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32553 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32554 lanai->stats.service_rxnotaal5++;
32555 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32556 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32557 return 0;
32558 }
32559 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32560 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32561 int bytes;
32562 read_unlock(&vcc_sklist_lock);
32563 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32564 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32565 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32566 lvcc->stats.x.aal5.service_trash++;
32567 bytes = (SERVICE_GET_END(s) * 16) -
32568 (((unsigned long) lvcc->rx.buf.ptr) -
32569 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32570 }
32571 if (s & SERVICE_STREAM) {
32572 read_unlock(&vcc_sklist_lock);
32573 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32574 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32575 lvcc->stats.x.aal5.service_stream++;
32576 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32577 "PDU on VCI %d!\n", lanai->number, vci);
32578 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32579 return 0;
32580 }
32581 DPRINTK("got rx crc error on vci %d\n", vci);
32582 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32583 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32584 lvcc->stats.x.aal5.service_rxcrc++;
32585 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32586 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32587 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32588 index ed1d2b7..8cffc1f 100644
32589 --- a/drivers/atm/nicstar.c
32590 +++ b/drivers/atm/nicstar.c
32591 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32592 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32593 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32594 card->index);
32595 - atomic_inc(&vcc->stats->tx_err);
32596 + atomic_inc_unchecked(&vcc->stats->tx_err);
32597 dev_kfree_skb_any(skb);
32598 return -EINVAL;
32599 }
32600 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32601 if (!vc->tx) {
32602 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32603 card->index);
32604 - atomic_inc(&vcc->stats->tx_err);
32605 + atomic_inc_unchecked(&vcc->stats->tx_err);
32606 dev_kfree_skb_any(skb);
32607 return -EINVAL;
32608 }
32609 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32610 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32611 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32612 card->index);
32613 - atomic_inc(&vcc->stats->tx_err);
32614 + atomic_inc_unchecked(&vcc->stats->tx_err);
32615 dev_kfree_skb_any(skb);
32616 return -EINVAL;
32617 }
32618
32619 if (skb_shinfo(skb)->nr_frags != 0) {
32620 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32621 - atomic_inc(&vcc->stats->tx_err);
32622 + atomic_inc_unchecked(&vcc->stats->tx_err);
32623 dev_kfree_skb_any(skb);
32624 return -EINVAL;
32625 }
32626 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32627 }
32628
32629 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32630 - atomic_inc(&vcc->stats->tx_err);
32631 + atomic_inc_unchecked(&vcc->stats->tx_err);
32632 dev_kfree_skb_any(skb);
32633 return -EIO;
32634 }
32635 - atomic_inc(&vcc->stats->tx);
32636 + atomic_inc_unchecked(&vcc->stats->tx);
32637
32638 return 0;
32639 }
32640 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32641 printk
32642 ("nicstar%d: Can't allocate buffers for aal0.\n",
32643 card->index);
32644 - atomic_add(i, &vcc->stats->rx_drop);
32645 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32646 break;
32647 }
32648 if (!atm_charge(vcc, sb->truesize)) {
32649 RXPRINTK
32650 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32651 card->index);
32652 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32653 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32654 dev_kfree_skb_any(sb);
32655 break;
32656 }
32657 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32658 ATM_SKB(sb)->vcc = vcc;
32659 __net_timestamp(sb);
32660 vcc->push(vcc, sb);
32661 - atomic_inc(&vcc->stats->rx);
32662 + atomic_inc_unchecked(&vcc->stats->rx);
32663 cell += ATM_CELL_PAYLOAD;
32664 }
32665
32666 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32667 if (iovb == NULL) {
32668 printk("nicstar%d: Out of iovec buffers.\n",
32669 card->index);
32670 - atomic_inc(&vcc->stats->rx_drop);
32671 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32672 recycle_rx_buf(card, skb);
32673 return;
32674 }
32675 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32676 small or large buffer itself. */
32677 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32678 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32679 - atomic_inc(&vcc->stats->rx_err);
32680 + atomic_inc_unchecked(&vcc->stats->rx_err);
32681 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32682 NS_MAX_IOVECS);
32683 NS_PRV_IOVCNT(iovb) = 0;
32684 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32685 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32686 card->index);
32687 which_list(card, skb);
32688 - atomic_inc(&vcc->stats->rx_err);
32689 + atomic_inc_unchecked(&vcc->stats->rx_err);
32690 recycle_rx_buf(card, skb);
32691 vc->rx_iov = NULL;
32692 recycle_iov_buf(card, iovb);
32693 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32694 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32695 card->index);
32696 which_list(card, skb);
32697 - atomic_inc(&vcc->stats->rx_err);
32698 + atomic_inc_unchecked(&vcc->stats->rx_err);
32699 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32700 NS_PRV_IOVCNT(iovb));
32701 vc->rx_iov = NULL;
32702 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32703 printk(" - PDU size mismatch.\n");
32704 else
32705 printk(".\n");
32706 - atomic_inc(&vcc->stats->rx_err);
32707 + atomic_inc_unchecked(&vcc->stats->rx_err);
32708 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32709 NS_PRV_IOVCNT(iovb));
32710 vc->rx_iov = NULL;
32711 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32712 /* skb points to a small buffer */
32713 if (!atm_charge(vcc, skb->truesize)) {
32714 push_rxbufs(card, skb);
32715 - atomic_inc(&vcc->stats->rx_drop);
32716 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32717 } else {
32718 skb_put(skb, len);
32719 dequeue_sm_buf(card, skb);
32720 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32721 ATM_SKB(skb)->vcc = vcc;
32722 __net_timestamp(skb);
32723 vcc->push(vcc, skb);
32724 - atomic_inc(&vcc->stats->rx);
32725 + atomic_inc_unchecked(&vcc->stats->rx);
32726 }
32727 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32728 struct sk_buff *sb;
32729 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32730 if (len <= NS_SMBUFSIZE) {
32731 if (!atm_charge(vcc, sb->truesize)) {
32732 push_rxbufs(card, sb);
32733 - atomic_inc(&vcc->stats->rx_drop);
32734 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32735 } else {
32736 skb_put(sb, len);
32737 dequeue_sm_buf(card, sb);
32738 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32739 ATM_SKB(sb)->vcc = vcc;
32740 __net_timestamp(sb);
32741 vcc->push(vcc, sb);
32742 - atomic_inc(&vcc->stats->rx);
32743 + atomic_inc_unchecked(&vcc->stats->rx);
32744 }
32745
32746 push_rxbufs(card, skb);
32747 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32748
32749 if (!atm_charge(vcc, skb->truesize)) {
32750 push_rxbufs(card, skb);
32751 - atomic_inc(&vcc->stats->rx_drop);
32752 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32753 } else {
32754 dequeue_lg_buf(card, skb);
32755 #ifdef NS_USE_DESTRUCTORS
32756 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32757 ATM_SKB(skb)->vcc = vcc;
32758 __net_timestamp(skb);
32759 vcc->push(vcc, skb);
32760 - atomic_inc(&vcc->stats->rx);
32761 + atomic_inc_unchecked(&vcc->stats->rx);
32762 }
32763
32764 push_rxbufs(card, sb);
32765 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32766 printk
32767 ("nicstar%d: Out of huge buffers.\n",
32768 card->index);
32769 - atomic_inc(&vcc->stats->rx_drop);
32770 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32771 recycle_iovec_rx_bufs(card,
32772 (struct iovec *)
32773 iovb->data,
32774 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32775 card->hbpool.count++;
32776 } else
32777 dev_kfree_skb_any(hb);
32778 - atomic_inc(&vcc->stats->rx_drop);
32779 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32780 } else {
32781 /* Copy the small buffer to the huge buffer */
32782 sb = (struct sk_buff *)iov->iov_base;
32783 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32784 #endif /* NS_USE_DESTRUCTORS */
32785 __net_timestamp(hb);
32786 vcc->push(vcc, hb);
32787 - atomic_inc(&vcc->stats->rx);
32788 + atomic_inc_unchecked(&vcc->stats->rx);
32789 }
32790 }
32791
32792 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32793 index 0474a89..06ea4a1 100644
32794 --- a/drivers/atm/solos-pci.c
32795 +++ b/drivers/atm/solos-pci.c
32796 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32797 }
32798 atm_charge(vcc, skb->truesize);
32799 vcc->push(vcc, skb);
32800 - atomic_inc(&vcc->stats->rx);
32801 + atomic_inc_unchecked(&vcc->stats->rx);
32802 break;
32803
32804 case PKT_STATUS:
32805 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32806 vcc = SKB_CB(oldskb)->vcc;
32807
32808 if (vcc) {
32809 - atomic_inc(&vcc->stats->tx);
32810 + atomic_inc_unchecked(&vcc->stats->tx);
32811 solos_pop(vcc, oldskb);
32812 } else {
32813 dev_kfree_skb_irq(oldskb);
32814 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
32815 index 0215934..ce9f5b1 100644
32816 --- a/drivers/atm/suni.c
32817 +++ b/drivers/atm/suni.c
32818 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
32819
32820
32821 #define ADD_LIMITED(s,v) \
32822 - atomic_add((v),&stats->s); \
32823 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
32824 + atomic_add_unchecked((v),&stats->s); \
32825 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
32826
32827
32828 static void suni_hz(unsigned long from_timer)
32829 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
32830 index 5120a96..e2572bd 100644
32831 --- a/drivers/atm/uPD98402.c
32832 +++ b/drivers/atm/uPD98402.c
32833 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
32834 struct sonet_stats tmp;
32835 int error = 0;
32836
32837 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32838 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32839 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
32840 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
32841 if (zero && !error) {
32842 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
32843
32844
32845 #define ADD_LIMITED(s,v) \
32846 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
32847 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
32848 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32849 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
32850 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
32851 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32852
32853
32854 static void stat_event(struct atm_dev *dev)
32855 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
32856 if (reason & uPD98402_INT_PFM) stat_event(dev);
32857 if (reason & uPD98402_INT_PCO) {
32858 (void) GET(PCOCR); /* clear interrupt cause */
32859 - atomic_add(GET(HECCT),
32860 + atomic_add_unchecked(GET(HECCT),
32861 &PRIV(dev)->sonet_stats.uncorr_hcs);
32862 }
32863 if ((reason & uPD98402_INT_RFO) &&
32864 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
32865 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
32866 uPD98402_INT_LOS),PIMR); /* enable them */
32867 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
32868 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32869 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
32870 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
32871 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32872 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
32873 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
32874 return 0;
32875 }
32876
32877 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
32878 index 969c3c2..9b72956 100644
32879 --- a/drivers/atm/zatm.c
32880 +++ b/drivers/atm/zatm.c
32881 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32882 }
32883 if (!size) {
32884 dev_kfree_skb_irq(skb);
32885 - if (vcc) atomic_inc(&vcc->stats->rx_err);
32886 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
32887 continue;
32888 }
32889 if (!atm_charge(vcc,skb->truesize)) {
32890 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32891 skb->len = size;
32892 ATM_SKB(skb)->vcc = vcc;
32893 vcc->push(vcc,skb);
32894 - atomic_inc(&vcc->stats->rx);
32895 + atomic_inc_unchecked(&vcc->stats->rx);
32896 }
32897 zout(pos & 0xffff,MTA(mbx));
32898 #if 0 /* probably a stupid idea */
32899 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
32900 skb_queue_head(&zatm_vcc->backlog,skb);
32901 break;
32902 }
32903 - atomic_inc(&vcc->stats->tx);
32904 + atomic_inc_unchecked(&vcc->stats->tx);
32905 wake_up(&zatm_vcc->tx_wait);
32906 }
32907
32908 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
32909 index 6856303..0602d70 100644
32910 --- a/drivers/base/bus.c
32911 +++ b/drivers/base/bus.c
32912 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
32913 return -EINVAL;
32914
32915 mutex_lock(&subsys->p->mutex);
32916 - list_add_tail(&sif->node, &subsys->p->interfaces);
32917 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
32918 if (sif->add_dev) {
32919 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32920 while ((dev = subsys_dev_iter_next(&iter)))
32921 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
32922 subsys = sif->subsys;
32923
32924 mutex_lock(&subsys->p->mutex);
32925 - list_del_init(&sif->node);
32926 + pax_list_del_init((struct list_head *)&sif->node);
32927 if (sif->remove_dev) {
32928 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32929 while ((dev = subsys_dev_iter_next(&iter)))
32930 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
32931 index 17cf7ca..7e553e1 100644
32932 --- a/drivers/base/devtmpfs.c
32933 +++ b/drivers/base/devtmpfs.c
32934 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
32935 if (!thread)
32936 return 0;
32937
32938 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
32939 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
32940 if (err)
32941 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
32942 else
32943 diff --git a/drivers/base/node.c b/drivers/base/node.c
32944 index fac124a..66bd4ab 100644
32945 --- a/drivers/base/node.c
32946 +++ b/drivers/base/node.c
32947 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
32948 struct node_attr {
32949 struct device_attribute attr;
32950 enum node_states state;
32951 -};
32952 +} __do_const;
32953
32954 static ssize_t show_node_state(struct device *dev,
32955 struct device_attribute *attr, char *buf)
32956 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
32957 index acc3a8d..981c236 100644
32958 --- a/drivers/base/power/domain.c
32959 +++ b/drivers/base/power/domain.c
32960 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
32961 {
32962 struct cpuidle_driver *cpuidle_drv;
32963 struct gpd_cpu_data *cpu_data;
32964 - struct cpuidle_state *idle_state;
32965 + cpuidle_state_no_const *idle_state;
32966 int ret = 0;
32967
32968 if (IS_ERR_OR_NULL(genpd) || state < 0)
32969 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
32970 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
32971 {
32972 struct gpd_cpu_data *cpu_data;
32973 - struct cpuidle_state *idle_state;
32974 + cpuidle_state_no_const *idle_state;
32975 int ret = 0;
32976
32977 if (IS_ERR_OR_NULL(genpd))
32978 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
32979 index e6ee5e8..98ad7fc 100644
32980 --- a/drivers/base/power/wakeup.c
32981 +++ b/drivers/base/power/wakeup.c
32982 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
32983 * They need to be modified together atomically, so it's better to use one
32984 * atomic variable to hold them both.
32985 */
32986 -static atomic_t combined_event_count = ATOMIC_INIT(0);
32987 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
32988
32989 #define IN_PROGRESS_BITS (sizeof(int) * 4)
32990 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
32991
32992 static void split_counters(unsigned int *cnt, unsigned int *inpr)
32993 {
32994 - unsigned int comb = atomic_read(&combined_event_count);
32995 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
32996
32997 *cnt = (comb >> IN_PROGRESS_BITS);
32998 *inpr = comb & MAX_IN_PROGRESS;
32999 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33000 ws->start_prevent_time = ws->last_time;
33001
33002 /* Increment the counter of events in progress. */
33003 - cec = atomic_inc_return(&combined_event_count);
33004 + cec = atomic_inc_return_unchecked(&combined_event_count);
33005
33006 trace_wakeup_source_activate(ws->name, cec);
33007 }
33008 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33009 * Increment the counter of registered wakeup events and decrement the
33010 * couter of wakeup events in progress simultaneously.
33011 */
33012 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33013 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33014 trace_wakeup_source_deactivate(ws->name, cec);
33015
33016 split_counters(&cnt, &inpr);
33017 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33018 index e8d11b6..7b1b36f 100644
33019 --- a/drivers/base/syscore.c
33020 +++ b/drivers/base/syscore.c
33021 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33022 void register_syscore_ops(struct syscore_ops *ops)
33023 {
33024 mutex_lock(&syscore_ops_lock);
33025 - list_add_tail(&ops->node, &syscore_ops_list);
33026 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33027 mutex_unlock(&syscore_ops_lock);
33028 }
33029 EXPORT_SYMBOL_GPL(register_syscore_ops);
33030 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33031 void unregister_syscore_ops(struct syscore_ops *ops)
33032 {
33033 mutex_lock(&syscore_ops_lock);
33034 - list_del(&ops->node);
33035 + pax_list_del((struct list_head *)&ops->node);
33036 mutex_unlock(&syscore_ops_lock);
33037 }
33038 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33039 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33040 index ade58bc..867143d 100644
33041 --- a/drivers/block/cciss.c
33042 +++ b/drivers/block/cciss.c
33043 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33044 int err;
33045 u32 cp;
33046
33047 + memset(&arg64, 0, sizeof(arg64));
33048 +
33049 err = 0;
33050 err |=
33051 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33052 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33053 while (!list_empty(&h->reqQ)) {
33054 c = list_entry(h->reqQ.next, CommandList_struct, list);
33055 /* can't do anything if fifo is full */
33056 - if ((h->access.fifo_full(h))) {
33057 + if ((h->access->fifo_full(h))) {
33058 dev_warn(&h->pdev->dev, "fifo full\n");
33059 break;
33060 }
33061 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33062 h->Qdepth--;
33063
33064 /* Tell the controller execute command */
33065 - h->access.submit_command(h, c);
33066 + h->access->submit_command(h, c);
33067
33068 /* Put job onto the completed Q */
33069 addQ(&h->cmpQ, c);
33070 @@ -3441,17 +3443,17 @@ startio:
33071
33072 static inline unsigned long get_next_completion(ctlr_info_t *h)
33073 {
33074 - return h->access.command_completed(h);
33075 + return h->access->command_completed(h);
33076 }
33077
33078 static inline int interrupt_pending(ctlr_info_t *h)
33079 {
33080 - return h->access.intr_pending(h);
33081 + return h->access->intr_pending(h);
33082 }
33083
33084 static inline long interrupt_not_for_us(ctlr_info_t *h)
33085 {
33086 - return ((h->access.intr_pending(h) == 0) ||
33087 + return ((h->access->intr_pending(h) == 0) ||
33088 (h->interrupts_enabled == 0));
33089 }
33090
33091 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33092 u32 a;
33093
33094 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33095 - return h->access.command_completed(h);
33096 + return h->access->command_completed(h);
33097
33098 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33099 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33100 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33101 trans_support & CFGTBL_Trans_use_short_tags);
33102
33103 /* Change the access methods to the performant access methods */
33104 - h->access = SA5_performant_access;
33105 + h->access = &SA5_performant_access;
33106 h->transMethod = CFGTBL_Trans_Performant;
33107
33108 return;
33109 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33110 if (prod_index < 0)
33111 return -ENODEV;
33112 h->product_name = products[prod_index].product_name;
33113 - h->access = *(products[prod_index].access);
33114 + h->access = products[prod_index].access;
33115
33116 if (cciss_board_disabled(h)) {
33117 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33118 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33119 }
33120
33121 /* make sure the board interrupts are off */
33122 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33123 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33124 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33125 if (rc)
33126 goto clean2;
33127 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33128 * fake ones to scoop up any residual completions.
33129 */
33130 spin_lock_irqsave(&h->lock, flags);
33131 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33132 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33133 spin_unlock_irqrestore(&h->lock, flags);
33134 free_irq(h->intr[h->intr_mode], h);
33135 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33136 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33137 dev_info(&h->pdev->dev, "Board READY.\n");
33138 dev_info(&h->pdev->dev,
33139 "Waiting for stale completions to drain.\n");
33140 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33141 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33142 msleep(10000);
33143 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33144 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33145
33146 rc = controller_reset_failed(h->cfgtable);
33147 if (rc)
33148 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33149 cciss_scsi_setup(h);
33150
33151 /* Turn the interrupts on so we can service requests */
33152 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33153 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33154
33155 /* Get the firmware version */
33156 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33157 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33158 kfree(flush_buf);
33159 if (return_code != IO_OK)
33160 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33161 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33162 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33163 free_irq(h->intr[h->intr_mode], h);
33164 }
33165
33166 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33167 index 7fda30e..eb5dfe0 100644
33168 --- a/drivers/block/cciss.h
33169 +++ b/drivers/block/cciss.h
33170 @@ -101,7 +101,7 @@ struct ctlr_info
33171 /* information about each logical volume */
33172 drive_info_struct *drv[CISS_MAX_LUN];
33173
33174 - struct access_method access;
33175 + struct access_method *access;
33176
33177 /* queue and queue Info */
33178 struct list_head reqQ;
33179 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33180 index 3f08713..56a586a 100644
33181 --- a/drivers/block/cpqarray.c
33182 +++ b/drivers/block/cpqarray.c
33183 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33184 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33185 goto Enomem4;
33186 }
33187 - hba[i]->access.set_intr_mask(hba[i], 0);
33188 + hba[i]->access->set_intr_mask(hba[i], 0);
33189 if (request_irq(hba[i]->intr, do_ida_intr,
33190 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33191 {
33192 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33193 add_timer(&hba[i]->timer);
33194
33195 /* Enable IRQ now that spinlock and rate limit timer are set up */
33196 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33197 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33198
33199 for(j=0; j<NWD; j++) {
33200 struct gendisk *disk = ida_gendisk[i][j];
33201 @@ -694,7 +694,7 @@ DBGINFO(
33202 for(i=0; i<NR_PRODUCTS; i++) {
33203 if (board_id == products[i].board_id) {
33204 c->product_name = products[i].product_name;
33205 - c->access = *(products[i].access);
33206 + c->access = products[i].access;
33207 break;
33208 }
33209 }
33210 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33211 hba[ctlr]->intr = intr;
33212 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33213 hba[ctlr]->product_name = products[j].product_name;
33214 - hba[ctlr]->access = *(products[j].access);
33215 + hba[ctlr]->access = products[j].access;
33216 hba[ctlr]->ctlr = ctlr;
33217 hba[ctlr]->board_id = board_id;
33218 hba[ctlr]->pci_dev = NULL; /* not PCI */
33219 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33220
33221 while((c = h->reqQ) != NULL) {
33222 /* Can't do anything if we're busy */
33223 - if (h->access.fifo_full(h) == 0)
33224 + if (h->access->fifo_full(h) == 0)
33225 return;
33226
33227 /* Get the first entry from the request Q */
33228 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33229 h->Qdepth--;
33230
33231 /* Tell the controller to do our bidding */
33232 - h->access.submit_command(h, c);
33233 + h->access->submit_command(h, c);
33234
33235 /* Get onto the completion Q */
33236 addQ(&h->cmpQ, c);
33237 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33238 unsigned long flags;
33239 __u32 a,a1;
33240
33241 - istat = h->access.intr_pending(h);
33242 + istat = h->access->intr_pending(h);
33243 /* Is this interrupt for us? */
33244 if (istat == 0)
33245 return IRQ_NONE;
33246 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33247 */
33248 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33249 if (istat & FIFO_NOT_EMPTY) {
33250 - while((a = h->access.command_completed(h))) {
33251 + while((a = h->access->command_completed(h))) {
33252 a1 = a; a &= ~3;
33253 if ((c = h->cmpQ) == NULL)
33254 {
33255 @@ -1449,11 +1449,11 @@ static int sendcmd(
33256 /*
33257 * Disable interrupt
33258 */
33259 - info_p->access.set_intr_mask(info_p, 0);
33260 + info_p->access->set_intr_mask(info_p, 0);
33261 /* Make sure there is room in the command FIFO */
33262 /* Actually it should be completely empty at this time. */
33263 for (i = 200000; i > 0; i--) {
33264 - temp = info_p->access.fifo_full(info_p);
33265 + temp = info_p->access->fifo_full(info_p);
33266 if (temp != 0) {
33267 break;
33268 }
33269 @@ -1466,7 +1466,7 @@ DBG(
33270 /*
33271 * Send the cmd
33272 */
33273 - info_p->access.submit_command(info_p, c);
33274 + info_p->access->submit_command(info_p, c);
33275 complete = pollcomplete(ctlr);
33276
33277 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33278 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33279 * we check the new geometry. Then turn interrupts back on when
33280 * we're done.
33281 */
33282 - host->access.set_intr_mask(host, 0);
33283 + host->access->set_intr_mask(host, 0);
33284 getgeometry(ctlr);
33285 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33286 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33287
33288 for(i=0; i<NWD; i++) {
33289 struct gendisk *disk = ida_gendisk[ctlr][i];
33290 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33291 /* Wait (up to 2 seconds) for a command to complete */
33292
33293 for (i = 200000; i > 0; i--) {
33294 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33295 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33296 if (done == 0) {
33297 udelay(10); /* a short fixed delay */
33298 } else
33299 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33300 index be73e9d..7fbf140 100644
33301 --- a/drivers/block/cpqarray.h
33302 +++ b/drivers/block/cpqarray.h
33303 @@ -99,7 +99,7 @@ struct ctlr_info {
33304 drv_info_t drv[NWD];
33305 struct proc_dir_entry *proc;
33306
33307 - struct access_method access;
33308 + struct access_method *access;
33309
33310 cmdlist_t *reqQ;
33311 cmdlist_t *cmpQ;
33312 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33313 index 6b51afa..17e1191 100644
33314 --- a/drivers/block/drbd/drbd_int.h
33315 +++ b/drivers/block/drbd/drbd_int.h
33316 @@ -582,7 +582,7 @@ struct drbd_epoch {
33317 struct drbd_tconn *tconn;
33318 struct list_head list;
33319 unsigned int barrier_nr;
33320 - atomic_t epoch_size; /* increased on every request added. */
33321 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33322 atomic_t active; /* increased on every req. added, and dec on every finished. */
33323 unsigned long flags;
33324 };
33325 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33326 int al_tr_cycle;
33327 int al_tr_pos; /* position of the next transaction in the journal */
33328 wait_queue_head_t seq_wait;
33329 - atomic_t packet_seq;
33330 + atomic_unchecked_t packet_seq;
33331 unsigned int peer_seq;
33332 spinlock_t peer_seq_lock;
33333 unsigned int minor;
33334 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33335 char __user *uoptval;
33336 int err;
33337
33338 - uoptval = (char __user __force *)optval;
33339 + uoptval = (char __force_user *)optval;
33340
33341 set_fs(KERNEL_DS);
33342 if (level == SOL_SOCKET)
33343 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33344 index 8c13eeb..217adee 100644
33345 --- a/drivers/block/drbd/drbd_main.c
33346 +++ b/drivers/block/drbd/drbd_main.c
33347 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33348 p->sector = sector;
33349 p->block_id = block_id;
33350 p->blksize = blksize;
33351 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33352 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33353 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33354 }
33355
33356 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33357 return -EIO;
33358 p->sector = cpu_to_be64(req->i.sector);
33359 p->block_id = (unsigned long)req;
33360 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33361 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33362 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33363 if (mdev->state.conn >= C_SYNC_SOURCE &&
33364 mdev->state.conn <= C_PAUSED_SYNC_T)
33365 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33366 {
33367 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33368
33369 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33370 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33371 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33372 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33373 kfree(tconn->current_epoch);
33374
33375 idr_destroy(&tconn->volumes);
33376 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33377 index a9eccfc..f5efe87 100644
33378 --- a/drivers/block/drbd/drbd_receiver.c
33379 +++ b/drivers/block/drbd/drbd_receiver.c
33380 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33381 {
33382 int err;
33383
33384 - atomic_set(&mdev->packet_seq, 0);
33385 + atomic_set_unchecked(&mdev->packet_seq, 0);
33386 mdev->peer_seq = 0;
33387
33388 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33389 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33390 do {
33391 next_epoch = NULL;
33392
33393 - epoch_size = atomic_read(&epoch->epoch_size);
33394 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33395
33396 switch (ev & ~EV_CLEANUP) {
33397 case EV_PUT:
33398 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33399 rv = FE_DESTROYED;
33400 } else {
33401 epoch->flags = 0;
33402 - atomic_set(&epoch->epoch_size, 0);
33403 + atomic_set_unchecked(&epoch->epoch_size, 0);
33404 /* atomic_set(&epoch->active, 0); is already zero */
33405 if (rv == FE_STILL_LIVE)
33406 rv = FE_RECYCLED;
33407 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33408 conn_wait_active_ee_empty(tconn);
33409 drbd_flush(tconn);
33410
33411 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33412 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33413 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33414 if (epoch)
33415 break;
33416 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33417 }
33418
33419 epoch->flags = 0;
33420 - atomic_set(&epoch->epoch_size, 0);
33421 + atomic_set_unchecked(&epoch->epoch_size, 0);
33422 atomic_set(&epoch->active, 0);
33423
33424 spin_lock(&tconn->epoch_lock);
33425 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33426 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33427 list_add(&epoch->list, &tconn->current_epoch->list);
33428 tconn->current_epoch = epoch;
33429 tconn->epochs++;
33430 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33431
33432 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33433 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33434 - atomic_inc(&tconn->current_epoch->epoch_size);
33435 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33436 err2 = drbd_drain_block(mdev, pi->size);
33437 if (!err)
33438 err = err2;
33439 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33440
33441 spin_lock(&tconn->epoch_lock);
33442 peer_req->epoch = tconn->current_epoch;
33443 - atomic_inc(&peer_req->epoch->epoch_size);
33444 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33445 atomic_inc(&peer_req->epoch->active);
33446 spin_unlock(&tconn->epoch_lock);
33447
33448 @@ -4346,7 +4346,7 @@ struct data_cmd {
33449 int expect_payload;
33450 size_t pkt_size;
33451 int (*fn)(struct drbd_tconn *, struct packet_info *);
33452 -};
33453 +} __do_const;
33454
33455 static struct data_cmd drbd_cmd_handler[] = {
33456 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33457 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33458 if (!list_empty(&tconn->current_epoch->list))
33459 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33460 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33461 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33462 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33463 tconn->send.seen_any_write_yet = false;
33464
33465 conn_info(tconn, "Connection closed\n");
33466 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33467 struct asender_cmd {
33468 size_t pkt_size;
33469 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33470 -};
33471 +} __do_const;
33472
33473 static struct asender_cmd asender_tbl[] = {
33474 [P_PING] = { 0, got_Ping },
33475 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33476 index 8bc6d39..f492563 100644
33477 --- a/drivers/block/loop.c
33478 +++ b/drivers/block/loop.c
33479 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
33480 mm_segment_t old_fs = get_fs();
33481
33482 set_fs(get_ds());
33483 - bw = file->f_op->write(file, buf, len, &pos);
33484 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33485 set_fs(old_fs);
33486 if (likely(bw == len))
33487 return 0;
33488 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33489 index d620b44..587561e 100644
33490 --- a/drivers/cdrom/cdrom.c
33491 +++ b/drivers/cdrom/cdrom.c
33492 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33493 ENSURE(reset, CDC_RESET);
33494 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33495 cdi->mc_flags = 0;
33496 - cdo->n_minors = 0;
33497 cdi->options = CDO_USE_FFLAGS;
33498
33499 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33500 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33501 else
33502 cdi->cdda_method = CDDA_OLD;
33503
33504 - if (!cdo->generic_packet)
33505 - cdo->generic_packet = cdrom_dummy_generic_packet;
33506 + if (!cdo->generic_packet) {
33507 + pax_open_kernel();
33508 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33509 + pax_close_kernel();
33510 + }
33511
33512 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33513 mutex_lock(&cdrom_mutex);
33514 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33515 if (cdi->exit)
33516 cdi->exit(cdi);
33517
33518 - cdi->ops->n_minors--;
33519 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33520 }
33521
33522 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33523 index d59cdcb..11afddf 100644
33524 --- a/drivers/cdrom/gdrom.c
33525 +++ b/drivers/cdrom/gdrom.c
33526 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33527 .audio_ioctl = gdrom_audio_ioctl,
33528 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33529 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33530 - .n_minors = 1,
33531 };
33532
33533 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33534 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33535 index 72bedad..8181ce1 100644
33536 --- a/drivers/char/Kconfig
33537 +++ b/drivers/char/Kconfig
33538 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33539
33540 config DEVKMEM
33541 bool "/dev/kmem virtual device support"
33542 - default y
33543 + default n
33544 + depends on !GRKERNSEC_KMEM
33545 help
33546 Say Y here if you want to support the /dev/kmem device. The
33547 /dev/kmem device is rarely used, but can be used for certain
33548 @@ -581,6 +582,7 @@ config DEVPORT
33549 bool
33550 depends on !M68K
33551 depends on ISA || PCI
33552 + depends on !GRKERNSEC_KMEM
33553 default y
33554
33555 source "drivers/s390/char/Kconfig"
33556 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33557 index 2e04433..22afc64 100644
33558 --- a/drivers/char/agp/frontend.c
33559 +++ b/drivers/char/agp/frontend.c
33560 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33561 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33562 return -EFAULT;
33563
33564 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33565 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33566 return -EFAULT;
33567
33568 client = agp_find_client_by_pid(reserve.pid);
33569 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33570 index 21cb980..f15107c 100644
33571 --- a/drivers/char/genrtc.c
33572 +++ b/drivers/char/genrtc.c
33573 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33574 switch (cmd) {
33575
33576 case RTC_PLL_GET:
33577 + memset(&pll, 0, sizeof(pll));
33578 if (get_rtc_pll(&pll))
33579 return -EINVAL;
33580 else
33581 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33582 index fe6d4be..89f32100 100644
33583 --- a/drivers/char/hpet.c
33584 +++ b/drivers/char/hpet.c
33585 @@ -571,7 +571,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33586 }
33587
33588 static int
33589 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33590 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33591 struct hpet_info *info)
33592 {
33593 struct hpet_timer __iomem *timer;
33594 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33595 index 053201b0..8335cce 100644
33596 --- a/drivers/char/ipmi/ipmi_msghandler.c
33597 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33598 @@ -420,7 +420,7 @@ struct ipmi_smi {
33599 struct proc_dir_entry *proc_dir;
33600 char proc_dir_name[10];
33601
33602 - atomic_t stats[IPMI_NUM_STATS];
33603 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33604
33605 /*
33606 * run_to_completion duplicate of smb_info, smi_info
33607 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33608
33609
33610 #define ipmi_inc_stat(intf, stat) \
33611 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33612 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33613 #define ipmi_get_stat(intf, stat) \
33614 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33615 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33616
33617 static int is_lan_addr(struct ipmi_addr *addr)
33618 {
33619 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33620 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33621 init_waitqueue_head(&intf->waitq);
33622 for (i = 0; i < IPMI_NUM_STATS; i++)
33623 - atomic_set(&intf->stats[i], 0);
33624 + atomic_set_unchecked(&intf->stats[i], 0);
33625
33626 intf->proc_dir = NULL;
33627
33628 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33629 index 1c7fdcd..4899100 100644
33630 --- a/drivers/char/ipmi/ipmi_si_intf.c
33631 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33632 @@ -275,7 +275,7 @@ struct smi_info {
33633 unsigned char slave_addr;
33634
33635 /* Counters and things for the proc filesystem. */
33636 - atomic_t stats[SI_NUM_STATS];
33637 + atomic_unchecked_t stats[SI_NUM_STATS];
33638
33639 struct task_struct *thread;
33640
33641 @@ -284,9 +284,9 @@ struct smi_info {
33642 };
33643
33644 #define smi_inc_stat(smi, stat) \
33645 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33646 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33647 #define smi_get_stat(smi, stat) \
33648 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33649 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33650
33651 #define SI_MAX_PARMS 4
33652
33653 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
33654 atomic_set(&new_smi->req_events, 0);
33655 new_smi->run_to_completion = 0;
33656 for (i = 0; i < SI_NUM_STATS; i++)
33657 - atomic_set(&new_smi->stats[i], 0);
33658 + atomic_set_unchecked(&new_smi->stats[i], 0);
33659
33660 new_smi->interrupt_disabled = 1;
33661 atomic_set(&new_smi->stop_operation, 0);
33662 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33663 index c6fa3bc..4ca3e42 100644
33664 --- a/drivers/char/mem.c
33665 +++ b/drivers/char/mem.c
33666 @@ -18,6 +18,7 @@
33667 #include <linux/raw.h>
33668 #include <linux/tty.h>
33669 #include <linux/capability.h>
33670 +#include <linux/security.h>
33671 #include <linux/ptrace.h>
33672 #include <linux/device.h>
33673 #include <linux/highmem.h>
33674 @@ -37,6 +38,10 @@
33675
33676 #define DEVPORT_MINOR 4
33677
33678 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33679 +extern const struct file_operations grsec_fops;
33680 +#endif
33681 +
33682 static inline unsigned long size_inside_page(unsigned long start,
33683 unsigned long size)
33684 {
33685 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33686
33687 while (cursor < to) {
33688 if (!devmem_is_allowed(pfn)) {
33689 +#ifdef CONFIG_GRKERNSEC_KMEM
33690 + gr_handle_mem_readwrite(from, to);
33691 +#else
33692 printk(KERN_INFO
33693 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
33694 current->comm, from, to);
33695 +#endif
33696 return 0;
33697 }
33698 cursor += PAGE_SIZE;
33699 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33700 }
33701 return 1;
33702 }
33703 +#elif defined(CONFIG_GRKERNSEC_KMEM)
33704 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33705 +{
33706 + return 0;
33707 +}
33708 #else
33709 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33710 {
33711 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33712
33713 while (count > 0) {
33714 unsigned long remaining;
33715 + char *temp;
33716
33717 sz = size_inside_page(p, count);
33718
33719 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33720 if (!ptr)
33721 return -EFAULT;
33722
33723 - remaining = copy_to_user(buf, ptr, sz);
33724 +#ifdef CONFIG_PAX_USERCOPY
33725 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33726 + if (!temp) {
33727 + unxlate_dev_mem_ptr(p, ptr);
33728 + return -ENOMEM;
33729 + }
33730 + memcpy(temp, ptr, sz);
33731 +#else
33732 + temp = ptr;
33733 +#endif
33734 +
33735 + remaining = copy_to_user(buf, temp, sz);
33736 +
33737 +#ifdef CONFIG_PAX_USERCOPY
33738 + kfree(temp);
33739 +#endif
33740 +
33741 unxlate_dev_mem_ptr(p, ptr);
33742 if (remaining)
33743 return -EFAULT;
33744 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33745 size_t count, loff_t *ppos)
33746 {
33747 unsigned long p = *ppos;
33748 - ssize_t low_count, read, sz;
33749 + ssize_t low_count, read, sz, err = 0;
33750 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
33751 - int err = 0;
33752
33753 read = 0;
33754 if (p < (unsigned long) high_memory) {
33755 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33756 }
33757 #endif
33758 while (low_count > 0) {
33759 + char *temp;
33760 +
33761 sz = size_inside_page(p, low_count);
33762
33763 /*
33764 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33765 */
33766 kbuf = xlate_dev_kmem_ptr((char *)p);
33767
33768 - if (copy_to_user(buf, kbuf, sz))
33769 +#ifdef CONFIG_PAX_USERCOPY
33770 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33771 + if (!temp)
33772 + return -ENOMEM;
33773 + memcpy(temp, kbuf, sz);
33774 +#else
33775 + temp = kbuf;
33776 +#endif
33777 +
33778 + err = copy_to_user(buf, temp, sz);
33779 +
33780 +#ifdef CONFIG_PAX_USERCOPY
33781 + kfree(temp);
33782 +#endif
33783 +
33784 + if (err)
33785 return -EFAULT;
33786 buf += sz;
33787 p += sz;
33788 @@ -833,6 +880,9 @@ static const struct memdev {
33789 #ifdef CONFIG_CRASH_DUMP
33790 [12] = { "oldmem", 0, &oldmem_fops, NULL },
33791 #endif
33792 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33793 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
33794 +#endif
33795 };
33796
33797 static int memory_open(struct inode *inode, struct file *filp)
33798 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
33799 index 9df78e2..01ba9ae 100644
33800 --- a/drivers/char/nvram.c
33801 +++ b/drivers/char/nvram.c
33802 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
33803
33804 spin_unlock_irq(&rtc_lock);
33805
33806 - if (copy_to_user(buf, contents, tmp - contents))
33807 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
33808 return -EFAULT;
33809
33810 *ppos = i;
33811 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
33812 index b66eaa0..2619d1b 100644
33813 --- a/drivers/char/pcmcia/synclink_cs.c
33814 +++ b/drivers/char/pcmcia/synclink_cs.c
33815 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33816
33817 if (debug_level >= DEBUG_LEVEL_INFO)
33818 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
33819 - __FILE__,__LINE__, info->device_name, port->count);
33820 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
33821
33822 - WARN_ON(!port->count);
33823 + WARN_ON(!atomic_read(&port->count));
33824
33825 if (tty_port_close_start(port, tty, filp) == 0)
33826 goto cleanup;
33827 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33828 cleanup:
33829 if (debug_level >= DEBUG_LEVEL_INFO)
33830 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
33831 - tty->driver->name, port->count);
33832 + tty->driver->name, atomic_read(&port->count));
33833 }
33834
33835 /* Wait until the transmitter is empty.
33836 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33837
33838 if (debug_level >= DEBUG_LEVEL_INFO)
33839 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
33840 - __FILE__,__LINE__,tty->driver->name, port->count);
33841 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
33842
33843 /* If port is closing, signal caller to try again */
33844 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
33845 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33846 goto cleanup;
33847 }
33848 spin_lock(&port->lock);
33849 - port->count++;
33850 + atomic_inc(&port->count);
33851 spin_unlock(&port->lock);
33852 spin_unlock_irqrestore(&info->netlock, flags);
33853
33854 - if (port->count == 1) {
33855 + if (atomic_read(&port->count) == 1) {
33856 /* 1st open on this device, init hardware */
33857 retval = startup(info, tty);
33858 if (retval < 0)
33859 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
33860 unsigned short new_crctype;
33861
33862 /* return error if TTY interface open */
33863 - if (info->port.count)
33864 + if (atomic_read(&info->port.count))
33865 return -EBUSY;
33866
33867 switch (encoding)
33868 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
33869
33870 /* arbitrate between network and tty opens */
33871 spin_lock_irqsave(&info->netlock, flags);
33872 - if (info->port.count != 0 || info->netcount != 0) {
33873 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
33874 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
33875 spin_unlock_irqrestore(&info->netlock, flags);
33876 return -EBUSY;
33877 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
33878 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
33879
33880 /* return error if TTY interface open */
33881 - if (info->port.count)
33882 + if (atomic_read(&info->port.count))
33883 return -EBUSY;
33884
33885 if (cmd != SIOCWANDEV)
33886 diff --git a/drivers/char/random.c b/drivers/char/random.c
33887 index 57d4b15..253207b 100644
33888 --- a/drivers/char/random.c
33889 +++ b/drivers/char/random.c
33890 @@ -272,8 +272,13 @@
33891 /*
33892 * Configuration information
33893 */
33894 +#ifdef CONFIG_GRKERNSEC_RANDNET
33895 +#define INPUT_POOL_WORDS 512
33896 +#define OUTPUT_POOL_WORDS 128
33897 +#else
33898 #define INPUT_POOL_WORDS 128
33899 #define OUTPUT_POOL_WORDS 32
33900 +#endif
33901 #define SEC_XFER_SIZE 512
33902 #define EXTRACT_SIZE 10
33903
33904 @@ -313,10 +318,17 @@ static struct poolinfo {
33905 int poolwords;
33906 int tap1, tap2, tap3, tap4, tap5;
33907 } poolinfo_table[] = {
33908 +#ifdef CONFIG_GRKERNSEC_RANDNET
33909 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
33910 + { 512, 411, 308, 208, 104, 1 },
33911 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
33912 + { 128, 103, 76, 51, 25, 1 },
33913 +#else
33914 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
33915 { 128, 103, 76, 51, 25, 1 },
33916 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
33917 { 32, 26, 20, 14, 7, 1 },
33918 +#endif
33919 #if 0
33920 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
33921 { 2048, 1638, 1231, 819, 411, 1 },
33922 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
33923 input_rotate += i ? 7 : 14;
33924 }
33925
33926 - ACCESS_ONCE(r->input_rotate) = input_rotate;
33927 - ACCESS_ONCE(r->add_ptr) = i;
33928 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
33929 + ACCESS_ONCE_RW(r->add_ptr) = i;
33930 smp_wmb();
33931
33932 if (out)
33933 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
33934
33935 extract_buf(r, tmp);
33936 i = min_t(int, nbytes, EXTRACT_SIZE);
33937 - if (copy_to_user(buf, tmp, i)) {
33938 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
33939 ret = -EFAULT;
33940 break;
33941 }
33942 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
33943 #include <linux/sysctl.h>
33944
33945 static int min_read_thresh = 8, min_write_thresh;
33946 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
33947 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
33948 static int max_write_thresh = INPUT_POOL_WORDS * 32;
33949 static char sysctl_bootid[16];
33950
33951 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
33952 static int proc_do_uuid(ctl_table *table, int write,
33953 void __user *buffer, size_t *lenp, loff_t *ppos)
33954 {
33955 - ctl_table fake_table;
33956 + ctl_table_no_const fake_table;
33957 unsigned char buf[64], tmp_uuid[16], *uuid;
33958
33959 uuid = table->data;
33960 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
33961 index d780295..b29f3a8 100644
33962 --- a/drivers/char/sonypi.c
33963 +++ b/drivers/char/sonypi.c
33964 @@ -54,6 +54,7 @@
33965
33966 #include <asm/uaccess.h>
33967 #include <asm/io.h>
33968 +#include <asm/local.h>
33969
33970 #include <linux/sonypi.h>
33971
33972 @@ -490,7 +491,7 @@ static struct sonypi_device {
33973 spinlock_t fifo_lock;
33974 wait_queue_head_t fifo_proc_list;
33975 struct fasync_struct *fifo_async;
33976 - int open_count;
33977 + local_t open_count;
33978 int model;
33979 struct input_dev *input_jog_dev;
33980 struct input_dev *input_key_dev;
33981 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
33982 static int sonypi_misc_release(struct inode *inode, struct file *file)
33983 {
33984 mutex_lock(&sonypi_device.lock);
33985 - sonypi_device.open_count--;
33986 + local_dec(&sonypi_device.open_count);
33987 mutex_unlock(&sonypi_device.lock);
33988 return 0;
33989 }
33990 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
33991 {
33992 mutex_lock(&sonypi_device.lock);
33993 /* Flush input queue on first open */
33994 - if (!sonypi_device.open_count)
33995 + if (!local_read(&sonypi_device.open_count))
33996 kfifo_reset(&sonypi_device.fifo);
33997 - sonypi_device.open_count++;
33998 + local_inc(&sonypi_device.open_count);
33999 mutex_unlock(&sonypi_device.lock);
34000
34001 return 0;
34002 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
34003 index 93211df..c7805f7 100644
34004 --- a/drivers/char/tpm/tpm.c
34005 +++ b/drivers/char/tpm/tpm.c
34006 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
34007 chip->vendor.req_complete_val)
34008 goto out_recv;
34009
34010 - if ((status == chip->vendor.req_canceled)) {
34011 + if (status == chip->vendor.req_canceled) {
34012 dev_err(chip->dev, "Operation Canceled\n");
34013 rc = -ECANCELED;
34014 goto out;
34015 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34016 index 56051d0..11cf3b7 100644
34017 --- a/drivers/char/tpm/tpm_acpi.c
34018 +++ b/drivers/char/tpm/tpm_acpi.c
34019 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34020 virt = acpi_os_map_memory(start, len);
34021 if (!virt) {
34022 kfree(log->bios_event_log);
34023 + log->bios_event_log = NULL;
34024 printk("%s: ERROR - Unable to map memory\n", __func__);
34025 return -EIO;
34026 }
34027
34028 - memcpy_fromio(log->bios_event_log, virt, len);
34029 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34030
34031 acpi_os_unmap_memory(virt, len);
34032 return 0;
34033 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34034 index 84ddc55..1d32f1e 100644
34035 --- a/drivers/char/tpm/tpm_eventlog.c
34036 +++ b/drivers/char/tpm/tpm_eventlog.c
34037 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34038 event = addr;
34039
34040 if ((event->event_type == 0 && event->event_size == 0) ||
34041 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34042 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34043 return NULL;
34044
34045 return addr;
34046 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34047 return NULL;
34048
34049 if ((event->event_type == 0 && event->event_size == 0) ||
34050 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34051 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34052 return NULL;
34053
34054 (*pos)++;
34055 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34056 int i;
34057
34058 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34059 - seq_putc(m, data[i]);
34060 + if (!seq_putc(m, data[i]))
34061 + return -EFAULT;
34062
34063 return 0;
34064 }
34065 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34066 index ee4dbea..69c817b 100644
34067 --- a/drivers/char/virtio_console.c
34068 +++ b/drivers/char/virtio_console.c
34069 @@ -681,7 +681,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34070 if (to_user) {
34071 ssize_t ret;
34072
34073 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34074 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34075 if (ret)
34076 return -EFAULT;
34077 } else {
34078 @@ -780,7 +780,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34079 if (!port_has_data(port) && !port->host_connected)
34080 return 0;
34081
34082 - return fill_readbuf(port, ubuf, count, true);
34083 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34084 }
34085
34086 static int wait_port_writable(struct port *port, bool nonblock)
34087 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
34088 index 8ae1a61..9c00613 100644
34089 --- a/drivers/clocksource/arm_generic.c
34090 +++ b/drivers/clocksource/arm_generic.c
34091 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34092 return NOTIFY_OK;
34093 }
34094
34095 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34096 +static struct notifier_block arch_timer_cpu_nb = {
34097 .notifier_call = arch_timer_cpu_notify,
34098 };
34099
34100 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34101 index 7b0d49d..134fac9 100644
34102 --- a/drivers/cpufreq/acpi-cpufreq.c
34103 +++ b/drivers/cpufreq/acpi-cpufreq.c
34104 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34105 return sprintf(buf, "%u\n", boost_enabled);
34106 }
34107
34108 -static struct global_attr global_boost = __ATTR(boost, 0644,
34109 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34110 show_global_boost,
34111 store_global_boost);
34112
34113 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34114 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34115 per_cpu(acfreq_data, cpu) = data;
34116
34117 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34118 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34119 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34120 + pax_open_kernel();
34121 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34122 + pax_close_kernel();
34123 + }
34124
34125 result = acpi_processor_register_performance(data->acpi_data, cpu);
34126 if (result)
34127 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34128 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34129 break;
34130 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34131 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34132 + pax_open_kernel();
34133 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34134 + pax_close_kernel();
34135 policy->cur = get_cur_freq_on_cpu(cpu);
34136 break;
34137 default:
34138 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34139 acpi_processor_notify_smm(THIS_MODULE);
34140
34141 /* Check for APERF/MPERF support in hardware */
34142 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34143 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34144 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34145 + pax_open_kernel();
34146 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34147 + pax_close_kernel();
34148 + }
34149
34150 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34151 for (i = 0; i < perf->state_count; i++)
34152 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34153 index 1f93dbd..305cef1 100644
34154 --- a/drivers/cpufreq/cpufreq.c
34155 +++ b/drivers/cpufreq/cpufreq.c
34156 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34157 return NOTIFY_OK;
34158 }
34159
34160 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34161 +static struct notifier_block cpufreq_cpu_notifier = {
34162 .notifier_call = cpufreq_cpu_callback,
34163 };
34164
34165 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34166
34167 pr_debug("trying to register driver %s\n", driver_data->name);
34168
34169 - if (driver_data->setpolicy)
34170 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34171 + if (driver_data->setpolicy) {
34172 + pax_open_kernel();
34173 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34174 + pax_close_kernel();
34175 + }
34176
34177 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34178 if (cpufreq_driver) {
34179 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34180 index 6c5f1d3..c7e2f35e 100644
34181 --- a/drivers/cpufreq/cpufreq_governor.c
34182 +++ b/drivers/cpufreq/cpufreq_governor.c
34183 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34184 * governor, thus we are bound to jiffes/HZ
34185 */
34186 if (dbs_data->governor == GOV_CONSERVATIVE) {
34187 - struct cs_ops *ops = dbs_data->gov_ops;
34188 + const struct cs_ops *ops = dbs_data->gov_ops;
34189
34190 cpufreq_register_notifier(ops->notifier_block,
34191 CPUFREQ_TRANSITION_NOTIFIER);
34192 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34193 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
34194 jiffies_to_usecs(10);
34195 } else {
34196 - struct od_ops *ops = dbs_data->gov_ops;
34197 + const struct od_ops *ops = dbs_data->gov_ops;
34198
34199 od_tuners->io_is_busy = ops->io_busy();
34200 }
34201 @@ -268,7 +268,7 @@ second_time:
34202 cs_dbs_info->enable = 1;
34203 cs_dbs_info->requested_freq = policy->cur;
34204 } else {
34205 - struct od_ops *ops = dbs_data->gov_ops;
34206 + const struct od_ops *ops = dbs_data->gov_ops;
34207 od_dbs_info->rate_mult = 1;
34208 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
34209 ops->powersave_bias_init_cpu(cpu);
34210 @@ -289,7 +289,7 @@ second_time:
34211 mutex_destroy(&cpu_cdbs->timer_mutex);
34212 dbs_data->enable--;
34213 if (!dbs_data->enable) {
34214 - struct cs_ops *ops = dbs_data->gov_ops;
34215 + const struct cs_ops *ops = dbs_data->gov_ops;
34216
34217 sysfs_remove_group(cpufreq_global_kobject,
34218 dbs_data->attr_group);
34219 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34220 index f661654..6c8e638 100644
34221 --- a/drivers/cpufreq/cpufreq_governor.h
34222 +++ b/drivers/cpufreq/cpufreq_governor.h
34223 @@ -142,7 +142,7 @@ struct dbs_data {
34224 void (*gov_check_cpu)(int cpu, unsigned int load);
34225
34226 /* Governor specific ops, see below */
34227 - void *gov_ops;
34228 + const void *gov_ops;
34229 };
34230
34231 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34232 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34233 index 9d7732b..0b1a793 100644
34234 --- a/drivers/cpufreq/cpufreq_stats.c
34235 +++ b/drivers/cpufreq/cpufreq_stats.c
34236 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34237 }
34238
34239 /* priority=1 so this will get called before cpufreq_remove_dev */
34240 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34241 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34242 .notifier_call = cpufreq_stat_cpu_callback,
34243 .priority = 1,
34244 };
34245 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34246 index 827629c9..0bc6a03 100644
34247 --- a/drivers/cpufreq/p4-clockmod.c
34248 +++ b/drivers/cpufreq/p4-clockmod.c
34249 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34250 case 0x0F: /* Core Duo */
34251 case 0x16: /* Celeron Core */
34252 case 0x1C: /* Atom */
34253 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34254 + pax_open_kernel();
34255 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34256 + pax_close_kernel();
34257 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34258 case 0x0D: /* Pentium M (Dothan) */
34259 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34260 + pax_open_kernel();
34261 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34262 + pax_close_kernel();
34263 /* fall through */
34264 case 0x09: /* Pentium M (Banias) */
34265 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34266 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34267
34268 /* on P-4s, the TSC runs with constant frequency independent whether
34269 * throttling is active or not. */
34270 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34271 + pax_open_kernel();
34272 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34273 + pax_close_kernel();
34274
34275 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34276 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34277 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34278 index 3a953d5..f5993f6 100644
34279 --- a/drivers/cpufreq/speedstep-centrino.c
34280 +++ b/drivers/cpufreq/speedstep-centrino.c
34281 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34282 !cpu_has(cpu, X86_FEATURE_EST))
34283 return -ENODEV;
34284
34285 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34286 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34287 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34288 + pax_open_kernel();
34289 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34290 + pax_close_kernel();
34291 + }
34292
34293 if (policy->cpu != 0)
34294 return -ENODEV;
34295 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34296 index e1f6860..f8de20b 100644
34297 --- a/drivers/cpuidle/cpuidle.c
34298 +++ b/drivers/cpuidle/cpuidle.c
34299 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
34300
34301 static void poll_idle_init(struct cpuidle_driver *drv)
34302 {
34303 - struct cpuidle_state *state = &drv->states[0];
34304 + cpuidle_state_no_const *state = &drv->states[0];
34305
34306 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34307 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34308 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34309 index ea2f8e7..70ac501 100644
34310 --- a/drivers/cpuidle/governor.c
34311 +++ b/drivers/cpuidle/governor.c
34312 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34313 mutex_lock(&cpuidle_lock);
34314 if (__cpuidle_find_governor(gov->name) == NULL) {
34315 ret = 0;
34316 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34317 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34318 if (!cpuidle_curr_governor ||
34319 cpuidle_curr_governor->rating < gov->rating)
34320 cpuidle_switch_governor(gov);
34321 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34322 new_gov = cpuidle_replace_governor(gov->rating);
34323 cpuidle_switch_governor(new_gov);
34324 }
34325 - list_del(&gov->governor_list);
34326 + pax_list_del((struct list_head *)&gov->governor_list);
34327 mutex_unlock(&cpuidle_lock);
34328 }
34329
34330 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34331 index 428754a..8bdf9cc 100644
34332 --- a/drivers/cpuidle/sysfs.c
34333 +++ b/drivers/cpuidle/sysfs.c
34334 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34335 NULL
34336 };
34337
34338 -static struct attribute_group cpuidle_attr_group = {
34339 +static attribute_group_no_const cpuidle_attr_group = {
34340 .attrs = cpuidle_default_attrs,
34341 .name = "cpuidle",
34342 };
34343 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34344 index 3b36797..289c16a 100644
34345 --- a/drivers/devfreq/devfreq.c
34346 +++ b/drivers/devfreq/devfreq.c
34347 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34348 goto err_out;
34349 }
34350
34351 - list_add(&governor->node, &devfreq_governor_list);
34352 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34353
34354 list_for_each_entry(devfreq, &devfreq_list, node) {
34355 int ret = 0;
34356 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34357 }
34358 }
34359
34360 - list_del(&governor->node);
34361 + pax_list_del((struct list_head *)&governor->node);
34362 err_out:
34363 mutex_unlock(&devfreq_list_lock);
34364
34365 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34366 index b70709b..1d8d02a 100644
34367 --- a/drivers/dma/sh/shdma.c
34368 +++ b/drivers/dma/sh/shdma.c
34369 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34370 return ret;
34371 }
34372
34373 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34374 +static struct notifier_block sh_dmae_nmi_notifier = {
34375 .notifier_call = sh_dmae_nmi_handler,
34376
34377 /* Run before NMI debug handler and KGDB */
34378 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34379 index 0ca1ca7..6e6f454 100644
34380 --- a/drivers/edac/edac_mc_sysfs.c
34381 +++ b/drivers/edac/edac_mc_sysfs.c
34382 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34383 struct dev_ch_attribute {
34384 struct device_attribute attr;
34385 int channel;
34386 -};
34387 +} __do_const;
34388
34389 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34390 struct dev_ch_attribute dev_attr_legacy_##_name = \
34391 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34392 index 0056c4d..23b54d9 100644
34393 --- a/drivers/edac/edac_pci_sysfs.c
34394 +++ b/drivers/edac/edac_pci_sysfs.c
34395 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34396 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34397 static int edac_pci_poll_msec = 1000; /* one second workq period */
34398
34399 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34400 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34401 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34402 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34403
34404 static struct kobject *edac_pci_top_main_kobj;
34405 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34406 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34407 void *value;
34408 ssize_t(*show) (void *, char *);
34409 ssize_t(*store) (void *, const char *, size_t);
34410 -};
34411 +} __do_const;
34412
34413 /* Set of show/store abstract level functions for PCI Parity object */
34414 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34415 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34416 edac_printk(KERN_CRIT, EDAC_PCI,
34417 "Signaled System Error on %s\n",
34418 pci_name(dev));
34419 - atomic_inc(&pci_nonparity_count);
34420 + atomic_inc_unchecked(&pci_nonparity_count);
34421 }
34422
34423 if (status & (PCI_STATUS_PARITY)) {
34424 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34425 "Master Data Parity Error on %s\n",
34426 pci_name(dev));
34427
34428 - atomic_inc(&pci_parity_count);
34429 + atomic_inc_unchecked(&pci_parity_count);
34430 }
34431
34432 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34433 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34434 "Detected Parity Error on %s\n",
34435 pci_name(dev));
34436
34437 - atomic_inc(&pci_parity_count);
34438 + atomic_inc_unchecked(&pci_parity_count);
34439 }
34440 }
34441
34442 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34443 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34444 "Signaled System Error on %s\n",
34445 pci_name(dev));
34446 - atomic_inc(&pci_nonparity_count);
34447 + atomic_inc_unchecked(&pci_nonparity_count);
34448 }
34449
34450 if (status & (PCI_STATUS_PARITY)) {
34451 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34452 "Master Data Parity Error on "
34453 "%s\n", pci_name(dev));
34454
34455 - atomic_inc(&pci_parity_count);
34456 + atomic_inc_unchecked(&pci_parity_count);
34457 }
34458
34459 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34460 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34461 "Detected Parity Error on %s\n",
34462 pci_name(dev));
34463
34464 - atomic_inc(&pci_parity_count);
34465 + atomic_inc_unchecked(&pci_parity_count);
34466 }
34467 }
34468 }
34469 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34470 if (!check_pci_errors)
34471 return;
34472
34473 - before_count = atomic_read(&pci_parity_count);
34474 + before_count = atomic_read_unchecked(&pci_parity_count);
34475
34476 /* scan all PCI devices looking for a Parity Error on devices and
34477 * bridges.
34478 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34479 /* Only if operator has selected panic on PCI Error */
34480 if (edac_pci_get_panic_on_pe()) {
34481 /* If the count is different 'after' from 'before' */
34482 - if (before_count != atomic_read(&pci_parity_count))
34483 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34484 panic("EDAC: PCI Parity Error");
34485 }
34486 }
34487 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34488 index 6796799..99e8377 100644
34489 --- a/drivers/edac/mce_amd.h
34490 +++ b/drivers/edac/mce_amd.h
34491 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
34492 struct amd_decoder_ops {
34493 bool (*mc0_mce)(u16, u8);
34494 bool (*mc1_mce)(u16, u8);
34495 -};
34496 +} __no_const;
34497
34498 void amd_report_gart_errors(bool);
34499 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34500 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34501 index 57ea7f4..789e3c3 100644
34502 --- a/drivers/firewire/core-card.c
34503 +++ b/drivers/firewire/core-card.c
34504 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34505
34506 void fw_core_remove_card(struct fw_card *card)
34507 {
34508 - struct fw_card_driver dummy_driver = dummy_driver_template;
34509 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34510
34511 card->driver->update_phy_reg(card, 4,
34512 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34513 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34514 index f8d2287..5aaf4db 100644
34515 --- a/drivers/firewire/core-cdev.c
34516 +++ b/drivers/firewire/core-cdev.c
34517 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
34518 int ret;
34519
34520 if ((request->channels == 0 && request->bandwidth == 0) ||
34521 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34522 - request->bandwidth < 0)
34523 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34524 return -EINVAL;
34525
34526 r = kmalloc(sizeof(*r), GFP_KERNEL);
34527 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34528 index af3e8aa..eb2f227 100644
34529 --- a/drivers/firewire/core-device.c
34530 +++ b/drivers/firewire/core-device.c
34531 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34532 struct config_rom_attribute {
34533 struct device_attribute attr;
34534 u32 key;
34535 -};
34536 +} __do_const;
34537
34538 static ssize_t show_immediate(struct device *dev,
34539 struct device_attribute *dattr, char *buf)
34540 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34541 index 28a94c7..58da63a 100644
34542 --- a/drivers/firewire/core-transaction.c
34543 +++ b/drivers/firewire/core-transaction.c
34544 @@ -38,6 +38,7 @@
34545 #include <linux/timer.h>
34546 #include <linux/types.h>
34547 #include <linux/workqueue.h>
34548 +#include <linux/sched.h>
34549
34550 #include <asm/byteorder.h>
34551
34552 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34553 index 515a42c..5ecf3ba 100644
34554 --- a/drivers/firewire/core.h
34555 +++ b/drivers/firewire/core.h
34556 @@ -111,6 +111,7 @@ struct fw_card_driver {
34557
34558 int (*stop_iso)(struct fw_iso_context *ctx);
34559 };
34560 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34561
34562 void fw_card_initialize(struct fw_card *card,
34563 const struct fw_card_driver *driver, struct device *device);
34564 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34565 index 94a58a0..f5eba42 100644
34566 --- a/drivers/firmware/dmi-id.c
34567 +++ b/drivers/firmware/dmi-id.c
34568 @@ -16,7 +16,7 @@
34569 struct dmi_device_attribute{
34570 struct device_attribute dev_attr;
34571 int field;
34572 -};
34573 +} __do_const;
34574 #define to_dmi_dev_attr(_dev_attr) \
34575 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34576
34577 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34578 index 4cd392d..4b629e1 100644
34579 --- a/drivers/firmware/dmi_scan.c
34580 +++ b/drivers/firmware/dmi_scan.c
34581 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34582 }
34583 }
34584 else {
34585 - /*
34586 - * no iounmap() for that ioremap(); it would be a no-op, but
34587 - * it's so early in setup that sucker gets confused into doing
34588 - * what it shouldn't if we actually call it.
34589 - */
34590 p = dmi_ioremap(0xF0000, 0x10000);
34591 if (p == NULL)
34592 goto error;
34593 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34594 if (buf == NULL)
34595 return -1;
34596
34597 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34598 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34599
34600 iounmap(buf);
34601 return 0;
34602 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34603 index e1d6253..bd00f91 100644
34604 --- a/drivers/firmware/efivars.c
34605 +++ b/drivers/firmware/efivars.c
34606 @@ -138,7 +138,7 @@ struct efivar_attribute {
34607 };
34608
34609 static struct efivars __efivars;
34610 -static struct efivar_operations ops;
34611 +static efivar_operations_no_const ops __read_only;
34612
34613 #define PSTORE_EFI_ATTRIBUTES \
34614 (EFI_VARIABLE_NON_VOLATILE | \
34615 @@ -1787,7 +1787,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34616 static int
34617 create_efivars_bin_attributes(struct efivars *efivars)
34618 {
34619 - struct bin_attribute *attr;
34620 + bin_attribute_no_const *attr;
34621 int error;
34622
34623 /* new_var */
34624 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34625 index 2a90ba6..07f3733 100644
34626 --- a/drivers/firmware/google/memconsole.c
34627 +++ b/drivers/firmware/google/memconsole.c
34628 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34629 if (!found_memconsole())
34630 return -ENODEV;
34631
34632 - memconsole_bin_attr.size = memconsole_length;
34633 + pax_open_kernel();
34634 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34635 + pax_close_kernel();
34636
34637 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34638
34639 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34640 index 6f2306d..af9476a 100644
34641 --- a/drivers/gpio/gpio-ich.c
34642 +++ b/drivers/gpio/gpio-ich.c
34643 @@ -69,7 +69,7 @@ struct ichx_desc {
34644 /* Some chipsets have quirks, let these use their own request/get */
34645 int (*request)(struct gpio_chip *chip, unsigned offset);
34646 int (*get)(struct gpio_chip *chip, unsigned offset);
34647 -};
34648 +} __do_const;
34649
34650 static struct {
34651 spinlock_t lock;
34652 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
34653 index 9902732..64b62dd 100644
34654 --- a/drivers/gpio/gpio-vr41xx.c
34655 +++ b/drivers/gpio/gpio-vr41xx.c
34656 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
34657 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
34658 maskl, pendl, maskh, pendh);
34659
34660 - atomic_inc(&irq_err_count);
34661 + atomic_inc_unchecked(&irq_err_count);
34662
34663 return -EINVAL;
34664 }
34665 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
34666 index 7b2d378..cc947ea 100644
34667 --- a/drivers/gpu/drm/drm_crtc_helper.c
34668 +++ b/drivers/gpu/drm/drm_crtc_helper.c
34669 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
34670 struct drm_crtc *tmp;
34671 int crtc_mask = 1;
34672
34673 - WARN(!crtc, "checking null crtc?\n");
34674 + BUG_ON(!crtc);
34675
34676 dev = crtc->dev;
34677
34678 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
34679 index be174ca..7f38143 100644
34680 --- a/drivers/gpu/drm/drm_drv.c
34681 +++ b/drivers/gpu/drm/drm_drv.c
34682 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
34683 /**
34684 * Copy and IOCTL return string to user space
34685 */
34686 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
34687 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
34688 {
34689 int len;
34690
34691 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
34692 struct drm_file *file_priv = filp->private_data;
34693 struct drm_device *dev;
34694 struct drm_ioctl_desc *ioctl;
34695 - drm_ioctl_t *func;
34696 + drm_ioctl_no_const_t func;
34697 unsigned int nr = DRM_IOCTL_NR(cmd);
34698 int retcode = -EINVAL;
34699 char stack_kdata[128];
34700 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
34701 return -ENODEV;
34702
34703 atomic_inc(&dev->ioctl_count);
34704 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
34705 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
34706 ++file_priv->ioctl_count;
34707
34708 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
34709 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
34710 index 133b413..fd68225 100644
34711 --- a/drivers/gpu/drm/drm_fops.c
34712 +++ b/drivers/gpu/drm/drm_fops.c
34713 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
34714 }
34715
34716 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
34717 - atomic_set(&dev->counts[i], 0);
34718 + atomic_set_unchecked(&dev->counts[i], 0);
34719
34720 dev->sigdata.lock = NULL;
34721
34722 @@ -134,7 +134,7 @@ int drm_open(struct inode *inode, struct file *filp)
34723 if (drm_device_is_unplugged(dev))
34724 return -ENODEV;
34725
34726 - if (!dev->open_count++)
34727 + if (local_inc_return(&dev->open_count) == 1)
34728 need_setup = 1;
34729 mutex_lock(&dev->struct_mutex);
34730 old_mapping = dev->dev_mapping;
34731 @@ -149,7 +149,7 @@ int drm_open(struct inode *inode, struct file *filp)
34732 retcode = drm_open_helper(inode, filp, dev);
34733 if (retcode)
34734 goto err_undo;
34735 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
34736 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
34737 if (need_setup) {
34738 retcode = drm_setup(dev);
34739 if (retcode)
34740 @@ -164,7 +164,7 @@ err_undo:
34741 iput(container_of(dev->dev_mapping, struct inode, i_data));
34742 dev->dev_mapping = old_mapping;
34743 mutex_unlock(&dev->struct_mutex);
34744 - dev->open_count--;
34745 + local_dec(&dev->open_count);
34746 return retcode;
34747 }
34748 EXPORT_SYMBOL(drm_open);
34749 @@ -438,7 +438,7 @@ int drm_release(struct inode *inode, struct file *filp)
34750
34751 mutex_lock(&drm_global_mutex);
34752
34753 - DRM_DEBUG("open_count = %d\n", dev->open_count);
34754 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
34755
34756 if (dev->driver->preclose)
34757 dev->driver->preclose(dev, file_priv);
34758 @@ -447,10 +447,10 @@ int drm_release(struct inode *inode, struct file *filp)
34759 * Begin inline drm_release
34760 */
34761
34762 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
34763 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
34764 task_pid_nr(current),
34765 (long)old_encode_dev(file_priv->minor->device),
34766 - dev->open_count);
34767 + local_read(&dev->open_count));
34768
34769 /* Release any auth tokens that might point to this file_priv,
34770 (do that under the drm_global_mutex) */
34771 @@ -547,8 +547,8 @@ int drm_release(struct inode *inode, struct file *filp)
34772 * End inline drm_release
34773 */
34774
34775 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
34776 - if (!--dev->open_count) {
34777 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
34778 + if (local_dec_and_test(&dev->open_count)) {
34779 if (atomic_read(&dev->ioctl_count)) {
34780 DRM_ERROR("Device busy: %d\n",
34781 atomic_read(&dev->ioctl_count));
34782 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
34783 index f731116..629842c 100644
34784 --- a/drivers/gpu/drm/drm_global.c
34785 +++ b/drivers/gpu/drm/drm_global.c
34786 @@ -36,7 +36,7 @@
34787 struct drm_global_item {
34788 struct mutex mutex;
34789 void *object;
34790 - int refcount;
34791 + atomic_t refcount;
34792 };
34793
34794 static struct drm_global_item glob[DRM_GLOBAL_NUM];
34795 @@ -49,7 +49,7 @@ void drm_global_init(void)
34796 struct drm_global_item *item = &glob[i];
34797 mutex_init(&item->mutex);
34798 item->object = NULL;
34799 - item->refcount = 0;
34800 + atomic_set(&item->refcount, 0);
34801 }
34802 }
34803
34804 @@ -59,7 +59,7 @@ void drm_global_release(void)
34805 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
34806 struct drm_global_item *item = &glob[i];
34807 BUG_ON(item->object != NULL);
34808 - BUG_ON(item->refcount != 0);
34809 + BUG_ON(atomic_read(&item->refcount) != 0);
34810 }
34811 }
34812
34813 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34814 void *object;
34815
34816 mutex_lock(&item->mutex);
34817 - if (item->refcount == 0) {
34818 + if (atomic_read(&item->refcount) == 0) {
34819 item->object = kzalloc(ref->size, GFP_KERNEL);
34820 if (unlikely(item->object == NULL)) {
34821 ret = -ENOMEM;
34822 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34823 goto out_err;
34824
34825 }
34826 - ++item->refcount;
34827 + atomic_inc(&item->refcount);
34828 ref->object = item->object;
34829 object = item->object;
34830 mutex_unlock(&item->mutex);
34831 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
34832 struct drm_global_item *item = &glob[ref->global_type];
34833
34834 mutex_lock(&item->mutex);
34835 - BUG_ON(item->refcount == 0);
34836 + BUG_ON(atomic_read(&item->refcount) == 0);
34837 BUG_ON(ref->object != item->object);
34838 - if (--item->refcount == 0) {
34839 + if (atomic_dec_and_test(&item->refcount)) {
34840 ref->release(ref);
34841 item->object = NULL;
34842 }
34843 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
34844 index d4b20ce..77a8d41 100644
34845 --- a/drivers/gpu/drm/drm_info.c
34846 +++ b/drivers/gpu/drm/drm_info.c
34847 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
34848 struct drm_local_map *map;
34849 struct drm_map_list *r_list;
34850
34851 - /* Hardcoded from _DRM_FRAME_BUFFER,
34852 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
34853 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
34854 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
34855 + static const char * const types[] = {
34856 + [_DRM_FRAME_BUFFER] = "FB",
34857 + [_DRM_REGISTERS] = "REG",
34858 + [_DRM_SHM] = "SHM",
34859 + [_DRM_AGP] = "AGP",
34860 + [_DRM_SCATTER_GATHER] = "SG",
34861 + [_DRM_CONSISTENT] = "PCI",
34862 + [_DRM_GEM] = "GEM" };
34863 const char *type;
34864 int i;
34865
34866 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
34867 map = r_list->map;
34868 if (!map)
34869 continue;
34870 - if (map->type < 0 || map->type > 5)
34871 + if (map->type >= ARRAY_SIZE(types))
34872 type = "??";
34873 else
34874 type = types[map->type];
34875 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
34876 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
34877 vma->vm_flags & VM_LOCKED ? 'l' : '-',
34878 vma->vm_flags & VM_IO ? 'i' : '-',
34879 +#ifdef CONFIG_GRKERNSEC_HIDESYM
34880 + 0);
34881 +#else
34882 vma->vm_pgoff);
34883 +#endif
34884
34885 #if defined(__i386__)
34886 pgprot = pgprot_val(vma->vm_page_prot);
34887 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
34888 index 2f4c434..dd12cd2 100644
34889 --- a/drivers/gpu/drm/drm_ioc32.c
34890 +++ b/drivers/gpu/drm/drm_ioc32.c
34891 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
34892 request = compat_alloc_user_space(nbytes);
34893 if (!access_ok(VERIFY_WRITE, request, nbytes))
34894 return -EFAULT;
34895 - list = (struct drm_buf_desc *) (request + 1);
34896 + list = (struct drm_buf_desc __user *) (request + 1);
34897
34898 if (__put_user(count, &request->count)
34899 || __put_user(list, &request->list))
34900 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
34901 request = compat_alloc_user_space(nbytes);
34902 if (!access_ok(VERIFY_WRITE, request, nbytes))
34903 return -EFAULT;
34904 - list = (struct drm_buf_pub *) (request + 1);
34905 + list = (struct drm_buf_pub __user *) (request + 1);
34906
34907 if (__put_user(count, &request->count)
34908 || __put_user(list, &request->list))
34909 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
34910 return 0;
34911 }
34912
34913 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
34914 +drm_ioctl_compat_t drm_compat_ioctls[] = {
34915 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
34916 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
34917 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
34918 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
34919 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34920 {
34921 unsigned int nr = DRM_IOCTL_NR(cmd);
34922 - drm_ioctl_compat_t *fn;
34923 int ret;
34924
34925 /* Assume that ioctls without an explicit compat routine will just
34926 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34927 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
34928 return drm_ioctl(filp, cmd, arg);
34929
34930 - fn = drm_compat_ioctls[nr];
34931 -
34932 - if (fn != NULL)
34933 - ret = (*fn) (filp, cmd, arg);
34934 + if (drm_compat_ioctls[nr] != NULL)
34935 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
34936 else
34937 ret = drm_ioctl(filp, cmd, arg);
34938
34939 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
34940 index e77bd8b..1571b85 100644
34941 --- a/drivers/gpu/drm/drm_ioctl.c
34942 +++ b/drivers/gpu/drm/drm_ioctl.c
34943 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
34944 stats->data[i].value =
34945 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
34946 else
34947 - stats->data[i].value = atomic_read(&dev->counts[i]);
34948 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
34949 stats->data[i].type = dev->types[i];
34950 }
34951
34952 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
34953 index d752c96..fe08455 100644
34954 --- a/drivers/gpu/drm/drm_lock.c
34955 +++ b/drivers/gpu/drm/drm_lock.c
34956 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
34957 if (drm_lock_take(&master->lock, lock->context)) {
34958 master->lock.file_priv = file_priv;
34959 master->lock.lock_time = jiffies;
34960 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
34961 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
34962 break; /* Got lock */
34963 }
34964
34965 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
34966 return -EINVAL;
34967 }
34968
34969 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
34970 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
34971
34972 if (drm_lock_free(&master->lock, lock->context)) {
34973 /* FIXME: Should really bail out here. */
34974 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
34975 index 200e104..59facda 100644
34976 --- a/drivers/gpu/drm/drm_stub.c
34977 +++ b/drivers/gpu/drm/drm_stub.c
34978 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
34979
34980 drm_device_set_unplugged(dev);
34981
34982 - if (dev->open_count == 0) {
34983 + if (local_read(&dev->open_count) == 0) {
34984 drm_put_dev(dev);
34985 }
34986 mutex_unlock(&drm_global_mutex);
34987 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
34988 index 004ecdf..db1f6e0 100644
34989 --- a/drivers/gpu/drm/i810/i810_dma.c
34990 +++ b/drivers/gpu/drm/i810/i810_dma.c
34991 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
34992 dma->buflist[vertex->idx],
34993 vertex->discard, vertex->used);
34994
34995 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
34996 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
34997 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
34998 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
34999 sarea_priv->last_enqueue = dev_priv->counter - 1;
35000 sarea_priv->last_dispatch = (int)hw_status[5];
35001
35002 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35003 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35004 mc->last_render);
35005
35006 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35007 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35008 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35009 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35010 sarea_priv->last_enqueue = dev_priv->counter - 1;
35011 sarea_priv->last_dispatch = (int)hw_status[5];
35012
35013 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35014 index 6e0acad..93c8289 100644
35015 --- a/drivers/gpu/drm/i810/i810_drv.h
35016 +++ b/drivers/gpu/drm/i810/i810_drv.h
35017 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35018 int page_flipping;
35019
35020 wait_queue_head_t irq_queue;
35021 - atomic_t irq_received;
35022 - atomic_t irq_emitted;
35023 + atomic_unchecked_t irq_received;
35024 + atomic_unchecked_t irq_emitted;
35025
35026 int front_offset;
35027 } drm_i810_private_t;
35028 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35029 index 261efc8e..27af8a5 100644
35030 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35031 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35032 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35033 I915_READ(GTIMR));
35034 }
35035 seq_printf(m, "Interrupts received: %d\n",
35036 - atomic_read(&dev_priv->irq_received));
35037 + atomic_read_unchecked(&dev_priv->irq_received));
35038 for_each_ring(ring, dev_priv, i) {
35039 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35040 seq_printf(m,
35041 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35042 index 99daa89..84ebd44 100644
35043 --- a/drivers/gpu/drm/i915/i915_dma.c
35044 +++ b/drivers/gpu/drm/i915/i915_dma.c
35045 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35046 bool can_switch;
35047
35048 spin_lock(&dev->count_lock);
35049 - can_switch = (dev->open_count == 0);
35050 + can_switch = (local_read(&dev->open_count) == 0);
35051 spin_unlock(&dev->count_lock);
35052 return can_switch;
35053 }
35054 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35055 index 7339a4b..445aaba 100644
35056 --- a/drivers/gpu/drm/i915/i915_drv.h
35057 +++ b/drivers/gpu/drm/i915/i915_drv.h
35058 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
35059 drm_dma_handle_t *status_page_dmah;
35060 struct resource mch_res;
35061
35062 - atomic_t irq_received;
35063 + atomic_unchecked_t irq_received;
35064
35065 /* protects the irq masks */
35066 spinlock_t irq_lock;
35067 @@ -1102,7 +1102,7 @@ struct drm_i915_gem_object {
35068 * will be page flipped away on the next vblank. When it
35069 * reaches 0, dev_priv->pending_flip_queue will be woken up.
35070 */
35071 - atomic_t pending_flip;
35072 + atomic_unchecked_t pending_flip;
35073 };
35074 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
35075
35076 @@ -1633,7 +1633,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35077 struct drm_i915_private *dev_priv, unsigned port);
35078 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35079 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35080 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35081 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35082 {
35083 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35084 }
35085 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35086 index 7adf5a7..e24fb51 100644
35087 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35088 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35089 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
35090 i915_gem_clflush_object(obj);
35091
35092 if (obj->base.pending_write_domain)
35093 - flips |= atomic_read(&obj->pending_flip);
35094 + flips |= atomic_read_unchecked(&obj->pending_flip);
35095
35096 flush_domains |= obj->base.write_domain;
35097 }
35098 @@ -703,9 +703,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35099
35100 static int
35101 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35102 - int count)
35103 + unsigned int count)
35104 {
35105 - int i;
35106 + unsigned int i;
35107 int relocs_total = 0;
35108 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35109
35110 @@ -1202,7 +1202,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35111 return -ENOMEM;
35112 }
35113 ret = copy_from_user(exec2_list,
35114 - (struct drm_i915_relocation_entry __user *)
35115 + (struct drm_i915_gem_exec_object2 __user *)
35116 (uintptr_t) args->buffers_ptr,
35117 sizeof(*exec2_list) * args->buffer_count);
35118 if (ret != 0) {
35119 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35120 index 3c59584..500f2e9 100644
35121 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35122 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35123 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35124 (unsigned long)request);
35125 }
35126
35127 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35128 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35129 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35130 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35131 [DRM_I915_GETPARAM] = compat_i915_getparam,
35132 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35133 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35134 {
35135 unsigned int nr = DRM_IOCTL_NR(cmd);
35136 - drm_ioctl_compat_t *fn = NULL;
35137 int ret;
35138
35139 if (nr < DRM_COMMAND_BASE)
35140 return drm_compat_ioctl(filp, cmd, arg);
35141
35142 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35143 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35144 -
35145 - if (fn != NULL)
35146 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35147 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35148 ret = (*fn) (filp, cmd, arg);
35149 - else
35150 + } else
35151 ret = drm_ioctl(filp, cmd, arg);
35152
35153 return ret;
35154 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35155 index fe84338..a863190 100644
35156 --- a/drivers/gpu/drm/i915/i915_irq.c
35157 +++ b/drivers/gpu/drm/i915/i915_irq.c
35158 @@ -535,7 +535,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35159 u32 pipe_stats[I915_MAX_PIPES];
35160 bool blc_event;
35161
35162 - atomic_inc(&dev_priv->irq_received);
35163 + atomic_inc_unchecked(&dev_priv->irq_received);
35164
35165 while (true) {
35166 iir = I915_READ(VLV_IIR);
35167 @@ -688,7 +688,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35168 irqreturn_t ret = IRQ_NONE;
35169 int i;
35170
35171 - atomic_inc(&dev_priv->irq_received);
35172 + atomic_inc_unchecked(&dev_priv->irq_received);
35173
35174 /* disable master interrupt before clearing iir */
35175 de_ier = I915_READ(DEIER);
35176 @@ -760,7 +760,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35177 int ret = IRQ_NONE;
35178 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
35179
35180 - atomic_inc(&dev_priv->irq_received);
35181 + atomic_inc_unchecked(&dev_priv->irq_received);
35182
35183 /* disable master interrupt before clearing iir */
35184 de_ier = I915_READ(DEIER);
35185 @@ -1787,7 +1787,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35186 {
35187 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35188
35189 - atomic_set(&dev_priv->irq_received, 0);
35190 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35191
35192 I915_WRITE(HWSTAM, 0xeffe);
35193
35194 @@ -1813,7 +1813,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35195 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35196 int pipe;
35197
35198 - atomic_set(&dev_priv->irq_received, 0);
35199 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35200
35201 /* VLV magic */
35202 I915_WRITE(VLV_IMR, 0);
35203 @@ -2108,7 +2108,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35204 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35205 int pipe;
35206
35207 - atomic_set(&dev_priv->irq_received, 0);
35208 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35209
35210 for_each_pipe(pipe)
35211 I915_WRITE(PIPESTAT(pipe), 0);
35212 @@ -2159,7 +2159,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35213 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35214 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35215
35216 - atomic_inc(&dev_priv->irq_received);
35217 + atomic_inc_unchecked(&dev_priv->irq_received);
35218
35219 iir = I915_READ16(IIR);
35220 if (iir == 0)
35221 @@ -2244,7 +2244,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35222 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35223 int pipe;
35224
35225 - atomic_set(&dev_priv->irq_received, 0);
35226 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35227
35228 if (I915_HAS_HOTPLUG(dev)) {
35229 I915_WRITE(PORT_HOTPLUG_EN, 0);
35230 @@ -2339,7 +2339,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35231 };
35232 int pipe, ret = IRQ_NONE;
35233
35234 - atomic_inc(&dev_priv->irq_received);
35235 + atomic_inc_unchecked(&dev_priv->irq_received);
35236
35237 iir = I915_READ(IIR);
35238 do {
35239 @@ -2465,7 +2465,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35240 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35241 int pipe;
35242
35243 - atomic_set(&dev_priv->irq_received, 0);
35244 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35245
35246 I915_WRITE(PORT_HOTPLUG_EN, 0);
35247 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35248 @@ -2572,7 +2572,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35249 int irq_received;
35250 int ret = IRQ_NONE, pipe;
35251
35252 - atomic_inc(&dev_priv->irq_received);
35253 + atomic_inc_unchecked(&dev_priv->irq_received);
35254
35255 iir = I915_READ(IIR);
35256
35257 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35258 index 80aa1fc..85cfce3 100644
35259 --- a/drivers/gpu/drm/i915/intel_display.c
35260 +++ b/drivers/gpu/drm/i915/intel_display.c
35261 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
35262
35263 wait_event(dev_priv->pending_flip_queue,
35264 atomic_read(&dev_priv->mm.wedged) ||
35265 - atomic_read(&obj->pending_flip) == 0);
35266 + atomic_read_unchecked(&obj->pending_flip) == 0);
35267
35268 /* Big Hammer, we also need to ensure that any pending
35269 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
35270 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
35271
35272 obj = work->old_fb_obj;
35273
35274 - atomic_clear_mask(1 << intel_crtc->plane,
35275 - &obj->pending_flip.counter);
35276 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
35277 wake_up(&dev_priv->pending_flip_queue);
35278
35279 queue_work(dev_priv->wq, &work->work);
35280 @@ -7490,7 +7489,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35281 /* Block clients from rendering to the new back buffer until
35282 * the flip occurs and the object is no longer visible.
35283 */
35284 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35285 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35286 atomic_inc(&intel_crtc->unpin_work_count);
35287
35288 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
35289 @@ -7507,7 +7506,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35290
35291 cleanup_pending:
35292 atomic_dec(&intel_crtc->unpin_work_count);
35293 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35294 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35295 drm_gem_object_unreference(&work->old_fb_obj->base);
35296 drm_gem_object_unreference(&obj->base);
35297 mutex_unlock(&dev->struct_mutex);
35298 @@ -8849,13 +8848,13 @@ struct intel_quirk {
35299 int subsystem_vendor;
35300 int subsystem_device;
35301 void (*hook)(struct drm_device *dev);
35302 -};
35303 +} __do_const;
35304
35305 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35306 struct intel_dmi_quirk {
35307 void (*hook)(struct drm_device *dev);
35308 const struct dmi_system_id (*dmi_id_list)[];
35309 -};
35310 +} __do_const;
35311
35312 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35313 {
35314 @@ -8863,18 +8862,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35315 return 1;
35316 }
35317
35318 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35319 + {
35320 + .callback = intel_dmi_reverse_brightness,
35321 + .ident = "NCR Corporation",
35322 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35323 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35324 + },
35325 + },
35326 + { } /* terminating entry */
35327 +};
35328 +
35329 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35330 {
35331 - .dmi_id_list = &(const struct dmi_system_id[]) {
35332 - {
35333 - .callback = intel_dmi_reverse_brightness,
35334 - .ident = "NCR Corporation",
35335 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35336 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35337 - },
35338 - },
35339 - { } /* terminating entry */
35340 - },
35341 + .dmi_id_list = &intel_dmi_quirks_table,
35342 .hook = quirk_invert_brightness,
35343 },
35344 };
35345 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35346 index 54558a0..2d97005 100644
35347 --- a/drivers/gpu/drm/mga/mga_drv.h
35348 +++ b/drivers/gpu/drm/mga/mga_drv.h
35349 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35350 u32 clear_cmd;
35351 u32 maccess;
35352
35353 - atomic_t vbl_received; /**< Number of vblanks received. */
35354 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35355 wait_queue_head_t fence_queue;
35356 - atomic_t last_fence_retired;
35357 + atomic_unchecked_t last_fence_retired;
35358 u32 next_fence_to_post;
35359
35360 unsigned int fb_cpp;
35361 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35362 index 709e90d..89a1c0d 100644
35363 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35364 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35365 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35366 return 0;
35367 }
35368
35369 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35370 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35371 [DRM_MGA_INIT] = compat_mga_init,
35372 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35373 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35374 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35375 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35376 {
35377 unsigned int nr = DRM_IOCTL_NR(cmd);
35378 - drm_ioctl_compat_t *fn = NULL;
35379 int ret;
35380
35381 if (nr < DRM_COMMAND_BASE)
35382 return drm_compat_ioctl(filp, cmd, arg);
35383
35384 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35385 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35386 -
35387 - if (fn != NULL)
35388 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35389 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35390 ret = (*fn) (filp, cmd, arg);
35391 - else
35392 + } else
35393 ret = drm_ioctl(filp, cmd, arg);
35394
35395 return ret;
35396 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35397 index 598c281..60d590e 100644
35398 --- a/drivers/gpu/drm/mga/mga_irq.c
35399 +++ b/drivers/gpu/drm/mga/mga_irq.c
35400 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35401 if (crtc != 0)
35402 return 0;
35403
35404 - return atomic_read(&dev_priv->vbl_received);
35405 + return atomic_read_unchecked(&dev_priv->vbl_received);
35406 }
35407
35408
35409 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35410 /* VBLANK interrupt */
35411 if (status & MGA_VLINEPEN) {
35412 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35413 - atomic_inc(&dev_priv->vbl_received);
35414 + atomic_inc_unchecked(&dev_priv->vbl_received);
35415 drm_handle_vblank(dev, 0);
35416 handled = 1;
35417 }
35418 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35419 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35420 MGA_WRITE(MGA_PRIMEND, prim_end);
35421
35422 - atomic_inc(&dev_priv->last_fence_retired);
35423 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35424 DRM_WAKEUP(&dev_priv->fence_queue);
35425 handled = 1;
35426 }
35427 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35428 * using fences.
35429 */
35430 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35431 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35432 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35433 - *sequence) <= (1 << 23)));
35434
35435 *sequence = cur_fence;
35436 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35437 index 865eddf..62c4cc3 100644
35438 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35439 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35440 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35441 struct bit_table {
35442 const char id;
35443 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35444 -};
35445 +} __no_const;
35446
35447 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35448
35449 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35450 index aa89eb9..d45d38b 100644
35451 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35452 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35453 @@ -80,7 +80,7 @@ struct nouveau_drm {
35454 struct drm_global_reference mem_global_ref;
35455 struct ttm_bo_global_ref bo_global_ref;
35456 struct ttm_bo_device bdev;
35457 - atomic_t validate_sequence;
35458 + atomic_unchecked_t validate_sequence;
35459 int (*move)(struct nouveau_channel *,
35460 struct ttm_buffer_object *,
35461 struct ttm_mem_reg *, struct ttm_mem_reg *);
35462 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
35463 index cdb83ac..27f0a16 100644
35464 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
35465 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
35466 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
35467 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
35468 struct nouveau_channel *);
35469 u32 (*read)(struct nouveau_channel *);
35470 -};
35471 +} __no_const;
35472
35473 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
35474
35475 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35476 index 8bf695c..9fbc90a 100644
35477 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35478 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35479 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35480 int trycnt = 0;
35481 int ret, i;
35482
35483 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35484 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35485 retry:
35486 if (++trycnt > 100000) {
35487 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
35488 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35489 index 08214bc..9208577 100644
35490 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35491 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35492 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35493 unsigned long arg)
35494 {
35495 unsigned int nr = DRM_IOCTL_NR(cmd);
35496 - drm_ioctl_compat_t *fn = NULL;
35497 + drm_ioctl_compat_t fn = NULL;
35498 int ret;
35499
35500 if (nr < DRM_COMMAND_BASE)
35501 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35502 index 25d3495..d81aaf6 100644
35503 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35504 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35505 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35506 bool can_switch;
35507
35508 spin_lock(&dev->count_lock);
35509 - can_switch = (dev->open_count == 0);
35510 + can_switch = (local_read(&dev->open_count) == 0);
35511 spin_unlock(&dev->count_lock);
35512 return can_switch;
35513 }
35514 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35515 index d4660cf..70dbe65 100644
35516 --- a/drivers/gpu/drm/r128/r128_cce.c
35517 +++ b/drivers/gpu/drm/r128/r128_cce.c
35518 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35519
35520 /* GH: Simple idle check.
35521 */
35522 - atomic_set(&dev_priv->idle_count, 0);
35523 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35524
35525 /* We don't support anything other than bus-mastering ring mode,
35526 * but the ring can be in either AGP or PCI space for the ring
35527 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35528 index 930c71b..499aded 100644
35529 --- a/drivers/gpu/drm/r128/r128_drv.h
35530 +++ b/drivers/gpu/drm/r128/r128_drv.h
35531 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35532 int is_pci;
35533 unsigned long cce_buffers_offset;
35534
35535 - atomic_t idle_count;
35536 + atomic_unchecked_t idle_count;
35537
35538 int page_flipping;
35539 int current_page;
35540 u32 crtc_offset;
35541 u32 crtc_offset_cntl;
35542
35543 - atomic_t vbl_received;
35544 + atomic_unchecked_t vbl_received;
35545
35546 u32 color_fmt;
35547 unsigned int front_offset;
35548 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35549 index a954c54..9cc595c 100644
35550 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35551 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35552 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35553 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35554 }
35555
35556 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35557 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35558 [DRM_R128_INIT] = compat_r128_init,
35559 [DRM_R128_DEPTH] = compat_r128_depth,
35560 [DRM_R128_STIPPLE] = compat_r128_stipple,
35561 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35562 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35563 {
35564 unsigned int nr = DRM_IOCTL_NR(cmd);
35565 - drm_ioctl_compat_t *fn = NULL;
35566 int ret;
35567
35568 if (nr < DRM_COMMAND_BASE)
35569 return drm_compat_ioctl(filp, cmd, arg);
35570
35571 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35572 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35573 -
35574 - if (fn != NULL)
35575 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35576 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35577 ret = (*fn) (filp, cmd, arg);
35578 - else
35579 + } else
35580 ret = drm_ioctl(filp, cmd, arg);
35581
35582 return ret;
35583 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35584 index 2ea4f09..d391371 100644
35585 --- a/drivers/gpu/drm/r128/r128_irq.c
35586 +++ b/drivers/gpu/drm/r128/r128_irq.c
35587 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35588 if (crtc != 0)
35589 return 0;
35590
35591 - return atomic_read(&dev_priv->vbl_received);
35592 + return atomic_read_unchecked(&dev_priv->vbl_received);
35593 }
35594
35595 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35596 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35597 /* VBLANK interrupt */
35598 if (status & R128_CRTC_VBLANK_INT) {
35599 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35600 - atomic_inc(&dev_priv->vbl_received);
35601 + atomic_inc_unchecked(&dev_priv->vbl_received);
35602 drm_handle_vblank(dev, 0);
35603 return IRQ_HANDLED;
35604 }
35605 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35606 index 19bb7e6..de7e2a2 100644
35607 --- a/drivers/gpu/drm/r128/r128_state.c
35608 +++ b/drivers/gpu/drm/r128/r128_state.c
35609 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35610
35611 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35612 {
35613 - if (atomic_read(&dev_priv->idle_count) == 0)
35614 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35615 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35616 else
35617 - atomic_set(&dev_priv->idle_count, 0);
35618 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35619 }
35620
35621 #endif
35622 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35623 index 5a82b6b..9e69c73 100644
35624 --- a/drivers/gpu/drm/radeon/mkregtable.c
35625 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35626 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35627 regex_t mask_rex;
35628 regmatch_t match[4];
35629 char buf[1024];
35630 - size_t end;
35631 + long end;
35632 int len;
35633 int done = 0;
35634 int r;
35635 unsigned o;
35636 struct offset *offset;
35637 char last_reg_s[10];
35638 - int last_reg;
35639 + unsigned long last_reg;
35640
35641 if (regcomp
35642 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35643 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35644 index 0d6562b..a154330 100644
35645 --- a/drivers/gpu/drm/radeon/radeon_device.c
35646 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35647 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35648 bool can_switch;
35649
35650 spin_lock(&dev->count_lock);
35651 - can_switch = (dev->open_count == 0);
35652 + can_switch = (local_read(&dev->open_count) == 0);
35653 spin_unlock(&dev->count_lock);
35654 return can_switch;
35655 }
35656 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35657 index e7fdf16..f4f6490 100644
35658 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35659 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35660 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
35661
35662 /* SW interrupt */
35663 wait_queue_head_t swi_queue;
35664 - atomic_t swi_emitted;
35665 + atomic_unchecked_t swi_emitted;
35666 int vblank_crtc;
35667 uint32_t irq_enable_reg;
35668 uint32_t r500_disp_irq_reg;
35669 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
35670 index c180df8..5fd8186 100644
35671 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
35672 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
35673 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35674 request = compat_alloc_user_space(sizeof(*request));
35675 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
35676 || __put_user(req32.param, &request->param)
35677 - || __put_user((void __user *)(unsigned long)req32.value,
35678 + || __put_user((unsigned long)req32.value,
35679 &request->value))
35680 return -EFAULT;
35681
35682 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35683 #define compat_radeon_cp_setparam NULL
35684 #endif /* X86_64 || IA64 */
35685
35686 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35687 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
35688 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
35689 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
35690 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
35691 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35692 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35693 {
35694 unsigned int nr = DRM_IOCTL_NR(cmd);
35695 - drm_ioctl_compat_t *fn = NULL;
35696 int ret;
35697
35698 if (nr < DRM_COMMAND_BASE)
35699 return drm_compat_ioctl(filp, cmd, arg);
35700
35701 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
35702 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35703 -
35704 - if (fn != NULL)
35705 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
35706 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35707 ret = (*fn) (filp, cmd, arg);
35708 - else
35709 + } else
35710 ret = drm_ioctl(filp, cmd, arg);
35711
35712 return ret;
35713 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
35714 index e771033..a0bc6b3 100644
35715 --- a/drivers/gpu/drm/radeon/radeon_irq.c
35716 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
35717 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
35718 unsigned int ret;
35719 RING_LOCALS;
35720
35721 - atomic_inc(&dev_priv->swi_emitted);
35722 - ret = atomic_read(&dev_priv->swi_emitted);
35723 + atomic_inc_unchecked(&dev_priv->swi_emitted);
35724 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
35725
35726 BEGIN_RING(4);
35727 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
35728 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
35729 drm_radeon_private_t *dev_priv =
35730 (drm_radeon_private_t *) dev->dev_private;
35731
35732 - atomic_set(&dev_priv->swi_emitted, 0);
35733 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
35734 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
35735
35736 dev->max_vblank_count = 0x001fffff;
35737 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
35738 index 8e9057b..af6dacb 100644
35739 --- a/drivers/gpu/drm/radeon/radeon_state.c
35740 +++ b/drivers/gpu/drm/radeon/radeon_state.c
35741 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
35742 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
35743 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
35744
35745 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35746 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35747 sarea_priv->nbox * sizeof(depth_boxes[0])))
35748 return -EFAULT;
35749
35750 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
35751 {
35752 drm_radeon_private_t *dev_priv = dev->dev_private;
35753 drm_radeon_getparam_t *param = data;
35754 - int value;
35755 + int value = 0;
35756
35757 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
35758
35759 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
35760 index 93f760e..8088227 100644
35761 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
35762 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
35763 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
35764 man->size = size >> PAGE_SHIFT;
35765 }
35766
35767 -static struct vm_operations_struct radeon_ttm_vm_ops;
35768 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
35769 static const struct vm_operations_struct *ttm_vm_ops = NULL;
35770
35771 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
35772 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
35773 }
35774 if (unlikely(ttm_vm_ops == NULL)) {
35775 ttm_vm_ops = vma->vm_ops;
35776 + pax_open_kernel();
35777 radeon_ttm_vm_ops = *ttm_vm_ops;
35778 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
35779 + pax_close_kernel();
35780 }
35781 vma->vm_ops = &radeon_ttm_vm_ops;
35782 return 0;
35783 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
35784 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
35785 else
35786 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
35787 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35788 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35789 - radeon_mem_types_list[i].driver_features = 0;
35790 + pax_open_kernel();
35791 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35792 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35793 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35794 if (i == 0)
35795 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35796 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35797 else
35798 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35799 -
35800 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35801 + pax_close_kernel();
35802 }
35803 /* Add ttm page pool to debugfs */
35804 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
35805 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35806 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35807 - radeon_mem_types_list[i].driver_features = 0;
35808 - radeon_mem_types_list[i++].data = NULL;
35809 + pax_open_kernel();
35810 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35811 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35812 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35813 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35814 + pax_close_kernel();
35815 #ifdef CONFIG_SWIOTLB
35816 if (swiotlb_nr_tbl()) {
35817 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
35818 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35819 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35820 - radeon_mem_types_list[i].driver_features = 0;
35821 - radeon_mem_types_list[i++].data = NULL;
35822 + pax_open_kernel();
35823 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35824 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35825 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35826 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35827 + pax_close_kernel();
35828 }
35829 #endif
35830 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
35831 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
35832 index 5706d2a..17aedaa 100644
35833 --- a/drivers/gpu/drm/radeon/rs690.c
35834 +++ b/drivers/gpu/drm/radeon/rs690.c
35835 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
35836 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
35837 rdev->pm.sideport_bandwidth.full)
35838 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
35839 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
35840 + read_delay_latency.full = dfixed_const(800 * 1000);
35841 read_delay_latency.full = dfixed_div(read_delay_latency,
35842 rdev->pm.igp_sideport_mclk);
35843 + a.full = dfixed_const(370);
35844 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
35845 } else {
35846 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
35847 rdev->pm.k8_bandwidth.full)
35848 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35849 index bd2a3b4..122d9ad 100644
35850 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
35851 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35852 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
35853 static int ttm_pool_mm_shrink(struct shrinker *shrink,
35854 struct shrink_control *sc)
35855 {
35856 - static atomic_t start_pool = ATOMIC_INIT(0);
35857 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
35858 unsigned i;
35859 - unsigned pool_offset = atomic_add_return(1, &start_pool);
35860 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
35861 struct ttm_page_pool *pool;
35862 int shrink_pages = sc->nr_to_scan;
35863
35864 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
35865 index 1eb060c..188b1fc 100644
35866 --- a/drivers/gpu/drm/udl/udl_fb.c
35867 +++ b/drivers/gpu/drm/udl/udl_fb.c
35868 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
35869 fb_deferred_io_cleanup(info);
35870 kfree(info->fbdefio);
35871 info->fbdefio = NULL;
35872 - info->fbops->fb_mmap = udl_fb_mmap;
35873 }
35874
35875 pr_warn("released /dev/fb%d user=%d count=%d\n",
35876 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
35877 index 893a650..6190d3b 100644
35878 --- a/drivers/gpu/drm/via/via_drv.h
35879 +++ b/drivers/gpu/drm/via/via_drv.h
35880 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
35881 typedef uint32_t maskarray_t[5];
35882
35883 typedef struct drm_via_irq {
35884 - atomic_t irq_received;
35885 + atomic_unchecked_t irq_received;
35886 uint32_t pending_mask;
35887 uint32_t enable_mask;
35888 wait_queue_head_t irq_queue;
35889 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
35890 struct timeval last_vblank;
35891 int last_vblank_valid;
35892 unsigned usec_per_vblank;
35893 - atomic_t vbl_received;
35894 + atomic_unchecked_t vbl_received;
35895 drm_via_state_t hc_state;
35896 char pci_buf[VIA_PCI_BUF_SIZE];
35897 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
35898 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
35899 index ac98964..5dbf512 100644
35900 --- a/drivers/gpu/drm/via/via_irq.c
35901 +++ b/drivers/gpu/drm/via/via_irq.c
35902 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
35903 if (crtc != 0)
35904 return 0;
35905
35906 - return atomic_read(&dev_priv->vbl_received);
35907 + return atomic_read_unchecked(&dev_priv->vbl_received);
35908 }
35909
35910 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35911 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35912
35913 status = VIA_READ(VIA_REG_INTERRUPT);
35914 if (status & VIA_IRQ_VBLANK_PENDING) {
35915 - atomic_inc(&dev_priv->vbl_received);
35916 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
35917 + atomic_inc_unchecked(&dev_priv->vbl_received);
35918 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
35919 do_gettimeofday(&cur_vblank);
35920 if (dev_priv->last_vblank_valid) {
35921 dev_priv->usec_per_vblank =
35922 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35923 dev_priv->last_vblank = cur_vblank;
35924 dev_priv->last_vblank_valid = 1;
35925 }
35926 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
35927 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
35928 DRM_DEBUG("US per vblank is: %u\n",
35929 dev_priv->usec_per_vblank);
35930 }
35931 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35932
35933 for (i = 0; i < dev_priv->num_irqs; ++i) {
35934 if (status & cur_irq->pending_mask) {
35935 - atomic_inc(&cur_irq->irq_received);
35936 + atomic_inc_unchecked(&cur_irq->irq_received);
35937 DRM_WAKEUP(&cur_irq->irq_queue);
35938 handled = 1;
35939 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
35940 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
35941 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
35942 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
35943 masks[irq][4]));
35944 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
35945 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
35946 } else {
35947 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
35948 (((cur_irq_sequence =
35949 - atomic_read(&cur_irq->irq_received)) -
35950 + atomic_read_unchecked(&cur_irq->irq_received)) -
35951 *sequence) <= (1 << 23)));
35952 }
35953 *sequence = cur_irq_sequence;
35954 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
35955 }
35956
35957 for (i = 0; i < dev_priv->num_irqs; ++i) {
35958 - atomic_set(&cur_irq->irq_received, 0);
35959 + atomic_set_unchecked(&cur_irq->irq_received, 0);
35960 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
35961 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
35962 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
35963 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
35964 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
35965 case VIA_IRQ_RELATIVE:
35966 irqwait->request.sequence +=
35967 - atomic_read(&cur_irq->irq_received);
35968 + atomic_read_unchecked(&cur_irq->irq_received);
35969 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
35970 case VIA_IRQ_ABSOLUTE:
35971 break;
35972 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35973 index 13aeda7..4a952d1 100644
35974 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35975 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35976 @@ -290,7 +290,7 @@ struct vmw_private {
35977 * Fencing and IRQs.
35978 */
35979
35980 - atomic_t marker_seq;
35981 + atomic_unchecked_t marker_seq;
35982 wait_queue_head_t fence_queue;
35983 wait_queue_head_t fifo_queue;
35984 int fence_queue_waiters; /* Protected by hw_mutex */
35985 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35986 index 3eb1486..0a47ee9 100644
35987 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35988 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35989 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
35990 (unsigned int) min,
35991 (unsigned int) fifo->capabilities);
35992
35993 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
35994 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
35995 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
35996 vmw_marker_queue_init(&fifo->marker_queue);
35997 return vmw_fifo_send_fence(dev_priv, &dummy);
35998 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
35999 if (reserveable)
36000 iowrite32(bytes, fifo_mem +
36001 SVGA_FIFO_RESERVED);
36002 - return fifo_mem + (next_cmd >> 2);
36003 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36004 } else {
36005 need_bounce = true;
36006 }
36007 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36008
36009 fm = vmw_fifo_reserve(dev_priv, bytes);
36010 if (unlikely(fm == NULL)) {
36011 - *seqno = atomic_read(&dev_priv->marker_seq);
36012 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36013 ret = -ENOMEM;
36014 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36015 false, 3*HZ);
36016 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36017 }
36018
36019 do {
36020 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36021 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36022 } while (*seqno == 0);
36023
36024 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36025 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36026 index 4640adb..e1384ed 100644
36027 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36028 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36029 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36030 * emitted. Then the fence is stale and signaled.
36031 */
36032
36033 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36034 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36035 > VMW_FENCE_WRAP);
36036
36037 return ret;
36038 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36039
36040 if (fifo_idle)
36041 down_read(&fifo_state->rwsem);
36042 - signal_seq = atomic_read(&dev_priv->marker_seq);
36043 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36044 ret = 0;
36045
36046 for (;;) {
36047 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36048 index 8a8725c..afed796 100644
36049 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36050 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36051 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36052 while (!vmw_lag_lt(queue, us)) {
36053 spin_lock(&queue->lock);
36054 if (list_empty(&queue->head))
36055 - seqno = atomic_read(&dev_priv->marker_seq);
36056 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36057 else {
36058 marker = list_first_entry(&queue->head,
36059 struct vmw_marker, head);
36060 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36061 index ceb3040..6160c5c 100644
36062 --- a/drivers/hid/hid-core.c
36063 +++ b/drivers/hid/hid-core.c
36064 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36065
36066 int hid_add_device(struct hid_device *hdev)
36067 {
36068 - static atomic_t id = ATOMIC_INIT(0);
36069 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36070 int ret;
36071
36072 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36073 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
36074 /* XXX hack, any other cleaner solution after the driver core
36075 * is converted to allow more than 20 bytes as the device name? */
36076 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36077 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36078 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36079
36080 hid_debug_register(hdev, dev_name(&hdev->dev));
36081 ret = device_add(&hdev->dev);
36082 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36083 index eec3291..8ed706b 100644
36084 --- a/drivers/hid/hid-wiimote-debug.c
36085 +++ b/drivers/hid/hid-wiimote-debug.c
36086 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36087 else if (size == 0)
36088 return -EIO;
36089
36090 - if (copy_to_user(u, buf, size))
36091 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36092 return -EFAULT;
36093
36094 *off += size;
36095 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36096 index 773a2f2..7ce08bc 100644
36097 --- a/drivers/hv/channel.c
36098 +++ b/drivers/hv/channel.c
36099 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36100 int ret = 0;
36101 int t;
36102
36103 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36104 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36105 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36106 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36107
36108 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36109 if (ret)
36110 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36111 index 3648f8f..30ef30d 100644
36112 --- a/drivers/hv/hv.c
36113 +++ b/drivers/hv/hv.c
36114 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36115 u64 output_address = (output) ? virt_to_phys(output) : 0;
36116 u32 output_address_hi = output_address >> 32;
36117 u32 output_address_lo = output_address & 0xFFFFFFFF;
36118 - void *hypercall_page = hv_context.hypercall_page;
36119 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36120
36121 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36122 "=a"(hv_status_lo) : "d" (control_hi),
36123 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36124 index d8d1fad..b91caf7 100644
36125 --- a/drivers/hv/hyperv_vmbus.h
36126 +++ b/drivers/hv/hyperv_vmbus.h
36127 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
36128 struct vmbus_connection {
36129 enum vmbus_connect_state conn_state;
36130
36131 - atomic_t next_gpadl_handle;
36132 + atomic_unchecked_t next_gpadl_handle;
36133
36134 /*
36135 * Represents channel interrupts. Each bit position represents a
36136 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36137 index 8e1a9ec..4687821 100644
36138 --- a/drivers/hv/vmbus_drv.c
36139 +++ b/drivers/hv/vmbus_drv.c
36140 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36141 {
36142 int ret = 0;
36143
36144 - static atomic_t device_num = ATOMIC_INIT(0);
36145 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36146
36147 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36148 - atomic_inc_return(&device_num));
36149 + atomic_inc_return_unchecked(&device_num));
36150
36151 child_device_obj->device.bus = &hv_bus;
36152 child_device_obj->device.parent = &hv_acpi_dev->dev;
36153 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36154 index 1672e2a..4a6297c 100644
36155 --- a/drivers/hwmon/acpi_power_meter.c
36156 +++ b/drivers/hwmon/acpi_power_meter.c
36157 @@ -117,7 +117,7 @@ struct sensor_template {
36158 struct device_attribute *devattr,
36159 const char *buf, size_t count);
36160 int index;
36161 -};
36162 +} __do_const;
36163
36164 /* Averaging interval */
36165 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36166 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36167 struct sensor_template *attrs)
36168 {
36169 struct device *dev = &resource->acpi_dev->dev;
36170 - struct sensor_device_attribute *sensors =
36171 + sensor_device_attribute_no_const *sensors =
36172 &resource->sensors[resource->num_sensors];
36173 int res = 0;
36174
36175 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36176 index b41baff..4953e4d 100644
36177 --- a/drivers/hwmon/applesmc.c
36178 +++ b/drivers/hwmon/applesmc.c
36179 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36180 {
36181 struct applesmc_node_group *grp;
36182 struct applesmc_dev_attr *node;
36183 - struct attribute *attr;
36184 + attribute_no_const *attr;
36185 int ret, i;
36186
36187 for (grp = groups; grp->format; grp++) {
36188 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36189 index 56dbcfb..9874bf1 100644
36190 --- a/drivers/hwmon/asus_atk0110.c
36191 +++ b/drivers/hwmon/asus_atk0110.c
36192 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36193 struct atk_sensor_data {
36194 struct list_head list;
36195 struct atk_data *data;
36196 - struct device_attribute label_attr;
36197 - struct device_attribute input_attr;
36198 - struct device_attribute limit1_attr;
36199 - struct device_attribute limit2_attr;
36200 + device_attribute_no_const label_attr;
36201 + device_attribute_no_const input_attr;
36202 + device_attribute_no_const limit1_attr;
36203 + device_attribute_no_const limit2_attr;
36204 char label_attr_name[ATTR_NAME_SIZE];
36205 char input_attr_name[ATTR_NAME_SIZE];
36206 char limit1_attr_name[ATTR_NAME_SIZE];
36207 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36208 static struct device_attribute atk_name_attr =
36209 __ATTR(name, 0444, atk_name_show, NULL);
36210
36211 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36212 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36213 sysfs_show_func show)
36214 {
36215 sysfs_attr_init(&attr->attr);
36216 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36217 index d64923d..72591e8 100644
36218 --- a/drivers/hwmon/coretemp.c
36219 +++ b/drivers/hwmon/coretemp.c
36220 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36221 return NOTIFY_OK;
36222 }
36223
36224 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36225 +static struct notifier_block coretemp_cpu_notifier = {
36226 .notifier_call = coretemp_cpu_callback,
36227 };
36228
36229 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36230 index a14f634..2916ee2 100644
36231 --- a/drivers/hwmon/ibmaem.c
36232 +++ b/drivers/hwmon/ibmaem.c
36233 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36234 struct aem_rw_sensor_template *rw)
36235 {
36236 struct device *dev = &data->pdev->dev;
36237 - struct sensor_device_attribute *sensors = data->sensors;
36238 + sensor_device_attribute_no_const *sensors = data->sensors;
36239 int err;
36240
36241 /* Set up read-only sensors */
36242 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36243 index 7d19b1b..8fdaaac 100644
36244 --- a/drivers/hwmon/pmbus/pmbus_core.c
36245 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36246 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
36247
36248 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
36249 do { \
36250 - struct sensor_device_attribute *a \
36251 + sensor_device_attribute_no_const *a \
36252 = &data->_type##s[data->num_##_type##s].attribute; \
36253 BUG_ON(data->num_attributes >= data->max_attributes); \
36254 sysfs_attr_init(&a->dev_attr.attr); \
36255 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36256 index 8047fed..1e956f0 100644
36257 --- a/drivers/hwmon/sht15.c
36258 +++ b/drivers/hwmon/sht15.c
36259 @@ -169,7 +169,7 @@ struct sht15_data {
36260 int supply_uV;
36261 bool supply_uV_valid;
36262 struct work_struct update_supply_work;
36263 - atomic_t interrupt_handled;
36264 + atomic_unchecked_t interrupt_handled;
36265 };
36266
36267 /**
36268 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
36269 return ret;
36270
36271 gpio_direction_input(data->pdata->gpio_data);
36272 - atomic_set(&data->interrupt_handled, 0);
36273 + atomic_set_unchecked(&data->interrupt_handled, 0);
36274
36275 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36276 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36277 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36278 /* Only relevant if the interrupt hasn't occurred. */
36279 - if (!atomic_read(&data->interrupt_handled))
36280 + if (!atomic_read_unchecked(&data->interrupt_handled))
36281 schedule_work(&data->read_work);
36282 }
36283 ret = wait_event_timeout(data->wait_queue,
36284 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36285
36286 /* First disable the interrupt */
36287 disable_irq_nosync(irq);
36288 - atomic_inc(&data->interrupt_handled);
36289 + atomic_inc_unchecked(&data->interrupt_handled);
36290 /* Then schedule a reading work struct */
36291 if (data->state != SHT15_READING_NOTHING)
36292 schedule_work(&data->read_work);
36293 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36294 * If not, then start the interrupt again - care here as could
36295 * have gone low in meantime so verify it hasn't!
36296 */
36297 - atomic_set(&data->interrupt_handled, 0);
36298 + atomic_set_unchecked(&data->interrupt_handled, 0);
36299 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36300 /* If still not occurred or another handler was scheduled */
36301 if (gpio_get_value(data->pdata->gpio_data)
36302 - || atomic_read(&data->interrupt_handled))
36303 + || atomic_read_unchecked(&data->interrupt_handled))
36304 return;
36305 }
36306
36307 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36308 index 76f157b..9c0db1b 100644
36309 --- a/drivers/hwmon/via-cputemp.c
36310 +++ b/drivers/hwmon/via-cputemp.c
36311 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36312 return NOTIFY_OK;
36313 }
36314
36315 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36316 +static struct notifier_block via_cputemp_cpu_notifier = {
36317 .notifier_call = via_cputemp_cpu_callback,
36318 };
36319
36320 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36321 index 378fcb5..5e91fa8 100644
36322 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36323 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36324 @@ -43,7 +43,7 @@
36325 extern struct i2c_adapter amd756_smbus;
36326
36327 static struct i2c_adapter *s4882_adapter;
36328 -static struct i2c_algorithm *s4882_algo;
36329 +static i2c_algorithm_no_const *s4882_algo;
36330
36331 /* Wrapper access functions for multiplexed SMBus */
36332 static DEFINE_MUTEX(amd756_lock);
36333 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36334 index 29015eb..af2d8e9 100644
36335 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36336 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36337 @@ -41,7 +41,7 @@
36338 extern struct i2c_adapter *nforce2_smbus;
36339
36340 static struct i2c_adapter *s4985_adapter;
36341 -static struct i2c_algorithm *s4985_algo;
36342 +static i2c_algorithm_no_const *s4985_algo;
36343
36344 /* Wrapper access functions for multiplexed SMBus */
36345 static DEFINE_MUTEX(nforce2_lock);
36346 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36347 index 8126824..55a2798 100644
36348 --- a/drivers/ide/ide-cd.c
36349 +++ b/drivers/ide/ide-cd.c
36350 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36351 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36352 if ((unsigned long)buf & alignment
36353 || blk_rq_bytes(rq) & q->dma_pad_mask
36354 - || object_is_on_stack(buf))
36355 + || object_starts_on_stack(buf))
36356 drive->dma = 0;
36357 }
36358 }
36359 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36360 index 8848f16..f8e6dd8 100644
36361 --- a/drivers/iio/industrialio-core.c
36362 +++ b/drivers/iio/industrialio-core.c
36363 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36364 }
36365
36366 static
36367 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36368 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36369 const char *postfix,
36370 struct iio_chan_spec const *chan,
36371 ssize_t (*readfunc)(struct device *dev,
36372 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36373 index 394fea2..c833880 100644
36374 --- a/drivers/infiniband/core/cm.c
36375 +++ b/drivers/infiniband/core/cm.c
36376 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36377
36378 struct cm_counter_group {
36379 struct kobject obj;
36380 - atomic_long_t counter[CM_ATTR_COUNT];
36381 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36382 };
36383
36384 struct cm_counter_attribute {
36385 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36386 struct ib_mad_send_buf *msg = NULL;
36387 int ret;
36388
36389 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36390 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36391 counter[CM_REQ_COUNTER]);
36392
36393 /* Quick state check to discard duplicate REQs. */
36394 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36395 if (!cm_id_priv)
36396 return;
36397
36398 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36399 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36400 counter[CM_REP_COUNTER]);
36401 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36402 if (ret)
36403 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
36404 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36405 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36406 spin_unlock_irq(&cm_id_priv->lock);
36407 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36408 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36409 counter[CM_RTU_COUNTER]);
36410 goto out;
36411 }
36412 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
36413 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36414 dreq_msg->local_comm_id);
36415 if (!cm_id_priv) {
36416 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36417 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36418 counter[CM_DREQ_COUNTER]);
36419 cm_issue_drep(work->port, work->mad_recv_wc);
36420 return -EINVAL;
36421 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
36422 case IB_CM_MRA_REP_RCVD:
36423 break;
36424 case IB_CM_TIMEWAIT:
36425 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36426 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36427 counter[CM_DREQ_COUNTER]);
36428 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36429 goto unlock;
36430 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
36431 cm_free_msg(msg);
36432 goto deref;
36433 case IB_CM_DREQ_RCVD:
36434 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36435 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36436 counter[CM_DREQ_COUNTER]);
36437 goto unlock;
36438 default:
36439 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
36440 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36441 cm_id_priv->msg, timeout)) {
36442 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36443 - atomic_long_inc(&work->port->
36444 + atomic_long_inc_unchecked(&work->port->
36445 counter_group[CM_RECV_DUPLICATES].
36446 counter[CM_MRA_COUNTER]);
36447 goto out;
36448 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
36449 break;
36450 case IB_CM_MRA_REQ_RCVD:
36451 case IB_CM_MRA_REP_RCVD:
36452 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36453 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36454 counter[CM_MRA_COUNTER]);
36455 /* fall through */
36456 default:
36457 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
36458 case IB_CM_LAP_IDLE:
36459 break;
36460 case IB_CM_MRA_LAP_SENT:
36461 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36462 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36463 counter[CM_LAP_COUNTER]);
36464 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36465 goto unlock;
36466 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
36467 cm_free_msg(msg);
36468 goto deref;
36469 case IB_CM_LAP_RCVD:
36470 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36471 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36472 counter[CM_LAP_COUNTER]);
36473 goto unlock;
36474 default:
36475 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36476 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36477 if (cur_cm_id_priv) {
36478 spin_unlock_irq(&cm.lock);
36479 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36480 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36481 counter[CM_SIDR_REQ_COUNTER]);
36482 goto out; /* Duplicate message. */
36483 }
36484 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36485 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36486 msg->retries = 1;
36487
36488 - atomic_long_add(1 + msg->retries,
36489 + atomic_long_add_unchecked(1 + msg->retries,
36490 &port->counter_group[CM_XMIT].counter[attr_index]);
36491 if (msg->retries)
36492 - atomic_long_add(msg->retries,
36493 + atomic_long_add_unchecked(msg->retries,
36494 &port->counter_group[CM_XMIT_RETRIES].
36495 counter[attr_index]);
36496
36497 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36498 }
36499
36500 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36501 - atomic_long_inc(&port->counter_group[CM_RECV].
36502 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36503 counter[attr_id - CM_ATTR_ID_OFFSET]);
36504
36505 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36506 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36507 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36508
36509 return sprintf(buf, "%ld\n",
36510 - atomic_long_read(&group->counter[cm_attr->index]));
36511 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36512 }
36513
36514 static const struct sysfs_ops cm_counter_ops = {
36515 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36516 index 176c8f9..2627b62 100644
36517 --- a/drivers/infiniband/core/fmr_pool.c
36518 +++ b/drivers/infiniband/core/fmr_pool.c
36519 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36520
36521 struct task_struct *thread;
36522
36523 - atomic_t req_ser;
36524 - atomic_t flush_ser;
36525 + atomic_unchecked_t req_ser;
36526 + atomic_unchecked_t flush_ser;
36527
36528 wait_queue_head_t force_wait;
36529 };
36530 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36531 struct ib_fmr_pool *pool = pool_ptr;
36532
36533 do {
36534 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36535 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36536 ib_fmr_batch_release(pool);
36537
36538 - atomic_inc(&pool->flush_ser);
36539 + atomic_inc_unchecked(&pool->flush_ser);
36540 wake_up_interruptible(&pool->force_wait);
36541
36542 if (pool->flush_function)
36543 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36544 }
36545
36546 set_current_state(TASK_INTERRUPTIBLE);
36547 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36548 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36549 !kthread_should_stop())
36550 schedule();
36551 __set_current_state(TASK_RUNNING);
36552 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36553 pool->dirty_watermark = params->dirty_watermark;
36554 pool->dirty_len = 0;
36555 spin_lock_init(&pool->pool_lock);
36556 - atomic_set(&pool->req_ser, 0);
36557 - atomic_set(&pool->flush_ser, 0);
36558 + atomic_set_unchecked(&pool->req_ser, 0);
36559 + atomic_set_unchecked(&pool->flush_ser, 0);
36560 init_waitqueue_head(&pool->force_wait);
36561
36562 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36563 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36564 }
36565 spin_unlock_irq(&pool->pool_lock);
36566
36567 - serial = atomic_inc_return(&pool->req_ser);
36568 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36569 wake_up_process(pool->thread);
36570
36571 if (wait_event_interruptible(pool->force_wait,
36572 - atomic_read(&pool->flush_ser) - serial >= 0))
36573 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36574 return -EINTR;
36575
36576 return 0;
36577 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36578 } else {
36579 list_add_tail(&fmr->list, &pool->dirty_list);
36580 if (++pool->dirty_len >= pool->dirty_watermark) {
36581 - atomic_inc(&pool->req_ser);
36582 + atomic_inc_unchecked(&pool->req_ser);
36583 wake_up_process(pool->thread);
36584 }
36585 }
36586 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36587 index afd8179..598063f 100644
36588 --- a/drivers/infiniband/hw/cxgb4/mem.c
36589 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36590 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36591 int err;
36592 struct fw_ri_tpte tpt;
36593 u32 stag_idx;
36594 - static atomic_t key;
36595 + static atomic_unchecked_t key;
36596
36597 if (c4iw_fatal_error(rdev))
36598 return -EIO;
36599 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36600 if (rdev->stats.stag.cur > rdev->stats.stag.max)
36601 rdev->stats.stag.max = rdev->stats.stag.cur;
36602 mutex_unlock(&rdev->stats.lock);
36603 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
36604 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
36605 }
36606 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
36607 __func__, stag_state, type, pdid, stag_idx);
36608 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
36609 index 79b3dbc..96e5fcc 100644
36610 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
36611 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
36612 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36613 struct ib_atomic_eth *ateth;
36614 struct ipath_ack_entry *e;
36615 u64 vaddr;
36616 - atomic64_t *maddr;
36617 + atomic64_unchecked_t *maddr;
36618 u64 sdata;
36619 u32 rkey;
36620 u8 next;
36621 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36622 IB_ACCESS_REMOTE_ATOMIC)))
36623 goto nack_acc_unlck;
36624 /* Perform atomic OP and save result. */
36625 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36626 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36627 sdata = be64_to_cpu(ateth->swap_data);
36628 e = &qp->s_ack_queue[qp->r_head_ack_queue];
36629 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
36630 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36631 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36632 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36633 be64_to_cpu(ateth->compare_data),
36634 sdata);
36635 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
36636 index 1f95bba..9530f87 100644
36637 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
36638 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
36639 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
36640 unsigned long flags;
36641 struct ib_wc wc;
36642 u64 sdata;
36643 - atomic64_t *maddr;
36644 + atomic64_unchecked_t *maddr;
36645 enum ib_wc_status send_status;
36646
36647 /*
36648 @@ -382,11 +382,11 @@ again:
36649 IB_ACCESS_REMOTE_ATOMIC)))
36650 goto acc_err;
36651 /* Perform atomic OP and save result. */
36652 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36653 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36654 sdata = wqe->wr.wr.atomic.compare_add;
36655 *(u64 *) sqp->s_sge.sge.vaddr =
36656 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
36657 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36658 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36659 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36660 sdata, wqe->wr.wr.atomic.swap);
36661 goto send_comp;
36662 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
36663 index 9d3e5c1..d9afe4a 100644
36664 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
36665 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
36666 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
36667 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
36668 }
36669
36670 -int mthca_QUERY_FW(struct mthca_dev *dev)
36671 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
36672 {
36673 struct mthca_mailbox *mailbox;
36674 u32 *outbox;
36675 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
36676 index ed9a989..e0c5871 100644
36677 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
36678 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
36679 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
36680 return key;
36681 }
36682
36683 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36684 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36685 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
36686 {
36687 struct mthca_mailbox *mailbox;
36688 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
36689 index 5b152a3..c1f3e83 100644
36690 --- a/drivers/infiniband/hw/nes/nes.c
36691 +++ b/drivers/infiniband/hw/nes/nes.c
36692 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
36693 LIST_HEAD(nes_adapter_list);
36694 static LIST_HEAD(nes_dev_list);
36695
36696 -atomic_t qps_destroyed;
36697 +atomic_unchecked_t qps_destroyed;
36698
36699 static unsigned int ee_flsh_adapter;
36700 static unsigned int sysfs_nonidx_addr;
36701 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
36702 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
36703 struct nes_adapter *nesadapter = nesdev->nesadapter;
36704
36705 - atomic_inc(&qps_destroyed);
36706 + atomic_inc_unchecked(&qps_destroyed);
36707
36708 /* Free the control structures */
36709
36710 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
36711 index 33cc589..3bd6538 100644
36712 --- a/drivers/infiniband/hw/nes/nes.h
36713 +++ b/drivers/infiniband/hw/nes/nes.h
36714 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
36715 extern unsigned int wqm_quanta;
36716 extern struct list_head nes_adapter_list;
36717
36718 -extern atomic_t cm_connects;
36719 -extern atomic_t cm_accepts;
36720 -extern atomic_t cm_disconnects;
36721 -extern atomic_t cm_closes;
36722 -extern atomic_t cm_connecteds;
36723 -extern atomic_t cm_connect_reqs;
36724 -extern atomic_t cm_rejects;
36725 -extern atomic_t mod_qp_timouts;
36726 -extern atomic_t qps_created;
36727 -extern atomic_t qps_destroyed;
36728 -extern atomic_t sw_qps_destroyed;
36729 +extern atomic_unchecked_t cm_connects;
36730 +extern atomic_unchecked_t cm_accepts;
36731 +extern atomic_unchecked_t cm_disconnects;
36732 +extern atomic_unchecked_t cm_closes;
36733 +extern atomic_unchecked_t cm_connecteds;
36734 +extern atomic_unchecked_t cm_connect_reqs;
36735 +extern atomic_unchecked_t cm_rejects;
36736 +extern atomic_unchecked_t mod_qp_timouts;
36737 +extern atomic_unchecked_t qps_created;
36738 +extern atomic_unchecked_t qps_destroyed;
36739 +extern atomic_unchecked_t sw_qps_destroyed;
36740 extern u32 mh_detected;
36741 extern u32 mh_pauses_sent;
36742 extern u32 cm_packets_sent;
36743 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
36744 extern u32 cm_packets_received;
36745 extern u32 cm_packets_dropped;
36746 extern u32 cm_packets_retrans;
36747 -extern atomic_t cm_listens_created;
36748 -extern atomic_t cm_listens_destroyed;
36749 +extern atomic_unchecked_t cm_listens_created;
36750 +extern atomic_unchecked_t cm_listens_destroyed;
36751 extern u32 cm_backlog_drops;
36752 -extern atomic_t cm_loopbacks;
36753 -extern atomic_t cm_nodes_created;
36754 -extern atomic_t cm_nodes_destroyed;
36755 -extern atomic_t cm_accel_dropped_pkts;
36756 -extern atomic_t cm_resets_recvd;
36757 -extern atomic_t pau_qps_created;
36758 -extern atomic_t pau_qps_destroyed;
36759 +extern atomic_unchecked_t cm_loopbacks;
36760 +extern atomic_unchecked_t cm_nodes_created;
36761 +extern atomic_unchecked_t cm_nodes_destroyed;
36762 +extern atomic_unchecked_t cm_accel_dropped_pkts;
36763 +extern atomic_unchecked_t cm_resets_recvd;
36764 +extern atomic_unchecked_t pau_qps_created;
36765 +extern atomic_unchecked_t pau_qps_destroyed;
36766
36767 extern u32 int_mod_timer_init;
36768 extern u32 int_mod_cq_depth_256;
36769 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
36770 index 22ea67e..dcbe3bc 100644
36771 --- a/drivers/infiniband/hw/nes/nes_cm.c
36772 +++ b/drivers/infiniband/hw/nes/nes_cm.c
36773 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
36774 u32 cm_packets_retrans;
36775 u32 cm_packets_created;
36776 u32 cm_packets_received;
36777 -atomic_t cm_listens_created;
36778 -atomic_t cm_listens_destroyed;
36779 +atomic_unchecked_t cm_listens_created;
36780 +atomic_unchecked_t cm_listens_destroyed;
36781 u32 cm_backlog_drops;
36782 -atomic_t cm_loopbacks;
36783 -atomic_t cm_nodes_created;
36784 -atomic_t cm_nodes_destroyed;
36785 -atomic_t cm_accel_dropped_pkts;
36786 -atomic_t cm_resets_recvd;
36787 +atomic_unchecked_t cm_loopbacks;
36788 +atomic_unchecked_t cm_nodes_created;
36789 +atomic_unchecked_t cm_nodes_destroyed;
36790 +atomic_unchecked_t cm_accel_dropped_pkts;
36791 +atomic_unchecked_t cm_resets_recvd;
36792
36793 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
36794 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
36795 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
36796
36797 static struct nes_cm_core *g_cm_core;
36798
36799 -atomic_t cm_connects;
36800 -atomic_t cm_accepts;
36801 -atomic_t cm_disconnects;
36802 -atomic_t cm_closes;
36803 -atomic_t cm_connecteds;
36804 -atomic_t cm_connect_reqs;
36805 -atomic_t cm_rejects;
36806 +atomic_unchecked_t cm_connects;
36807 +atomic_unchecked_t cm_accepts;
36808 +atomic_unchecked_t cm_disconnects;
36809 +atomic_unchecked_t cm_closes;
36810 +atomic_unchecked_t cm_connecteds;
36811 +atomic_unchecked_t cm_connect_reqs;
36812 +atomic_unchecked_t cm_rejects;
36813
36814 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
36815 {
36816 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
36817 kfree(listener);
36818 listener = NULL;
36819 ret = 0;
36820 - atomic_inc(&cm_listens_destroyed);
36821 + atomic_inc_unchecked(&cm_listens_destroyed);
36822 } else {
36823 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
36824 }
36825 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
36826 cm_node->rem_mac);
36827
36828 add_hte_node(cm_core, cm_node);
36829 - atomic_inc(&cm_nodes_created);
36830 + atomic_inc_unchecked(&cm_nodes_created);
36831
36832 return cm_node;
36833 }
36834 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
36835 }
36836
36837 atomic_dec(&cm_core->node_cnt);
36838 - atomic_inc(&cm_nodes_destroyed);
36839 + atomic_inc_unchecked(&cm_nodes_destroyed);
36840 nesqp = cm_node->nesqp;
36841 if (nesqp) {
36842 nesqp->cm_node = NULL;
36843 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
36844
36845 static void drop_packet(struct sk_buff *skb)
36846 {
36847 - atomic_inc(&cm_accel_dropped_pkts);
36848 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
36849 dev_kfree_skb_any(skb);
36850 }
36851
36852 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
36853 {
36854
36855 int reset = 0; /* whether to send reset in case of err.. */
36856 - atomic_inc(&cm_resets_recvd);
36857 + atomic_inc_unchecked(&cm_resets_recvd);
36858 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
36859 " refcnt=%d\n", cm_node, cm_node->state,
36860 atomic_read(&cm_node->ref_count));
36861 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
36862 rem_ref_cm_node(cm_node->cm_core, cm_node);
36863 return NULL;
36864 }
36865 - atomic_inc(&cm_loopbacks);
36866 + atomic_inc_unchecked(&cm_loopbacks);
36867 loopbackremotenode->loopbackpartner = cm_node;
36868 loopbackremotenode->tcp_cntxt.rcv_wscale =
36869 NES_CM_DEFAULT_RCV_WND_SCALE;
36870 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
36871 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
36872 else {
36873 rem_ref_cm_node(cm_core, cm_node);
36874 - atomic_inc(&cm_accel_dropped_pkts);
36875 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
36876 dev_kfree_skb_any(skb);
36877 }
36878 break;
36879 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
36880
36881 if ((cm_id) && (cm_id->event_handler)) {
36882 if (issue_disconn) {
36883 - atomic_inc(&cm_disconnects);
36884 + atomic_inc_unchecked(&cm_disconnects);
36885 cm_event.event = IW_CM_EVENT_DISCONNECT;
36886 cm_event.status = disconn_status;
36887 cm_event.local_addr = cm_id->local_addr;
36888 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
36889 }
36890
36891 if (issue_close) {
36892 - atomic_inc(&cm_closes);
36893 + atomic_inc_unchecked(&cm_closes);
36894 nes_disconnect(nesqp, 1);
36895
36896 cm_id->provider_data = nesqp;
36897 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
36898
36899 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
36900 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
36901 - atomic_inc(&cm_accepts);
36902 + atomic_inc_unchecked(&cm_accepts);
36903
36904 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
36905 netdev_refcnt_read(nesvnic->netdev));
36906 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
36907 struct nes_cm_core *cm_core;
36908 u8 *start_buff;
36909
36910 - atomic_inc(&cm_rejects);
36911 + atomic_inc_unchecked(&cm_rejects);
36912 cm_node = (struct nes_cm_node *)cm_id->provider_data;
36913 loopback = cm_node->loopbackpartner;
36914 cm_core = cm_node->cm_core;
36915 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
36916 ntohl(cm_id->local_addr.sin_addr.s_addr),
36917 ntohs(cm_id->local_addr.sin_port));
36918
36919 - atomic_inc(&cm_connects);
36920 + atomic_inc_unchecked(&cm_connects);
36921 nesqp->active_conn = 1;
36922
36923 /* cache the cm_id in the qp */
36924 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
36925 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
36926 return err;
36927 }
36928 - atomic_inc(&cm_listens_created);
36929 + atomic_inc_unchecked(&cm_listens_created);
36930 }
36931
36932 cm_id->add_ref(cm_id);
36933 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
36934
36935 if (nesqp->destroyed)
36936 return;
36937 - atomic_inc(&cm_connecteds);
36938 + atomic_inc_unchecked(&cm_connecteds);
36939 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
36940 " local port 0x%04X. jiffies = %lu.\n",
36941 nesqp->hwqp.qp_id,
36942 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
36943
36944 cm_id->add_ref(cm_id);
36945 ret = cm_id->event_handler(cm_id, &cm_event);
36946 - atomic_inc(&cm_closes);
36947 + atomic_inc_unchecked(&cm_closes);
36948 cm_event.event = IW_CM_EVENT_CLOSE;
36949 cm_event.status = 0;
36950 cm_event.provider_data = cm_id->provider_data;
36951 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
36952 return;
36953 cm_id = cm_node->cm_id;
36954
36955 - atomic_inc(&cm_connect_reqs);
36956 + atomic_inc_unchecked(&cm_connect_reqs);
36957 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
36958 cm_node, cm_id, jiffies);
36959
36960 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
36961 return;
36962 cm_id = cm_node->cm_id;
36963
36964 - atomic_inc(&cm_connect_reqs);
36965 + atomic_inc_unchecked(&cm_connect_reqs);
36966 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
36967 cm_node, cm_id, jiffies);
36968
36969 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
36970 index 4166452..fc952c3 100644
36971 --- a/drivers/infiniband/hw/nes/nes_mgt.c
36972 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
36973 @@ -40,8 +40,8 @@
36974 #include "nes.h"
36975 #include "nes_mgt.h"
36976
36977 -atomic_t pau_qps_created;
36978 -atomic_t pau_qps_destroyed;
36979 +atomic_unchecked_t pau_qps_created;
36980 +atomic_unchecked_t pau_qps_destroyed;
36981
36982 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
36983 {
36984 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
36985 {
36986 struct sk_buff *skb;
36987 unsigned long flags;
36988 - atomic_inc(&pau_qps_destroyed);
36989 + atomic_inc_unchecked(&pau_qps_destroyed);
36990
36991 /* Free packets that have not yet been forwarded */
36992 /* Lock is acquired by skb_dequeue when removing the skb */
36993 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
36994 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
36995 skb_queue_head_init(&nesqp->pau_list);
36996 spin_lock_init(&nesqp->pau_lock);
36997 - atomic_inc(&pau_qps_created);
36998 + atomic_inc_unchecked(&pau_qps_created);
36999 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37000 }
37001
37002 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37003 index 9542e16..a008c40 100644
37004 --- a/drivers/infiniband/hw/nes/nes_nic.c
37005 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37006 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37007 target_stat_values[++index] = mh_detected;
37008 target_stat_values[++index] = mh_pauses_sent;
37009 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37010 - target_stat_values[++index] = atomic_read(&cm_connects);
37011 - target_stat_values[++index] = atomic_read(&cm_accepts);
37012 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37013 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37014 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37015 - target_stat_values[++index] = atomic_read(&cm_rejects);
37016 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37017 - target_stat_values[++index] = atomic_read(&qps_created);
37018 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37019 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37020 - target_stat_values[++index] = atomic_read(&cm_closes);
37021 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37022 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37023 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37024 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37025 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37026 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37027 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37028 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37029 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37030 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37031 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37032 target_stat_values[++index] = cm_packets_sent;
37033 target_stat_values[++index] = cm_packets_bounced;
37034 target_stat_values[++index] = cm_packets_created;
37035 target_stat_values[++index] = cm_packets_received;
37036 target_stat_values[++index] = cm_packets_dropped;
37037 target_stat_values[++index] = cm_packets_retrans;
37038 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37039 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37040 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37041 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37042 target_stat_values[++index] = cm_backlog_drops;
37043 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37044 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37045 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37046 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37047 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37048 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37049 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37050 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37051 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37052 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37053 target_stat_values[++index] = nesadapter->free_4kpbl;
37054 target_stat_values[++index] = nesadapter->free_256pbl;
37055 target_stat_values[++index] = int_mod_timer_init;
37056 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37057 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37058 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37059 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37060 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37061 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37062 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37063 }
37064
37065 /**
37066 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37067 index 07e4fba..685f041 100644
37068 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37069 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37070 @@ -46,9 +46,9 @@
37071
37072 #include <rdma/ib_umem.h>
37073
37074 -atomic_t mod_qp_timouts;
37075 -atomic_t qps_created;
37076 -atomic_t sw_qps_destroyed;
37077 +atomic_unchecked_t mod_qp_timouts;
37078 +atomic_unchecked_t qps_created;
37079 +atomic_unchecked_t sw_qps_destroyed;
37080
37081 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37082
37083 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37084 if (init_attr->create_flags)
37085 return ERR_PTR(-EINVAL);
37086
37087 - atomic_inc(&qps_created);
37088 + atomic_inc_unchecked(&qps_created);
37089 switch (init_attr->qp_type) {
37090 case IB_QPT_RC:
37091 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37092 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37093 struct iw_cm_event cm_event;
37094 int ret = 0;
37095
37096 - atomic_inc(&sw_qps_destroyed);
37097 + atomic_inc_unchecked(&sw_qps_destroyed);
37098 nesqp->destroyed = 1;
37099
37100 /* Blow away the connection if it exists. */
37101 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37102 index 4d11575..3e890e5 100644
37103 --- a/drivers/infiniband/hw/qib/qib.h
37104 +++ b/drivers/infiniband/hw/qib/qib.h
37105 @@ -51,6 +51,7 @@
37106 #include <linux/completion.h>
37107 #include <linux/kref.h>
37108 #include <linux/sched.h>
37109 +#include <linux/slab.h>
37110
37111 #include "qib_common.h"
37112 #include "qib_verbs.h"
37113 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37114 index da739d9..da1c7f4 100644
37115 --- a/drivers/input/gameport/gameport.c
37116 +++ b/drivers/input/gameport/gameport.c
37117 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37118 */
37119 static void gameport_init_port(struct gameport *gameport)
37120 {
37121 - static atomic_t gameport_no = ATOMIC_INIT(0);
37122 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37123
37124 __module_get(THIS_MODULE);
37125
37126 mutex_init(&gameport->drv_mutex);
37127 device_initialize(&gameport->dev);
37128 dev_set_name(&gameport->dev, "gameport%lu",
37129 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37130 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37131 gameport->dev.bus = &gameport_bus;
37132 gameport->dev.release = gameport_release_port;
37133 if (gameport->parent)
37134 diff --git a/drivers/input/input.c b/drivers/input/input.c
37135 index c044699..174d71a 100644
37136 --- a/drivers/input/input.c
37137 +++ b/drivers/input/input.c
37138 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37139 */
37140 int input_register_device(struct input_dev *dev)
37141 {
37142 - static atomic_t input_no = ATOMIC_INIT(0);
37143 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37144 struct input_devres *devres = NULL;
37145 struct input_handler *handler;
37146 unsigned int packet_size;
37147 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37148 dev->setkeycode = input_default_setkeycode;
37149
37150 dev_set_name(&dev->dev, "input%ld",
37151 - (unsigned long) atomic_inc_return(&input_no) - 1);
37152 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37153
37154 error = device_add(&dev->dev);
37155 if (error)
37156 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37157 index 04c69af..5f92d00 100644
37158 --- a/drivers/input/joystick/sidewinder.c
37159 +++ b/drivers/input/joystick/sidewinder.c
37160 @@ -30,6 +30,7 @@
37161 #include <linux/kernel.h>
37162 #include <linux/module.h>
37163 #include <linux/slab.h>
37164 +#include <linux/sched.h>
37165 #include <linux/init.h>
37166 #include <linux/input.h>
37167 #include <linux/gameport.h>
37168 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37169 index d6cbfe9..6225402 100644
37170 --- a/drivers/input/joystick/xpad.c
37171 +++ b/drivers/input/joystick/xpad.c
37172 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37173
37174 static int xpad_led_probe(struct usb_xpad *xpad)
37175 {
37176 - static atomic_t led_seq = ATOMIC_INIT(0);
37177 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37178 long led_no;
37179 struct xpad_led *led;
37180 struct led_classdev *led_cdev;
37181 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37182 if (!led)
37183 return -ENOMEM;
37184
37185 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37186 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37187
37188 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37189 led->xpad = xpad;
37190 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37191 index fe1df23..5b710f3 100644
37192 --- a/drivers/input/mouse/psmouse.h
37193 +++ b/drivers/input/mouse/psmouse.h
37194 @@ -115,7 +115,7 @@ struct psmouse_attribute {
37195 ssize_t (*set)(struct psmouse *psmouse, void *data,
37196 const char *buf, size_t count);
37197 bool protect;
37198 -};
37199 +} __do_const;
37200 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37201
37202 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37203 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37204 index 4c842c3..590b0bf 100644
37205 --- a/drivers/input/mousedev.c
37206 +++ b/drivers/input/mousedev.c
37207 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37208
37209 spin_unlock_irq(&client->packet_lock);
37210
37211 - if (copy_to_user(buffer, data, count))
37212 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37213 return -EFAULT;
37214
37215 return count;
37216 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37217 index 25fc597..558bf3b 100644
37218 --- a/drivers/input/serio/serio.c
37219 +++ b/drivers/input/serio/serio.c
37220 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37221 */
37222 static void serio_init_port(struct serio *serio)
37223 {
37224 - static atomic_t serio_no = ATOMIC_INIT(0);
37225 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37226
37227 __module_get(THIS_MODULE);
37228
37229 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37230 mutex_init(&serio->drv_mutex);
37231 device_initialize(&serio->dev);
37232 dev_set_name(&serio->dev, "serio%ld",
37233 - (long)atomic_inc_return(&serio_no) - 1);
37234 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37235 serio->dev.bus = &serio_bus;
37236 serio->dev.release = serio_release_port;
37237 serio->dev.groups = serio_device_attr_groups;
37238 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37239 index ddbdaca..be18a78 100644
37240 --- a/drivers/iommu/iommu.c
37241 +++ b/drivers/iommu/iommu.c
37242 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37243 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37244 {
37245 bus_register_notifier(bus, &iommu_bus_nb);
37246 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37247 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37248 }
37249
37250 /**
37251 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37252 index 89562a8..218999b 100644
37253 --- a/drivers/isdn/capi/capi.c
37254 +++ b/drivers/isdn/capi/capi.c
37255 @@ -81,8 +81,8 @@ struct capiminor {
37256
37257 struct capi20_appl *ap;
37258 u32 ncci;
37259 - atomic_t datahandle;
37260 - atomic_t msgid;
37261 + atomic_unchecked_t datahandle;
37262 + atomic_unchecked_t msgid;
37263
37264 struct tty_port port;
37265 int ttyinstop;
37266 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37267 capimsg_setu16(s, 2, mp->ap->applid);
37268 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37269 capimsg_setu8 (s, 5, CAPI_RESP);
37270 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37271 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37272 capimsg_setu32(s, 8, mp->ncci);
37273 capimsg_setu16(s, 12, datahandle);
37274 }
37275 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37276 mp->outbytes -= len;
37277 spin_unlock_bh(&mp->outlock);
37278
37279 - datahandle = atomic_inc_return(&mp->datahandle);
37280 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37281 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37282 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37283 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37284 capimsg_setu16(skb->data, 2, mp->ap->applid);
37285 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37286 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37287 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37288 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37289 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37290 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37291 capimsg_setu16(skb->data, 16, len); /* Data length */
37292 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37293 index 67abf3f..076b3a6 100644
37294 --- a/drivers/isdn/gigaset/interface.c
37295 +++ b/drivers/isdn/gigaset/interface.c
37296 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37297 }
37298 tty->driver_data = cs;
37299
37300 - ++cs->port.count;
37301 + atomic_inc(&cs->port.count);
37302
37303 - if (cs->port.count == 1) {
37304 + if (atomic_read(&cs->port.count) == 1) {
37305 tty_port_tty_set(&cs->port, tty);
37306 tty->low_latency = 1;
37307 }
37308 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37309
37310 if (!cs->connected)
37311 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37312 - else if (!cs->port.count)
37313 + else if (!atomic_read(&cs->port.count))
37314 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37315 - else if (!--cs->port.count)
37316 + else if (!atomic_dec_return(&cs->port.count))
37317 tty_port_tty_set(&cs->port, NULL);
37318
37319 mutex_unlock(&cs->mutex);
37320 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37321 index 821f7ac..28d4030 100644
37322 --- a/drivers/isdn/hardware/avm/b1.c
37323 +++ b/drivers/isdn/hardware/avm/b1.c
37324 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37325 }
37326 if (left) {
37327 if (t4file->user) {
37328 - if (copy_from_user(buf, dp, left))
37329 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37330 return -EFAULT;
37331 } else {
37332 memcpy(buf, dp, left);
37333 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37334 }
37335 if (left) {
37336 if (config->user) {
37337 - if (copy_from_user(buf, dp, left))
37338 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37339 return -EFAULT;
37340 } else {
37341 memcpy(buf, dp, left);
37342 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37343 index e09dc8a..15e2efb 100644
37344 --- a/drivers/isdn/i4l/isdn_tty.c
37345 +++ b/drivers/isdn/i4l/isdn_tty.c
37346 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37347
37348 #ifdef ISDN_DEBUG_MODEM_OPEN
37349 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37350 - port->count);
37351 + atomic_read(&port->count));
37352 #endif
37353 - port->count++;
37354 + atomic_inc(&port->count);
37355 port->tty = tty;
37356 /*
37357 * Start up serial port
37358 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37359 #endif
37360 return;
37361 }
37362 - if ((tty->count == 1) && (port->count != 1)) {
37363 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37364 /*
37365 * Uh, oh. tty->count is 1, which means that the tty
37366 * structure will be freed. Info->count should always
37367 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37368 * serial port won't be shutdown.
37369 */
37370 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37371 - "info->count is %d\n", port->count);
37372 - port->count = 1;
37373 + "info->count is %d\n", atomic_read(&port->count));
37374 + atomic_set(&port->count, 1);
37375 }
37376 - if (--port->count < 0) {
37377 + if (atomic_dec_return(&port->count) < 0) {
37378 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37379 - info->line, port->count);
37380 - port->count = 0;
37381 + info->line, atomic_read(&port->count));
37382 + atomic_set(&port->count, 0);
37383 }
37384 - if (port->count) {
37385 + if (atomic_read(&port->count)) {
37386 #ifdef ISDN_DEBUG_MODEM_OPEN
37387 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37388 #endif
37389 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37390 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37391 return;
37392 isdn_tty_shutdown(info);
37393 - port->count = 0;
37394 + atomic_set(&port->count, 0);
37395 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37396 port->tty = NULL;
37397 wake_up_interruptible(&port->open_wait);
37398 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37399 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37400 modem_info *info = &dev->mdm.info[i];
37401
37402 - if (info->port.count == 0)
37403 + if (atomic_read(&info->port.count) == 0)
37404 continue;
37405 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37406 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37407 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37408 index e74df7c..03a03ba 100644
37409 --- a/drivers/isdn/icn/icn.c
37410 +++ b/drivers/isdn/icn/icn.c
37411 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37412 if (count > len)
37413 count = len;
37414 if (user) {
37415 - if (copy_from_user(msg, buf, count))
37416 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37417 return -EFAULT;
37418 } else
37419 memcpy(msg, buf, count);
37420 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37421 index 6a8405d..0bd1c7e 100644
37422 --- a/drivers/leds/leds-clevo-mail.c
37423 +++ b/drivers/leds/leds-clevo-mail.c
37424 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37425 * detected as working, but in reality it is not) as low as
37426 * possible.
37427 */
37428 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37429 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37430 {
37431 .callback = clevo_mail_led_dmi_callback,
37432 .ident = "Clevo D410J",
37433 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37434 index ec9b287..65c9bf4 100644
37435 --- a/drivers/leds/leds-ss4200.c
37436 +++ b/drivers/leds/leds-ss4200.c
37437 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37438 * detected as working, but in reality it is not) as low as
37439 * possible.
37440 */
37441 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37442 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37443 {
37444 .callback = ss4200_led_dmi_callback,
37445 .ident = "Intel SS4200-E",
37446 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37447 index a5ebc00..982886f 100644
37448 --- a/drivers/lguest/core.c
37449 +++ b/drivers/lguest/core.c
37450 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37451 * it's worked so far. The end address needs +1 because __get_vm_area
37452 * allocates an extra guard page, so we need space for that.
37453 */
37454 +
37455 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37456 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37457 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37458 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37459 +#else
37460 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37461 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37462 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37463 +#endif
37464 +
37465 if (!switcher_vma) {
37466 err = -ENOMEM;
37467 printk("lguest: could not map switcher pages high\n");
37468 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37469 * Now the Switcher is mapped at the right address, we can't fail!
37470 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37471 */
37472 - memcpy(switcher_vma->addr, start_switcher_text,
37473 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37474 end_switcher_text - start_switcher_text);
37475
37476 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37477 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37478 index 3b62be16..e33134a 100644
37479 --- a/drivers/lguest/page_tables.c
37480 +++ b/drivers/lguest/page_tables.c
37481 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37482 /*:*/
37483
37484 #ifdef CONFIG_X86_PAE
37485 -static void release_pmd(pmd_t *spmd)
37486 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37487 {
37488 /* If the entry's not present, there's nothing to release. */
37489 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37490 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37491 index 4af12e1..0e89afe 100644
37492 --- a/drivers/lguest/x86/core.c
37493 +++ b/drivers/lguest/x86/core.c
37494 @@ -59,7 +59,7 @@ static struct {
37495 /* Offset from where switcher.S was compiled to where we've copied it */
37496 static unsigned long switcher_offset(void)
37497 {
37498 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37499 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37500 }
37501
37502 /* This cpu's struct lguest_pages. */
37503 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37504 * These copies are pretty cheap, so we do them unconditionally: */
37505 /* Save the current Host top-level page directory.
37506 */
37507 +
37508 +#ifdef CONFIG_PAX_PER_CPU_PGD
37509 + pages->state.host_cr3 = read_cr3();
37510 +#else
37511 pages->state.host_cr3 = __pa(current->mm->pgd);
37512 +#endif
37513 +
37514 /*
37515 * Set up the Guest's page tables to see this CPU's pages (and no
37516 * other CPU's pages).
37517 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37518 * compiled-in switcher code and the high-mapped copy we just made.
37519 */
37520 for (i = 0; i < IDT_ENTRIES; i++)
37521 - default_idt_entries[i] += switcher_offset();
37522 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37523
37524 /*
37525 * Set up the Switcher's per-cpu areas.
37526 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37527 * it will be undisturbed when we switch. To change %cs and jump we
37528 * need this structure to feed to Intel's "lcall" instruction.
37529 */
37530 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37531 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37532 lguest_entry.segment = LGUEST_CS;
37533
37534 /*
37535 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37536 index 40634b0..4f5855e 100644
37537 --- a/drivers/lguest/x86/switcher_32.S
37538 +++ b/drivers/lguest/x86/switcher_32.S
37539 @@ -87,6 +87,7 @@
37540 #include <asm/page.h>
37541 #include <asm/segment.h>
37542 #include <asm/lguest.h>
37543 +#include <asm/processor-flags.h>
37544
37545 // We mark the start of the code to copy
37546 // It's placed in .text tho it's never run here
37547 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37548 // Changes type when we load it: damn Intel!
37549 // For after we switch over our page tables
37550 // That entry will be read-only: we'd crash.
37551 +
37552 +#ifdef CONFIG_PAX_KERNEXEC
37553 + mov %cr0, %edx
37554 + xor $X86_CR0_WP, %edx
37555 + mov %edx, %cr0
37556 +#endif
37557 +
37558 movl $(GDT_ENTRY_TSS*8), %edx
37559 ltr %dx
37560
37561 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37562 // Let's clear it again for our return.
37563 // The GDT descriptor of the Host
37564 // Points to the table after two "size" bytes
37565 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37566 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37567 // Clear "used" from type field (byte 5, bit 2)
37568 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37569 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37570 +
37571 +#ifdef CONFIG_PAX_KERNEXEC
37572 + mov %cr0, %eax
37573 + xor $X86_CR0_WP, %eax
37574 + mov %eax, %cr0
37575 +#endif
37576
37577 // Once our page table's switched, the Guest is live!
37578 // The Host fades as we run this final step.
37579 @@ -295,13 +309,12 @@ deliver_to_host:
37580 // I consulted gcc, and it gave
37581 // These instructions, which I gladly credit:
37582 leal (%edx,%ebx,8), %eax
37583 - movzwl (%eax),%edx
37584 - movl 4(%eax), %eax
37585 - xorw %ax, %ax
37586 - orl %eax, %edx
37587 + movl 4(%eax), %edx
37588 + movw (%eax), %dx
37589 // Now the address of the handler's in %edx
37590 // We call it now: its "iret" drops us home.
37591 - jmp *%edx
37592 + ljmp $__KERNEL_CS, $1f
37593 +1: jmp *%edx
37594
37595 // Every interrupt can come to us here
37596 // But we must truly tell each apart.
37597 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
37598 index 7155945..4bcc562 100644
37599 --- a/drivers/md/bitmap.c
37600 +++ b/drivers/md/bitmap.c
37601 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
37602 chunk_kb ? "KB" : "B");
37603 if (bitmap->storage.file) {
37604 seq_printf(seq, ", file: ");
37605 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
37606 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
37607 }
37608
37609 seq_printf(seq, "\n");
37610 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
37611 index eee353d..74504c4 100644
37612 --- a/drivers/md/dm-ioctl.c
37613 +++ b/drivers/md/dm-ioctl.c
37614 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
37615 cmd == DM_LIST_VERSIONS_CMD)
37616 return 0;
37617
37618 - if ((cmd == DM_DEV_CREATE_CMD)) {
37619 + if (cmd == DM_DEV_CREATE_CMD) {
37620 if (!*param->name) {
37621 DMWARN("name not supplied when creating device");
37622 return -EINVAL;
37623 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
37624 index 7f24190..0e18099 100644
37625 --- a/drivers/md/dm-raid1.c
37626 +++ b/drivers/md/dm-raid1.c
37627 @@ -40,7 +40,7 @@ enum dm_raid1_error {
37628
37629 struct mirror {
37630 struct mirror_set *ms;
37631 - atomic_t error_count;
37632 + atomic_unchecked_t error_count;
37633 unsigned long error_type;
37634 struct dm_dev *dev;
37635 sector_t offset;
37636 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
37637 struct mirror *m;
37638
37639 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
37640 - if (!atomic_read(&m->error_count))
37641 + if (!atomic_read_unchecked(&m->error_count))
37642 return m;
37643
37644 return NULL;
37645 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
37646 * simple way to tell if a device has encountered
37647 * errors.
37648 */
37649 - atomic_inc(&m->error_count);
37650 + atomic_inc_unchecked(&m->error_count);
37651
37652 if (test_and_set_bit(error_type, &m->error_type))
37653 return;
37654 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
37655 struct mirror *m = get_default_mirror(ms);
37656
37657 do {
37658 - if (likely(!atomic_read(&m->error_count)))
37659 + if (likely(!atomic_read_unchecked(&m->error_count)))
37660 return m;
37661
37662 if (m-- == ms->mirror)
37663 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
37664 {
37665 struct mirror *default_mirror = get_default_mirror(m->ms);
37666
37667 - return !atomic_read(&default_mirror->error_count);
37668 + return !atomic_read_unchecked(&default_mirror->error_count);
37669 }
37670
37671 static int mirror_available(struct mirror_set *ms, struct bio *bio)
37672 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
37673 */
37674 if (likely(region_in_sync(ms, region, 1)))
37675 m = choose_mirror(ms, bio->bi_sector);
37676 - else if (m && atomic_read(&m->error_count))
37677 + else if (m && atomic_read_unchecked(&m->error_count))
37678 m = NULL;
37679
37680 if (likely(m))
37681 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
37682 }
37683
37684 ms->mirror[mirror].ms = ms;
37685 - atomic_set(&(ms->mirror[mirror].error_count), 0);
37686 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
37687 ms->mirror[mirror].error_type = 0;
37688 ms->mirror[mirror].offset = offset;
37689
37690 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
37691 */
37692 static char device_status_char(struct mirror *m)
37693 {
37694 - if (!atomic_read(&(m->error_count)))
37695 + if (!atomic_read_unchecked(&(m->error_count)))
37696 return 'A';
37697
37698 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
37699 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
37700 index aaecefa..23b3026 100644
37701 --- a/drivers/md/dm-stripe.c
37702 +++ b/drivers/md/dm-stripe.c
37703 @@ -20,7 +20,7 @@ struct stripe {
37704 struct dm_dev *dev;
37705 sector_t physical_start;
37706
37707 - atomic_t error_count;
37708 + atomic_unchecked_t error_count;
37709 };
37710
37711 struct stripe_c {
37712 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
37713 kfree(sc);
37714 return r;
37715 }
37716 - atomic_set(&(sc->stripe[i].error_count), 0);
37717 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
37718 }
37719
37720 ti->private = sc;
37721 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
37722 DMEMIT("%d ", sc->stripes);
37723 for (i = 0; i < sc->stripes; i++) {
37724 DMEMIT("%s ", sc->stripe[i].dev->name);
37725 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
37726 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
37727 'D' : 'A';
37728 }
37729 buffer[i] = '\0';
37730 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
37731 */
37732 for (i = 0; i < sc->stripes; i++)
37733 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
37734 - atomic_inc(&(sc->stripe[i].error_count));
37735 - if (atomic_read(&(sc->stripe[i].error_count)) <
37736 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
37737 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
37738 DM_IO_ERROR_THRESHOLD)
37739 schedule_work(&sc->trigger_event);
37740 }
37741 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
37742 index daf25d0..d74f49f 100644
37743 --- a/drivers/md/dm-table.c
37744 +++ b/drivers/md/dm-table.c
37745 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
37746 if (!dev_size)
37747 return 0;
37748
37749 - if ((start >= dev_size) || (start + len > dev_size)) {
37750 + if ((start >= dev_size) || (len > dev_size - start)) {
37751 DMWARN("%s: %s too small for target: "
37752 "start=%llu, len=%llu, dev_size=%llu",
37753 dm_device_name(ti->table->md), bdevname(bdev, b),
37754 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
37755 index 4d6e853..a234157 100644
37756 --- a/drivers/md/dm-thin-metadata.c
37757 +++ b/drivers/md/dm-thin-metadata.c
37758 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37759 {
37760 pmd->info.tm = pmd->tm;
37761 pmd->info.levels = 2;
37762 - pmd->info.value_type.context = pmd->data_sm;
37763 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37764 pmd->info.value_type.size = sizeof(__le64);
37765 pmd->info.value_type.inc = data_block_inc;
37766 pmd->info.value_type.dec = data_block_dec;
37767 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37768
37769 pmd->bl_info.tm = pmd->tm;
37770 pmd->bl_info.levels = 1;
37771 - pmd->bl_info.value_type.context = pmd->data_sm;
37772 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37773 pmd->bl_info.value_type.size = sizeof(__le64);
37774 pmd->bl_info.value_type.inc = data_block_inc;
37775 pmd->bl_info.value_type.dec = data_block_dec;
37776 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
37777 index 0d8f086..f5a91d5 100644
37778 --- a/drivers/md/dm.c
37779 +++ b/drivers/md/dm.c
37780 @@ -170,9 +170,9 @@ struct mapped_device {
37781 /*
37782 * Event handling.
37783 */
37784 - atomic_t event_nr;
37785 + atomic_unchecked_t event_nr;
37786 wait_queue_head_t eventq;
37787 - atomic_t uevent_seq;
37788 + atomic_unchecked_t uevent_seq;
37789 struct list_head uevent_list;
37790 spinlock_t uevent_lock; /* Protect access to uevent_list */
37791
37792 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
37793 rwlock_init(&md->map_lock);
37794 atomic_set(&md->holders, 1);
37795 atomic_set(&md->open_count, 0);
37796 - atomic_set(&md->event_nr, 0);
37797 - atomic_set(&md->uevent_seq, 0);
37798 + atomic_set_unchecked(&md->event_nr, 0);
37799 + atomic_set_unchecked(&md->uevent_seq, 0);
37800 INIT_LIST_HEAD(&md->uevent_list);
37801 spin_lock_init(&md->uevent_lock);
37802
37803 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
37804
37805 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
37806
37807 - atomic_inc(&md->event_nr);
37808 + atomic_inc_unchecked(&md->event_nr);
37809 wake_up(&md->eventq);
37810 }
37811
37812 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
37813
37814 uint32_t dm_next_uevent_seq(struct mapped_device *md)
37815 {
37816 - return atomic_add_return(1, &md->uevent_seq);
37817 + return atomic_add_return_unchecked(1, &md->uevent_seq);
37818 }
37819
37820 uint32_t dm_get_event_nr(struct mapped_device *md)
37821 {
37822 - return atomic_read(&md->event_nr);
37823 + return atomic_read_unchecked(&md->event_nr);
37824 }
37825
37826 int dm_wait_event(struct mapped_device *md, int event_nr)
37827 {
37828 return wait_event_interruptible(md->eventq,
37829 - (event_nr != atomic_read(&md->event_nr)));
37830 + (event_nr != atomic_read_unchecked(&md->event_nr)));
37831 }
37832
37833 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
37834 diff --git a/drivers/md/md.c b/drivers/md/md.c
37835 index f363135..9b38815 100644
37836 --- a/drivers/md/md.c
37837 +++ b/drivers/md/md.c
37838 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
37839 * start build, activate spare
37840 */
37841 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
37842 -static atomic_t md_event_count;
37843 +static atomic_unchecked_t md_event_count;
37844 void md_new_event(struct mddev *mddev)
37845 {
37846 - atomic_inc(&md_event_count);
37847 + atomic_inc_unchecked(&md_event_count);
37848 wake_up(&md_event_waiters);
37849 }
37850 EXPORT_SYMBOL_GPL(md_new_event);
37851 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
37852 */
37853 static void md_new_event_inintr(struct mddev *mddev)
37854 {
37855 - atomic_inc(&md_event_count);
37856 + atomic_inc_unchecked(&md_event_count);
37857 wake_up(&md_event_waiters);
37858 }
37859
37860 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
37861 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
37862 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
37863 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
37864 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
37865 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
37866
37867 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
37868 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
37869 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
37870 else
37871 sb->resync_offset = cpu_to_le64(0);
37872
37873 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
37874 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
37875
37876 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
37877 sb->size = cpu_to_le64(mddev->dev_sectors);
37878 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
37879 static ssize_t
37880 errors_show(struct md_rdev *rdev, char *page)
37881 {
37882 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
37883 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
37884 }
37885
37886 static ssize_t
37887 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
37888 char *e;
37889 unsigned long n = simple_strtoul(buf, &e, 10);
37890 if (*buf && (*e == 0 || *e == '\n')) {
37891 - atomic_set(&rdev->corrected_errors, n);
37892 + atomic_set_unchecked(&rdev->corrected_errors, n);
37893 return len;
37894 }
37895 return -EINVAL;
37896 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
37897 rdev->sb_loaded = 0;
37898 rdev->bb_page = NULL;
37899 atomic_set(&rdev->nr_pending, 0);
37900 - atomic_set(&rdev->read_errors, 0);
37901 - atomic_set(&rdev->corrected_errors, 0);
37902 + atomic_set_unchecked(&rdev->read_errors, 0);
37903 + atomic_set_unchecked(&rdev->corrected_errors, 0);
37904
37905 INIT_LIST_HEAD(&rdev->same_set);
37906 init_waitqueue_head(&rdev->blocked_wait);
37907 @@ -6987,7 +6987,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
37908
37909 spin_unlock(&pers_lock);
37910 seq_printf(seq, "\n");
37911 - seq->poll_event = atomic_read(&md_event_count);
37912 + seq->poll_event = atomic_read_unchecked(&md_event_count);
37913 return 0;
37914 }
37915 if (v == (void*)2) {
37916 @@ -7090,7 +7090,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
37917 return error;
37918
37919 seq = file->private_data;
37920 - seq->poll_event = atomic_read(&md_event_count);
37921 + seq->poll_event = atomic_read_unchecked(&md_event_count);
37922 return error;
37923 }
37924
37925 @@ -7104,7 +7104,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
37926 /* always allow read */
37927 mask = POLLIN | POLLRDNORM;
37928
37929 - if (seq->poll_event != atomic_read(&md_event_count))
37930 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
37931 mask |= POLLERR | POLLPRI;
37932 return mask;
37933 }
37934 @@ -7148,7 +7148,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
37935 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
37936 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
37937 (int)part_stat_read(&disk->part0, sectors[1]) -
37938 - atomic_read(&disk->sync_io);
37939 + atomic_read_unchecked(&disk->sync_io);
37940 /* sync IO will cause sync_io to increase before the disk_stats
37941 * as sync_io is counted when a request starts, and
37942 * disk_stats is counted when it completes.
37943 diff --git a/drivers/md/md.h b/drivers/md/md.h
37944 index eca59c3..7c42285 100644
37945 --- a/drivers/md/md.h
37946 +++ b/drivers/md/md.h
37947 @@ -94,13 +94,13 @@ struct md_rdev {
37948 * only maintained for arrays that
37949 * support hot removal
37950 */
37951 - atomic_t read_errors; /* number of consecutive read errors that
37952 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
37953 * we have tried to ignore.
37954 */
37955 struct timespec last_read_error; /* monotonic time since our
37956 * last read error
37957 */
37958 - atomic_t corrected_errors; /* number of corrected read errors,
37959 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
37960 * for reporting to userspace and storing
37961 * in superblock.
37962 */
37963 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
37964
37965 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
37966 {
37967 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
37968 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
37969 }
37970
37971 struct md_personality
37972 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
37973 index 1cbfc6b..56e1dbb 100644
37974 --- a/drivers/md/persistent-data/dm-space-map.h
37975 +++ b/drivers/md/persistent-data/dm-space-map.h
37976 @@ -60,6 +60,7 @@ struct dm_space_map {
37977 int (*root_size)(struct dm_space_map *sm, size_t *result);
37978 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
37979 };
37980 +typedef struct dm_space_map __no_const dm_space_map_no_const;
37981
37982 /*----------------------------------------------------------------*/
37983
37984 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
37985 index 75b1f89..00ba344 100644
37986 --- a/drivers/md/raid1.c
37987 +++ b/drivers/md/raid1.c
37988 @@ -1819,7 +1819,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
37989 if (r1_sync_page_io(rdev, sect, s,
37990 bio->bi_io_vec[idx].bv_page,
37991 READ) != 0)
37992 - atomic_add(s, &rdev->corrected_errors);
37993 + atomic_add_unchecked(s, &rdev->corrected_errors);
37994 }
37995 sectors -= s;
37996 sect += s;
37997 @@ -2041,7 +2041,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
37998 test_bit(In_sync, &rdev->flags)) {
37999 if (r1_sync_page_io(rdev, sect, s,
38000 conf->tmppage, READ)) {
38001 - atomic_add(s, &rdev->corrected_errors);
38002 + atomic_add_unchecked(s, &rdev->corrected_errors);
38003 printk(KERN_INFO
38004 "md/raid1:%s: read error corrected "
38005 "(%d sectors at %llu on %s)\n",
38006 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38007 index 8d925dc..11d674f 100644
38008 --- a/drivers/md/raid10.c
38009 +++ b/drivers/md/raid10.c
38010 @@ -1878,7 +1878,7 @@ static void end_sync_read(struct bio *bio, int error)
38011 /* The write handler will notice the lack of
38012 * R10BIO_Uptodate and record any errors etc
38013 */
38014 - atomic_add(r10_bio->sectors,
38015 + atomic_add_unchecked(r10_bio->sectors,
38016 &conf->mirrors[d].rdev->corrected_errors);
38017
38018 /* for reconstruct, we always reschedule after a read.
38019 @@ -2227,7 +2227,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38020 {
38021 struct timespec cur_time_mon;
38022 unsigned long hours_since_last;
38023 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38024 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38025
38026 ktime_get_ts(&cur_time_mon);
38027
38028 @@ -2249,9 +2249,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38029 * overflowing the shift of read_errors by hours_since_last.
38030 */
38031 if (hours_since_last >= 8 * sizeof(read_errors))
38032 - atomic_set(&rdev->read_errors, 0);
38033 + atomic_set_unchecked(&rdev->read_errors, 0);
38034 else
38035 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38036 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38037 }
38038
38039 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38040 @@ -2305,8 +2305,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38041 return;
38042
38043 check_decay_read_errors(mddev, rdev);
38044 - atomic_inc(&rdev->read_errors);
38045 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38046 + atomic_inc_unchecked(&rdev->read_errors);
38047 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38048 char b[BDEVNAME_SIZE];
38049 bdevname(rdev->bdev, b);
38050
38051 @@ -2314,7 +2314,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38052 "md/raid10:%s: %s: Raid device exceeded "
38053 "read_error threshold [cur %d:max %d]\n",
38054 mdname(mddev), b,
38055 - atomic_read(&rdev->read_errors), max_read_errors);
38056 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38057 printk(KERN_NOTICE
38058 "md/raid10:%s: %s: Failing raid device\n",
38059 mdname(mddev), b);
38060 @@ -2469,7 +2469,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38061 sect +
38062 choose_data_offset(r10_bio, rdev)),
38063 bdevname(rdev->bdev, b));
38064 - atomic_add(s, &rdev->corrected_errors);
38065 + atomic_add_unchecked(s, &rdev->corrected_errors);
38066 }
38067
38068 rdev_dec_pending(rdev, mddev);
38069 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38070 index 94ce78e..df99e24 100644
38071 --- a/drivers/md/raid5.c
38072 +++ b/drivers/md/raid5.c
38073 @@ -1800,21 +1800,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38074 mdname(conf->mddev), STRIPE_SECTORS,
38075 (unsigned long long)s,
38076 bdevname(rdev->bdev, b));
38077 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38078 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38079 clear_bit(R5_ReadError, &sh->dev[i].flags);
38080 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38081 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38082 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38083
38084 - if (atomic_read(&rdev->read_errors))
38085 - atomic_set(&rdev->read_errors, 0);
38086 + if (atomic_read_unchecked(&rdev->read_errors))
38087 + atomic_set_unchecked(&rdev->read_errors, 0);
38088 } else {
38089 const char *bdn = bdevname(rdev->bdev, b);
38090 int retry = 0;
38091 int set_bad = 0;
38092
38093 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38094 - atomic_inc(&rdev->read_errors);
38095 + atomic_inc_unchecked(&rdev->read_errors);
38096 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38097 printk_ratelimited(
38098 KERN_WARNING
38099 @@ -1842,7 +1842,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38100 mdname(conf->mddev),
38101 (unsigned long long)s,
38102 bdn);
38103 - } else if (atomic_read(&rdev->read_errors)
38104 + } else if (atomic_read_unchecked(&rdev->read_errors)
38105 > conf->max_nr_stripes)
38106 printk(KERN_WARNING
38107 "md/raid:%s: Too many read errors, failing device %s.\n",
38108 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38109 index d33101a..6b13069 100644
38110 --- a/drivers/media/dvb-core/dvbdev.c
38111 +++ b/drivers/media/dvb-core/dvbdev.c
38112 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38113 const struct dvb_device *template, void *priv, int type)
38114 {
38115 struct dvb_device *dvbdev;
38116 - struct file_operations *dvbdevfops;
38117 + file_operations_no_const *dvbdevfops;
38118 struct device *clsdev;
38119 int minor;
38120 int id;
38121 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38122 index 404f63a..4796533 100644
38123 --- a/drivers/media/dvb-frontends/dib3000.h
38124 +++ b/drivers/media/dvb-frontends/dib3000.h
38125 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38126 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38127 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38128 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38129 -};
38130 +} __no_const;
38131
38132 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
38133 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38134 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38135 index bc78354..42c9459 100644
38136 --- a/drivers/media/pci/cx88/cx88-video.c
38137 +++ b/drivers/media/pci/cx88/cx88-video.c
38138 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38139
38140 /* ------------------------------------------------------------------ */
38141
38142 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38143 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38144 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38145 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38146 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38147 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38148
38149 module_param_array(video_nr, int, NULL, 0444);
38150 module_param_array(vbi_nr, int, NULL, 0444);
38151 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38152 index 8e9a668..78d6310 100644
38153 --- a/drivers/media/platform/omap/omap_vout.c
38154 +++ b/drivers/media/platform/omap/omap_vout.c
38155 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38156 OMAP_VIDEO2,
38157 };
38158
38159 -static struct videobuf_queue_ops video_vbq_ops;
38160 /* Variables configurable through module params*/
38161 static u32 video1_numbuffers = 3;
38162 static u32 video2_numbuffers = 3;
38163 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38164 {
38165 struct videobuf_queue *q;
38166 struct omap_vout_device *vout = NULL;
38167 + static struct videobuf_queue_ops video_vbq_ops = {
38168 + .buf_setup = omap_vout_buffer_setup,
38169 + .buf_prepare = omap_vout_buffer_prepare,
38170 + .buf_release = omap_vout_buffer_release,
38171 + .buf_queue = omap_vout_buffer_queue,
38172 + };
38173
38174 vout = video_drvdata(file);
38175 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38176 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38177 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38178
38179 q = &vout->vbq;
38180 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38181 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38182 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38183 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38184 spin_lock_init(&vout->vbq_lock);
38185
38186 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38187 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38188 index b671e20..34088b7 100644
38189 --- a/drivers/media/platform/s5p-tv/mixer.h
38190 +++ b/drivers/media/platform/s5p-tv/mixer.h
38191 @@ -155,7 +155,7 @@ struct mxr_layer {
38192 /** layer index (unique identifier) */
38193 int idx;
38194 /** callbacks for layer methods */
38195 - struct mxr_layer_ops ops;
38196 + struct mxr_layer_ops *ops;
38197 /** format array */
38198 const struct mxr_format **fmt_array;
38199 /** size of format array */
38200 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38201 index b93a21f..2535195 100644
38202 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38203 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38204 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38205 {
38206 struct mxr_layer *layer;
38207 int ret;
38208 - struct mxr_layer_ops ops = {
38209 + static struct mxr_layer_ops ops = {
38210 .release = mxr_graph_layer_release,
38211 .buffer_set = mxr_graph_buffer_set,
38212 .stream_set = mxr_graph_stream_set,
38213 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38214 index 3b1670a..595c939 100644
38215 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38216 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38217 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38218 layer->update_buf = next;
38219 }
38220
38221 - layer->ops.buffer_set(layer, layer->update_buf);
38222 + layer->ops->buffer_set(layer, layer->update_buf);
38223
38224 if (done && done != layer->shadow_buf)
38225 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38226 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38227 index 1f3b743..e839271 100644
38228 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38229 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38230 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38231 layer->geo.src.height = layer->geo.src.full_height;
38232
38233 mxr_geometry_dump(mdev, &layer->geo);
38234 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38235 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38236 mxr_geometry_dump(mdev, &layer->geo);
38237 }
38238
38239 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38240 layer->geo.dst.full_width = mbus_fmt.width;
38241 layer->geo.dst.full_height = mbus_fmt.height;
38242 layer->geo.dst.field = mbus_fmt.field;
38243 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38244 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38245
38246 mxr_geometry_dump(mdev, &layer->geo);
38247 }
38248 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38249 /* set source size to highest accepted value */
38250 geo->src.full_width = max(geo->dst.full_width, pix->width);
38251 geo->src.full_height = max(geo->dst.full_height, pix->height);
38252 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38253 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38254 mxr_geometry_dump(mdev, &layer->geo);
38255 /* set cropping to total visible screen */
38256 geo->src.width = pix->width;
38257 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38258 geo->src.x_offset = 0;
38259 geo->src.y_offset = 0;
38260 /* assure consistency of geometry */
38261 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38262 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38263 mxr_geometry_dump(mdev, &layer->geo);
38264 /* set full size to lowest possible value */
38265 geo->src.full_width = 0;
38266 geo->src.full_height = 0;
38267 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38268 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38269 mxr_geometry_dump(mdev, &layer->geo);
38270
38271 /* returning results */
38272 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38273 target->width = s->r.width;
38274 target->height = s->r.height;
38275
38276 - layer->ops.fix_geometry(layer, stage, s->flags);
38277 + layer->ops->fix_geometry(layer, stage, s->flags);
38278
38279 /* retrieve update selection rectangle */
38280 res.left = target->x_offset;
38281 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38282 mxr_output_get(mdev);
38283
38284 mxr_layer_update_output(layer);
38285 - layer->ops.format_set(layer);
38286 + layer->ops->format_set(layer);
38287 /* enabling layer in hardware */
38288 spin_lock_irqsave(&layer->enq_slock, flags);
38289 layer->state = MXR_LAYER_STREAMING;
38290 spin_unlock_irqrestore(&layer->enq_slock, flags);
38291
38292 - layer->ops.stream_set(layer, MXR_ENABLE);
38293 + layer->ops->stream_set(layer, MXR_ENABLE);
38294 mxr_streamer_get(mdev);
38295
38296 return 0;
38297 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
38298 spin_unlock_irqrestore(&layer->enq_slock, flags);
38299
38300 /* disabling layer in hardware */
38301 - layer->ops.stream_set(layer, MXR_DISABLE);
38302 + layer->ops->stream_set(layer, MXR_DISABLE);
38303 /* remove one streamer */
38304 mxr_streamer_put(mdev);
38305 /* allow changes in output configuration */
38306 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38307
38308 void mxr_layer_release(struct mxr_layer *layer)
38309 {
38310 - if (layer->ops.release)
38311 - layer->ops.release(layer);
38312 + if (layer->ops->release)
38313 + layer->ops->release(layer);
38314 }
38315
38316 void mxr_base_layer_release(struct mxr_layer *layer)
38317 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38318
38319 layer->mdev = mdev;
38320 layer->idx = idx;
38321 - layer->ops = *ops;
38322 + layer->ops = ops;
38323
38324 spin_lock_init(&layer->enq_slock);
38325 INIT_LIST_HEAD(&layer->enq_list);
38326 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38327 index 3d13a63..da31bf1 100644
38328 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38329 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38330 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38331 {
38332 struct mxr_layer *layer;
38333 int ret;
38334 - struct mxr_layer_ops ops = {
38335 + static struct mxr_layer_ops ops = {
38336 .release = mxr_vp_layer_release,
38337 .buffer_set = mxr_vp_buffer_set,
38338 .stream_set = mxr_vp_stream_set,
38339 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38340 index 643d80a..56bb96b 100644
38341 --- a/drivers/media/radio/radio-cadet.c
38342 +++ b/drivers/media/radio/radio-cadet.c
38343 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38344 unsigned char readbuf[RDS_BUFFER];
38345 int i = 0;
38346
38347 + if (count > RDS_BUFFER)
38348 + return -EFAULT;
38349 mutex_lock(&dev->lock);
38350 if (dev->rdsstat == 0)
38351 cadet_start_rds(dev);
38352 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38353 while (i < count && dev->rdsin != dev->rdsout)
38354 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38355
38356 - if (i && copy_to_user(data, readbuf, i))
38357 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38358 i = -EFAULT;
38359 unlock:
38360 mutex_unlock(&dev->lock);
38361 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38362 index 3940bb0..fb3952a 100644
38363 --- a/drivers/media/usb/dvb-usb/cxusb.c
38364 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38365 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38366
38367 struct dib0700_adapter_state {
38368 int (*set_param_save) (struct dvb_frontend *);
38369 -};
38370 +} __no_const;
38371
38372 static int dib7070_set_param_override(struct dvb_frontend *fe)
38373 {
38374 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38375 index 9382895..ac8093c 100644
38376 --- a/drivers/media/usb/dvb-usb/dw2102.c
38377 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38378 @@ -95,7 +95,7 @@ struct su3000_state {
38379
38380 struct s6x0_state {
38381 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38382 -};
38383 +} __no_const;
38384
38385 /* debug */
38386 static int dvb_usb_dw2102_debug;
38387 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38388 index aa6e7c7..4cd8061 100644
38389 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38390 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38391 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38392 struct file *file, void *fh, void *p);
38393 } u;
38394 void (*debug)(const void *arg, bool write_only);
38395 -};
38396 +} __do_const;
38397 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38398
38399 /* This control needs a priority check */
38400 #define INFO_FL_PRIO (1 << 0)
38401 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38402 struct video_device *vfd = video_devdata(file);
38403 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38404 bool write_only = false;
38405 - struct v4l2_ioctl_info default_info;
38406 + v4l2_ioctl_info_no_const default_info;
38407 const struct v4l2_ioctl_info *info;
38408 void *fh = file->private_data;
38409 struct v4l2_fh *vfh = NULL;
38410 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
38411 index 29b2172..a7c5b31 100644
38412 --- a/drivers/memstick/host/r592.c
38413 +++ b/drivers/memstick/host/r592.c
38414 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
38415 /* Executes one TPC (data is read/written from small or large fifo) */
38416 static void r592_execute_tpc(struct r592_device *dev)
38417 {
38418 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38419 + bool is_write;
38420 int len, error;
38421 u32 status, reg;
38422
38423 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
38424 return;
38425 }
38426
38427 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38428 len = dev->req->long_data ?
38429 dev->req->sg.length : dev->req->data_len;
38430
38431 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38432 index fb69baa..3aeea2e 100644
38433 --- a/drivers/message/fusion/mptbase.c
38434 +++ b/drivers/message/fusion/mptbase.c
38435 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38436 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38437 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38438
38439 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38440 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38441 +#else
38442 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38443 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38444 +#endif
38445 +
38446 /*
38447 * Rounding UP to nearest 4-kB boundary here...
38448 */
38449 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38450 ioc->facts.GlobalCredits);
38451
38452 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38453 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38454 + NULL, NULL);
38455 +#else
38456 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38457 +#endif
38458 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38459 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38460 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38461 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38462 index fa43c39..daeb158 100644
38463 --- a/drivers/message/fusion/mptsas.c
38464 +++ b/drivers/message/fusion/mptsas.c
38465 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38466 return 0;
38467 }
38468
38469 +static inline void
38470 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38471 +{
38472 + if (phy_info->port_details) {
38473 + phy_info->port_details->rphy = rphy;
38474 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38475 + ioc->name, rphy));
38476 + }
38477 +
38478 + if (rphy) {
38479 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38480 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38481 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38482 + ioc->name, rphy, rphy->dev.release));
38483 + }
38484 +}
38485 +
38486 /* no mutex */
38487 static void
38488 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38489 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38490 return NULL;
38491 }
38492
38493 -static inline void
38494 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38495 -{
38496 - if (phy_info->port_details) {
38497 - phy_info->port_details->rphy = rphy;
38498 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38499 - ioc->name, rphy));
38500 - }
38501 -
38502 - if (rphy) {
38503 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38504 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38505 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38506 - ioc->name, rphy, rphy->dev.release));
38507 - }
38508 -}
38509 -
38510 static inline struct sas_port *
38511 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38512 {
38513 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38514 index 164afa7..b6b2e74 100644
38515 --- a/drivers/message/fusion/mptscsih.c
38516 +++ b/drivers/message/fusion/mptscsih.c
38517 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38518
38519 h = shost_priv(SChost);
38520
38521 - if (h) {
38522 - if (h->info_kbuf == NULL)
38523 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38524 - return h->info_kbuf;
38525 - h->info_kbuf[0] = '\0';
38526 + if (!h)
38527 + return NULL;
38528
38529 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38530 - h->info_kbuf[size-1] = '\0';
38531 - }
38532 + if (h->info_kbuf == NULL)
38533 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38534 + return h->info_kbuf;
38535 + h->info_kbuf[0] = '\0';
38536 +
38537 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38538 + h->info_kbuf[size-1] = '\0';
38539
38540 return h->info_kbuf;
38541 }
38542 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38543 index 8001aa6..b137580 100644
38544 --- a/drivers/message/i2o/i2o_proc.c
38545 +++ b/drivers/message/i2o/i2o_proc.c
38546 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38547 "Array Controller Device"
38548 };
38549
38550 -static char *chtostr(char *tmp, u8 *chars, int n)
38551 -{
38552 - tmp[0] = 0;
38553 - return strncat(tmp, (char *)chars, n);
38554 -}
38555 -
38556 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38557 char *group)
38558 {
38559 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38560 } *result;
38561
38562 i2o_exec_execute_ddm_table ddm_table;
38563 - char tmp[28 + 1];
38564
38565 result = kmalloc(sizeof(*result), GFP_KERNEL);
38566 if (!result)
38567 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38568
38569 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38570 seq_printf(seq, "%-#8x", ddm_table.module_id);
38571 - seq_printf(seq, "%-29s",
38572 - chtostr(tmp, ddm_table.module_name_version, 28));
38573 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
38574 seq_printf(seq, "%9d ", ddm_table.data_size);
38575 seq_printf(seq, "%8d", ddm_table.code_size);
38576
38577 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38578
38579 i2o_driver_result_table *result;
38580 i2o_driver_store_table *dst;
38581 - char tmp[28 + 1];
38582
38583 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
38584 if (result == NULL)
38585 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38586
38587 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
38588 seq_printf(seq, "%-#8x", dst->module_id);
38589 - seq_printf(seq, "%-29s",
38590 - chtostr(tmp, dst->module_name_version, 28));
38591 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
38592 + seq_printf(seq, "%-.28s", dst->module_name_version);
38593 + seq_printf(seq, "%-.8s", dst->date);
38594 seq_printf(seq, "%8d ", dst->module_size);
38595 seq_printf(seq, "%8d ", dst->mpb_size);
38596 seq_printf(seq, "0x%04x", dst->module_flags);
38597 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38598 // == (allow) 512d bytes (max)
38599 static u16 *work16 = (u16 *) work32;
38600 int token;
38601 - char tmp[16 + 1];
38602
38603 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
38604
38605 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38606 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
38607 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
38608 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
38609 - seq_printf(seq, "Vendor info : %s\n",
38610 - chtostr(tmp, (u8 *) (work32 + 2), 16));
38611 - seq_printf(seq, "Product info : %s\n",
38612 - chtostr(tmp, (u8 *) (work32 + 6), 16));
38613 - seq_printf(seq, "Description : %s\n",
38614 - chtostr(tmp, (u8 *) (work32 + 10), 16));
38615 - seq_printf(seq, "Product rev. : %s\n",
38616 - chtostr(tmp, (u8 *) (work32 + 14), 8));
38617 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
38618 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
38619 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
38620 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
38621
38622 seq_printf(seq, "Serial number : ");
38623 print_serial_number(seq, (u8 *) (work32 + 16),
38624 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38625 u8 pad[256]; // allow up to 256 byte (max) serial number
38626 } result;
38627
38628 - char tmp[24 + 1];
38629 -
38630 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
38631
38632 if (token < 0) {
38633 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38634 }
38635
38636 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
38637 - seq_printf(seq, "Module name : %s\n",
38638 - chtostr(tmp, result.module_name, 24));
38639 - seq_printf(seq, "Module revision : %s\n",
38640 - chtostr(tmp, result.module_rev, 8));
38641 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
38642 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
38643
38644 seq_printf(seq, "Serial number : ");
38645 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
38646 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38647 u8 instance_number[4];
38648 } result;
38649
38650 - char tmp[64 + 1];
38651 -
38652 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
38653
38654 if (token < 0) {
38655 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38656 return 0;
38657 }
38658
38659 - seq_printf(seq, "Device name : %s\n",
38660 - chtostr(tmp, result.device_name, 64));
38661 - seq_printf(seq, "Service name : %s\n",
38662 - chtostr(tmp, result.service_name, 64));
38663 - seq_printf(seq, "Physical name : %s\n",
38664 - chtostr(tmp, result.physical_location, 64));
38665 - seq_printf(seq, "Instance number : %s\n",
38666 - chtostr(tmp, result.instance_number, 4));
38667 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
38668 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
38669 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
38670 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
38671
38672 return 0;
38673 }
38674 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
38675 index a8c08f3..155fe3d 100644
38676 --- a/drivers/message/i2o/iop.c
38677 +++ b/drivers/message/i2o/iop.c
38678 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
38679
38680 spin_lock_irqsave(&c->context_list_lock, flags);
38681
38682 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
38683 - atomic_inc(&c->context_list_counter);
38684 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
38685 + atomic_inc_unchecked(&c->context_list_counter);
38686
38687 - entry->context = atomic_read(&c->context_list_counter);
38688 + entry->context = atomic_read_unchecked(&c->context_list_counter);
38689
38690 list_add(&entry->list, &c->context_list);
38691
38692 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
38693
38694 #if BITS_PER_LONG == 64
38695 spin_lock_init(&c->context_list_lock);
38696 - atomic_set(&c->context_list_counter, 0);
38697 + atomic_set_unchecked(&c->context_list_counter, 0);
38698 INIT_LIST_HEAD(&c->context_list);
38699 #endif
38700
38701 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
38702 index 45ece11..8efa218 100644
38703 --- a/drivers/mfd/janz-cmodio.c
38704 +++ b/drivers/mfd/janz-cmodio.c
38705 @@ -13,6 +13,7 @@
38706
38707 #include <linux/kernel.h>
38708 #include <linux/module.h>
38709 +#include <linux/slab.h>
38710 #include <linux/init.h>
38711 #include <linux/pci.h>
38712 #include <linux/interrupt.h>
38713 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
38714 index a5f9888..1c0ed56 100644
38715 --- a/drivers/mfd/twl4030-irq.c
38716 +++ b/drivers/mfd/twl4030-irq.c
38717 @@ -35,6 +35,7 @@
38718 #include <linux/of.h>
38719 #include <linux/irqdomain.h>
38720 #include <linux/i2c/twl.h>
38721 +#include <asm/pgtable.h>
38722
38723 #include "twl-core.h"
38724
38725 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
38726 * Install an irq handler for each of the SIH modules;
38727 * clone dummy irq_chip since PIH can't *do* anything
38728 */
38729 - twl4030_irq_chip = dummy_irq_chip;
38730 - twl4030_irq_chip.name = "twl4030";
38731 + pax_open_kernel();
38732 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
38733 + *(const char **)&twl4030_irq_chip.name = "twl4030";
38734
38735 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38736 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38737 + pax_close_kernel();
38738
38739 for (i = irq_base; i < irq_end; i++) {
38740 irq_set_chip_and_handler(i, &twl4030_irq_chip,
38741 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
38742 index 277a8db..0e0b754 100644
38743 --- a/drivers/mfd/twl6030-irq.c
38744 +++ b/drivers/mfd/twl6030-irq.c
38745 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
38746 * install an irq handler for each of the modules;
38747 * clone dummy irq_chip since PIH can't *do* anything
38748 */
38749 - twl6030_irq_chip = dummy_irq_chip;
38750 - twl6030_irq_chip.name = "twl6030";
38751 - twl6030_irq_chip.irq_set_type = NULL;
38752 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
38753 + pax_open_kernel();
38754 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
38755 + *(const char **)&twl6030_irq_chip.name = "twl6030";
38756 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
38757 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
38758 + pax_close_kernel();
38759
38760 for (i = irq_base; i < irq_end; i++) {
38761 irq_set_chip_and_handler(i, &twl6030_irq_chip,
38762 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
38763 index f428d86..274c368 100644
38764 --- a/drivers/misc/c2port/core.c
38765 +++ b/drivers/misc/c2port/core.c
38766 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
38767 mutex_init(&c2dev->mutex);
38768
38769 /* Create binary file */
38770 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
38771 + pax_open_kernel();
38772 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
38773 + pax_close_kernel();
38774 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
38775 if (unlikely(ret))
38776 goto error_device_create_bin_file;
38777 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
38778 index 3aa9a96..59cf685 100644
38779 --- a/drivers/misc/kgdbts.c
38780 +++ b/drivers/misc/kgdbts.c
38781 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
38782 char before[BREAK_INSTR_SIZE];
38783 char after[BREAK_INSTR_SIZE];
38784
38785 - probe_kernel_read(before, (char *)kgdbts_break_test,
38786 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
38787 BREAK_INSTR_SIZE);
38788 init_simple_test();
38789 ts.tst = plant_and_detach_test;
38790 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
38791 /* Activate test with initial breakpoint */
38792 if (!is_early)
38793 kgdb_breakpoint();
38794 - probe_kernel_read(after, (char *)kgdbts_break_test,
38795 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
38796 BREAK_INSTR_SIZE);
38797 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
38798 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
38799 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
38800 index 4a87e5c..76bdf5c 100644
38801 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
38802 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
38803 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
38804 * the lid is closed. This leads to interrupts as soon as a little move
38805 * is done.
38806 */
38807 - atomic_inc(&lis3->count);
38808 + atomic_inc_unchecked(&lis3->count);
38809
38810 wake_up_interruptible(&lis3->misc_wait);
38811 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
38812 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
38813 if (lis3->pm_dev)
38814 pm_runtime_get_sync(lis3->pm_dev);
38815
38816 - atomic_set(&lis3->count, 0);
38817 + atomic_set_unchecked(&lis3->count, 0);
38818 return 0;
38819 }
38820
38821 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
38822 add_wait_queue(&lis3->misc_wait, &wait);
38823 while (true) {
38824 set_current_state(TASK_INTERRUPTIBLE);
38825 - data = atomic_xchg(&lis3->count, 0);
38826 + data = atomic_xchg_unchecked(&lis3->count, 0);
38827 if (data)
38828 break;
38829
38830 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
38831 struct lis3lv02d, miscdev);
38832
38833 poll_wait(file, &lis3->misc_wait, wait);
38834 - if (atomic_read(&lis3->count))
38835 + if (atomic_read_unchecked(&lis3->count))
38836 return POLLIN | POLLRDNORM;
38837 return 0;
38838 }
38839 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
38840 index c439c82..1f20f57 100644
38841 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
38842 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
38843 @@ -297,7 +297,7 @@ struct lis3lv02d {
38844 struct input_polled_dev *idev; /* input device */
38845 struct platform_device *pdev; /* platform device */
38846 struct regulator_bulk_data regulators[2];
38847 - atomic_t count; /* interrupt count after last read */
38848 + atomic_unchecked_t count; /* interrupt count after last read */
38849 union axis_conversion ac; /* hw -> logical axis */
38850 int mapped_btns[3];
38851
38852 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
38853 index 2f30bad..c4c13d0 100644
38854 --- a/drivers/misc/sgi-gru/gruhandles.c
38855 +++ b/drivers/misc/sgi-gru/gruhandles.c
38856 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
38857 unsigned long nsec;
38858
38859 nsec = CLKS2NSEC(clks);
38860 - atomic_long_inc(&mcs_op_statistics[op].count);
38861 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
38862 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
38863 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
38864 if (mcs_op_statistics[op].max < nsec)
38865 mcs_op_statistics[op].max = nsec;
38866 }
38867 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
38868 index 950dbe9..eeef0f8 100644
38869 --- a/drivers/misc/sgi-gru/gruprocfs.c
38870 +++ b/drivers/misc/sgi-gru/gruprocfs.c
38871 @@ -32,9 +32,9 @@
38872
38873 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
38874
38875 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
38876 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
38877 {
38878 - unsigned long val = atomic_long_read(v);
38879 + unsigned long val = atomic_long_read_unchecked(v);
38880
38881 seq_printf(s, "%16lu %s\n", val, id);
38882 }
38883 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
38884
38885 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
38886 for (op = 0; op < mcsop_last; op++) {
38887 - count = atomic_long_read(&mcs_op_statistics[op].count);
38888 - total = atomic_long_read(&mcs_op_statistics[op].total);
38889 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
38890 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
38891 max = mcs_op_statistics[op].max;
38892 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
38893 count ? total / count : 0, max);
38894 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
38895 index 5c3ce24..4915ccb 100644
38896 --- a/drivers/misc/sgi-gru/grutables.h
38897 +++ b/drivers/misc/sgi-gru/grutables.h
38898 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
38899 * GRU statistics.
38900 */
38901 struct gru_stats_s {
38902 - atomic_long_t vdata_alloc;
38903 - atomic_long_t vdata_free;
38904 - atomic_long_t gts_alloc;
38905 - atomic_long_t gts_free;
38906 - atomic_long_t gms_alloc;
38907 - atomic_long_t gms_free;
38908 - atomic_long_t gts_double_allocate;
38909 - atomic_long_t assign_context;
38910 - atomic_long_t assign_context_failed;
38911 - atomic_long_t free_context;
38912 - atomic_long_t load_user_context;
38913 - atomic_long_t load_kernel_context;
38914 - atomic_long_t lock_kernel_context;
38915 - atomic_long_t unlock_kernel_context;
38916 - atomic_long_t steal_user_context;
38917 - atomic_long_t steal_kernel_context;
38918 - atomic_long_t steal_context_failed;
38919 - atomic_long_t nopfn;
38920 - atomic_long_t asid_new;
38921 - atomic_long_t asid_next;
38922 - atomic_long_t asid_wrap;
38923 - atomic_long_t asid_reuse;
38924 - atomic_long_t intr;
38925 - atomic_long_t intr_cbr;
38926 - atomic_long_t intr_tfh;
38927 - atomic_long_t intr_spurious;
38928 - atomic_long_t intr_mm_lock_failed;
38929 - atomic_long_t call_os;
38930 - atomic_long_t call_os_wait_queue;
38931 - atomic_long_t user_flush_tlb;
38932 - atomic_long_t user_unload_context;
38933 - atomic_long_t user_exception;
38934 - atomic_long_t set_context_option;
38935 - atomic_long_t check_context_retarget_intr;
38936 - atomic_long_t check_context_unload;
38937 - atomic_long_t tlb_dropin;
38938 - atomic_long_t tlb_preload_page;
38939 - atomic_long_t tlb_dropin_fail_no_asid;
38940 - atomic_long_t tlb_dropin_fail_upm;
38941 - atomic_long_t tlb_dropin_fail_invalid;
38942 - atomic_long_t tlb_dropin_fail_range_active;
38943 - atomic_long_t tlb_dropin_fail_idle;
38944 - atomic_long_t tlb_dropin_fail_fmm;
38945 - atomic_long_t tlb_dropin_fail_no_exception;
38946 - atomic_long_t tfh_stale_on_fault;
38947 - atomic_long_t mmu_invalidate_range;
38948 - atomic_long_t mmu_invalidate_page;
38949 - atomic_long_t flush_tlb;
38950 - atomic_long_t flush_tlb_gru;
38951 - atomic_long_t flush_tlb_gru_tgh;
38952 - atomic_long_t flush_tlb_gru_zero_asid;
38953 + atomic_long_unchecked_t vdata_alloc;
38954 + atomic_long_unchecked_t vdata_free;
38955 + atomic_long_unchecked_t gts_alloc;
38956 + atomic_long_unchecked_t gts_free;
38957 + atomic_long_unchecked_t gms_alloc;
38958 + atomic_long_unchecked_t gms_free;
38959 + atomic_long_unchecked_t gts_double_allocate;
38960 + atomic_long_unchecked_t assign_context;
38961 + atomic_long_unchecked_t assign_context_failed;
38962 + atomic_long_unchecked_t free_context;
38963 + atomic_long_unchecked_t load_user_context;
38964 + atomic_long_unchecked_t load_kernel_context;
38965 + atomic_long_unchecked_t lock_kernel_context;
38966 + atomic_long_unchecked_t unlock_kernel_context;
38967 + atomic_long_unchecked_t steal_user_context;
38968 + atomic_long_unchecked_t steal_kernel_context;
38969 + atomic_long_unchecked_t steal_context_failed;
38970 + atomic_long_unchecked_t nopfn;
38971 + atomic_long_unchecked_t asid_new;
38972 + atomic_long_unchecked_t asid_next;
38973 + atomic_long_unchecked_t asid_wrap;
38974 + atomic_long_unchecked_t asid_reuse;
38975 + atomic_long_unchecked_t intr;
38976 + atomic_long_unchecked_t intr_cbr;
38977 + atomic_long_unchecked_t intr_tfh;
38978 + atomic_long_unchecked_t intr_spurious;
38979 + atomic_long_unchecked_t intr_mm_lock_failed;
38980 + atomic_long_unchecked_t call_os;
38981 + atomic_long_unchecked_t call_os_wait_queue;
38982 + atomic_long_unchecked_t user_flush_tlb;
38983 + atomic_long_unchecked_t user_unload_context;
38984 + atomic_long_unchecked_t user_exception;
38985 + atomic_long_unchecked_t set_context_option;
38986 + atomic_long_unchecked_t check_context_retarget_intr;
38987 + atomic_long_unchecked_t check_context_unload;
38988 + atomic_long_unchecked_t tlb_dropin;
38989 + atomic_long_unchecked_t tlb_preload_page;
38990 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
38991 + atomic_long_unchecked_t tlb_dropin_fail_upm;
38992 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
38993 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
38994 + atomic_long_unchecked_t tlb_dropin_fail_idle;
38995 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
38996 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
38997 + atomic_long_unchecked_t tfh_stale_on_fault;
38998 + atomic_long_unchecked_t mmu_invalidate_range;
38999 + atomic_long_unchecked_t mmu_invalidate_page;
39000 + atomic_long_unchecked_t flush_tlb;
39001 + atomic_long_unchecked_t flush_tlb_gru;
39002 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39003 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39004
39005 - atomic_long_t copy_gpa;
39006 - atomic_long_t read_gpa;
39007 + atomic_long_unchecked_t copy_gpa;
39008 + atomic_long_unchecked_t read_gpa;
39009
39010 - atomic_long_t mesq_receive;
39011 - atomic_long_t mesq_receive_none;
39012 - atomic_long_t mesq_send;
39013 - atomic_long_t mesq_send_failed;
39014 - atomic_long_t mesq_noop;
39015 - atomic_long_t mesq_send_unexpected_error;
39016 - atomic_long_t mesq_send_lb_overflow;
39017 - atomic_long_t mesq_send_qlimit_reached;
39018 - atomic_long_t mesq_send_amo_nacked;
39019 - atomic_long_t mesq_send_put_nacked;
39020 - atomic_long_t mesq_page_overflow;
39021 - atomic_long_t mesq_qf_locked;
39022 - atomic_long_t mesq_qf_noop_not_full;
39023 - atomic_long_t mesq_qf_switch_head_failed;
39024 - atomic_long_t mesq_qf_unexpected_error;
39025 - atomic_long_t mesq_noop_unexpected_error;
39026 - atomic_long_t mesq_noop_lb_overflow;
39027 - atomic_long_t mesq_noop_qlimit_reached;
39028 - atomic_long_t mesq_noop_amo_nacked;
39029 - atomic_long_t mesq_noop_put_nacked;
39030 - atomic_long_t mesq_noop_page_overflow;
39031 + atomic_long_unchecked_t mesq_receive;
39032 + atomic_long_unchecked_t mesq_receive_none;
39033 + atomic_long_unchecked_t mesq_send;
39034 + atomic_long_unchecked_t mesq_send_failed;
39035 + atomic_long_unchecked_t mesq_noop;
39036 + atomic_long_unchecked_t mesq_send_unexpected_error;
39037 + atomic_long_unchecked_t mesq_send_lb_overflow;
39038 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39039 + atomic_long_unchecked_t mesq_send_amo_nacked;
39040 + atomic_long_unchecked_t mesq_send_put_nacked;
39041 + atomic_long_unchecked_t mesq_page_overflow;
39042 + atomic_long_unchecked_t mesq_qf_locked;
39043 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39044 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39045 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39046 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39047 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39048 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39049 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39050 + atomic_long_unchecked_t mesq_noop_put_nacked;
39051 + atomic_long_unchecked_t mesq_noop_page_overflow;
39052
39053 };
39054
39055 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39056 tghop_invalidate, mcsop_last};
39057
39058 struct mcs_op_statistic {
39059 - atomic_long_t count;
39060 - atomic_long_t total;
39061 + atomic_long_unchecked_t count;
39062 + atomic_long_unchecked_t total;
39063 unsigned long max;
39064 };
39065
39066 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39067
39068 #define STAT(id) do { \
39069 if (gru_options & OPT_STATS) \
39070 - atomic_long_inc(&gru_stats.id); \
39071 + atomic_long_inc_unchecked(&gru_stats.id); \
39072 } while (0)
39073
39074 #ifdef CONFIG_SGI_GRU_DEBUG
39075 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39076 index c862cd4..0d176fe 100644
39077 --- a/drivers/misc/sgi-xp/xp.h
39078 +++ b/drivers/misc/sgi-xp/xp.h
39079 @@ -288,7 +288,7 @@ struct xpc_interface {
39080 xpc_notify_func, void *);
39081 void (*received) (short, int, void *);
39082 enum xp_retval (*partid_to_nasids) (short, void *);
39083 -};
39084 +} __no_const;
39085
39086 extern struct xpc_interface xpc_interface;
39087
39088 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39089 index b94d5f7..7f494c5 100644
39090 --- a/drivers/misc/sgi-xp/xpc.h
39091 +++ b/drivers/misc/sgi-xp/xpc.h
39092 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39093 void (*received_payload) (struct xpc_channel *, void *);
39094 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39095 };
39096 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39097
39098 /* struct xpc_partition act_state values (for XPC HB) */
39099
39100 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39101 /* found in xpc_main.c */
39102 extern struct device *xpc_part;
39103 extern struct device *xpc_chan;
39104 -extern struct xpc_arch_operations xpc_arch_ops;
39105 +extern xpc_arch_operations_no_const xpc_arch_ops;
39106 extern int xpc_disengage_timelimit;
39107 extern int xpc_disengage_timedout;
39108 extern int xpc_activate_IRQ_rcvd;
39109 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39110 index d971817..33bdca5 100644
39111 --- a/drivers/misc/sgi-xp/xpc_main.c
39112 +++ b/drivers/misc/sgi-xp/xpc_main.c
39113 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39114 .notifier_call = xpc_system_die,
39115 };
39116
39117 -struct xpc_arch_operations xpc_arch_ops;
39118 +xpc_arch_operations_no_const xpc_arch_ops;
39119
39120 /*
39121 * Timer function to enforce the timelimit on the partition disengage.
39122 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39123
39124 if (((die_args->trapnr == X86_TRAP_MF) ||
39125 (die_args->trapnr == X86_TRAP_XF)) &&
39126 - !user_mode_vm(die_args->regs))
39127 + !user_mode(die_args->regs))
39128 xpc_die_deactivate();
39129
39130 break;
39131 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39132 index 6d8f701..35b6369 100644
39133 --- a/drivers/mmc/core/mmc_ops.c
39134 +++ b/drivers/mmc/core/mmc_ops.c
39135 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39136 void *data_buf;
39137 int is_on_stack;
39138
39139 - is_on_stack = object_is_on_stack(buf);
39140 + is_on_stack = object_starts_on_stack(buf);
39141 if (is_on_stack) {
39142 /*
39143 * dma onto stack is unsafe/nonportable, but callers to this
39144 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39145 index 53b8fd9..615b462 100644
39146 --- a/drivers/mmc/host/dw_mmc.h
39147 +++ b/drivers/mmc/host/dw_mmc.h
39148 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39149 int (*parse_dt)(struct dw_mci *host);
39150 int (*setup_bus)(struct dw_mci *host,
39151 struct device_node *slot_np, u8 bus_width);
39152 -};
39153 +} __do_const;
39154 #endif /* _DW_MMC_H_ */
39155 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39156 index 82a8de1..3c56ccb 100644
39157 --- a/drivers/mmc/host/sdhci-s3c.c
39158 +++ b/drivers/mmc/host/sdhci-s3c.c
39159 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39160 * we can use overriding functions instead of default.
39161 */
39162 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39163 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39164 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39165 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39166 + pax_open_kernel();
39167 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39168 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39169 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39170 + pax_close_kernel();
39171 }
39172
39173 /* It supports additional host capabilities if needed */
39174 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39175 index a4eb8b5..8c0628f 100644
39176 --- a/drivers/mtd/devices/doc2000.c
39177 +++ b/drivers/mtd/devices/doc2000.c
39178 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39179
39180 /* The ECC will not be calculated correctly if less than 512 is written */
39181 /* DBB-
39182 - if (len != 0x200 && eccbuf)
39183 + if (len != 0x200)
39184 printk(KERN_WARNING
39185 "ECC needs a full sector write (adr: %lx size %lx)\n",
39186 (long) to, (long) len);
39187 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39188 index 0c8bb6b..6f35deb 100644
39189 --- a/drivers/mtd/nand/denali.c
39190 +++ b/drivers/mtd/nand/denali.c
39191 @@ -24,6 +24,7 @@
39192 #include <linux/slab.h>
39193 #include <linux/mtd/mtd.h>
39194 #include <linux/module.h>
39195 +#include <linux/slab.h>
39196
39197 #include "denali.h"
39198
39199 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39200 index 51b9d6a..52af9a7 100644
39201 --- a/drivers/mtd/nftlmount.c
39202 +++ b/drivers/mtd/nftlmount.c
39203 @@ -24,6 +24,7 @@
39204 #include <asm/errno.h>
39205 #include <linux/delay.h>
39206 #include <linux/slab.h>
39207 +#include <linux/sched.h>
39208 #include <linux/mtd/mtd.h>
39209 #include <linux/mtd/nand.h>
39210 #include <linux/mtd/nftl.h>
39211 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39212 index 8dd6ba5..419cc1d 100644
39213 --- a/drivers/mtd/sm_ftl.c
39214 +++ b/drivers/mtd/sm_ftl.c
39215 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39216 #define SM_CIS_VENDOR_OFFSET 0x59
39217 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39218 {
39219 - struct attribute_group *attr_group;
39220 + attribute_group_no_const *attr_group;
39221 struct attribute **attributes;
39222 struct sm_sysfs_attribute *vendor_attribute;
39223
39224 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39225 index 272f81a..c3d767c 100644
39226 --- a/drivers/net/bonding/bond_main.c
39227 +++ b/drivers/net/bonding/bond_main.c
39228 @@ -4860,7 +4860,7 @@ static unsigned int bond_get_num_tx_queues(void)
39229 return tx_queues;
39230 }
39231
39232 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39233 +static struct rtnl_link_ops bond_link_ops = {
39234 .kind = "bond",
39235 .priv_size = sizeof(struct bonding),
39236 .setup = bond_setup,
39237 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39238 index 70dba5d..11a0919 100644
39239 --- a/drivers/net/ethernet/8390/ax88796.c
39240 +++ b/drivers/net/ethernet/8390/ax88796.c
39241 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39242 if (ax->plat->reg_offsets)
39243 ei_local->reg_offset = ax->plat->reg_offsets;
39244 else {
39245 + resource_size_t _mem_size = mem_size;
39246 + do_div(_mem_size, 0x18);
39247 ei_local->reg_offset = ax->reg_offsets;
39248 for (ret = 0; ret < 0x18; ret++)
39249 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39250 + ax->reg_offsets[ret] = _mem_size * ret;
39251 }
39252
39253 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39254 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39255 index 0991534..8098e92 100644
39256 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39257 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39258 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39259 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39260 {
39261 /* RX_MODE controlling object */
39262 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39263 + bnx2x_init_rx_mode_obj(bp);
39264
39265 /* multicast configuration controlling object */
39266 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39267 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39268 index 09b625e..15b16fe 100644
39269 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39270 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39271 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39272 return rc;
39273 }
39274
39275 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39276 - struct bnx2x_rx_mode_obj *o)
39277 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39278 {
39279 if (CHIP_IS_E1x(bp)) {
39280 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39281 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39282 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39283 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39284 } else {
39285 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39286 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39287 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39288 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39289 }
39290 }
39291
39292 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39293 index adbd91b..58ec94a 100644
39294 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39295 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39296 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39297
39298 /********************* RX MODE ****************/
39299
39300 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39301 - struct bnx2x_rx_mode_obj *o);
39302 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39303
39304 /**
39305 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39306 diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
39307 index 3ec98f2..b9980e0 100644
39308 --- a/drivers/net/ethernet/broadcom/tg3.c
39309 +++ b/drivers/net/ethernet/broadcom/tg3.c
39310 @@ -14403,8 +14403,10 @@ static void tg3_read_vpd(struct tg3 *tp)
39311 if (j + len > block_end)
39312 goto partno;
39313
39314 - memcpy(tp->fw_ver, &vpd_data[j], len);
39315 - strncat(tp->fw_ver, " bc ", vpdlen - len - 1);
39316 + if (len >= sizeof(tp->fw_ver))
39317 + len = sizeof(tp->fw_ver) - 1;
39318 + memset(tp->fw_ver, 0, sizeof(tp->fw_ver));
39319 + snprintf(tp->fw_ver, sizeof(tp->fw_ver), "%.*s bc ", len, &vpd_data[j]);
39320 }
39321
39322 partno:
39323 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39324 index d330e81..ce1fb9a 100644
39325 --- a/drivers/net/ethernet/broadcom/tg3.h
39326 +++ b/drivers/net/ethernet/broadcom/tg3.h
39327 @@ -146,6 +146,7 @@
39328 #define CHIPREV_ID_5750_A0 0x4000
39329 #define CHIPREV_ID_5750_A1 0x4001
39330 #define CHIPREV_ID_5750_A3 0x4003
39331 +#define CHIPREV_ID_5750_C1 0x4201
39332 #define CHIPREV_ID_5750_C2 0x4202
39333 #define CHIPREV_ID_5752_A0_HW 0x5000
39334 #define CHIPREV_ID_5752_A0 0x6000
39335 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39336 index 8cffcdf..aadf043 100644
39337 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39338 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39339 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39340 */
39341 struct l2t_skb_cb {
39342 arp_failure_handler_func arp_failure_handler;
39343 -};
39344 +} __no_const;
39345
39346 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39347
39348 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39349 index 4c83003..2a2a5b9 100644
39350 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39351 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39352 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39353 for (i=0; i<ETH_ALEN; i++) {
39354 tmp.addr[i] = dev->dev_addr[i];
39355 }
39356 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39357 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39358 break;
39359
39360 case DE4X5_SET_HWADDR: /* Set the hardware address */
39361 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39362 spin_lock_irqsave(&lp->lock, flags);
39363 memcpy(&statbuf, &lp->pktStats, ioc->len);
39364 spin_unlock_irqrestore(&lp->lock, flags);
39365 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39366 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39367 return -EFAULT;
39368 break;
39369 }
39370 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39371 index 4d6f3c5..6169e60 100644
39372 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39373 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39374 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39375
39376 if (wrapped)
39377 newacc += 65536;
39378 - ACCESS_ONCE(*acc) = newacc;
39379 + ACCESS_ONCE_RW(*acc) = newacc;
39380 }
39381
39382 void be_parse_stats(struct be_adapter *adapter)
39383 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39384 index 74d749e..eefb1bd 100644
39385 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39386 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39387 @@ -31,6 +31,8 @@
39388 #include <linux/netdevice.h>
39389 #include <linux/phy.h>
39390 #include <linux/platform_device.h>
39391 +#include <linux/interrupt.h>
39392 +#include <linux/irqreturn.h>
39393 #include <net/ip.h>
39394
39395 #include "ftgmac100.h"
39396 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39397 index b901a01..1ff32ee 100644
39398 --- a/drivers/net/ethernet/faraday/ftmac100.c
39399 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39400 @@ -31,6 +31,8 @@
39401 #include <linux/module.h>
39402 #include <linux/netdevice.h>
39403 #include <linux/platform_device.h>
39404 +#include <linux/interrupt.h>
39405 +#include <linux/irqreturn.h>
39406
39407 #include "ftmac100.h"
39408
39409 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39410 index bb9256a..56d8752 100644
39411 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39412 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39413 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39414 }
39415
39416 /* update the base incval used to calculate frequency adjustment */
39417 - ACCESS_ONCE(adapter->base_incval) = incval;
39418 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
39419 smp_mb();
39420
39421 /* need lock to prevent incorrect read while modifying cyclecounter */
39422 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39423 index fbe5363..266b4e3 100644
39424 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
39425 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39426 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39427 struct __vxge_hw_fifo *fifo;
39428 struct vxge_hw_fifo_config *config;
39429 u32 txdl_size, txdl_per_memblock;
39430 - struct vxge_hw_mempool_cbs fifo_mp_callback;
39431 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
39432 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
39433 + };
39434 +
39435 struct __vxge_hw_virtualpath *vpath;
39436
39437 if ((vp == NULL) || (attr == NULL)) {
39438 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39439 goto exit;
39440 }
39441
39442 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
39443 -
39444 fifo->mempool =
39445 __vxge_hw_mempool_create(vpath->hldev,
39446 fifo->config->memblock_size,
39447 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
39448 index 998974f..ecd26db 100644
39449 --- a/drivers/net/ethernet/realtek/r8169.c
39450 +++ b/drivers/net/ethernet/realtek/r8169.c
39451 @@ -741,22 +741,22 @@ struct rtl8169_private {
39452 struct mdio_ops {
39453 void (*write)(struct rtl8169_private *, int, int);
39454 int (*read)(struct rtl8169_private *, int);
39455 - } mdio_ops;
39456 + } __no_const mdio_ops;
39457
39458 struct pll_power_ops {
39459 void (*down)(struct rtl8169_private *);
39460 void (*up)(struct rtl8169_private *);
39461 - } pll_power_ops;
39462 + } __no_const pll_power_ops;
39463
39464 struct jumbo_ops {
39465 void (*enable)(struct rtl8169_private *);
39466 void (*disable)(struct rtl8169_private *);
39467 - } jumbo_ops;
39468 + } __no_const jumbo_ops;
39469
39470 struct csi_ops {
39471 void (*write)(struct rtl8169_private *, int, int);
39472 u32 (*read)(struct rtl8169_private *, int);
39473 - } csi_ops;
39474 + } __no_const csi_ops;
39475
39476 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
39477 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
39478 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
39479 index 3f93624..cf01144 100644
39480 --- a/drivers/net/ethernet/sfc/ptp.c
39481 +++ b/drivers/net/ethernet/sfc/ptp.c
39482 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
39483 (u32)((u64)ptp->start.dma_addr >> 32));
39484
39485 /* Clear flag that signals MC ready */
39486 - ACCESS_ONCE(*start) = 0;
39487 + ACCESS_ONCE_RW(*start) = 0;
39488 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
39489 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
39490
39491 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39492 index 0c74a70..3bc6f68 100644
39493 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39494 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39495 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
39496
39497 writel(value, ioaddr + MMC_CNTRL);
39498
39499 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39500 - MMC_CNTRL, value);
39501 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39502 +// MMC_CNTRL, value);
39503 }
39504
39505 /* To mask all all interrupts.*/
39506 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
39507 index e6fe0d8..2b7d752 100644
39508 --- a/drivers/net/hyperv/hyperv_net.h
39509 +++ b/drivers/net/hyperv/hyperv_net.h
39510 @@ -101,7 +101,7 @@ struct rndis_device {
39511
39512 enum rndis_device_state state;
39513 bool link_state;
39514 - atomic_t new_req_id;
39515 + atomic_unchecked_t new_req_id;
39516
39517 spinlock_t request_lock;
39518 struct list_head req_list;
39519 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
39520 index 2b657d4..9903bc0 100644
39521 --- a/drivers/net/hyperv/rndis_filter.c
39522 +++ b/drivers/net/hyperv/rndis_filter.c
39523 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
39524 * template
39525 */
39526 set = &rndis_msg->msg.set_req;
39527 - set->req_id = atomic_inc_return(&dev->new_req_id);
39528 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39529
39530 /* Add to the request list */
39531 spin_lock_irqsave(&dev->request_lock, flags);
39532 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
39533
39534 /* Setup the rndis set */
39535 halt = &request->request_msg.msg.halt_req;
39536 - halt->req_id = atomic_inc_return(&dev->new_req_id);
39537 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39538
39539 /* Ignore return since this msg is optional. */
39540 rndis_filter_send_request(dev, request);
39541 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
39542 index 1e9cb0b..7839125 100644
39543 --- a/drivers/net/ieee802154/fakehard.c
39544 +++ b/drivers/net/ieee802154/fakehard.c
39545 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
39546 phy->transmit_power = 0xbf;
39547
39548 dev->netdev_ops = &fake_ops;
39549 - dev->ml_priv = &fake_mlme;
39550 + dev->ml_priv = (void *)&fake_mlme;
39551
39552 priv = netdev_priv(dev);
39553 priv->phy = phy;
39554 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
39555 index e5cb723..1fc0461 100644
39556 --- a/drivers/net/macvlan.c
39557 +++ b/drivers/net/macvlan.c
39558 @@ -852,13 +852,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
39559 int macvlan_link_register(struct rtnl_link_ops *ops)
39560 {
39561 /* common fields */
39562 - ops->priv_size = sizeof(struct macvlan_dev);
39563 - ops->validate = macvlan_validate;
39564 - ops->maxtype = IFLA_MACVLAN_MAX;
39565 - ops->policy = macvlan_policy;
39566 - ops->changelink = macvlan_changelink;
39567 - ops->get_size = macvlan_get_size;
39568 - ops->fill_info = macvlan_fill_info;
39569 + pax_open_kernel();
39570 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
39571 + *(void **)&ops->validate = macvlan_validate;
39572 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
39573 + *(const void **)&ops->policy = macvlan_policy;
39574 + *(void **)&ops->changelink = macvlan_changelink;
39575 + *(void **)&ops->get_size = macvlan_get_size;
39576 + *(void **)&ops->fill_info = macvlan_fill_info;
39577 + pax_close_kernel();
39578
39579 return rtnl_link_register(ops);
39580 };
39581 @@ -914,7 +916,7 @@ static int macvlan_device_event(struct notifier_block *unused,
39582 return NOTIFY_DONE;
39583 }
39584
39585 -static struct notifier_block macvlan_notifier_block __read_mostly = {
39586 +static struct notifier_block macvlan_notifier_block = {
39587 .notifier_call = macvlan_device_event,
39588 };
39589
39590 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
39591 index 0f0f9ce..0ca5819 100644
39592 --- a/drivers/net/macvtap.c
39593 +++ b/drivers/net/macvtap.c
39594 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
39595 return NOTIFY_DONE;
39596 }
39597
39598 -static struct notifier_block macvtap_notifier_block __read_mostly = {
39599 +static struct notifier_block macvtap_notifier_block = {
39600 .notifier_call = macvtap_device_event,
39601 };
39602
39603 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
39604 index daec9b0..6428fcb 100644
39605 --- a/drivers/net/phy/mdio-bitbang.c
39606 +++ b/drivers/net/phy/mdio-bitbang.c
39607 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
39608 struct mdiobb_ctrl *ctrl = bus->priv;
39609
39610 module_put(ctrl->ops->owner);
39611 + mdiobus_unregister(bus);
39612 mdiobus_free(bus);
39613 }
39614 EXPORT_SYMBOL(free_mdio_bitbang);
39615 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
39616 index 508570e..f706dc7 100644
39617 --- a/drivers/net/ppp/ppp_generic.c
39618 +++ b/drivers/net/ppp/ppp_generic.c
39619 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39620 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
39621 struct ppp_stats stats;
39622 struct ppp_comp_stats cstats;
39623 - char *vers;
39624
39625 switch (cmd) {
39626 case SIOCGPPPSTATS:
39627 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39628 break;
39629
39630 case SIOCGPPPVER:
39631 - vers = PPP_VERSION;
39632 - if (copy_to_user(addr, vers, strlen(vers) + 1))
39633 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
39634 break;
39635 err = 0;
39636 break;
39637 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
39638 index 8efe47a..a8075c5 100644
39639 --- a/drivers/net/team/team.c
39640 +++ b/drivers/net/team/team.c
39641 @@ -2603,7 +2603,7 @@ static int team_device_event(struct notifier_block *unused,
39642 return NOTIFY_DONE;
39643 }
39644
39645 -static struct notifier_block team_notifier_block __read_mostly = {
39646 +static struct notifier_block team_notifier_block = {
39647 .notifier_call = team_device_event,
39648 };
39649
39650 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
39651 index cb95fe5..a5bdab5 100644
39652 --- a/drivers/net/tun.c
39653 +++ b/drivers/net/tun.c
39654 @@ -1838,7 +1838,7 @@ unlock:
39655 }
39656
39657 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39658 - unsigned long arg, int ifreq_len)
39659 + unsigned long arg, size_t ifreq_len)
39660 {
39661 struct tun_file *tfile = file->private_data;
39662 struct tun_struct *tun;
39663 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39664 int vnet_hdr_sz;
39665 int ret;
39666
39667 + if (ifreq_len > sizeof ifr)
39668 + return -EFAULT;
39669 +
39670 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
39671 if (copy_from_user(&ifr, argp, ifreq_len))
39672 return -EFAULT;
39673 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
39674 index cd8ccb2..cff5144 100644
39675 --- a/drivers/net/usb/hso.c
39676 +++ b/drivers/net/usb/hso.c
39677 @@ -71,7 +71,7 @@
39678 #include <asm/byteorder.h>
39679 #include <linux/serial_core.h>
39680 #include <linux/serial.h>
39681 -
39682 +#include <asm/local.h>
39683
39684 #define MOD_AUTHOR "Option Wireless"
39685 #define MOD_DESCRIPTION "USB High Speed Option driver"
39686 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
39687 struct urb *urb;
39688
39689 urb = serial->rx_urb[0];
39690 - if (serial->port.count > 0) {
39691 + if (atomic_read(&serial->port.count) > 0) {
39692 count = put_rxbuf_data(urb, serial);
39693 if (count == -1)
39694 return;
39695 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
39696 DUMP1(urb->transfer_buffer, urb->actual_length);
39697
39698 /* Anyone listening? */
39699 - if (serial->port.count == 0)
39700 + if (atomic_read(&serial->port.count) == 0)
39701 return;
39702
39703 if (status == 0) {
39704 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
39705 tty_port_tty_set(&serial->port, tty);
39706
39707 /* check for port already opened, if not set the termios */
39708 - serial->port.count++;
39709 - if (serial->port.count == 1) {
39710 + if (atomic_inc_return(&serial->port.count) == 1) {
39711 serial->rx_state = RX_IDLE;
39712 /* Force default termio settings */
39713 _hso_serial_set_termios(tty, NULL);
39714 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
39715 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
39716 if (result) {
39717 hso_stop_serial_device(serial->parent);
39718 - serial->port.count--;
39719 + atomic_dec(&serial->port.count);
39720 kref_put(&serial->parent->ref, hso_serial_ref_free);
39721 }
39722 } else {
39723 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
39724
39725 /* reset the rts and dtr */
39726 /* do the actual close */
39727 - serial->port.count--;
39728 + atomic_dec(&serial->port.count);
39729
39730 - if (serial->port.count <= 0) {
39731 - serial->port.count = 0;
39732 + if (atomic_read(&serial->port.count) <= 0) {
39733 + atomic_set(&serial->port.count, 0);
39734 tty_port_tty_set(&serial->port, NULL);
39735 if (!usb_gone)
39736 hso_stop_serial_device(serial->parent);
39737 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
39738
39739 /* the actual setup */
39740 spin_lock_irqsave(&serial->serial_lock, flags);
39741 - if (serial->port.count)
39742 + if (atomic_read(&serial->port.count))
39743 _hso_serial_set_termios(tty, old);
39744 else
39745 tty->termios = *old;
39746 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
39747 D1("Pending read interrupt on port %d\n", i);
39748 spin_lock(&serial->serial_lock);
39749 if (serial->rx_state == RX_IDLE &&
39750 - serial->port.count > 0) {
39751 + atomic_read(&serial->port.count) > 0) {
39752 /* Setup and send a ctrl req read on
39753 * port i */
39754 if (!serial->rx_urb_filled[0]) {
39755 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
39756 /* Start all serial ports */
39757 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
39758 if (serial_table[i] && (serial_table[i]->interface == iface)) {
39759 - if (dev2ser(serial_table[i])->port.count) {
39760 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
39761 result =
39762 hso_start_serial_device(serial_table[i], GFP_NOIO);
39763 hso_kick_transmit(dev2ser(serial_table[i]));
39764 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
39765 index 6993bfa..9053a34 100644
39766 --- a/drivers/net/vxlan.c
39767 +++ b/drivers/net/vxlan.c
39768 @@ -1428,7 +1428,7 @@ nla_put_failure:
39769 return -EMSGSIZE;
39770 }
39771
39772 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
39773 +static struct rtnl_link_ops vxlan_link_ops = {
39774 .kind = "vxlan",
39775 .maxtype = IFLA_VXLAN_MAX,
39776 .policy = vxlan_policy,
39777 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
39778 index 77fa428..996b355 100644
39779 --- a/drivers/net/wireless/at76c50x-usb.c
39780 +++ b/drivers/net/wireless/at76c50x-usb.c
39781 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
39782 }
39783
39784 /* Convert timeout from the DFU status to jiffies */
39785 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
39786 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
39787 {
39788 return msecs_to_jiffies((s->poll_timeout[2] << 16)
39789 | (s->poll_timeout[1] << 8)
39790 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39791 index 8d78253..bebbb68 100644
39792 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39793 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39794 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39795 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
39796 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
39797
39798 - ACCESS_ONCE(ads->ds_link) = i->link;
39799 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
39800 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
39801 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
39802
39803 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
39804 ctl6 = SM(i->keytype, AR_EncrType);
39805 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39806
39807 if ((i->is_first || i->is_last) &&
39808 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
39809 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
39810 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
39811 | set11nTries(i->rates, 1)
39812 | set11nTries(i->rates, 2)
39813 | set11nTries(i->rates, 3)
39814 | (i->dur_update ? AR_DurUpdateEna : 0)
39815 | SM(0, AR_BurstDur);
39816
39817 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
39818 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
39819 | set11nRate(i->rates, 1)
39820 | set11nRate(i->rates, 2)
39821 | set11nRate(i->rates, 3);
39822 } else {
39823 - ACCESS_ONCE(ads->ds_ctl2) = 0;
39824 - ACCESS_ONCE(ads->ds_ctl3) = 0;
39825 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
39826 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
39827 }
39828
39829 if (!i->is_first) {
39830 - ACCESS_ONCE(ads->ds_ctl0) = 0;
39831 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
39832 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
39833 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
39834 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
39835 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
39836 return;
39837 }
39838
39839 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39840 break;
39841 }
39842
39843 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
39844 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
39845 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
39846 | SM(i->txpower, AR_XmitPower)
39847 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
39848 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39849 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
39850 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
39851
39852 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
39853 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
39854 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
39855 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
39856
39857 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
39858 return;
39859
39860 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
39861 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
39862 | set11nPktDurRTSCTS(i->rates, 1);
39863
39864 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
39865 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
39866 | set11nPktDurRTSCTS(i->rates, 3);
39867
39868 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
39869 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
39870 | set11nRateFlags(i->rates, 1)
39871 | set11nRateFlags(i->rates, 2)
39872 | set11nRateFlags(i->rates, 3)
39873 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39874 index 301bf72..3f5654f 100644
39875 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39876 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39877 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39878 (i->qcu << AR_TxQcuNum_S) | desc_len;
39879
39880 checksum += val;
39881 - ACCESS_ONCE(ads->info) = val;
39882 + ACCESS_ONCE_RW(ads->info) = val;
39883
39884 checksum += i->link;
39885 - ACCESS_ONCE(ads->link) = i->link;
39886 + ACCESS_ONCE_RW(ads->link) = i->link;
39887
39888 checksum += i->buf_addr[0];
39889 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
39890 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
39891 checksum += i->buf_addr[1];
39892 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
39893 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
39894 checksum += i->buf_addr[2];
39895 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
39896 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
39897 checksum += i->buf_addr[3];
39898 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
39899 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
39900
39901 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
39902 - ACCESS_ONCE(ads->ctl3) = val;
39903 + ACCESS_ONCE_RW(ads->ctl3) = val;
39904 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
39905 - ACCESS_ONCE(ads->ctl5) = val;
39906 + ACCESS_ONCE_RW(ads->ctl5) = val;
39907 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
39908 - ACCESS_ONCE(ads->ctl7) = val;
39909 + ACCESS_ONCE_RW(ads->ctl7) = val;
39910 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
39911 - ACCESS_ONCE(ads->ctl9) = val;
39912 + ACCESS_ONCE_RW(ads->ctl9) = val;
39913
39914 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
39915 - ACCESS_ONCE(ads->ctl10) = checksum;
39916 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
39917
39918 if (i->is_first || i->is_last) {
39919 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
39920 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
39921 | set11nTries(i->rates, 1)
39922 | set11nTries(i->rates, 2)
39923 | set11nTries(i->rates, 3)
39924 | (i->dur_update ? AR_DurUpdateEna : 0)
39925 | SM(0, AR_BurstDur);
39926
39927 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
39928 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
39929 | set11nRate(i->rates, 1)
39930 | set11nRate(i->rates, 2)
39931 | set11nRate(i->rates, 3);
39932 } else {
39933 - ACCESS_ONCE(ads->ctl13) = 0;
39934 - ACCESS_ONCE(ads->ctl14) = 0;
39935 + ACCESS_ONCE_RW(ads->ctl13) = 0;
39936 + ACCESS_ONCE_RW(ads->ctl14) = 0;
39937 }
39938
39939 ads->ctl20 = 0;
39940 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39941
39942 ctl17 = SM(i->keytype, AR_EncrType);
39943 if (!i->is_first) {
39944 - ACCESS_ONCE(ads->ctl11) = 0;
39945 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
39946 - ACCESS_ONCE(ads->ctl15) = 0;
39947 - ACCESS_ONCE(ads->ctl16) = 0;
39948 - ACCESS_ONCE(ads->ctl17) = ctl17;
39949 - ACCESS_ONCE(ads->ctl18) = 0;
39950 - ACCESS_ONCE(ads->ctl19) = 0;
39951 + ACCESS_ONCE_RW(ads->ctl11) = 0;
39952 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
39953 + ACCESS_ONCE_RW(ads->ctl15) = 0;
39954 + ACCESS_ONCE_RW(ads->ctl16) = 0;
39955 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
39956 + ACCESS_ONCE_RW(ads->ctl18) = 0;
39957 + ACCESS_ONCE_RW(ads->ctl19) = 0;
39958 return;
39959 }
39960
39961 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
39962 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
39963 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
39964 | SM(i->txpower, AR_XmitPower)
39965 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
39966 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39967 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
39968 ctl12 |= SM(val, AR_PAPRDChainMask);
39969
39970 - ACCESS_ONCE(ads->ctl12) = ctl12;
39971 - ACCESS_ONCE(ads->ctl17) = ctl17;
39972 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
39973 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
39974
39975 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
39976 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
39977 | set11nPktDurRTSCTS(i->rates, 1);
39978
39979 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
39980 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
39981 | set11nPktDurRTSCTS(i->rates, 3);
39982
39983 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
39984 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
39985 | set11nRateFlags(i->rates, 1)
39986 | set11nRateFlags(i->rates, 2)
39987 | set11nRateFlags(i->rates, 3)
39988 | SM(i->rtscts_rate, AR_RTSCTSRate);
39989
39990 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
39991 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
39992 }
39993
39994 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
39995 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
39996 index 9d26fc5..60d9f14 100644
39997 --- a/drivers/net/wireless/ath/ath9k/hw.h
39998 +++ b/drivers/net/wireless/ath/ath9k/hw.h
39999 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
40000
40001 /* ANI */
40002 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40003 -};
40004 +} __no_const;
40005
40006 /**
40007 * struct ath_hw_ops - callbacks used by hardware code and driver code
40008 @@ -688,7 +688,7 @@ struct ath_hw_ops {
40009 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
40010 struct ath_hw_antcomb_conf *antconf);
40011 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
40012 -};
40013 +} __no_const;
40014
40015 struct ath_nf_limits {
40016 s16 max;
40017 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40018 index 3726cd6..b655808 100644
40019 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40020 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40021 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40022 */
40023 if (il3945_mod_params.disable_hw_scan) {
40024 D_INFO("Disabling hw_scan\n");
40025 - il3945_mac_ops.hw_scan = NULL;
40026 + pax_open_kernel();
40027 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40028 + pax_close_kernel();
40029 }
40030
40031 D_INFO("*** LOAD DRIVER ***\n");
40032 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40033 index 5b9533e..7733880 100644
40034 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40035 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40036 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40037 {
40038 struct iwl_priv *priv = file->private_data;
40039 char buf[64];
40040 - int buf_size;
40041 + size_t buf_size;
40042 u32 offset, len;
40043
40044 memset(buf, 0, sizeof(buf));
40045 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40046 struct iwl_priv *priv = file->private_data;
40047
40048 char buf[8];
40049 - int buf_size;
40050 + size_t buf_size;
40051 u32 reset_flag;
40052
40053 memset(buf, 0, sizeof(buf));
40054 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40055 {
40056 struct iwl_priv *priv = file->private_data;
40057 char buf[8];
40058 - int buf_size;
40059 + size_t buf_size;
40060 int ht40;
40061
40062 memset(buf, 0, sizeof(buf));
40063 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40064 {
40065 struct iwl_priv *priv = file->private_data;
40066 char buf[8];
40067 - int buf_size;
40068 + size_t buf_size;
40069 int value;
40070
40071 memset(buf, 0, sizeof(buf));
40072 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40073 {
40074 struct iwl_priv *priv = file->private_data;
40075 char buf[8];
40076 - int buf_size;
40077 + size_t buf_size;
40078 int clear;
40079
40080 memset(buf, 0, sizeof(buf));
40081 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40082 {
40083 struct iwl_priv *priv = file->private_data;
40084 char buf[8];
40085 - int buf_size;
40086 + size_t buf_size;
40087 int trace;
40088
40089 memset(buf, 0, sizeof(buf));
40090 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40091 {
40092 struct iwl_priv *priv = file->private_data;
40093 char buf[8];
40094 - int buf_size;
40095 + size_t buf_size;
40096 int missed;
40097
40098 memset(buf, 0, sizeof(buf));
40099 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40100
40101 struct iwl_priv *priv = file->private_data;
40102 char buf[8];
40103 - int buf_size;
40104 + size_t buf_size;
40105 int plcp;
40106
40107 memset(buf, 0, sizeof(buf));
40108 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40109
40110 struct iwl_priv *priv = file->private_data;
40111 char buf[8];
40112 - int buf_size;
40113 + size_t buf_size;
40114 int flush;
40115
40116 memset(buf, 0, sizeof(buf));
40117 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40118
40119 struct iwl_priv *priv = file->private_data;
40120 char buf[8];
40121 - int buf_size;
40122 + size_t buf_size;
40123 int rts;
40124
40125 if (!priv->cfg->ht_params)
40126 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40127 {
40128 struct iwl_priv *priv = file->private_data;
40129 char buf[8];
40130 - int buf_size;
40131 + size_t buf_size;
40132
40133 memset(buf, 0, sizeof(buf));
40134 buf_size = min(count, sizeof(buf) - 1);
40135 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40136 struct iwl_priv *priv = file->private_data;
40137 u32 event_log_flag;
40138 char buf[8];
40139 - int buf_size;
40140 + size_t buf_size;
40141
40142 /* check that the interface is up */
40143 if (!iwl_is_ready(priv))
40144 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40145 struct iwl_priv *priv = file->private_data;
40146 char buf[8];
40147 u32 calib_disabled;
40148 - int buf_size;
40149 + size_t buf_size;
40150
40151 memset(buf, 0, sizeof(buf));
40152 buf_size = min(count, sizeof(buf) - 1);
40153 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40154 index 35708b9..31f7754 100644
40155 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40156 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40157 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40158 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40159
40160 char buf[8];
40161 - int buf_size;
40162 + size_t buf_size;
40163 u32 reset_flag;
40164
40165 memset(buf, 0, sizeof(buf));
40166 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40167 {
40168 struct iwl_trans *trans = file->private_data;
40169 char buf[8];
40170 - int buf_size;
40171 + size_t buf_size;
40172 int csr;
40173
40174 memset(buf, 0, sizeof(buf));
40175 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40176 index ff90855..e46d223 100644
40177 --- a/drivers/net/wireless/mac80211_hwsim.c
40178 +++ b/drivers/net/wireless/mac80211_hwsim.c
40179 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
40180
40181 if (channels > 1) {
40182 hwsim_if_comb.num_different_channels = channels;
40183 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40184 - mac80211_hwsim_ops.cancel_hw_scan =
40185 - mac80211_hwsim_cancel_hw_scan;
40186 - mac80211_hwsim_ops.sw_scan_start = NULL;
40187 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40188 - mac80211_hwsim_ops.remain_on_channel =
40189 - mac80211_hwsim_roc;
40190 - mac80211_hwsim_ops.cancel_remain_on_channel =
40191 - mac80211_hwsim_croc;
40192 - mac80211_hwsim_ops.add_chanctx =
40193 - mac80211_hwsim_add_chanctx;
40194 - mac80211_hwsim_ops.remove_chanctx =
40195 - mac80211_hwsim_remove_chanctx;
40196 - mac80211_hwsim_ops.change_chanctx =
40197 - mac80211_hwsim_change_chanctx;
40198 - mac80211_hwsim_ops.assign_vif_chanctx =
40199 - mac80211_hwsim_assign_vif_chanctx;
40200 - mac80211_hwsim_ops.unassign_vif_chanctx =
40201 - mac80211_hwsim_unassign_vif_chanctx;
40202 + pax_open_kernel();
40203 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40204 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40205 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40206 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40207 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40208 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40209 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40210 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40211 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40212 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40213 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40214 + pax_close_kernel();
40215 }
40216
40217 spin_lock_init(&hwsim_radio_lock);
40218 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40219 index abe1d03..fb02c22 100644
40220 --- a/drivers/net/wireless/rndis_wlan.c
40221 +++ b/drivers/net/wireless/rndis_wlan.c
40222 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40223
40224 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40225
40226 - if (rts_threshold < 0 || rts_threshold > 2347)
40227 + if (rts_threshold > 2347)
40228 rts_threshold = 2347;
40229
40230 tmp = cpu_to_le32(rts_threshold);
40231 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40232 index 0751b35..246ba3e 100644
40233 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40234 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40235 @@ -398,7 +398,7 @@ struct rt2x00_intf {
40236 * for hardware which doesn't support hardware
40237 * sequence counting.
40238 */
40239 - atomic_t seqno;
40240 + atomic_unchecked_t seqno;
40241 };
40242
40243 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40244 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40245 index e488b94..14b6a0c 100644
40246 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40247 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40248 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40249 * sequence counter given by mac80211.
40250 */
40251 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40252 - seqno = atomic_add_return(0x10, &intf->seqno);
40253 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40254 else
40255 - seqno = atomic_read(&intf->seqno);
40256 + seqno = atomic_read_unchecked(&intf->seqno);
40257
40258 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40259 hdr->seq_ctrl |= cpu_to_le16(seqno);
40260 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40261 index e57ee48..541cf6c 100644
40262 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40263 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40264 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40265
40266 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40267
40268 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40269 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40270 + pax_open_kernel();
40271 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40272 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40273 + pax_close_kernel();
40274
40275 wl1251_info("using dedicated interrupt line");
40276 } else {
40277 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40278 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40279 + pax_open_kernel();
40280 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40281 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40282 + pax_close_kernel();
40283
40284 wl1251_info("using SDIO interrupt");
40285 }
40286 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40287 index e5f5f8f..fdf15b7 100644
40288 --- a/drivers/net/wireless/ti/wl12xx/main.c
40289 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40290 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40291 sizeof(wl->conf.mem));
40292
40293 /* read data preparation is only needed by wl127x */
40294 - wl->ops->prepare_read = wl127x_prepare_read;
40295 + pax_open_kernel();
40296 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40297 + pax_close_kernel();
40298
40299 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40300 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40301 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40302 sizeof(wl->conf.mem));
40303
40304 /* read data preparation is only needed by wl127x */
40305 - wl->ops->prepare_read = wl127x_prepare_read;
40306 + pax_open_kernel();
40307 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40308 + pax_close_kernel();
40309
40310 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40311 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40312 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40313 index 8d8c1f8..e754844 100644
40314 --- a/drivers/net/wireless/ti/wl18xx/main.c
40315 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40316 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40317 }
40318
40319 if (!checksum_param) {
40320 - wl18xx_ops.set_rx_csum = NULL;
40321 - wl18xx_ops.init_vif = NULL;
40322 + pax_open_kernel();
40323 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40324 + *(void **)&wl18xx_ops.init_vif = NULL;
40325 + pax_close_kernel();
40326 }
40327
40328 /* Enable 11a Band only if we have 5G antennas */
40329 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
40330 index ef2b171..bb513a6 100644
40331 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
40332 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
40333 @@ -387,7 +387,7 @@ static inline void handle_regs_int(struct urb *urb)
40334 {
40335 struct zd_usb *usb = urb->context;
40336 struct zd_usb_interrupt *intr = &usb->intr;
40337 - int len;
40338 + unsigned int len;
40339 u16 int_num;
40340
40341 ZD_ASSERT(in_interrupt());
40342 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
40343 index d93b2b6..ae50401 100644
40344 --- a/drivers/oprofile/buffer_sync.c
40345 +++ b/drivers/oprofile/buffer_sync.c
40346 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
40347 if (cookie == NO_COOKIE)
40348 offset = pc;
40349 if (cookie == INVALID_COOKIE) {
40350 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40351 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40352 offset = pc;
40353 }
40354 if (cookie != last_cookie) {
40355 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
40356 /* add userspace sample */
40357
40358 if (!mm) {
40359 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
40360 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
40361 return 0;
40362 }
40363
40364 cookie = lookup_dcookie(mm, s->eip, &offset);
40365
40366 if (cookie == INVALID_COOKIE) {
40367 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40368 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40369 return 0;
40370 }
40371
40372 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
40373 /* ignore backtraces if failed to add a sample */
40374 if (state == sb_bt_start) {
40375 state = sb_bt_ignore;
40376 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
40377 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
40378 }
40379 }
40380 release_mm(mm);
40381 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
40382 index c0cc4e7..44d4e54 100644
40383 --- a/drivers/oprofile/event_buffer.c
40384 +++ b/drivers/oprofile/event_buffer.c
40385 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
40386 }
40387
40388 if (buffer_pos == buffer_size) {
40389 - atomic_inc(&oprofile_stats.event_lost_overflow);
40390 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
40391 return;
40392 }
40393
40394 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
40395 index ed2c3ec..deda85a 100644
40396 --- a/drivers/oprofile/oprof.c
40397 +++ b/drivers/oprofile/oprof.c
40398 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
40399 if (oprofile_ops.switch_events())
40400 return;
40401
40402 - atomic_inc(&oprofile_stats.multiplex_counter);
40403 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
40404 start_switch_worker();
40405 }
40406
40407 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
40408 index 84a208d..d61b0a1 100644
40409 --- a/drivers/oprofile/oprofile_files.c
40410 +++ b/drivers/oprofile/oprofile_files.c
40411 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
40412
40413 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
40414
40415 -static ssize_t timeout_read(struct file *file, char __user *buf,
40416 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
40417 size_t count, loff_t *offset)
40418 {
40419 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
40420 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
40421 index 917d28e..d62d981 100644
40422 --- a/drivers/oprofile/oprofile_stats.c
40423 +++ b/drivers/oprofile/oprofile_stats.c
40424 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
40425 cpu_buf->sample_invalid_eip = 0;
40426 }
40427
40428 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
40429 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
40430 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
40431 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
40432 - atomic_set(&oprofile_stats.multiplex_counter, 0);
40433 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
40434 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
40435 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
40436 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
40437 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
40438 }
40439
40440
40441 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
40442 index 38b6fc0..b5cbfce 100644
40443 --- a/drivers/oprofile/oprofile_stats.h
40444 +++ b/drivers/oprofile/oprofile_stats.h
40445 @@ -13,11 +13,11 @@
40446 #include <linux/atomic.h>
40447
40448 struct oprofile_stat_struct {
40449 - atomic_t sample_lost_no_mm;
40450 - atomic_t sample_lost_no_mapping;
40451 - atomic_t bt_lost_no_mapping;
40452 - atomic_t event_lost_overflow;
40453 - atomic_t multiplex_counter;
40454 + atomic_unchecked_t sample_lost_no_mm;
40455 + atomic_unchecked_t sample_lost_no_mapping;
40456 + atomic_unchecked_t bt_lost_no_mapping;
40457 + atomic_unchecked_t event_lost_overflow;
40458 + atomic_unchecked_t multiplex_counter;
40459 };
40460
40461 extern struct oprofile_stat_struct oprofile_stats;
40462 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
40463 index 849357c..b83c1e0 100644
40464 --- a/drivers/oprofile/oprofilefs.c
40465 +++ b/drivers/oprofile/oprofilefs.c
40466 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
40467
40468
40469 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
40470 - char const *name, atomic_t *val)
40471 + char const *name, atomic_unchecked_t *val)
40472 {
40473 return __oprofilefs_create_file(sb, root, name,
40474 &atomic_ro_fops, 0444, val);
40475 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
40476 index 93404f7..4a313d8 100644
40477 --- a/drivers/oprofile/timer_int.c
40478 +++ b/drivers/oprofile/timer_int.c
40479 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
40480 return NOTIFY_OK;
40481 }
40482
40483 -static struct notifier_block __refdata oprofile_cpu_notifier = {
40484 +static struct notifier_block oprofile_cpu_notifier = {
40485 .notifier_call = oprofile_cpu_notify,
40486 };
40487
40488 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
40489 index 3f56bc0..707d642 100644
40490 --- a/drivers/parport/procfs.c
40491 +++ b/drivers/parport/procfs.c
40492 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
40493
40494 *ppos += len;
40495
40496 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
40497 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
40498 }
40499
40500 #ifdef CONFIG_PARPORT_1284
40501 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
40502
40503 *ppos += len;
40504
40505 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
40506 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
40507 }
40508 #endif /* IEEE1284.3 support. */
40509
40510 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
40511 index c35e8ad..fc33beb 100644
40512 --- a/drivers/pci/hotplug/acpiphp_ibm.c
40513 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
40514 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
40515 goto init_cleanup;
40516 }
40517
40518 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40519 + pax_open_kernel();
40520 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40521 + pax_close_kernel();
40522 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
40523
40524 return retval;
40525 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
40526 index a6a71c4..c91097b 100644
40527 --- a/drivers/pci/hotplug/cpcihp_generic.c
40528 +++ b/drivers/pci/hotplug/cpcihp_generic.c
40529 @@ -73,7 +73,6 @@ static u16 port;
40530 static unsigned int enum_bit;
40531 static u8 enum_mask;
40532
40533 -static struct cpci_hp_controller_ops generic_hpc_ops;
40534 static struct cpci_hp_controller generic_hpc;
40535
40536 static int __init validate_parameters(void)
40537 @@ -139,6 +138,10 @@ static int query_enum(void)
40538 return ((value & enum_mask) == enum_mask);
40539 }
40540
40541 +static struct cpci_hp_controller_ops generic_hpc_ops = {
40542 + .query_enum = query_enum,
40543 +};
40544 +
40545 static int __init cpcihp_generic_init(void)
40546 {
40547 int status;
40548 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
40549 pci_dev_put(dev);
40550
40551 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
40552 - generic_hpc_ops.query_enum = query_enum;
40553 generic_hpc.ops = &generic_hpc_ops;
40554
40555 status = cpci_hp_register_controller(&generic_hpc);
40556 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
40557 index 449b4bb..257e2e8 100644
40558 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
40559 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
40560 @@ -59,7 +59,6 @@
40561 /* local variables */
40562 static bool debug;
40563 static bool poll;
40564 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
40565 static struct cpci_hp_controller zt5550_hpc;
40566
40567 /* Primary cPCI bus bridge device */
40568 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
40569 return 0;
40570 }
40571
40572 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
40573 + .query_enum = zt5550_hc_query_enum,
40574 +};
40575 +
40576 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
40577 {
40578 int status;
40579 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
40580 dbg("returned from zt5550_hc_config");
40581
40582 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
40583 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
40584 zt5550_hpc.ops = &zt5550_hpc_ops;
40585 if(!poll) {
40586 zt5550_hpc.irq = hc_dev->irq;
40587 zt5550_hpc.irq_flags = IRQF_SHARED;
40588 zt5550_hpc.dev_id = hc_dev;
40589
40590 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40591 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40592 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40593 + pax_open_kernel();
40594 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40595 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40596 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40597 + pax_open_kernel();
40598 } else {
40599 info("using ENUM# polling mode");
40600 }
40601 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
40602 index 76ba8a1..20ca857 100644
40603 --- a/drivers/pci/hotplug/cpqphp_nvram.c
40604 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
40605 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
40606
40607 void compaq_nvram_init (void __iomem *rom_start)
40608 {
40609 +
40610 +#ifndef CONFIG_PAX_KERNEXEC
40611 if (rom_start) {
40612 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
40613 }
40614 +#endif
40615 +
40616 dbg("int15 entry = %p\n", compaq_int15_entry_point);
40617
40618 /* initialize our int15 lock */
40619 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
40620 index 202f4a9..8ee47d0 100644
40621 --- a/drivers/pci/hotplug/pci_hotplug_core.c
40622 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
40623 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
40624 return -EINVAL;
40625 }
40626
40627 - slot->ops->owner = owner;
40628 - slot->ops->mod_name = mod_name;
40629 + pax_open_kernel();
40630 + *(struct module **)&slot->ops->owner = owner;
40631 + *(const char **)&slot->ops->mod_name = mod_name;
40632 + pax_close_kernel();
40633
40634 mutex_lock(&pci_hp_mutex);
40635 /*
40636 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
40637 index 939bd1d..a1459c9 100644
40638 --- a/drivers/pci/hotplug/pciehp_core.c
40639 +++ b/drivers/pci/hotplug/pciehp_core.c
40640 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
40641 struct slot *slot = ctrl->slot;
40642 struct hotplug_slot *hotplug = NULL;
40643 struct hotplug_slot_info *info = NULL;
40644 - struct hotplug_slot_ops *ops = NULL;
40645 + hotplug_slot_ops_no_const *ops = NULL;
40646 char name[SLOT_NAME_SIZE];
40647 int retval = -ENOMEM;
40648
40649 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
40650 index 9c6e9bb..2916736 100644
40651 --- a/drivers/pci/pci-sysfs.c
40652 +++ b/drivers/pci/pci-sysfs.c
40653 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
40654 {
40655 /* allocate attribute structure, piggyback attribute name */
40656 int name_len = write_combine ? 13 : 10;
40657 - struct bin_attribute *res_attr;
40658 + bin_attribute_no_const *res_attr;
40659 int retval;
40660
40661 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
40662 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
40663 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
40664 {
40665 int retval;
40666 - struct bin_attribute *attr;
40667 + bin_attribute_no_const *attr;
40668
40669 /* If the device has VPD, try to expose it in sysfs. */
40670 if (dev->vpd) {
40671 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
40672 {
40673 int retval;
40674 int rom_size = 0;
40675 - struct bin_attribute *attr;
40676 + bin_attribute_no_const *attr;
40677
40678 if (!sysfs_initialized)
40679 return -EACCES;
40680 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
40681 index e851829..a1a7196 100644
40682 --- a/drivers/pci/pci.h
40683 +++ b/drivers/pci/pci.h
40684 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
40685 struct pci_vpd {
40686 unsigned int len;
40687 const struct pci_vpd_ops *ops;
40688 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
40689 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
40690 };
40691
40692 extern int pci_vpd_pci22_init(struct pci_dev *dev);
40693 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
40694 index 8474b6a..ee81993 100644
40695 --- a/drivers/pci/pcie/aspm.c
40696 +++ b/drivers/pci/pcie/aspm.c
40697 @@ -27,9 +27,9 @@
40698 #define MODULE_PARAM_PREFIX "pcie_aspm."
40699
40700 /* Note: those are not register definitions */
40701 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
40702 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
40703 -#define ASPM_STATE_L1 (4) /* L1 state */
40704 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
40705 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
40706 +#define ASPM_STATE_L1 (4U) /* L1 state */
40707 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
40708 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
40709
40710 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
40711 index 6186f03..1a78714 100644
40712 --- a/drivers/pci/probe.c
40713 +++ b/drivers/pci/probe.c
40714 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
40715 struct pci_bus_region region;
40716 bool bar_too_big = false, bar_disabled = false;
40717
40718 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
40719 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
40720
40721 /* No printks while decoding is disabled! */
40722 if (!dev->mmio_always_on) {
40723 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
40724 index 9b8505c..f00870a 100644
40725 --- a/drivers/pci/proc.c
40726 +++ b/drivers/pci/proc.c
40727 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
40728 static int __init pci_proc_init(void)
40729 {
40730 struct pci_dev *dev = NULL;
40731 +
40732 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
40733 +#ifdef CONFIG_GRKERNSEC_PROC_USER
40734 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
40735 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
40736 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
40737 +#endif
40738 +#else
40739 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
40740 +#endif
40741 proc_create("devices", 0, proc_bus_pci_dir,
40742 &proc_bus_pci_dev_operations);
40743 proc_initialized = 1;
40744 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
40745 index 2111dbb..79e434b 100644
40746 --- a/drivers/platform/x86/msi-laptop.c
40747 +++ b/drivers/platform/x86/msi-laptop.c
40748 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
40749 int result;
40750
40751 /* allow userland write sysfs file */
40752 - dev_attr_bluetooth.store = store_bluetooth;
40753 - dev_attr_wlan.store = store_wlan;
40754 - dev_attr_threeg.store = store_threeg;
40755 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
40756 - dev_attr_wlan.attr.mode |= S_IWUSR;
40757 - dev_attr_threeg.attr.mode |= S_IWUSR;
40758 + pax_open_kernel();
40759 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
40760 + *(void **)&dev_attr_wlan.store = store_wlan;
40761 + *(void **)&dev_attr_threeg.store = store_threeg;
40762 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
40763 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
40764 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
40765 + pax_close_kernel();
40766
40767 /* disable hardware control by fn key */
40768 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
40769 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
40770 index 0fe987f..6f3d5c3 100644
40771 --- a/drivers/platform/x86/sony-laptop.c
40772 +++ b/drivers/platform/x86/sony-laptop.c
40773 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
40774 }
40775
40776 /* High speed charging function */
40777 -static struct device_attribute *hsc_handle;
40778 +static device_attribute_no_const *hsc_handle;
40779
40780 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
40781 struct device_attribute *attr,
40782 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
40783 index f946ca7..f25c833 100644
40784 --- a/drivers/platform/x86/thinkpad_acpi.c
40785 +++ b/drivers/platform/x86/thinkpad_acpi.c
40786 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
40787 return 0;
40788 }
40789
40790 -void static hotkey_mask_warn_incomplete_mask(void)
40791 +static void hotkey_mask_warn_incomplete_mask(void)
40792 {
40793 /* log only what the user can fix... */
40794 const u32 wantedmask = hotkey_driver_mask &
40795 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
40796 }
40797 }
40798
40799 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40800 - struct tp_nvram_state *newn,
40801 - const u32 event_mask)
40802 -{
40803 -
40804 #define TPACPI_COMPARE_KEY(__scancode, __member) \
40805 do { \
40806 if ((event_mask & (1 << __scancode)) && \
40807 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40808 tpacpi_hotkey_send_key(__scancode); \
40809 } while (0)
40810
40811 - void issue_volchange(const unsigned int oldvol,
40812 - const unsigned int newvol)
40813 - {
40814 - unsigned int i = oldvol;
40815 +static void issue_volchange(const unsigned int oldvol,
40816 + const unsigned int newvol,
40817 + const u32 event_mask)
40818 +{
40819 + unsigned int i = oldvol;
40820
40821 - while (i > newvol) {
40822 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
40823 - i--;
40824 - }
40825 - while (i < newvol) {
40826 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40827 - i++;
40828 - }
40829 + while (i > newvol) {
40830 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
40831 + i--;
40832 }
40833 + while (i < newvol) {
40834 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40835 + i++;
40836 + }
40837 +}
40838
40839 - void issue_brightnesschange(const unsigned int oldbrt,
40840 - const unsigned int newbrt)
40841 - {
40842 - unsigned int i = oldbrt;
40843 +static void issue_brightnesschange(const unsigned int oldbrt,
40844 + const unsigned int newbrt,
40845 + const u32 event_mask)
40846 +{
40847 + unsigned int i = oldbrt;
40848
40849 - while (i > newbrt) {
40850 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
40851 - i--;
40852 - }
40853 - while (i < newbrt) {
40854 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40855 - i++;
40856 - }
40857 + while (i > newbrt) {
40858 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
40859 + i--;
40860 + }
40861 + while (i < newbrt) {
40862 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40863 + i++;
40864 }
40865 +}
40866
40867 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40868 + struct tp_nvram_state *newn,
40869 + const u32 event_mask)
40870 +{
40871 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
40872 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
40873 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
40874 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40875 oldn->volume_level != newn->volume_level) {
40876 /* recently muted, or repeated mute keypress, or
40877 * multiple presses ending in mute */
40878 - issue_volchange(oldn->volume_level, newn->volume_level);
40879 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
40880 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
40881 }
40882 } else {
40883 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40884 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40885 }
40886 if (oldn->volume_level != newn->volume_level) {
40887 - issue_volchange(oldn->volume_level, newn->volume_level);
40888 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
40889 } else if (oldn->volume_toggle != newn->volume_toggle) {
40890 /* repeated vol up/down keypress at end of scale ? */
40891 if (newn->volume_level == 0)
40892 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40893 /* handle brightness */
40894 if (oldn->brightness_level != newn->brightness_level) {
40895 issue_brightnesschange(oldn->brightness_level,
40896 - newn->brightness_level);
40897 + newn->brightness_level,
40898 + event_mask);
40899 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
40900 /* repeated key presses that didn't change state */
40901 if (newn->brightness_level == 0)
40902 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40903 && !tp_features.bright_unkfw)
40904 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40905 }
40906 +}
40907
40908 #undef TPACPI_COMPARE_KEY
40909 #undef TPACPI_MAY_SEND_KEY
40910 -}
40911
40912 /*
40913 * Polling driver
40914 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
40915 index 769d265..a3a05ca 100644
40916 --- a/drivers/pnp/pnpbios/bioscalls.c
40917 +++ b/drivers/pnp/pnpbios/bioscalls.c
40918 @@ -58,7 +58,7 @@ do { \
40919 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
40920 } while(0)
40921
40922 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
40923 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
40924 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
40925
40926 /*
40927 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
40928
40929 cpu = get_cpu();
40930 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
40931 +
40932 + pax_open_kernel();
40933 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
40934 + pax_close_kernel();
40935
40936 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
40937 spin_lock_irqsave(&pnp_bios_lock, flags);
40938 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
40939 :"memory");
40940 spin_unlock_irqrestore(&pnp_bios_lock, flags);
40941
40942 + pax_open_kernel();
40943 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
40944 + pax_close_kernel();
40945 +
40946 put_cpu();
40947
40948 /* If we get here and this is set then the PnP BIOS faulted on us. */
40949 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
40950 return status;
40951 }
40952
40953 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
40954 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
40955 {
40956 int i;
40957
40958 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
40959 pnp_bios_callpoint.offset = header->fields.pm16offset;
40960 pnp_bios_callpoint.segment = PNP_CS16;
40961
40962 + pax_open_kernel();
40963 +
40964 for_each_possible_cpu(i) {
40965 struct desc_struct *gdt = get_cpu_gdt_table(i);
40966 if (!gdt)
40967 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
40968 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
40969 (unsigned long)__va(header->fields.pm16dseg));
40970 }
40971 +
40972 + pax_close_kernel();
40973 }
40974 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
40975 index 3e6db1c..1fbbdae 100644
40976 --- a/drivers/pnp/resource.c
40977 +++ b/drivers/pnp/resource.c
40978 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
40979 return 1;
40980
40981 /* check if the resource is valid */
40982 - if (*irq < 0 || *irq > 15)
40983 + if (*irq > 15)
40984 return 0;
40985
40986 /* check if the resource is reserved */
40987 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
40988 return 1;
40989
40990 /* check if the resource is valid */
40991 - if (*dma < 0 || *dma == 4 || *dma > 7)
40992 + if (*dma == 4 || *dma > 7)
40993 return 0;
40994
40995 /* check if the resource is reserved */
40996 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
40997 index 7df7c5f..bd48c47 100644
40998 --- a/drivers/power/pda_power.c
40999 +++ b/drivers/power/pda_power.c
41000 @@ -37,7 +37,11 @@ static int polling;
41001
41002 #ifdef CONFIG_USB_OTG_UTILS
41003 static struct usb_phy *transceiver;
41004 -static struct notifier_block otg_nb;
41005 +static int otg_handle_notification(struct notifier_block *nb,
41006 + unsigned long event, void *unused);
41007 +static struct notifier_block otg_nb = {
41008 + .notifier_call = otg_handle_notification
41009 +};
41010 #endif
41011
41012 static struct regulator *ac_draw;
41013 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41014
41015 #ifdef CONFIG_USB_OTG_UTILS
41016 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41017 - otg_nb.notifier_call = otg_handle_notification;
41018 ret = usb_register_notifier(transceiver, &otg_nb);
41019 if (ret) {
41020 dev_err(dev, "failure to register otg notifier\n");
41021 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41022 index cc439fd..8fa30df 100644
41023 --- a/drivers/power/power_supply.h
41024 +++ b/drivers/power/power_supply.h
41025 @@ -16,12 +16,12 @@ struct power_supply;
41026
41027 #ifdef CONFIG_SYSFS
41028
41029 -extern void power_supply_init_attrs(struct device_type *dev_type);
41030 +extern void power_supply_init_attrs(void);
41031 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41032
41033 #else
41034
41035 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41036 +static inline void power_supply_init_attrs(void) {}
41037 #define power_supply_uevent NULL
41038
41039 #endif /* CONFIG_SYSFS */
41040 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41041 index 8a7cfb3..72e6e9b 100644
41042 --- a/drivers/power/power_supply_core.c
41043 +++ b/drivers/power/power_supply_core.c
41044 @@ -24,7 +24,10 @@
41045 struct class *power_supply_class;
41046 EXPORT_SYMBOL_GPL(power_supply_class);
41047
41048 -static struct device_type power_supply_dev_type;
41049 +extern const struct attribute_group *power_supply_attr_groups[];
41050 +static struct device_type power_supply_dev_type = {
41051 + .groups = power_supply_attr_groups,
41052 +};
41053
41054 static int __power_supply_changed_work(struct device *dev, void *data)
41055 {
41056 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41057 return PTR_ERR(power_supply_class);
41058
41059 power_supply_class->dev_uevent = power_supply_uevent;
41060 - power_supply_init_attrs(&power_supply_dev_type);
41061 + power_supply_init_attrs();
41062
41063 return 0;
41064 }
41065 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41066 index 40fa3b7..d9c2e0e 100644
41067 --- a/drivers/power/power_supply_sysfs.c
41068 +++ b/drivers/power/power_supply_sysfs.c
41069 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
41070 .is_visible = power_supply_attr_is_visible,
41071 };
41072
41073 -static const struct attribute_group *power_supply_attr_groups[] = {
41074 +const struct attribute_group *power_supply_attr_groups[] = {
41075 &power_supply_attr_group,
41076 NULL,
41077 };
41078
41079 -void power_supply_init_attrs(struct device_type *dev_type)
41080 +void power_supply_init_attrs(void)
41081 {
41082 int i;
41083
41084 - dev_type->groups = power_supply_attr_groups;
41085 -
41086 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41087 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41088 }
41089 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41090 index 4d7c635..9860196 100644
41091 --- a/drivers/regulator/max8660.c
41092 +++ b/drivers/regulator/max8660.c
41093 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41094 max8660->shadow_regs[MAX8660_OVER1] = 5;
41095 } else {
41096 /* Otherwise devices can be toggled via software */
41097 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41098 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41099 + pax_open_kernel();
41100 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41101 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41102 + pax_close_kernel();
41103 }
41104
41105 /*
41106 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41107 index 9a8ea91..c483dd9 100644
41108 --- a/drivers/regulator/max8973-regulator.c
41109 +++ b/drivers/regulator/max8973-regulator.c
41110 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41111 if (!pdata->enable_ext_control) {
41112 max->desc.enable_reg = MAX8973_VOUT;
41113 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41114 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41115 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41116 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41117 + pax_open_kernel();
41118 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41119 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41120 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41121 + pax_close_kernel();
41122 }
41123
41124 max->enable_external_control = pdata->enable_ext_control;
41125 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41126 index 0d84b1f..c2da6ac 100644
41127 --- a/drivers/regulator/mc13892-regulator.c
41128 +++ b/drivers/regulator/mc13892-regulator.c
41129 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41130 }
41131 mc13xxx_unlock(mc13892);
41132
41133 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41134 + pax_open_kernel();
41135 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41136 = mc13892_vcam_set_mode;
41137 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41138 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41139 = mc13892_vcam_get_mode;
41140 + pax_close_kernel();
41141
41142 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41143 ARRAY_SIZE(mc13892_regulators));
41144 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41145 index 16630aa..6afc992 100644
41146 --- a/drivers/rtc/rtc-cmos.c
41147 +++ b/drivers/rtc/rtc-cmos.c
41148 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41149 hpet_rtc_timer_init();
41150
41151 /* export at least the first block of NVRAM */
41152 - nvram.size = address_space - NVRAM_OFFSET;
41153 + pax_open_kernel();
41154 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41155 + pax_close_kernel();
41156 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41157 if (retval < 0) {
41158 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41159 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41160 index 9a86b4b..3a383dc 100644
41161 --- a/drivers/rtc/rtc-dev.c
41162 +++ b/drivers/rtc/rtc-dev.c
41163 @@ -14,6 +14,7 @@
41164 #include <linux/module.h>
41165 #include <linux/rtc.h>
41166 #include <linux/sched.h>
41167 +#include <linux/grsecurity.h>
41168 #include "rtc-core.h"
41169
41170 static dev_t rtc_devt;
41171 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
41172 if (copy_from_user(&tm, uarg, sizeof(tm)))
41173 return -EFAULT;
41174
41175 + gr_log_timechange();
41176 +
41177 return rtc_set_time(rtc, &tm);
41178
41179 case RTC_PIE_ON:
41180 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41181 index e0d0ba4..3c65868 100644
41182 --- a/drivers/rtc/rtc-ds1307.c
41183 +++ b/drivers/rtc/rtc-ds1307.c
41184 @@ -106,7 +106,7 @@ struct ds1307 {
41185 u8 offset; /* register's offset */
41186 u8 regs[11];
41187 u16 nvram_offset;
41188 - struct bin_attribute *nvram;
41189 + bin_attribute_no_const *nvram;
41190 enum ds_type type;
41191 unsigned long flags;
41192 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41193 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41194 index 130f29a..6179d03 100644
41195 --- a/drivers/rtc/rtc-m48t59.c
41196 +++ b/drivers/rtc/rtc-m48t59.c
41197 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41198 goto out;
41199 }
41200
41201 - m48t59_nvram_attr.size = pdata->offset;
41202 + pax_open_kernel();
41203 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41204 + pax_close_kernel();
41205
41206 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41207 if (ret) {
41208 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41209 index e693af6..2e525b6 100644
41210 --- a/drivers/scsi/bfa/bfa_fcpim.h
41211 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41212 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41213
41214 struct bfa_itn_s {
41215 bfa_isr_func_t isr;
41216 -};
41217 +} __no_const;
41218
41219 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41220 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41221 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41222 index 23a90e7..9cf04ee 100644
41223 --- a/drivers/scsi/bfa/bfa_ioc.h
41224 +++ b/drivers/scsi/bfa/bfa_ioc.h
41225 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41226 bfa_ioc_disable_cbfn_t disable_cbfn;
41227 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41228 bfa_ioc_reset_cbfn_t reset_cbfn;
41229 -};
41230 +} __no_const;
41231
41232 /*
41233 * IOC event notification mechanism.
41234 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41235 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41236 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41237 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41238 -};
41239 +} __no_const;
41240
41241 /*
41242 * Queue element to wait for room in request queue. FIFO order is
41243 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41244 index 593085a..47aa999 100644
41245 --- a/drivers/scsi/hosts.c
41246 +++ b/drivers/scsi/hosts.c
41247 @@ -42,7 +42,7 @@
41248 #include "scsi_logging.h"
41249
41250
41251 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41252 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41253
41254
41255 static void scsi_host_cls_release(struct device *dev)
41256 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41257 * subtract one because we increment first then return, but we need to
41258 * know what the next host number was before increment
41259 */
41260 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41261 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41262 shost->dma_channel = 0xff;
41263
41264 /* These three are default values which can be overridden */
41265 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41266 index 4f33806..afd6f60 100644
41267 --- a/drivers/scsi/hpsa.c
41268 +++ b/drivers/scsi/hpsa.c
41269 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41270 unsigned long flags;
41271
41272 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41273 - return h->access.command_completed(h, q);
41274 + return h->access->command_completed(h, q);
41275
41276 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41277 a = rq->head[rq->current_entry];
41278 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
41279 while (!list_empty(&h->reqQ)) {
41280 c = list_entry(h->reqQ.next, struct CommandList, list);
41281 /* can't do anything if fifo is full */
41282 - if ((h->access.fifo_full(h))) {
41283 + if ((h->access->fifo_full(h))) {
41284 dev_warn(&h->pdev->dev, "fifo full\n");
41285 break;
41286 }
41287 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
41288
41289 /* Tell the controller execute command */
41290 spin_unlock_irqrestore(&h->lock, flags);
41291 - h->access.submit_command(h, c);
41292 + h->access->submit_command(h, c);
41293 spin_lock_irqsave(&h->lock, flags);
41294 }
41295 spin_unlock_irqrestore(&h->lock, flags);
41296 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
41297
41298 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41299 {
41300 - return h->access.command_completed(h, q);
41301 + return h->access->command_completed(h, q);
41302 }
41303
41304 static inline bool interrupt_pending(struct ctlr_info *h)
41305 {
41306 - return h->access.intr_pending(h);
41307 + return h->access->intr_pending(h);
41308 }
41309
41310 static inline long interrupt_not_for_us(struct ctlr_info *h)
41311 {
41312 - return (h->access.intr_pending(h) == 0) ||
41313 + return (h->access->intr_pending(h) == 0) ||
41314 (h->interrupts_enabled == 0);
41315 }
41316
41317 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41318 if (prod_index < 0)
41319 return -ENODEV;
41320 h->product_name = products[prod_index].product_name;
41321 - h->access = *(products[prod_index].access);
41322 + h->access = products[prod_index].access;
41323
41324 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41325 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41326 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
41327
41328 assert_spin_locked(&lockup_detector_lock);
41329 remove_ctlr_from_lockup_detector_list(h);
41330 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41331 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41332 spin_lock_irqsave(&h->lock, flags);
41333 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
41334 spin_unlock_irqrestore(&h->lock, flags);
41335 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
41336 }
41337
41338 /* make sure the board interrupts are off */
41339 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41340 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41341
41342 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
41343 goto clean2;
41344 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
41345 * fake ones to scoop up any residual completions.
41346 */
41347 spin_lock_irqsave(&h->lock, flags);
41348 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41349 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41350 spin_unlock_irqrestore(&h->lock, flags);
41351 free_irqs(h);
41352 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
41353 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
41354 dev_info(&h->pdev->dev, "Board READY.\n");
41355 dev_info(&h->pdev->dev,
41356 "Waiting for stale completions to drain.\n");
41357 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41358 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41359 msleep(10000);
41360 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41361 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41362
41363 rc = controller_reset_failed(h->cfgtable);
41364 if (rc)
41365 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
41366 }
41367
41368 /* Turn the interrupts on so we can service requests */
41369 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41370 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41371
41372 hpsa_hba_inquiry(h);
41373 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
41374 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
41375 * To write all data in the battery backed cache to disks
41376 */
41377 hpsa_flush_cache(h);
41378 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41379 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41380 hpsa_free_irqs_and_disable_msix(h);
41381 }
41382
41383 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
41384 return;
41385 }
41386 /* Change the access methods to the performant access methods */
41387 - h->access = SA5_performant_access;
41388 + h->access = &SA5_performant_access;
41389 h->transMethod = CFGTBL_Trans_Performant;
41390 }
41391
41392 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
41393 index 9816479..c5d4e97 100644
41394 --- a/drivers/scsi/hpsa.h
41395 +++ b/drivers/scsi/hpsa.h
41396 @@ -79,7 +79,7 @@ struct ctlr_info {
41397 unsigned int msix_vector;
41398 unsigned int msi_vector;
41399 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
41400 - struct access_method access;
41401 + struct access_method *access;
41402
41403 /* queue and queue Info */
41404 struct list_head reqQ;
41405 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
41406 index c772d8d..35c362c 100644
41407 --- a/drivers/scsi/libfc/fc_exch.c
41408 +++ b/drivers/scsi/libfc/fc_exch.c
41409 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
41410 u16 pool_max_index;
41411
41412 struct {
41413 - atomic_t no_free_exch;
41414 - atomic_t no_free_exch_xid;
41415 - atomic_t xid_not_found;
41416 - atomic_t xid_busy;
41417 - atomic_t seq_not_found;
41418 - atomic_t non_bls_resp;
41419 + atomic_unchecked_t no_free_exch;
41420 + atomic_unchecked_t no_free_exch_xid;
41421 + atomic_unchecked_t xid_not_found;
41422 + atomic_unchecked_t xid_busy;
41423 + atomic_unchecked_t seq_not_found;
41424 + atomic_unchecked_t non_bls_resp;
41425 } stats;
41426 };
41427
41428 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
41429 /* allocate memory for exchange */
41430 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
41431 if (!ep) {
41432 - atomic_inc(&mp->stats.no_free_exch);
41433 + atomic_inc_unchecked(&mp->stats.no_free_exch);
41434 goto out;
41435 }
41436 memset(ep, 0, sizeof(*ep));
41437 @@ -786,7 +786,7 @@ out:
41438 return ep;
41439 err:
41440 spin_unlock_bh(&pool->lock);
41441 - atomic_inc(&mp->stats.no_free_exch_xid);
41442 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
41443 mempool_free(ep, mp->ep_pool);
41444 return NULL;
41445 }
41446 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41447 xid = ntohs(fh->fh_ox_id); /* we originated exch */
41448 ep = fc_exch_find(mp, xid);
41449 if (!ep) {
41450 - atomic_inc(&mp->stats.xid_not_found);
41451 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41452 reject = FC_RJT_OX_ID;
41453 goto out;
41454 }
41455 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41456 ep = fc_exch_find(mp, xid);
41457 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
41458 if (ep) {
41459 - atomic_inc(&mp->stats.xid_busy);
41460 + atomic_inc_unchecked(&mp->stats.xid_busy);
41461 reject = FC_RJT_RX_ID;
41462 goto rel;
41463 }
41464 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41465 }
41466 xid = ep->xid; /* get our XID */
41467 } else if (!ep) {
41468 - atomic_inc(&mp->stats.xid_not_found);
41469 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41470 reject = FC_RJT_RX_ID; /* XID not found */
41471 goto out;
41472 }
41473 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41474 } else {
41475 sp = &ep->seq;
41476 if (sp->id != fh->fh_seq_id) {
41477 - atomic_inc(&mp->stats.seq_not_found);
41478 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41479 if (f_ctl & FC_FC_END_SEQ) {
41480 /*
41481 * Update sequence_id based on incoming last
41482 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41483
41484 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
41485 if (!ep) {
41486 - atomic_inc(&mp->stats.xid_not_found);
41487 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41488 goto out;
41489 }
41490 if (ep->esb_stat & ESB_ST_COMPLETE) {
41491 - atomic_inc(&mp->stats.xid_not_found);
41492 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41493 goto rel;
41494 }
41495 if (ep->rxid == FC_XID_UNKNOWN)
41496 ep->rxid = ntohs(fh->fh_rx_id);
41497 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
41498 - atomic_inc(&mp->stats.xid_not_found);
41499 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41500 goto rel;
41501 }
41502 if (ep->did != ntoh24(fh->fh_s_id) &&
41503 ep->did != FC_FID_FLOGI) {
41504 - atomic_inc(&mp->stats.xid_not_found);
41505 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41506 goto rel;
41507 }
41508 sof = fr_sof(fp);
41509 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41510 sp->ssb_stat |= SSB_ST_RESP;
41511 sp->id = fh->fh_seq_id;
41512 } else if (sp->id != fh->fh_seq_id) {
41513 - atomic_inc(&mp->stats.seq_not_found);
41514 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41515 goto rel;
41516 }
41517
41518 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41519 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
41520
41521 if (!sp)
41522 - atomic_inc(&mp->stats.xid_not_found);
41523 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41524 else
41525 - atomic_inc(&mp->stats.non_bls_resp);
41526 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
41527
41528 fc_frame_free(fp);
41529 }
41530 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
41531
41532 list_for_each_entry(ema, &lport->ema_list, ema_list) {
41533 mp = ema->mp;
41534 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
41535 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
41536 st->fc_no_free_exch_xid +=
41537 - atomic_read(&mp->stats.no_free_exch_xid);
41538 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
41539 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
41540 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
41541 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
41542 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
41543 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
41544 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
41545 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
41546 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
41547 }
41548 }
41549 EXPORT_SYMBOL(fc_exch_update_stats);
41550 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
41551 index bdb81cd..d3c7c2c 100644
41552 --- a/drivers/scsi/libsas/sas_ata.c
41553 +++ b/drivers/scsi/libsas/sas_ata.c
41554 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
41555 .postreset = ata_std_postreset,
41556 .error_handler = ata_std_error_handler,
41557 .post_internal_cmd = sas_ata_post_internal,
41558 - .qc_defer = ata_std_qc_defer,
41559 + .qc_defer = ata_std_qc_defer,
41560 .qc_prep = ata_noop_qc_prep,
41561 .qc_issue = sas_ata_qc_issue,
41562 .qc_fill_rtf = sas_ata_qc_fill_rtf,
41563 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
41564 index df4c13a..a51e90c 100644
41565 --- a/drivers/scsi/lpfc/lpfc.h
41566 +++ b/drivers/scsi/lpfc/lpfc.h
41567 @@ -424,7 +424,7 @@ struct lpfc_vport {
41568 struct dentry *debug_nodelist;
41569 struct dentry *vport_debugfs_root;
41570 struct lpfc_debugfs_trc *disc_trc;
41571 - atomic_t disc_trc_cnt;
41572 + atomic_unchecked_t disc_trc_cnt;
41573 #endif
41574 uint8_t stat_data_enabled;
41575 uint8_t stat_data_blocked;
41576 @@ -842,8 +842,8 @@ struct lpfc_hba {
41577 struct timer_list fabric_block_timer;
41578 unsigned long bit_flags;
41579 #define FABRIC_COMANDS_BLOCKED 0
41580 - atomic_t num_rsrc_err;
41581 - atomic_t num_cmd_success;
41582 + atomic_unchecked_t num_rsrc_err;
41583 + atomic_unchecked_t num_cmd_success;
41584 unsigned long last_rsrc_error_time;
41585 unsigned long last_ramp_down_time;
41586 unsigned long last_ramp_up_time;
41587 @@ -879,7 +879,7 @@ struct lpfc_hba {
41588
41589 struct dentry *debug_slow_ring_trc;
41590 struct lpfc_debugfs_trc *slow_ring_trc;
41591 - atomic_t slow_ring_trc_cnt;
41592 + atomic_unchecked_t slow_ring_trc_cnt;
41593 /* iDiag debugfs sub-directory */
41594 struct dentry *idiag_root;
41595 struct dentry *idiag_pci_cfg;
41596 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
41597 index f63f5ff..de29189 100644
41598 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
41599 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
41600 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
41601
41602 #include <linux/debugfs.h>
41603
41604 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41605 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41606 static unsigned long lpfc_debugfs_start_time = 0L;
41607
41608 /* iDiag */
41609 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
41610 lpfc_debugfs_enable = 0;
41611
41612 len = 0;
41613 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
41614 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
41615 (lpfc_debugfs_max_disc_trc - 1);
41616 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
41617 dtp = vport->disc_trc + i;
41618 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
41619 lpfc_debugfs_enable = 0;
41620
41621 len = 0;
41622 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
41623 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
41624 (lpfc_debugfs_max_slow_ring_trc - 1);
41625 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
41626 dtp = phba->slow_ring_trc + i;
41627 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
41628 !vport || !vport->disc_trc)
41629 return;
41630
41631 - index = atomic_inc_return(&vport->disc_trc_cnt) &
41632 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
41633 (lpfc_debugfs_max_disc_trc - 1);
41634 dtp = vport->disc_trc + index;
41635 dtp->fmt = fmt;
41636 dtp->data1 = data1;
41637 dtp->data2 = data2;
41638 dtp->data3 = data3;
41639 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41640 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41641 dtp->jif = jiffies;
41642 #endif
41643 return;
41644 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
41645 !phba || !phba->slow_ring_trc)
41646 return;
41647
41648 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
41649 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
41650 (lpfc_debugfs_max_slow_ring_trc - 1);
41651 dtp = phba->slow_ring_trc + index;
41652 dtp->fmt = fmt;
41653 dtp->data1 = data1;
41654 dtp->data2 = data2;
41655 dtp->data3 = data3;
41656 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41657 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41658 dtp->jif = jiffies;
41659 #endif
41660 return;
41661 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
41662 "slow_ring buffer\n");
41663 goto debug_failed;
41664 }
41665 - atomic_set(&phba->slow_ring_trc_cnt, 0);
41666 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
41667 memset(phba->slow_ring_trc, 0,
41668 (sizeof(struct lpfc_debugfs_trc) *
41669 lpfc_debugfs_max_slow_ring_trc));
41670 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
41671 "buffer\n");
41672 goto debug_failed;
41673 }
41674 - atomic_set(&vport->disc_trc_cnt, 0);
41675 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
41676
41677 snprintf(name, sizeof(name), "discovery_trace");
41678 vport->debug_disc_trc =
41679 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
41680 index 89ad558..76956c4 100644
41681 --- a/drivers/scsi/lpfc/lpfc_init.c
41682 +++ b/drivers/scsi/lpfc/lpfc_init.c
41683 @@ -10618,8 +10618,10 @@ lpfc_init(void)
41684 "misc_register returned with status %d", error);
41685
41686 if (lpfc_enable_npiv) {
41687 - lpfc_transport_functions.vport_create = lpfc_vport_create;
41688 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
41689 + pax_open_kernel();
41690 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
41691 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
41692 + pax_close_kernel();
41693 }
41694 lpfc_transport_template =
41695 fc_attach_transport(&lpfc_transport_functions);
41696 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
41697 index 60e5a17..ff7a793 100644
41698 --- a/drivers/scsi/lpfc/lpfc_scsi.c
41699 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
41700 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
41701 uint32_t evt_posted;
41702
41703 spin_lock_irqsave(&phba->hbalock, flags);
41704 - atomic_inc(&phba->num_rsrc_err);
41705 + atomic_inc_unchecked(&phba->num_rsrc_err);
41706 phba->last_rsrc_error_time = jiffies;
41707
41708 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
41709 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
41710 unsigned long flags;
41711 struct lpfc_hba *phba = vport->phba;
41712 uint32_t evt_posted;
41713 - atomic_inc(&phba->num_cmd_success);
41714 + atomic_inc_unchecked(&phba->num_cmd_success);
41715
41716 if (vport->cfg_lun_queue_depth <= queue_depth)
41717 return;
41718 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
41719 unsigned long num_rsrc_err, num_cmd_success;
41720 int i;
41721
41722 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
41723 - num_cmd_success = atomic_read(&phba->num_cmd_success);
41724 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
41725 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
41726
41727 /*
41728 * The error and success command counters are global per
41729 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
41730 }
41731 }
41732 lpfc_destroy_vport_work_array(phba, vports);
41733 - atomic_set(&phba->num_rsrc_err, 0);
41734 - atomic_set(&phba->num_cmd_success, 0);
41735 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
41736 + atomic_set_unchecked(&phba->num_cmd_success, 0);
41737 }
41738
41739 /**
41740 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
41741 }
41742 }
41743 lpfc_destroy_vport_work_array(phba, vports);
41744 - atomic_set(&phba->num_rsrc_err, 0);
41745 - atomic_set(&phba->num_cmd_success, 0);
41746 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
41747 + atomic_set_unchecked(&phba->num_cmd_success, 0);
41748 }
41749
41750 /**
41751 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
41752 index b46f5e9..c4c4ccb 100644
41753 --- a/drivers/scsi/pmcraid.c
41754 +++ b/drivers/scsi/pmcraid.c
41755 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
41756 res->scsi_dev = scsi_dev;
41757 scsi_dev->hostdata = res;
41758 res->change_detected = 0;
41759 - atomic_set(&res->read_failures, 0);
41760 - atomic_set(&res->write_failures, 0);
41761 + atomic_set_unchecked(&res->read_failures, 0);
41762 + atomic_set_unchecked(&res->write_failures, 0);
41763 rc = 0;
41764 }
41765 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
41766 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
41767
41768 /* If this was a SCSI read/write command keep count of errors */
41769 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
41770 - atomic_inc(&res->read_failures);
41771 + atomic_inc_unchecked(&res->read_failures);
41772 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
41773 - atomic_inc(&res->write_failures);
41774 + atomic_inc_unchecked(&res->write_failures);
41775
41776 if (!RES_IS_GSCSI(res->cfg_entry) &&
41777 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
41778 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
41779 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
41780 * hrrq_id assigned here in queuecommand
41781 */
41782 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
41783 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
41784 pinstance->num_hrrq;
41785 cmd->cmd_done = pmcraid_io_done;
41786
41787 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
41788 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
41789 * hrrq_id assigned here in queuecommand
41790 */
41791 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
41792 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
41793 pinstance->num_hrrq;
41794
41795 if (request_size) {
41796 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
41797
41798 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
41799 /* add resources only after host is added into system */
41800 - if (!atomic_read(&pinstance->expose_resources))
41801 + if (!atomic_read_unchecked(&pinstance->expose_resources))
41802 return;
41803
41804 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
41805 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
41806 init_waitqueue_head(&pinstance->reset_wait_q);
41807
41808 atomic_set(&pinstance->outstanding_cmds, 0);
41809 - atomic_set(&pinstance->last_message_id, 0);
41810 - atomic_set(&pinstance->expose_resources, 0);
41811 + atomic_set_unchecked(&pinstance->last_message_id, 0);
41812 + atomic_set_unchecked(&pinstance->expose_resources, 0);
41813
41814 INIT_LIST_HEAD(&pinstance->free_res_q);
41815 INIT_LIST_HEAD(&pinstance->used_res_q);
41816 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
41817 /* Schedule worker thread to handle CCN and take care of adding and
41818 * removing devices to OS
41819 */
41820 - atomic_set(&pinstance->expose_resources, 1);
41821 + atomic_set_unchecked(&pinstance->expose_resources, 1);
41822 schedule_work(&pinstance->worker_q);
41823 return rc;
41824
41825 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
41826 index e1d150f..6c6df44 100644
41827 --- a/drivers/scsi/pmcraid.h
41828 +++ b/drivers/scsi/pmcraid.h
41829 @@ -748,7 +748,7 @@ struct pmcraid_instance {
41830 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
41831
41832 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
41833 - atomic_t last_message_id;
41834 + atomic_unchecked_t last_message_id;
41835
41836 /* configuration table */
41837 struct pmcraid_config_table *cfg_table;
41838 @@ -777,7 +777,7 @@ struct pmcraid_instance {
41839 atomic_t outstanding_cmds;
41840
41841 /* should add/delete resources to mid-layer now ?*/
41842 - atomic_t expose_resources;
41843 + atomic_unchecked_t expose_resources;
41844
41845
41846
41847 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
41848 struct pmcraid_config_table_entry_ext cfg_entry_ext;
41849 };
41850 struct scsi_device *scsi_dev; /* Link scsi_device structure */
41851 - atomic_t read_failures; /* count of failed READ commands */
41852 - atomic_t write_failures; /* count of failed WRITE commands */
41853 + atomic_unchecked_t read_failures; /* count of failed READ commands */
41854 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
41855
41856 /* To indicate add/delete/modify during CCN */
41857 u8 change_detected;
41858 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
41859 index 83d7984..a27d947 100644
41860 --- a/drivers/scsi/qla2xxx/qla_attr.c
41861 +++ b/drivers/scsi/qla2xxx/qla_attr.c
41862 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
41863 return 0;
41864 }
41865
41866 -struct fc_function_template qla2xxx_transport_functions = {
41867 +fc_function_template_no_const qla2xxx_transport_functions = {
41868
41869 .show_host_node_name = 1,
41870 .show_host_port_name = 1,
41871 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
41872 .bsg_timeout = qla24xx_bsg_timeout,
41873 };
41874
41875 -struct fc_function_template qla2xxx_transport_vport_functions = {
41876 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
41877
41878 .show_host_node_name = 1,
41879 .show_host_port_name = 1,
41880 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
41881 index 2411d1a..4673766 100644
41882 --- a/drivers/scsi/qla2xxx/qla_gbl.h
41883 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
41884 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
41885 struct device_attribute;
41886 extern struct device_attribute *qla2x00_host_attrs[];
41887 struct fc_function_template;
41888 -extern struct fc_function_template qla2xxx_transport_functions;
41889 -extern struct fc_function_template qla2xxx_transport_vport_functions;
41890 +extern fc_function_template_no_const qla2xxx_transport_functions;
41891 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
41892 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
41893 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
41894 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
41895 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
41896 index 10d23f8..a7d5d4c 100644
41897 --- a/drivers/scsi/qla2xxx/qla_os.c
41898 +++ b/drivers/scsi/qla2xxx/qla_os.c
41899 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
41900 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
41901 /* Ok, a 64bit DMA mask is applicable. */
41902 ha->flags.enable_64bit_addressing = 1;
41903 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
41904 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
41905 + pax_open_kernel();
41906 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
41907 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
41908 + pax_close_kernel();
41909 return;
41910 }
41911 }
41912 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
41913 index 329d553..f20d31d 100644
41914 --- a/drivers/scsi/qla4xxx/ql4_def.h
41915 +++ b/drivers/scsi/qla4xxx/ql4_def.h
41916 @@ -273,7 +273,7 @@ struct ddb_entry {
41917 * (4000 only) */
41918 atomic_t relogin_timer; /* Max Time to wait for
41919 * relogin to complete */
41920 - atomic_t relogin_retry_count; /* Num of times relogin has been
41921 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
41922 * retried */
41923 uint32_t default_time2wait; /* Default Min time between
41924 * relogins (+aens) */
41925 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
41926 index 4cec123..7c1329f 100644
41927 --- a/drivers/scsi/qla4xxx/ql4_os.c
41928 +++ b/drivers/scsi/qla4xxx/ql4_os.c
41929 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
41930 */
41931 if (!iscsi_is_session_online(cls_sess)) {
41932 /* Reset retry relogin timer */
41933 - atomic_inc(&ddb_entry->relogin_retry_count);
41934 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
41935 DEBUG2(ql4_printk(KERN_INFO, ha,
41936 "%s: index[%d] relogin timed out-retrying"
41937 " relogin (%d), retry (%d)\n", __func__,
41938 ddb_entry->fw_ddb_index,
41939 - atomic_read(&ddb_entry->relogin_retry_count),
41940 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
41941 ddb_entry->default_time2wait + 4));
41942 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
41943 atomic_set(&ddb_entry->retry_relogin_timer,
41944 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
41945
41946 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
41947 atomic_set(&ddb_entry->relogin_timer, 0);
41948 - atomic_set(&ddb_entry->relogin_retry_count, 0);
41949 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
41950 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
41951 ddb_entry->default_relogin_timeout =
41952 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
41953 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
41954 index 2c0d0ec..4e8681a 100644
41955 --- a/drivers/scsi/scsi.c
41956 +++ b/drivers/scsi/scsi.c
41957 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
41958 unsigned long timeout;
41959 int rtn = 0;
41960
41961 - atomic_inc(&cmd->device->iorequest_cnt);
41962 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
41963
41964 /* check if the device is still usable */
41965 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
41966 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
41967 index f1bf5af..f67e943 100644
41968 --- a/drivers/scsi/scsi_lib.c
41969 +++ b/drivers/scsi/scsi_lib.c
41970 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
41971 shost = sdev->host;
41972 scsi_init_cmd_errh(cmd);
41973 cmd->result = DID_NO_CONNECT << 16;
41974 - atomic_inc(&cmd->device->iorequest_cnt);
41975 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
41976
41977 /*
41978 * SCSI request completion path will do scsi_device_unbusy(),
41979 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
41980
41981 INIT_LIST_HEAD(&cmd->eh_entry);
41982
41983 - atomic_inc(&cmd->device->iodone_cnt);
41984 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
41985 if (cmd->result)
41986 - atomic_inc(&cmd->device->ioerr_cnt);
41987 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
41988
41989 disposition = scsi_decide_disposition(cmd);
41990 if (disposition != SUCCESS &&
41991 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
41992 index 931a7d9..0c2a754 100644
41993 --- a/drivers/scsi/scsi_sysfs.c
41994 +++ b/drivers/scsi/scsi_sysfs.c
41995 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
41996 char *buf) \
41997 { \
41998 struct scsi_device *sdev = to_scsi_device(dev); \
41999 - unsigned long long count = atomic_read(&sdev->field); \
42000 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42001 return snprintf(buf, 20, "0x%llx\n", count); \
42002 } \
42003 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42004 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42005 index 84a1fdf..693b0d6 100644
42006 --- a/drivers/scsi/scsi_tgt_lib.c
42007 +++ b/drivers/scsi/scsi_tgt_lib.c
42008 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42009 int err;
42010
42011 dprintk("%lx %u\n", uaddr, len);
42012 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42013 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42014 if (err) {
42015 /*
42016 * TODO: need to fixup sg_tablesize, max_segment_size,
42017 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42018 index e894ca7..de9d7660 100644
42019 --- a/drivers/scsi/scsi_transport_fc.c
42020 +++ b/drivers/scsi/scsi_transport_fc.c
42021 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42022 * Netlink Infrastructure
42023 */
42024
42025 -static atomic_t fc_event_seq;
42026 +static atomic_unchecked_t fc_event_seq;
42027
42028 /**
42029 * fc_get_event_number - Obtain the next sequential FC event number
42030 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42031 u32
42032 fc_get_event_number(void)
42033 {
42034 - return atomic_add_return(1, &fc_event_seq);
42035 + return atomic_add_return_unchecked(1, &fc_event_seq);
42036 }
42037 EXPORT_SYMBOL(fc_get_event_number);
42038
42039 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42040 {
42041 int error;
42042
42043 - atomic_set(&fc_event_seq, 0);
42044 + atomic_set_unchecked(&fc_event_seq, 0);
42045
42046 error = transport_class_register(&fc_host_class);
42047 if (error)
42048 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42049 char *cp;
42050
42051 *val = simple_strtoul(buf, &cp, 0);
42052 - if ((*cp && (*cp != '\n')) || (*val < 0))
42053 + if (*cp && (*cp != '\n'))
42054 return -EINVAL;
42055 /*
42056 * Check for overflow; dev_loss_tmo is u32
42057 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42058 index 31969f2..2b348f0 100644
42059 --- a/drivers/scsi/scsi_transport_iscsi.c
42060 +++ b/drivers/scsi/scsi_transport_iscsi.c
42061 @@ -79,7 +79,7 @@ struct iscsi_internal {
42062 struct transport_container session_cont;
42063 };
42064
42065 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42066 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42067 static struct workqueue_struct *iscsi_eh_timer_workq;
42068
42069 static DEFINE_IDA(iscsi_sess_ida);
42070 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42071 int err;
42072
42073 ihost = shost->shost_data;
42074 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42075 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42076
42077 if (target_id == ISCSI_MAX_TARGET) {
42078 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42079 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
42080 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42081 ISCSI_TRANSPORT_VERSION);
42082
42083 - atomic_set(&iscsi_session_nr, 0);
42084 + atomic_set_unchecked(&iscsi_session_nr, 0);
42085
42086 err = class_register(&iscsi_transport_class);
42087 if (err)
42088 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42089 index f379c7f..e8fc69c 100644
42090 --- a/drivers/scsi/scsi_transport_srp.c
42091 +++ b/drivers/scsi/scsi_transport_srp.c
42092 @@ -33,7 +33,7 @@
42093 #include "scsi_transport_srp_internal.h"
42094
42095 struct srp_host_attrs {
42096 - atomic_t next_port_id;
42097 + atomic_unchecked_t next_port_id;
42098 };
42099 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42100
42101 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42102 struct Scsi_Host *shost = dev_to_shost(dev);
42103 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42104
42105 - atomic_set(&srp_host->next_port_id, 0);
42106 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42107 return 0;
42108 }
42109
42110 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42111 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42112 rport->roles = ids->roles;
42113
42114 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42115 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42116 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42117
42118 transport_setup_device(&rport->dev);
42119 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42120 index 7992635..609faf8 100644
42121 --- a/drivers/scsi/sd.c
42122 +++ b/drivers/scsi/sd.c
42123 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
42124 sdkp->disk = gd;
42125 sdkp->index = index;
42126 atomic_set(&sdkp->openers, 0);
42127 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42128 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42129
42130 if (!sdp->request_queue->rq_timeout) {
42131 if (sdp->type != TYPE_MOD)
42132 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42133 index be2c9a6..275525c 100644
42134 --- a/drivers/scsi/sg.c
42135 +++ b/drivers/scsi/sg.c
42136 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42137 sdp->disk->disk_name,
42138 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42139 NULL,
42140 - (char *)arg);
42141 + (char __user *)arg);
42142 case BLKTRACESTART:
42143 return blk_trace_startstop(sdp->device->request_queue, 1);
42144 case BLKTRACESTOP:
42145 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42146 index 19ee901..6e8c2ef 100644
42147 --- a/drivers/spi/spi.c
42148 +++ b/drivers/spi/spi.c
42149 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
42150 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42151
42152 /* portable code must never pass more than 32 bytes */
42153 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42154 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42155
42156 static u8 *buf;
42157
42158 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42159 index c7a5f97..71ecd35 100644
42160 --- a/drivers/staging/iio/iio_hwmon.c
42161 +++ b/drivers/staging/iio/iio_hwmon.c
42162 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
42163 static int iio_hwmon_probe(struct platform_device *pdev)
42164 {
42165 struct iio_hwmon_state *st;
42166 - struct sensor_device_attribute *a;
42167 + sensor_device_attribute_no_const *a;
42168 int ret, i;
42169 int in_i = 1, temp_i = 1, curr_i = 1;
42170 enum iio_chan_type type;
42171 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42172 index 34afc16..ffe44dd 100644
42173 --- a/drivers/staging/octeon/ethernet-rx.c
42174 +++ b/drivers/staging/octeon/ethernet-rx.c
42175 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42176 /* Increment RX stats for virtual ports */
42177 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42178 #ifdef CONFIG_64BIT
42179 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42180 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42181 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42182 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42183 #else
42184 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42185 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42186 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42187 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42188 #endif
42189 }
42190 netif_receive_skb(skb);
42191 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42192 dev->name);
42193 */
42194 #ifdef CONFIG_64BIT
42195 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42196 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42197 #else
42198 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42199 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42200 #endif
42201 dev_kfree_skb_irq(skb);
42202 }
42203 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42204 index ef32dc1..a159d68 100644
42205 --- a/drivers/staging/octeon/ethernet.c
42206 +++ b/drivers/staging/octeon/ethernet.c
42207 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42208 * since the RX tasklet also increments it.
42209 */
42210 #ifdef CONFIG_64BIT
42211 - atomic64_add(rx_status.dropped_packets,
42212 - (atomic64_t *)&priv->stats.rx_dropped);
42213 + atomic64_add_unchecked(rx_status.dropped_packets,
42214 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42215 #else
42216 - atomic_add(rx_status.dropped_packets,
42217 - (atomic_t *)&priv->stats.rx_dropped);
42218 + atomic_add_unchecked(rx_status.dropped_packets,
42219 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42220 #endif
42221 }
42222
42223 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
42224 index a2b7e03..aaf3630 100644
42225 --- a/drivers/staging/ramster/tmem.c
42226 +++ b/drivers/staging/ramster/tmem.c
42227 @@ -50,25 +50,25 @@
42228 * A tmem host implementation must use this function to register callbacks
42229 * for memory allocation.
42230 */
42231 -static struct tmem_hostops tmem_hostops;
42232 +static struct tmem_hostops *tmem_hostops;
42233
42234 static void tmem_objnode_tree_init(void);
42235
42236 void tmem_register_hostops(struct tmem_hostops *m)
42237 {
42238 tmem_objnode_tree_init();
42239 - tmem_hostops = *m;
42240 + tmem_hostops = m;
42241 }
42242
42243 /*
42244 * A tmem host implementation must use this function to register
42245 * callbacks for a page-accessible memory (PAM) implementation.
42246 */
42247 -static struct tmem_pamops tmem_pamops;
42248 +static struct tmem_pamops *tmem_pamops;
42249
42250 void tmem_register_pamops(struct tmem_pamops *m)
42251 {
42252 - tmem_pamops = *m;
42253 + tmem_pamops = m;
42254 }
42255
42256 /*
42257 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
42258 obj->pampd_count = 0;
42259 #ifdef CONFIG_RAMSTER
42260 if (tmem_pamops.new_obj != NULL)
42261 - (*tmem_pamops.new_obj)(obj);
42262 + (tmem_pamops->new_obj)(obj);
42263 #endif
42264 SET_SENTINEL(obj, OBJ);
42265
42266 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
42267 rbnode = rb_next(rbnode);
42268 tmem_pampd_destroy_all_in_obj(obj, true);
42269 tmem_obj_free(obj, hb);
42270 - (*tmem_hostops.obj_free)(obj, pool);
42271 + (tmem_hostops->obj_free)(obj, pool);
42272 }
42273 spin_unlock(&hb->lock);
42274 }
42275 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
42276 ASSERT_SENTINEL(obj, OBJ);
42277 BUG_ON(obj->pool == NULL);
42278 ASSERT_SENTINEL(obj->pool, POOL);
42279 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
42280 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
42281 if (unlikely(objnode == NULL))
42282 goto out;
42283 objnode->obj = obj;
42284 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
42285 ASSERT_SENTINEL(pool, POOL);
42286 objnode->obj->objnode_count--;
42287 objnode->obj = NULL;
42288 - (*tmem_hostops.objnode_free)(objnode, pool);
42289 + (tmem_hostops->objnode_free)(objnode, pool);
42290 }
42291
42292 /*
42293 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
42294 void *old_pampd = *(void **)slot;
42295 *(void **)slot = new_pampd;
42296 if (!no_free)
42297 - (*tmem_pamops.free)(old_pampd, obj->pool,
42298 + (tmem_pamops->free)(old_pampd, obj->pool,
42299 NULL, 0, false);
42300 ret = new_pampd;
42301 }
42302 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
42303 if (objnode->slots[i]) {
42304 if (ht == 1) {
42305 obj->pampd_count--;
42306 - (*tmem_pamops.free)(objnode->slots[i],
42307 + (tmem_pamops->free)(objnode->slots[i],
42308 obj->pool, NULL, 0, true);
42309 objnode->slots[i] = NULL;
42310 continue;
42311 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42312 return;
42313 if (obj->objnode_tree_height == 0) {
42314 obj->pampd_count--;
42315 - (*tmem_pamops.free)(obj->objnode_tree_root,
42316 + (tmem_pamops->free)(obj->objnode_tree_root,
42317 obj->pool, NULL, 0, true);
42318 } else {
42319 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
42320 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42321 obj->objnode_tree_root = NULL;
42322 #ifdef CONFIG_RAMSTER
42323 if (tmem_pamops.free_obj != NULL)
42324 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
42325 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
42326 #endif
42327 }
42328
42329 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42330 /* if found, is a dup put, flush the old one */
42331 pampd_del = tmem_pampd_delete_from_obj(obj, index);
42332 BUG_ON(pampd_del != pampd);
42333 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
42334 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
42335 if (obj->pampd_count == 0) {
42336 objnew = obj;
42337 objfound = NULL;
42338 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42339 pampd = NULL;
42340 }
42341 } else {
42342 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
42343 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
42344 if (unlikely(obj == NULL)) {
42345 ret = -ENOMEM;
42346 goto out;
42347 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42348 if (unlikely(ret == -ENOMEM))
42349 /* may have partially built objnode tree ("stump") */
42350 goto delete_and_free;
42351 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
42352 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
42353 goto out;
42354
42355 delete_and_free:
42356 (void)tmem_pampd_delete_from_obj(obj, index);
42357 if (pampd)
42358 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
42359 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
42360 if (objnew) {
42361 tmem_obj_free(objnew, hb);
42362 - (*tmem_hostops.obj_free)(objnew, pool);
42363 + (tmem_hostops->obj_free)(objnew, pool);
42364 }
42365 out:
42366 spin_unlock(&hb->lock);
42367 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
42368 if (pampd != NULL) {
42369 BUG_ON(obj == NULL);
42370 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
42371 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
42372 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
42373 } else if (delete) {
42374 BUG_ON(obj == NULL);
42375 (void)tmem_pampd_delete_from_obj(obj, index);
42376 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
42377 int ret = 0;
42378
42379 if (!is_ephemeral(pool))
42380 - new_pampd = (*tmem_pamops.repatriate_preload)(
42381 + new_pampd = (tmem_pamops->repatriate_preload)(
42382 old_pampd, pool, oidp, index, &intransit);
42383 if (intransit)
42384 ret = -EAGAIN;
42385 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
42386 /* must release the hb->lock else repatriate can't sleep */
42387 spin_unlock(&hb->lock);
42388 if (!intransit)
42389 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
42390 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
42391 oidp, index, free, data);
42392 if (ret == -EAGAIN) {
42393 /* rare I think, but should cond_resched()??? */
42394 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
42395 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
42396 /* if we bug here, pamops wasn't properly set up for ramster */
42397 BUG_ON(tmem_pamops.replace_in_obj == NULL);
42398 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
42399 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
42400 out:
42401 spin_unlock(&hb->lock);
42402 return ret;
42403 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42404 if (free) {
42405 if (obj->pampd_count == 0) {
42406 tmem_obj_free(obj, hb);
42407 - (*tmem_hostops.obj_free)(obj, pool);
42408 + (tmem_hostops->obj_free)(obj, pool);
42409 obj = NULL;
42410 }
42411 }
42412 if (free)
42413 - ret = (*tmem_pamops.get_data_and_free)(
42414 + ret = (tmem_pamops->get_data_and_free)(
42415 data, sizep, raw, pampd, pool, oidp, index);
42416 else
42417 - ret = (*tmem_pamops.get_data)(
42418 + ret = (tmem_pamops->get_data)(
42419 data, sizep, raw, pampd, pool, oidp, index);
42420 if (ret < 0)
42421 goto out;
42422 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
42423 pampd = tmem_pampd_delete_from_obj(obj, index);
42424 if (pampd == NULL)
42425 goto out;
42426 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
42427 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
42428 if (obj->pampd_count == 0) {
42429 tmem_obj_free(obj, hb);
42430 - (*tmem_hostops.obj_free)(obj, pool);
42431 + (tmem_hostops->obj_free)(obj, pool);
42432 }
42433 ret = 0;
42434
42435 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
42436 goto out;
42437 tmem_pampd_destroy_all_in_obj(obj, false);
42438 tmem_obj_free(obj, hb);
42439 - (*tmem_hostops.obj_free)(obj, pool);
42440 + (tmem_hostops->obj_free)(obj, pool);
42441 ret = 0;
42442
42443 out:
42444 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42445 index dc23395..cf7e9b1 100644
42446 --- a/drivers/staging/rtl8712/rtl871x_io.h
42447 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42448 @@ -108,7 +108,7 @@ struct _io_ops {
42449 u8 *pmem);
42450 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42451 u8 *pmem);
42452 -};
42453 +} __no_const;
42454
42455 struct io_req {
42456 struct list_head list;
42457 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42458 index 1f5088b..0e59820 100644
42459 --- a/drivers/staging/sbe-2t3e3/netdev.c
42460 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42461 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42462 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
42463
42464 if (rlen)
42465 - if (copy_to_user(data, &resp, rlen))
42466 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
42467 return -EFAULT;
42468
42469 return 0;
42470 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
42471 index 5dddc4d..34fcb2f 100644
42472 --- a/drivers/staging/usbip/vhci.h
42473 +++ b/drivers/staging/usbip/vhci.h
42474 @@ -83,7 +83,7 @@ struct vhci_hcd {
42475 unsigned resuming:1;
42476 unsigned long re_timeout;
42477
42478 - atomic_t seqnum;
42479 + atomic_unchecked_t seqnum;
42480
42481 /*
42482 * NOTE:
42483 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
42484 index c3aa219..bf8b3de 100644
42485 --- a/drivers/staging/usbip/vhci_hcd.c
42486 +++ b/drivers/staging/usbip/vhci_hcd.c
42487 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
42488 return;
42489 }
42490
42491 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
42492 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42493 if (priv->seqnum == 0xffff)
42494 dev_info(&urb->dev->dev, "seqnum max\n");
42495
42496 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
42497 return -ENOMEM;
42498 }
42499
42500 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
42501 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42502 if (unlink->seqnum == 0xffff)
42503 pr_info("seqnum max\n");
42504
42505 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
42506 vdev->rhport = rhport;
42507 }
42508
42509 - atomic_set(&vhci->seqnum, 0);
42510 + atomic_set_unchecked(&vhci->seqnum, 0);
42511 spin_lock_init(&vhci->lock);
42512
42513 hcd->power_budget = 0; /* no limit */
42514 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
42515 index ba5f1c0..11d8122 100644
42516 --- a/drivers/staging/usbip/vhci_rx.c
42517 +++ b/drivers/staging/usbip/vhci_rx.c
42518 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
42519 if (!urb) {
42520 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
42521 pr_info("max seqnum %d\n",
42522 - atomic_read(&the_controller->seqnum));
42523 + atomic_read_unchecked(&the_controller->seqnum));
42524 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
42525 return;
42526 }
42527 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
42528 index 5f13890..36a044b 100644
42529 --- a/drivers/staging/vt6655/hostap.c
42530 +++ b/drivers/staging/vt6655/hostap.c
42531 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
42532 *
42533 */
42534
42535 +static net_device_ops_no_const apdev_netdev_ops;
42536 +
42537 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42538 {
42539 PSDevice apdev_priv;
42540 struct net_device *dev = pDevice->dev;
42541 int ret;
42542 - const struct net_device_ops apdev_netdev_ops = {
42543 - .ndo_start_xmit = pDevice->tx_80211,
42544 - };
42545
42546 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42547
42548 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42549 *apdev_priv = *pDevice;
42550 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42551
42552 + /* only half broken now */
42553 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42554 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42555
42556 pDevice->apdev->type = ARPHRD_IEEE80211;
42557 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
42558 index 26a7d0e..897b083 100644
42559 --- a/drivers/staging/vt6656/hostap.c
42560 +++ b/drivers/staging/vt6656/hostap.c
42561 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
42562 *
42563 */
42564
42565 +static net_device_ops_no_const apdev_netdev_ops;
42566 +
42567 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42568 {
42569 PSDevice apdev_priv;
42570 struct net_device *dev = pDevice->dev;
42571 int ret;
42572 - const struct net_device_ops apdev_netdev_ops = {
42573 - .ndo_start_xmit = pDevice->tx_80211,
42574 - };
42575
42576 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42577
42578 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42579 *apdev_priv = *pDevice;
42580 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42581
42582 + /* only half broken now */
42583 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42584 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42585
42586 pDevice->apdev->type = ARPHRD_IEEE80211;
42587 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
42588 index 56c8e60..1920c63 100644
42589 --- a/drivers/staging/zcache/tmem.c
42590 +++ b/drivers/staging/zcache/tmem.c
42591 @@ -39,7 +39,7 @@
42592 * A tmem host implementation must use this function to register callbacks
42593 * for memory allocation.
42594 */
42595 -static struct tmem_hostops tmem_hostops;
42596 +static tmem_hostops_no_const tmem_hostops;
42597
42598 static void tmem_objnode_tree_init(void);
42599
42600 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
42601 * A tmem host implementation must use this function to register
42602 * callbacks for a page-accessible memory (PAM) implementation
42603 */
42604 -static struct tmem_pamops tmem_pamops;
42605 +static tmem_pamops_no_const tmem_pamops;
42606
42607 void tmem_register_pamops(struct tmem_pamops *m)
42608 {
42609 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
42610 index 0d4aa82..f7832d4 100644
42611 --- a/drivers/staging/zcache/tmem.h
42612 +++ b/drivers/staging/zcache/tmem.h
42613 @@ -180,6 +180,7 @@ struct tmem_pamops {
42614 void (*new_obj)(struct tmem_obj *);
42615 int (*replace_in_obj)(void *, struct tmem_obj *);
42616 };
42617 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
42618 extern void tmem_register_pamops(struct tmem_pamops *m);
42619
42620 /* memory allocation methods provided by the host implementation */
42621 @@ -189,6 +190,7 @@ struct tmem_hostops {
42622 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
42623 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
42624 };
42625 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
42626 extern void tmem_register_hostops(struct tmem_hostops *m);
42627
42628 /* core tmem accessor functions */
42629 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
42630 index 96f4981..4daaa7e 100644
42631 --- a/drivers/target/target_core_device.c
42632 +++ b/drivers/target/target_core_device.c
42633 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
42634 spin_lock_init(&dev->se_port_lock);
42635 spin_lock_init(&dev->se_tmr_lock);
42636 spin_lock_init(&dev->qf_cmd_lock);
42637 - atomic_set(&dev->dev_ordered_id, 0);
42638 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
42639 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
42640 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
42641 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
42642 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
42643 index bd587b7..173daf3 100644
42644 --- a/drivers/target/target_core_transport.c
42645 +++ b/drivers/target/target_core_transport.c
42646 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
42647 * Used to determine when ORDERED commands should go from
42648 * Dormant to Active status.
42649 */
42650 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
42651 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
42652 smp_mb__after_atomic_inc();
42653 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
42654 cmd->se_ordered_id, cmd->sam_task_attr,
42655 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
42656 index b09c8d1f..c4225c0 100644
42657 --- a/drivers/tty/cyclades.c
42658 +++ b/drivers/tty/cyclades.c
42659 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
42660 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
42661 info->port.count);
42662 #endif
42663 - info->port.count++;
42664 + atomic_inc(&info->port.count);
42665 #ifdef CY_DEBUG_COUNT
42666 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
42667 - current->pid, info->port.count);
42668 + current->pid, atomic_read(&info->port.count));
42669 #endif
42670
42671 /*
42672 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
42673 for (j = 0; j < cy_card[i].nports; j++) {
42674 info = &cy_card[i].ports[j];
42675
42676 - if (info->port.count) {
42677 + if (atomic_read(&info->port.count)) {
42678 /* XXX is the ldisc num worth this? */
42679 struct tty_struct *tty;
42680 struct tty_ldisc *ld;
42681 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
42682 index 13ee53b..418d164 100644
42683 --- a/drivers/tty/hvc/hvc_console.c
42684 +++ b/drivers/tty/hvc/hvc_console.c
42685 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
42686
42687 spin_lock_irqsave(&hp->port.lock, flags);
42688 /* Check and then increment for fast path open. */
42689 - if (hp->port.count++ > 0) {
42690 + if (atomic_inc_return(&hp->port.count) > 1) {
42691 spin_unlock_irqrestore(&hp->port.lock, flags);
42692 hvc_kick();
42693 return 0;
42694 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42695
42696 spin_lock_irqsave(&hp->port.lock, flags);
42697
42698 - if (--hp->port.count == 0) {
42699 + if (atomic_dec_return(&hp->port.count) == 0) {
42700 spin_unlock_irqrestore(&hp->port.lock, flags);
42701 /* We are done with the tty pointer now. */
42702 tty_port_tty_set(&hp->port, NULL);
42703 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42704 */
42705 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
42706 } else {
42707 - if (hp->port.count < 0)
42708 + if (atomic_read(&hp->port.count) < 0)
42709 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
42710 - hp->vtermno, hp->port.count);
42711 + hp->vtermno, atomic_read(&hp->port.count));
42712 spin_unlock_irqrestore(&hp->port.lock, flags);
42713 }
42714 }
42715 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
42716 * open->hangup case this can be called after the final close so prevent
42717 * that from happening for now.
42718 */
42719 - if (hp->port.count <= 0) {
42720 + if (atomic_read(&hp->port.count) <= 0) {
42721 spin_unlock_irqrestore(&hp->port.lock, flags);
42722 return;
42723 }
42724
42725 - hp->port.count = 0;
42726 + atomic_set(&hp->port.count, 0);
42727 spin_unlock_irqrestore(&hp->port.lock, flags);
42728 tty_port_tty_set(&hp->port, NULL);
42729
42730 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
42731 return -EPIPE;
42732
42733 /* FIXME what's this (unprotected) check for? */
42734 - if (hp->port.count <= 0)
42735 + if (atomic_read(&hp->port.count) <= 0)
42736 return -EIO;
42737
42738 spin_lock_irqsave(&hp->lock, flags);
42739 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
42740 index 8776357..b2d4afd 100644
42741 --- a/drivers/tty/hvc/hvcs.c
42742 +++ b/drivers/tty/hvc/hvcs.c
42743 @@ -83,6 +83,7 @@
42744 #include <asm/hvcserver.h>
42745 #include <asm/uaccess.h>
42746 #include <asm/vio.h>
42747 +#include <asm/local.h>
42748
42749 /*
42750 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
42751 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
42752
42753 spin_lock_irqsave(&hvcsd->lock, flags);
42754
42755 - if (hvcsd->port.count > 0) {
42756 + if (atomic_read(&hvcsd->port.count) > 0) {
42757 spin_unlock_irqrestore(&hvcsd->lock, flags);
42758 printk(KERN_INFO "HVCS: vterm state unchanged. "
42759 "The hvcs device node is still in use.\n");
42760 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
42761 }
42762 }
42763
42764 - hvcsd->port.count = 0;
42765 + atomic_set(&hvcsd->port.count, 0);
42766 hvcsd->port.tty = tty;
42767 tty->driver_data = hvcsd;
42768
42769 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
42770 unsigned long flags;
42771
42772 spin_lock_irqsave(&hvcsd->lock, flags);
42773 - hvcsd->port.count++;
42774 + atomic_inc(&hvcsd->port.count);
42775 hvcsd->todo_mask |= HVCS_SCHED_READ;
42776 spin_unlock_irqrestore(&hvcsd->lock, flags);
42777
42778 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42779 hvcsd = tty->driver_data;
42780
42781 spin_lock_irqsave(&hvcsd->lock, flags);
42782 - if (--hvcsd->port.count == 0) {
42783 + if (atomic_dec_and_test(&hvcsd->port.count)) {
42784
42785 vio_disable_interrupts(hvcsd->vdev);
42786
42787 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42788
42789 free_irq(irq, hvcsd);
42790 return;
42791 - } else if (hvcsd->port.count < 0) {
42792 + } else if (atomic_read(&hvcsd->port.count) < 0) {
42793 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
42794 " is missmanaged.\n",
42795 - hvcsd->vdev->unit_address, hvcsd->port.count);
42796 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
42797 }
42798
42799 spin_unlock_irqrestore(&hvcsd->lock, flags);
42800 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42801
42802 spin_lock_irqsave(&hvcsd->lock, flags);
42803 /* Preserve this so that we know how many kref refs to put */
42804 - temp_open_count = hvcsd->port.count;
42805 + temp_open_count = atomic_read(&hvcsd->port.count);
42806
42807 /*
42808 * Don't kref put inside the spinlock because the destruction
42809 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42810 tty->driver_data = NULL;
42811 hvcsd->port.tty = NULL;
42812
42813 - hvcsd->port.count = 0;
42814 + atomic_set(&hvcsd->port.count, 0);
42815
42816 /* This will drop any buffered data on the floor which is OK in a hangup
42817 * scenario. */
42818 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
42819 * the middle of a write operation? This is a crummy place to do this
42820 * but we want to keep it all in the spinlock.
42821 */
42822 - if (hvcsd->port.count <= 0) {
42823 + if (atomic_read(&hvcsd->port.count) <= 0) {
42824 spin_unlock_irqrestore(&hvcsd->lock, flags);
42825 return -ENODEV;
42826 }
42827 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
42828 {
42829 struct hvcs_struct *hvcsd = tty->driver_data;
42830
42831 - if (!hvcsd || hvcsd->port.count <= 0)
42832 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
42833 return 0;
42834
42835 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
42836 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
42837 index 2cde13d..645d78f 100644
42838 --- a/drivers/tty/ipwireless/tty.c
42839 +++ b/drivers/tty/ipwireless/tty.c
42840 @@ -29,6 +29,7 @@
42841 #include <linux/tty_driver.h>
42842 #include <linux/tty_flip.h>
42843 #include <linux/uaccess.h>
42844 +#include <asm/local.h>
42845
42846 #include "tty.h"
42847 #include "network.h"
42848 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42849 mutex_unlock(&tty->ipw_tty_mutex);
42850 return -ENODEV;
42851 }
42852 - if (tty->port.count == 0)
42853 + if (atomic_read(&tty->port.count) == 0)
42854 tty->tx_bytes_queued = 0;
42855
42856 - tty->port.count++;
42857 + atomic_inc(&tty->port.count);
42858
42859 tty->port.tty = linux_tty;
42860 linux_tty->driver_data = tty;
42861 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42862
42863 static void do_ipw_close(struct ipw_tty *tty)
42864 {
42865 - tty->port.count--;
42866 -
42867 - if (tty->port.count == 0) {
42868 + if (atomic_dec_return(&tty->port.count) == 0) {
42869 struct tty_struct *linux_tty = tty->port.tty;
42870
42871 if (linux_tty != NULL) {
42872 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
42873 return;
42874
42875 mutex_lock(&tty->ipw_tty_mutex);
42876 - if (tty->port.count == 0) {
42877 + if (atomic_read(&tty->port.count) == 0) {
42878 mutex_unlock(&tty->ipw_tty_mutex);
42879 return;
42880 }
42881 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
42882 return;
42883 }
42884
42885 - if (!tty->port.count) {
42886 + if (!atomic_read(&tty->port.count)) {
42887 mutex_unlock(&tty->ipw_tty_mutex);
42888 return;
42889 }
42890 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
42891 return -ENODEV;
42892
42893 mutex_lock(&tty->ipw_tty_mutex);
42894 - if (!tty->port.count) {
42895 + if (!atomic_read(&tty->port.count)) {
42896 mutex_unlock(&tty->ipw_tty_mutex);
42897 return -EINVAL;
42898 }
42899 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
42900 if (!tty)
42901 return -ENODEV;
42902
42903 - if (!tty->port.count)
42904 + if (!atomic_read(&tty->port.count))
42905 return -EINVAL;
42906
42907 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
42908 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
42909 if (!tty)
42910 return 0;
42911
42912 - if (!tty->port.count)
42913 + if (!atomic_read(&tty->port.count))
42914 return 0;
42915
42916 return tty->tx_bytes_queued;
42917 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
42918 if (!tty)
42919 return -ENODEV;
42920
42921 - if (!tty->port.count)
42922 + if (!atomic_read(&tty->port.count))
42923 return -EINVAL;
42924
42925 return get_control_lines(tty);
42926 @@ -391,7 +390,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
42927 if (!tty)
42928 return -ENODEV;
42929
42930 - if (!tty->port.count)
42931 + if (!atomic_read(&tty->port.count))
42932 return -EINVAL;
42933
42934 return set_control_lines(tty, set, clear);
42935 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
42936 if (!tty)
42937 return -ENODEV;
42938
42939 - if (!tty->port.count)
42940 + if (!atomic_read(&tty->port.count))
42941 return -EINVAL;
42942
42943 /* FIXME: Exactly how is the tty object locked here .. */
42944 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
42945 * are gone */
42946 mutex_lock(&ttyj->ipw_tty_mutex);
42947 }
42948 - while (ttyj->port.count)
42949 + while (atomic_read(&ttyj->port.count))
42950 do_ipw_close(ttyj);
42951 ipwireless_disassociate_network_ttys(network,
42952 ttyj->channel_idx);
42953 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
42954 index f9d2850..b006f04 100644
42955 --- a/drivers/tty/moxa.c
42956 +++ b/drivers/tty/moxa.c
42957 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
42958 }
42959
42960 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
42961 - ch->port.count++;
42962 + atomic_inc(&ch->port.count);
42963 tty->driver_data = ch;
42964 tty_port_tty_set(&ch->port, tty);
42965 mutex_lock(&ch->port.mutex);
42966 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
42967 index bfd6771..e0d93c4 100644
42968 --- a/drivers/tty/n_gsm.c
42969 +++ b/drivers/tty/n_gsm.c
42970 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
42971 spin_lock_init(&dlci->lock);
42972 mutex_init(&dlci->mutex);
42973 dlci->fifo = &dlci->_fifo;
42974 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
42975 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
42976 kfree(dlci);
42977 return NULL;
42978 }
42979 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
42980 struct gsm_dlci *dlci = tty->driver_data;
42981 struct tty_port *port = &dlci->port;
42982
42983 - port->count++;
42984 + atomic_inc(&port->count);
42985 dlci_get(dlci);
42986 dlci_get(dlci->gsm->dlci[0]);
42987 mux_get(dlci->gsm);
42988 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
42989 index 19083ef..6e34e97 100644
42990 --- a/drivers/tty/n_tty.c
42991 +++ b/drivers/tty/n_tty.c
42992 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
42993 {
42994 *ops = tty_ldisc_N_TTY;
42995 ops->owner = NULL;
42996 - ops->refcount = ops->flags = 0;
42997 + atomic_set(&ops->refcount, 0);
42998 + ops->flags = 0;
42999 }
43000 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43001 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43002 index ac35c90..c47deac 100644
43003 --- a/drivers/tty/pty.c
43004 +++ b/drivers/tty/pty.c
43005 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
43006 panic("Couldn't register Unix98 pts driver");
43007
43008 /* Now create the /dev/ptmx special device */
43009 + pax_open_kernel();
43010 tty_default_fops(&ptmx_fops);
43011 - ptmx_fops.open = ptmx_open;
43012 + *(void **)&ptmx_fops.open = ptmx_open;
43013 + pax_close_kernel();
43014
43015 cdev_init(&ptmx_cdev, &ptmx_fops);
43016 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43017 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43018 index e42009a..566a036 100644
43019 --- a/drivers/tty/rocket.c
43020 +++ b/drivers/tty/rocket.c
43021 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43022 tty->driver_data = info;
43023 tty_port_tty_set(port, tty);
43024
43025 - if (port->count++ == 0) {
43026 + if (atomic_inc_return(&port->count) == 1) {
43027 atomic_inc(&rp_num_ports_open);
43028
43029 #ifdef ROCKET_DEBUG_OPEN
43030 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43031 #endif
43032 }
43033 #ifdef ROCKET_DEBUG_OPEN
43034 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43035 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43036 #endif
43037
43038 /*
43039 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
43040 spin_unlock_irqrestore(&info->port.lock, flags);
43041 return;
43042 }
43043 - if (info->port.count)
43044 + if (atomic_read(&info->port.count))
43045 atomic_dec(&rp_num_ports_open);
43046 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43047 spin_unlock_irqrestore(&info->port.lock, flags);
43048 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43049 index 1002054..dd644a8 100644
43050 --- a/drivers/tty/serial/kgdboc.c
43051 +++ b/drivers/tty/serial/kgdboc.c
43052 @@ -24,8 +24,9 @@
43053 #define MAX_CONFIG_LEN 40
43054
43055 static struct kgdb_io kgdboc_io_ops;
43056 +static struct kgdb_io kgdboc_io_ops_console;
43057
43058 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43059 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43060 static int configured = -1;
43061
43062 static char config[MAX_CONFIG_LEN];
43063 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43064 kgdboc_unregister_kbd();
43065 if (configured == 1)
43066 kgdb_unregister_io_module(&kgdboc_io_ops);
43067 + else if (configured == 2)
43068 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43069 }
43070
43071 static int configure_kgdboc(void)
43072 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43073 int err;
43074 char *cptr = config;
43075 struct console *cons;
43076 + int is_console = 0;
43077
43078 err = kgdboc_option_setup(config);
43079 if (err || !strlen(config) || isspace(config[0]))
43080 goto noconfig;
43081
43082 err = -ENODEV;
43083 - kgdboc_io_ops.is_console = 0;
43084 kgdb_tty_driver = NULL;
43085
43086 kgdboc_use_kms = 0;
43087 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43088 int idx;
43089 if (cons->device && cons->device(cons, &idx) == p &&
43090 idx == tty_line) {
43091 - kgdboc_io_ops.is_console = 1;
43092 + is_console = 1;
43093 break;
43094 }
43095 cons = cons->next;
43096 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43097 kgdb_tty_line = tty_line;
43098
43099 do_register:
43100 - err = kgdb_register_io_module(&kgdboc_io_ops);
43101 + if (is_console) {
43102 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43103 + configured = 2;
43104 + } else {
43105 + err = kgdb_register_io_module(&kgdboc_io_ops);
43106 + configured = 1;
43107 + }
43108 if (err)
43109 goto noconfig;
43110
43111 @@ -205,8 +214,6 @@ do_register:
43112 if (err)
43113 goto nmi_con_failed;
43114
43115 - configured = 1;
43116 -
43117 return 0;
43118
43119 nmi_con_failed:
43120 @@ -223,7 +230,7 @@ noconfig:
43121 static int __init init_kgdboc(void)
43122 {
43123 /* Already configured? */
43124 - if (configured == 1)
43125 + if (configured >= 1)
43126 return 0;
43127
43128 return configure_kgdboc();
43129 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43130 if (config[len - 1] == '\n')
43131 config[len - 1] = '\0';
43132
43133 - if (configured == 1)
43134 + if (configured >= 1)
43135 cleanup_kgdboc();
43136
43137 /* Go and configure with the new params. */
43138 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43139 .post_exception = kgdboc_post_exp_handler,
43140 };
43141
43142 +static struct kgdb_io kgdboc_io_ops_console = {
43143 + .name = "kgdboc",
43144 + .read_char = kgdboc_get_char,
43145 + .write_char = kgdboc_put_char,
43146 + .pre_exception = kgdboc_pre_exp_handler,
43147 + .post_exception = kgdboc_post_exp_handler,
43148 + .is_console = 1
43149 +};
43150 +
43151 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43152 /* This is only available if kgdboc is a built in for early debugging */
43153 static int __init kgdboc_early_init(char *opt)
43154 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43155 index e514b3a..c73d614 100644
43156 --- a/drivers/tty/serial/samsung.c
43157 +++ b/drivers/tty/serial/samsung.c
43158 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43159 }
43160 }
43161
43162 +static int s3c64xx_serial_startup(struct uart_port *port);
43163 static int s3c24xx_serial_startup(struct uart_port *port)
43164 {
43165 struct s3c24xx_uart_port *ourport = to_ourport(port);
43166 int ret;
43167
43168 + /* Startup sequence is different for s3c64xx and higher SoC's */
43169 + if (s3c24xx_serial_has_interrupt_mask(port))
43170 + return s3c64xx_serial_startup(port);
43171 +
43172 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43173 port->mapbase, port->membase);
43174
43175 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43176 /* setup info for port */
43177 port->dev = &platdev->dev;
43178
43179 - /* Startup sequence is different for s3c64xx and higher SoC's */
43180 - if (s3c24xx_serial_has_interrupt_mask(port))
43181 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43182 -
43183 port->uartclk = 1;
43184
43185 if (cfg->uart_flags & UPF_CONS_FLOW) {
43186 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43187 index 2c7230a..2104f16 100644
43188 --- a/drivers/tty/serial/serial_core.c
43189 +++ b/drivers/tty/serial/serial_core.c
43190 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
43191 uart_flush_buffer(tty);
43192 uart_shutdown(tty, state);
43193 spin_lock_irqsave(&port->lock, flags);
43194 - port->count = 0;
43195 + atomic_set(&port->count, 0);
43196 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43197 spin_unlock_irqrestore(&port->lock, flags);
43198 tty_port_tty_set(port, NULL);
43199 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43200 goto end;
43201 }
43202
43203 - port->count++;
43204 + atomic_inc(&port->count);
43205 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43206 retval = -ENXIO;
43207 goto err_dec_count;
43208 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43209 /*
43210 * Make sure the device is in D0 state.
43211 */
43212 - if (port->count == 1)
43213 + if (atomic_read(&port->count) == 1)
43214 uart_change_pm(state, 0);
43215
43216 /*
43217 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43218 end:
43219 return retval;
43220 err_dec_count:
43221 - port->count--;
43222 + atomic_inc(&port->count);
43223 mutex_unlock(&port->mutex);
43224 goto end;
43225 }
43226 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43227 index 9e071f6..f30ae69 100644
43228 --- a/drivers/tty/synclink.c
43229 +++ b/drivers/tty/synclink.c
43230 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43231
43232 if (debug_level >= DEBUG_LEVEL_INFO)
43233 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43234 - __FILE__,__LINE__, info->device_name, info->port.count);
43235 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43236
43237 if (tty_port_close_start(&info->port, tty, filp) == 0)
43238 goto cleanup;
43239 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43240 cleanup:
43241 if (debug_level >= DEBUG_LEVEL_INFO)
43242 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43243 - tty->driver->name, info->port.count);
43244 + tty->driver->name, atomic_read(&info->port.count));
43245
43246 } /* end of mgsl_close() */
43247
43248 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43249
43250 mgsl_flush_buffer(tty);
43251 shutdown(info);
43252 -
43253 - info->port.count = 0;
43254 +
43255 + atomic_set(&info->port.count, 0);
43256 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43257 info->port.tty = NULL;
43258
43259 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43260
43261 if (debug_level >= DEBUG_LEVEL_INFO)
43262 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43263 - __FILE__,__LINE__, tty->driver->name, port->count );
43264 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43265
43266 spin_lock_irqsave(&info->irq_spinlock, flags);
43267 if (!tty_hung_up_p(filp)) {
43268 extra_count = true;
43269 - port->count--;
43270 + atomic_dec(&port->count);
43271 }
43272 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43273 port->blocked_open++;
43274 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43275
43276 if (debug_level >= DEBUG_LEVEL_INFO)
43277 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43278 - __FILE__,__LINE__, tty->driver->name, port->count );
43279 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43280
43281 tty_unlock(tty);
43282 schedule();
43283 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43284
43285 /* FIXME: Racy on hangup during close wait */
43286 if (extra_count)
43287 - port->count++;
43288 + atomic_inc(&port->count);
43289 port->blocked_open--;
43290
43291 if (debug_level >= DEBUG_LEVEL_INFO)
43292 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43293 - __FILE__,__LINE__, tty->driver->name, port->count );
43294 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43295
43296 if (!retval)
43297 port->flags |= ASYNC_NORMAL_ACTIVE;
43298 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43299
43300 if (debug_level >= DEBUG_LEVEL_INFO)
43301 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43302 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43303 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43304
43305 /* If port is closing, signal caller to try again */
43306 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43307 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43308 spin_unlock_irqrestore(&info->netlock, flags);
43309 goto cleanup;
43310 }
43311 - info->port.count++;
43312 + atomic_inc(&info->port.count);
43313 spin_unlock_irqrestore(&info->netlock, flags);
43314
43315 - if (info->port.count == 1) {
43316 + if (atomic_read(&info->port.count) == 1) {
43317 /* 1st open on this device, init hardware */
43318 retval = startup(info);
43319 if (retval < 0)
43320 @@ -3451,8 +3451,8 @@ cleanup:
43321 if (retval) {
43322 if (tty->count == 1)
43323 info->port.tty = NULL; /* tty layer will release tty struct */
43324 - if(info->port.count)
43325 - info->port.count--;
43326 + if (atomic_read(&info->port.count))
43327 + atomic_dec(&info->port.count);
43328 }
43329
43330 return retval;
43331 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43332 unsigned short new_crctype;
43333
43334 /* return error if TTY interface open */
43335 - if (info->port.count)
43336 + if (atomic_read(&info->port.count))
43337 return -EBUSY;
43338
43339 switch (encoding)
43340 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
43341
43342 /* arbitrate between network and tty opens */
43343 spin_lock_irqsave(&info->netlock, flags);
43344 - if (info->port.count != 0 || info->netcount != 0) {
43345 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43346 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43347 spin_unlock_irqrestore(&info->netlock, flags);
43348 return -EBUSY;
43349 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43350 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43351
43352 /* return error if TTY interface open */
43353 - if (info->port.count)
43354 + if (atomic_read(&info->port.count))
43355 return -EBUSY;
43356
43357 if (cmd != SIOCWANDEV)
43358 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43359 index aba1e59..877ac33 100644
43360 --- a/drivers/tty/synclink_gt.c
43361 +++ b/drivers/tty/synclink_gt.c
43362 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43363 tty->driver_data = info;
43364 info->port.tty = tty;
43365
43366 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43367 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43368
43369 /* If port is closing, signal caller to try again */
43370 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43371 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43372 mutex_unlock(&info->port.mutex);
43373 goto cleanup;
43374 }
43375 - info->port.count++;
43376 + atomic_inc(&info->port.count);
43377 spin_unlock_irqrestore(&info->netlock, flags);
43378
43379 - if (info->port.count == 1) {
43380 + if (atomic_read(&info->port.count) == 1) {
43381 /* 1st open on this device, init hardware */
43382 retval = startup(info);
43383 if (retval < 0) {
43384 @@ -716,8 +716,8 @@ cleanup:
43385 if (retval) {
43386 if (tty->count == 1)
43387 info->port.tty = NULL; /* tty layer will release tty struct */
43388 - if(info->port.count)
43389 - info->port.count--;
43390 + if(atomic_read(&info->port.count))
43391 + atomic_dec(&info->port.count);
43392 }
43393
43394 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43395 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43396
43397 if (sanity_check(info, tty->name, "close"))
43398 return;
43399 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43400 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43401
43402 if (tty_port_close_start(&info->port, tty, filp) == 0)
43403 goto cleanup;
43404 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43405 tty_port_close_end(&info->port, tty);
43406 info->port.tty = NULL;
43407 cleanup:
43408 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43409 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43410 }
43411
43412 static void hangup(struct tty_struct *tty)
43413 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
43414 shutdown(info);
43415
43416 spin_lock_irqsave(&info->port.lock, flags);
43417 - info->port.count = 0;
43418 + atomic_set(&info->port.count, 0);
43419 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43420 info->port.tty = NULL;
43421 spin_unlock_irqrestore(&info->port.lock, flags);
43422 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43423 unsigned short new_crctype;
43424
43425 /* return error if TTY interface open */
43426 - if (info->port.count)
43427 + if (atomic_read(&info->port.count))
43428 return -EBUSY;
43429
43430 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43431 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
43432
43433 /* arbitrate between network and tty opens */
43434 spin_lock_irqsave(&info->netlock, flags);
43435 - if (info->port.count != 0 || info->netcount != 0) {
43436 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43437 DBGINFO(("%s hdlc_open busy\n", dev->name));
43438 spin_unlock_irqrestore(&info->netlock, flags);
43439 return -EBUSY;
43440 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43441 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
43442
43443 /* return error if TTY interface open */
43444 - if (info->port.count)
43445 + if (atomic_read(&info->port.count))
43446 return -EBUSY;
43447
43448 if (cmd != SIOCWANDEV)
43449 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43450 if (port == NULL)
43451 continue;
43452 spin_lock(&port->lock);
43453 - if ((port->port.count || port->netcount) &&
43454 + if ((atomic_read(&port->port.count) || port->netcount) &&
43455 port->pending_bh && !port->bh_running &&
43456 !port->bh_requested) {
43457 DBGISR(("%s bh queued\n", port->device_name));
43458 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43459 spin_lock_irqsave(&info->lock, flags);
43460 if (!tty_hung_up_p(filp)) {
43461 extra_count = true;
43462 - port->count--;
43463 + atomic_dec(&port->count);
43464 }
43465 spin_unlock_irqrestore(&info->lock, flags);
43466 port->blocked_open++;
43467 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43468 remove_wait_queue(&port->open_wait, &wait);
43469
43470 if (extra_count)
43471 - port->count++;
43472 + atomic_inc(&port->count);
43473 port->blocked_open--;
43474
43475 if (!retval)
43476 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
43477 index fd43fb6..34704ad 100644
43478 --- a/drivers/tty/synclinkmp.c
43479 +++ b/drivers/tty/synclinkmp.c
43480 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43481
43482 if (debug_level >= DEBUG_LEVEL_INFO)
43483 printk("%s(%d):%s open(), old ref count = %d\n",
43484 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43485 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43486
43487 /* If port is closing, signal caller to try again */
43488 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43489 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43490 spin_unlock_irqrestore(&info->netlock, flags);
43491 goto cleanup;
43492 }
43493 - info->port.count++;
43494 + atomic_inc(&info->port.count);
43495 spin_unlock_irqrestore(&info->netlock, flags);
43496
43497 - if (info->port.count == 1) {
43498 + if (atomic_read(&info->port.count) == 1) {
43499 /* 1st open on this device, init hardware */
43500 retval = startup(info);
43501 if (retval < 0)
43502 @@ -797,8 +797,8 @@ cleanup:
43503 if (retval) {
43504 if (tty->count == 1)
43505 info->port.tty = NULL; /* tty layer will release tty struct */
43506 - if(info->port.count)
43507 - info->port.count--;
43508 + if(atomic_read(&info->port.count))
43509 + atomic_dec(&info->port.count);
43510 }
43511
43512 return retval;
43513 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43514
43515 if (debug_level >= DEBUG_LEVEL_INFO)
43516 printk("%s(%d):%s close() entry, count=%d\n",
43517 - __FILE__,__LINE__, info->device_name, info->port.count);
43518 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43519
43520 if (tty_port_close_start(&info->port, tty, filp) == 0)
43521 goto cleanup;
43522 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43523 cleanup:
43524 if (debug_level >= DEBUG_LEVEL_INFO)
43525 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
43526 - tty->driver->name, info->port.count);
43527 + tty->driver->name, atomic_read(&info->port.count));
43528 }
43529
43530 /* Called by tty_hangup() when a hangup is signaled.
43531 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
43532 shutdown(info);
43533
43534 spin_lock_irqsave(&info->port.lock, flags);
43535 - info->port.count = 0;
43536 + atomic_set(&info->port.count, 0);
43537 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43538 info->port.tty = NULL;
43539 spin_unlock_irqrestore(&info->port.lock, flags);
43540 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43541 unsigned short new_crctype;
43542
43543 /* return error if TTY interface open */
43544 - if (info->port.count)
43545 + if (atomic_read(&info->port.count))
43546 return -EBUSY;
43547
43548 switch (encoding)
43549 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
43550
43551 /* arbitrate between network and tty opens */
43552 spin_lock_irqsave(&info->netlock, flags);
43553 - if (info->port.count != 0 || info->netcount != 0) {
43554 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43555 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43556 spin_unlock_irqrestore(&info->netlock, flags);
43557 return -EBUSY;
43558 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43559 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43560
43561 /* return error if TTY interface open */
43562 - if (info->port.count)
43563 + if (atomic_read(&info->port.count))
43564 return -EBUSY;
43565
43566 if (cmd != SIOCWANDEV)
43567 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
43568 * do not request bottom half processing if the
43569 * device is not open in a normal mode.
43570 */
43571 - if ( port && (port->port.count || port->netcount) &&
43572 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
43573 port->pending_bh && !port->bh_running &&
43574 !port->bh_requested ) {
43575 if ( debug_level >= DEBUG_LEVEL_ISR )
43576 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43577
43578 if (debug_level >= DEBUG_LEVEL_INFO)
43579 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
43580 - __FILE__,__LINE__, tty->driver->name, port->count );
43581 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43582
43583 spin_lock_irqsave(&info->lock, flags);
43584 if (!tty_hung_up_p(filp)) {
43585 extra_count = true;
43586 - port->count--;
43587 + atomic_dec(&port->count);
43588 }
43589 spin_unlock_irqrestore(&info->lock, flags);
43590 port->blocked_open++;
43591 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43592
43593 if (debug_level >= DEBUG_LEVEL_INFO)
43594 printk("%s(%d):%s block_til_ready() count=%d\n",
43595 - __FILE__,__LINE__, tty->driver->name, port->count );
43596 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43597
43598 tty_unlock(tty);
43599 schedule();
43600 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43601 remove_wait_queue(&port->open_wait, &wait);
43602
43603 if (extra_count)
43604 - port->count++;
43605 + atomic_inc(&port->count);
43606 port->blocked_open--;
43607
43608 if (debug_level >= DEBUG_LEVEL_INFO)
43609 printk("%s(%d):%s block_til_ready() after, count=%d\n",
43610 - __FILE__,__LINE__, tty->driver->name, port->count );
43611 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43612
43613 if (!retval)
43614 port->flags |= ASYNC_NORMAL_ACTIVE;
43615 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
43616 index b3c4a25..723916f 100644
43617 --- a/drivers/tty/sysrq.c
43618 +++ b/drivers/tty/sysrq.c
43619 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
43620 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
43621 size_t count, loff_t *ppos)
43622 {
43623 - if (count) {
43624 + if (count && capable(CAP_SYS_ADMIN)) {
43625 char c;
43626
43627 if (get_user(c, buf))
43628 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
43629 index da9fde8..c07975f 100644
43630 --- a/drivers/tty/tty_io.c
43631 +++ b/drivers/tty/tty_io.c
43632 @@ -3391,7 +3391,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
43633
43634 void tty_default_fops(struct file_operations *fops)
43635 {
43636 - *fops = tty_fops;
43637 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
43638 }
43639
43640 /*
43641 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
43642 index c578229..45aa9ee 100644
43643 --- a/drivers/tty/tty_ldisc.c
43644 +++ b/drivers/tty/tty_ldisc.c
43645 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
43646 if (atomic_dec_and_test(&ld->users)) {
43647 struct tty_ldisc_ops *ldo = ld->ops;
43648
43649 - ldo->refcount--;
43650 + atomic_dec(&ldo->refcount);
43651 module_put(ldo->owner);
43652 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43653
43654 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
43655 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43656 tty_ldiscs[disc] = new_ldisc;
43657 new_ldisc->num = disc;
43658 - new_ldisc->refcount = 0;
43659 + atomic_set(&new_ldisc->refcount, 0);
43660 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43661
43662 return ret;
43663 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
43664 return -EINVAL;
43665
43666 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43667 - if (tty_ldiscs[disc]->refcount)
43668 + if (atomic_read(&tty_ldiscs[disc]->refcount))
43669 ret = -EBUSY;
43670 else
43671 tty_ldiscs[disc] = NULL;
43672 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
43673 if (ldops) {
43674 ret = ERR_PTR(-EAGAIN);
43675 if (try_module_get(ldops->owner)) {
43676 - ldops->refcount++;
43677 + atomic_inc(&ldops->refcount);
43678 ret = ldops;
43679 }
43680 }
43681 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
43682 unsigned long flags;
43683
43684 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43685 - ldops->refcount--;
43686 + atomic_dec(&ldops->refcount);
43687 module_put(ldops->owner);
43688 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43689 }
43690 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
43691 index b7ff59d..7c6105e 100644
43692 --- a/drivers/tty/tty_port.c
43693 +++ b/drivers/tty/tty_port.c
43694 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
43695 unsigned long flags;
43696
43697 spin_lock_irqsave(&port->lock, flags);
43698 - port->count = 0;
43699 + atomic_set(&port->count, 0);
43700 port->flags &= ~ASYNC_NORMAL_ACTIVE;
43701 if (port->tty) {
43702 set_bit(TTY_IO_ERROR, &port->tty->flags);
43703 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43704 /* The port lock protects the port counts */
43705 spin_lock_irqsave(&port->lock, flags);
43706 if (!tty_hung_up_p(filp))
43707 - port->count--;
43708 + atomic_dec(&port->count);
43709 port->blocked_open++;
43710 spin_unlock_irqrestore(&port->lock, flags);
43711
43712 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43713 we must not mess that up further */
43714 spin_lock_irqsave(&port->lock, flags);
43715 if (!tty_hung_up_p(filp))
43716 - port->count++;
43717 + atomic_inc(&port->count);
43718 port->blocked_open--;
43719 if (retval == 0)
43720 port->flags |= ASYNC_NORMAL_ACTIVE;
43721 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
43722 return 0;
43723 }
43724
43725 - if (tty->count == 1 && port->count != 1) {
43726 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
43727 printk(KERN_WARNING
43728 "tty_port_close_start: tty->count = 1 port count = %d.\n",
43729 - port->count);
43730 - port->count = 1;
43731 + atomic_read(&port->count));
43732 + atomic_set(&port->count, 1);
43733 }
43734 - if (--port->count < 0) {
43735 + if (atomic_dec_return(&port->count) < 0) {
43736 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
43737 - port->count);
43738 - port->count = 0;
43739 + atomic_read(&port->count));
43740 + atomic_set(&port->count, 0);
43741 }
43742
43743 - if (port->count) {
43744 + if (atomic_read(&port->count)) {
43745 spin_unlock_irqrestore(&port->lock, flags);
43746 if (port->ops->drop)
43747 port->ops->drop(port);
43748 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
43749 {
43750 spin_lock_irq(&port->lock);
43751 if (!tty_hung_up_p(filp))
43752 - ++port->count;
43753 + atomic_inc(&port->count);
43754 spin_unlock_irq(&port->lock);
43755 tty_port_tty_set(port, tty);
43756
43757 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
43758 index 681765b..d3ccdf2 100644
43759 --- a/drivers/tty/vt/keyboard.c
43760 +++ b/drivers/tty/vt/keyboard.c
43761 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
43762 kbd->kbdmode == VC_OFF) &&
43763 value != KVAL(K_SAK))
43764 return; /* SAK is allowed even in raw mode */
43765 +
43766 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
43767 + {
43768 + void *func = fn_handler[value];
43769 + if (func == fn_show_state || func == fn_show_ptregs ||
43770 + func == fn_show_mem)
43771 + return;
43772 + }
43773 +#endif
43774 +
43775 fn_handler[value](vc);
43776 }
43777
43778 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43779 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
43780 return -EFAULT;
43781
43782 - if (!capable(CAP_SYS_TTY_CONFIG))
43783 - perm = 0;
43784 -
43785 switch (cmd) {
43786 case KDGKBENT:
43787 /* Ensure another thread doesn't free it under us */
43788 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43789 spin_unlock_irqrestore(&kbd_event_lock, flags);
43790 return put_user(val, &user_kbe->kb_value);
43791 case KDSKBENT:
43792 + if (!capable(CAP_SYS_TTY_CONFIG))
43793 + perm = 0;
43794 +
43795 if (!perm)
43796 return -EPERM;
43797 if (!i && v == K_NOSUCHMAP) {
43798 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43799 int i, j, k;
43800 int ret;
43801
43802 - if (!capable(CAP_SYS_TTY_CONFIG))
43803 - perm = 0;
43804 -
43805 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
43806 if (!kbs) {
43807 ret = -ENOMEM;
43808 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43809 kfree(kbs);
43810 return ((p && *p) ? -EOVERFLOW : 0);
43811 case KDSKBSENT:
43812 + if (!capable(CAP_SYS_TTY_CONFIG))
43813 + perm = 0;
43814 +
43815 if (!perm) {
43816 ret = -EPERM;
43817 goto reterr;
43818 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
43819 index 5110f36..8dc0a74 100644
43820 --- a/drivers/uio/uio.c
43821 +++ b/drivers/uio/uio.c
43822 @@ -25,6 +25,7 @@
43823 #include <linux/kobject.h>
43824 #include <linux/cdev.h>
43825 #include <linux/uio_driver.h>
43826 +#include <asm/local.h>
43827
43828 #define UIO_MAX_DEVICES (1U << MINORBITS)
43829
43830 @@ -32,10 +33,10 @@ struct uio_device {
43831 struct module *owner;
43832 struct device *dev;
43833 int minor;
43834 - atomic_t event;
43835 + atomic_unchecked_t event;
43836 struct fasync_struct *async_queue;
43837 wait_queue_head_t wait;
43838 - int vma_count;
43839 + local_t vma_count;
43840 struct uio_info *info;
43841 struct kobject *map_dir;
43842 struct kobject *portio_dir;
43843 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
43844 struct device_attribute *attr, char *buf)
43845 {
43846 struct uio_device *idev = dev_get_drvdata(dev);
43847 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
43848 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
43849 }
43850
43851 static struct device_attribute uio_class_attributes[] = {
43852 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
43853 {
43854 struct uio_device *idev = info->uio_dev;
43855
43856 - atomic_inc(&idev->event);
43857 + atomic_inc_unchecked(&idev->event);
43858 wake_up_interruptible(&idev->wait);
43859 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
43860 }
43861 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
43862 }
43863
43864 listener->dev = idev;
43865 - listener->event_count = atomic_read(&idev->event);
43866 + listener->event_count = atomic_read_unchecked(&idev->event);
43867 filep->private_data = listener;
43868
43869 if (idev->info->open) {
43870 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
43871 return -EIO;
43872
43873 poll_wait(filep, &idev->wait, wait);
43874 - if (listener->event_count != atomic_read(&idev->event))
43875 + if (listener->event_count != atomic_read_unchecked(&idev->event))
43876 return POLLIN | POLLRDNORM;
43877 return 0;
43878 }
43879 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
43880 do {
43881 set_current_state(TASK_INTERRUPTIBLE);
43882
43883 - event_count = atomic_read(&idev->event);
43884 + event_count = atomic_read_unchecked(&idev->event);
43885 if (event_count != listener->event_count) {
43886 if (copy_to_user(buf, &event_count, count))
43887 retval = -EFAULT;
43888 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
43889 static void uio_vma_open(struct vm_area_struct *vma)
43890 {
43891 struct uio_device *idev = vma->vm_private_data;
43892 - idev->vma_count++;
43893 + local_inc(&idev->vma_count);
43894 }
43895
43896 static void uio_vma_close(struct vm_area_struct *vma)
43897 {
43898 struct uio_device *idev = vma->vm_private_data;
43899 - idev->vma_count--;
43900 + local_dec(&idev->vma_count);
43901 }
43902
43903 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43904 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
43905 idev->owner = owner;
43906 idev->info = info;
43907 init_waitqueue_head(&idev->wait);
43908 - atomic_set(&idev->event, 0);
43909 + atomic_set_unchecked(&idev->event, 0);
43910
43911 ret = uio_get_minor(idev);
43912 if (ret)
43913 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
43914 index b7eb86a..36d28af 100644
43915 --- a/drivers/usb/atm/cxacru.c
43916 +++ b/drivers/usb/atm/cxacru.c
43917 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
43918 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
43919 if (ret < 2)
43920 return -EINVAL;
43921 - if (index < 0 || index > 0x7f)
43922 + if (index > 0x7f)
43923 return -EINVAL;
43924 pos += tmp;
43925
43926 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
43927 index 35f10bf..6a38a0b 100644
43928 --- a/drivers/usb/atm/usbatm.c
43929 +++ b/drivers/usb/atm/usbatm.c
43930 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43931 if (printk_ratelimit())
43932 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
43933 __func__, vpi, vci);
43934 - atomic_inc(&vcc->stats->rx_err);
43935 + atomic_inc_unchecked(&vcc->stats->rx_err);
43936 return;
43937 }
43938
43939 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43940 if (length > ATM_MAX_AAL5_PDU) {
43941 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
43942 __func__, length, vcc);
43943 - atomic_inc(&vcc->stats->rx_err);
43944 + atomic_inc_unchecked(&vcc->stats->rx_err);
43945 goto out;
43946 }
43947
43948 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43949 if (sarb->len < pdu_length) {
43950 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
43951 __func__, pdu_length, sarb->len, vcc);
43952 - atomic_inc(&vcc->stats->rx_err);
43953 + atomic_inc_unchecked(&vcc->stats->rx_err);
43954 goto out;
43955 }
43956
43957 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
43958 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
43959 __func__, vcc);
43960 - atomic_inc(&vcc->stats->rx_err);
43961 + atomic_inc_unchecked(&vcc->stats->rx_err);
43962 goto out;
43963 }
43964
43965 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43966 if (printk_ratelimit())
43967 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
43968 __func__, length);
43969 - atomic_inc(&vcc->stats->rx_drop);
43970 + atomic_inc_unchecked(&vcc->stats->rx_drop);
43971 goto out;
43972 }
43973
43974 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43975
43976 vcc->push(vcc, skb);
43977
43978 - atomic_inc(&vcc->stats->rx);
43979 + atomic_inc_unchecked(&vcc->stats->rx);
43980 out:
43981 skb_trim(sarb, 0);
43982 }
43983 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
43984 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
43985
43986 usbatm_pop(vcc, skb);
43987 - atomic_inc(&vcc->stats->tx);
43988 + atomic_inc_unchecked(&vcc->stats->tx);
43989
43990 skb = skb_dequeue(&instance->sndqueue);
43991 }
43992 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
43993 if (!left--)
43994 return sprintf(page,
43995 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
43996 - atomic_read(&atm_dev->stats.aal5.tx),
43997 - atomic_read(&atm_dev->stats.aal5.tx_err),
43998 - atomic_read(&atm_dev->stats.aal5.rx),
43999 - atomic_read(&atm_dev->stats.aal5.rx_err),
44000 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44001 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44002 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44003 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44004 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44005 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44006
44007 if (!left--) {
44008 if (instance->disconnected)
44009 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44010 index cbacea9..246cccd 100644
44011 --- a/drivers/usb/core/devices.c
44012 +++ b/drivers/usb/core/devices.c
44013 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44014 * time it gets called.
44015 */
44016 static struct device_connect_event {
44017 - atomic_t count;
44018 + atomic_unchecked_t count;
44019 wait_queue_head_t wait;
44020 } device_event = {
44021 .count = ATOMIC_INIT(1),
44022 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44023
44024 void usbfs_conn_disc_event(void)
44025 {
44026 - atomic_add(2, &device_event.count);
44027 + atomic_add_unchecked(2, &device_event.count);
44028 wake_up(&device_event.wait);
44029 }
44030
44031 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
44032
44033 poll_wait(file, &device_event.wait, wait);
44034
44035 - event_count = atomic_read(&device_event.count);
44036 + event_count = atomic_read_unchecked(&device_event.count);
44037 if (file->f_version != event_count) {
44038 file->f_version = event_count;
44039 return POLLIN | POLLRDNORM;
44040 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44041 index 8e64adf..9a33a3c 100644
44042 --- a/drivers/usb/core/hcd.c
44043 +++ b/drivers/usb/core/hcd.c
44044 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44045 */
44046 usb_get_urb(urb);
44047 atomic_inc(&urb->use_count);
44048 - atomic_inc(&urb->dev->urbnum);
44049 + atomic_inc_unchecked(&urb->dev->urbnum);
44050 usbmon_urb_submit(&hcd->self, urb);
44051
44052 /* NOTE requirements on root-hub callers (usbfs and the hub
44053 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44054 urb->hcpriv = NULL;
44055 INIT_LIST_HEAD(&urb->urb_list);
44056 atomic_dec(&urb->use_count);
44057 - atomic_dec(&urb->dev->urbnum);
44058 + atomic_dec_unchecked(&urb->dev->urbnum);
44059 if (atomic_read(&urb->reject))
44060 wake_up(&usb_kill_urb_queue);
44061 usb_put_urb(urb);
44062 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44063 index 131f736..99004c3 100644
44064 --- a/drivers/usb/core/message.c
44065 +++ b/drivers/usb/core/message.c
44066 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44067 * method can wait for it to complete. Since you don't have a handle on the
44068 * URB used, you can't cancel the request.
44069 */
44070 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44071 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44072 __u8 requesttype, __u16 value, __u16 index, void *data,
44073 __u16 size, int timeout)
44074 {
44075 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44076 index 818e4a0..0fc9589 100644
44077 --- a/drivers/usb/core/sysfs.c
44078 +++ b/drivers/usb/core/sysfs.c
44079 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44080 struct usb_device *udev;
44081
44082 udev = to_usb_device(dev);
44083 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44084 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44085 }
44086 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44087
44088 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44089 index f81b925..78d22ec 100644
44090 --- a/drivers/usb/core/usb.c
44091 +++ b/drivers/usb/core/usb.c
44092 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44093 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44094 dev->state = USB_STATE_ATTACHED;
44095 dev->lpm_disable_count = 1;
44096 - atomic_set(&dev->urbnum, 0);
44097 + atomic_set_unchecked(&dev->urbnum, 0);
44098
44099 INIT_LIST_HEAD(&dev->ep0.urb_list);
44100 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44101 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44102 index 5e29dde..eca992f 100644
44103 --- a/drivers/usb/early/ehci-dbgp.c
44104 +++ b/drivers/usb/early/ehci-dbgp.c
44105 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44106
44107 #ifdef CONFIG_KGDB
44108 static struct kgdb_io kgdbdbgp_io_ops;
44109 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44110 +static struct kgdb_io kgdbdbgp_io_ops_console;
44111 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44112 #else
44113 #define dbgp_kgdb_mode (0)
44114 #endif
44115 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44116 .write_char = kgdbdbgp_write_char,
44117 };
44118
44119 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44120 + .name = "kgdbdbgp",
44121 + .read_char = kgdbdbgp_read_char,
44122 + .write_char = kgdbdbgp_write_char,
44123 + .is_console = 1
44124 +};
44125 +
44126 static int kgdbdbgp_wait_time;
44127
44128 static int __init kgdbdbgp_parse_config(char *str)
44129 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44130 ptr++;
44131 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44132 }
44133 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44134 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44135 + if (early_dbgp_console.index != -1)
44136 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44137 + else
44138 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44139
44140 return 0;
44141 }
44142 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44143 index 598dcc1..032dd4f 100644
44144 --- a/drivers/usb/gadget/u_serial.c
44145 +++ b/drivers/usb/gadget/u_serial.c
44146 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44147 spin_lock_irq(&port->port_lock);
44148
44149 /* already open? Great. */
44150 - if (port->port.count) {
44151 + if (atomic_read(&port->port.count)) {
44152 status = 0;
44153 - port->port.count++;
44154 + atomic_inc(&port->port.count);
44155
44156 /* currently opening/closing? wait ... */
44157 } else if (port->openclose) {
44158 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44159 tty->driver_data = port;
44160 port->port.tty = tty;
44161
44162 - port->port.count = 1;
44163 + atomic_set(&port->port.count, 1);
44164 port->openclose = false;
44165
44166 /* if connected, start the I/O stream */
44167 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44168
44169 spin_lock_irq(&port->port_lock);
44170
44171 - if (port->port.count != 1) {
44172 - if (port->port.count == 0)
44173 + if (atomic_read(&port->port.count) != 1) {
44174 + if (atomic_read(&port->port.count) == 0)
44175 WARN_ON(1);
44176 else
44177 - --port->port.count;
44178 + atomic_dec(&port->port.count);
44179 goto exit;
44180 }
44181
44182 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44183 * and sleep if necessary
44184 */
44185 port->openclose = true;
44186 - port->port.count = 0;
44187 + atomic_set(&port->port.count, 0);
44188
44189 gser = port->port_usb;
44190 if (gser && gser->disconnect)
44191 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
44192 int cond;
44193
44194 spin_lock_irq(&port->port_lock);
44195 - cond = (port->port.count == 0) && !port->openclose;
44196 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44197 spin_unlock_irq(&port->port_lock);
44198 return cond;
44199 }
44200 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44201 /* if it's already open, start I/O ... and notify the serial
44202 * protocol about open/close status (connect/disconnect).
44203 */
44204 - if (port->port.count) {
44205 + if (atomic_read(&port->port.count)) {
44206 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44207 gs_start_io(port);
44208 if (gser->connect)
44209 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
44210
44211 port->port_usb = NULL;
44212 gser->ioport = NULL;
44213 - if (port->port.count > 0 || port->openclose) {
44214 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44215 wake_up_interruptible(&port->drain_wait);
44216 if (port->port.tty)
44217 tty_hangup(port->port.tty);
44218 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
44219
44220 /* finally, free any unused/unusable I/O buffers */
44221 spin_lock_irqsave(&port->port_lock, flags);
44222 - if (port->port.count == 0 && !port->openclose)
44223 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44224 gs_buf_free(&port->port_write_buf);
44225 gs_free_requests(gser->out, &port->read_pool, NULL);
44226 gs_free_requests(gser->out, &port->read_queue, NULL);
44227 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44228 index 5f3bcd3..bfca43f 100644
44229 --- a/drivers/usb/serial/console.c
44230 +++ b/drivers/usb/serial/console.c
44231 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44232
44233 info->port = port;
44234
44235 - ++port->port.count;
44236 + atomic_inc(&port->port.count);
44237 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44238 if (serial->type->set_termios) {
44239 /*
44240 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44241 }
44242 /* Now that any required fake tty operations are completed restore
44243 * the tty port count */
44244 - --port->port.count;
44245 + atomic_dec(&port->port.count);
44246 /* The console is special in terms of closing the device so
44247 * indicate this port is now acting as a system console. */
44248 port->port.console = 1;
44249 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44250 free_tty:
44251 kfree(tty);
44252 reset_open_count:
44253 - port->port.count = 0;
44254 + atomic_set(&port->port.count, 0);
44255 usb_autopm_put_interface(serial->interface);
44256 error_get_interface:
44257 usb_serial_put(serial);
44258 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44259 index 6c3586a..a94e621 100644
44260 --- a/drivers/usb/storage/realtek_cr.c
44261 +++ b/drivers/usb/storage/realtek_cr.c
44262 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44263
44264 buf = kmalloc(len, GFP_NOIO);
44265 if (buf == NULL)
44266 - return USB_STOR_TRANSPORT_ERROR;
44267 + return -ENOMEM;
44268
44269 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44270
44271 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44272 index 75f70f0..d467e1a 100644
44273 --- a/drivers/usb/storage/usb.h
44274 +++ b/drivers/usb/storage/usb.h
44275 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44276 __u8 useProtocol;
44277 __u8 useTransport;
44278 int (*initFunction)(struct us_data *);
44279 -};
44280 +} __do_const;
44281
44282
44283 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44284 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44285 index d6bea3e..60b250e 100644
44286 --- a/drivers/usb/wusbcore/wa-hc.h
44287 +++ b/drivers/usb/wusbcore/wa-hc.h
44288 @@ -192,7 +192,7 @@ struct wahc {
44289 struct list_head xfer_delayed_list;
44290 spinlock_t xfer_list_lock;
44291 struct work_struct xfer_work;
44292 - atomic_t xfer_id_count;
44293 + atomic_unchecked_t xfer_id_count;
44294 };
44295
44296
44297 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44298 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44299 spin_lock_init(&wa->xfer_list_lock);
44300 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44301 - atomic_set(&wa->xfer_id_count, 1);
44302 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44303 }
44304
44305 /**
44306 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44307 index 57c01ab..8a05959 100644
44308 --- a/drivers/usb/wusbcore/wa-xfer.c
44309 +++ b/drivers/usb/wusbcore/wa-xfer.c
44310 @@ -296,7 +296,7 @@ out:
44311 */
44312 static void wa_xfer_id_init(struct wa_xfer *xfer)
44313 {
44314 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44315 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44316 }
44317
44318 /*
44319 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44320 index 8c55011..eed4ae1a 100644
44321 --- a/drivers/video/aty/aty128fb.c
44322 +++ b/drivers/video/aty/aty128fb.c
44323 @@ -149,7 +149,7 @@ enum {
44324 };
44325
44326 /* Must match above enum */
44327 -static char * const r128_family[] = {
44328 +static const char * const r128_family[] = {
44329 "AGP",
44330 "PCI",
44331 "PRO AGP",
44332 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44333 index 4f27fdc..d3537e6 100644
44334 --- a/drivers/video/aty/atyfb_base.c
44335 +++ b/drivers/video/aty/atyfb_base.c
44336 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44337 par->accel_flags = var->accel_flags; /* hack */
44338
44339 if (var->accel_flags) {
44340 - info->fbops->fb_sync = atyfb_sync;
44341 + pax_open_kernel();
44342 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44343 + pax_close_kernel();
44344 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44345 } else {
44346 - info->fbops->fb_sync = NULL;
44347 + pax_open_kernel();
44348 + *(void **)&info->fbops->fb_sync = NULL;
44349 + pax_close_kernel();
44350 info->flags |= FBINFO_HWACCEL_DISABLED;
44351 }
44352
44353 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44354 index 95ec042..e6affdd 100644
44355 --- a/drivers/video/aty/mach64_cursor.c
44356 +++ b/drivers/video/aty/mach64_cursor.c
44357 @@ -7,6 +7,7 @@
44358 #include <linux/string.h>
44359
44360 #include <asm/io.h>
44361 +#include <asm/pgtable.h>
44362
44363 #ifdef __sparc__
44364 #include <asm/fbio.h>
44365 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44366 info->sprite.buf_align = 16; /* and 64 lines tall. */
44367 info->sprite.flags = FB_PIXMAP_IO;
44368
44369 - info->fbops->fb_cursor = atyfb_cursor;
44370 + pax_open_kernel();
44371 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44372 + pax_close_kernel();
44373
44374 return 0;
44375 }
44376 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44377 index 6c5ed6b..b727c88 100644
44378 --- a/drivers/video/backlight/kb3886_bl.c
44379 +++ b/drivers/video/backlight/kb3886_bl.c
44380 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44381 static unsigned long kb3886bl_flags;
44382 #define KB3886BL_SUSPENDED 0x01
44383
44384 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44385 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44386 {
44387 .ident = "Sahara Touch-iT",
44388 .matches = {
44389 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44390 index 88cad6b..dd746c7 100644
44391 --- a/drivers/video/fb_defio.c
44392 +++ b/drivers/video/fb_defio.c
44393 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44394
44395 BUG_ON(!fbdefio);
44396 mutex_init(&fbdefio->lock);
44397 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44398 + pax_open_kernel();
44399 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44400 + pax_close_kernel();
44401 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44402 INIT_LIST_HEAD(&fbdefio->pagelist);
44403 if (fbdefio->delay == 0) /* set a default of 1 s */
44404 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44405 page->mapping = NULL;
44406 }
44407
44408 - info->fbops->fb_mmap = NULL;
44409 + *(void **)&info->fbops->fb_mmap = NULL;
44410 mutex_destroy(&fbdefio->lock);
44411 }
44412 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44413 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44414 index 5c3960d..15cf8fc 100644
44415 --- a/drivers/video/fbcmap.c
44416 +++ b/drivers/video/fbcmap.c
44417 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44418 rc = -ENODEV;
44419 goto out;
44420 }
44421 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44422 - !info->fbops->fb_setcmap)) {
44423 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44424 rc = -EINVAL;
44425 goto out1;
44426 }
44427 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44428 index dc61c12..e29796e 100644
44429 --- a/drivers/video/fbmem.c
44430 +++ b/drivers/video/fbmem.c
44431 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44432 image->dx += image->width + 8;
44433 }
44434 } else if (rotate == FB_ROTATE_UD) {
44435 - for (x = 0; x < num && image->dx >= 0; x++) {
44436 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44437 info->fbops->fb_imageblit(info, image);
44438 image->dx -= image->width + 8;
44439 }
44440 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44441 image->dy += image->height + 8;
44442 }
44443 } else if (rotate == FB_ROTATE_CCW) {
44444 - for (x = 0; x < num && image->dy >= 0; x++) {
44445 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44446 info->fbops->fb_imageblit(info, image);
44447 image->dy -= image->height + 8;
44448 }
44449 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44450 return -EFAULT;
44451 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44452 return -EINVAL;
44453 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44454 + if (con2fb.framebuffer >= FB_MAX)
44455 return -EINVAL;
44456 if (!registered_fb[con2fb.framebuffer])
44457 request_module("fb%d", con2fb.framebuffer);
44458 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44459 index 7672d2e..b56437f 100644
44460 --- a/drivers/video/i810/i810_accel.c
44461 +++ b/drivers/video/i810/i810_accel.c
44462 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
44463 }
44464 }
44465 printk("ringbuffer lockup!!!\n");
44466 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
44467 i810_report_error(mmio);
44468 par->dev_flags |= LOCKUP;
44469 info->pixmap.scan_align = 1;
44470 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
44471 index 3c14e43..eafa544 100644
44472 --- a/drivers/video/logo/logo_linux_clut224.ppm
44473 +++ b/drivers/video/logo/logo_linux_clut224.ppm
44474 @@ -1,1604 +1,1123 @@
44475 P3
44476 -# Standard 224-color Linux logo
44477 80 80
44478 255
44479 - 0 0 0 0 0 0 0 0 0 0 0 0
44480 - 0 0 0 0 0 0 0 0 0 0 0 0
44481 - 0 0 0 0 0 0 0 0 0 0 0 0
44482 - 0 0 0 0 0 0 0 0 0 0 0 0
44483 - 0 0 0 0 0 0 0 0 0 0 0 0
44484 - 0 0 0 0 0 0 0 0 0 0 0 0
44485 - 0 0 0 0 0 0 0 0 0 0 0 0
44486 - 0 0 0 0 0 0 0 0 0 0 0 0
44487 - 0 0 0 0 0 0 0 0 0 0 0 0
44488 - 6 6 6 6 6 6 10 10 10 10 10 10
44489 - 10 10 10 6 6 6 6 6 6 6 6 6
44490 - 0 0 0 0 0 0 0 0 0 0 0 0
44491 - 0 0 0 0 0 0 0 0 0 0 0 0
44492 - 0 0 0 0 0 0 0 0 0 0 0 0
44493 - 0 0 0 0 0 0 0 0 0 0 0 0
44494 - 0 0 0 0 0 0 0 0 0 0 0 0
44495 - 0 0 0 0 0 0 0 0 0 0 0 0
44496 - 0 0 0 0 0 0 0 0 0 0 0 0
44497 - 0 0 0 0 0 0 0 0 0 0 0 0
44498 - 0 0 0 0 0 0 0 0 0 0 0 0
44499 - 0 0 0 0 0 0 0 0 0 0 0 0
44500 - 0 0 0 0 0 0 0 0 0 0 0 0
44501 - 0 0 0 0 0 0 0 0 0 0 0 0
44502 - 0 0 0 0 0 0 0 0 0 0 0 0
44503 - 0 0 0 0 0 0 0 0 0 0 0 0
44504 - 0 0 0 0 0 0 0 0 0 0 0 0
44505 - 0 0 0 0 0 0 0 0 0 0 0 0
44506 - 0 0 0 0 0 0 0 0 0 0 0 0
44507 - 0 0 0 6 6 6 10 10 10 14 14 14
44508 - 22 22 22 26 26 26 30 30 30 34 34 34
44509 - 30 30 30 30 30 30 26 26 26 18 18 18
44510 - 14 14 14 10 10 10 6 6 6 0 0 0
44511 - 0 0 0 0 0 0 0 0 0 0 0 0
44512 - 0 0 0 0 0 0 0 0 0 0 0 0
44513 - 0 0 0 0 0 0 0 0 0 0 0 0
44514 - 0 0 0 0 0 0 0 0 0 0 0 0
44515 - 0 0 0 0 0 0 0 0 0 0 0 0
44516 - 0 0 0 0 0 0 0 0 0 0 0 0
44517 - 0 0 0 0 0 0 0 0 0 0 0 0
44518 - 0 0 0 0 0 0 0 0 0 0 0 0
44519 - 0 0 0 0 0 0 0 0 0 0 0 0
44520 - 0 0 0 0 0 1 0 0 1 0 0 0
44521 - 0 0 0 0 0 0 0 0 0 0 0 0
44522 - 0 0 0 0 0 0 0 0 0 0 0 0
44523 - 0 0 0 0 0 0 0 0 0 0 0 0
44524 - 0 0 0 0 0 0 0 0 0 0 0 0
44525 - 0 0 0 0 0 0 0 0 0 0 0 0
44526 - 0 0 0 0 0 0 0 0 0 0 0 0
44527 - 6 6 6 14 14 14 26 26 26 42 42 42
44528 - 54 54 54 66 66 66 78 78 78 78 78 78
44529 - 78 78 78 74 74 74 66 66 66 54 54 54
44530 - 42 42 42 26 26 26 18 18 18 10 10 10
44531 - 6 6 6 0 0 0 0 0 0 0 0 0
44532 - 0 0 0 0 0 0 0 0 0 0 0 0
44533 - 0 0 0 0 0 0 0 0 0 0 0 0
44534 - 0 0 0 0 0 0 0 0 0 0 0 0
44535 - 0 0 0 0 0 0 0 0 0 0 0 0
44536 - 0 0 0 0 0 0 0 0 0 0 0 0
44537 - 0 0 0 0 0 0 0 0 0 0 0 0
44538 - 0 0 0 0 0 0 0 0 0 0 0 0
44539 - 0 0 0 0 0 0 0 0 0 0 0 0
44540 - 0 0 1 0 0 0 0 0 0 0 0 0
44541 - 0 0 0 0 0 0 0 0 0 0 0 0
44542 - 0 0 0 0 0 0 0 0 0 0 0 0
44543 - 0 0 0 0 0 0 0 0 0 0 0 0
44544 - 0 0 0 0 0 0 0 0 0 0 0 0
44545 - 0 0 0 0 0 0 0 0 0 0 0 0
44546 - 0 0 0 0 0 0 0 0 0 10 10 10
44547 - 22 22 22 42 42 42 66 66 66 86 86 86
44548 - 66 66 66 38 38 38 38 38 38 22 22 22
44549 - 26 26 26 34 34 34 54 54 54 66 66 66
44550 - 86 86 86 70 70 70 46 46 46 26 26 26
44551 - 14 14 14 6 6 6 0 0 0 0 0 0
44552 - 0 0 0 0 0 0 0 0 0 0 0 0
44553 - 0 0 0 0 0 0 0 0 0 0 0 0
44554 - 0 0 0 0 0 0 0 0 0 0 0 0
44555 - 0 0 0 0 0 0 0 0 0 0 0 0
44556 - 0 0 0 0 0 0 0 0 0 0 0 0
44557 - 0 0 0 0 0 0 0 0 0 0 0 0
44558 - 0 0 0 0 0 0 0 0 0 0 0 0
44559 - 0 0 0 0 0 0 0 0 0 0 0 0
44560 - 0 0 1 0 0 1 0 0 1 0 0 0
44561 - 0 0 0 0 0 0 0 0 0 0 0 0
44562 - 0 0 0 0 0 0 0 0 0 0 0 0
44563 - 0 0 0 0 0 0 0 0 0 0 0 0
44564 - 0 0 0 0 0 0 0 0 0 0 0 0
44565 - 0 0 0 0 0 0 0 0 0 0 0 0
44566 - 0 0 0 0 0 0 10 10 10 26 26 26
44567 - 50 50 50 82 82 82 58 58 58 6 6 6
44568 - 2 2 6 2 2 6 2 2 6 2 2 6
44569 - 2 2 6 2 2 6 2 2 6 2 2 6
44570 - 6 6 6 54 54 54 86 86 86 66 66 66
44571 - 38 38 38 18 18 18 6 6 6 0 0 0
44572 - 0 0 0 0 0 0 0 0 0 0 0 0
44573 - 0 0 0 0 0 0 0 0 0 0 0 0
44574 - 0 0 0 0 0 0 0 0 0 0 0 0
44575 - 0 0 0 0 0 0 0 0 0 0 0 0
44576 - 0 0 0 0 0 0 0 0 0 0 0 0
44577 - 0 0 0 0 0 0 0 0 0 0 0 0
44578 - 0 0 0 0 0 0 0 0 0 0 0 0
44579 - 0 0 0 0 0 0 0 0 0 0 0 0
44580 - 0 0 0 0 0 0 0 0 0 0 0 0
44581 - 0 0 0 0 0 0 0 0 0 0 0 0
44582 - 0 0 0 0 0 0 0 0 0 0 0 0
44583 - 0 0 0 0 0 0 0 0 0 0 0 0
44584 - 0 0 0 0 0 0 0 0 0 0 0 0
44585 - 0 0 0 0 0 0 0 0 0 0 0 0
44586 - 0 0 0 6 6 6 22 22 22 50 50 50
44587 - 78 78 78 34 34 34 2 2 6 2 2 6
44588 - 2 2 6 2 2 6 2 2 6 2 2 6
44589 - 2 2 6 2 2 6 2 2 6 2 2 6
44590 - 2 2 6 2 2 6 6 6 6 70 70 70
44591 - 78 78 78 46 46 46 22 22 22 6 6 6
44592 - 0 0 0 0 0 0 0 0 0 0 0 0
44593 - 0 0 0 0 0 0 0 0 0 0 0 0
44594 - 0 0 0 0 0 0 0 0 0 0 0 0
44595 - 0 0 0 0 0 0 0 0 0 0 0 0
44596 - 0 0 0 0 0 0 0 0 0 0 0 0
44597 - 0 0 0 0 0 0 0 0 0 0 0 0
44598 - 0 0 0 0 0 0 0 0 0 0 0 0
44599 - 0 0 0 0 0 0 0 0 0 0 0 0
44600 - 0 0 1 0 0 1 0 0 1 0 0 0
44601 - 0 0 0 0 0 0 0 0 0 0 0 0
44602 - 0 0 0 0 0 0 0 0 0 0 0 0
44603 - 0 0 0 0 0 0 0 0 0 0 0 0
44604 - 0 0 0 0 0 0 0 0 0 0 0 0
44605 - 0 0 0 0 0 0 0 0 0 0 0 0
44606 - 6 6 6 18 18 18 42 42 42 82 82 82
44607 - 26 26 26 2 2 6 2 2 6 2 2 6
44608 - 2 2 6 2 2 6 2 2 6 2 2 6
44609 - 2 2 6 2 2 6 2 2 6 14 14 14
44610 - 46 46 46 34 34 34 6 6 6 2 2 6
44611 - 42 42 42 78 78 78 42 42 42 18 18 18
44612 - 6 6 6 0 0 0 0 0 0 0 0 0
44613 - 0 0 0 0 0 0 0 0 0 0 0 0
44614 - 0 0 0 0 0 0 0 0 0 0 0 0
44615 - 0 0 0 0 0 0 0 0 0 0 0 0
44616 - 0 0 0 0 0 0 0 0 0 0 0 0
44617 - 0 0 0 0 0 0 0 0 0 0 0 0
44618 - 0 0 0 0 0 0 0 0 0 0 0 0
44619 - 0 0 0 0 0 0 0 0 0 0 0 0
44620 - 0 0 1 0 0 0 0 0 1 0 0 0
44621 - 0 0 0 0 0 0 0 0 0 0 0 0
44622 - 0 0 0 0 0 0 0 0 0 0 0 0
44623 - 0 0 0 0 0 0 0 0 0 0 0 0
44624 - 0 0 0 0 0 0 0 0 0 0 0 0
44625 - 0 0 0 0 0 0 0 0 0 0 0 0
44626 - 10 10 10 30 30 30 66 66 66 58 58 58
44627 - 2 2 6 2 2 6 2 2 6 2 2 6
44628 - 2 2 6 2 2 6 2 2 6 2 2 6
44629 - 2 2 6 2 2 6 2 2 6 26 26 26
44630 - 86 86 86 101 101 101 46 46 46 10 10 10
44631 - 2 2 6 58 58 58 70 70 70 34 34 34
44632 - 10 10 10 0 0 0 0 0 0 0 0 0
44633 - 0 0 0 0 0 0 0 0 0 0 0 0
44634 - 0 0 0 0 0 0 0 0 0 0 0 0
44635 - 0 0 0 0 0 0 0 0 0 0 0 0
44636 - 0 0 0 0 0 0 0 0 0 0 0 0
44637 - 0 0 0 0 0 0 0 0 0 0 0 0
44638 - 0 0 0 0 0 0 0 0 0 0 0 0
44639 - 0 0 0 0 0 0 0 0 0 0 0 0
44640 - 0 0 1 0 0 1 0 0 1 0 0 0
44641 - 0 0 0 0 0 0 0 0 0 0 0 0
44642 - 0 0 0 0 0 0 0 0 0 0 0 0
44643 - 0 0 0 0 0 0 0 0 0 0 0 0
44644 - 0 0 0 0 0 0 0 0 0 0 0 0
44645 - 0 0 0 0 0 0 0 0 0 0 0 0
44646 - 14 14 14 42 42 42 86 86 86 10 10 10
44647 - 2 2 6 2 2 6 2 2 6 2 2 6
44648 - 2 2 6 2 2 6 2 2 6 2 2 6
44649 - 2 2 6 2 2 6 2 2 6 30 30 30
44650 - 94 94 94 94 94 94 58 58 58 26 26 26
44651 - 2 2 6 6 6 6 78 78 78 54 54 54
44652 - 22 22 22 6 6 6 0 0 0 0 0 0
44653 - 0 0 0 0 0 0 0 0 0 0 0 0
44654 - 0 0 0 0 0 0 0 0 0 0 0 0
44655 - 0 0 0 0 0 0 0 0 0 0 0 0
44656 - 0 0 0 0 0 0 0 0 0 0 0 0
44657 - 0 0 0 0 0 0 0 0 0 0 0 0
44658 - 0 0 0 0 0 0 0 0 0 0 0 0
44659 - 0 0 0 0 0 0 0 0 0 0 0 0
44660 - 0 0 0 0 0 0 0 0 0 0 0 0
44661 - 0 0 0 0 0 0 0 0 0 0 0 0
44662 - 0 0 0 0 0 0 0 0 0 0 0 0
44663 - 0 0 0 0 0 0 0 0 0 0 0 0
44664 - 0 0 0 0 0 0 0 0 0 0 0 0
44665 - 0 0 0 0 0 0 0 0 0 6 6 6
44666 - 22 22 22 62 62 62 62 62 62 2 2 6
44667 - 2 2 6 2 2 6 2 2 6 2 2 6
44668 - 2 2 6 2 2 6 2 2 6 2 2 6
44669 - 2 2 6 2 2 6 2 2 6 26 26 26
44670 - 54 54 54 38 38 38 18 18 18 10 10 10
44671 - 2 2 6 2 2 6 34 34 34 82 82 82
44672 - 38 38 38 14 14 14 0 0 0 0 0 0
44673 - 0 0 0 0 0 0 0 0 0 0 0 0
44674 - 0 0 0 0 0 0 0 0 0 0 0 0
44675 - 0 0 0 0 0 0 0 0 0 0 0 0
44676 - 0 0 0 0 0 0 0 0 0 0 0 0
44677 - 0 0 0 0 0 0 0 0 0 0 0 0
44678 - 0 0 0 0 0 0 0 0 0 0 0 0
44679 - 0 0 0 0 0 0 0 0 0 0 0 0
44680 - 0 0 0 0 0 1 0 0 1 0 0 0
44681 - 0 0 0 0 0 0 0 0 0 0 0 0
44682 - 0 0 0 0 0 0 0 0 0 0 0 0
44683 - 0 0 0 0 0 0 0 0 0 0 0 0
44684 - 0 0 0 0 0 0 0 0 0 0 0 0
44685 - 0 0 0 0 0 0 0 0 0 6 6 6
44686 - 30 30 30 78 78 78 30 30 30 2 2 6
44687 - 2 2 6 2 2 6 2 2 6 2 2 6
44688 - 2 2 6 2 2 6 2 2 6 2 2 6
44689 - 2 2 6 2 2 6 2 2 6 10 10 10
44690 - 10 10 10 2 2 6 2 2 6 2 2 6
44691 - 2 2 6 2 2 6 2 2 6 78 78 78
44692 - 50 50 50 18 18 18 6 6 6 0 0 0
44693 - 0 0 0 0 0 0 0 0 0 0 0 0
44694 - 0 0 0 0 0 0 0 0 0 0 0 0
44695 - 0 0 0 0 0 0 0 0 0 0 0 0
44696 - 0 0 0 0 0 0 0 0 0 0 0 0
44697 - 0 0 0 0 0 0 0 0 0 0 0 0
44698 - 0 0 0 0 0 0 0 0 0 0 0 0
44699 - 0 0 0 0 0 0 0 0 0 0 0 0
44700 - 0 0 1 0 0 0 0 0 0 0 0 0
44701 - 0 0 0 0 0 0 0 0 0 0 0 0
44702 - 0 0 0 0 0 0 0 0 0 0 0 0
44703 - 0 0 0 0 0 0 0 0 0 0 0 0
44704 - 0 0 0 0 0 0 0 0 0 0 0 0
44705 - 0 0 0 0 0 0 0 0 0 10 10 10
44706 - 38 38 38 86 86 86 14 14 14 2 2 6
44707 - 2 2 6 2 2 6 2 2 6 2 2 6
44708 - 2 2 6 2 2 6 2 2 6 2 2 6
44709 - 2 2 6 2 2 6 2 2 6 2 2 6
44710 - 2 2 6 2 2 6 2 2 6 2 2 6
44711 - 2 2 6 2 2 6 2 2 6 54 54 54
44712 - 66 66 66 26 26 26 6 6 6 0 0 0
44713 - 0 0 0 0 0 0 0 0 0 0 0 0
44714 - 0 0 0 0 0 0 0 0 0 0 0 0
44715 - 0 0 0 0 0 0 0 0 0 0 0 0
44716 - 0 0 0 0 0 0 0 0 0 0 0 0
44717 - 0 0 0 0 0 0 0 0 0 0 0 0
44718 - 0 0 0 0 0 0 0 0 0 0 0 0
44719 - 0 0 0 0 0 0 0 0 0 0 0 0
44720 - 0 0 0 0 0 1 0 0 1 0 0 0
44721 - 0 0 0 0 0 0 0 0 0 0 0 0
44722 - 0 0 0 0 0 0 0 0 0 0 0 0
44723 - 0 0 0 0 0 0 0 0 0 0 0 0
44724 - 0 0 0 0 0 0 0 0 0 0 0 0
44725 - 0 0 0 0 0 0 0 0 0 14 14 14
44726 - 42 42 42 82 82 82 2 2 6 2 2 6
44727 - 2 2 6 6 6 6 10 10 10 2 2 6
44728 - 2 2 6 2 2 6 2 2 6 2 2 6
44729 - 2 2 6 2 2 6 2 2 6 6 6 6
44730 - 14 14 14 10 10 10 2 2 6 2 2 6
44731 - 2 2 6 2 2 6 2 2 6 18 18 18
44732 - 82 82 82 34 34 34 10 10 10 0 0 0
44733 - 0 0 0 0 0 0 0 0 0 0 0 0
44734 - 0 0 0 0 0 0 0 0 0 0 0 0
44735 - 0 0 0 0 0 0 0 0 0 0 0 0
44736 - 0 0 0 0 0 0 0 0 0 0 0 0
44737 - 0 0 0 0 0 0 0 0 0 0 0 0
44738 - 0 0 0 0 0 0 0 0 0 0 0 0
44739 - 0 0 0 0 0 0 0 0 0 0 0 0
44740 - 0 0 1 0 0 0 0 0 0 0 0 0
44741 - 0 0 0 0 0 0 0 0 0 0 0 0
44742 - 0 0 0 0 0 0 0 0 0 0 0 0
44743 - 0 0 0 0 0 0 0 0 0 0 0 0
44744 - 0 0 0 0 0 0 0 0 0 0 0 0
44745 - 0 0 0 0 0 0 0 0 0 14 14 14
44746 - 46 46 46 86 86 86 2 2 6 2 2 6
44747 - 6 6 6 6 6 6 22 22 22 34 34 34
44748 - 6 6 6 2 2 6 2 2 6 2 2 6
44749 - 2 2 6 2 2 6 18 18 18 34 34 34
44750 - 10 10 10 50 50 50 22 22 22 2 2 6
44751 - 2 2 6 2 2 6 2 2 6 10 10 10
44752 - 86 86 86 42 42 42 14 14 14 0 0 0
44753 - 0 0 0 0 0 0 0 0 0 0 0 0
44754 - 0 0 0 0 0 0 0 0 0 0 0 0
44755 - 0 0 0 0 0 0 0 0 0 0 0 0
44756 - 0 0 0 0 0 0 0 0 0 0 0 0
44757 - 0 0 0 0 0 0 0 0 0 0 0 0
44758 - 0 0 0 0 0 0 0 0 0 0 0 0
44759 - 0 0 0 0 0 0 0 0 0 0 0 0
44760 - 0 0 1 0 0 1 0 0 1 0 0 0
44761 - 0 0 0 0 0 0 0 0 0 0 0 0
44762 - 0 0 0 0 0 0 0 0 0 0 0 0
44763 - 0 0 0 0 0 0 0 0 0 0 0 0
44764 - 0 0 0 0 0 0 0 0 0 0 0 0
44765 - 0 0 0 0 0 0 0 0 0 14 14 14
44766 - 46 46 46 86 86 86 2 2 6 2 2 6
44767 - 38 38 38 116 116 116 94 94 94 22 22 22
44768 - 22 22 22 2 2 6 2 2 6 2 2 6
44769 - 14 14 14 86 86 86 138 138 138 162 162 162
44770 -154 154 154 38 38 38 26 26 26 6 6 6
44771 - 2 2 6 2 2 6 2 2 6 2 2 6
44772 - 86 86 86 46 46 46 14 14 14 0 0 0
44773 - 0 0 0 0 0 0 0 0 0 0 0 0
44774 - 0 0 0 0 0 0 0 0 0 0 0 0
44775 - 0 0 0 0 0 0 0 0 0 0 0 0
44776 - 0 0 0 0 0 0 0 0 0 0 0 0
44777 - 0 0 0 0 0 0 0 0 0 0 0 0
44778 - 0 0 0 0 0 0 0 0 0 0 0 0
44779 - 0 0 0 0 0 0 0 0 0 0 0 0
44780 - 0 0 0 0 0 0 0 0 0 0 0 0
44781 - 0 0 0 0 0 0 0 0 0 0 0 0
44782 - 0 0 0 0 0 0 0 0 0 0 0 0
44783 - 0 0 0 0 0 0 0 0 0 0 0 0
44784 - 0 0 0 0 0 0 0 0 0 0 0 0
44785 - 0 0 0 0 0 0 0 0 0 14 14 14
44786 - 46 46 46 86 86 86 2 2 6 14 14 14
44787 -134 134 134 198 198 198 195 195 195 116 116 116
44788 - 10 10 10 2 2 6 2 2 6 6 6 6
44789 -101 98 89 187 187 187 210 210 210 218 218 218
44790 -214 214 214 134 134 134 14 14 14 6 6 6
44791 - 2 2 6 2 2 6 2 2 6 2 2 6
44792 - 86 86 86 50 50 50 18 18 18 6 6 6
44793 - 0 0 0 0 0 0 0 0 0 0 0 0
44794 - 0 0 0 0 0 0 0 0 0 0 0 0
44795 - 0 0 0 0 0 0 0 0 0 0 0 0
44796 - 0 0 0 0 0 0 0 0 0 0 0 0
44797 - 0 0 0 0 0 0 0 0 0 0 0 0
44798 - 0 0 0 0 0 0 0 0 0 0 0 0
44799 - 0 0 0 0 0 0 0 0 1 0 0 0
44800 - 0 0 1 0 0 1 0 0 1 0 0 0
44801 - 0 0 0 0 0 0 0 0 0 0 0 0
44802 - 0 0 0 0 0 0 0 0 0 0 0 0
44803 - 0 0 0 0 0 0 0 0 0 0 0 0
44804 - 0 0 0 0 0 0 0 0 0 0 0 0
44805 - 0 0 0 0 0 0 0 0 0 14 14 14
44806 - 46 46 46 86 86 86 2 2 6 54 54 54
44807 -218 218 218 195 195 195 226 226 226 246 246 246
44808 - 58 58 58 2 2 6 2 2 6 30 30 30
44809 -210 210 210 253 253 253 174 174 174 123 123 123
44810 -221 221 221 234 234 234 74 74 74 2 2 6
44811 - 2 2 6 2 2 6 2 2 6 2 2 6
44812 - 70 70 70 58 58 58 22 22 22 6 6 6
44813 - 0 0 0 0 0 0 0 0 0 0 0 0
44814 - 0 0 0 0 0 0 0 0 0 0 0 0
44815 - 0 0 0 0 0 0 0 0 0 0 0 0
44816 - 0 0 0 0 0 0 0 0 0 0 0 0
44817 - 0 0 0 0 0 0 0 0 0 0 0 0
44818 - 0 0 0 0 0 0 0 0 0 0 0 0
44819 - 0 0 0 0 0 0 0 0 0 0 0 0
44820 - 0 0 0 0 0 0 0 0 0 0 0 0
44821 - 0 0 0 0 0 0 0 0 0 0 0 0
44822 - 0 0 0 0 0 0 0 0 0 0 0 0
44823 - 0 0 0 0 0 0 0 0 0 0 0 0
44824 - 0 0 0 0 0 0 0 0 0 0 0 0
44825 - 0 0 0 0 0 0 0 0 0 14 14 14
44826 - 46 46 46 82 82 82 2 2 6 106 106 106
44827 -170 170 170 26 26 26 86 86 86 226 226 226
44828 -123 123 123 10 10 10 14 14 14 46 46 46
44829 -231 231 231 190 190 190 6 6 6 70 70 70
44830 - 90 90 90 238 238 238 158 158 158 2 2 6
44831 - 2 2 6 2 2 6 2 2 6 2 2 6
44832 - 70 70 70 58 58 58 22 22 22 6 6 6
44833 - 0 0 0 0 0 0 0 0 0 0 0 0
44834 - 0 0 0 0 0 0 0 0 0 0 0 0
44835 - 0 0 0 0 0 0 0 0 0 0 0 0
44836 - 0 0 0 0 0 0 0 0 0 0 0 0
44837 - 0 0 0 0 0 0 0 0 0 0 0 0
44838 - 0 0 0 0 0 0 0 0 0 0 0 0
44839 - 0 0 0 0 0 0 0 0 1 0 0 0
44840 - 0 0 1 0 0 1 0 0 1 0 0 0
44841 - 0 0 0 0 0 0 0 0 0 0 0 0
44842 - 0 0 0 0 0 0 0 0 0 0 0 0
44843 - 0 0 0 0 0 0 0 0 0 0 0 0
44844 - 0 0 0 0 0 0 0 0 0 0 0 0
44845 - 0 0 0 0 0 0 0 0 0 14 14 14
44846 - 42 42 42 86 86 86 6 6 6 116 116 116
44847 -106 106 106 6 6 6 70 70 70 149 149 149
44848 -128 128 128 18 18 18 38 38 38 54 54 54
44849 -221 221 221 106 106 106 2 2 6 14 14 14
44850 - 46 46 46 190 190 190 198 198 198 2 2 6
44851 - 2 2 6 2 2 6 2 2 6 2 2 6
44852 - 74 74 74 62 62 62 22 22 22 6 6 6
44853 - 0 0 0 0 0 0 0 0 0 0 0 0
44854 - 0 0 0 0 0 0 0 0 0 0 0 0
44855 - 0 0 0 0 0 0 0 0 0 0 0 0
44856 - 0 0 0 0 0 0 0 0 0 0 0 0
44857 - 0 0 0 0 0 0 0 0 0 0 0 0
44858 - 0 0 0 0 0 0 0 0 0 0 0 0
44859 - 0 0 0 0 0 0 0 0 1 0 0 0
44860 - 0 0 1 0 0 0 0 0 1 0 0 0
44861 - 0 0 0 0 0 0 0 0 0 0 0 0
44862 - 0 0 0 0 0 0 0 0 0 0 0 0
44863 - 0 0 0 0 0 0 0 0 0 0 0 0
44864 - 0 0 0 0 0 0 0 0 0 0 0 0
44865 - 0 0 0 0 0 0 0 0 0 14 14 14
44866 - 42 42 42 94 94 94 14 14 14 101 101 101
44867 -128 128 128 2 2 6 18 18 18 116 116 116
44868 -118 98 46 121 92 8 121 92 8 98 78 10
44869 -162 162 162 106 106 106 2 2 6 2 2 6
44870 - 2 2 6 195 195 195 195 195 195 6 6 6
44871 - 2 2 6 2 2 6 2 2 6 2 2 6
44872 - 74 74 74 62 62 62 22 22 22 6 6 6
44873 - 0 0 0 0 0 0 0 0 0 0 0 0
44874 - 0 0 0 0 0 0 0 0 0 0 0 0
44875 - 0 0 0 0 0 0 0 0 0 0 0 0
44876 - 0 0 0 0 0 0 0 0 0 0 0 0
44877 - 0 0 0 0 0 0 0 0 0 0 0 0
44878 - 0 0 0 0 0 0 0 0 0 0 0 0
44879 - 0 0 0 0 0 0 0 0 1 0 0 1
44880 - 0 0 1 0 0 0 0 0 1 0 0 0
44881 - 0 0 0 0 0 0 0 0 0 0 0 0
44882 - 0 0 0 0 0 0 0 0 0 0 0 0
44883 - 0 0 0 0 0 0 0 0 0 0 0 0
44884 - 0 0 0 0 0 0 0 0 0 0 0 0
44885 - 0 0 0 0 0 0 0 0 0 10 10 10
44886 - 38 38 38 90 90 90 14 14 14 58 58 58
44887 -210 210 210 26 26 26 54 38 6 154 114 10
44888 -226 170 11 236 186 11 225 175 15 184 144 12
44889 -215 174 15 175 146 61 37 26 9 2 2 6
44890 - 70 70 70 246 246 246 138 138 138 2 2 6
44891 - 2 2 6 2 2 6 2 2 6 2 2 6
44892 - 70 70 70 66 66 66 26 26 26 6 6 6
44893 - 0 0 0 0 0 0 0 0 0 0 0 0
44894 - 0 0 0 0 0 0 0 0 0 0 0 0
44895 - 0 0 0 0 0 0 0 0 0 0 0 0
44896 - 0 0 0 0 0 0 0 0 0 0 0 0
44897 - 0 0 0 0 0 0 0 0 0 0 0 0
44898 - 0 0 0 0 0 0 0 0 0 0 0 0
44899 - 0 0 0 0 0 0 0 0 0 0 0 0
44900 - 0 0 0 0 0 0 0 0 0 0 0 0
44901 - 0 0 0 0 0 0 0 0 0 0 0 0
44902 - 0 0 0 0 0 0 0 0 0 0 0 0
44903 - 0 0 0 0 0 0 0 0 0 0 0 0
44904 - 0 0 0 0 0 0 0 0 0 0 0 0
44905 - 0 0 0 0 0 0 0 0 0 10 10 10
44906 - 38 38 38 86 86 86 14 14 14 10 10 10
44907 -195 195 195 188 164 115 192 133 9 225 175 15
44908 -239 182 13 234 190 10 232 195 16 232 200 30
44909 -245 207 45 241 208 19 232 195 16 184 144 12
44910 -218 194 134 211 206 186 42 42 42 2 2 6
44911 - 2 2 6 2 2 6 2 2 6 2 2 6
44912 - 50 50 50 74 74 74 30 30 30 6 6 6
44913 - 0 0 0 0 0 0 0 0 0 0 0 0
44914 - 0 0 0 0 0 0 0 0 0 0 0 0
44915 - 0 0 0 0 0 0 0 0 0 0 0 0
44916 - 0 0 0 0 0 0 0 0 0 0 0 0
44917 - 0 0 0 0 0 0 0 0 0 0 0 0
44918 - 0 0 0 0 0 0 0 0 0 0 0 0
44919 - 0 0 0 0 0 0 0 0 0 0 0 0
44920 - 0 0 0 0 0 0 0 0 0 0 0 0
44921 - 0 0 0 0 0 0 0 0 0 0 0 0
44922 - 0 0 0 0 0 0 0 0 0 0 0 0
44923 - 0 0 0 0 0 0 0 0 0 0 0 0
44924 - 0 0 0 0 0 0 0 0 0 0 0 0
44925 - 0 0 0 0 0 0 0 0 0 10 10 10
44926 - 34 34 34 86 86 86 14 14 14 2 2 6
44927 -121 87 25 192 133 9 219 162 10 239 182 13
44928 -236 186 11 232 195 16 241 208 19 244 214 54
44929 -246 218 60 246 218 38 246 215 20 241 208 19
44930 -241 208 19 226 184 13 121 87 25 2 2 6
44931 - 2 2 6 2 2 6 2 2 6 2 2 6
44932 - 50 50 50 82 82 82 34 34 34 10 10 10
44933 - 0 0 0 0 0 0 0 0 0 0 0 0
44934 - 0 0 0 0 0 0 0 0 0 0 0 0
44935 - 0 0 0 0 0 0 0 0 0 0 0 0
44936 - 0 0 0 0 0 0 0 0 0 0 0 0
44937 - 0 0 0 0 0 0 0 0 0 0 0 0
44938 - 0 0 0 0 0 0 0 0 0 0 0 0
44939 - 0 0 0 0 0 0 0 0 0 0 0 0
44940 - 0 0 0 0 0 0 0 0 0 0 0 0
44941 - 0 0 0 0 0 0 0 0 0 0 0 0
44942 - 0 0 0 0 0 0 0 0 0 0 0 0
44943 - 0 0 0 0 0 0 0 0 0 0 0 0
44944 - 0 0 0 0 0 0 0 0 0 0 0 0
44945 - 0 0 0 0 0 0 0 0 0 10 10 10
44946 - 34 34 34 82 82 82 30 30 30 61 42 6
44947 -180 123 7 206 145 10 230 174 11 239 182 13
44948 -234 190 10 238 202 15 241 208 19 246 218 74
44949 -246 218 38 246 215 20 246 215 20 246 215 20
44950 -226 184 13 215 174 15 184 144 12 6 6 6
44951 - 2 2 6 2 2 6 2 2 6 2 2 6
44952 - 26 26 26 94 94 94 42 42 42 14 14 14
44953 - 0 0 0 0 0 0 0 0 0 0 0 0
44954 - 0 0 0 0 0 0 0 0 0 0 0 0
44955 - 0 0 0 0 0 0 0 0 0 0 0 0
44956 - 0 0 0 0 0 0 0 0 0 0 0 0
44957 - 0 0 0 0 0 0 0 0 0 0 0 0
44958 - 0 0 0 0 0 0 0 0 0 0 0 0
44959 - 0 0 0 0 0 0 0 0 0 0 0 0
44960 - 0 0 0 0 0 0 0 0 0 0 0 0
44961 - 0 0 0 0 0 0 0 0 0 0 0 0
44962 - 0 0 0 0 0 0 0 0 0 0 0 0
44963 - 0 0 0 0 0 0 0 0 0 0 0 0
44964 - 0 0 0 0 0 0 0 0 0 0 0 0
44965 - 0 0 0 0 0 0 0 0 0 10 10 10
44966 - 30 30 30 78 78 78 50 50 50 104 69 6
44967 -192 133 9 216 158 10 236 178 12 236 186 11
44968 -232 195 16 241 208 19 244 214 54 245 215 43
44969 -246 215 20 246 215 20 241 208 19 198 155 10
44970 -200 144 11 216 158 10 156 118 10 2 2 6
44971 - 2 2 6 2 2 6 2 2 6 2 2 6
44972 - 6 6 6 90 90 90 54 54 54 18 18 18
44973 - 6 6 6 0 0 0 0 0 0 0 0 0
44974 - 0 0 0 0 0 0 0 0 0 0 0 0
44975 - 0 0 0 0 0 0 0 0 0 0 0 0
44976 - 0 0 0 0 0 0 0 0 0 0 0 0
44977 - 0 0 0 0 0 0 0 0 0 0 0 0
44978 - 0 0 0 0 0 0 0 0 0 0 0 0
44979 - 0 0 0 0 0 0 0 0 0 0 0 0
44980 - 0 0 0 0 0 0 0 0 0 0 0 0
44981 - 0 0 0 0 0 0 0 0 0 0 0 0
44982 - 0 0 0 0 0 0 0 0 0 0 0 0
44983 - 0 0 0 0 0 0 0 0 0 0 0 0
44984 - 0 0 0 0 0 0 0 0 0 0 0 0
44985 - 0 0 0 0 0 0 0 0 0 10 10 10
44986 - 30 30 30 78 78 78 46 46 46 22 22 22
44987 -137 92 6 210 162 10 239 182 13 238 190 10
44988 -238 202 15 241 208 19 246 215 20 246 215 20
44989 -241 208 19 203 166 17 185 133 11 210 150 10
44990 -216 158 10 210 150 10 102 78 10 2 2 6
44991 - 6 6 6 54 54 54 14 14 14 2 2 6
44992 - 2 2 6 62 62 62 74 74 74 30 30 30
44993 - 10 10 10 0 0 0 0 0 0 0 0 0
44994 - 0 0 0 0 0 0 0 0 0 0 0 0
44995 - 0 0 0 0 0 0 0 0 0 0 0 0
44996 - 0 0 0 0 0 0 0 0 0 0 0 0
44997 - 0 0 0 0 0 0 0 0 0 0 0 0
44998 - 0 0 0 0 0 0 0 0 0 0 0 0
44999 - 0 0 0 0 0 0 0 0 0 0 0 0
45000 - 0 0 0 0 0 0 0 0 0 0 0 0
45001 - 0 0 0 0 0 0 0 0 0 0 0 0
45002 - 0 0 0 0 0 0 0 0 0 0 0 0
45003 - 0 0 0 0 0 0 0 0 0 0 0 0
45004 - 0 0 0 0 0 0 0 0 0 0 0 0
45005 - 0 0 0 0 0 0 0 0 0 10 10 10
45006 - 34 34 34 78 78 78 50 50 50 6 6 6
45007 - 94 70 30 139 102 15 190 146 13 226 184 13
45008 -232 200 30 232 195 16 215 174 15 190 146 13
45009 -168 122 10 192 133 9 210 150 10 213 154 11
45010 -202 150 34 182 157 106 101 98 89 2 2 6
45011 - 2 2 6 78 78 78 116 116 116 58 58 58
45012 - 2 2 6 22 22 22 90 90 90 46 46 46
45013 - 18 18 18 6 6 6 0 0 0 0 0 0
45014 - 0 0 0 0 0 0 0 0 0 0 0 0
45015 - 0 0 0 0 0 0 0 0 0 0 0 0
45016 - 0 0 0 0 0 0 0 0 0 0 0 0
45017 - 0 0 0 0 0 0 0 0 0 0 0 0
45018 - 0 0 0 0 0 0 0 0 0 0 0 0
45019 - 0 0 0 0 0 0 0 0 0 0 0 0
45020 - 0 0 0 0 0 0 0 0 0 0 0 0
45021 - 0 0 0 0 0 0 0 0 0 0 0 0
45022 - 0 0 0 0 0 0 0 0 0 0 0 0
45023 - 0 0 0 0 0 0 0 0 0 0 0 0
45024 - 0 0 0 0 0 0 0 0 0 0 0 0
45025 - 0 0 0 0 0 0 0 0 0 10 10 10
45026 - 38 38 38 86 86 86 50 50 50 6 6 6
45027 -128 128 128 174 154 114 156 107 11 168 122 10
45028 -198 155 10 184 144 12 197 138 11 200 144 11
45029 -206 145 10 206 145 10 197 138 11 188 164 115
45030 -195 195 195 198 198 198 174 174 174 14 14 14
45031 - 2 2 6 22 22 22 116 116 116 116 116 116
45032 - 22 22 22 2 2 6 74 74 74 70 70 70
45033 - 30 30 30 10 10 10 0 0 0 0 0 0
45034 - 0 0 0 0 0 0 0 0 0 0 0 0
45035 - 0 0 0 0 0 0 0 0 0 0 0 0
45036 - 0 0 0 0 0 0 0 0 0 0 0 0
45037 - 0 0 0 0 0 0 0 0 0 0 0 0
45038 - 0 0 0 0 0 0 0 0 0 0 0 0
45039 - 0 0 0 0 0 0 0 0 0 0 0 0
45040 - 0 0 0 0 0 0 0 0 0 0 0 0
45041 - 0 0 0 0 0 0 0 0 0 0 0 0
45042 - 0 0 0 0 0 0 0 0 0 0 0 0
45043 - 0 0 0 0 0 0 0 0 0 0 0 0
45044 - 0 0 0 0 0 0 0 0 0 0 0 0
45045 - 0 0 0 0 0 0 6 6 6 18 18 18
45046 - 50 50 50 101 101 101 26 26 26 10 10 10
45047 -138 138 138 190 190 190 174 154 114 156 107 11
45048 -197 138 11 200 144 11 197 138 11 192 133 9
45049 -180 123 7 190 142 34 190 178 144 187 187 187
45050 -202 202 202 221 221 221 214 214 214 66 66 66
45051 - 2 2 6 2 2 6 50 50 50 62 62 62
45052 - 6 6 6 2 2 6 10 10 10 90 90 90
45053 - 50 50 50 18 18 18 6 6 6 0 0 0
45054 - 0 0 0 0 0 0 0 0 0 0 0 0
45055 - 0 0 0 0 0 0 0 0 0 0 0 0
45056 - 0 0 0 0 0 0 0 0 0 0 0 0
45057 - 0 0 0 0 0 0 0 0 0 0 0 0
45058 - 0 0 0 0 0 0 0 0 0 0 0 0
45059 - 0 0 0 0 0 0 0 0 0 0 0 0
45060 - 0 0 0 0 0 0 0 0 0 0 0 0
45061 - 0 0 0 0 0 0 0 0 0 0 0 0
45062 - 0 0 0 0 0 0 0 0 0 0 0 0
45063 - 0 0 0 0 0 0 0 0 0 0 0 0
45064 - 0 0 0 0 0 0 0 0 0 0 0 0
45065 - 0 0 0 0 0 0 10 10 10 34 34 34
45066 - 74 74 74 74 74 74 2 2 6 6 6 6
45067 -144 144 144 198 198 198 190 190 190 178 166 146
45068 -154 121 60 156 107 11 156 107 11 168 124 44
45069 -174 154 114 187 187 187 190 190 190 210 210 210
45070 -246 246 246 253 253 253 253 253 253 182 182 182
45071 - 6 6 6 2 2 6 2 2 6 2 2 6
45072 - 2 2 6 2 2 6 2 2 6 62 62 62
45073 - 74 74 74 34 34 34 14 14 14 0 0 0
45074 - 0 0 0 0 0 0 0 0 0 0 0 0
45075 - 0 0 0 0 0 0 0 0 0 0 0 0
45076 - 0 0 0 0 0 0 0 0 0 0 0 0
45077 - 0 0 0 0 0 0 0 0 0 0 0 0
45078 - 0 0 0 0 0 0 0 0 0 0 0 0
45079 - 0 0 0 0 0 0 0 0 0 0 0 0
45080 - 0 0 0 0 0 0 0 0 0 0 0 0
45081 - 0 0 0 0 0 0 0 0 0 0 0 0
45082 - 0 0 0 0 0 0 0 0 0 0 0 0
45083 - 0 0 0 0 0 0 0 0 0 0 0 0
45084 - 0 0 0 0 0 0 0 0 0 0 0 0
45085 - 0 0 0 10 10 10 22 22 22 54 54 54
45086 - 94 94 94 18 18 18 2 2 6 46 46 46
45087 -234 234 234 221 221 221 190 190 190 190 190 190
45088 -190 190 190 187 187 187 187 187 187 190 190 190
45089 -190 190 190 195 195 195 214 214 214 242 242 242
45090 -253 253 253 253 253 253 253 253 253 253 253 253
45091 - 82 82 82 2 2 6 2 2 6 2 2 6
45092 - 2 2 6 2 2 6 2 2 6 14 14 14
45093 - 86 86 86 54 54 54 22 22 22 6 6 6
45094 - 0 0 0 0 0 0 0 0 0 0 0 0
45095 - 0 0 0 0 0 0 0 0 0 0 0 0
45096 - 0 0 0 0 0 0 0 0 0 0 0 0
45097 - 0 0 0 0 0 0 0 0 0 0 0 0
45098 - 0 0 0 0 0 0 0 0 0 0 0 0
45099 - 0 0 0 0 0 0 0 0 0 0 0 0
45100 - 0 0 0 0 0 0 0 0 0 0 0 0
45101 - 0 0 0 0 0 0 0 0 0 0 0 0
45102 - 0 0 0 0 0 0 0 0 0 0 0 0
45103 - 0 0 0 0 0 0 0 0 0 0 0 0
45104 - 0 0 0 0 0 0 0 0 0 0 0 0
45105 - 6 6 6 18 18 18 46 46 46 90 90 90
45106 - 46 46 46 18 18 18 6 6 6 182 182 182
45107 -253 253 253 246 246 246 206 206 206 190 190 190
45108 -190 190 190 190 190 190 190 190 190 190 190 190
45109 -206 206 206 231 231 231 250 250 250 253 253 253
45110 -253 253 253 253 253 253 253 253 253 253 253 253
45111 -202 202 202 14 14 14 2 2 6 2 2 6
45112 - 2 2 6 2 2 6 2 2 6 2 2 6
45113 - 42 42 42 86 86 86 42 42 42 18 18 18
45114 - 6 6 6 0 0 0 0 0 0 0 0 0
45115 - 0 0 0 0 0 0 0 0 0 0 0 0
45116 - 0 0 0 0 0 0 0 0 0 0 0 0
45117 - 0 0 0 0 0 0 0 0 0 0 0 0
45118 - 0 0 0 0 0 0 0 0 0 0 0 0
45119 - 0 0 0 0 0 0 0 0 0 0 0 0
45120 - 0 0 0 0 0 0 0 0 0 0 0 0
45121 - 0 0 0 0 0 0 0 0 0 0 0 0
45122 - 0 0 0 0 0 0 0 0 0 0 0 0
45123 - 0 0 0 0 0 0 0 0 0 0 0 0
45124 - 0 0 0 0 0 0 0 0 0 6 6 6
45125 - 14 14 14 38 38 38 74 74 74 66 66 66
45126 - 2 2 6 6 6 6 90 90 90 250 250 250
45127 -253 253 253 253 253 253 238 238 238 198 198 198
45128 -190 190 190 190 190 190 195 195 195 221 221 221
45129 -246 246 246 253 253 253 253 253 253 253 253 253
45130 -253 253 253 253 253 253 253 253 253 253 253 253
45131 -253 253 253 82 82 82 2 2 6 2 2 6
45132 - 2 2 6 2 2 6 2 2 6 2 2 6
45133 - 2 2 6 78 78 78 70 70 70 34 34 34
45134 - 14 14 14 6 6 6 0 0 0 0 0 0
45135 - 0 0 0 0 0 0 0 0 0 0 0 0
45136 - 0 0 0 0 0 0 0 0 0 0 0 0
45137 - 0 0 0 0 0 0 0 0 0 0 0 0
45138 - 0 0 0 0 0 0 0 0 0 0 0 0
45139 - 0 0 0 0 0 0 0 0 0 0 0 0
45140 - 0 0 0 0 0 0 0 0 0 0 0 0
45141 - 0 0 0 0 0 0 0 0 0 0 0 0
45142 - 0 0 0 0 0 0 0 0 0 0 0 0
45143 - 0 0 0 0 0 0 0 0 0 0 0 0
45144 - 0 0 0 0 0 0 0 0 0 14 14 14
45145 - 34 34 34 66 66 66 78 78 78 6 6 6
45146 - 2 2 6 18 18 18 218 218 218 253 253 253
45147 -253 253 253 253 253 253 253 253 253 246 246 246
45148 -226 226 226 231 231 231 246 246 246 253 253 253
45149 -253 253 253 253 253 253 253 253 253 253 253 253
45150 -253 253 253 253 253 253 253 253 253 253 253 253
45151 -253 253 253 178 178 178 2 2 6 2 2 6
45152 - 2 2 6 2 2 6 2 2 6 2 2 6
45153 - 2 2 6 18 18 18 90 90 90 62 62 62
45154 - 30 30 30 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45162 - 0 0 0 0 0 0 0 0 0 0 0 0
45163 - 0 0 0 0 0 0 0 0 0 0 0 0
45164 - 0 0 0 0 0 0 10 10 10 26 26 26
45165 - 58 58 58 90 90 90 18 18 18 2 2 6
45166 - 2 2 6 110 110 110 253 253 253 253 253 253
45167 -253 253 253 253 253 253 253 253 253 253 253 253
45168 -250 250 250 253 253 253 253 253 253 253 253 253
45169 -253 253 253 253 253 253 253 253 253 253 253 253
45170 -253 253 253 253 253 253 253 253 253 253 253 253
45171 -253 253 253 231 231 231 18 18 18 2 2 6
45172 - 2 2 6 2 2 6 2 2 6 2 2 6
45173 - 2 2 6 2 2 6 18 18 18 94 94 94
45174 - 54 54 54 26 26 26 10 10 10 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 0 0 0 0 0 0 0 0 0
45181 - 0 0 0 0 0 0 0 0 0 0 0 0
45182 - 0 0 0 0 0 0 0 0 0 0 0 0
45183 - 0 0 0 0 0 0 0 0 0 0 0 0
45184 - 0 0 0 6 6 6 22 22 22 50 50 50
45185 - 90 90 90 26 26 26 2 2 6 2 2 6
45186 - 14 14 14 195 195 195 250 250 250 253 253 253
45187 -253 253 253 253 253 253 253 253 253 253 253 253
45188 -253 253 253 253 253 253 253 253 253 253 253 253
45189 -253 253 253 253 253 253 253 253 253 253 253 253
45190 -253 253 253 253 253 253 253 253 253 253 253 253
45191 -250 250 250 242 242 242 54 54 54 2 2 6
45192 - 2 2 6 2 2 6 2 2 6 2 2 6
45193 - 2 2 6 2 2 6 2 2 6 38 38 38
45194 - 86 86 86 50 50 50 22 22 22 6 6 6
45195 - 0 0 0 0 0 0 0 0 0 0 0 0
45196 - 0 0 0 0 0 0 0 0 0 0 0 0
45197 - 0 0 0 0 0 0 0 0 0 0 0 0
45198 - 0 0 0 0 0 0 0 0 0 0 0 0
45199 - 0 0 0 0 0 0 0 0 0 0 0 0
45200 - 0 0 0 0 0 0 0 0 0 0 0 0
45201 - 0 0 0 0 0 0 0 0 0 0 0 0
45202 - 0 0 0 0 0 0 0 0 0 0 0 0
45203 - 0 0 0 0 0 0 0 0 0 0 0 0
45204 - 6 6 6 14 14 14 38 38 38 82 82 82
45205 - 34 34 34 2 2 6 2 2 6 2 2 6
45206 - 42 42 42 195 195 195 246 246 246 253 253 253
45207 -253 253 253 253 253 253 253 253 253 250 250 250
45208 -242 242 242 242 242 242 250 250 250 253 253 253
45209 -253 253 253 253 253 253 253 253 253 253 253 253
45210 -253 253 253 250 250 250 246 246 246 238 238 238
45211 -226 226 226 231 231 231 101 101 101 6 6 6
45212 - 2 2 6 2 2 6 2 2 6 2 2 6
45213 - 2 2 6 2 2 6 2 2 6 2 2 6
45214 - 38 38 38 82 82 82 42 42 42 14 14 14
45215 - 6 6 6 0 0 0 0 0 0 0 0 0
45216 - 0 0 0 0 0 0 0 0 0 0 0 0
45217 - 0 0 0 0 0 0 0 0 0 0 0 0
45218 - 0 0 0 0 0 0 0 0 0 0 0 0
45219 - 0 0 0 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 0 0 0
45221 - 0 0 0 0 0 0 0 0 0 0 0 0
45222 - 0 0 0 0 0 0 0 0 0 0 0 0
45223 - 0 0 0 0 0 0 0 0 0 0 0 0
45224 - 10 10 10 26 26 26 62 62 62 66 66 66
45225 - 2 2 6 2 2 6 2 2 6 6 6 6
45226 - 70 70 70 170 170 170 206 206 206 234 234 234
45227 -246 246 246 250 250 250 250 250 250 238 238 238
45228 -226 226 226 231 231 231 238 238 238 250 250 250
45229 -250 250 250 250 250 250 246 246 246 231 231 231
45230 -214 214 214 206 206 206 202 202 202 202 202 202
45231 -198 198 198 202 202 202 182 182 182 18 18 18
45232 - 2 2 6 2 2 6 2 2 6 2 2 6
45233 - 2 2 6 2 2 6 2 2 6 2 2 6
45234 - 2 2 6 62 62 62 66 66 66 30 30 30
45235 - 10 10 10 0 0 0 0 0 0 0 0 0
45236 - 0 0 0 0 0 0 0 0 0 0 0 0
45237 - 0 0 0 0 0 0 0 0 0 0 0 0
45238 - 0 0 0 0 0 0 0 0 0 0 0 0
45239 - 0 0 0 0 0 0 0 0 0 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 0 0 0
45242 - 0 0 0 0 0 0 0 0 0 0 0 0
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 14 14 14 42 42 42 82 82 82 18 18 18
45245 - 2 2 6 2 2 6 2 2 6 10 10 10
45246 - 94 94 94 182 182 182 218 218 218 242 242 242
45247 -250 250 250 253 253 253 253 253 253 250 250 250
45248 -234 234 234 253 253 253 253 253 253 253 253 253
45249 -253 253 253 253 253 253 253 253 253 246 246 246
45250 -238 238 238 226 226 226 210 210 210 202 202 202
45251 -195 195 195 195 195 195 210 210 210 158 158 158
45252 - 6 6 6 14 14 14 50 50 50 14 14 14
45253 - 2 2 6 2 2 6 2 2 6 2 2 6
45254 - 2 2 6 6 6 6 86 86 86 46 46 46
45255 - 18 18 18 6 6 6 0 0 0 0 0 0
45256 - 0 0 0 0 0 0 0 0 0 0 0 0
45257 - 0 0 0 0 0 0 0 0 0 0 0 0
45258 - 0 0 0 0 0 0 0 0 0 0 0 0
45259 - 0 0 0 0 0 0 0 0 0 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 0 0 0
45262 - 0 0 0 0 0 0 0 0 0 0 0 0
45263 - 0 0 0 0 0 0 0 0 0 6 6 6
45264 - 22 22 22 54 54 54 70 70 70 2 2 6
45265 - 2 2 6 10 10 10 2 2 6 22 22 22
45266 -166 166 166 231 231 231 250 250 250 253 253 253
45267 -253 253 253 253 253 253 253 253 253 250 250 250
45268 -242 242 242 253 253 253 253 253 253 253 253 253
45269 -253 253 253 253 253 253 253 253 253 253 253 253
45270 -253 253 253 253 253 253 253 253 253 246 246 246
45271 -231 231 231 206 206 206 198 198 198 226 226 226
45272 - 94 94 94 2 2 6 6 6 6 38 38 38
45273 - 30 30 30 2 2 6 2 2 6 2 2 6
45274 - 2 2 6 2 2 6 62 62 62 66 66 66
45275 - 26 26 26 10 10 10 0 0 0 0 0 0
45276 - 0 0 0 0 0 0 0 0 0 0 0 0
45277 - 0 0 0 0 0 0 0 0 0 0 0 0
45278 - 0 0 0 0 0 0 0 0 0 0 0 0
45279 - 0 0 0 0 0 0 0 0 0 0 0 0
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 0 0 0
45282 - 0 0 0 0 0 0 0 0 0 0 0 0
45283 - 0 0 0 0 0 0 0 0 0 10 10 10
45284 - 30 30 30 74 74 74 50 50 50 2 2 6
45285 - 26 26 26 26 26 26 2 2 6 106 106 106
45286 -238 238 238 253 253 253 253 253 253 253 253 253
45287 -253 253 253 253 253 253 253 253 253 253 253 253
45288 -253 253 253 253 253 253 253 253 253 253 253 253
45289 -253 253 253 253 253 253 253 253 253 253 253 253
45290 -253 253 253 253 253 253 253 253 253 253 253 253
45291 -253 253 253 246 246 246 218 218 218 202 202 202
45292 -210 210 210 14 14 14 2 2 6 2 2 6
45293 - 30 30 30 22 22 22 2 2 6 2 2 6
45294 - 2 2 6 2 2 6 18 18 18 86 86 86
45295 - 42 42 42 14 14 14 0 0 0 0 0 0
45296 - 0 0 0 0 0 0 0 0 0 0 0 0
45297 - 0 0 0 0 0 0 0 0 0 0 0 0
45298 - 0 0 0 0 0 0 0 0 0 0 0 0
45299 - 0 0 0 0 0 0 0 0 0 0 0 0
45300 - 0 0 0 0 0 0 0 0 0 0 0 0
45301 - 0 0 0 0 0 0 0 0 0 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 14 14 14
45304 - 42 42 42 90 90 90 22 22 22 2 2 6
45305 - 42 42 42 2 2 6 18 18 18 218 218 218
45306 -253 253 253 253 253 253 253 253 253 253 253 253
45307 -253 253 253 253 253 253 253 253 253 253 253 253
45308 -253 253 253 253 253 253 253 253 253 253 253 253
45309 -253 253 253 253 253 253 253 253 253 253 253 253
45310 -253 253 253 253 253 253 253 253 253 253 253 253
45311 -253 253 253 253 253 253 250 250 250 221 221 221
45312 -218 218 218 101 101 101 2 2 6 14 14 14
45313 - 18 18 18 38 38 38 10 10 10 2 2 6
45314 - 2 2 6 2 2 6 2 2 6 78 78 78
45315 - 58 58 58 22 22 22 6 6 6 0 0 0
45316 - 0 0 0 0 0 0 0 0 0 0 0 0
45317 - 0 0 0 0 0 0 0 0 0 0 0 0
45318 - 0 0 0 0 0 0 0 0 0 0 0 0
45319 - 0 0 0 0 0 0 0 0 0 0 0 0
45320 - 0 0 0 0 0 0 0 0 0 0 0 0
45321 - 0 0 0 0 0 0 0 0 0 0 0 0
45322 - 0 0 0 0 0 0 0 0 0 0 0 0
45323 - 0 0 0 0 0 0 6 6 6 18 18 18
45324 - 54 54 54 82 82 82 2 2 6 26 26 26
45325 - 22 22 22 2 2 6 123 123 123 253 253 253
45326 -253 253 253 253 253 253 253 253 253 253 253 253
45327 -253 253 253 253 253 253 253 253 253 253 253 253
45328 -253 253 253 253 253 253 253 253 253 253 253 253
45329 -253 253 253 253 253 253 253 253 253 253 253 253
45330 -253 253 253 253 253 253 253 253 253 253 253 253
45331 -253 253 253 253 253 253 253 253 253 250 250 250
45332 -238 238 238 198 198 198 6 6 6 38 38 38
45333 - 58 58 58 26 26 26 38 38 38 2 2 6
45334 - 2 2 6 2 2 6 2 2 6 46 46 46
45335 - 78 78 78 30 30 30 10 10 10 0 0 0
45336 - 0 0 0 0 0 0 0 0 0 0 0 0
45337 - 0 0 0 0 0 0 0 0 0 0 0 0
45338 - 0 0 0 0 0 0 0 0 0 0 0 0
45339 - 0 0 0 0 0 0 0 0 0 0 0 0
45340 - 0 0 0 0 0 0 0 0 0 0 0 0
45341 - 0 0 0 0 0 0 0 0 0 0 0 0
45342 - 0 0 0 0 0 0 0 0 0 0 0 0
45343 - 0 0 0 0 0 0 10 10 10 30 30 30
45344 - 74 74 74 58 58 58 2 2 6 42 42 42
45345 - 2 2 6 22 22 22 231 231 231 253 253 253
45346 -253 253 253 253 253 253 253 253 253 253 253 253
45347 -253 253 253 253 253 253 253 253 253 250 250 250
45348 -253 253 253 253 253 253 253 253 253 253 253 253
45349 -253 253 253 253 253 253 253 253 253 253 253 253
45350 -253 253 253 253 253 253 253 253 253 253 253 253
45351 -253 253 253 253 253 253 253 253 253 253 253 253
45352 -253 253 253 246 246 246 46 46 46 38 38 38
45353 - 42 42 42 14 14 14 38 38 38 14 14 14
45354 - 2 2 6 2 2 6 2 2 6 6 6 6
45355 - 86 86 86 46 46 46 14 14 14 0 0 0
45356 - 0 0 0 0 0 0 0 0 0 0 0 0
45357 - 0 0 0 0 0 0 0 0 0 0 0 0
45358 - 0 0 0 0 0 0 0 0 0 0 0 0
45359 - 0 0 0 0 0 0 0 0 0 0 0 0
45360 - 0 0 0 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 0 0 0 0 0 0 0 0 0 0
45363 - 0 0 0 6 6 6 14 14 14 42 42 42
45364 - 90 90 90 18 18 18 18 18 18 26 26 26
45365 - 2 2 6 116 116 116 253 253 253 253 253 253
45366 -253 253 253 253 253 253 253 253 253 253 253 253
45367 -253 253 253 253 253 253 250 250 250 238 238 238
45368 -253 253 253 253 253 253 253 253 253 253 253 253
45369 -253 253 253 253 253 253 253 253 253 253 253 253
45370 -253 253 253 253 253 253 253 253 253 253 253 253
45371 -253 253 253 253 253 253 253 253 253 253 253 253
45372 -253 253 253 253 253 253 94 94 94 6 6 6
45373 - 2 2 6 2 2 6 10 10 10 34 34 34
45374 - 2 2 6 2 2 6 2 2 6 2 2 6
45375 - 74 74 74 58 58 58 22 22 22 6 6 6
45376 - 0 0 0 0 0 0 0 0 0 0 0 0
45377 - 0 0 0 0 0 0 0 0 0 0 0 0
45378 - 0 0 0 0 0 0 0 0 0 0 0 0
45379 - 0 0 0 0 0 0 0 0 0 0 0 0
45380 - 0 0 0 0 0 0 0 0 0 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 0 0 0
45382 - 0 0 0 0 0 0 0 0 0 0 0 0
45383 - 0 0 0 10 10 10 26 26 26 66 66 66
45384 - 82 82 82 2 2 6 38 38 38 6 6 6
45385 - 14 14 14 210 210 210 253 253 253 253 253 253
45386 -253 253 253 253 253 253 253 253 253 253 253 253
45387 -253 253 253 253 253 253 246 246 246 242 242 242
45388 -253 253 253 253 253 253 253 253 253 253 253 253
45389 -253 253 253 253 253 253 253 253 253 253 253 253
45390 -253 253 253 253 253 253 253 253 253 253 253 253
45391 -253 253 253 253 253 253 253 253 253 253 253 253
45392 -253 253 253 253 253 253 144 144 144 2 2 6
45393 - 2 2 6 2 2 6 2 2 6 46 46 46
45394 - 2 2 6 2 2 6 2 2 6 2 2 6
45395 - 42 42 42 74 74 74 30 30 30 10 10 10
45396 - 0 0 0 0 0 0 0 0 0 0 0 0
45397 - 0 0 0 0 0 0 0 0 0 0 0 0
45398 - 0 0 0 0 0 0 0 0 0 0 0 0
45399 - 0 0 0 0 0 0 0 0 0 0 0 0
45400 - 0 0 0 0 0 0 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 0 0 0 0 0 0 0 0 0 0
45403 - 6 6 6 14 14 14 42 42 42 90 90 90
45404 - 26 26 26 6 6 6 42 42 42 2 2 6
45405 - 74 74 74 250 250 250 253 253 253 253 253 253
45406 -253 253 253 253 253 253 253 253 253 253 253 253
45407 -253 253 253 253 253 253 242 242 242 242 242 242
45408 -253 253 253 253 253 253 253 253 253 253 253 253
45409 -253 253 253 253 253 253 253 253 253 253 253 253
45410 -253 253 253 253 253 253 253 253 253 253 253 253
45411 -253 253 253 253 253 253 253 253 253 253 253 253
45412 -253 253 253 253 253 253 182 182 182 2 2 6
45413 - 2 2 6 2 2 6 2 2 6 46 46 46
45414 - 2 2 6 2 2 6 2 2 6 2 2 6
45415 - 10 10 10 86 86 86 38 38 38 10 10 10
45416 - 0 0 0 0 0 0 0 0 0 0 0 0
45417 - 0 0 0 0 0 0 0 0 0 0 0 0
45418 - 0 0 0 0 0 0 0 0 0 0 0 0
45419 - 0 0 0 0 0 0 0 0 0 0 0 0
45420 - 0 0 0 0 0 0 0 0 0 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 0 0 0 0 0 0 0 0 0 0
45423 - 10 10 10 26 26 26 66 66 66 82 82 82
45424 - 2 2 6 22 22 22 18 18 18 2 2 6
45425 -149 149 149 253 253 253 253 253 253 253 253 253
45426 -253 253 253 253 253 253 253 253 253 253 253 253
45427 -253 253 253 253 253 253 234 234 234 242 242 242
45428 -253 253 253 253 253 253 253 253 253 253 253 253
45429 -253 253 253 253 253 253 253 253 253 253 253 253
45430 -253 253 253 253 253 253 253 253 253 253 253 253
45431 -253 253 253 253 253 253 253 253 253 253 253 253
45432 -253 253 253 253 253 253 206 206 206 2 2 6
45433 - 2 2 6 2 2 6 2 2 6 38 38 38
45434 - 2 2 6 2 2 6 2 2 6 2 2 6
45435 - 6 6 6 86 86 86 46 46 46 14 14 14
45436 - 0 0 0 0 0 0 0 0 0 0 0 0
45437 - 0 0 0 0 0 0 0 0 0 0 0 0
45438 - 0 0 0 0 0 0 0 0 0 0 0 0
45439 - 0 0 0 0 0 0 0 0 0 0 0 0
45440 - 0 0 0 0 0 0 0 0 0 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 0 0 0 0 6 6 6
45443 - 18 18 18 46 46 46 86 86 86 18 18 18
45444 - 2 2 6 34 34 34 10 10 10 6 6 6
45445 -210 210 210 253 253 253 253 253 253 253 253 253
45446 -253 253 253 253 253 253 253 253 253 253 253 253
45447 -253 253 253 253 253 253 234 234 234 242 242 242
45448 -253 253 253 253 253 253 253 253 253 253 253 253
45449 -253 253 253 253 253 253 253 253 253 253 253 253
45450 -253 253 253 253 253 253 253 253 253 253 253 253
45451 -253 253 253 253 253 253 253 253 253 253 253 253
45452 -253 253 253 253 253 253 221 221 221 6 6 6
45453 - 2 2 6 2 2 6 6 6 6 30 30 30
45454 - 2 2 6 2 2 6 2 2 6 2 2 6
45455 - 2 2 6 82 82 82 54 54 54 18 18 18
45456 - 6 6 6 0 0 0 0 0 0 0 0 0
45457 - 0 0 0 0 0 0 0 0 0 0 0 0
45458 - 0 0 0 0 0 0 0 0 0 0 0 0
45459 - 0 0 0 0 0 0 0 0 0 0 0 0
45460 - 0 0 0 0 0 0 0 0 0 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 0 0 0 0 0 0 0 10 10 10
45463 - 26 26 26 66 66 66 62 62 62 2 2 6
45464 - 2 2 6 38 38 38 10 10 10 26 26 26
45465 -238 238 238 253 253 253 253 253 253 253 253 253
45466 -253 253 253 253 253 253 253 253 253 253 253 253
45467 -253 253 253 253 253 253 231 231 231 238 238 238
45468 -253 253 253 253 253 253 253 253 253 253 253 253
45469 -253 253 253 253 253 253 253 253 253 253 253 253
45470 -253 253 253 253 253 253 253 253 253 253 253 253
45471 -253 253 253 253 253 253 253 253 253 253 253 253
45472 -253 253 253 253 253 253 231 231 231 6 6 6
45473 - 2 2 6 2 2 6 10 10 10 30 30 30
45474 - 2 2 6 2 2 6 2 2 6 2 2 6
45475 - 2 2 6 66 66 66 58 58 58 22 22 22
45476 - 6 6 6 0 0 0 0 0 0 0 0 0
45477 - 0 0 0 0 0 0 0 0 0 0 0 0
45478 - 0 0 0 0 0 0 0 0 0 0 0 0
45479 - 0 0 0 0 0 0 0 0 0 0 0 0
45480 - 0 0 0 0 0 0 0 0 0 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 0 0 0 0 0 0 0 10 10 10
45483 - 38 38 38 78 78 78 6 6 6 2 2 6
45484 - 2 2 6 46 46 46 14 14 14 42 42 42
45485 -246 246 246 253 253 253 253 253 253 253 253 253
45486 -253 253 253 253 253 253 253 253 253 253 253 253
45487 -253 253 253 253 253 253 231 231 231 242 242 242
45488 -253 253 253 253 253 253 253 253 253 253 253 253
45489 -253 253 253 253 253 253 253 253 253 253 253 253
45490 -253 253 253 253 253 253 253 253 253 253 253 253
45491 -253 253 253 253 253 253 253 253 253 253 253 253
45492 -253 253 253 253 253 253 234 234 234 10 10 10
45493 - 2 2 6 2 2 6 22 22 22 14 14 14
45494 - 2 2 6 2 2 6 2 2 6 2 2 6
45495 - 2 2 6 66 66 66 62 62 62 22 22 22
45496 - 6 6 6 0 0 0 0 0 0 0 0 0
45497 - 0 0 0 0 0 0 0 0 0 0 0 0
45498 - 0 0 0 0 0 0 0 0 0 0 0 0
45499 - 0 0 0 0 0 0 0 0 0 0 0 0
45500 - 0 0 0 0 0 0 0 0 0 0 0 0
45501 - 0 0 0 0 0 0 0 0 0 0 0 0
45502 - 0 0 0 0 0 0 6 6 6 18 18 18
45503 - 50 50 50 74 74 74 2 2 6 2 2 6
45504 - 14 14 14 70 70 70 34 34 34 62 62 62
45505 -250 250 250 253 253 253 253 253 253 253 253 253
45506 -253 253 253 253 253 253 253 253 253 253 253 253
45507 -253 253 253 253 253 253 231 231 231 246 246 246
45508 -253 253 253 253 253 253 253 253 253 253 253 253
45509 -253 253 253 253 253 253 253 253 253 253 253 253
45510 -253 253 253 253 253 253 253 253 253 253 253 253
45511 -253 253 253 253 253 253 253 253 253 253 253 253
45512 -253 253 253 253 253 253 234 234 234 14 14 14
45513 - 2 2 6 2 2 6 30 30 30 2 2 6
45514 - 2 2 6 2 2 6 2 2 6 2 2 6
45515 - 2 2 6 66 66 66 62 62 62 22 22 22
45516 - 6 6 6 0 0 0 0 0 0 0 0 0
45517 - 0 0 0 0 0 0 0 0 0 0 0 0
45518 - 0 0 0 0 0 0 0 0 0 0 0 0
45519 - 0 0 0 0 0 0 0 0 0 0 0 0
45520 - 0 0 0 0 0 0 0 0 0 0 0 0
45521 - 0 0 0 0 0 0 0 0 0 0 0 0
45522 - 0 0 0 0 0 0 6 6 6 18 18 18
45523 - 54 54 54 62 62 62 2 2 6 2 2 6
45524 - 2 2 6 30 30 30 46 46 46 70 70 70
45525 -250 250 250 253 253 253 253 253 253 253 253 253
45526 -253 253 253 253 253 253 253 253 253 253 253 253
45527 -253 253 253 253 253 253 231 231 231 246 246 246
45528 -253 253 253 253 253 253 253 253 253 253 253 253
45529 -253 253 253 253 253 253 253 253 253 253 253 253
45530 -253 253 253 253 253 253 253 253 253 253 253 253
45531 -253 253 253 253 253 253 253 253 253 253 253 253
45532 -253 253 253 253 253 253 226 226 226 10 10 10
45533 - 2 2 6 6 6 6 30 30 30 2 2 6
45534 - 2 2 6 2 2 6 2 2 6 2 2 6
45535 - 2 2 6 66 66 66 58 58 58 22 22 22
45536 - 6 6 6 0 0 0 0 0 0 0 0 0
45537 - 0 0 0 0 0 0 0 0 0 0 0 0
45538 - 0 0 0 0 0 0 0 0 0 0 0 0
45539 - 0 0 0 0 0 0 0 0 0 0 0 0
45540 - 0 0 0 0 0 0 0 0 0 0 0 0
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 6 6 6 22 22 22
45543 - 58 58 58 62 62 62 2 2 6 2 2 6
45544 - 2 2 6 2 2 6 30 30 30 78 78 78
45545 -250 250 250 253 253 253 253 253 253 253 253 253
45546 -253 253 253 253 253 253 253 253 253 253 253 253
45547 -253 253 253 253 253 253 231 231 231 246 246 246
45548 -253 253 253 253 253 253 253 253 253 253 253 253
45549 -253 253 253 253 253 253 253 253 253 253 253 253
45550 -253 253 253 253 253 253 253 253 253 253 253 253
45551 -253 253 253 253 253 253 253 253 253 253 253 253
45552 -253 253 253 253 253 253 206 206 206 2 2 6
45553 - 22 22 22 34 34 34 18 14 6 22 22 22
45554 - 26 26 26 18 18 18 6 6 6 2 2 6
45555 - 2 2 6 82 82 82 54 54 54 18 18 18
45556 - 6 6 6 0 0 0 0 0 0 0 0 0
45557 - 0 0 0 0 0 0 0 0 0 0 0 0
45558 - 0 0 0 0 0 0 0 0 0 0 0 0
45559 - 0 0 0 0 0 0 0 0 0 0 0 0
45560 - 0 0 0 0 0 0 0 0 0 0 0 0
45561 - 0 0 0 0 0 0 0 0 0 0 0 0
45562 - 0 0 0 0 0 0 6 6 6 26 26 26
45563 - 62 62 62 106 106 106 74 54 14 185 133 11
45564 -210 162 10 121 92 8 6 6 6 62 62 62
45565 -238 238 238 253 253 253 253 253 253 253 253 253
45566 -253 253 253 253 253 253 253 253 253 253 253 253
45567 -253 253 253 253 253 253 231 231 231 246 246 246
45568 -253 253 253 253 253 253 253 253 253 253 253 253
45569 -253 253 253 253 253 253 253 253 253 253 253 253
45570 -253 253 253 253 253 253 253 253 253 253 253 253
45571 -253 253 253 253 253 253 253 253 253 253 253 253
45572 -253 253 253 253 253 253 158 158 158 18 18 18
45573 - 14 14 14 2 2 6 2 2 6 2 2 6
45574 - 6 6 6 18 18 18 66 66 66 38 38 38
45575 - 6 6 6 94 94 94 50 50 50 18 18 18
45576 - 6 6 6 0 0 0 0 0 0 0 0 0
45577 - 0 0 0 0 0 0 0 0 0 0 0 0
45578 - 0 0 0 0 0 0 0 0 0 0 0 0
45579 - 0 0 0 0 0 0 0 0 0 0 0 0
45580 - 0 0 0 0 0 0 0 0 0 0 0 0
45581 - 0 0 0 0 0 0 0 0 0 6 6 6
45582 - 10 10 10 10 10 10 18 18 18 38 38 38
45583 - 78 78 78 142 134 106 216 158 10 242 186 14
45584 -246 190 14 246 190 14 156 118 10 10 10 10
45585 - 90 90 90 238 238 238 253 253 253 253 253 253
45586 -253 253 253 253 253 253 253 253 253 253 253 253
45587 -253 253 253 253 253 253 231 231 231 250 250 250
45588 -253 253 253 253 253 253 253 253 253 253 253 253
45589 -253 253 253 253 253 253 253 253 253 253 253 253
45590 -253 253 253 253 253 253 253 253 253 253 253 253
45591 -253 253 253 253 253 253 253 253 253 246 230 190
45592 -238 204 91 238 204 91 181 142 44 37 26 9
45593 - 2 2 6 2 2 6 2 2 6 2 2 6
45594 - 2 2 6 2 2 6 38 38 38 46 46 46
45595 - 26 26 26 106 106 106 54 54 54 18 18 18
45596 - 6 6 6 0 0 0 0 0 0 0 0 0
45597 - 0 0 0 0 0 0 0 0 0 0 0 0
45598 - 0 0 0 0 0 0 0 0 0 0 0 0
45599 - 0 0 0 0 0 0 0 0 0 0 0 0
45600 - 0 0 0 0 0 0 0 0 0 0 0 0
45601 - 0 0 0 6 6 6 14 14 14 22 22 22
45602 - 30 30 30 38 38 38 50 50 50 70 70 70
45603 -106 106 106 190 142 34 226 170 11 242 186 14
45604 -246 190 14 246 190 14 246 190 14 154 114 10
45605 - 6 6 6 74 74 74 226 226 226 253 253 253
45606 -253 253 253 253 253 253 253 253 253 253 253 253
45607 -253 253 253 253 253 253 231 231 231 250 250 250
45608 -253 253 253 253 253 253 253 253 253 253 253 253
45609 -253 253 253 253 253 253 253 253 253 253 253 253
45610 -253 253 253 253 253 253 253 253 253 253 253 253
45611 -253 253 253 253 253 253 253 253 253 228 184 62
45612 -241 196 14 241 208 19 232 195 16 38 30 10
45613 - 2 2 6 2 2 6 2 2 6 2 2 6
45614 - 2 2 6 6 6 6 30 30 30 26 26 26
45615 -203 166 17 154 142 90 66 66 66 26 26 26
45616 - 6 6 6 0 0 0 0 0 0 0 0 0
45617 - 0 0 0 0 0 0 0 0 0 0 0 0
45618 - 0 0 0 0 0 0 0 0 0 0 0 0
45619 - 0 0 0 0 0 0 0 0 0 0 0 0
45620 - 0 0 0 0 0 0 0 0 0 0 0 0
45621 - 6 6 6 18 18 18 38 38 38 58 58 58
45622 - 78 78 78 86 86 86 101 101 101 123 123 123
45623 -175 146 61 210 150 10 234 174 13 246 186 14
45624 -246 190 14 246 190 14 246 190 14 238 190 10
45625 -102 78 10 2 2 6 46 46 46 198 198 198
45626 -253 253 253 253 253 253 253 253 253 253 253 253
45627 -253 253 253 253 253 253 234 234 234 242 242 242
45628 -253 253 253 253 253 253 253 253 253 253 253 253
45629 -253 253 253 253 253 253 253 253 253 253 253 253
45630 -253 253 253 253 253 253 253 253 253 253 253 253
45631 -253 253 253 253 253 253 253 253 253 224 178 62
45632 -242 186 14 241 196 14 210 166 10 22 18 6
45633 - 2 2 6 2 2 6 2 2 6 2 2 6
45634 - 2 2 6 2 2 6 6 6 6 121 92 8
45635 -238 202 15 232 195 16 82 82 82 34 34 34
45636 - 10 10 10 0 0 0 0 0 0 0 0 0
45637 - 0 0 0 0 0 0 0 0 0 0 0 0
45638 - 0 0 0 0 0 0 0 0 0 0 0 0
45639 - 0 0 0 0 0 0 0 0 0 0 0 0
45640 - 0 0 0 0 0 0 0 0 0 0 0 0
45641 - 14 14 14 38 38 38 70 70 70 154 122 46
45642 -190 142 34 200 144 11 197 138 11 197 138 11
45643 -213 154 11 226 170 11 242 186 14 246 190 14
45644 -246 190 14 246 190 14 246 190 14 246 190 14
45645 -225 175 15 46 32 6 2 2 6 22 22 22
45646 -158 158 158 250 250 250 253 253 253 253 253 253
45647 -253 253 253 253 253 253 253 253 253 253 253 253
45648 -253 253 253 253 253 253 253 253 253 253 253 253
45649 -253 253 253 253 253 253 253 253 253 253 253 253
45650 -253 253 253 253 253 253 253 253 253 253 253 253
45651 -253 253 253 250 250 250 242 242 242 224 178 62
45652 -239 182 13 236 186 11 213 154 11 46 32 6
45653 - 2 2 6 2 2 6 2 2 6 2 2 6
45654 - 2 2 6 2 2 6 61 42 6 225 175 15
45655 -238 190 10 236 186 11 112 100 78 42 42 42
45656 - 14 14 14 0 0 0 0 0 0 0 0 0
45657 - 0 0 0 0 0 0 0 0 0 0 0 0
45658 - 0 0 0 0 0 0 0 0 0 0 0 0
45659 - 0 0 0 0 0 0 0 0 0 0 0 0
45660 - 0 0 0 0 0 0 0 0 0 6 6 6
45661 - 22 22 22 54 54 54 154 122 46 213 154 11
45662 -226 170 11 230 174 11 226 170 11 226 170 11
45663 -236 178 12 242 186 14 246 190 14 246 190 14
45664 -246 190 14 246 190 14 246 190 14 246 190 14
45665 -241 196 14 184 144 12 10 10 10 2 2 6
45666 - 6 6 6 116 116 116 242 242 242 253 253 253
45667 -253 253 253 253 253 253 253 253 253 253 253 253
45668 -253 253 253 253 253 253 253 253 253 253 253 253
45669 -253 253 253 253 253 253 253 253 253 253 253 253
45670 -253 253 253 253 253 253 253 253 253 253 253 253
45671 -253 253 253 231 231 231 198 198 198 214 170 54
45672 -236 178 12 236 178 12 210 150 10 137 92 6
45673 - 18 14 6 2 2 6 2 2 6 2 2 6
45674 - 6 6 6 70 47 6 200 144 11 236 178 12
45675 -239 182 13 239 182 13 124 112 88 58 58 58
45676 - 22 22 22 6 6 6 0 0 0 0 0 0
45677 - 0 0 0 0 0 0 0 0 0 0 0 0
45678 - 0 0 0 0 0 0 0 0 0 0 0 0
45679 - 0 0 0 0 0 0 0 0 0 0 0 0
45680 - 0 0 0 0 0 0 0 0 0 10 10 10
45681 - 30 30 30 70 70 70 180 133 36 226 170 11
45682 -239 182 13 242 186 14 242 186 14 246 186 14
45683 -246 190 14 246 190 14 246 190 14 246 190 14
45684 -246 190 14 246 190 14 246 190 14 246 190 14
45685 -246 190 14 232 195 16 98 70 6 2 2 6
45686 - 2 2 6 2 2 6 66 66 66 221 221 221
45687 -253 253 253 253 253 253 253 253 253 253 253 253
45688 -253 253 253 253 253 253 253 253 253 253 253 253
45689 -253 253 253 253 253 253 253 253 253 253 253 253
45690 -253 253 253 253 253 253 253 253 253 253 253 253
45691 -253 253 253 206 206 206 198 198 198 214 166 58
45692 -230 174 11 230 174 11 216 158 10 192 133 9
45693 -163 110 8 116 81 8 102 78 10 116 81 8
45694 -167 114 7 197 138 11 226 170 11 239 182 13
45695 -242 186 14 242 186 14 162 146 94 78 78 78
45696 - 34 34 34 14 14 14 6 6 6 0 0 0
45697 - 0 0 0 0 0 0 0 0 0 0 0 0
45698 - 0 0 0 0 0 0 0 0 0 0 0 0
45699 - 0 0 0 0 0 0 0 0 0 0 0 0
45700 - 0 0 0 0 0 0 0 0 0 6 6 6
45701 - 30 30 30 78 78 78 190 142 34 226 170 11
45702 -239 182 13 246 190 14 246 190 14 246 190 14
45703 -246 190 14 246 190 14 246 190 14 246 190 14
45704 -246 190 14 246 190 14 246 190 14 246 190 14
45705 -246 190 14 241 196 14 203 166 17 22 18 6
45706 - 2 2 6 2 2 6 2 2 6 38 38 38
45707 -218 218 218 253 253 253 253 253 253 253 253 253
45708 -253 253 253 253 253 253 253 253 253 253 253 253
45709 -253 253 253 253 253 253 253 253 253 253 253 253
45710 -253 253 253 253 253 253 253 253 253 253 253 253
45711 -250 250 250 206 206 206 198 198 198 202 162 69
45712 -226 170 11 236 178 12 224 166 10 210 150 10
45713 -200 144 11 197 138 11 192 133 9 197 138 11
45714 -210 150 10 226 170 11 242 186 14 246 190 14
45715 -246 190 14 246 186 14 225 175 15 124 112 88
45716 - 62 62 62 30 30 30 14 14 14 6 6 6
45717 - 0 0 0 0 0 0 0 0 0 0 0 0
45718 - 0 0 0 0 0 0 0 0 0 0 0 0
45719 - 0 0 0 0 0 0 0 0 0 0 0 0
45720 - 0 0 0 0 0 0 0 0 0 10 10 10
45721 - 30 30 30 78 78 78 174 135 50 224 166 10
45722 -239 182 13 246 190 14 246 190 14 246 190 14
45723 -246 190 14 246 190 14 246 190 14 246 190 14
45724 -246 190 14 246 190 14 246 190 14 246 190 14
45725 -246 190 14 246 190 14 241 196 14 139 102 15
45726 - 2 2 6 2 2 6 2 2 6 2 2 6
45727 - 78 78 78 250 250 250 253 253 253 253 253 253
45728 -253 253 253 253 253 253 253 253 253 253 253 253
45729 -253 253 253 253 253 253 253 253 253 253 253 253
45730 -253 253 253 253 253 253 253 253 253 253 253 253
45731 -250 250 250 214 214 214 198 198 198 190 150 46
45732 -219 162 10 236 178 12 234 174 13 224 166 10
45733 -216 158 10 213 154 11 213 154 11 216 158 10
45734 -226 170 11 239 182 13 246 190 14 246 190 14
45735 -246 190 14 246 190 14 242 186 14 206 162 42
45736 -101 101 101 58 58 58 30 30 30 14 14 14
45737 - 6 6 6 0 0 0 0 0 0 0 0 0
45738 - 0 0 0 0 0 0 0 0 0 0 0 0
45739 - 0 0 0 0 0 0 0 0 0 0 0 0
45740 - 0 0 0 0 0 0 0 0 0 10 10 10
45741 - 30 30 30 74 74 74 174 135 50 216 158 10
45742 -236 178 12 246 190 14 246 190 14 246 190 14
45743 -246 190 14 246 190 14 246 190 14 246 190 14
45744 -246 190 14 246 190 14 246 190 14 246 190 14
45745 -246 190 14 246 190 14 241 196 14 226 184 13
45746 - 61 42 6 2 2 6 2 2 6 2 2 6
45747 - 22 22 22 238 238 238 253 253 253 253 253 253
45748 -253 253 253 253 253 253 253 253 253 253 253 253
45749 -253 253 253 253 253 253 253 253 253 253 253 253
45750 -253 253 253 253 253 253 253 253 253 253 253 253
45751 -253 253 253 226 226 226 187 187 187 180 133 36
45752 -216 158 10 236 178 12 239 182 13 236 178 12
45753 -230 174 11 226 170 11 226 170 11 230 174 11
45754 -236 178 12 242 186 14 246 190 14 246 190 14
45755 -246 190 14 246 190 14 246 186 14 239 182 13
45756 -206 162 42 106 106 106 66 66 66 34 34 34
45757 - 14 14 14 6 6 6 0 0 0 0 0 0
45758 - 0 0 0 0 0 0 0 0 0 0 0 0
45759 - 0 0 0 0 0 0 0 0 0 0 0 0
45760 - 0 0 0 0 0 0 0 0 0 6 6 6
45761 - 26 26 26 70 70 70 163 133 67 213 154 11
45762 -236 178 12 246 190 14 246 190 14 246 190 14
45763 -246 190 14 246 190 14 246 190 14 246 190 14
45764 -246 190 14 246 190 14 246 190 14 246 190 14
45765 -246 190 14 246 190 14 246 190 14 241 196 14
45766 -190 146 13 18 14 6 2 2 6 2 2 6
45767 - 46 46 46 246 246 246 253 253 253 253 253 253
45768 -253 253 253 253 253 253 253 253 253 253 253 253
45769 -253 253 253 253 253 253 253 253 253 253 253 253
45770 -253 253 253 253 253 253 253 253 253 253 253 253
45771 -253 253 253 221 221 221 86 86 86 156 107 11
45772 -216 158 10 236 178 12 242 186 14 246 186 14
45773 -242 186 14 239 182 13 239 182 13 242 186 14
45774 -242 186 14 246 186 14 246 190 14 246 190 14
45775 -246 190 14 246 190 14 246 190 14 246 190 14
45776 -242 186 14 225 175 15 142 122 72 66 66 66
45777 - 30 30 30 10 10 10 0 0 0 0 0 0
45778 - 0 0 0 0 0 0 0 0 0 0 0 0
45779 - 0 0 0 0 0 0 0 0 0 0 0 0
45780 - 0 0 0 0 0 0 0 0 0 6 6 6
45781 - 26 26 26 70 70 70 163 133 67 210 150 10
45782 -236 178 12 246 190 14 246 190 14 246 190 14
45783 -246 190 14 246 190 14 246 190 14 246 190 14
45784 -246 190 14 246 190 14 246 190 14 246 190 14
45785 -246 190 14 246 190 14 246 190 14 246 190 14
45786 -232 195 16 121 92 8 34 34 34 106 106 106
45787 -221 221 221 253 253 253 253 253 253 253 253 253
45788 -253 253 253 253 253 253 253 253 253 253 253 253
45789 -253 253 253 253 253 253 253 253 253 253 253 253
45790 -253 253 253 253 253 253 253 253 253 253 253 253
45791 -242 242 242 82 82 82 18 14 6 163 110 8
45792 -216 158 10 236 178 12 242 186 14 246 190 14
45793 -246 190 14 246 190 14 246 190 14 246 190 14
45794 -246 190 14 246 190 14 246 190 14 246 190 14
45795 -246 190 14 246 190 14 246 190 14 246 190 14
45796 -246 190 14 246 190 14 242 186 14 163 133 67
45797 - 46 46 46 18 18 18 6 6 6 0 0 0
45798 - 0 0 0 0 0 0 0 0 0 0 0 0
45799 - 0 0 0 0 0 0 0 0 0 0 0 0
45800 - 0 0 0 0 0 0 0 0 0 10 10 10
45801 - 30 30 30 78 78 78 163 133 67 210 150 10
45802 -236 178 12 246 186 14 246 190 14 246 190 14
45803 -246 190 14 246 190 14 246 190 14 246 190 14
45804 -246 190 14 246 190 14 246 190 14 246 190 14
45805 -246 190 14 246 190 14 246 190 14 246 190 14
45806 -241 196 14 215 174 15 190 178 144 253 253 253
45807 -253 253 253 253 253 253 253 253 253 253 253 253
45808 -253 253 253 253 253 253 253 253 253 253 253 253
45809 -253 253 253 253 253 253 253 253 253 253 253 253
45810 -253 253 253 253 253 253 253 253 253 218 218 218
45811 - 58 58 58 2 2 6 22 18 6 167 114 7
45812 -216 158 10 236 178 12 246 186 14 246 190 14
45813 -246 190 14 246 190 14 246 190 14 246 190 14
45814 -246 190 14 246 190 14 246 190 14 246 190 14
45815 -246 190 14 246 190 14 246 190 14 246 190 14
45816 -246 190 14 246 186 14 242 186 14 190 150 46
45817 - 54 54 54 22 22 22 6 6 6 0 0 0
45818 - 0 0 0 0 0 0 0 0 0 0 0 0
45819 - 0 0 0 0 0 0 0 0 0 0 0 0
45820 - 0 0 0 0 0 0 0 0 0 14 14 14
45821 - 38 38 38 86 86 86 180 133 36 213 154 11
45822 -236 178 12 246 186 14 246 190 14 246 190 14
45823 -246 190 14 246 190 14 246 190 14 246 190 14
45824 -246 190 14 246 190 14 246 190 14 246 190 14
45825 -246 190 14 246 190 14 246 190 14 246 190 14
45826 -246 190 14 232 195 16 190 146 13 214 214 214
45827 -253 253 253 253 253 253 253 253 253 253 253 253
45828 -253 253 253 253 253 253 253 253 253 253 253 253
45829 -253 253 253 253 253 253 253 253 253 253 253 253
45830 -253 253 253 250 250 250 170 170 170 26 26 26
45831 - 2 2 6 2 2 6 37 26 9 163 110 8
45832 -219 162 10 239 182 13 246 186 14 246 190 14
45833 -246 190 14 246 190 14 246 190 14 246 190 14
45834 -246 190 14 246 190 14 246 190 14 246 190 14
45835 -246 190 14 246 190 14 246 190 14 246 190 14
45836 -246 186 14 236 178 12 224 166 10 142 122 72
45837 - 46 46 46 18 18 18 6 6 6 0 0 0
45838 - 0 0 0 0 0 0 0 0 0 0 0 0
45839 - 0 0 0 0 0 0 0 0 0 0 0 0
45840 - 0 0 0 0 0 0 6 6 6 18 18 18
45841 - 50 50 50 109 106 95 192 133 9 224 166 10
45842 -242 186 14 246 190 14 246 190 14 246 190 14
45843 -246 190 14 246 190 14 246 190 14 246 190 14
45844 -246 190 14 246 190 14 246 190 14 246 190 14
45845 -246 190 14 246 190 14 246 190 14 246 190 14
45846 -242 186 14 226 184 13 210 162 10 142 110 46
45847 -226 226 226 253 253 253 253 253 253 253 253 253
45848 -253 253 253 253 253 253 253 253 253 253 253 253
45849 -253 253 253 253 253 253 253 253 253 253 253 253
45850 -198 198 198 66 66 66 2 2 6 2 2 6
45851 - 2 2 6 2 2 6 50 34 6 156 107 11
45852 -219 162 10 239 182 13 246 186 14 246 190 14
45853 -246 190 14 246 190 14 246 190 14 246 190 14
45854 -246 190 14 246 190 14 246 190 14 246 190 14
45855 -246 190 14 246 190 14 246 190 14 242 186 14
45856 -234 174 13 213 154 11 154 122 46 66 66 66
45857 - 30 30 30 10 10 10 0 0 0 0 0 0
45858 - 0 0 0 0 0 0 0 0 0 0 0 0
45859 - 0 0 0 0 0 0 0 0 0 0 0 0
45860 - 0 0 0 0 0 0 6 6 6 22 22 22
45861 - 58 58 58 154 121 60 206 145 10 234 174 13
45862 -242 186 14 246 186 14 246 190 14 246 190 14
45863 -246 190 14 246 190 14 246 190 14 246 190 14
45864 -246 190 14 246 190 14 246 190 14 246 190 14
45865 -246 190 14 246 190 14 246 190 14 246 190 14
45866 -246 186 14 236 178 12 210 162 10 163 110 8
45867 - 61 42 6 138 138 138 218 218 218 250 250 250
45868 -253 253 253 253 253 253 253 253 253 250 250 250
45869 -242 242 242 210 210 210 144 144 144 66 66 66
45870 - 6 6 6 2 2 6 2 2 6 2 2 6
45871 - 2 2 6 2 2 6 61 42 6 163 110 8
45872 -216 158 10 236 178 12 246 190 14 246 190 14
45873 -246 190 14 246 190 14 246 190 14 246 190 14
45874 -246 190 14 246 190 14 246 190 14 246 190 14
45875 -246 190 14 239 182 13 230 174 11 216 158 10
45876 -190 142 34 124 112 88 70 70 70 38 38 38
45877 - 18 18 18 6 6 6 0 0 0 0 0 0
45878 - 0 0 0 0 0 0 0 0 0 0 0 0
45879 - 0 0 0 0 0 0 0 0 0 0 0 0
45880 - 0 0 0 0 0 0 6 6 6 22 22 22
45881 - 62 62 62 168 124 44 206 145 10 224 166 10
45882 -236 178 12 239 182 13 242 186 14 242 186 14
45883 -246 186 14 246 190 14 246 190 14 246 190 14
45884 -246 190 14 246 190 14 246 190 14 246 190 14
45885 -246 190 14 246 190 14 246 190 14 246 190 14
45886 -246 190 14 236 178 12 216 158 10 175 118 6
45887 - 80 54 7 2 2 6 6 6 6 30 30 30
45888 - 54 54 54 62 62 62 50 50 50 38 38 38
45889 - 14 14 14 2 2 6 2 2 6 2 2 6
45890 - 2 2 6 2 2 6 2 2 6 2 2 6
45891 - 2 2 6 6 6 6 80 54 7 167 114 7
45892 -213 154 11 236 178 12 246 190 14 246 190 14
45893 -246 190 14 246 190 14 246 190 14 246 190 14
45894 -246 190 14 242 186 14 239 182 13 239 182 13
45895 -230 174 11 210 150 10 174 135 50 124 112 88
45896 - 82 82 82 54 54 54 34 34 34 18 18 18
45897 - 6 6 6 0 0 0 0 0 0 0 0 0
45898 - 0 0 0 0 0 0 0 0 0 0 0 0
45899 - 0 0 0 0 0 0 0 0 0 0 0 0
45900 - 0 0 0 0 0 0 6 6 6 18 18 18
45901 - 50 50 50 158 118 36 192 133 9 200 144 11
45902 -216 158 10 219 162 10 224 166 10 226 170 11
45903 -230 174 11 236 178 12 239 182 13 239 182 13
45904 -242 186 14 246 186 14 246 190 14 246 190 14
45905 -246 190 14 246 190 14 246 190 14 246 190 14
45906 -246 186 14 230 174 11 210 150 10 163 110 8
45907 -104 69 6 10 10 10 2 2 6 2 2 6
45908 - 2 2 6 2 2 6 2 2 6 2 2 6
45909 - 2 2 6 2 2 6 2 2 6 2 2 6
45910 - 2 2 6 2 2 6 2 2 6 2 2 6
45911 - 2 2 6 6 6 6 91 60 6 167 114 7
45912 -206 145 10 230 174 11 242 186 14 246 190 14
45913 -246 190 14 246 190 14 246 186 14 242 186 14
45914 -239 182 13 230 174 11 224 166 10 213 154 11
45915 -180 133 36 124 112 88 86 86 86 58 58 58
45916 - 38 38 38 22 22 22 10 10 10 6 6 6
45917 - 0 0 0 0 0 0 0 0 0 0 0 0
45918 - 0 0 0 0 0 0 0 0 0 0 0 0
45919 - 0 0 0 0 0 0 0 0 0 0 0 0
45920 - 0 0 0 0 0 0 0 0 0 14 14 14
45921 - 34 34 34 70 70 70 138 110 50 158 118 36
45922 -167 114 7 180 123 7 192 133 9 197 138 11
45923 -200 144 11 206 145 10 213 154 11 219 162 10
45924 -224 166 10 230 174 11 239 182 13 242 186 14
45925 -246 186 14 246 186 14 246 186 14 246 186 14
45926 -239 182 13 216 158 10 185 133 11 152 99 6
45927 -104 69 6 18 14 6 2 2 6 2 2 6
45928 - 2 2 6 2 2 6 2 2 6 2 2 6
45929 - 2 2 6 2 2 6 2 2 6 2 2 6
45930 - 2 2 6 2 2 6 2 2 6 2 2 6
45931 - 2 2 6 6 6 6 80 54 7 152 99 6
45932 -192 133 9 219 162 10 236 178 12 239 182 13
45933 -246 186 14 242 186 14 239 182 13 236 178 12
45934 -224 166 10 206 145 10 192 133 9 154 121 60
45935 - 94 94 94 62 62 62 42 42 42 22 22 22
45936 - 14 14 14 6 6 6 0 0 0 0 0 0
45937 - 0 0 0 0 0 0 0 0 0 0 0 0
45938 - 0 0 0 0 0 0 0 0 0 0 0 0
45939 - 0 0 0 0 0 0 0 0 0 0 0 0
45940 - 0 0 0 0 0 0 0 0 0 6 6 6
45941 - 18 18 18 34 34 34 58 58 58 78 78 78
45942 -101 98 89 124 112 88 142 110 46 156 107 11
45943 -163 110 8 167 114 7 175 118 6 180 123 7
45944 -185 133 11 197 138 11 210 150 10 219 162 10
45945 -226 170 11 236 178 12 236 178 12 234 174 13
45946 -219 162 10 197 138 11 163 110 8 130 83 6
45947 - 91 60 6 10 10 10 2 2 6 2 2 6
45948 - 18 18 18 38 38 38 38 38 38 38 38 38
45949 - 38 38 38 38 38 38 38 38 38 38 38 38
45950 - 38 38 38 38 38 38 26 26 26 2 2 6
45951 - 2 2 6 6 6 6 70 47 6 137 92 6
45952 -175 118 6 200 144 11 219 162 10 230 174 11
45953 -234 174 13 230 174 11 219 162 10 210 150 10
45954 -192 133 9 163 110 8 124 112 88 82 82 82
45955 - 50 50 50 30 30 30 14 14 14 6 6 6
45956 - 0 0 0 0 0 0 0 0 0 0 0 0
45957 - 0 0 0 0 0 0 0 0 0 0 0 0
45958 - 0 0 0 0 0 0 0 0 0 0 0 0
45959 - 0 0 0 0 0 0 0 0 0 0 0 0
45960 - 0 0 0 0 0 0 0 0 0 0 0 0
45961 - 6 6 6 14 14 14 22 22 22 34 34 34
45962 - 42 42 42 58 58 58 74 74 74 86 86 86
45963 -101 98 89 122 102 70 130 98 46 121 87 25
45964 -137 92 6 152 99 6 163 110 8 180 123 7
45965 -185 133 11 197 138 11 206 145 10 200 144 11
45966 -180 123 7 156 107 11 130 83 6 104 69 6
45967 - 50 34 6 54 54 54 110 110 110 101 98 89
45968 - 86 86 86 82 82 82 78 78 78 78 78 78
45969 - 78 78 78 78 78 78 78 78 78 78 78 78
45970 - 78 78 78 82 82 82 86 86 86 94 94 94
45971 -106 106 106 101 101 101 86 66 34 124 80 6
45972 -156 107 11 180 123 7 192 133 9 200 144 11
45973 -206 145 10 200 144 11 192 133 9 175 118 6
45974 -139 102 15 109 106 95 70 70 70 42 42 42
45975 - 22 22 22 10 10 10 0 0 0 0 0 0
45976 - 0 0 0 0 0 0 0 0 0 0 0 0
45977 - 0 0 0 0 0 0 0 0 0 0 0 0
45978 - 0 0 0 0 0 0 0 0 0 0 0 0
45979 - 0 0 0 0 0 0 0 0 0 0 0 0
45980 - 0 0 0 0 0 0 0 0 0 0 0 0
45981 - 0 0 0 0 0 0 6 6 6 10 10 10
45982 - 14 14 14 22 22 22 30 30 30 38 38 38
45983 - 50 50 50 62 62 62 74 74 74 90 90 90
45984 -101 98 89 112 100 78 121 87 25 124 80 6
45985 -137 92 6 152 99 6 152 99 6 152 99 6
45986 -138 86 6 124 80 6 98 70 6 86 66 30
45987 -101 98 89 82 82 82 58 58 58 46 46 46
45988 - 38 38 38 34 34 34 34 34 34 34 34 34
45989 - 34 34 34 34 34 34 34 34 34 34 34 34
45990 - 34 34 34 34 34 34 38 38 38 42 42 42
45991 - 54 54 54 82 82 82 94 86 76 91 60 6
45992 -134 86 6 156 107 11 167 114 7 175 118 6
45993 -175 118 6 167 114 7 152 99 6 121 87 25
45994 -101 98 89 62 62 62 34 34 34 18 18 18
45995 - 6 6 6 0 0 0 0 0 0 0 0 0
45996 - 0 0 0 0 0 0 0 0 0 0 0 0
45997 - 0 0 0 0 0 0 0 0 0 0 0 0
45998 - 0 0 0 0 0 0 0 0 0 0 0 0
45999 - 0 0 0 0 0 0 0 0 0 0 0 0
46000 - 0 0 0 0 0 0 0 0 0 0 0 0
46001 - 0 0 0 0 0 0 0 0 0 0 0 0
46002 - 0 0 0 6 6 6 6 6 6 10 10 10
46003 - 18 18 18 22 22 22 30 30 30 42 42 42
46004 - 50 50 50 66 66 66 86 86 86 101 98 89
46005 -106 86 58 98 70 6 104 69 6 104 69 6
46006 -104 69 6 91 60 6 82 62 34 90 90 90
46007 - 62 62 62 38 38 38 22 22 22 14 14 14
46008 - 10 10 10 10 10 10 10 10 10 10 10 10
46009 - 10 10 10 10 10 10 6 6 6 10 10 10
46010 - 10 10 10 10 10 10 10 10 10 14 14 14
46011 - 22 22 22 42 42 42 70 70 70 89 81 66
46012 - 80 54 7 104 69 6 124 80 6 137 92 6
46013 -134 86 6 116 81 8 100 82 52 86 86 86
46014 - 58 58 58 30 30 30 14 14 14 6 6 6
46015 - 0 0 0 0 0 0 0 0 0 0 0 0
46016 - 0 0 0 0 0 0 0 0 0 0 0 0
46017 - 0 0 0 0 0 0 0 0 0 0 0 0
46018 - 0 0 0 0 0 0 0 0 0 0 0 0
46019 - 0 0 0 0 0 0 0 0 0 0 0 0
46020 - 0 0 0 0 0 0 0 0 0 0 0 0
46021 - 0 0 0 0 0 0 0 0 0 0 0 0
46022 - 0 0 0 0 0 0 0 0 0 0 0 0
46023 - 0 0 0 6 6 6 10 10 10 14 14 14
46024 - 18 18 18 26 26 26 38 38 38 54 54 54
46025 - 70 70 70 86 86 86 94 86 76 89 81 66
46026 - 89 81 66 86 86 86 74 74 74 50 50 50
46027 - 30 30 30 14 14 14 6 6 6 0 0 0
46028 - 0 0 0 0 0 0 0 0 0 0 0 0
46029 - 0 0 0 0 0 0 0 0 0 0 0 0
46030 - 0 0 0 0 0 0 0 0 0 0 0 0
46031 - 6 6 6 18 18 18 34 34 34 58 58 58
46032 - 82 82 82 89 81 66 89 81 66 89 81 66
46033 - 94 86 66 94 86 76 74 74 74 50 50 50
46034 - 26 26 26 14 14 14 6 6 6 0 0 0
46035 - 0 0 0 0 0 0 0 0 0 0 0 0
46036 - 0 0 0 0 0 0 0 0 0 0 0 0
46037 - 0 0 0 0 0 0 0 0 0 0 0 0
46038 - 0 0 0 0 0 0 0 0 0 0 0 0
46039 - 0 0 0 0 0 0 0 0 0 0 0 0
46040 - 0 0 0 0 0 0 0 0 0 0 0 0
46041 - 0 0 0 0 0 0 0 0 0 0 0 0
46042 - 0 0 0 0 0 0 0 0 0 0 0 0
46043 - 0 0 0 0 0 0 0 0 0 0 0 0
46044 - 6 6 6 6 6 6 14 14 14 18 18 18
46045 - 30 30 30 38 38 38 46 46 46 54 54 54
46046 - 50 50 50 42 42 42 30 30 30 18 18 18
46047 - 10 10 10 0 0 0 0 0 0 0 0 0
46048 - 0 0 0 0 0 0 0 0 0 0 0 0
46049 - 0 0 0 0 0 0 0 0 0 0 0 0
46050 - 0 0 0 0 0 0 0 0 0 0 0 0
46051 - 0 0 0 6 6 6 14 14 14 26 26 26
46052 - 38 38 38 50 50 50 58 58 58 58 58 58
46053 - 54 54 54 42 42 42 30 30 30 18 18 18
46054 - 10 10 10 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 0 0 0 0 0 0 0 0 0
46057 - 0 0 0 0 0 0 0 0 0 0 0 0
46058 - 0 0 0 0 0 0 0 0 0 0 0 0
46059 - 0 0 0 0 0 0 0 0 0 0 0 0
46060 - 0 0 0 0 0 0 0 0 0 0 0 0
46061 - 0 0 0 0 0 0 0 0 0 0 0 0
46062 - 0 0 0 0 0 0 0 0 0 0 0 0
46063 - 0 0 0 0 0 0 0 0 0 0 0 0
46064 - 0 0 0 0 0 0 0 0 0 6 6 6
46065 - 6 6 6 10 10 10 14 14 14 18 18 18
46066 - 18 18 18 14 14 14 10 10 10 6 6 6
46067 - 0 0 0 0 0 0 0 0 0 0 0 0
46068 - 0 0 0 0 0 0 0 0 0 0 0 0
46069 - 0 0 0 0 0 0 0 0 0 0 0 0
46070 - 0 0 0 0 0 0 0 0 0 0 0 0
46071 - 0 0 0 0 0 0 0 0 0 6 6 6
46072 - 14 14 14 18 18 18 22 22 22 22 22 22
46073 - 18 18 18 14 14 14 10 10 10 6 6 6
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 - 0 0 0 0 0 0 0 0 0 0 0 0
46077 - 0 0 0 0 0 0 0 0 0 0 0 0
46078 - 0 0 0 0 0 0 0 0 0 0 0 0
46079 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46080 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46085 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46086 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46089 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46090 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46091 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46092 +4 4 4 4 4 4
46093 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46094 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46096 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46097 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46099 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46100 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46103 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46104 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46105 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46106 +4 4 4 4 4 4
46107 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46108 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46110 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46111 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46112 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46113 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46114 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46117 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46118 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46119 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46120 +4 4 4 4 4 4
46121 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46122 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46123 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46124 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46125 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46126 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46127 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46128 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46131 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46132 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46133 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46134 +4 4 4 4 4 4
46135 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46136 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46137 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46138 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46139 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46140 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46141 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46142 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46145 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46146 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46147 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46148 +4 4 4 4 4 4
46149 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46150 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46151 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46152 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46153 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46154 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46155 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46156 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46158 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46159 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46160 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46161 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46162 +4 4 4 4 4 4
46163 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46164 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46165 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46166 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46167 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46168 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46169 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46170 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46172 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46173 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46174 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46175 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46176 +4 4 4 4 4 4
46177 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46178 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46179 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46180 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46181 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46182 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46183 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46184 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46186 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46187 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46188 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46189 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46190 +4 4 4 4 4 4
46191 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46192 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46193 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46194 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46195 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46196 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46197 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46198 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46200 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46201 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46202 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46203 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46204 +4 4 4 4 4 4
46205 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46206 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46207 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46208 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46209 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46210 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46211 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46212 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46213 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46214 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46215 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46216 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46217 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46218 +4 4 4 4 4 4
46219 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46220 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46221 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46222 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46223 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46224 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46225 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46226 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46227 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46228 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46229 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46230 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46231 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46232 +4 4 4 4 4 4
46233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46234 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46235 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46236 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46237 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46238 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46239 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46240 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46241 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46242 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46243 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46244 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46245 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46246 +4 4 4 4 4 4
46247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46248 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46249 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46250 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46251 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46252 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46253 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46254 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46255 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46256 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46257 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46258 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46259 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46260 +4 4 4 4 4 4
46261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46263 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46264 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46265 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46266 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46267 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46268 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46269 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46270 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46271 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46272 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46273 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46274 +4 4 4 4 4 4
46275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46277 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46278 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46279 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46280 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46281 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46282 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46283 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46284 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46285 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46286 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46287 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46288 +4 4 4 4 4 4
46289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46291 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46292 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46293 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46294 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46295 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46296 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46297 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46298 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46299 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46300 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46301 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46302 +4 4 4 4 4 4
46303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46304 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46305 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46306 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46307 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46308 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46309 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46310 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46311 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46312 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46313 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46314 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46315 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46316 +4 4 4 4 4 4
46317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46318 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46319 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46320 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46321 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46322 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46323 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46324 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46325 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46326 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46327 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46328 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46329 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46330 +0 0 0 4 4 4
46331 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46332 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46333 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46334 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46335 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46336 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46337 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46338 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46339 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46340 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46341 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46342 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46343 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46344 +2 0 0 0 0 0
46345 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46346 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46347 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46348 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46349 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46350 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46351 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46352 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46353 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46354 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46355 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46356 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46357 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46358 +37 38 37 0 0 0
46359 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46360 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46361 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46362 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46363 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46364 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46365 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46366 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46367 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46368 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46369 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46370 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46371 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46372 +85 115 134 4 0 0
46373 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46374 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46375 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46376 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46377 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46378 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46379 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46380 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46381 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46382 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46383 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46384 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46385 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46386 +60 73 81 4 0 0
46387 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46388 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46389 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46390 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46391 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46392 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46393 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46394 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46395 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46396 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46397 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46398 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46399 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46400 +16 19 21 4 0 0
46401 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46402 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46403 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46404 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46405 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46406 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46407 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46408 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46409 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46410 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46411 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46412 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46413 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46414 +4 0 0 4 3 3
46415 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46416 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46417 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46419 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46420 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46421 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46422 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46423 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46424 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46425 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46426 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46427 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46428 +3 2 2 4 4 4
46429 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46430 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46431 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46432 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46433 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46434 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46435 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46436 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46437 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46438 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46439 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46440 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46441 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46442 +4 4 4 4 4 4
46443 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46444 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46445 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46446 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46447 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46448 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46449 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46450 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46451 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46452 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46453 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46454 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46455 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46456 +4 4 4 4 4 4
46457 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46458 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46459 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46460 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46461 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46462 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46463 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
46464 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
46465 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
46466 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
46467 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
46468 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
46469 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
46470 +5 5 5 5 5 5
46471 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
46472 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
46473 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
46474 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
46475 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
46476 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46477 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
46478 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
46479 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
46480 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
46481 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
46482 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
46483 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46484 +5 5 5 4 4 4
46485 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
46486 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
46487 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
46488 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
46489 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46490 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
46491 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
46492 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
46493 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
46494 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
46495 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
46496 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46498 +4 4 4 4 4 4
46499 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
46500 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
46501 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
46502 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
46503 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
46504 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46505 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46506 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
46507 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
46508 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
46509 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
46510 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
46511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46512 +4 4 4 4 4 4
46513 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
46514 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
46515 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
46516 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
46517 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46518 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
46519 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
46520 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
46521 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
46522 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
46523 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
46524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46526 +4 4 4 4 4 4
46527 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
46528 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
46529 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
46530 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
46531 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46532 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46533 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46534 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
46535 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
46536 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
46537 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
46538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46540 +4 4 4 4 4 4
46541 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
46542 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
46543 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
46544 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
46545 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46546 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
46547 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46548 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
46549 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
46550 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
46551 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46554 +4 4 4 4 4 4
46555 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
46556 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
46557 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
46558 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
46559 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46560 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
46561 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
46562 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
46563 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
46564 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
46565 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
46566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46568 +4 4 4 4 4 4
46569 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
46570 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
46571 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
46572 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
46573 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46574 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
46575 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
46576 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
46577 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
46578 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
46579 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
46580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46582 +4 4 4 4 4 4
46583 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
46584 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
46585 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
46586 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46587 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
46588 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
46589 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
46590 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
46591 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
46592 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
46593 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46596 +4 4 4 4 4 4
46597 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
46598 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
46599 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
46600 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46601 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46602 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
46603 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
46604 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
46605 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
46606 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
46607 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46610 +4 4 4 4 4 4
46611 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
46612 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
46613 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46614 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46615 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46616 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
46617 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
46618 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
46619 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
46620 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
46621 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46624 +4 4 4 4 4 4
46625 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
46626 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
46627 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46628 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46629 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46630 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
46631 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
46632 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
46633 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46634 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46635 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46638 +4 4 4 4 4 4
46639 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46640 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
46641 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46642 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
46643 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
46644 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
46645 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
46646 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
46647 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46648 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46649 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46652 +4 4 4 4 4 4
46653 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46654 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
46655 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46656 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
46657 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46658 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
46659 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
46660 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
46661 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46662 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46663 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46666 +4 4 4 4 4 4
46667 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
46668 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
46669 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46670 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
46671 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
46672 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
46673 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
46674 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
46675 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46676 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46677 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46680 +4 4 4 4 4 4
46681 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
46682 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
46683 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46684 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
46685 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
46686 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
46687 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
46688 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
46689 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46690 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46691 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46694 +4 4 4 4 4 4
46695 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46696 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
46697 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46698 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
46699 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
46700 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
46701 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
46702 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
46703 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46704 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46705 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46708 +4 4 4 4 4 4
46709 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
46710 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
46711 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46712 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
46713 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
46714 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
46715 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
46716 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
46717 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
46718 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46719 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46722 +4 4 4 4 4 4
46723 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46724 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
46725 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
46726 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
46727 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
46728 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
46729 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
46730 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
46731 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46732 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46733 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46736 +4 4 4 4 4 4
46737 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46738 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
46739 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46740 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
46741 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
46742 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
46743 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
46744 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
46745 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46746 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46747 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46750 +4 4 4 4 4 4
46751 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46752 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
46753 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
46754 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
46755 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
46756 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
46757 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46758 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
46759 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46760 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46761 +0 0 0 3 3 3 5 5 5 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
46765 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46766 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
46767 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
46768 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46769 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
46770 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
46771 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46772 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
46773 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46774 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46775 +0 0 0 3 3 3 5 5 5 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
46779 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46780 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
46781 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
46782 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
46783 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
46784 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
46785 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
46786 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
46787 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
46788 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46789 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46792 +4 4 4 4 4 4
46793 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46794 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
46795 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
46796 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
46797 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
46798 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
46799 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
46800 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
46801 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
46802 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46803 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46806 +4 4 4 4 4 4
46807 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
46808 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
46809 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
46810 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
46811 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46812 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
46813 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
46814 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
46815 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
46816 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46817 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46820 +4 4 4 4 4 4
46821 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46822 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
46823 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
46824 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
46825 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
46826 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
46827 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
46828 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
46829 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
46830 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46831 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46834 +4 4 4 4 4 4
46835 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
46836 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
46837 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
46838 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
46839 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
46840 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
46841 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
46842 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
46843 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
46844 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
46845 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46848 +4 4 4 4 4 4
46849 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
46850 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46851 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
46852 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
46853 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
46854 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
46855 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
46856 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
46857 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
46858 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
46859 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46862 +4 4 4 4 4 4
46863 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
46864 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46865 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
46866 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
46867 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
46868 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
46869 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46870 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
46871 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
46872 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
46873 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46876 +4 4 4 4 4 4
46877 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
46878 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
46879 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
46880 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
46881 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
46882 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
46883 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
46884 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
46885 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
46886 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
46887 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46890 +4 4 4 4 4 4
46891 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
46892 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
46893 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
46894 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
46895 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
46896 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
46897 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
46898 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
46899 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
46900 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
46901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46904 +4 4 4 4 4 4
46905 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46906 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
46907 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
46908 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
46909 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
46910 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
46911 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
46912 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
46913 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
46914 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
46915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46918 +4 4 4 4 4 4
46919 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
46920 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
46921 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
46922 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
46923 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
46924 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
46925 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
46926 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
46927 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
46928 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46932 +4 4 4 4 4 4
46933 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
46934 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
46935 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
46936 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
46937 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
46938 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
46939 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
46940 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
46941 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46942 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46946 +4 4 4 4 4 4
46947 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
46948 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46949 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
46950 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
46951 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
46952 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
46953 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
46954 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
46955 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
46956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46960 +4 4 4 4 4 4
46961 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
46962 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
46963 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
46964 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
46965 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
46966 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
46967 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
46968 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
46969 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
46970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46974 +4 4 4 4 4 4
46975 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
46976 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
46977 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
46978 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
46979 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
46980 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
46981 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
46982 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
46983 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46984 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46988 +4 4 4 4 4 4
46989 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
46990 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
46991 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
46992 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
46993 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
46994 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
46995 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
46996 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
46997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46998 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47002 +4 4 4 4 4 4
47003 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47004 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47005 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47006 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47007 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47008 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47009 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47010 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47016 +4 4 4 4 4 4
47017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47018 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47019 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47020 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47021 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47022 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47023 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47024 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47026 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47030 +4 4 4 4 4 4
47031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47032 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47033 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47034 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47035 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47036 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47037 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47038 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47044 +4 4 4 4 4 4
47045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47046 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47047 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47048 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47049 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47050 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47051 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47052 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47054 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47057 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47058 +4 4 4 4 4 4
47059 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47061 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47062 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47063 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47064 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47065 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47066 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47067 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47068 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47070 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47071 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47072 +4 4 4 4 4 4
47073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47075 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47076 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47077 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47078 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47079 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47080 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47085 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47086 +4 4 4 4 4 4
47087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47089 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47090 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47091 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47092 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47093 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47094 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47096 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47097 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47099 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47100 +4 4 4 4 4 4
47101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47103 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47104 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47105 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47106 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47107 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47108 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47110 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47111 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47112 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47113 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47114 +4 4 4 4 4 4
47115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47117 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47118 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47119 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47120 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47121 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47122 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47123 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47124 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47125 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47126 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47127 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47128 +4 4 4 4 4 4
47129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47131 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47132 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47133 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47134 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47135 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47136 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47137 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47138 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47139 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47140 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47141 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47142 +4 4 4 4 4 4
47143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47145 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47146 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47147 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47148 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47149 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47150 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47151 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47152 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47153 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47154 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47155 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47156 +4 4 4 4 4 4
47157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47158 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47159 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47160 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47161 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47162 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47163 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47164 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47165 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47166 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47167 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47168 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47169 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47170 +4 4 4 4 4 4
47171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47172 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47173 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47174 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47175 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47176 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47177 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47178 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47179 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47180 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47181 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47182 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47183 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47184 +4 4 4 4 4 4
47185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47186 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47187 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47188 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47189 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47190 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47191 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47192 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47193 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47194 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47195 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47196 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47197 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47198 +4 4 4 4 4 4
47199 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47200 index fe92eed..106e085 100644
47201 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47202 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47203 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47204 struct mb862xxfb_par *par = info->par;
47205
47206 if (info->var.bits_per_pixel == 32) {
47207 - info->fbops->fb_fillrect = cfb_fillrect;
47208 - info->fbops->fb_copyarea = cfb_copyarea;
47209 - info->fbops->fb_imageblit = cfb_imageblit;
47210 + pax_open_kernel();
47211 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47212 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47213 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47214 + pax_close_kernel();
47215 } else {
47216 outreg(disp, GC_L0EM, 3);
47217 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47218 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47219 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47220 + pax_open_kernel();
47221 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47222 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47223 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47224 + pax_close_kernel();
47225 }
47226 outreg(draw, GDC_REG_DRAW_BASE, 0);
47227 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47228 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47229 index ff22871..b129bed 100644
47230 --- a/drivers/video/nvidia/nvidia.c
47231 +++ b/drivers/video/nvidia/nvidia.c
47232 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47233 info->fix.line_length = (info->var.xres_virtual *
47234 info->var.bits_per_pixel) >> 3;
47235 if (info->var.accel_flags) {
47236 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47237 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47238 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47239 - info->fbops->fb_sync = nvidiafb_sync;
47240 + pax_open_kernel();
47241 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47242 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47243 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47244 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47245 + pax_close_kernel();
47246 info->pixmap.scan_align = 4;
47247 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47248 info->flags |= FBINFO_READS_FAST;
47249 NVResetGraphics(info);
47250 } else {
47251 - info->fbops->fb_imageblit = cfb_imageblit;
47252 - info->fbops->fb_fillrect = cfb_fillrect;
47253 - info->fbops->fb_copyarea = cfb_copyarea;
47254 - info->fbops->fb_sync = NULL;
47255 + pax_open_kernel();
47256 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47257 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47258 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47259 + *(void **)&info->fbops->fb_sync = NULL;
47260 + pax_close_kernel();
47261 info->pixmap.scan_align = 1;
47262 info->flags |= FBINFO_HWACCEL_DISABLED;
47263 info->flags &= ~FBINFO_READS_FAST;
47264 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47265 info->pixmap.size = 8 * 1024;
47266 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47267
47268 - if (!hwcur)
47269 - info->fbops->fb_cursor = NULL;
47270 + if (!hwcur) {
47271 + pax_open_kernel();
47272 + *(void **)&info->fbops->fb_cursor = NULL;
47273 + pax_close_kernel();
47274 + }
47275
47276 info->var.accel_flags = (!noaccel);
47277
47278 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47279 index 76d9053..dec2bfd 100644
47280 --- a/drivers/video/s1d13xxxfb.c
47281 +++ b/drivers/video/s1d13xxxfb.c
47282 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47283
47284 switch(prod_id) {
47285 case S1D13506_PROD_ID: /* activate acceleration */
47286 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47287 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47288 + pax_open_kernel();
47289 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47290 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47291 + pax_close_kernel();
47292 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47293 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47294 break;
47295 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47296 index 97bd662..39fab85 100644
47297 --- a/drivers/video/smscufx.c
47298 +++ b/drivers/video/smscufx.c
47299 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47300 fb_deferred_io_cleanup(info);
47301 kfree(info->fbdefio);
47302 info->fbdefio = NULL;
47303 - info->fbops->fb_mmap = ufx_ops_mmap;
47304 + pax_open_kernel();
47305 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47306 + pax_close_kernel();
47307 }
47308
47309 pr_debug("released /dev/fb%d user=%d count=%d",
47310 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47311 index 86d449e..8e04dc5 100644
47312 --- a/drivers/video/udlfb.c
47313 +++ b/drivers/video/udlfb.c
47314 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47315 dlfb_urb_completion(urb);
47316
47317 error:
47318 - atomic_add(bytes_sent, &dev->bytes_sent);
47319 - atomic_add(bytes_identical, &dev->bytes_identical);
47320 - atomic_add(width*height*2, &dev->bytes_rendered);
47321 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47322 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47323 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47324 end_cycles = get_cycles();
47325 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47326 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47327 >> 10)), /* Kcycles */
47328 &dev->cpu_kcycles_used);
47329
47330 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47331 dlfb_urb_completion(urb);
47332
47333 error:
47334 - atomic_add(bytes_sent, &dev->bytes_sent);
47335 - atomic_add(bytes_identical, &dev->bytes_identical);
47336 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47337 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47338 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47339 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47340 end_cycles = get_cycles();
47341 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47342 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47343 >> 10)), /* Kcycles */
47344 &dev->cpu_kcycles_used);
47345 }
47346 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47347 fb_deferred_io_cleanup(info);
47348 kfree(info->fbdefio);
47349 info->fbdefio = NULL;
47350 - info->fbops->fb_mmap = dlfb_ops_mmap;
47351 + pax_open_kernel();
47352 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47353 + pax_close_kernel();
47354 }
47355
47356 pr_warn("released /dev/fb%d user=%d count=%d\n",
47357 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47358 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47359 struct dlfb_data *dev = fb_info->par;
47360 return snprintf(buf, PAGE_SIZE, "%u\n",
47361 - atomic_read(&dev->bytes_rendered));
47362 + atomic_read_unchecked(&dev->bytes_rendered));
47363 }
47364
47365 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47366 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47367 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47368 struct dlfb_data *dev = fb_info->par;
47369 return snprintf(buf, PAGE_SIZE, "%u\n",
47370 - atomic_read(&dev->bytes_identical));
47371 + atomic_read_unchecked(&dev->bytes_identical));
47372 }
47373
47374 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47375 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47376 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47377 struct dlfb_data *dev = fb_info->par;
47378 return snprintf(buf, PAGE_SIZE, "%u\n",
47379 - atomic_read(&dev->bytes_sent));
47380 + atomic_read_unchecked(&dev->bytes_sent));
47381 }
47382
47383 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47384 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47385 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47386 struct dlfb_data *dev = fb_info->par;
47387 return snprintf(buf, PAGE_SIZE, "%u\n",
47388 - atomic_read(&dev->cpu_kcycles_used));
47389 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47390 }
47391
47392 static ssize_t edid_show(
47393 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47394 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47395 struct dlfb_data *dev = fb_info->par;
47396
47397 - atomic_set(&dev->bytes_rendered, 0);
47398 - atomic_set(&dev->bytes_identical, 0);
47399 - atomic_set(&dev->bytes_sent, 0);
47400 - atomic_set(&dev->cpu_kcycles_used, 0);
47401 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47402 + atomic_set_unchecked(&dev->bytes_identical, 0);
47403 + atomic_set_unchecked(&dev->bytes_sent, 0);
47404 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47405
47406 return count;
47407 }
47408 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47409 index b75db01..ad2f34a 100644
47410 --- a/drivers/video/uvesafb.c
47411 +++ b/drivers/video/uvesafb.c
47412 @@ -19,6 +19,7 @@
47413 #include <linux/io.h>
47414 #include <linux/mutex.h>
47415 #include <linux/slab.h>
47416 +#include <linux/moduleloader.h>
47417 #include <video/edid.h>
47418 #include <video/uvesafb.h>
47419 #ifdef CONFIG_X86
47420 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47421 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47422 par->pmi_setpal = par->ypan = 0;
47423 } else {
47424 +
47425 +#ifdef CONFIG_PAX_KERNEXEC
47426 +#ifdef CONFIG_MODULES
47427 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47428 +#endif
47429 + if (!par->pmi_code) {
47430 + par->pmi_setpal = par->ypan = 0;
47431 + return 0;
47432 + }
47433 +#endif
47434 +
47435 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47436 + task->t.regs.edi);
47437 +
47438 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47439 + pax_open_kernel();
47440 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47441 + pax_close_kernel();
47442 +
47443 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47444 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47445 +#else
47446 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47447 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47448 +#endif
47449 +
47450 printk(KERN_INFO "uvesafb: protected mode interface info at "
47451 "%04x:%04x\n",
47452 (u16)task->t.regs.es, (u16)task->t.regs.edi);
47453 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
47454 par->ypan = ypan;
47455
47456 if (par->pmi_setpal || par->ypan) {
47457 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
47458 if (__supported_pte_mask & _PAGE_NX) {
47459 par->pmi_setpal = par->ypan = 0;
47460 printk(KERN_WARNING "uvesafb: NX protection is actively."
47461 "We have better not to use the PMI.\n");
47462 - } else {
47463 + } else
47464 +#endif
47465 uvesafb_vbe_getpmi(task, par);
47466 - }
47467 }
47468 #else
47469 /* The protected mode interface is not available on non-x86. */
47470 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47471 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
47472
47473 /* Disable blanking if the user requested so. */
47474 - if (!blank)
47475 - info->fbops->fb_blank = NULL;
47476 + if (!blank) {
47477 + pax_open_kernel();
47478 + *(void **)&info->fbops->fb_blank = NULL;
47479 + pax_close_kernel();
47480 + }
47481
47482 /*
47483 * Find out how much IO memory is required for the mode with
47484 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47485 info->flags = FBINFO_FLAG_DEFAULT |
47486 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
47487
47488 - if (!par->ypan)
47489 - info->fbops->fb_pan_display = NULL;
47490 + if (!par->ypan) {
47491 + pax_open_kernel();
47492 + *(void **)&info->fbops->fb_pan_display = NULL;
47493 + pax_close_kernel();
47494 + }
47495 }
47496
47497 static void uvesafb_init_mtrr(struct fb_info *info)
47498 @@ -1836,6 +1866,11 @@ out:
47499 if (par->vbe_modes)
47500 kfree(par->vbe_modes);
47501
47502 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47503 + if (par->pmi_code)
47504 + module_free_exec(NULL, par->pmi_code);
47505 +#endif
47506 +
47507 framebuffer_release(info);
47508 return err;
47509 }
47510 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
47511 kfree(par->vbe_state_orig);
47512 if (par->vbe_state_saved)
47513 kfree(par->vbe_state_saved);
47514 +
47515 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47516 + if (par->pmi_code)
47517 + module_free_exec(NULL, par->pmi_code);
47518 +#endif
47519 +
47520 }
47521
47522 framebuffer_release(info);
47523 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
47524 index 501b340..d80aa17 100644
47525 --- a/drivers/video/vesafb.c
47526 +++ b/drivers/video/vesafb.c
47527 @@ -9,6 +9,7 @@
47528 */
47529
47530 #include <linux/module.h>
47531 +#include <linux/moduleloader.h>
47532 #include <linux/kernel.h>
47533 #include <linux/errno.h>
47534 #include <linux/string.h>
47535 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
47536 static int vram_total __initdata; /* Set total amount of memory */
47537 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
47538 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
47539 -static void (*pmi_start)(void) __read_mostly;
47540 -static void (*pmi_pal) (void) __read_mostly;
47541 +static void (*pmi_start)(void) __read_only;
47542 +static void (*pmi_pal) (void) __read_only;
47543 static int depth __read_mostly;
47544 static int vga_compat __read_mostly;
47545 /* --------------------------------------------------------------------- */
47546 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
47547 unsigned int size_vmode;
47548 unsigned int size_remap;
47549 unsigned int size_total;
47550 + void *pmi_code = NULL;
47551
47552 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
47553 return -ENODEV;
47554 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
47555 size_remap = size_total;
47556 vesafb_fix.smem_len = size_remap;
47557
47558 -#ifndef __i386__
47559 - screen_info.vesapm_seg = 0;
47560 -#endif
47561 -
47562 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
47563 printk(KERN_WARNING
47564 "vesafb: cannot reserve video memory at 0x%lx\n",
47565 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
47566 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
47567 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
47568
47569 +#ifdef __i386__
47570 +
47571 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47572 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
47573 + if (!pmi_code)
47574 +#elif !defined(CONFIG_PAX_KERNEXEC)
47575 + if (0)
47576 +#endif
47577 +
47578 +#endif
47579 + screen_info.vesapm_seg = 0;
47580 +
47581 if (screen_info.vesapm_seg) {
47582 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
47583 - screen_info.vesapm_seg,screen_info.vesapm_off);
47584 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
47585 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
47586 }
47587
47588 if (screen_info.vesapm_seg < 0xc000)
47589 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
47590
47591 if (ypan || pmi_setpal) {
47592 unsigned short *pmi_base;
47593 +
47594 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
47595 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
47596 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
47597 +
47598 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47599 + pax_open_kernel();
47600 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
47601 +#else
47602 + pmi_code = pmi_base;
47603 +#endif
47604 +
47605 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
47606 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
47607 +
47608 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47609 + pmi_start = ktva_ktla(pmi_start);
47610 + pmi_pal = ktva_ktla(pmi_pal);
47611 + pax_close_kernel();
47612 +#endif
47613 +
47614 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
47615 if (pmi_base[3]) {
47616 printk(KERN_INFO "vesafb: pmi: ports = ");
47617 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47618 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
47619 (ypan ? FBINFO_HWACCEL_YPAN : 0);
47620
47621 - if (!ypan)
47622 - info->fbops->fb_pan_display = NULL;
47623 + if (!ypan) {
47624 + pax_open_kernel();
47625 + *(void **)&info->fbops->fb_pan_display = NULL;
47626 + pax_close_kernel();
47627 + }
47628
47629 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
47630 err = -ENOMEM;
47631 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47632 info->node, info->fix.id);
47633 return 0;
47634 err:
47635 +
47636 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47637 + module_free_exec(NULL, pmi_code);
47638 +#endif
47639 +
47640 if (info->screen_base)
47641 iounmap(info->screen_base);
47642 framebuffer_release(info);
47643 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
47644 index 88714ae..16c2e11 100644
47645 --- a/drivers/video/via/via_clock.h
47646 +++ b/drivers/video/via/via_clock.h
47647 @@ -56,7 +56,7 @@ struct via_clock {
47648
47649 void (*set_engine_pll_state)(u8 state);
47650 void (*set_engine_pll)(struct via_pll_config config);
47651 -};
47652 +} __no_const;
47653
47654
47655 static inline u32 get_pll_internal_frequency(u32 ref_freq,
47656 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
47657 index fef20db..d28b1ab 100644
47658 --- a/drivers/xen/xenfs/xenstored.c
47659 +++ b/drivers/xen/xenfs/xenstored.c
47660 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
47661 static int xsd_kva_open(struct inode *inode, struct file *file)
47662 {
47663 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
47664 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47665 + NULL);
47666 +#else
47667 xen_store_interface);
47668 +#endif
47669 +
47670 if (!file->private_data)
47671 return -ENOMEM;
47672 return 0;
47673 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
47674 index 890bed5..17ae73e 100644
47675 --- a/fs/9p/vfs_inode.c
47676 +++ b/fs/9p/vfs_inode.c
47677 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
47678 void
47679 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47680 {
47681 - char *s = nd_get_link(nd);
47682 + const char *s = nd_get_link(nd);
47683
47684 p9_debug(P9_DEBUG_VFS, " %s %s\n",
47685 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
47686 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
47687 index 0efd152..b5802ad 100644
47688 --- a/fs/Kconfig.binfmt
47689 +++ b/fs/Kconfig.binfmt
47690 @@ -89,7 +89,7 @@ config HAVE_AOUT
47691
47692 config BINFMT_AOUT
47693 tristate "Kernel support for a.out and ECOFF binaries"
47694 - depends on HAVE_AOUT
47695 + depends on HAVE_AOUT && BROKEN
47696 ---help---
47697 A.out (Assembler.OUTput) is a set of formats for libraries and
47698 executables used in the earliest versions of UNIX. Linux used
47699 diff --git a/fs/aio.c b/fs/aio.c
47700 index 71f613c..9d01f1f 100644
47701 --- a/fs/aio.c
47702 +++ b/fs/aio.c
47703 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
47704 size += sizeof(struct io_event) * nr_events;
47705 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
47706
47707 - if (nr_pages < 0)
47708 + if (nr_pages <= 0)
47709 return -EINVAL;
47710
47711 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
47712 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
47713 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47714 {
47715 ssize_t ret;
47716 + struct iovec iovstack;
47717
47718 #ifdef CONFIG_COMPAT
47719 if (compat)
47720 ret = compat_rw_copy_check_uvector(type,
47721 (struct compat_iovec __user *)kiocb->ki_buf,
47722 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47723 + kiocb->ki_nbytes, 1, &iovstack,
47724 &kiocb->ki_iovec);
47725 else
47726 #endif
47727 ret = rw_copy_check_uvector(type,
47728 (struct iovec __user *)kiocb->ki_buf,
47729 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47730 + kiocb->ki_nbytes, 1, &iovstack,
47731 &kiocb->ki_iovec);
47732 if (ret < 0)
47733 goto out;
47734 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47735 if (ret < 0)
47736 goto out;
47737
47738 + if (kiocb->ki_iovec == &iovstack) {
47739 + kiocb->ki_inline_vec = iovstack;
47740 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
47741 + }
47742 kiocb->ki_nr_segs = kiocb->ki_nbytes;
47743 kiocb->ki_cur_seg = 0;
47744 /* ki_nbytes/left now reflect bytes instead of segs */
47745 diff --git a/fs/attr.c b/fs/attr.c
47746 index 1449adb..a2038c2 100644
47747 --- a/fs/attr.c
47748 +++ b/fs/attr.c
47749 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
47750 unsigned long limit;
47751
47752 limit = rlimit(RLIMIT_FSIZE);
47753 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
47754 if (limit != RLIM_INFINITY && offset > limit)
47755 goto out_sig;
47756 if (offset > inode->i_sb->s_maxbytes)
47757 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
47758 index 03bc1d3..6205356 100644
47759 --- a/fs/autofs4/waitq.c
47760 +++ b/fs/autofs4/waitq.c
47761 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
47762 {
47763 unsigned long sigpipe, flags;
47764 mm_segment_t fs;
47765 - const char *data = (const char *)addr;
47766 + const char __user *data = (const char __force_user *)addr;
47767 ssize_t wr = 0;
47768
47769 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
47770 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
47771 return 1;
47772 }
47773
47774 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47775 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
47776 +#endif
47777 +
47778 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47779 enum autofs_notify notify)
47780 {
47781 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47782
47783 /* If this is a direct mount request create a dummy name */
47784 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
47785 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47786 + /* this name does get written to userland via autofs4_write() */
47787 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
47788 +#else
47789 qstr.len = sprintf(name, "%p", dentry);
47790 +#endif
47791 else {
47792 qstr.len = autofs4_getpath(sbi, dentry, &name);
47793 if (!qstr.len) {
47794 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
47795 index 2722387..c8dd2a7 100644
47796 --- a/fs/befs/endian.h
47797 +++ b/fs/befs/endian.h
47798 @@ -11,7 +11,7 @@
47799
47800 #include <asm/byteorder.h>
47801
47802 -static inline u64
47803 +static inline u64 __intentional_overflow(-1)
47804 fs64_to_cpu(const struct super_block *sb, fs64 n)
47805 {
47806 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47807 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
47808 return (__force fs64)cpu_to_be64(n);
47809 }
47810
47811 -static inline u32
47812 +static inline u32 __intentional_overflow(-1)
47813 fs32_to_cpu(const struct super_block *sb, fs32 n)
47814 {
47815 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47816 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
47817 index 2b3bda8..6a2d4be 100644
47818 --- a/fs/befs/linuxvfs.c
47819 +++ b/fs/befs/linuxvfs.c
47820 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47821 {
47822 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
47823 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
47824 - char *link = nd_get_link(nd);
47825 + const char *link = nd_get_link(nd);
47826 if (!IS_ERR(link))
47827 kfree(link);
47828 }
47829 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
47830 index 6043567..16a9239 100644
47831 --- a/fs/binfmt_aout.c
47832 +++ b/fs/binfmt_aout.c
47833 @@ -16,6 +16,7 @@
47834 #include <linux/string.h>
47835 #include <linux/fs.h>
47836 #include <linux/file.h>
47837 +#include <linux/security.h>
47838 #include <linux/stat.h>
47839 #include <linux/fcntl.h>
47840 #include <linux/ptrace.h>
47841 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
47842 #endif
47843 # define START_STACK(u) ((void __user *)u.start_stack)
47844
47845 + memset(&dump, 0, sizeof(dump));
47846 +
47847 fs = get_fs();
47848 set_fs(KERNEL_DS);
47849 has_dumped = 1;
47850 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
47851
47852 /* If the size of the dump file exceeds the rlimit, then see what would happen
47853 if we wrote the stack, but not the data area. */
47854 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
47855 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
47856 dump.u_dsize = 0;
47857
47858 /* Make sure we have enough room to write the stack and data areas. */
47859 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
47860 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
47861 dump.u_ssize = 0;
47862
47863 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
47864 rlim = rlimit(RLIMIT_DATA);
47865 if (rlim >= RLIM_INFINITY)
47866 rlim = ~0;
47867 +
47868 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
47869 if (ex.a_data + ex.a_bss > rlim)
47870 return -ENOMEM;
47871
47872 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
47873
47874 install_exec_creds(bprm);
47875
47876 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
47877 + current->mm->pax_flags = 0UL;
47878 +#endif
47879 +
47880 +#ifdef CONFIG_PAX_PAGEEXEC
47881 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
47882 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
47883 +
47884 +#ifdef CONFIG_PAX_EMUTRAMP
47885 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
47886 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
47887 +#endif
47888 +
47889 +#ifdef CONFIG_PAX_MPROTECT
47890 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
47891 + current->mm->pax_flags |= MF_PAX_MPROTECT;
47892 +#endif
47893 +
47894 + }
47895 +#endif
47896 +
47897 if (N_MAGIC(ex) == OMAGIC) {
47898 unsigned long text_addr, map_size;
47899 loff_t pos;
47900 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
47901 }
47902
47903 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
47904 - PROT_READ | PROT_WRITE | PROT_EXEC,
47905 + PROT_READ | PROT_WRITE,
47906 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
47907 fd_offset + ex.a_text);
47908 if (error != N_DATADDR(ex)) {
47909 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
47910 index 0c42cdb..b62581e9 100644
47911 --- a/fs/binfmt_elf.c
47912 +++ b/fs/binfmt_elf.c
47913 @@ -33,6 +33,7 @@
47914 #include <linux/elf.h>
47915 #include <linux/utsname.h>
47916 #include <linux/coredump.h>
47917 +#include <linux/xattr.h>
47918 #include <asm/uaccess.h>
47919 #include <asm/param.h>
47920 #include <asm/page.h>
47921 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
47922 #define elf_core_dump NULL
47923 #endif
47924
47925 +#ifdef CONFIG_PAX_MPROTECT
47926 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
47927 +#endif
47928 +
47929 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
47930 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
47931 #else
47932 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
47933 .load_binary = load_elf_binary,
47934 .load_shlib = load_elf_library,
47935 .core_dump = elf_core_dump,
47936 +
47937 +#ifdef CONFIG_PAX_MPROTECT
47938 + .handle_mprotect= elf_handle_mprotect,
47939 +#endif
47940 +
47941 .min_coredump = ELF_EXEC_PAGESIZE,
47942 };
47943
47944 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
47945
47946 static int set_brk(unsigned long start, unsigned long end)
47947 {
47948 + unsigned long e = end;
47949 +
47950 start = ELF_PAGEALIGN(start);
47951 end = ELF_PAGEALIGN(end);
47952 if (end > start) {
47953 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
47954 if (BAD_ADDR(addr))
47955 return addr;
47956 }
47957 - current->mm->start_brk = current->mm->brk = end;
47958 + current->mm->start_brk = current->mm->brk = e;
47959 return 0;
47960 }
47961
47962 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47963 elf_addr_t __user *u_rand_bytes;
47964 const char *k_platform = ELF_PLATFORM;
47965 const char *k_base_platform = ELF_BASE_PLATFORM;
47966 - unsigned char k_rand_bytes[16];
47967 + u32 k_rand_bytes[4];
47968 int items;
47969 elf_addr_t *elf_info;
47970 int ei_index = 0;
47971 const struct cred *cred = current_cred();
47972 struct vm_area_struct *vma;
47973 + unsigned long saved_auxv[AT_VECTOR_SIZE];
47974
47975 /*
47976 * In some cases (e.g. Hyper-Threading), we want to avoid L1
47977 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47978 * Generate 16 random bytes for userspace PRNG seeding.
47979 */
47980 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
47981 - u_rand_bytes = (elf_addr_t __user *)
47982 - STACK_ALLOC(p, sizeof(k_rand_bytes));
47983 + srandom32(k_rand_bytes[0] ^ random32());
47984 + srandom32(k_rand_bytes[1] ^ random32());
47985 + srandom32(k_rand_bytes[2] ^ random32());
47986 + srandom32(k_rand_bytes[3] ^ random32());
47987 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
47988 + u_rand_bytes = (elf_addr_t __user *) p;
47989 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
47990 return -EFAULT;
47991
47992 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47993 return -EFAULT;
47994 current->mm->env_end = p;
47995
47996 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
47997 +
47998 /* Put the elf_info on the stack in the right place. */
47999 sp = (elf_addr_t __user *)envp + 1;
48000 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48001 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48002 return -EFAULT;
48003 return 0;
48004 }
48005 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48006 an ELF header */
48007
48008 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48009 - struct file *interpreter, unsigned long *interp_map_addr,
48010 - unsigned long no_base)
48011 + struct file *interpreter, unsigned long no_base)
48012 {
48013 struct elf_phdr *elf_phdata;
48014 struct elf_phdr *eppnt;
48015 - unsigned long load_addr = 0;
48016 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48017 int load_addr_set = 0;
48018 unsigned long last_bss = 0, elf_bss = 0;
48019 - unsigned long error = ~0UL;
48020 + unsigned long error = -EINVAL;
48021 unsigned long total_size;
48022 int retval, i, size;
48023
48024 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48025 goto out_close;
48026 }
48027
48028 +#ifdef CONFIG_PAX_SEGMEXEC
48029 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48030 + pax_task_size = SEGMEXEC_TASK_SIZE;
48031 +#endif
48032 +
48033 eppnt = elf_phdata;
48034 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48035 if (eppnt->p_type == PT_LOAD) {
48036 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48037 map_addr = elf_map(interpreter, load_addr + vaddr,
48038 eppnt, elf_prot, elf_type, total_size);
48039 total_size = 0;
48040 - if (!*interp_map_addr)
48041 - *interp_map_addr = map_addr;
48042 error = map_addr;
48043 if (BAD_ADDR(map_addr))
48044 goto out_close;
48045 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48046 k = load_addr + eppnt->p_vaddr;
48047 if (BAD_ADDR(k) ||
48048 eppnt->p_filesz > eppnt->p_memsz ||
48049 - eppnt->p_memsz > TASK_SIZE ||
48050 - TASK_SIZE - eppnt->p_memsz < k) {
48051 + eppnt->p_memsz > pax_task_size ||
48052 + pax_task_size - eppnt->p_memsz < k) {
48053 error = -ENOMEM;
48054 goto out_close;
48055 }
48056 @@ -530,6 +551,315 @@ out:
48057 return error;
48058 }
48059
48060 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48061 +#ifdef CONFIG_PAX_SOFTMODE
48062 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48063 +{
48064 + unsigned long pax_flags = 0UL;
48065 +
48066 +#ifdef CONFIG_PAX_PAGEEXEC
48067 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48068 + pax_flags |= MF_PAX_PAGEEXEC;
48069 +#endif
48070 +
48071 +#ifdef CONFIG_PAX_SEGMEXEC
48072 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48073 + pax_flags |= MF_PAX_SEGMEXEC;
48074 +#endif
48075 +
48076 +#ifdef CONFIG_PAX_EMUTRAMP
48077 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48078 + pax_flags |= MF_PAX_EMUTRAMP;
48079 +#endif
48080 +
48081 +#ifdef CONFIG_PAX_MPROTECT
48082 + if (elf_phdata->p_flags & PF_MPROTECT)
48083 + pax_flags |= MF_PAX_MPROTECT;
48084 +#endif
48085 +
48086 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48087 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48088 + pax_flags |= MF_PAX_RANDMMAP;
48089 +#endif
48090 +
48091 + return pax_flags;
48092 +}
48093 +#endif
48094 +
48095 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48096 +{
48097 + unsigned long pax_flags = 0UL;
48098 +
48099 +#ifdef CONFIG_PAX_PAGEEXEC
48100 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48101 + pax_flags |= MF_PAX_PAGEEXEC;
48102 +#endif
48103 +
48104 +#ifdef CONFIG_PAX_SEGMEXEC
48105 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48106 + pax_flags |= MF_PAX_SEGMEXEC;
48107 +#endif
48108 +
48109 +#ifdef CONFIG_PAX_EMUTRAMP
48110 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48111 + pax_flags |= MF_PAX_EMUTRAMP;
48112 +#endif
48113 +
48114 +#ifdef CONFIG_PAX_MPROTECT
48115 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48116 + pax_flags |= MF_PAX_MPROTECT;
48117 +#endif
48118 +
48119 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48120 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48121 + pax_flags |= MF_PAX_RANDMMAP;
48122 +#endif
48123 +
48124 + return pax_flags;
48125 +}
48126 +#endif
48127 +
48128 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48129 +#ifdef CONFIG_PAX_SOFTMODE
48130 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48131 +{
48132 + unsigned long pax_flags = 0UL;
48133 +
48134 +#ifdef CONFIG_PAX_PAGEEXEC
48135 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48136 + pax_flags |= MF_PAX_PAGEEXEC;
48137 +#endif
48138 +
48139 +#ifdef CONFIG_PAX_SEGMEXEC
48140 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48141 + pax_flags |= MF_PAX_SEGMEXEC;
48142 +#endif
48143 +
48144 +#ifdef CONFIG_PAX_EMUTRAMP
48145 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48146 + pax_flags |= MF_PAX_EMUTRAMP;
48147 +#endif
48148 +
48149 +#ifdef CONFIG_PAX_MPROTECT
48150 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48151 + pax_flags |= MF_PAX_MPROTECT;
48152 +#endif
48153 +
48154 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48155 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48156 + pax_flags |= MF_PAX_RANDMMAP;
48157 +#endif
48158 +
48159 + return pax_flags;
48160 +}
48161 +#endif
48162 +
48163 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48164 +{
48165 + unsigned long pax_flags = 0UL;
48166 +
48167 +#ifdef CONFIG_PAX_PAGEEXEC
48168 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48169 + pax_flags |= MF_PAX_PAGEEXEC;
48170 +#endif
48171 +
48172 +#ifdef CONFIG_PAX_SEGMEXEC
48173 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48174 + pax_flags |= MF_PAX_SEGMEXEC;
48175 +#endif
48176 +
48177 +#ifdef CONFIG_PAX_EMUTRAMP
48178 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48179 + pax_flags |= MF_PAX_EMUTRAMP;
48180 +#endif
48181 +
48182 +#ifdef CONFIG_PAX_MPROTECT
48183 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48184 + pax_flags |= MF_PAX_MPROTECT;
48185 +#endif
48186 +
48187 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48188 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48189 + pax_flags |= MF_PAX_RANDMMAP;
48190 +#endif
48191 +
48192 + return pax_flags;
48193 +}
48194 +#endif
48195 +
48196 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48197 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48198 +{
48199 + unsigned long pax_flags = 0UL;
48200 +
48201 +#ifdef CONFIG_PAX_EI_PAX
48202 +
48203 +#ifdef CONFIG_PAX_PAGEEXEC
48204 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48205 + pax_flags |= MF_PAX_PAGEEXEC;
48206 +#endif
48207 +
48208 +#ifdef CONFIG_PAX_SEGMEXEC
48209 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48210 + pax_flags |= MF_PAX_SEGMEXEC;
48211 +#endif
48212 +
48213 +#ifdef CONFIG_PAX_EMUTRAMP
48214 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48215 + pax_flags |= MF_PAX_EMUTRAMP;
48216 +#endif
48217 +
48218 +#ifdef CONFIG_PAX_MPROTECT
48219 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48220 + pax_flags |= MF_PAX_MPROTECT;
48221 +#endif
48222 +
48223 +#ifdef CONFIG_PAX_ASLR
48224 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48225 + pax_flags |= MF_PAX_RANDMMAP;
48226 +#endif
48227 +
48228 +#else
48229 +
48230 +#ifdef CONFIG_PAX_PAGEEXEC
48231 + pax_flags |= MF_PAX_PAGEEXEC;
48232 +#endif
48233 +
48234 +#ifdef CONFIG_PAX_SEGMEXEC
48235 + pax_flags |= MF_PAX_SEGMEXEC;
48236 +#endif
48237 +
48238 +#ifdef CONFIG_PAX_MPROTECT
48239 + pax_flags |= MF_PAX_MPROTECT;
48240 +#endif
48241 +
48242 +#ifdef CONFIG_PAX_RANDMMAP
48243 + if (randomize_va_space)
48244 + pax_flags |= MF_PAX_RANDMMAP;
48245 +#endif
48246 +
48247 +#endif
48248 +
48249 + return pax_flags;
48250 +}
48251 +
48252 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48253 +{
48254 +
48255 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48256 + unsigned long i;
48257 +
48258 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48259 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48260 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48261 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48262 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48263 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48264 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48265 + return ~0UL;
48266 +
48267 +#ifdef CONFIG_PAX_SOFTMODE
48268 + if (pax_softmode)
48269 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48270 + else
48271 +#endif
48272 +
48273 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48274 + break;
48275 + }
48276 +#endif
48277 +
48278 + return ~0UL;
48279 +}
48280 +
48281 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48282 +{
48283 +
48284 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48285 + ssize_t xattr_size, i;
48286 + unsigned char xattr_value[5];
48287 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48288 +
48289 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
48290 + if (xattr_size <= 0 || xattr_size > 5)
48291 + return ~0UL;
48292 +
48293 + for (i = 0; i < xattr_size; i++)
48294 + switch (xattr_value[i]) {
48295 + default:
48296 + return ~0UL;
48297 +
48298 +#define parse_flag(option1, option2, flag) \
48299 + case option1: \
48300 + if (pax_flags_hardmode & MF_PAX_##flag) \
48301 + return ~0UL; \
48302 + pax_flags_hardmode |= MF_PAX_##flag; \
48303 + break; \
48304 + case option2: \
48305 + if (pax_flags_softmode & MF_PAX_##flag) \
48306 + return ~0UL; \
48307 + pax_flags_softmode |= MF_PAX_##flag; \
48308 + break;
48309 +
48310 + parse_flag('p', 'P', PAGEEXEC);
48311 + parse_flag('e', 'E', EMUTRAMP);
48312 + parse_flag('m', 'M', MPROTECT);
48313 + parse_flag('r', 'R', RANDMMAP);
48314 + parse_flag('s', 'S', SEGMEXEC);
48315 +
48316 +#undef parse_flag
48317 + }
48318 +
48319 + if (pax_flags_hardmode & pax_flags_softmode)
48320 + return ~0UL;
48321 +
48322 +#ifdef CONFIG_PAX_SOFTMODE
48323 + if (pax_softmode)
48324 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48325 + else
48326 +#endif
48327 +
48328 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48329 +#else
48330 + return ~0UL;
48331 +#endif
48332 +
48333 +}
48334 +
48335 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48336 +{
48337 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48338 +
48339 + pax_flags = pax_parse_ei_pax(elf_ex);
48340 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48341 + xattr_pax_flags = pax_parse_xattr_pax(file);
48342 +
48343 + if (pt_pax_flags == ~0UL)
48344 + pt_pax_flags = xattr_pax_flags;
48345 + else if (xattr_pax_flags == ~0UL)
48346 + xattr_pax_flags = pt_pax_flags;
48347 + if (pt_pax_flags != xattr_pax_flags)
48348 + return -EINVAL;
48349 + if (pt_pax_flags != ~0UL)
48350 + pax_flags = pt_pax_flags;
48351 +
48352 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48353 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48354 + if ((__supported_pte_mask & _PAGE_NX))
48355 + pax_flags &= ~MF_PAX_SEGMEXEC;
48356 + else
48357 + pax_flags &= ~MF_PAX_PAGEEXEC;
48358 + }
48359 +#endif
48360 +
48361 + if (0 > pax_check_flags(&pax_flags))
48362 + return -EINVAL;
48363 +
48364 + current->mm->pax_flags = pax_flags;
48365 + return 0;
48366 +}
48367 +#endif
48368 +
48369 /*
48370 * These are the functions used to load ELF style executables and shared
48371 * libraries. There is no binary dependent code anywhere else.
48372 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48373 {
48374 unsigned int random_variable = 0;
48375
48376 +#ifdef CONFIG_PAX_RANDUSTACK
48377 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48378 + return stack_top - current->mm->delta_stack;
48379 +#endif
48380 +
48381 if ((current->flags & PF_RANDOMIZE) &&
48382 !(current->personality & ADDR_NO_RANDOMIZE)) {
48383 random_variable = get_random_int() & STACK_RND_MASK;
48384 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48385 unsigned long load_addr = 0, load_bias = 0;
48386 int load_addr_set = 0;
48387 char * elf_interpreter = NULL;
48388 - unsigned long error;
48389 + unsigned long error = 0;
48390 struct elf_phdr *elf_ppnt, *elf_phdata;
48391 unsigned long elf_bss, elf_brk;
48392 int retval, i;
48393 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48394 unsigned long start_code, end_code, start_data, end_data;
48395 unsigned long reloc_func_desc __maybe_unused = 0;
48396 int executable_stack = EXSTACK_DEFAULT;
48397 - unsigned long def_flags = 0;
48398 struct pt_regs *regs = current_pt_regs();
48399 struct {
48400 struct elfhdr elf_ex;
48401 struct elfhdr interp_elf_ex;
48402 } *loc;
48403 + unsigned long pax_task_size = TASK_SIZE;
48404
48405 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48406 if (!loc) {
48407 @@ -715,11 +1050,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
48408 goto out_free_dentry;
48409
48410 /* OK, This is the point of no return */
48411 - current->mm->def_flags = def_flags;
48412 +
48413 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48414 + current->mm->pax_flags = 0UL;
48415 +#endif
48416 +
48417 +#ifdef CONFIG_PAX_DLRESOLVE
48418 + current->mm->call_dl_resolve = 0UL;
48419 +#endif
48420 +
48421 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48422 + current->mm->call_syscall = 0UL;
48423 +#endif
48424 +
48425 +#ifdef CONFIG_PAX_ASLR
48426 + current->mm->delta_mmap = 0UL;
48427 + current->mm->delta_stack = 0UL;
48428 +#endif
48429 +
48430 + current->mm->def_flags = 0;
48431 +
48432 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48433 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48434 + send_sig(SIGKILL, current, 0);
48435 + goto out_free_dentry;
48436 + }
48437 +#endif
48438 +
48439 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
48440 + pax_set_initial_flags(bprm);
48441 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
48442 + if (pax_set_initial_flags_func)
48443 + (pax_set_initial_flags_func)(bprm);
48444 +#endif
48445 +
48446 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48447 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
48448 + current->mm->context.user_cs_limit = PAGE_SIZE;
48449 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
48450 + }
48451 +#endif
48452 +
48453 +#ifdef CONFIG_PAX_SEGMEXEC
48454 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
48455 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
48456 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
48457 + pax_task_size = SEGMEXEC_TASK_SIZE;
48458 + current->mm->def_flags |= VM_NOHUGEPAGE;
48459 + }
48460 +#endif
48461 +
48462 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
48463 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48464 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
48465 + put_cpu();
48466 + }
48467 +#endif
48468
48469 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
48470 may depend on the personality. */
48471 SET_PERSONALITY(loc->elf_ex);
48472 +
48473 +#ifdef CONFIG_PAX_ASLR
48474 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48475 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
48476 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
48477 + }
48478 +#endif
48479 +
48480 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
48481 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48482 + executable_stack = EXSTACK_DISABLE_X;
48483 + current->personality &= ~READ_IMPLIES_EXEC;
48484 + } else
48485 +#endif
48486 +
48487 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
48488 current->personality |= READ_IMPLIES_EXEC;
48489
48490 @@ -810,6 +1215,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
48491 #else
48492 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
48493 #endif
48494 +
48495 +#ifdef CONFIG_PAX_RANDMMAP
48496 + /* PaX: randomize base address at the default exe base if requested */
48497 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
48498 +#ifdef CONFIG_SPARC64
48499 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
48500 +#else
48501 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
48502 +#endif
48503 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
48504 + elf_flags |= MAP_FIXED;
48505 + }
48506 +#endif
48507 +
48508 }
48509
48510 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
48511 @@ -842,9 +1261,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
48512 * allowed task size. Note that p_filesz must always be
48513 * <= p_memsz so it is only necessary to check p_memsz.
48514 */
48515 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48516 - elf_ppnt->p_memsz > TASK_SIZE ||
48517 - TASK_SIZE - elf_ppnt->p_memsz < k) {
48518 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48519 + elf_ppnt->p_memsz > pax_task_size ||
48520 + pax_task_size - elf_ppnt->p_memsz < k) {
48521 /* set_brk can never work. Avoid overflows. */
48522 send_sig(SIGKILL, current, 0);
48523 retval = -EINVAL;
48524 @@ -883,17 +1302,44 @@ static int load_elf_binary(struct linux_binprm *bprm)
48525 goto out_free_dentry;
48526 }
48527 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
48528 - send_sig(SIGSEGV, current, 0);
48529 - retval = -EFAULT; /* Nobody gets to see this, but.. */
48530 - goto out_free_dentry;
48531 + /*
48532 + * This bss-zeroing can fail if the ELF
48533 + * file specifies odd protections. So
48534 + * we don't check the return value
48535 + */
48536 }
48537
48538 +#ifdef CONFIG_PAX_RANDMMAP
48539 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48540 + unsigned long start, size, flags, vm_flags;
48541 +
48542 + start = ELF_PAGEALIGN(elf_brk);
48543 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
48544 + flags = MAP_FIXED | MAP_PRIVATE;
48545 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
48546 +
48547 + down_write(&current->mm->mmap_sem);
48548 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
48549 + retval = -ENOMEM;
48550 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
48551 +// if (current->personality & ADDR_NO_RANDOMIZE)
48552 +// vm_flags |= VM_READ | VM_MAYREAD;
48553 + start = mmap_region(NULL, start, PAGE_ALIGN(size), flags, vm_flags, 0);
48554 + retval = IS_ERR_VALUE(start) ? start : 0;
48555 + }
48556 + up_write(&current->mm->mmap_sem);
48557 + if (retval == 0)
48558 + retval = set_brk(start + size, start + size + PAGE_SIZE);
48559 + if (retval < 0) {
48560 + send_sig(SIGKILL, current, 0);
48561 + goto out_free_dentry;
48562 + }
48563 + }
48564 +#endif
48565 +
48566 if (elf_interpreter) {
48567 - unsigned long interp_map_addr = 0;
48568 -
48569 elf_entry = load_elf_interp(&loc->interp_elf_ex,
48570 interpreter,
48571 - &interp_map_addr,
48572 load_bias);
48573 if (!IS_ERR((void *)elf_entry)) {
48574 /*
48575 @@ -1115,7 +1561,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
48576 * Decide what to dump of a segment, part, all or none.
48577 */
48578 static unsigned long vma_dump_size(struct vm_area_struct *vma,
48579 - unsigned long mm_flags)
48580 + unsigned long mm_flags, long signr)
48581 {
48582 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
48583
48584 @@ -1152,7 +1598,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
48585 if (vma->vm_file == NULL)
48586 return 0;
48587
48588 - if (FILTER(MAPPED_PRIVATE))
48589 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
48590 goto whole;
48591
48592 /*
48593 @@ -1374,9 +1820,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
48594 {
48595 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
48596 int i = 0;
48597 - do
48598 + do {
48599 i += 2;
48600 - while (auxv[i - 2] != AT_NULL);
48601 + } while (auxv[i - 2] != AT_NULL);
48602 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
48603 }
48604
48605 @@ -2006,14 +2452,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
48606 }
48607
48608 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
48609 - unsigned long mm_flags)
48610 + struct coredump_params *cprm)
48611 {
48612 struct vm_area_struct *vma;
48613 size_t size = 0;
48614
48615 for (vma = first_vma(current, gate_vma); vma != NULL;
48616 vma = next_vma(vma, gate_vma))
48617 - size += vma_dump_size(vma, mm_flags);
48618 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48619 return size;
48620 }
48621
48622 @@ -2107,7 +2553,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48623
48624 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
48625
48626 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
48627 + offset += elf_core_vma_data_size(gate_vma, cprm);
48628 offset += elf_core_extra_data_size();
48629 e_shoff = offset;
48630
48631 @@ -2121,10 +2567,12 @@ static int elf_core_dump(struct coredump_params *cprm)
48632 offset = dataoff;
48633
48634 size += sizeof(*elf);
48635 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48636 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
48637 goto end_coredump;
48638
48639 size += sizeof(*phdr4note);
48640 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48641 if (size > cprm->limit
48642 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
48643 goto end_coredump;
48644 @@ -2138,7 +2586,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48645 phdr.p_offset = offset;
48646 phdr.p_vaddr = vma->vm_start;
48647 phdr.p_paddr = 0;
48648 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
48649 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48650 phdr.p_memsz = vma->vm_end - vma->vm_start;
48651 offset += phdr.p_filesz;
48652 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
48653 @@ -2149,6 +2597,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48654 phdr.p_align = ELF_EXEC_PAGESIZE;
48655
48656 size += sizeof(phdr);
48657 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48658 if (size > cprm->limit
48659 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
48660 goto end_coredump;
48661 @@ -2173,7 +2622,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48662 unsigned long addr;
48663 unsigned long end;
48664
48665 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
48666 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48667
48668 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
48669 struct page *page;
48670 @@ -2182,6 +2631,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48671 page = get_dump_page(addr);
48672 if (page) {
48673 void *kaddr = kmap(page);
48674 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
48675 stop = ((size += PAGE_SIZE) > cprm->limit) ||
48676 !dump_write(cprm->file, kaddr,
48677 PAGE_SIZE);
48678 @@ -2199,6 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48679
48680 if (e_phnum == PN_XNUM) {
48681 size += sizeof(*shdr4extnum);
48682 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48683 if (size > cprm->limit
48684 || !dump_write(cprm->file, shdr4extnum,
48685 sizeof(*shdr4extnum)))
48686 @@ -2219,6 +2670,97 @@ out:
48687
48688 #endif /* CONFIG_ELF_CORE */
48689
48690 +#ifdef CONFIG_PAX_MPROTECT
48691 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
48692 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
48693 + * we'll remove VM_MAYWRITE for good on RELRO segments.
48694 + *
48695 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
48696 + * basis because we want to allow the common case and not the special ones.
48697 + */
48698 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
48699 +{
48700 + struct elfhdr elf_h;
48701 + struct elf_phdr elf_p;
48702 + unsigned long i;
48703 + unsigned long oldflags;
48704 + bool is_textrel_rw, is_textrel_rx, is_relro;
48705 +
48706 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
48707 + return;
48708 +
48709 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
48710 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
48711 +
48712 +#ifdef CONFIG_PAX_ELFRELOCS
48713 + /* possible TEXTREL */
48714 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
48715 + 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);
48716 +#else
48717 + is_textrel_rw = false;
48718 + is_textrel_rx = false;
48719 +#endif
48720 +
48721 + /* possible RELRO */
48722 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
48723 +
48724 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
48725 + return;
48726 +
48727 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
48728 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
48729 +
48730 +#ifdef CONFIG_PAX_ETEXECRELOCS
48731 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48732 +#else
48733 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
48734 +#endif
48735 +
48736 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48737 + !elf_check_arch(&elf_h) ||
48738 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
48739 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
48740 + return;
48741 +
48742 + for (i = 0UL; i < elf_h.e_phnum; i++) {
48743 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
48744 + return;
48745 + switch (elf_p.p_type) {
48746 + case PT_DYNAMIC:
48747 + if (!is_textrel_rw && !is_textrel_rx)
48748 + continue;
48749 + i = 0UL;
48750 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
48751 + elf_dyn dyn;
48752 +
48753 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
48754 + return;
48755 + if (dyn.d_tag == DT_NULL)
48756 + return;
48757 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
48758 + gr_log_textrel(vma);
48759 + if (is_textrel_rw)
48760 + vma->vm_flags |= VM_MAYWRITE;
48761 + else
48762 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
48763 + vma->vm_flags &= ~VM_MAYWRITE;
48764 + return;
48765 + }
48766 + i++;
48767 + }
48768 + return;
48769 +
48770 + case PT_GNU_RELRO:
48771 + if (!is_relro)
48772 + continue;
48773 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
48774 + vma->vm_flags &= ~VM_MAYWRITE;
48775 + return;
48776 + }
48777 + }
48778 +}
48779 +#endif
48780 +
48781 static int __init init_elf_binfmt(void)
48782 {
48783 register_binfmt(&elf_format);
48784 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
48785 index b563719..3868998 100644
48786 --- a/fs/binfmt_flat.c
48787 +++ b/fs/binfmt_flat.c
48788 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
48789 realdatastart = (unsigned long) -ENOMEM;
48790 printk("Unable to allocate RAM for process data, errno %d\n",
48791 (int)-realdatastart);
48792 + down_write(&current->mm->mmap_sem);
48793 vm_munmap(textpos, text_len);
48794 + up_write(&current->mm->mmap_sem);
48795 ret = realdatastart;
48796 goto err;
48797 }
48798 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48799 }
48800 if (IS_ERR_VALUE(result)) {
48801 printk("Unable to read data+bss, errno %d\n", (int)-result);
48802 + down_write(&current->mm->mmap_sem);
48803 vm_munmap(textpos, text_len);
48804 vm_munmap(realdatastart, len);
48805 + up_write(&current->mm->mmap_sem);
48806 ret = result;
48807 goto err;
48808 }
48809 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48810 }
48811 if (IS_ERR_VALUE(result)) {
48812 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
48813 + down_write(&current->mm->mmap_sem);
48814 vm_munmap(textpos, text_len + data_len + extra +
48815 MAX_SHARED_LIBS * sizeof(unsigned long));
48816 + up_write(&current->mm->mmap_sem);
48817 ret = result;
48818 goto err;
48819 }
48820 diff --git a/fs/bio.c b/fs/bio.c
48821 index b96fc6c..431d628 100644
48822 --- a/fs/bio.c
48823 +++ b/fs/bio.c
48824 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
48825 /*
48826 * Overflow, abort
48827 */
48828 - if (end < start)
48829 + if (end < start || end - start > INT_MAX - nr_pages)
48830 return ERR_PTR(-EINVAL);
48831
48832 nr_pages += end - start;
48833 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
48834 /*
48835 * Overflow, abort
48836 */
48837 - if (end < start)
48838 + if (end < start || end - start > INT_MAX - nr_pages)
48839 return ERR_PTR(-EINVAL);
48840
48841 nr_pages += end - start;
48842 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
48843 const int read = bio_data_dir(bio) == READ;
48844 struct bio_map_data *bmd = bio->bi_private;
48845 int i;
48846 - char *p = bmd->sgvecs[0].iov_base;
48847 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
48848
48849 __bio_for_each_segment(bvec, bio, i, 0) {
48850 char *addr = page_address(bvec->bv_page);
48851 diff --git a/fs/block_dev.c b/fs/block_dev.c
48852 index 78edf76..da14f3f 100644
48853 --- a/fs/block_dev.c
48854 +++ b/fs/block_dev.c
48855 @@ -651,7 +651,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
48856 else if (bdev->bd_contains == bdev)
48857 return true; /* is a whole device which isn't held */
48858
48859 - else if (whole->bd_holder == bd_may_claim)
48860 + else if (whole->bd_holder == (void *)bd_may_claim)
48861 return true; /* is a partition of a device that is being partitioned */
48862 else if (whole->bd_holder != NULL)
48863 return false; /* is a partition of a held device */
48864 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
48865 index eea5da7..88fead70 100644
48866 --- a/fs/btrfs/ctree.c
48867 +++ b/fs/btrfs/ctree.c
48868 @@ -1033,9 +1033,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
48869 free_extent_buffer(buf);
48870 add_root_to_dirty_list(root);
48871 } else {
48872 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
48873 - parent_start = parent->start;
48874 - else
48875 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
48876 + if (parent)
48877 + parent_start = parent->start;
48878 + else
48879 + parent_start = 0;
48880 + } else
48881 parent_start = 0;
48882
48883 WARN_ON(trans->transid != btrfs_header_generation(parent));
48884 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
48885 index 659ea81..0f63c1a 100644
48886 --- a/fs/btrfs/inode.c
48887 +++ b/fs/btrfs/inode.c
48888 @@ -7300,7 +7300,7 @@ fail:
48889 return -ENOMEM;
48890 }
48891
48892 -static int btrfs_getattr(struct vfsmount *mnt,
48893 +int btrfs_getattr(struct vfsmount *mnt,
48894 struct dentry *dentry, struct kstat *stat)
48895 {
48896 struct inode *inode = dentry->d_inode;
48897 @@ -7314,6 +7314,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
48898 return 0;
48899 }
48900
48901 +EXPORT_SYMBOL(btrfs_getattr);
48902 +
48903 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
48904 +{
48905 + return BTRFS_I(inode)->root->anon_dev;
48906 +}
48907 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
48908 +
48909 /*
48910 * If a file is moved, it will inherit the cow and compression flags of the new
48911 * directory.
48912 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
48913 index 338f259..b657640 100644
48914 --- a/fs/btrfs/ioctl.c
48915 +++ b/fs/btrfs/ioctl.c
48916 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
48917 for (i = 0; i < num_types; i++) {
48918 struct btrfs_space_info *tmp;
48919
48920 + /* Don't copy in more than we allocated */
48921 if (!slot_count)
48922 break;
48923
48924 + slot_count--;
48925 +
48926 info = NULL;
48927 rcu_read_lock();
48928 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
48929 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
48930 memcpy(dest, &space, sizeof(space));
48931 dest++;
48932 space_args.total_spaces++;
48933 - slot_count--;
48934 }
48935 - if (!slot_count)
48936 - break;
48937 }
48938 up_read(&info->groups_sem);
48939 }
48940 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
48941 index 300e09a..9fe4539 100644
48942 --- a/fs/btrfs/relocation.c
48943 +++ b/fs/btrfs/relocation.c
48944 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
48945 }
48946 spin_unlock(&rc->reloc_root_tree.lock);
48947
48948 - BUG_ON((struct btrfs_root *)node->data != root);
48949 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
48950
48951 if (!del) {
48952 spin_lock(&rc->reloc_root_tree.lock);
48953 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
48954 index d8982e9..29a85fa 100644
48955 --- a/fs/btrfs/super.c
48956 +++ b/fs/btrfs/super.c
48957 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
48958 function, line, errstr);
48959 return;
48960 }
48961 - ACCESS_ONCE(trans->transaction->aborted) = errno;
48962 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
48963 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
48964 }
48965 /*
48966 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
48967 index 622f469..e8d2d55 100644
48968 --- a/fs/cachefiles/bind.c
48969 +++ b/fs/cachefiles/bind.c
48970 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
48971 args);
48972
48973 /* start by checking things over */
48974 - ASSERT(cache->fstop_percent >= 0 &&
48975 - cache->fstop_percent < cache->fcull_percent &&
48976 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
48977 cache->fcull_percent < cache->frun_percent &&
48978 cache->frun_percent < 100);
48979
48980 - ASSERT(cache->bstop_percent >= 0 &&
48981 - cache->bstop_percent < cache->bcull_percent &&
48982 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
48983 cache->bcull_percent < cache->brun_percent &&
48984 cache->brun_percent < 100);
48985
48986 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
48987 index 0a1467b..6a53245 100644
48988 --- a/fs/cachefiles/daemon.c
48989 +++ b/fs/cachefiles/daemon.c
48990 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
48991 if (n > buflen)
48992 return -EMSGSIZE;
48993
48994 - if (copy_to_user(_buffer, buffer, n) != 0)
48995 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
48996 return -EFAULT;
48997
48998 return n;
48999 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49000 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49001 return -EIO;
49002
49003 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49004 + if (datalen > PAGE_SIZE - 1)
49005 return -EOPNOTSUPP;
49006
49007 /* drag the command string into the kernel so we can parse it */
49008 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49009 if (args[0] != '%' || args[1] != '\0')
49010 return -EINVAL;
49011
49012 - if (fstop < 0 || fstop >= cache->fcull_percent)
49013 + if (fstop >= cache->fcull_percent)
49014 return cachefiles_daemon_range_error(cache, args);
49015
49016 cache->fstop_percent = fstop;
49017 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49018 if (args[0] != '%' || args[1] != '\0')
49019 return -EINVAL;
49020
49021 - if (bstop < 0 || bstop >= cache->bcull_percent)
49022 + if (bstop >= cache->bcull_percent)
49023 return cachefiles_daemon_range_error(cache, args);
49024
49025 cache->bstop_percent = bstop;
49026 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49027 index 4938251..7e01445 100644
49028 --- a/fs/cachefiles/internal.h
49029 +++ b/fs/cachefiles/internal.h
49030 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49031 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49032 struct rb_root active_nodes; /* active nodes (can't be culled) */
49033 rwlock_t active_lock; /* lock for active_nodes */
49034 - atomic_t gravecounter; /* graveyard uniquifier */
49035 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49036 unsigned frun_percent; /* when to stop culling (% files) */
49037 unsigned fcull_percent; /* when to start culling (% files) */
49038 unsigned fstop_percent; /* when to stop allocating (% files) */
49039 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49040 * proc.c
49041 */
49042 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49043 -extern atomic_t cachefiles_lookup_histogram[HZ];
49044 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49045 -extern atomic_t cachefiles_create_histogram[HZ];
49046 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49047 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49048 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49049
49050 extern int __init cachefiles_proc_init(void);
49051 extern void cachefiles_proc_cleanup(void);
49052 static inline
49053 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49054 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49055 {
49056 unsigned long jif = jiffies - start_jif;
49057 if (jif >= HZ)
49058 jif = HZ - 1;
49059 - atomic_inc(&histogram[jif]);
49060 + atomic_inc_unchecked(&histogram[jif]);
49061 }
49062
49063 #else
49064 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49065 index 8c01c5fc..15f982e 100644
49066 --- a/fs/cachefiles/namei.c
49067 +++ b/fs/cachefiles/namei.c
49068 @@ -317,7 +317,7 @@ try_again:
49069 /* first step is to make up a grave dentry in the graveyard */
49070 sprintf(nbuffer, "%08x%08x",
49071 (uint32_t) get_seconds(),
49072 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49073 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49074
49075 /* do the multiway lock magic */
49076 trap = lock_rename(cache->graveyard, dir);
49077 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49078 index eccd339..4c1d995 100644
49079 --- a/fs/cachefiles/proc.c
49080 +++ b/fs/cachefiles/proc.c
49081 @@ -14,9 +14,9 @@
49082 #include <linux/seq_file.h>
49083 #include "internal.h"
49084
49085 -atomic_t cachefiles_lookup_histogram[HZ];
49086 -atomic_t cachefiles_mkdir_histogram[HZ];
49087 -atomic_t cachefiles_create_histogram[HZ];
49088 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49089 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49090 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49091
49092 /*
49093 * display the latency histogram
49094 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49095 return 0;
49096 default:
49097 index = (unsigned long) v - 3;
49098 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49099 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49100 - z = atomic_read(&cachefiles_create_histogram[index]);
49101 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49102 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49103 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49104 if (x == 0 && y == 0 && z == 0)
49105 return 0;
49106
49107 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49108 index 4809922..aab2c39 100644
49109 --- a/fs/cachefiles/rdwr.c
49110 +++ b/fs/cachefiles/rdwr.c
49111 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49112 old_fs = get_fs();
49113 set_fs(KERNEL_DS);
49114 ret = file->f_op->write(
49115 - file, (const void __user *) data, len, &pos);
49116 + file, (const void __force_user *) data, len, &pos);
49117 set_fs(old_fs);
49118 kunmap(page);
49119 if (ret != len)
49120 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49121 index 8c1aabe..bbf856a 100644
49122 --- a/fs/ceph/dir.c
49123 +++ b/fs/ceph/dir.c
49124 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49125 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49126 struct ceph_mds_client *mdsc = fsc->mdsc;
49127 unsigned frag = fpos_frag(filp->f_pos);
49128 - int off = fpos_off(filp->f_pos);
49129 + unsigned int off = fpos_off(filp->f_pos);
49130 int err;
49131 u32 ftype;
49132 struct ceph_mds_reply_info_parsed *rinfo;
49133 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49134 index d9ea6ed..1e6c8ac 100644
49135 --- a/fs/cifs/cifs_debug.c
49136 +++ b/fs/cifs/cifs_debug.c
49137 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49138
49139 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49140 #ifdef CONFIG_CIFS_STATS2
49141 - atomic_set(&totBufAllocCount, 0);
49142 - atomic_set(&totSmBufAllocCount, 0);
49143 + atomic_set_unchecked(&totBufAllocCount, 0);
49144 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49145 #endif /* CONFIG_CIFS_STATS2 */
49146 spin_lock(&cifs_tcp_ses_lock);
49147 list_for_each(tmp1, &cifs_tcp_ses_list) {
49148 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49149 tcon = list_entry(tmp3,
49150 struct cifs_tcon,
49151 tcon_list);
49152 - atomic_set(&tcon->num_smbs_sent, 0);
49153 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49154 if (server->ops->clear_stats)
49155 server->ops->clear_stats(tcon);
49156 }
49157 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49158 smBufAllocCount.counter, cifs_min_small);
49159 #ifdef CONFIG_CIFS_STATS2
49160 seq_printf(m, "Total Large %d Small %d Allocations\n",
49161 - atomic_read(&totBufAllocCount),
49162 - atomic_read(&totSmBufAllocCount));
49163 + atomic_read_unchecked(&totBufAllocCount),
49164 + atomic_read_unchecked(&totSmBufAllocCount));
49165 #endif /* CONFIG_CIFS_STATS2 */
49166
49167 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49168 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49169 if (tcon->need_reconnect)
49170 seq_puts(m, "\tDISCONNECTED ");
49171 seq_printf(m, "\nSMBs: %d",
49172 - atomic_read(&tcon->num_smbs_sent));
49173 + atomic_read_unchecked(&tcon->num_smbs_sent));
49174 if (server->ops->print_stats)
49175 server->ops->print_stats(m, tcon);
49176 }
49177 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49178 index b9db388..9a73d6d 100644
49179 --- a/fs/cifs/cifsfs.c
49180 +++ b/fs/cifs/cifsfs.c
49181 @@ -1026,7 +1026,7 @@ cifs_init_request_bufs(void)
49182 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49183 cifs_req_cachep = kmem_cache_create("cifs_request",
49184 CIFSMaxBufSize + max_hdr_size, 0,
49185 - SLAB_HWCACHE_ALIGN, NULL);
49186 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49187 if (cifs_req_cachep == NULL)
49188 return -ENOMEM;
49189
49190 @@ -1053,7 +1053,7 @@ cifs_init_request_bufs(void)
49191 efficient to alloc 1 per page off the slab compared to 17K (5page)
49192 alloc of large cifs buffers even when page debugging is on */
49193 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49194 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49195 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49196 NULL);
49197 if (cifs_sm_req_cachep == NULL) {
49198 mempool_destroy(cifs_req_poolp);
49199 @@ -1138,8 +1138,8 @@ init_cifs(void)
49200 atomic_set(&bufAllocCount, 0);
49201 atomic_set(&smBufAllocCount, 0);
49202 #ifdef CONFIG_CIFS_STATS2
49203 - atomic_set(&totBufAllocCount, 0);
49204 - atomic_set(&totSmBufAllocCount, 0);
49205 + atomic_set_unchecked(&totBufAllocCount, 0);
49206 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49207 #endif /* CONFIG_CIFS_STATS2 */
49208
49209 atomic_set(&midCount, 0);
49210 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49211 index e6899ce..d6b2920 100644
49212 --- a/fs/cifs/cifsglob.h
49213 +++ b/fs/cifs/cifsglob.h
49214 @@ -751,35 +751,35 @@ struct cifs_tcon {
49215 __u16 Flags; /* optional support bits */
49216 enum statusEnum tidStatus;
49217 #ifdef CONFIG_CIFS_STATS
49218 - atomic_t num_smbs_sent;
49219 + atomic_unchecked_t num_smbs_sent;
49220 union {
49221 struct {
49222 - atomic_t num_writes;
49223 - atomic_t num_reads;
49224 - atomic_t num_flushes;
49225 - atomic_t num_oplock_brks;
49226 - atomic_t num_opens;
49227 - atomic_t num_closes;
49228 - atomic_t num_deletes;
49229 - atomic_t num_mkdirs;
49230 - atomic_t num_posixopens;
49231 - atomic_t num_posixmkdirs;
49232 - atomic_t num_rmdirs;
49233 - atomic_t num_renames;
49234 - atomic_t num_t2renames;
49235 - atomic_t num_ffirst;
49236 - atomic_t num_fnext;
49237 - atomic_t num_fclose;
49238 - atomic_t num_hardlinks;
49239 - atomic_t num_symlinks;
49240 - atomic_t num_locks;
49241 - atomic_t num_acl_get;
49242 - atomic_t num_acl_set;
49243 + atomic_unchecked_t num_writes;
49244 + atomic_unchecked_t num_reads;
49245 + atomic_unchecked_t num_flushes;
49246 + atomic_unchecked_t num_oplock_brks;
49247 + atomic_unchecked_t num_opens;
49248 + atomic_unchecked_t num_closes;
49249 + atomic_unchecked_t num_deletes;
49250 + atomic_unchecked_t num_mkdirs;
49251 + atomic_unchecked_t num_posixopens;
49252 + atomic_unchecked_t num_posixmkdirs;
49253 + atomic_unchecked_t num_rmdirs;
49254 + atomic_unchecked_t num_renames;
49255 + atomic_unchecked_t num_t2renames;
49256 + atomic_unchecked_t num_ffirst;
49257 + atomic_unchecked_t num_fnext;
49258 + atomic_unchecked_t num_fclose;
49259 + atomic_unchecked_t num_hardlinks;
49260 + atomic_unchecked_t num_symlinks;
49261 + atomic_unchecked_t num_locks;
49262 + atomic_unchecked_t num_acl_get;
49263 + atomic_unchecked_t num_acl_set;
49264 } cifs_stats;
49265 #ifdef CONFIG_CIFS_SMB2
49266 struct {
49267 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49268 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49269 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49270 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49271 } smb2_stats;
49272 #endif /* CONFIG_CIFS_SMB2 */
49273 } stats;
49274 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49275 }
49276
49277 #ifdef CONFIG_CIFS_STATS
49278 -#define cifs_stats_inc atomic_inc
49279 +#define cifs_stats_inc atomic_inc_unchecked
49280
49281 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49282 unsigned int bytes)
49283 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49284 /* Various Debug counters */
49285 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49286 #ifdef CONFIG_CIFS_STATS2
49287 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49288 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49289 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49290 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49291 #endif
49292 GLOBAL_EXTERN atomic_t smBufAllocCount;
49293 GLOBAL_EXTERN atomic_t midCount;
49294 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49295 index 51dc2fb..1e12a33 100644
49296 --- a/fs/cifs/link.c
49297 +++ b/fs/cifs/link.c
49298 @@ -616,7 +616,7 @@ symlink_exit:
49299
49300 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49301 {
49302 - char *p = nd_get_link(nd);
49303 + const char *p = nd_get_link(nd);
49304 if (!IS_ERR(p))
49305 kfree(p);
49306 }
49307 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49308 index 3a00c0d..42d901c 100644
49309 --- a/fs/cifs/misc.c
49310 +++ b/fs/cifs/misc.c
49311 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49312 memset(ret_buf, 0, buf_size + 3);
49313 atomic_inc(&bufAllocCount);
49314 #ifdef CONFIG_CIFS_STATS2
49315 - atomic_inc(&totBufAllocCount);
49316 + atomic_inc_unchecked(&totBufAllocCount);
49317 #endif /* CONFIG_CIFS_STATS2 */
49318 }
49319
49320 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49321 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49322 atomic_inc(&smBufAllocCount);
49323 #ifdef CONFIG_CIFS_STATS2
49324 - atomic_inc(&totSmBufAllocCount);
49325 + atomic_inc_unchecked(&totSmBufAllocCount);
49326 #endif /* CONFIG_CIFS_STATS2 */
49327
49328 }
49329 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49330 index 47bc5a8..10decbe 100644
49331 --- a/fs/cifs/smb1ops.c
49332 +++ b/fs/cifs/smb1ops.c
49333 @@ -586,27 +586,27 @@ static void
49334 cifs_clear_stats(struct cifs_tcon *tcon)
49335 {
49336 #ifdef CONFIG_CIFS_STATS
49337 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49338 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49339 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49340 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49341 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49342 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49343 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49344 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49345 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49346 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49347 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49348 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49349 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49350 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49351 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49352 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49353 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49354 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49355 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49356 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49357 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49358 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49359 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49360 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49361 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49362 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49363 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49364 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49365 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49366 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49367 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49368 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49369 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49370 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49371 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49372 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49373 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49374 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49375 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49376 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49377 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49378 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49379 #endif
49380 }
49381
49382 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49383 {
49384 #ifdef CONFIG_CIFS_STATS
49385 seq_printf(m, " Oplocks breaks: %d",
49386 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49387 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49388 seq_printf(m, "\nReads: %d Bytes: %llu",
49389 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49390 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49391 (long long)(tcon->bytes_read));
49392 seq_printf(m, "\nWrites: %d Bytes: %llu",
49393 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49394 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49395 (long long)(tcon->bytes_written));
49396 seq_printf(m, "\nFlushes: %d",
49397 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49398 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49399 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49400 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49401 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49402 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49403 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49404 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49405 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49406 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49407 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49408 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49409 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49410 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49411 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49412 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49413 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49414 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49415 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49416 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49417 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49418 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49419 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49420 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49421 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49422 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49423 seq_printf(m, "\nRenames: %d T2 Renames %d",
49424 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49425 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49426 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49427 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49428 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49429 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49430 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49431 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49432 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49433 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49434 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49435 #endif
49436 }
49437
49438 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49439 index bceffe7..cd1ae59 100644
49440 --- a/fs/cifs/smb2ops.c
49441 +++ b/fs/cifs/smb2ops.c
49442 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49443 #ifdef CONFIG_CIFS_STATS
49444 int i;
49445 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49446 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49447 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49448 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49449 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49450 }
49451 #endif
49452 }
49453 @@ -284,66 +284,66 @@ static void
49454 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49455 {
49456 #ifdef CONFIG_CIFS_STATS
49457 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49458 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49459 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49460 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49461 seq_printf(m, "\nNegotiates: %d sent %d failed",
49462 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49463 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49464 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49465 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49466 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49467 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
49468 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
49469 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
49470 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
49471 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
49472 seq_printf(m, "\nLogoffs: %d sent %d failed",
49473 - atomic_read(&sent[SMB2_LOGOFF_HE]),
49474 - atomic_read(&failed[SMB2_LOGOFF_HE]));
49475 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
49476 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
49477 seq_printf(m, "\nTreeConnects: %d sent %d failed",
49478 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
49479 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
49480 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
49481 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
49482 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
49483 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
49484 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
49485 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
49486 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
49487 seq_printf(m, "\nCreates: %d sent %d failed",
49488 - atomic_read(&sent[SMB2_CREATE_HE]),
49489 - atomic_read(&failed[SMB2_CREATE_HE]));
49490 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
49491 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
49492 seq_printf(m, "\nCloses: %d sent %d failed",
49493 - atomic_read(&sent[SMB2_CLOSE_HE]),
49494 - atomic_read(&failed[SMB2_CLOSE_HE]));
49495 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
49496 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
49497 seq_printf(m, "\nFlushes: %d sent %d failed",
49498 - atomic_read(&sent[SMB2_FLUSH_HE]),
49499 - atomic_read(&failed[SMB2_FLUSH_HE]));
49500 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
49501 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
49502 seq_printf(m, "\nReads: %d sent %d failed",
49503 - atomic_read(&sent[SMB2_READ_HE]),
49504 - atomic_read(&failed[SMB2_READ_HE]));
49505 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
49506 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
49507 seq_printf(m, "\nWrites: %d sent %d failed",
49508 - atomic_read(&sent[SMB2_WRITE_HE]),
49509 - atomic_read(&failed[SMB2_WRITE_HE]));
49510 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
49511 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
49512 seq_printf(m, "\nLocks: %d sent %d failed",
49513 - atomic_read(&sent[SMB2_LOCK_HE]),
49514 - atomic_read(&failed[SMB2_LOCK_HE]));
49515 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
49516 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
49517 seq_printf(m, "\nIOCTLs: %d sent %d failed",
49518 - atomic_read(&sent[SMB2_IOCTL_HE]),
49519 - atomic_read(&failed[SMB2_IOCTL_HE]));
49520 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
49521 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
49522 seq_printf(m, "\nCancels: %d sent %d failed",
49523 - atomic_read(&sent[SMB2_CANCEL_HE]),
49524 - atomic_read(&failed[SMB2_CANCEL_HE]));
49525 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
49526 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
49527 seq_printf(m, "\nEchos: %d sent %d failed",
49528 - atomic_read(&sent[SMB2_ECHO_HE]),
49529 - atomic_read(&failed[SMB2_ECHO_HE]));
49530 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
49531 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
49532 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
49533 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
49534 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
49535 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
49536 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
49537 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
49538 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
49539 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
49540 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
49541 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
49542 seq_printf(m, "\nQueryInfos: %d sent %d failed",
49543 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
49544 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
49545 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
49546 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
49547 seq_printf(m, "\nSetInfos: %d sent %d failed",
49548 - atomic_read(&sent[SMB2_SET_INFO_HE]),
49549 - atomic_read(&failed[SMB2_SET_INFO_HE]));
49550 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
49551 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
49552 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
49553 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
49554 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
49555 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
49556 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
49557 #endif
49558 }
49559
49560 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
49561 index 41d9d07..dbb4772 100644
49562 --- a/fs/cifs/smb2pdu.c
49563 +++ b/fs/cifs/smb2pdu.c
49564 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
49565 default:
49566 cERROR(1, "info level %u isn't supported",
49567 srch_inf->info_level);
49568 - rc = -EINVAL;
49569 - goto qdir_exit;
49570 + return -EINVAL;
49571 }
49572
49573 req->FileIndex = cpu_to_le32(index);
49574 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
49575 index 958ae0e..505c9d0 100644
49576 --- a/fs/coda/cache.c
49577 +++ b/fs/coda/cache.c
49578 @@ -24,7 +24,7 @@
49579 #include "coda_linux.h"
49580 #include "coda_cache.h"
49581
49582 -static atomic_t permission_epoch = ATOMIC_INIT(0);
49583 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
49584
49585 /* replace or extend an acl cache hit */
49586 void coda_cache_enter(struct inode *inode, int mask)
49587 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
49588 struct coda_inode_info *cii = ITOC(inode);
49589
49590 spin_lock(&cii->c_lock);
49591 - cii->c_cached_epoch = atomic_read(&permission_epoch);
49592 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
49593 if (cii->c_uid != current_fsuid()) {
49594 cii->c_uid = current_fsuid();
49595 cii->c_cached_perm = mask;
49596 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
49597 {
49598 struct coda_inode_info *cii = ITOC(inode);
49599 spin_lock(&cii->c_lock);
49600 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
49601 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
49602 spin_unlock(&cii->c_lock);
49603 }
49604
49605 /* remove all acl caches */
49606 void coda_cache_clear_all(struct super_block *sb)
49607 {
49608 - atomic_inc(&permission_epoch);
49609 + atomic_inc_unchecked(&permission_epoch);
49610 }
49611
49612
49613 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
49614 spin_lock(&cii->c_lock);
49615 hit = (mask & cii->c_cached_perm) == mask &&
49616 cii->c_uid == current_fsuid() &&
49617 - cii->c_cached_epoch == atomic_read(&permission_epoch);
49618 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
49619 spin_unlock(&cii->c_lock);
49620
49621 return hit;
49622 diff --git a/fs/compat.c b/fs/compat.c
49623 index a06dcbc..dacb6d3 100644
49624 --- a/fs/compat.c
49625 +++ b/fs/compat.c
49626 @@ -54,7 +54,7 @@
49627 #include <asm/ioctls.h>
49628 #include "internal.h"
49629
49630 -int compat_log = 1;
49631 +int compat_log = 0;
49632
49633 int compat_printk(const char *fmt, ...)
49634 {
49635 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
49636
49637 set_fs(KERNEL_DS);
49638 /* The __user pointer cast is valid because of the set_fs() */
49639 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
49640 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
49641 set_fs(oldfs);
49642 /* truncating is ok because it's a user address */
49643 if (!ret)
49644 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
49645 goto out;
49646
49647 ret = -EINVAL;
49648 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
49649 + if (nr_segs > UIO_MAXIOV)
49650 goto out;
49651 if (nr_segs > fast_segs) {
49652 ret = -ENOMEM;
49653 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
49654
49655 struct compat_readdir_callback {
49656 struct compat_old_linux_dirent __user *dirent;
49657 + struct file * file;
49658 int result;
49659 };
49660
49661 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
49662 buf->result = -EOVERFLOW;
49663 return -EOVERFLOW;
49664 }
49665 +
49666 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49667 + return 0;
49668 +
49669 buf->result++;
49670 dirent = buf->dirent;
49671 if (!access_ok(VERIFY_WRITE, dirent,
49672 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
49673
49674 buf.result = 0;
49675 buf.dirent = dirent;
49676 + buf.file = f.file;
49677
49678 error = vfs_readdir(f.file, compat_fillonedir, &buf);
49679 if (buf.result)
49680 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
49681 struct compat_getdents_callback {
49682 struct compat_linux_dirent __user *current_dir;
49683 struct compat_linux_dirent __user *previous;
49684 + struct file * file;
49685 int count;
49686 int error;
49687 };
49688 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
49689 buf->error = -EOVERFLOW;
49690 return -EOVERFLOW;
49691 }
49692 +
49693 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49694 + return 0;
49695 +
49696 dirent = buf->previous;
49697 if (dirent) {
49698 if (__put_user(offset, &dirent->d_off))
49699 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49700 buf.previous = NULL;
49701 buf.count = count;
49702 buf.error = 0;
49703 + buf.file = f.file;
49704
49705 error = vfs_readdir(f.file, compat_filldir, &buf);
49706 if (error >= 0)
49707 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49708 struct compat_getdents_callback64 {
49709 struct linux_dirent64 __user *current_dir;
49710 struct linux_dirent64 __user *previous;
49711 + struct file * file;
49712 int count;
49713 int error;
49714 };
49715 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
49716 buf->error = -EINVAL; /* only used if we fail.. */
49717 if (reclen > buf->count)
49718 return -EINVAL;
49719 +
49720 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49721 + return 0;
49722 +
49723 dirent = buf->previous;
49724
49725 if (dirent) {
49726 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
49727 buf.previous = NULL;
49728 buf.count = count;
49729 buf.error = 0;
49730 + buf.file = f.file;
49731
49732 error = vfs_readdir(f.file, compat_filldir64, &buf);
49733 if (error >= 0)
49734 error = buf.error;
49735 lastdirent = buf.previous;
49736 if (lastdirent) {
49737 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
49738 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
49739 if (__put_user_unaligned(d_off, &lastdirent->d_off))
49740 error = -EFAULT;
49741 else
49742 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
49743 index a81147e..20bf2b5 100644
49744 --- a/fs/compat_binfmt_elf.c
49745 +++ b/fs/compat_binfmt_elf.c
49746 @@ -30,11 +30,13 @@
49747 #undef elf_phdr
49748 #undef elf_shdr
49749 #undef elf_note
49750 +#undef elf_dyn
49751 #undef elf_addr_t
49752 #define elfhdr elf32_hdr
49753 #define elf_phdr elf32_phdr
49754 #define elf_shdr elf32_shdr
49755 #define elf_note elf32_note
49756 +#define elf_dyn Elf32_Dyn
49757 #define elf_addr_t Elf32_Addr
49758
49759 /*
49760 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
49761 index e2f57a0..3c78771 100644
49762 --- a/fs/compat_ioctl.c
49763 +++ b/fs/compat_ioctl.c
49764 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
49765 return -EFAULT;
49766 if (__get_user(udata, &ss32->iomem_base))
49767 return -EFAULT;
49768 - ss.iomem_base = compat_ptr(udata);
49769 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
49770 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
49771 __get_user(ss.port_high, &ss32->port_high))
49772 return -EFAULT;
49773 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
49774 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
49775 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
49776 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
49777 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49778 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49779 return -EFAULT;
49780
49781 return ioctl_preallocate(file, p);
49782 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
49783 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
49784 {
49785 unsigned int a, b;
49786 - a = *(unsigned int *)p;
49787 - b = *(unsigned int *)q;
49788 + a = *(const unsigned int *)p;
49789 + b = *(const unsigned int *)q;
49790 if (a > b)
49791 return 1;
49792 if (a < b)
49793 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
49794 index 712b10f..c33c4ca 100644
49795 --- a/fs/configfs/dir.c
49796 +++ b/fs/configfs/dir.c
49797 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
49798 static int configfs_depend_prep(struct dentry *origin,
49799 struct config_item *target)
49800 {
49801 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
49802 + struct configfs_dirent *child_sd, *sd;
49803 int ret = 0;
49804
49805 - BUG_ON(!origin || !sd);
49806 + BUG_ON(!origin || !origin->d_fsdata);
49807 + sd = origin->d_fsdata;
49808
49809 if (sd->s_element == target) /* Boo-yah */
49810 goto out;
49811 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49812 }
49813 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
49814 struct configfs_dirent *next;
49815 - const char * name;
49816 + const unsigned char * name;
49817 + char d_name[sizeof(next->s_dentry->d_iname)];
49818 int len;
49819 struct inode *inode = NULL;
49820
49821 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49822 continue;
49823
49824 name = configfs_get_name(next);
49825 - len = strlen(name);
49826 + if (next->s_dentry && name == next->s_dentry->d_iname) {
49827 + len = next->s_dentry->d_name.len;
49828 + memcpy(d_name, name, len);
49829 + name = d_name;
49830 + } else
49831 + len = strlen(name);
49832
49833 /*
49834 * We'll have a dentry and an inode for
49835 diff --git a/fs/coredump.c b/fs/coredump.c
49836 index 1774932..5812106 100644
49837 --- a/fs/coredump.c
49838 +++ b/fs/coredump.c
49839 @@ -52,7 +52,7 @@ struct core_name {
49840 char *corename;
49841 int used, size;
49842 };
49843 -static atomic_t call_count = ATOMIC_INIT(1);
49844 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
49845
49846 /* The maximal length of core_pattern is also specified in sysctl.c */
49847
49848 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
49849 {
49850 char *old_corename = cn->corename;
49851
49852 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
49853 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
49854 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
49855
49856 if (!cn->corename) {
49857 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
49858 int pid_in_pattern = 0;
49859 int err = 0;
49860
49861 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
49862 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
49863 cn->corename = kmalloc(cn->size, GFP_KERNEL);
49864 cn->used = 0;
49865
49866 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
49867 pipe = file->f_path.dentry->d_inode->i_pipe;
49868
49869 pipe_lock(pipe);
49870 - pipe->readers++;
49871 - pipe->writers--;
49872 + atomic_inc(&pipe->readers);
49873 + atomic_dec(&pipe->writers);
49874
49875 - while ((pipe->readers > 1) && (!signal_pending(current))) {
49876 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
49877 wake_up_interruptible_sync(&pipe->wait);
49878 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
49879 pipe_wait(pipe);
49880 }
49881
49882 - pipe->readers--;
49883 - pipe->writers++;
49884 + atomic_dec(&pipe->readers);
49885 + atomic_inc(&pipe->writers);
49886 pipe_unlock(pipe);
49887
49888 }
49889 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
49890 int ispipe;
49891 struct files_struct *displaced;
49892 bool need_nonrelative = false;
49893 - static atomic_t core_dump_count = ATOMIC_INIT(0);
49894 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
49895 + long signr = siginfo->si_signo;
49896 struct coredump_params cprm = {
49897 .siginfo = siginfo,
49898 .regs = signal_pt_regs(),
49899 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
49900 .mm_flags = mm->flags,
49901 };
49902
49903 - audit_core_dumps(siginfo->si_signo);
49904 + audit_core_dumps(signr);
49905 +
49906 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
49907 + gr_handle_brute_attach(cprm.mm_flags);
49908
49909 binfmt = mm->binfmt;
49910 if (!binfmt || !binfmt->core_dump)
49911 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
49912 need_nonrelative = true;
49913 }
49914
49915 - retval = coredump_wait(siginfo->si_signo, &core_state);
49916 + retval = coredump_wait(signr, &core_state);
49917 if (retval < 0)
49918 goto fail_creds;
49919
49920 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
49921 }
49922 cprm.limit = RLIM_INFINITY;
49923
49924 - dump_count = atomic_inc_return(&core_dump_count);
49925 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
49926 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
49927 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
49928 task_tgid_vnr(current), current->comm);
49929 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
49930 } else {
49931 struct inode *inode;
49932
49933 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
49934 +
49935 if (cprm.limit < binfmt->min_coredump)
49936 goto fail_unlock;
49937
49938 @@ -640,7 +646,7 @@ close_fail:
49939 filp_close(cprm.file, NULL);
49940 fail_dropcount:
49941 if (ispipe)
49942 - atomic_dec(&core_dump_count);
49943 + atomic_dec_unchecked(&core_dump_count);
49944 fail_unlock:
49945 kfree(cn.corename);
49946 fail_corename:
49947 @@ -659,7 +665,7 @@ fail:
49948 */
49949 int dump_write(struct file *file, const void *addr, int nr)
49950 {
49951 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
49952 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
49953 }
49954 EXPORT_SYMBOL(dump_write);
49955
49956 diff --git a/fs/dcache.c b/fs/dcache.c
49957 index 19153a0..5b71101 100644
49958 --- a/fs/dcache.c
49959 +++ b/fs/dcache.c
49960 @@ -2552,7 +2552,6 @@ static int prepend_path(const struct path *path,
49961 bool slash = false;
49962 int error = 0;
49963
49964 - br_read_lock(&vfsmount_lock);
49965 while (dentry != root->dentry || vfsmnt != root->mnt) {
49966 struct dentry * parent;
49967
49968 @@ -2582,8 +2581,6 @@ static int prepend_path(const struct path *path,
49969 if (!error && !slash)
49970 error = prepend(buffer, buflen, "/", 1);
49971
49972 -out:
49973 - br_read_unlock(&vfsmount_lock);
49974 return error;
49975
49976 global_root:
49977 @@ -2600,7 +2597,7 @@ global_root:
49978 error = prepend(buffer, buflen, "/", 1);
49979 if (!error)
49980 error = is_mounted(vfsmnt) ? 1 : 2;
49981 - goto out;
49982 + return error;
49983 }
49984
49985 /**
49986 @@ -2627,9 +2624,11 @@ char *__d_path(const struct path *path,
49987 int error;
49988
49989 prepend(&res, &buflen, "\0", 1);
49990 + br_read_lock(&vfsmount_lock);
49991 write_seqlock(&rename_lock);
49992 error = prepend_path(path, root, &res, &buflen);
49993 write_sequnlock(&rename_lock);
49994 + br_read_unlock(&vfsmount_lock);
49995
49996 if (error < 0)
49997 return ERR_PTR(error);
49998 @@ -2646,9 +2645,11 @@ char *d_absolute_path(const struct path *path,
49999 int error;
50000
50001 prepend(&res, &buflen, "\0", 1);
50002 + br_read_lock(&vfsmount_lock);
50003 write_seqlock(&rename_lock);
50004 error = prepend_path(path, &root, &res, &buflen);
50005 write_sequnlock(&rename_lock);
50006 + br_read_unlock(&vfsmount_lock);
50007
50008 if (error > 1)
50009 error = -EINVAL;
50010 @@ -2712,11 +2713,13 @@ char *d_path(const struct path *path, char *buf, int buflen)
50011 return path->dentry->d_op->d_dname(path->dentry, buf, buflen);
50012
50013 get_fs_root(current->fs, &root);
50014 + br_read_lock(&vfsmount_lock);
50015 write_seqlock(&rename_lock);
50016 error = path_with_deleted(path, &root, &res, &buflen);
50017 + write_sequnlock(&rename_lock);
50018 + br_read_unlock(&vfsmount_lock);
50019 if (error < 0)
50020 res = ERR_PTR(error);
50021 - write_sequnlock(&rename_lock);
50022 path_put(&root);
50023 return res;
50024 }
50025 @@ -2871,6 +2874,7 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size)
50026 get_fs_root_and_pwd(current->fs, &root, &pwd);
50027
50028 error = -ENOENT;
50029 + br_read_lock(&vfsmount_lock);
50030 write_seqlock(&rename_lock);
50031 if (!d_unlinked(pwd.dentry)) {
50032 unsigned long len;
50033 @@ -2880,6 +2884,7 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size)
50034 prepend(&cwd, &buflen, "\0", 1);
50035 error = prepend_path(&pwd, &root, &cwd, &buflen);
50036 write_sequnlock(&rename_lock);
50037 + br_read_unlock(&vfsmount_lock);
50038
50039 if (error < 0)
50040 goto out;
50041 @@ -2900,6 +2905,7 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size)
50042 }
50043 } else {
50044 write_sequnlock(&rename_lock);
50045 + br_read_unlock(&vfsmount_lock);
50046 }
50047
50048 out:
50049 @@ -3133,7 +3139,7 @@ void __init vfs_caches_init(unsigned long mempages)
50050 mempages -= reserve;
50051
50052 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50053 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50054 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50055
50056 dcache_init();
50057 inode_init();
50058 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50059 index a5f12b7..4ee8a6f 100644
50060 --- a/fs/debugfs/inode.c
50061 +++ b/fs/debugfs/inode.c
50062 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50063 */
50064 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50065 {
50066 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50067 + return __create_file(name, S_IFDIR | S_IRWXU,
50068 +#else
50069 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50070 +#endif
50071 parent, NULL, NULL);
50072 }
50073 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50074 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50075 index cc7709e..7e7211f 100644
50076 --- a/fs/ecryptfs/inode.c
50077 +++ b/fs/ecryptfs/inode.c
50078 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50079 old_fs = get_fs();
50080 set_fs(get_ds());
50081 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50082 - (char __user *)lower_buf,
50083 + (char __force_user *)lower_buf,
50084 PATH_MAX);
50085 set_fs(old_fs);
50086 if (rc < 0)
50087 @@ -706,7 +706,7 @@ out:
50088 static void
50089 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50090 {
50091 - char *buf = nd_get_link(nd);
50092 + const char *buf = nd_get_link(nd);
50093 if (!IS_ERR(buf)) {
50094 /* Free the char* */
50095 kfree(buf);
50096 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50097 index 412e6ed..4292d22 100644
50098 --- a/fs/ecryptfs/miscdev.c
50099 +++ b/fs/ecryptfs/miscdev.c
50100 @@ -315,7 +315,7 @@ check_list:
50101 goto out_unlock_msg_ctx;
50102 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50103 if (msg_ctx->msg) {
50104 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50105 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50106 goto out_unlock_msg_ctx;
50107 i += packet_length_size;
50108 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50109 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50110 index b2a34a1..162fa69 100644
50111 --- a/fs/ecryptfs/read_write.c
50112 +++ b/fs/ecryptfs/read_write.c
50113 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
50114 return -EIO;
50115 fs_save = get_fs();
50116 set_fs(get_ds());
50117 - rc = vfs_write(lower_file, data, size, &offset);
50118 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
50119 set_fs(fs_save);
50120 mark_inode_dirty_sync(ecryptfs_inode);
50121 return rc;
50122 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50123 return -EIO;
50124 fs_save = get_fs();
50125 set_fs(get_ds());
50126 - rc = vfs_read(lower_file, data, size, &offset);
50127 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50128 set_fs(fs_save);
50129 return rc;
50130 }
50131 diff --git a/fs/exec.c b/fs/exec.c
50132 index 20df02c..1b1d946 100644
50133 --- a/fs/exec.c
50134 +++ b/fs/exec.c
50135 @@ -55,6 +55,17 @@
50136 #include <linux/pipe_fs_i.h>
50137 #include <linux/oom.h>
50138 #include <linux/compat.h>
50139 +#include <linux/random.h>
50140 +#include <linux/seq_file.h>
50141 +#include <linux/coredump.h>
50142 +#include <linux/mman.h>
50143 +
50144 +#ifdef CONFIG_PAX_REFCOUNT
50145 +#include <linux/kallsyms.h>
50146 +#include <linux/kdebug.h>
50147 +#endif
50148 +
50149 +#include <trace/events/fs.h>
50150
50151 #include <asm/uaccess.h>
50152 #include <asm/mmu_context.h>
50153 @@ -66,6 +77,18 @@
50154
50155 #include <trace/events/sched.h>
50156
50157 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50158 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50159 +{
50160 + 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");
50161 +}
50162 +#endif
50163 +
50164 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50165 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50166 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50167 +#endif
50168 +
50169 int suid_dumpable = 0;
50170
50171 static LIST_HEAD(formats);
50172 @@ -75,8 +98,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50173 {
50174 BUG_ON(!fmt);
50175 write_lock(&binfmt_lock);
50176 - insert ? list_add(&fmt->lh, &formats) :
50177 - list_add_tail(&fmt->lh, &formats);
50178 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50179 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50180 write_unlock(&binfmt_lock);
50181 }
50182
50183 @@ -85,7 +108,7 @@ EXPORT_SYMBOL(__register_binfmt);
50184 void unregister_binfmt(struct linux_binfmt * fmt)
50185 {
50186 write_lock(&binfmt_lock);
50187 - list_del(&fmt->lh);
50188 + pax_list_del((struct list_head *)&fmt->lh);
50189 write_unlock(&binfmt_lock);
50190 }
50191
50192 @@ -180,18 +203,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50193 int write)
50194 {
50195 struct page *page;
50196 - int ret;
50197
50198 -#ifdef CONFIG_STACK_GROWSUP
50199 - if (write) {
50200 - ret = expand_downwards(bprm->vma, pos);
50201 - if (ret < 0)
50202 - return NULL;
50203 - }
50204 -#endif
50205 - ret = get_user_pages(current, bprm->mm, pos,
50206 - 1, write, 1, &page, NULL);
50207 - if (ret <= 0)
50208 + if (0 > expand_downwards(bprm->vma, pos))
50209 + return NULL;
50210 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50211 return NULL;
50212
50213 if (write) {
50214 @@ -207,6 +222,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50215 if (size <= ARG_MAX)
50216 return page;
50217
50218 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50219 + // only allow 512KB for argv+env on suid/sgid binaries
50220 + // to prevent easy ASLR exhaustion
50221 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50222 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50223 + (size > (512 * 1024))) {
50224 + put_page(page);
50225 + return NULL;
50226 + }
50227 +#endif
50228 +
50229 /*
50230 * Limit to 1/4-th the stack size for the argv+env strings.
50231 * This ensures that:
50232 @@ -266,6 +292,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50233 vma->vm_end = STACK_TOP_MAX;
50234 vma->vm_start = vma->vm_end - PAGE_SIZE;
50235 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50236 +
50237 +#ifdef CONFIG_PAX_SEGMEXEC
50238 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50239 +#endif
50240 +
50241 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50242 INIT_LIST_HEAD(&vma->anon_vma_chain);
50243
50244 @@ -276,6 +307,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50245 mm->stack_vm = mm->total_vm = 1;
50246 up_write(&mm->mmap_sem);
50247 bprm->p = vma->vm_end - sizeof(void *);
50248 +
50249 +#ifdef CONFIG_PAX_RANDUSTACK
50250 + if (randomize_va_space)
50251 + bprm->p ^= random32() & ~PAGE_MASK;
50252 +#endif
50253 +
50254 return 0;
50255 err:
50256 up_write(&mm->mmap_sem);
50257 @@ -396,7 +433,7 @@ struct user_arg_ptr {
50258 } ptr;
50259 };
50260
50261 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50262 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50263 {
50264 const char __user *native;
50265
50266 @@ -405,14 +442,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50267 compat_uptr_t compat;
50268
50269 if (get_user(compat, argv.ptr.compat + nr))
50270 - return ERR_PTR(-EFAULT);
50271 + return (const char __force_user *)ERR_PTR(-EFAULT);
50272
50273 return compat_ptr(compat);
50274 }
50275 #endif
50276
50277 if (get_user(native, argv.ptr.native + nr))
50278 - return ERR_PTR(-EFAULT);
50279 + return (const char __force_user *)ERR_PTR(-EFAULT);
50280
50281 return native;
50282 }
50283 @@ -431,7 +468,7 @@ static int count(struct user_arg_ptr argv, int max)
50284 if (!p)
50285 break;
50286
50287 - if (IS_ERR(p))
50288 + if (IS_ERR((const char __force_kernel *)p))
50289 return -EFAULT;
50290
50291 if (i >= max)
50292 @@ -466,7 +503,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50293
50294 ret = -EFAULT;
50295 str = get_user_arg_ptr(argv, argc);
50296 - if (IS_ERR(str))
50297 + if (IS_ERR((const char __force_kernel *)str))
50298 goto out;
50299
50300 len = strnlen_user(str, MAX_ARG_STRLEN);
50301 @@ -548,7 +585,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50302 int r;
50303 mm_segment_t oldfs = get_fs();
50304 struct user_arg_ptr argv = {
50305 - .ptr.native = (const char __user *const __user *)__argv,
50306 + .ptr.native = (const char __force_user *const __force_user *)__argv,
50307 };
50308
50309 set_fs(KERNEL_DS);
50310 @@ -583,7 +620,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50311 unsigned long new_end = old_end - shift;
50312 struct mmu_gather tlb;
50313
50314 - BUG_ON(new_start > new_end);
50315 + if (new_start >= new_end || new_start < mmap_min_addr)
50316 + return -ENOMEM;
50317
50318 /*
50319 * ensure there are no vmas between where we want to go
50320 @@ -592,6 +630,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50321 if (vma != find_vma(mm, new_start))
50322 return -EFAULT;
50323
50324 +#ifdef CONFIG_PAX_SEGMEXEC
50325 + BUG_ON(pax_find_mirror_vma(vma));
50326 +#endif
50327 +
50328 /*
50329 * cover the whole range: [new_start, old_end)
50330 */
50331 @@ -672,10 +714,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50332 stack_top = arch_align_stack(stack_top);
50333 stack_top = PAGE_ALIGN(stack_top);
50334
50335 - if (unlikely(stack_top < mmap_min_addr) ||
50336 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50337 - return -ENOMEM;
50338 -
50339 stack_shift = vma->vm_end - stack_top;
50340
50341 bprm->p -= stack_shift;
50342 @@ -687,8 +725,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50343 bprm->exec -= stack_shift;
50344
50345 down_write(&mm->mmap_sem);
50346 +
50347 + /* Move stack pages down in memory. */
50348 + if (stack_shift) {
50349 + ret = shift_arg_pages(vma, stack_shift);
50350 + if (ret)
50351 + goto out_unlock;
50352 + }
50353 +
50354 vm_flags = VM_STACK_FLAGS;
50355
50356 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50357 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50358 + vm_flags &= ~VM_EXEC;
50359 +
50360 +#ifdef CONFIG_PAX_MPROTECT
50361 + if (mm->pax_flags & MF_PAX_MPROTECT)
50362 + vm_flags &= ~VM_MAYEXEC;
50363 +#endif
50364 +
50365 + }
50366 +#endif
50367 +
50368 /*
50369 * Adjust stack execute permissions; explicitly enable for
50370 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50371 @@ -707,13 +765,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50372 goto out_unlock;
50373 BUG_ON(prev != vma);
50374
50375 - /* Move stack pages down in memory. */
50376 - if (stack_shift) {
50377 - ret = shift_arg_pages(vma, stack_shift);
50378 - if (ret)
50379 - goto out_unlock;
50380 - }
50381 -
50382 /* mprotect_fixup is overkill to remove the temporary stack flags */
50383 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50384
50385 @@ -737,6 +788,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50386 #endif
50387 current->mm->start_stack = bprm->p;
50388 ret = expand_stack(vma, stack_base);
50389 +
50390 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50391 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50392 + unsigned long size, flags, vm_flags;
50393 +
50394 + size = STACK_TOP - vma->vm_end;
50395 + flags = MAP_FIXED | MAP_PRIVATE;
50396 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50397 +
50398 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
50399 +
50400 +#ifdef CONFIG_X86
50401 + if (!ret) {
50402 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50403 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), flags, vm_flags, 0);
50404 + }
50405 +#endif
50406 +
50407 + }
50408 +#endif
50409 +
50410 if (ret)
50411 ret = -EFAULT;
50412
50413 @@ -772,6 +844,8 @@ struct file *open_exec(const char *name)
50414
50415 fsnotify_open(file);
50416
50417 + trace_open_exec(name);
50418 +
50419 err = deny_write_access(file);
50420 if (err)
50421 goto exit;
50422 @@ -795,7 +869,7 @@ int kernel_read(struct file *file, loff_t offset,
50423 old_fs = get_fs();
50424 set_fs(get_ds());
50425 /* The cast to a user pointer is valid due to the set_fs() */
50426 - result = vfs_read(file, (void __user *)addr, count, &pos);
50427 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50428 set_fs(old_fs);
50429 return result;
50430 }
50431 @@ -1247,7 +1321,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50432 }
50433 rcu_read_unlock();
50434
50435 - if (p->fs->users > n_fs) {
50436 + if (atomic_read(&p->fs->users) > n_fs) {
50437 bprm->unsafe |= LSM_UNSAFE_SHARE;
50438 } else {
50439 res = -EAGAIN;
50440 @@ -1447,6 +1521,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50441
50442 EXPORT_SYMBOL(search_binary_handler);
50443
50444 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50445 +static DEFINE_PER_CPU(u64, exec_counter);
50446 +static int __init init_exec_counters(void)
50447 +{
50448 + unsigned int cpu;
50449 +
50450 + for_each_possible_cpu(cpu) {
50451 + per_cpu(exec_counter, cpu) = (u64)cpu;
50452 + }
50453 +
50454 + return 0;
50455 +}
50456 +early_initcall(init_exec_counters);
50457 +static inline void increment_exec_counter(void)
50458 +{
50459 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50460 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50461 +}
50462 +#else
50463 +static inline void increment_exec_counter(void) {}
50464 +#endif
50465 +
50466 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50467 + struct user_arg_ptr argv);
50468 +
50469 /*
50470 * sys_execve() executes a new program.
50471 */
50472 @@ -1454,6 +1553,11 @@ static int do_execve_common(const char *filename,
50473 struct user_arg_ptr argv,
50474 struct user_arg_ptr envp)
50475 {
50476 +#ifdef CONFIG_GRKERNSEC
50477 + struct file *old_exec_file;
50478 + struct acl_subject_label *old_acl;
50479 + struct rlimit old_rlim[RLIM_NLIMITS];
50480 +#endif
50481 struct linux_binprm *bprm;
50482 struct file *file;
50483 struct files_struct *displaced;
50484 @@ -1461,6 +1565,8 @@ static int do_execve_common(const char *filename,
50485 int retval;
50486 const struct cred *cred = current_cred();
50487
50488 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
50489 +
50490 /*
50491 * We move the actual failure in case of RLIMIT_NPROC excess from
50492 * set*uid() to execve() because too many poorly written programs
50493 @@ -1501,12 +1607,27 @@ static int do_execve_common(const char *filename,
50494 if (IS_ERR(file))
50495 goto out_unmark;
50496
50497 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50498 + retval = -EPERM;
50499 + goto out_file;
50500 + }
50501 +
50502 sched_exec();
50503
50504 bprm->file = file;
50505 bprm->filename = filename;
50506 bprm->interp = filename;
50507
50508 + if (gr_process_user_ban()) {
50509 + retval = -EPERM;
50510 + goto out_file;
50511 + }
50512 +
50513 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
50514 + retval = -EACCES;
50515 + goto out_file;
50516 + }
50517 +
50518 retval = bprm_mm_init(bprm);
50519 if (retval)
50520 goto out_file;
50521 @@ -1523,24 +1644,65 @@ static int do_execve_common(const char *filename,
50522 if (retval < 0)
50523 goto out;
50524
50525 +#ifdef CONFIG_GRKERNSEC
50526 + old_acl = current->acl;
50527 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50528 + old_exec_file = current->exec_file;
50529 + get_file(file);
50530 + current->exec_file = file;
50531 +#endif
50532 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50533 + /* limit suid stack to 8MB
50534 + * we saved the old limits above and will restore them if this exec fails
50535 + */
50536 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50537 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50538 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50539 +#endif
50540 +
50541 + if (!gr_tpe_allow(file)) {
50542 + retval = -EACCES;
50543 + goto out_fail;
50544 + }
50545 +
50546 + if (gr_check_crash_exec(file)) {
50547 + retval = -EACCES;
50548 + goto out_fail;
50549 + }
50550 +
50551 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
50552 + bprm->unsafe);
50553 + if (retval < 0)
50554 + goto out_fail;
50555 +
50556 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50557 if (retval < 0)
50558 - goto out;
50559 + goto out_fail;
50560
50561 bprm->exec = bprm->p;
50562 retval = copy_strings(bprm->envc, envp, bprm);
50563 if (retval < 0)
50564 - goto out;
50565 + goto out_fail;
50566
50567 retval = copy_strings(bprm->argc, argv, bprm);
50568 if (retval < 0)
50569 - goto out;
50570 + goto out_fail;
50571 +
50572 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
50573 +
50574 + gr_handle_exec_args(bprm, argv);
50575
50576 retval = search_binary_handler(bprm);
50577 if (retval < 0)
50578 - goto out;
50579 + goto out_fail;
50580 +#ifdef CONFIG_GRKERNSEC
50581 + if (old_exec_file)
50582 + fput(old_exec_file);
50583 +#endif
50584
50585 /* execve succeeded */
50586 +
50587 + increment_exec_counter();
50588 current->fs->in_exec = 0;
50589 current->in_execve = 0;
50590 acct_update_integrals(current);
50591 @@ -1549,6 +1711,14 @@ static int do_execve_common(const char *filename,
50592 put_files_struct(displaced);
50593 return retval;
50594
50595 +out_fail:
50596 +#ifdef CONFIG_GRKERNSEC
50597 + current->acl = old_acl;
50598 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
50599 + fput(current->exec_file);
50600 + current->exec_file = old_exec_file;
50601 +#endif
50602 +
50603 out:
50604 if (bprm->mm) {
50605 acct_arg_size(bprm, 0);
50606 @@ -1697,3 +1867,253 @@ asmlinkage long compat_sys_execve(const char __user * filename,
50607 return error;
50608 }
50609 #endif
50610 +
50611 +int pax_check_flags(unsigned long *flags)
50612 +{
50613 + int retval = 0;
50614 +
50615 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
50616 + if (*flags & MF_PAX_SEGMEXEC)
50617 + {
50618 + *flags &= ~MF_PAX_SEGMEXEC;
50619 + retval = -EINVAL;
50620 + }
50621 +#endif
50622 +
50623 + if ((*flags & MF_PAX_PAGEEXEC)
50624 +
50625 +#ifdef CONFIG_PAX_PAGEEXEC
50626 + && (*flags & MF_PAX_SEGMEXEC)
50627 +#endif
50628 +
50629 + )
50630 + {
50631 + *flags &= ~MF_PAX_PAGEEXEC;
50632 + retval = -EINVAL;
50633 + }
50634 +
50635 + if ((*flags & MF_PAX_MPROTECT)
50636 +
50637 +#ifdef CONFIG_PAX_MPROTECT
50638 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50639 +#endif
50640 +
50641 + )
50642 + {
50643 + *flags &= ~MF_PAX_MPROTECT;
50644 + retval = -EINVAL;
50645 + }
50646 +
50647 + if ((*flags & MF_PAX_EMUTRAMP)
50648 +
50649 +#ifdef CONFIG_PAX_EMUTRAMP
50650 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50651 +#endif
50652 +
50653 + )
50654 + {
50655 + *flags &= ~MF_PAX_EMUTRAMP;
50656 + retval = -EINVAL;
50657 + }
50658 +
50659 + return retval;
50660 +}
50661 +
50662 +EXPORT_SYMBOL(pax_check_flags);
50663 +
50664 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50665 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
50666 +{
50667 + struct task_struct *tsk = current;
50668 + struct mm_struct *mm = current->mm;
50669 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
50670 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
50671 + char *path_exec = NULL;
50672 + char *path_fault = NULL;
50673 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
50674 + siginfo_t info = { };
50675 +
50676 + if (buffer_exec && buffer_fault) {
50677 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
50678 +
50679 + down_read(&mm->mmap_sem);
50680 + vma = mm->mmap;
50681 + while (vma && (!vma_exec || !vma_fault)) {
50682 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
50683 + vma_exec = vma;
50684 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
50685 + vma_fault = vma;
50686 + vma = vma->vm_next;
50687 + }
50688 + if (vma_exec) {
50689 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
50690 + if (IS_ERR(path_exec))
50691 + path_exec = "<path too long>";
50692 + else {
50693 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
50694 + if (path_exec) {
50695 + *path_exec = 0;
50696 + path_exec = buffer_exec;
50697 + } else
50698 + path_exec = "<path too long>";
50699 + }
50700 + }
50701 + if (vma_fault) {
50702 + start = vma_fault->vm_start;
50703 + end = vma_fault->vm_end;
50704 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
50705 + if (vma_fault->vm_file) {
50706 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
50707 + if (IS_ERR(path_fault))
50708 + path_fault = "<path too long>";
50709 + else {
50710 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
50711 + if (path_fault) {
50712 + *path_fault = 0;
50713 + path_fault = buffer_fault;
50714 + } else
50715 + path_fault = "<path too long>";
50716 + }
50717 + } else
50718 + path_fault = "<anonymous mapping>";
50719 + }
50720 + up_read(&mm->mmap_sem);
50721 + }
50722 + if (tsk->signal->curr_ip)
50723 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
50724 + else
50725 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
50726 + 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),
50727 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
50728 + free_page((unsigned long)buffer_exec);
50729 + free_page((unsigned long)buffer_fault);
50730 + pax_report_insns(regs, pc, sp);
50731 + info.si_signo = SIGKILL;
50732 + info.si_errno = 0;
50733 + info.si_code = SI_KERNEL;
50734 + info.si_pid = 0;
50735 + info.si_uid = 0;
50736 + do_coredump(&info);
50737 +}
50738 +#endif
50739 +
50740 +#ifdef CONFIG_PAX_REFCOUNT
50741 +void pax_report_refcount_overflow(struct pt_regs *regs)
50742 +{
50743 + if (current->signal->curr_ip)
50744 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
50745 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
50746 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50747 + else
50748 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
50749 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50750 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
50751 + show_regs(regs);
50752 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
50753 +}
50754 +#endif
50755 +
50756 +#ifdef CONFIG_PAX_USERCOPY
50757 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
50758 +static noinline int check_stack_object(const void *obj, unsigned long len)
50759 +{
50760 + const void * const stack = task_stack_page(current);
50761 + const void * const stackend = stack + THREAD_SIZE;
50762 +
50763 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50764 + const void *frame = NULL;
50765 + const void *oldframe;
50766 +#endif
50767 +
50768 + if (obj + len < obj)
50769 + return -1;
50770 +
50771 + if (obj + len <= stack || stackend <= obj)
50772 + return 0;
50773 +
50774 + if (obj < stack || stackend < obj + len)
50775 + return -1;
50776 +
50777 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50778 + oldframe = __builtin_frame_address(1);
50779 + if (oldframe)
50780 + frame = __builtin_frame_address(2);
50781 + /*
50782 + low ----------------------------------------------> high
50783 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
50784 + ^----------------^
50785 + allow copies only within here
50786 + */
50787 + while (stack <= frame && frame < stackend) {
50788 + /* if obj + len extends past the last frame, this
50789 + check won't pass and the next frame will be 0,
50790 + causing us to bail out and correctly report
50791 + the copy as invalid
50792 + */
50793 + if (obj + len <= frame)
50794 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
50795 + oldframe = frame;
50796 + frame = *(const void * const *)frame;
50797 + }
50798 + return -1;
50799 +#else
50800 + return 1;
50801 +#endif
50802 +}
50803 +
50804 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
50805 +{
50806 + if (current->signal->curr_ip)
50807 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50808 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50809 + else
50810 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50811 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50812 + dump_stack();
50813 + gr_handle_kernel_exploit();
50814 + do_group_exit(SIGKILL);
50815 +}
50816 +#endif
50817 +
50818 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
50819 +{
50820 +
50821 +#ifdef CONFIG_PAX_USERCOPY
50822 + const char *type;
50823 +
50824 + if (!n)
50825 + return;
50826 +
50827 + type = check_heap_object(ptr, n);
50828 + if (!type) {
50829 + if (check_stack_object(ptr, n) != -1)
50830 + return;
50831 + type = "<process stack>";
50832 + }
50833 +
50834 + pax_report_usercopy(ptr, n, to_user, type);
50835 +#endif
50836 +
50837 +}
50838 +EXPORT_SYMBOL(__check_object_size);
50839 +
50840 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
50841 +void pax_track_stack(void)
50842 +{
50843 + unsigned long sp = (unsigned long)&sp;
50844 + if (sp < current_thread_info()->lowest_stack &&
50845 + sp > (unsigned long)task_stack_page(current))
50846 + current_thread_info()->lowest_stack = sp;
50847 +}
50848 +EXPORT_SYMBOL(pax_track_stack);
50849 +#endif
50850 +
50851 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
50852 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
50853 +{
50854 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
50855 + dump_stack();
50856 + do_group_exit(SIGKILL);
50857 +}
50858 +EXPORT_SYMBOL(report_size_overflow);
50859 +#endif
50860 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
50861 index 2616d0e..2ffdec9 100644
50862 --- a/fs/ext2/balloc.c
50863 +++ b/fs/ext2/balloc.c
50864 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
50865
50866 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50867 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50868 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50869 + if (free_blocks < root_blocks + 1 &&
50870 !uid_eq(sbi->s_resuid, current_fsuid()) &&
50871 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50872 - !in_group_p (sbi->s_resgid))) {
50873 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50874 return 0;
50875 }
50876 return 1;
50877 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
50878 index 22548f5..41521d8 100644
50879 --- a/fs/ext3/balloc.c
50880 +++ b/fs/ext3/balloc.c
50881 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
50882
50883 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50884 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50885 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50886 + if (free_blocks < root_blocks + 1 &&
50887 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
50888 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50889 - !in_group_p (sbi->s_resgid))) {
50890 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50891 return 0;
50892 }
50893 return 1;
50894 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
50895 index 92e68b3..115d987 100644
50896 --- a/fs/ext4/balloc.c
50897 +++ b/fs/ext4/balloc.c
50898 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
50899 /* Hm, nope. Are (enough) root reserved clusters available? */
50900 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
50901 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
50902 - capable(CAP_SYS_RESOURCE) ||
50903 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
50904 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
50905 + capable_nolog(CAP_SYS_RESOURCE)) {
50906
50907 if (free_clusters >= (nclusters + dirty_clusters))
50908 return 1;
50909 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
50910 index bbcd6a0..2824592 100644
50911 --- a/fs/ext4/ext4.h
50912 +++ b/fs/ext4/ext4.h
50913 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
50914 unsigned long s_mb_last_start;
50915
50916 /* stats for buddy allocator */
50917 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
50918 - atomic_t s_bal_success; /* we found long enough chunks */
50919 - atomic_t s_bal_allocated; /* in blocks */
50920 - atomic_t s_bal_ex_scanned; /* total extents scanned */
50921 - atomic_t s_bal_goals; /* goal hits */
50922 - atomic_t s_bal_breaks; /* too long searches */
50923 - atomic_t s_bal_2orders; /* 2^order hits */
50924 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
50925 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
50926 + atomic_unchecked_t s_bal_allocated; /* in blocks */
50927 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
50928 + atomic_unchecked_t s_bal_goals; /* goal hits */
50929 + atomic_unchecked_t s_bal_breaks; /* too long searches */
50930 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
50931 spinlock_t s_bal_lock;
50932 unsigned long s_mb_buddies_generated;
50933 unsigned long long s_mb_generation_time;
50934 - atomic_t s_mb_lost_chunks;
50935 - atomic_t s_mb_preallocated;
50936 - atomic_t s_mb_discarded;
50937 + atomic_unchecked_t s_mb_lost_chunks;
50938 + atomic_unchecked_t s_mb_preallocated;
50939 + atomic_unchecked_t s_mb_discarded;
50940 atomic_t s_lock_busy;
50941
50942 /* locality groups */
50943 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
50944 index 82f8c2d..ce7c889 100644
50945 --- a/fs/ext4/mballoc.c
50946 +++ b/fs/ext4/mballoc.c
50947 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
50948 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
50949
50950 if (EXT4_SB(sb)->s_mb_stats)
50951 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
50952 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
50953
50954 break;
50955 }
50956 @@ -2044,7 +2044,7 @@ repeat:
50957 ac->ac_status = AC_STATUS_CONTINUE;
50958 ac->ac_flags |= EXT4_MB_HINT_FIRST;
50959 cr = 3;
50960 - atomic_inc(&sbi->s_mb_lost_chunks);
50961 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
50962 goto repeat;
50963 }
50964 }
50965 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
50966 if (sbi->s_mb_stats) {
50967 ext4_msg(sb, KERN_INFO,
50968 "mballoc: %u blocks %u reqs (%u success)",
50969 - atomic_read(&sbi->s_bal_allocated),
50970 - atomic_read(&sbi->s_bal_reqs),
50971 - atomic_read(&sbi->s_bal_success));
50972 + atomic_read_unchecked(&sbi->s_bal_allocated),
50973 + atomic_read_unchecked(&sbi->s_bal_reqs),
50974 + atomic_read_unchecked(&sbi->s_bal_success));
50975 ext4_msg(sb, KERN_INFO,
50976 "mballoc: %u extents scanned, %u goal hits, "
50977 "%u 2^N hits, %u breaks, %u lost",
50978 - atomic_read(&sbi->s_bal_ex_scanned),
50979 - atomic_read(&sbi->s_bal_goals),
50980 - atomic_read(&sbi->s_bal_2orders),
50981 - atomic_read(&sbi->s_bal_breaks),
50982 - atomic_read(&sbi->s_mb_lost_chunks));
50983 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
50984 + atomic_read_unchecked(&sbi->s_bal_goals),
50985 + atomic_read_unchecked(&sbi->s_bal_2orders),
50986 + atomic_read_unchecked(&sbi->s_bal_breaks),
50987 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
50988 ext4_msg(sb, KERN_INFO,
50989 "mballoc: %lu generated and it took %Lu",
50990 sbi->s_mb_buddies_generated,
50991 sbi->s_mb_generation_time);
50992 ext4_msg(sb, KERN_INFO,
50993 "mballoc: %u preallocated, %u discarded",
50994 - atomic_read(&sbi->s_mb_preallocated),
50995 - atomic_read(&sbi->s_mb_discarded));
50996 + atomic_read_unchecked(&sbi->s_mb_preallocated),
50997 + atomic_read_unchecked(&sbi->s_mb_discarded));
50998 }
50999
51000 free_percpu(sbi->s_locality_groups);
51001 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51002 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51003
51004 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51005 - atomic_inc(&sbi->s_bal_reqs);
51006 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51007 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51008 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51009 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51010 - atomic_inc(&sbi->s_bal_success);
51011 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51012 + atomic_inc_unchecked(&sbi->s_bal_success);
51013 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51014 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51015 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51016 - atomic_inc(&sbi->s_bal_goals);
51017 + atomic_inc_unchecked(&sbi->s_bal_goals);
51018 if (ac->ac_found > sbi->s_mb_max_to_scan)
51019 - atomic_inc(&sbi->s_bal_breaks);
51020 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51021 }
51022
51023 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51024 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51025 trace_ext4_mb_new_inode_pa(ac, pa);
51026
51027 ext4_mb_use_inode_pa(ac, pa);
51028 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51029 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51030
51031 ei = EXT4_I(ac->ac_inode);
51032 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51033 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51034 trace_ext4_mb_new_group_pa(ac, pa);
51035
51036 ext4_mb_use_group_pa(ac, pa);
51037 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51038 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51039
51040 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51041 lg = ac->ac_lg;
51042 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51043 * from the bitmap and continue.
51044 */
51045 }
51046 - atomic_add(free, &sbi->s_mb_discarded);
51047 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51048
51049 return err;
51050 }
51051 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51052 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51053 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51054 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51055 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51056 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51057 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51058
51059 return 0;
51060 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51061 index 24c767d..893aa55 100644
51062 --- a/fs/ext4/super.c
51063 +++ b/fs/ext4/super.c
51064 @@ -2429,7 +2429,7 @@ struct ext4_attr {
51065 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51066 const char *, size_t);
51067 int offset;
51068 -};
51069 +} __do_const;
51070
51071 static int parse_strtoul(const char *buf,
51072 unsigned long max, unsigned long *value)
51073 diff --git a/fs/fcntl.c b/fs/fcntl.c
51074 index 71a600a..20d87b1 100644
51075 --- a/fs/fcntl.c
51076 +++ b/fs/fcntl.c
51077 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51078 if (err)
51079 return err;
51080
51081 + if (gr_handle_chroot_fowner(pid, type))
51082 + return -ENOENT;
51083 + if (gr_check_protected_task_fowner(pid, type))
51084 + return -EACCES;
51085 +
51086 f_modown(filp, pid, type, force);
51087 return 0;
51088 }
51089 diff --git a/fs/fhandle.c b/fs/fhandle.c
51090 index 999ff5c..41f4109 100644
51091 --- a/fs/fhandle.c
51092 +++ b/fs/fhandle.c
51093 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51094 } else
51095 retval = 0;
51096 /* copy the mount id */
51097 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51098 - sizeof(*mnt_id)) ||
51099 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51100 copy_to_user(ufh, handle,
51101 sizeof(struct file_handle) + handle_bytes))
51102 retval = -EFAULT;
51103 diff --git a/fs/fifo.c b/fs/fifo.c
51104 index cf6f434..3d7942c 100644
51105 --- a/fs/fifo.c
51106 +++ b/fs/fifo.c
51107 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51108 */
51109 filp->f_op = &read_pipefifo_fops;
51110 pipe->r_counter++;
51111 - if (pipe->readers++ == 0)
51112 + if (atomic_inc_return(&pipe->readers) == 1)
51113 wake_up_partner(inode);
51114
51115 - if (!pipe->writers) {
51116 + if (!atomic_read(&pipe->writers)) {
51117 if ((filp->f_flags & O_NONBLOCK)) {
51118 /* suppress POLLHUP until we have
51119 * seen a writer */
51120 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51121 * errno=ENXIO when there is no process reading the FIFO.
51122 */
51123 ret = -ENXIO;
51124 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51125 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51126 goto err;
51127
51128 filp->f_op = &write_pipefifo_fops;
51129 pipe->w_counter++;
51130 - if (!pipe->writers++)
51131 + if (atomic_inc_return(&pipe->writers) == 1)
51132 wake_up_partner(inode);
51133
51134 - if (!pipe->readers) {
51135 + if (!atomic_read(&pipe->readers)) {
51136 if (wait_for_partner(inode, &pipe->r_counter))
51137 goto err_wr;
51138 }
51139 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51140 */
51141 filp->f_op = &rdwr_pipefifo_fops;
51142
51143 - pipe->readers++;
51144 - pipe->writers++;
51145 + atomic_inc(&pipe->readers);
51146 + atomic_inc(&pipe->writers);
51147 pipe->r_counter++;
51148 pipe->w_counter++;
51149 - if (pipe->readers == 1 || pipe->writers == 1)
51150 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51151 wake_up_partner(inode);
51152 break;
51153
51154 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51155 return 0;
51156
51157 err_rd:
51158 - if (!--pipe->readers)
51159 + if (atomic_dec_and_test(&pipe->readers))
51160 wake_up_interruptible(&pipe->wait);
51161 ret = -ERESTARTSYS;
51162 goto err;
51163
51164 err_wr:
51165 - if (!--pipe->writers)
51166 + if (atomic_dec_and_test(&pipe->writers))
51167 wake_up_interruptible(&pipe->wait);
51168 ret = -ERESTARTSYS;
51169 goto err;
51170
51171 err:
51172 - if (!pipe->readers && !pipe->writers)
51173 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51174 free_pipe_info(inode);
51175
51176 err_nocleanup:
51177 diff --git a/fs/file.c b/fs/file.c
51178 index 2b3570b..c57924b 100644
51179 --- a/fs/file.c
51180 +++ b/fs/file.c
51181 @@ -16,6 +16,7 @@
51182 #include <linux/slab.h>
51183 #include <linux/vmalloc.h>
51184 #include <linux/file.h>
51185 +#include <linux/security.h>
51186 #include <linux/fdtable.h>
51187 #include <linux/bitops.h>
51188 #include <linux/interrupt.h>
51189 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51190 if (!file)
51191 return __close_fd(files, fd);
51192
51193 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51194 if (fd >= rlimit(RLIMIT_NOFILE))
51195 return -EBADF;
51196
51197 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51198 if (unlikely(oldfd == newfd))
51199 return -EINVAL;
51200
51201 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51202 if (newfd >= rlimit(RLIMIT_NOFILE))
51203 return -EBADF;
51204
51205 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51206 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51207 {
51208 int err;
51209 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51210 if (from >= rlimit(RLIMIT_NOFILE))
51211 return -EINVAL;
51212 err = alloc_fd(from, flags);
51213 diff --git a/fs/filesystems.c b/fs/filesystems.c
51214 index da165f6..3671bdb 100644
51215 --- a/fs/filesystems.c
51216 +++ b/fs/filesystems.c
51217 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
51218 int len = dot ? dot - name : strlen(name);
51219
51220 fs = __get_fs_type(name, len);
51221 +
51222 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51223 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
51224 +#else
51225 if (!fs && (request_module("%.*s", len, name) == 0))
51226 +#endif
51227 fs = __get_fs_type(name, len);
51228
51229 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51230 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51231 index fe6ca58..65318cf 100644
51232 --- a/fs/fs_struct.c
51233 +++ b/fs/fs_struct.c
51234 @@ -4,6 +4,7 @@
51235 #include <linux/path.h>
51236 #include <linux/slab.h>
51237 #include <linux/fs_struct.h>
51238 +#include <linux/grsecurity.h>
51239 #include "internal.h"
51240
51241 /*
51242 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
51243 write_seqcount_begin(&fs->seq);
51244 old_root = fs->root;
51245 fs->root = *path;
51246 + gr_set_chroot_entries(current, path);
51247 write_seqcount_end(&fs->seq);
51248 spin_unlock(&fs->lock);
51249 if (old_root.dentry)
51250 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
51251 return 1;
51252 }
51253
51254 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
51255 +{
51256 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
51257 + return 0;
51258 + *p = *new;
51259 +
51260 + /* This function is only called from pivot_root(). Leave our
51261 + gr_chroot_dentry and is_chrooted flags as-is, so that a
51262 + pivoted root isn't treated as a chroot
51263 + */
51264 + //gr_set_chroot_entries(task, new);
51265 +
51266 + return 1;
51267 +}
51268 +
51269 void chroot_fs_refs(struct path *old_root, struct path *new_root)
51270 {
51271 struct task_struct *g, *p;
51272 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
51273 int hits = 0;
51274 spin_lock(&fs->lock);
51275 write_seqcount_begin(&fs->seq);
51276 - hits += replace_path(&fs->root, old_root, new_root);
51277 + hits += replace_root_path(p, &fs->root, old_root, new_root);
51278 hits += replace_path(&fs->pwd, old_root, new_root);
51279 write_seqcount_end(&fs->seq);
51280 while (hits--) {
51281 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
51282 task_lock(tsk);
51283 spin_lock(&fs->lock);
51284 tsk->fs = NULL;
51285 - kill = !--fs->users;
51286 + gr_clear_chroot_entries(tsk);
51287 + kill = !atomic_dec_return(&fs->users);
51288 spin_unlock(&fs->lock);
51289 task_unlock(tsk);
51290 if (kill)
51291 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51292 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51293 /* We don't need to lock fs - think why ;-) */
51294 if (fs) {
51295 - fs->users = 1;
51296 + atomic_set(&fs->users, 1);
51297 fs->in_exec = 0;
51298 spin_lock_init(&fs->lock);
51299 seqcount_init(&fs->seq);
51300 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51301 spin_lock(&old->lock);
51302 fs->root = old->root;
51303 path_get(&fs->root);
51304 + /* instead of calling gr_set_chroot_entries here,
51305 + we call it from every caller of this function
51306 + */
51307 fs->pwd = old->pwd;
51308 path_get(&fs->pwd);
51309 spin_unlock(&old->lock);
51310 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
51311
51312 task_lock(current);
51313 spin_lock(&fs->lock);
51314 - kill = !--fs->users;
51315 + kill = !atomic_dec_return(&fs->users);
51316 current->fs = new_fs;
51317 + gr_set_chroot_entries(current, &new_fs->root);
51318 spin_unlock(&fs->lock);
51319 task_unlock(current);
51320
51321 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51322
51323 int current_umask(void)
51324 {
51325 - return current->fs->umask;
51326 + return current->fs->umask | gr_acl_umask();
51327 }
51328 EXPORT_SYMBOL(current_umask);
51329
51330 /* to be mentioned only in INIT_TASK */
51331 struct fs_struct init_fs = {
51332 - .users = 1,
51333 + .users = ATOMIC_INIT(1),
51334 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51335 .seq = SEQCNT_ZERO,
51336 .umask = 0022,
51337 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51338 index 8dcb114..b1072e2 100644
51339 --- a/fs/fscache/cookie.c
51340 +++ b/fs/fscache/cookie.c
51341 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51342 parent ? (char *) parent->def->name : "<no-parent>",
51343 def->name, netfs_data);
51344
51345 - fscache_stat(&fscache_n_acquires);
51346 + fscache_stat_unchecked(&fscache_n_acquires);
51347
51348 /* if there's no parent cookie, then we don't create one here either */
51349 if (!parent) {
51350 - fscache_stat(&fscache_n_acquires_null);
51351 + fscache_stat_unchecked(&fscache_n_acquires_null);
51352 _leave(" [no parent]");
51353 return NULL;
51354 }
51355 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51356 /* allocate and initialise a cookie */
51357 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51358 if (!cookie) {
51359 - fscache_stat(&fscache_n_acquires_oom);
51360 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51361 _leave(" [ENOMEM]");
51362 return NULL;
51363 }
51364 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51365
51366 switch (cookie->def->type) {
51367 case FSCACHE_COOKIE_TYPE_INDEX:
51368 - fscache_stat(&fscache_n_cookie_index);
51369 + fscache_stat_unchecked(&fscache_n_cookie_index);
51370 break;
51371 case FSCACHE_COOKIE_TYPE_DATAFILE:
51372 - fscache_stat(&fscache_n_cookie_data);
51373 + fscache_stat_unchecked(&fscache_n_cookie_data);
51374 break;
51375 default:
51376 - fscache_stat(&fscache_n_cookie_special);
51377 + fscache_stat_unchecked(&fscache_n_cookie_special);
51378 break;
51379 }
51380
51381 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51382 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51383 atomic_dec(&parent->n_children);
51384 __fscache_cookie_put(cookie);
51385 - fscache_stat(&fscache_n_acquires_nobufs);
51386 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51387 _leave(" = NULL");
51388 return NULL;
51389 }
51390 }
51391
51392 - fscache_stat(&fscache_n_acquires_ok);
51393 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51394 _leave(" = %p", cookie);
51395 return cookie;
51396 }
51397 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51398 cache = fscache_select_cache_for_object(cookie->parent);
51399 if (!cache) {
51400 up_read(&fscache_addremove_sem);
51401 - fscache_stat(&fscache_n_acquires_no_cache);
51402 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51403 _leave(" = -ENOMEDIUM [no cache]");
51404 return -ENOMEDIUM;
51405 }
51406 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51407 object = cache->ops->alloc_object(cache, cookie);
51408 fscache_stat_d(&fscache_n_cop_alloc_object);
51409 if (IS_ERR(object)) {
51410 - fscache_stat(&fscache_n_object_no_alloc);
51411 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51412 ret = PTR_ERR(object);
51413 goto error;
51414 }
51415
51416 - fscache_stat(&fscache_n_object_alloc);
51417 + fscache_stat_unchecked(&fscache_n_object_alloc);
51418
51419 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51420
51421 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51422
51423 _enter("{%s}", cookie->def->name);
51424
51425 - fscache_stat(&fscache_n_invalidates);
51426 + fscache_stat_unchecked(&fscache_n_invalidates);
51427
51428 /* Only permit invalidation of data files. Invalidating an index will
51429 * require the caller to release all its attachments to the tree rooted
51430 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51431 struct fscache_object *object;
51432 struct hlist_node *_p;
51433
51434 - fscache_stat(&fscache_n_updates);
51435 + fscache_stat_unchecked(&fscache_n_updates);
51436
51437 if (!cookie) {
51438 - fscache_stat(&fscache_n_updates_null);
51439 + fscache_stat_unchecked(&fscache_n_updates_null);
51440 _leave(" [no cookie]");
51441 return;
51442 }
51443 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51444 struct fscache_object *object;
51445 unsigned long event;
51446
51447 - fscache_stat(&fscache_n_relinquishes);
51448 + fscache_stat_unchecked(&fscache_n_relinquishes);
51449 if (retire)
51450 - fscache_stat(&fscache_n_relinquishes_retire);
51451 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51452
51453 if (!cookie) {
51454 - fscache_stat(&fscache_n_relinquishes_null);
51455 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51456 _leave(" [no cookie]");
51457 return;
51458 }
51459 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51460
51461 /* wait for the cookie to finish being instantiated (or to fail) */
51462 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51463 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51464 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51465 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51466 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51467 }
51468 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51469 index ee38fef..0a326d4 100644
51470 --- a/fs/fscache/internal.h
51471 +++ b/fs/fscache/internal.h
51472 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51473 * stats.c
51474 */
51475 #ifdef CONFIG_FSCACHE_STATS
51476 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51477 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51478 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51479 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51480
51481 -extern atomic_t fscache_n_op_pend;
51482 -extern atomic_t fscache_n_op_run;
51483 -extern atomic_t fscache_n_op_enqueue;
51484 -extern atomic_t fscache_n_op_deferred_release;
51485 -extern atomic_t fscache_n_op_release;
51486 -extern atomic_t fscache_n_op_gc;
51487 -extern atomic_t fscache_n_op_cancelled;
51488 -extern atomic_t fscache_n_op_rejected;
51489 +extern atomic_unchecked_t fscache_n_op_pend;
51490 +extern atomic_unchecked_t fscache_n_op_run;
51491 +extern atomic_unchecked_t fscache_n_op_enqueue;
51492 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51493 +extern atomic_unchecked_t fscache_n_op_release;
51494 +extern atomic_unchecked_t fscache_n_op_gc;
51495 +extern atomic_unchecked_t fscache_n_op_cancelled;
51496 +extern atomic_unchecked_t fscache_n_op_rejected;
51497
51498 -extern atomic_t fscache_n_attr_changed;
51499 -extern atomic_t fscache_n_attr_changed_ok;
51500 -extern atomic_t fscache_n_attr_changed_nobufs;
51501 -extern atomic_t fscache_n_attr_changed_nomem;
51502 -extern atomic_t fscache_n_attr_changed_calls;
51503 +extern atomic_unchecked_t fscache_n_attr_changed;
51504 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51505 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51506 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51507 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51508
51509 -extern atomic_t fscache_n_allocs;
51510 -extern atomic_t fscache_n_allocs_ok;
51511 -extern atomic_t fscache_n_allocs_wait;
51512 -extern atomic_t fscache_n_allocs_nobufs;
51513 -extern atomic_t fscache_n_allocs_intr;
51514 -extern atomic_t fscache_n_allocs_object_dead;
51515 -extern atomic_t fscache_n_alloc_ops;
51516 -extern atomic_t fscache_n_alloc_op_waits;
51517 +extern atomic_unchecked_t fscache_n_allocs;
51518 +extern atomic_unchecked_t fscache_n_allocs_ok;
51519 +extern atomic_unchecked_t fscache_n_allocs_wait;
51520 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51521 +extern atomic_unchecked_t fscache_n_allocs_intr;
51522 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51523 +extern atomic_unchecked_t fscache_n_alloc_ops;
51524 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51525
51526 -extern atomic_t fscache_n_retrievals;
51527 -extern atomic_t fscache_n_retrievals_ok;
51528 -extern atomic_t fscache_n_retrievals_wait;
51529 -extern atomic_t fscache_n_retrievals_nodata;
51530 -extern atomic_t fscache_n_retrievals_nobufs;
51531 -extern atomic_t fscache_n_retrievals_intr;
51532 -extern atomic_t fscache_n_retrievals_nomem;
51533 -extern atomic_t fscache_n_retrievals_object_dead;
51534 -extern atomic_t fscache_n_retrieval_ops;
51535 -extern atomic_t fscache_n_retrieval_op_waits;
51536 +extern atomic_unchecked_t fscache_n_retrievals;
51537 +extern atomic_unchecked_t fscache_n_retrievals_ok;
51538 +extern atomic_unchecked_t fscache_n_retrievals_wait;
51539 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
51540 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
51541 +extern atomic_unchecked_t fscache_n_retrievals_intr;
51542 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
51543 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
51544 +extern atomic_unchecked_t fscache_n_retrieval_ops;
51545 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
51546
51547 -extern atomic_t fscache_n_stores;
51548 -extern atomic_t fscache_n_stores_ok;
51549 -extern atomic_t fscache_n_stores_again;
51550 -extern atomic_t fscache_n_stores_nobufs;
51551 -extern atomic_t fscache_n_stores_oom;
51552 -extern atomic_t fscache_n_store_ops;
51553 -extern atomic_t fscache_n_store_calls;
51554 -extern atomic_t fscache_n_store_pages;
51555 -extern atomic_t fscache_n_store_radix_deletes;
51556 -extern atomic_t fscache_n_store_pages_over_limit;
51557 +extern atomic_unchecked_t fscache_n_stores;
51558 +extern atomic_unchecked_t fscache_n_stores_ok;
51559 +extern atomic_unchecked_t fscache_n_stores_again;
51560 +extern atomic_unchecked_t fscache_n_stores_nobufs;
51561 +extern atomic_unchecked_t fscache_n_stores_oom;
51562 +extern atomic_unchecked_t fscache_n_store_ops;
51563 +extern atomic_unchecked_t fscache_n_store_calls;
51564 +extern atomic_unchecked_t fscache_n_store_pages;
51565 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
51566 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
51567
51568 -extern atomic_t fscache_n_store_vmscan_not_storing;
51569 -extern atomic_t fscache_n_store_vmscan_gone;
51570 -extern atomic_t fscache_n_store_vmscan_busy;
51571 -extern atomic_t fscache_n_store_vmscan_cancelled;
51572 -extern atomic_t fscache_n_store_vmscan_wait;
51573 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
51574 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
51575 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
51576 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
51577 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
51578
51579 -extern atomic_t fscache_n_marks;
51580 -extern atomic_t fscache_n_uncaches;
51581 +extern atomic_unchecked_t fscache_n_marks;
51582 +extern atomic_unchecked_t fscache_n_uncaches;
51583
51584 -extern atomic_t fscache_n_acquires;
51585 -extern atomic_t fscache_n_acquires_null;
51586 -extern atomic_t fscache_n_acquires_no_cache;
51587 -extern atomic_t fscache_n_acquires_ok;
51588 -extern atomic_t fscache_n_acquires_nobufs;
51589 -extern atomic_t fscache_n_acquires_oom;
51590 +extern atomic_unchecked_t fscache_n_acquires;
51591 +extern atomic_unchecked_t fscache_n_acquires_null;
51592 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
51593 +extern atomic_unchecked_t fscache_n_acquires_ok;
51594 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
51595 +extern atomic_unchecked_t fscache_n_acquires_oom;
51596
51597 -extern atomic_t fscache_n_invalidates;
51598 -extern atomic_t fscache_n_invalidates_run;
51599 +extern atomic_unchecked_t fscache_n_invalidates;
51600 +extern atomic_unchecked_t fscache_n_invalidates_run;
51601
51602 -extern atomic_t fscache_n_updates;
51603 -extern atomic_t fscache_n_updates_null;
51604 -extern atomic_t fscache_n_updates_run;
51605 +extern atomic_unchecked_t fscache_n_updates;
51606 +extern atomic_unchecked_t fscache_n_updates_null;
51607 +extern atomic_unchecked_t fscache_n_updates_run;
51608
51609 -extern atomic_t fscache_n_relinquishes;
51610 -extern atomic_t fscache_n_relinquishes_null;
51611 -extern atomic_t fscache_n_relinquishes_waitcrt;
51612 -extern atomic_t fscache_n_relinquishes_retire;
51613 +extern atomic_unchecked_t fscache_n_relinquishes;
51614 +extern atomic_unchecked_t fscache_n_relinquishes_null;
51615 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
51616 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
51617
51618 -extern atomic_t fscache_n_cookie_index;
51619 -extern atomic_t fscache_n_cookie_data;
51620 -extern atomic_t fscache_n_cookie_special;
51621 +extern atomic_unchecked_t fscache_n_cookie_index;
51622 +extern atomic_unchecked_t fscache_n_cookie_data;
51623 +extern atomic_unchecked_t fscache_n_cookie_special;
51624
51625 -extern atomic_t fscache_n_object_alloc;
51626 -extern atomic_t fscache_n_object_no_alloc;
51627 -extern atomic_t fscache_n_object_lookups;
51628 -extern atomic_t fscache_n_object_lookups_negative;
51629 -extern atomic_t fscache_n_object_lookups_positive;
51630 -extern atomic_t fscache_n_object_lookups_timed_out;
51631 -extern atomic_t fscache_n_object_created;
51632 -extern atomic_t fscache_n_object_avail;
51633 -extern atomic_t fscache_n_object_dead;
51634 +extern atomic_unchecked_t fscache_n_object_alloc;
51635 +extern atomic_unchecked_t fscache_n_object_no_alloc;
51636 +extern atomic_unchecked_t fscache_n_object_lookups;
51637 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
51638 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
51639 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
51640 +extern atomic_unchecked_t fscache_n_object_created;
51641 +extern atomic_unchecked_t fscache_n_object_avail;
51642 +extern atomic_unchecked_t fscache_n_object_dead;
51643
51644 -extern atomic_t fscache_n_checkaux_none;
51645 -extern atomic_t fscache_n_checkaux_okay;
51646 -extern atomic_t fscache_n_checkaux_update;
51647 -extern atomic_t fscache_n_checkaux_obsolete;
51648 +extern atomic_unchecked_t fscache_n_checkaux_none;
51649 +extern atomic_unchecked_t fscache_n_checkaux_okay;
51650 +extern atomic_unchecked_t fscache_n_checkaux_update;
51651 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
51652
51653 extern atomic_t fscache_n_cop_alloc_object;
51654 extern atomic_t fscache_n_cop_lookup_object;
51655 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
51656 atomic_inc(stat);
51657 }
51658
51659 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
51660 +{
51661 + atomic_inc_unchecked(stat);
51662 +}
51663 +
51664 static inline void fscache_stat_d(atomic_t *stat)
51665 {
51666 atomic_dec(stat);
51667 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
51668
51669 #define __fscache_stat(stat) (NULL)
51670 #define fscache_stat(stat) do {} while (0)
51671 +#define fscache_stat_unchecked(stat) do {} while (0)
51672 #define fscache_stat_d(stat) do {} while (0)
51673 #endif
51674
51675 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
51676 index 50d41c1..10ee117 100644
51677 --- a/fs/fscache/object.c
51678 +++ b/fs/fscache/object.c
51679 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51680 /* Invalidate an object on disk */
51681 case FSCACHE_OBJECT_INVALIDATING:
51682 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
51683 - fscache_stat(&fscache_n_invalidates_run);
51684 + fscache_stat_unchecked(&fscache_n_invalidates_run);
51685 fscache_stat(&fscache_n_cop_invalidate_object);
51686 fscache_invalidate_object(object);
51687 fscache_stat_d(&fscache_n_cop_invalidate_object);
51688 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51689 /* update the object metadata on disk */
51690 case FSCACHE_OBJECT_UPDATING:
51691 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
51692 - fscache_stat(&fscache_n_updates_run);
51693 + fscache_stat_unchecked(&fscache_n_updates_run);
51694 fscache_stat(&fscache_n_cop_update_object);
51695 object->cache->ops->update_object(object);
51696 fscache_stat_d(&fscache_n_cop_update_object);
51697 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51698 spin_lock(&object->lock);
51699 object->state = FSCACHE_OBJECT_DEAD;
51700 spin_unlock(&object->lock);
51701 - fscache_stat(&fscache_n_object_dead);
51702 + fscache_stat_unchecked(&fscache_n_object_dead);
51703 goto terminal_transit;
51704
51705 /* handle the parent cache of this object being withdrawn from
51706 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51707 spin_lock(&object->lock);
51708 object->state = FSCACHE_OBJECT_DEAD;
51709 spin_unlock(&object->lock);
51710 - fscache_stat(&fscache_n_object_dead);
51711 + fscache_stat_unchecked(&fscache_n_object_dead);
51712 goto terminal_transit;
51713
51714 /* complain about the object being woken up once it is
51715 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51716 parent->cookie->def->name, cookie->def->name,
51717 object->cache->tag->name);
51718
51719 - fscache_stat(&fscache_n_object_lookups);
51720 + fscache_stat_unchecked(&fscache_n_object_lookups);
51721 fscache_stat(&fscache_n_cop_lookup_object);
51722 ret = object->cache->ops->lookup_object(object);
51723 fscache_stat_d(&fscache_n_cop_lookup_object);
51724 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51725 if (ret == -ETIMEDOUT) {
51726 /* probably stuck behind another object, so move this one to
51727 * the back of the queue */
51728 - fscache_stat(&fscache_n_object_lookups_timed_out);
51729 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
51730 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51731 }
51732
51733 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
51734
51735 spin_lock(&object->lock);
51736 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51737 - fscache_stat(&fscache_n_object_lookups_negative);
51738 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
51739
51740 /* transit here to allow write requests to begin stacking up
51741 * and read requests to begin returning ENODATA */
51742 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
51743 * result, in which case there may be data available */
51744 spin_lock(&object->lock);
51745 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51746 - fscache_stat(&fscache_n_object_lookups_positive);
51747 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
51748
51749 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
51750
51751 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
51752 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51753 } else {
51754 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
51755 - fscache_stat(&fscache_n_object_created);
51756 + fscache_stat_unchecked(&fscache_n_object_created);
51757
51758 object->state = FSCACHE_OBJECT_AVAILABLE;
51759 spin_unlock(&object->lock);
51760 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
51761 fscache_enqueue_dependents(object);
51762
51763 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
51764 - fscache_stat(&fscache_n_object_avail);
51765 + fscache_stat_unchecked(&fscache_n_object_avail);
51766
51767 _leave("");
51768 }
51769 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51770 enum fscache_checkaux result;
51771
51772 if (!object->cookie->def->check_aux) {
51773 - fscache_stat(&fscache_n_checkaux_none);
51774 + fscache_stat_unchecked(&fscache_n_checkaux_none);
51775 return FSCACHE_CHECKAUX_OKAY;
51776 }
51777
51778 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51779 switch (result) {
51780 /* entry okay as is */
51781 case FSCACHE_CHECKAUX_OKAY:
51782 - fscache_stat(&fscache_n_checkaux_okay);
51783 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
51784 break;
51785
51786 /* entry requires update */
51787 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
51788 - fscache_stat(&fscache_n_checkaux_update);
51789 + fscache_stat_unchecked(&fscache_n_checkaux_update);
51790 break;
51791
51792 /* entry requires deletion */
51793 case FSCACHE_CHECKAUX_OBSOLETE:
51794 - fscache_stat(&fscache_n_checkaux_obsolete);
51795 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
51796 break;
51797
51798 default:
51799 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
51800 index 762a9ec..2023284 100644
51801 --- a/fs/fscache/operation.c
51802 +++ b/fs/fscache/operation.c
51803 @@ -17,7 +17,7 @@
51804 #include <linux/slab.h>
51805 #include "internal.h"
51806
51807 -atomic_t fscache_op_debug_id;
51808 +atomic_unchecked_t fscache_op_debug_id;
51809 EXPORT_SYMBOL(fscache_op_debug_id);
51810
51811 /**
51812 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
51813 ASSERTCMP(atomic_read(&op->usage), >, 0);
51814 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
51815
51816 - fscache_stat(&fscache_n_op_enqueue);
51817 + fscache_stat_unchecked(&fscache_n_op_enqueue);
51818 switch (op->flags & FSCACHE_OP_TYPE) {
51819 case FSCACHE_OP_ASYNC:
51820 _debug("queue async");
51821 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
51822 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
51823 if (op->processor)
51824 fscache_enqueue_operation(op);
51825 - fscache_stat(&fscache_n_op_run);
51826 + fscache_stat_unchecked(&fscache_n_op_run);
51827 }
51828
51829 /*
51830 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51831 if (object->n_in_progress > 0) {
51832 atomic_inc(&op->usage);
51833 list_add_tail(&op->pend_link, &object->pending_ops);
51834 - fscache_stat(&fscache_n_op_pend);
51835 + fscache_stat_unchecked(&fscache_n_op_pend);
51836 } else if (!list_empty(&object->pending_ops)) {
51837 atomic_inc(&op->usage);
51838 list_add_tail(&op->pend_link, &object->pending_ops);
51839 - fscache_stat(&fscache_n_op_pend);
51840 + fscache_stat_unchecked(&fscache_n_op_pend);
51841 fscache_start_operations(object);
51842 } else {
51843 ASSERTCMP(object->n_in_progress, ==, 0);
51844 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51845 object->n_exclusive++; /* reads and writes must wait */
51846 atomic_inc(&op->usage);
51847 list_add_tail(&op->pend_link, &object->pending_ops);
51848 - fscache_stat(&fscache_n_op_pend);
51849 + fscache_stat_unchecked(&fscache_n_op_pend);
51850 ret = 0;
51851 } else {
51852 /* If we're in any other state, there must have been an I/O
51853 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
51854 if (object->n_exclusive > 0) {
51855 atomic_inc(&op->usage);
51856 list_add_tail(&op->pend_link, &object->pending_ops);
51857 - fscache_stat(&fscache_n_op_pend);
51858 + fscache_stat_unchecked(&fscache_n_op_pend);
51859 } else if (!list_empty(&object->pending_ops)) {
51860 atomic_inc(&op->usage);
51861 list_add_tail(&op->pend_link, &object->pending_ops);
51862 - fscache_stat(&fscache_n_op_pend);
51863 + fscache_stat_unchecked(&fscache_n_op_pend);
51864 fscache_start_operations(object);
51865 } else {
51866 ASSERTCMP(object->n_exclusive, ==, 0);
51867 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
51868 object->n_ops++;
51869 atomic_inc(&op->usage);
51870 list_add_tail(&op->pend_link, &object->pending_ops);
51871 - fscache_stat(&fscache_n_op_pend);
51872 + fscache_stat_unchecked(&fscache_n_op_pend);
51873 ret = 0;
51874 } else if (object->state == FSCACHE_OBJECT_DYING ||
51875 object->state == FSCACHE_OBJECT_LC_DYING ||
51876 object->state == FSCACHE_OBJECT_WITHDRAWING) {
51877 - fscache_stat(&fscache_n_op_rejected);
51878 + fscache_stat_unchecked(&fscache_n_op_rejected);
51879 op->state = FSCACHE_OP_ST_CANCELLED;
51880 ret = -ENOBUFS;
51881 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
51882 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
51883 ret = -EBUSY;
51884 if (op->state == FSCACHE_OP_ST_PENDING) {
51885 ASSERT(!list_empty(&op->pend_link));
51886 - fscache_stat(&fscache_n_op_cancelled);
51887 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51888 list_del_init(&op->pend_link);
51889 if (do_cancel)
51890 do_cancel(op);
51891 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
51892 while (!list_empty(&object->pending_ops)) {
51893 op = list_entry(object->pending_ops.next,
51894 struct fscache_operation, pend_link);
51895 - fscache_stat(&fscache_n_op_cancelled);
51896 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51897 list_del_init(&op->pend_link);
51898
51899 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
51900 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
51901 op->state, ==, FSCACHE_OP_ST_CANCELLED);
51902 op->state = FSCACHE_OP_ST_DEAD;
51903
51904 - fscache_stat(&fscache_n_op_release);
51905 + fscache_stat_unchecked(&fscache_n_op_release);
51906
51907 if (op->release) {
51908 op->release(op);
51909 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
51910 * lock, and defer it otherwise */
51911 if (!spin_trylock(&object->lock)) {
51912 _debug("defer put");
51913 - fscache_stat(&fscache_n_op_deferred_release);
51914 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
51915
51916 cache = object->cache;
51917 spin_lock(&cache->op_gc_list_lock);
51918 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
51919
51920 _debug("GC DEFERRED REL OBJ%x OP%x",
51921 object->debug_id, op->debug_id);
51922 - fscache_stat(&fscache_n_op_gc);
51923 + fscache_stat_unchecked(&fscache_n_op_gc);
51924
51925 ASSERTCMP(atomic_read(&op->usage), ==, 0);
51926 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
51927 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
51928 index ff000e5..c44ec6d 100644
51929 --- a/fs/fscache/page.c
51930 +++ b/fs/fscache/page.c
51931 @@ -61,7 +61,7 @@ try_again:
51932 val = radix_tree_lookup(&cookie->stores, page->index);
51933 if (!val) {
51934 rcu_read_unlock();
51935 - fscache_stat(&fscache_n_store_vmscan_not_storing);
51936 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
51937 __fscache_uncache_page(cookie, page);
51938 return true;
51939 }
51940 @@ -91,11 +91,11 @@ try_again:
51941 spin_unlock(&cookie->stores_lock);
51942
51943 if (xpage) {
51944 - fscache_stat(&fscache_n_store_vmscan_cancelled);
51945 - fscache_stat(&fscache_n_store_radix_deletes);
51946 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
51947 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51948 ASSERTCMP(xpage, ==, page);
51949 } else {
51950 - fscache_stat(&fscache_n_store_vmscan_gone);
51951 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
51952 }
51953
51954 wake_up_bit(&cookie->flags, 0);
51955 @@ -110,11 +110,11 @@ page_busy:
51956 * sleeping on memory allocation, so we may need to impose a timeout
51957 * too. */
51958 if (!(gfp & __GFP_WAIT)) {
51959 - fscache_stat(&fscache_n_store_vmscan_busy);
51960 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
51961 return false;
51962 }
51963
51964 - fscache_stat(&fscache_n_store_vmscan_wait);
51965 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
51966 __fscache_wait_on_page_write(cookie, page);
51967 gfp &= ~__GFP_WAIT;
51968 goto try_again;
51969 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
51970 FSCACHE_COOKIE_STORING_TAG);
51971 if (!radix_tree_tag_get(&cookie->stores, page->index,
51972 FSCACHE_COOKIE_PENDING_TAG)) {
51973 - fscache_stat(&fscache_n_store_radix_deletes);
51974 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51975 xpage = radix_tree_delete(&cookie->stores, page->index);
51976 }
51977 spin_unlock(&cookie->stores_lock);
51978 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
51979
51980 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
51981
51982 - fscache_stat(&fscache_n_attr_changed_calls);
51983 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
51984
51985 if (fscache_object_is_active(object)) {
51986 fscache_stat(&fscache_n_cop_attr_changed);
51987 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51988
51989 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
51990
51991 - fscache_stat(&fscache_n_attr_changed);
51992 + fscache_stat_unchecked(&fscache_n_attr_changed);
51993
51994 op = kzalloc(sizeof(*op), GFP_KERNEL);
51995 if (!op) {
51996 - fscache_stat(&fscache_n_attr_changed_nomem);
51997 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
51998 _leave(" = -ENOMEM");
51999 return -ENOMEM;
52000 }
52001 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52002 if (fscache_submit_exclusive_op(object, op) < 0)
52003 goto nobufs;
52004 spin_unlock(&cookie->lock);
52005 - fscache_stat(&fscache_n_attr_changed_ok);
52006 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52007 fscache_put_operation(op);
52008 _leave(" = 0");
52009 return 0;
52010 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52011 nobufs:
52012 spin_unlock(&cookie->lock);
52013 kfree(op);
52014 - fscache_stat(&fscache_n_attr_changed_nobufs);
52015 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52016 _leave(" = %d", -ENOBUFS);
52017 return -ENOBUFS;
52018 }
52019 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52020 /* allocate a retrieval operation and attempt to submit it */
52021 op = kzalloc(sizeof(*op), GFP_NOIO);
52022 if (!op) {
52023 - fscache_stat(&fscache_n_retrievals_nomem);
52024 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52025 return NULL;
52026 }
52027
52028 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52029 return 0;
52030 }
52031
52032 - fscache_stat(&fscache_n_retrievals_wait);
52033 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52034
52035 jif = jiffies;
52036 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52037 fscache_wait_bit_interruptible,
52038 TASK_INTERRUPTIBLE) != 0) {
52039 - fscache_stat(&fscache_n_retrievals_intr);
52040 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52041 _leave(" = -ERESTARTSYS");
52042 return -ERESTARTSYS;
52043 }
52044 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52045 */
52046 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52047 struct fscache_retrieval *op,
52048 - atomic_t *stat_op_waits,
52049 - atomic_t *stat_object_dead)
52050 + atomic_unchecked_t *stat_op_waits,
52051 + atomic_unchecked_t *stat_object_dead)
52052 {
52053 int ret;
52054
52055 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52056 goto check_if_dead;
52057
52058 _debug(">>> WT");
52059 - fscache_stat(stat_op_waits);
52060 + fscache_stat_unchecked(stat_op_waits);
52061 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52062 fscache_wait_bit_interruptible,
52063 TASK_INTERRUPTIBLE) != 0) {
52064 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52065
52066 check_if_dead:
52067 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52068 - fscache_stat(stat_object_dead);
52069 + fscache_stat_unchecked(stat_object_dead);
52070 _leave(" = -ENOBUFS [cancelled]");
52071 return -ENOBUFS;
52072 }
52073 if (unlikely(fscache_object_is_dead(object))) {
52074 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52075 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52076 - fscache_stat(stat_object_dead);
52077 + fscache_stat_unchecked(stat_object_dead);
52078 return -ENOBUFS;
52079 }
52080 return 0;
52081 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52082
52083 _enter("%p,%p,,,", cookie, page);
52084
52085 - fscache_stat(&fscache_n_retrievals);
52086 + fscache_stat_unchecked(&fscache_n_retrievals);
52087
52088 if (hlist_empty(&cookie->backing_objects))
52089 goto nobufs;
52090 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52091 goto nobufs_unlock_dec;
52092 spin_unlock(&cookie->lock);
52093
52094 - fscache_stat(&fscache_n_retrieval_ops);
52095 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52096
52097 /* pin the netfs read context in case we need to do the actual netfs
52098 * read because we've encountered a cache read failure */
52099 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52100
52101 error:
52102 if (ret == -ENOMEM)
52103 - fscache_stat(&fscache_n_retrievals_nomem);
52104 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52105 else if (ret == -ERESTARTSYS)
52106 - fscache_stat(&fscache_n_retrievals_intr);
52107 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52108 else if (ret == -ENODATA)
52109 - fscache_stat(&fscache_n_retrievals_nodata);
52110 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52111 else if (ret < 0)
52112 - fscache_stat(&fscache_n_retrievals_nobufs);
52113 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52114 else
52115 - fscache_stat(&fscache_n_retrievals_ok);
52116 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52117
52118 fscache_put_retrieval(op);
52119 _leave(" = %d", ret);
52120 @@ -467,7 +467,7 @@ nobufs_unlock:
52121 spin_unlock(&cookie->lock);
52122 kfree(op);
52123 nobufs:
52124 - fscache_stat(&fscache_n_retrievals_nobufs);
52125 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52126 _leave(" = -ENOBUFS");
52127 return -ENOBUFS;
52128 }
52129 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52130
52131 _enter("%p,,%d,,,", cookie, *nr_pages);
52132
52133 - fscache_stat(&fscache_n_retrievals);
52134 + fscache_stat_unchecked(&fscache_n_retrievals);
52135
52136 if (hlist_empty(&cookie->backing_objects))
52137 goto nobufs;
52138 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52139 goto nobufs_unlock_dec;
52140 spin_unlock(&cookie->lock);
52141
52142 - fscache_stat(&fscache_n_retrieval_ops);
52143 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52144
52145 /* pin the netfs read context in case we need to do the actual netfs
52146 * read because we've encountered a cache read failure */
52147 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52148
52149 error:
52150 if (ret == -ENOMEM)
52151 - fscache_stat(&fscache_n_retrievals_nomem);
52152 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52153 else if (ret == -ERESTARTSYS)
52154 - fscache_stat(&fscache_n_retrievals_intr);
52155 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52156 else if (ret == -ENODATA)
52157 - fscache_stat(&fscache_n_retrievals_nodata);
52158 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52159 else if (ret < 0)
52160 - fscache_stat(&fscache_n_retrievals_nobufs);
52161 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52162 else
52163 - fscache_stat(&fscache_n_retrievals_ok);
52164 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52165
52166 fscache_put_retrieval(op);
52167 _leave(" = %d", ret);
52168 @@ -591,7 +591,7 @@ nobufs_unlock:
52169 spin_unlock(&cookie->lock);
52170 kfree(op);
52171 nobufs:
52172 - fscache_stat(&fscache_n_retrievals_nobufs);
52173 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52174 _leave(" = -ENOBUFS");
52175 return -ENOBUFS;
52176 }
52177 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52178
52179 _enter("%p,%p,,,", cookie, page);
52180
52181 - fscache_stat(&fscache_n_allocs);
52182 + fscache_stat_unchecked(&fscache_n_allocs);
52183
52184 if (hlist_empty(&cookie->backing_objects))
52185 goto nobufs;
52186 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52187 goto nobufs_unlock;
52188 spin_unlock(&cookie->lock);
52189
52190 - fscache_stat(&fscache_n_alloc_ops);
52191 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52192
52193 ret = fscache_wait_for_retrieval_activation(
52194 object, op,
52195 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52196
52197 error:
52198 if (ret == -ERESTARTSYS)
52199 - fscache_stat(&fscache_n_allocs_intr);
52200 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52201 else if (ret < 0)
52202 - fscache_stat(&fscache_n_allocs_nobufs);
52203 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52204 else
52205 - fscache_stat(&fscache_n_allocs_ok);
52206 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52207
52208 fscache_put_retrieval(op);
52209 _leave(" = %d", ret);
52210 @@ -677,7 +677,7 @@ nobufs_unlock:
52211 spin_unlock(&cookie->lock);
52212 kfree(op);
52213 nobufs:
52214 - fscache_stat(&fscache_n_allocs_nobufs);
52215 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52216 _leave(" = -ENOBUFS");
52217 return -ENOBUFS;
52218 }
52219 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52220
52221 spin_lock(&cookie->stores_lock);
52222
52223 - fscache_stat(&fscache_n_store_calls);
52224 + fscache_stat_unchecked(&fscache_n_store_calls);
52225
52226 /* find a page to store */
52227 page = NULL;
52228 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52229 page = results[0];
52230 _debug("gang %d [%lx]", n, page->index);
52231 if (page->index > op->store_limit) {
52232 - fscache_stat(&fscache_n_store_pages_over_limit);
52233 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52234 goto superseded;
52235 }
52236
52237 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52238 spin_unlock(&cookie->stores_lock);
52239 spin_unlock(&object->lock);
52240
52241 - fscache_stat(&fscache_n_store_pages);
52242 + fscache_stat_unchecked(&fscache_n_store_pages);
52243 fscache_stat(&fscache_n_cop_write_page);
52244 ret = object->cache->ops->write_page(op, page);
52245 fscache_stat_d(&fscache_n_cop_write_page);
52246 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52247 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52248 ASSERT(PageFsCache(page));
52249
52250 - fscache_stat(&fscache_n_stores);
52251 + fscache_stat_unchecked(&fscache_n_stores);
52252
52253 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52254 _leave(" = -ENOBUFS [invalidating]");
52255 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52256 spin_unlock(&cookie->stores_lock);
52257 spin_unlock(&object->lock);
52258
52259 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52260 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52261 op->store_limit = object->store_limit;
52262
52263 if (fscache_submit_op(object, &op->op) < 0)
52264 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52265
52266 spin_unlock(&cookie->lock);
52267 radix_tree_preload_end();
52268 - fscache_stat(&fscache_n_store_ops);
52269 - fscache_stat(&fscache_n_stores_ok);
52270 + fscache_stat_unchecked(&fscache_n_store_ops);
52271 + fscache_stat_unchecked(&fscache_n_stores_ok);
52272
52273 /* the work queue now carries its own ref on the object */
52274 fscache_put_operation(&op->op);
52275 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52276 return 0;
52277
52278 already_queued:
52279 - fscache_stat(&fscache_n_stores_again);
52280 + fscache_stat_unchecked(&fscache_n_stores_again);
52281 already_pending:
52282 spin_unlock(&cookie->stores_lock);
52283 spin_unlock(&object->lock);
52284 spin_unlock(&cookie->lock);
52285 radix_tree_preload_end();
52286 kfree(op);
52287 - fscache_stat(&fscache_n_stores_ok);
52288 + fscache_stat_unchecked(&fscache_n_stores_ok);
52289 _leave(" = 0");
52290 return 0;
52291
52292 @@ -959,14 +959,14 @@ nobufs:
52293 spin_unlock(&cookie->lock);
52294 radix_tree_preload_end();
52295 kfree(op);
52296 - fscache_stat(&fscache_n_stores_nobufs);
52297 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52298 _leave(" = -ENOBUFS");
52299 return -ENOBUFS;
52300
52301 nomem_free:
52302 kfree(op);
52303 nomem:
52304 - fscache_stat(&fscache_n_stores_oom);
52305 + fscache_stat_unchecked(&fscache_n_stores_oom);
52306 _leave(" = -ENOMEM");
52307 return -ENOMEM;
52308 }
52309 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52310 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52311 ASSERTCMP(page, !=, NULL);
52312
52313 - fscache_stat(&fscache_n_uncaches);
52314 + fscache_stat_unchecked(&fscache_n_uncaches);
52315
52316 /* cache withdrawal may beat us to it */
52317 if (!PageFsCache(page))
52318 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52319 struct fscache_cookie *cookie = op->op.object->cookie;
52320
52321 #ifdef CONFIG_FSCACHE_STATS
52322 - atomic_inc(&fscache_n_marks);
52323 + atomic_inc_unchecked(&fscache_n_marks);
52324 #endif
52325
52326 _debug("- mark %p{%lx}", page, page->index);
52327 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52328 index 8179e8b..5072cc7 100644
52329 --- a/fs/fscache/stats.c
52330 +++ b/fs/fscache/stats.c
52331 @@ -18,99 +18,99 @@
52332 /*
52333 * operation counters
52334 */
52335 -atomic_t fscache_n_op_pend;
52336 -atomic_t fscache_n_op_run;
52337 -atomic_t fscache_n_op_enqueue;
52338 -atomic_t fscache_n_op_requeue;
52339 -atomic_t fscache_n_op_deferred_release;
52340 -atomic_t fscache_n_op_release;
52341 -atomic_t fscache_n_op_gc;
52342 -atomic_t fscache_n_op_cancelled;
52343 -atomic_t fscache_n_op_rejected;
52344 +atomic_unchecked_t fscache_n_op_pend;
52345 +atomic_unchecked_t fscache_n_op_run;
52346 +atomic_unchecked_t fscache_n_op_enqueue;
52347 +atomic_unchecked_t fscache_n_op_requeue;
52348 +atomic_unchecked_t fscache_n_op_deferred_release;
52349 +atomic_unchecked_t fscache_n_op_release;
52350 +atomic_unchecked_t fscache_n_op_gc;
52351 +atomic_unchecked_t fscache_n_op_cancelled;
52352 +atomic_unchecked_t fscache_n_op_rejected;
52353
52354 -atomic_t fscache_n_attr_changed;
52355 -atomic_t fscache_n_attr_changed_ok;
52356 -atomic_t fscache_n_attr_changed_nobufs;
52357 -atomic_t fscache_n_attr_changed_nomem;
52358 -atomic_t fscache_n_attr_changed_calls;
52359 +atomic_unchecked_t fscache_n_attr_changed;
52360 +atomic_unchecked_t fscache_n_attr_changed_ok;
52361 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52362 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52363 +atomic_unchecked_t fscache_n_attr_changed_calls;
52364
52365 -atomic_t fscache_n_allocs;
52366 -atomic_t fscache_n_allocs_ok;
52367 -atomic_t fscache_n_allocs_wait;
52368 -atomic_t fscache_n_allocs_nobufs;
52369 -atomic_t fscache_n_allocs_intr;
52370 -atomic_t fscache_n_allocs_object_dead;
52371 -atomic_t fscache_n_alloc_ops;
52372 -atomic_t fscache_n_alloc_op_waits;
52373 +atomic_unchecked_t fscache_n_allocs;
52374 +atomic_unchecked_t fscache_n_allocs_ok;
52375 +atomic_unchecked_t fscache_n_allocs_wait;
52376 +atomic_unchecked_t fscache_n_allocs_nobufs;
52377 +atomic_unchecked_t fscache_n_allocs_intr;
52378 +atomic_unchecked_t fscache_n_allocs_object_dead;
52379 +atomic_unchecked_t fscache_n_alloc_ops;
52380 +atomic_unchecked_t fscache_n_alloc_op_waits;
52381
52382 -atomic_t fscache_n_retrievals;
52383 -atomic_t fscache_n_retrievals_ok;
52384 -atomic_t fscache_n_retrievals_wait;
52385 -atomic_t fscache_n_retrievals_nodata;
52386 -atomic_t fscache_n_retrievals_nobufs;
52387 -atomic_t fscache_n_retrievals_intr;
52388 -atomic_t fscache_n_retrievals_nomem;
52389 -atomic_t fscache_n_retrievals_object_dead;
52390 -atomic_t fscache_n_retrieval_ops;
52391 -atomic_t fscache_n_retrieval_op_waits;
52392 +atomic_unchecked_t fscache_n_retrievals;
52393 +atomic_unchecked_t fscache_n_retrievals_ok;
52394 +atomic_unchecked_t fscache_n_retrievals_wait;
52395 +atomic_unchecked_t fscache_n_retrievals_nodata;
52396 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52397 +atomic_unchecked_t fscache_n_retrievals_intr;
52398 +atomic_unchecked_t fscache_n_retrievals_nomem;
52399 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52400 +atomic_unchecked_t fscache_n_retrieval_ops;
52401 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52402
52403 -atomic_t fscache_n_stores;
52404 -atomic_t fscache_n_stores_ok;
52405 -atomic_t fscache_n_stores_again;
52406 -atomic_t fscache_n_stores_nobufs;
52407 -atomic_t fscache_n_stores_oom;
52408 -atomic_t fscache_n_store_ops;
52409 -atomic_t fscache_n_store_calls;
52410 -atomic_t fscache_n_store_pages;
52411 -atomic_t fscache_n_store_radix_deletes;
52412 -atomic_t fscache_n_store_pages_over_limit;
52413 +atomic_unchecked_t fscache_n_stores;
52414 +atomic_unchecked_t fscache_n_stores_ok;
52415 +atomic_unchecked_t fscache_n_stores_again;
52416 +atomic_unchecked_t fscache_n_stores_nobufs;
52417 +atomic_unchecked_t fscache_n_stores_oom;
52418 +atomic_unchecked_t fscache_n_store_ops;
52419 +atomic_unchecked_t fscache_n_store_calls;
52420 +atomic_unchecked_t fscache_n_store_pages;
52421 +atomic_unchecked_t fscache_n_store_radix_deletes;
52422 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52423
52424 -atomic_t fscache_n_store_vmscan_not_storing;
52425 -atomic_t fscache_n_store_vmscan_gone;
52426 -atomic_t fscache_n_store_vmscan_busy;
52427 -atomic_t fscache_n_store_vmscan_cancelled;
52428 -atomic_t fscache_n_store_vmscan_wait;
52429 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52430 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52431 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52432 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52433 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52434
52435 -atomic_t fscache_n_marks;
52436 -atomic_t fscache_n_uncaches;
52437 +atomic_unchecked_t fscache_n_marks;
52438 +atomic_unchecked_t fscache_n_uncaches;
52439
52440 -atomic_t fscache_n_acquires;
52441 -atomic_t fscache_n_acquires_null;
52442 -atomic_t fscache_n_acquires_no_cache;
52443 -atomic_t fscache_n_acquires_ok;
52444 -atomic_t fscache_n_acquires_nobufs;
52445 -atomic_t fscache_n_acquires_oom;
52446 +atomic_unchecked_t fscache_n_acquires;
52447 +atomic_unchecked_t fscache_n_acquires_null;
52448 +atomic_unchecked_t fscache_n_acquires_no_cache;
52449 +atomic_unchecked_t fscache_n_acquires_ok;
52450 +atomic_unchecked_t fscache_n_acquires_nobufs;
52451 +atomic_unchecked_t fscache_n_acquires_oom;
52452
52453 -atomic_t fscache_n_invalidates;
52454 -atomic_t fscache_n_invalidates_run;
52455 +atomic_unchecked_t fscache_n_invalidates;
52456 +atomic_unchecked_t fscache_n_invalidates_run;
52457
52458 -atomic_t fscache_n_updates;
52459 -atomic_t fscache_n_updates_null;
52460 -atomic_t fscache_n_updates_run;
52461 +atomic_unchecked_t fscache_n_updates;
52462 +atomic_unchecked_t fscache_n_updates_null;
52463 +atomic_unchecked_t fscache_n_updates_run;
52464
52465 -atomic_t fscache_n_relinquishes;
52466 -atomic_t fscache_n_relinquishes_null;
52467 -atomic_t fscache_n_relinquishes_waitcrt;
52468 -atomic_t fscache_n_relinquishes_retire;
52469 +atomic_unchecked_t fscache_n_relinquishes;
52470 +atomic_unchecked_t fscache_n_relinquishes_null;
52471 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52472 +atomic_unchecked_t fscache_n_relinquishes_retire;
52473
52474 -atomic_t fscache_n_cookie_index;
52475 -atomic_t fscache_n_cookie_data;
52476 -atomic_t fscache_n_cookie_special;
52477 +atomic_unchecked_t fscache_n_cookie_index;
52478 +atomic_unchecked_t fscache_n_cookie_data;
52479 +atomic_unchecked_t fscache_n_cookie_special;
52480
52481 -atomic_t fscache_n_object_alloc;
52482 -atomic_t fscache_n_object_no_alloc;
52483 -atomic_t fscache_n_object_lookups;
52484 -atomic_t fscache_n_object_lookups_negative;
52485 -atomic_t fscache_n_object_lookups_positive;
52486 -atomic_t fscache_n_object_lookups_timed_out;
52487 -atomic_t fscache_n_object_created;
52488 -atomic_t fscache_n_object_avail;
52489 -atomic_t fscache_n_object_dead;
52490 +atomic_unchecked_t fscache_n_object_alloc;
52491 +atomic_unchecked_t fscache_n_object_no_alloc;
52492 +atomic_unchecked_t fscache_n_object_lookups;
52493 +atomic_unchecked_t fscache_n_object_lookups_negative;
52494 +atomic_unchecked_t fscache_n_object_lookups_positive;
52495 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52496 +atomic_unchecked_t fscache_n_object_created;
52497 +atomic_unchecked_t fscache_n_object_avail;
52498 +atomic_unchecked_t fscache_n_object_dead;
52499
52500 -atomic_t fscache_n_checkaux_none;
52501 -atomic_t fscache_n_checkaux_okay;
52502 -atomic_t fscache_n_checkaux_update;
52503 -atomic_t fscache_n_checkaux_obsolete;
52504 +atomic_unchecked_t fscache_n_checkaux_none;
52505 +atomic_unchecked_t fscache_n_checkaux_okay;
52506 +atomic_unchecked_t fscache_n_checkaux_update;
52507 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52508
52509 atomic_t fscache_n_cop_alloc_object;
52510 atomic_t fscache_n_cop_lookup_object;
52511 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52512 seq_puts(m, "FS-Cache statistics\n");
52513
52514 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52515 - atomic_read(&fscache_n_cookie_index),
52516 - atomic_read(&fscache_n_cookie_data),
52517 - atomic_read(&fscache_n_cookie_special));
52518 + atomic_read_unchecked(&fscache_n_cookie_index),
52519 + atomic_read_unchecked(&fscache_n_cookie_data),
52520 + atomic_read_unchecked(&fscache_n_cookie_special));
52521
52522 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52523 - atomic_read(&fscache_n_object_alloc),
52524 - atomic_read(&fscache_n_object_no_alloc),
52525 - atomic_read(&fscache_n_object_avail),
52526 - atomic_read(&fscache_n_object_dead));
52527 + atomic_read_unchecked(&fscache_n_object_alloc),
52528 + atomic_read_unchecked(&fscache_n_object_no_alloc),
52529 + atomic_read_unchecked(&fscache_n_object_avail),
52530 + atomic_read_unchecked(&fscache_n_object_dead));
52531 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
52532 - atomic_read(&fscache_n_checkaux_none),
52533 - atomic_read(&fscache_n_checkaux_okay),
52534 - atomic_read(&fscache_n_checkaux_update),
52535 - atomic_read(&fscache_n_checkaux_obsolete));
52536 + atomic_read_unchecked(&fscache_n_checkaux_none),
52537 + atomic_read_unchecked(&fscache_n_checkaux_okay),
52538 + atomic_read_unchecked(&fscache_n_checkaux_update),
52539 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
52540
52541 seq_printf(m, "Pages : mrk=%u unc=%u\n",
52542 - atomic_read(&fscache_n_marks),
52543 - atomic_read(&fscache_n_uncaches));
52544 + atomic_read_unchecked(&fscache_n_marks),
52545 + atomic_read_unchecked(&fscache_n_uncaches));
52546
52547 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
52548 " oom=%u\n",
52549 - atomic_read(&fscache_n_acquires),
52550 - atomic_read(&fscache_n_acquires_null),
52551 - atomic_read(&fscache_n_acquires_no_cache),
52552 - atomic_read(&fscache_n_acquires_ok),
52553 - atomic_read(&fscache_n_acquires_nobufs),
52554 - atomic_read(&fscache_n_acquires_oom));
52555 + atomic_read_unchecked(&fscache_n_acquires),
52556 + atomic_read_unchecked(&fscache_n_acquires_null),
52557 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
52558 + atomic_read_unchecked(&fscache_n_acquires_ok),
52559 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
52560 + atomic_read_unchecked(&fscache_n_acquires_oom));
52561
52562 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
52563 - atomic_read(&fscache_n_object_lookups),
52564 - atomic_read(&fscache_n_object_lookups_negative),
52565 - atomic_read(&fscache_n_object_lookups_positive),
52566 - atomic_read(&fscache_n_object_created),
52567 - atomic_read(&fscache_n_object_lookups_timed_out));
52568 + atomic_read_unchecked(&fscache_n_object_lookups),
52569 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
52570 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
52571 + atomic_read_unchecked(&fscache_n_object_created),
52572 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
52573
52574 seq_printf(m, "Invals : n=%u run=%u\n",
52575 - atomic_read(&fscache_n_invalidates),
52576 - atomic_read(&fscache_n_invalidates_run));
52577 + atomic_read_unchecked(&fscache_n_invalidates),
52578 + atomic_read_unchecked(&fscache_n_invalidates_run));
52579
52580 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
52581 - atomic_read(&fscache_n_updates),
52582 - atomic_read(&fscache_n_updates_null),
52583 - atomic_read(&fscache_n_updates_run));
52584 + atomic_read_unchecked(&fscache_n_updates),
52585 + atomic_read_unchecked(&fscache_n_updates_null),
52586 + atomic_read_unchecked(&fscache_n_updates_run));
52587
52588 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
52589 - atomic_read(&fscache_n_relinquishes),
52590 - atomic_read(&fscache_n_relinquishes_null),
52591 - atomic_read(&fscache_n_relinquishes_waitcrt),
52592 - atomic_read(&fscache_n_relinquishes_retire));
52593 + atomic_read_unchecked(&fscache_n_relinquishes),
52594 + atomic_read_unchecked(&fscache_n_relinquishes_null),
52595 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
52596 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
52597
52598 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
52599 - atomic_read(&fscache_n_attr_changed),
52600 - atomic_read(&fscache_n_attr_changed_ok),
52601 - atomic_read(&fscache_n_attr_changed_nobufs),
52602 - atomic_read(&fscache_n_attr_changed_nomem),
52603 - atomic_read(&fscache_n_attr_changed_calls));
52604 + atomic_read_unchecked(&fscache_n_attr_changed),
52605 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
52606 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
52607 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
52608 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
52609
52610 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
52611 - atomic_read(&fscache_n_allocs),
52612 - atomic_read(&fscache_n_allocs_ok),
52613 - atomic_read(&fscache_n_allocs_wait),
52614 - atomic_read(&fscache_n_allocs_nobufs),
52615 - atomic_read(&fscache_n_allocs_intr));
52616 + atomic_read_unchecked(&fscache_n_allocs),
52617 + atomic_read_unchecked(&fscache_n_allocs_ok),
52618 + atomic_read_unchecked(&fscache_n_allocs_wait),
52619 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
52620 + atomic_read_unchecked(&fscache_n_allocs_intr));
52621 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
52622 - atomic_read(&fscache_n_alloc_ops),
52623 - atomic_read(&fscache_n_alloc_op_waits),
52624 - atomic_read(&fscache_n_allocs_object_dead));
52625 + atomic_read_unchecked(&fscache_n_alloc_ops),
52626 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
52627 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
52628
52629 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
52630 " int=%u oom=%u\n",
52631 - atomic_read(&fscache_n_retrievals),
52632 - atomic_read(&fscache_n_retrievals_ok),
52633 - atomic_read(&fscache_n_retrievals_wait),
52634 - atomic_read(&fscache_n_retrievals_nodata),
52635 - atomic_read(&fscache_n_retrievals_nobufs),
52636 - atomic_read(&fscache_n_retrievals_intr),
52637 - atomic_read(&fscache_n_retrievals_nomem));
52638 + atomic_read_unchecked(&fscache_n_retrievals),
52639 + atomic_read_unchecked(&fscache_n_retrievals_ok),
52640 + atomic_read_unchecked(&fscache_n_retrievals_wait),
52641 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
52642 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
52643 + atomic_read_unchecked(&fscache_n_retrievals_intr),
52644 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
52645 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
52646 - atomic_read(&fscache_n_retrieval_ops),
52647 - atomic_read(&fscache_n_retrieval_op_waits),
52648 - atomic_read(&fscache_n_retrievals_object_dead));
52649 + atomic_read_unchecked(&fscache_n_retrieval_ops),
52650 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
52651 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
52652
52653 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
52654 - atomic_read(&fscache_n_stores),
52655 - atomic_read(&fscache_n_stores_ok),
52656 - atomic_read(&fscache_n_stores_again),
52657 - atomic_read(&fscache_n_stores_nobufs),
52658 - atomic_read(&fscache_n_stores_oom));
52659 + atomic_read_unchecked(&fscache_n_stores),
52660 + atomic_read_unchecked(&fscache_n_stores_ok),
52661 + atomic_read_unchecked(&fscache_n_stores_again),
52662 + atomic_read_unchecked(&fscache_n_stores_nobufs),
52663 + atomic_read_unchecked(&fscache_n_stores_oom));
52664 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
52665 - atomic_read(&fscache_n_store_ops),
52666 - atomic_read(&fscache_n_store_calls),
52667 - atomic_read(&fscache_n_store_pages),
52668 - atomic_read(&fscache_n_store_radix_deletes),
52669 - atomic_read(&fscache_n_store_pages_over_limit));
52670 + atomic_read_unchecked(&fscache_n_store_ops),
52671 + atomic_read_unchecked(&fscache_n_store_calls),
52672 + atomic_read_unchecked(&fscache_n_store_pages),
52673 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
52674 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
52675
52676 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
52677 - atomic_read(&fscache_n_store_vmscan_not_storing),
52678 - atomic_read(&fscache_n_store_vmscan_gone),
52679 - atomic_read(&fscache_n_store_vmscan_busy),
52680 - atomic_read(&fscache_n_store_vmscan_cancelled),
52681 - atomic_read(&fscache_n_store_vmscan_wait));
52682 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
52683 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
52684 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
52685 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
52686 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
52687
52688 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
52689 - atomic_read(&fscache_n_op_pend),
52690 - atomic_read(&fscache_n_op_run),
52691 - atomic_read(&fscache_n_op_enqueue),
52692 - atomic_read(&fscache_n_op_cancelled),
52693 - atomic_read(&fscache_n_op_rejected));
52694 + atomic_read_unchecked(&fscache_n_op_pend),
52695 + atomic_read_unchecked(&fscache_n_op_run),
52696 + atomic_read_unchecked(&fscache_n_op_enqueue),
52697 + atomic_read_unchecked(&fscache_n_op_cancelled),
52698 + atomic_read_unchecked(&fscache_n_op_rejected));
52699 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
52700 - atomic_read(&fscache_n_op_deferred_release),
52701 - atomic_read(&fscache_n_op_release),
52702 - atomic_read(&fscache_n_op_gc));
52703 + atomic_read_unchecked(&fscache_n_op_deferred_release),
52704 + atomic_read_unchecked(&fscache_n_op_release),
52705 + atomic_read_unchecked(&fscache_n_op_gc));
52706
52707 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
52708 atomic_read(&fscache_n_cop_alloc_object),
52709 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
52710 index e397b67..b0d8709 100644
52711 --- a/fs/fuse/cuse.c
52712 +++ b/fs/fuse/cuse.c
52713 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
52714 INIT_LIST_HEAD(&cuse_conntbl[i]);
52715
52716 /* inherit and extend fuse_dev_operations */
52717 - cuse_channel_fops = fuse_dev_operations;
52718 - cuse_channel_fops.owner = THIS_MODULE;
52719 - cuse_channel_fops.open = cuse_channel_open;
52720 - cuse_channel_fops.release = cuse_channel_release;
52721 + pax_open_kernel();
52722 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
52723 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
52724 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
52725 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
52726 + pax_close_kernel();
52727
52728 cuse_class = class_create(THIS_MODULE, "cuse");
52729 if (IS_ERR(cuse_class))
52730 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
52731 index e83351a..41e3c9c 100644
52732 --- a/fs/fuse/dev.c
52733 +++ b/fs/fuse/dev.c
52734 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
52735 ret = 0;
52736 pipe_lock(pipe);
52737
52738 - if (!pipe->readers) {
52739 + if (!atomic_read(&pipe->readers)) {
52740 send_sig(SIGPIPE, current, 0);
52741 if (!ret)
52742 ret = -EPIPE;
52743 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
52744 index 315e1f8..91f890c 100644
52745 --- a/fs/fuse/dir.c
52746 +++ b/fs/fuse/dir.c
52747 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
52748 return link;
52749 }
52750
52751 -static void free_link(char *link)
52752 +static void free_link(const char *link)
52753 {
52754 if (!IS_ERR(link))
52755 free_page((unsigned long) link);
52756 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
52757 index 2b6f569..fcb4d1f 100644
52758 --- a/fs/gfs2/inode.c
52759 +++ b/fs/gfs2/inode.c
52760 @@ -1499,7 +1499,7 @@ out:
52761
52762 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52763 {
52764 - char *s = nd_get_link(nd);
52765 + const char *s = nd_get_link(nd);
52766 if (!IS_ERR(s))
52767 kfree(s);
52768 }
52769 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
52770 index 78bde32..767e906 100644
52771 --- a/fs/hugetlbfs/inode.c
52772 +++ b/fs/hugetlbfs/inode.c
52773 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52774 struct mm_struct *mm = current->mm;
52775 struct vm_area_struct *vma;
52776 struct hstate *h = hstate_file(file);
52777 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
52778 struct vm_unmapped_area_info info;
52779
52780 if (len & ~huge_page_mask(h))
52781 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52782 return addr;
52783 }
52784
52785 +#ifdef CONFIG_PAX_RANDMMAP
52786 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
52787 +#endif
52788 +
52789 if (addr) {
52790 addr = ALIGN(addr, huge_page_size(h));
52791 vma = find_vma(mm, addr);
52792 - if (TASK_SIZE - len >= addr &&
52793 - (!vma || addr + len <= vma->vm_start))
52794 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
52795 return addr;
52796 }
52797
52798 info.flags = 0;
52799 info.length = len;
52800 info.low_limit = TASK_UNMAPPED_BASE;
52801 +
52802 +#ifdef CONFIG_PAX_RANDMMAP
52803 + if (mm->pax_flags & MF_PAX_RANDMMAP)
52804 + info.low_limit += mm->delta_mmap;
52805 +#endif
52806 +
52807 info.high_limit = TASK_SIZE;
52808 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
52809 info.align_offset = 0;
52810 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
52811 .kill_sb = kill_litter_super,
52812 };
52813
52814 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52815 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52816
52817 static int can_do_hugetlb_shm(void)
52818 {
52819 diff --git a/fs/inode.c b/fs/inode.c
52820 index 14084b7..29af1d9 100644
52821 --- a/fs/inode.c
52822 +++ b/fs/inode.c
52823 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
52824
52825 #ifdef CONFIG_SMP
52826 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
52827 - static atomic_t shared_last_ino;
52828 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
52829 + static atomic_unchecked_t shared_last_ino;
52830 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
52831
52832 res = next - LAST_INO_BATCH;
52833 }
52834 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
52835 index 4a6cf28..d3a29d3 100644
52836 --- a/fs/jffs2/erase.c
52837 +++ b/fs/jffs2/erase.c
52838 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
52839 struct jffs2_unknown_node marker = {
52840 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
52841 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52842 - .totlen = cpu_to_je32(c->cleanmarker_size)
52843 + .totlen = cpu_to_je32(c->cleanmarker_size),
52844 + .hdr_crc = cpu_to_je32(0)
52845 };
52846
52847 jffs2_prealloc_raw_node_refs(c, jeb, 1);
52848 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
52849 index a6597d6..41b30ec 100644
52850 --- a/fs/jffs2/wbuf.c
52851 +++ b/fs/jffs2/wbuf.c
52852 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
52853 {
52854 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
52855 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52856 - .totlen = constant_cpu_to_je32(8)
52857 + .totlen = constant_cpu_to_je32(8),
52858 + .hdr_crc = constant_cpu_to_je32(0)
52859 };
52860
52861 /*
52862 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
52863 index 1a543be..a4e1363 100644
52864 --- a/fs/jfs/super.c
52865 +++ b/fs/jfs/super.c
52866 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
52867 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
52868 int *flag)
52869 {
52870 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
52871 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
52872 char *p;
52873 struct jfs_sb_info *sbi = JFS_SBI(sb);
52874
52875 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
52876 /* Don't do anything ;-) */
52877 break;
52878 case Opt_iocharset:
52879 - if (nls_map && nls_map != (void *) -1)
52880 + if (nls_map && nls_map != (const void *) -1)
52881 unload_nls(nls_map);
52882 if (!strcmp(args[0].from, "none"))
52883 nls_map = NULL;
52884 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
52885
52886 jfs_inode_cachep =
52887 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
52888 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
52889 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
52890 init_once);
52891 if (jfs_inode_cachep == NULL)
52892 return -ENOMEM;
52893 diff --git a/fs/libfs.c b/fs/libfs.c
52894 index 916da8c..1588998 100644
52895 --- a/fs/libfs.c
52896 +++ b/fs/libfs.c
52897 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52898
52899 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
52900 struct dentry *next;
52901 + char d_name[sizeof(next->d_iname)];
52902 + const unsigned char *name;
52903 +
52904 next = list_entry(p, struct dentry, d_u.d_child);
52905 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
52906 if (!simple_positive(next)) {
52907 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52908
52909 spin_unlock(&next->d_lock);
52910 spin_unlock(&dentry->d_lock);
52911 - if (filldir(dirent, next->d_name.name,
52912 + name = next->d_name.name;
52913 + if (name == next->d_iname) {
52914 + memcpy(d_name, name, next->d_name.len);
52915 + name = d_name;
52916 + }
52917 + if (filldir(dirent, name,
52918 next->d_name.len, filp->f_pos,
52919 next->d_inode->i_ino,
52920 dt_type(next->d_inode)) < 0)
52921 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
52922 index 52e5120..808936e 100644
52923 --- a/fs/lockd/clntproc.c
52924 +++ b/fs/lockd/clntproc.c
52925 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
52926 /*
52927 * Cookie counter for NLM requests
52928 */
52929 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
52930 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
52931
52932 void nlmclnt_next_cookie(struct nlm_cookie *c)
52933 {
52934 - u32 cookie = atomic_inc_return(&nlm_cookie);
52935 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
52936
52937 memcpy(c->data, &cookie, 4);
52938 c->len=4;
52939 diff --git a/fs/locks.c b/fs/locks.c
52940 index a94e331..060bce3 100644
52941 --- a/fs/locks.c
52942 +++ b/fs/locks.c
52943 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
52944 return;
52945
52946 if (filp->f_op && filp->f_op->flock) {
52947 - struct file_lock fl = {
52948 + struct file_lock flock = {
52949 .fl_pid = current->tgid,
52950 .fl_file = filp,
52951 .fl_flags = FL_FLOCK,
52952 .fl_type = F_UNLCK,
52953 .fl_end = OFFSET_MAX,
52954 };
52955 - filp->f_op->flock(filp, F_SETLKW, &fl);
52956 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
52957 - fl.fl_ops->fl_release_private(&fl);
52958 + filp->f_op->flock(filp, F_SETLKW, &flock);
52959 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
52960 + flock.fl_ops->fl_release_private(&flock);
52961 }
52962
52963 lock_flocks();
52964 diff --git a/fs/namei.c b/fs/namei.c
52965 index ec97aef..e67718d 100644
52966 --- a/fs/namei.c
52967 +++ b/fs/namei.c
52968 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
52969 if (ret != -EACCES)
52970 return ret;
52971
52972 +#ifdef CONFIG_GRKERNSEC
52973 + /* we'll block if we have to log due to a denied capability use */
52974 + if (mask & MAY_NOT_BLOCK)
52975 + return -ECHILD;
52976 +#endif
52977 +
52978 if (S_ISDIR(inode->i_mode)) {
52979 /* DACs are overridable for directories */
52980 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
52981 - return 0;
52982 if (!(mask & MAY_WRITE))
52983 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
52984 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
52985 + inode_capable(inode, CAP_DAC_READ_SEARCH))
52986 return 0;
52987 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
52988 + return 0;
52989 return -EACCES;
52990 }
52991 /*
52992 + * Searching includes executable on directories, else just read.
52993 + */
52994 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
52995 + if (mask == MAY_READ)
52996 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
52997 + inode_capable(inode, CAP_DAC_READ_SEARCH))
52998 + return 0;
52999 +
53000 + /*
53001 * Read/write DACs are always overridable.
53002 * Executable DACs are overridable when there is
53003 * at least one exec bit set.
53004 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53005 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53006 return 0;
53007
53008 - /*
53009 - * Searching includes executable on directories, else just read.
53010 - */
53011 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53012 - if (mask == MAY_READ)
53013 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53014 - return 0;
53015 -
53016 return -EACCES;
53017 }
53018
53019 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53020 {
53021 struct dentry *dentry = link->dentry;
53022 int error;
53023 - char *s;
53024 + const char *s;
53025
53026 BUG_ON(nd->flags & LOOKUP_RCU);
53027
53028 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53029 if (error)
53030 goto out_put_nd_path;
53031
53032 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53033 + dentry->d_inode, dentry, nd->path.mnt)) {
53034 + error = -EACCES;
53035 + goto out_put_nd_path;
53036 + }
53037 +
53038 nd->last_type = LAST_BIND;
53039 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53040 error = PTR_ERR(*p);
53041 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53042 break;
53043 res = walk_component(nd, path, &nd->last,
53044 nd->last_type, LOOKUP_FOLLOW);
53045 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53046 + res = -EACCES;
53047 put_link(nd, &link, cookie);
53048 } while (res > 0);
53049
53050 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
53051 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53052 {
53053 unsigned long a, b, adata, bdata, mask, hash, len;
53054 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53055 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53056
53057 hash = a = 0;
53058 len = -sizeof(unsigned long);
53059 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
53060 if (err)
53061 break;
53062 err = lookup_last(nd, &path);
53063 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53064 + err = -EACCES;
53065 put_link(nd, &link, cookie);
53066 }
53067 }
53068 @@ -1984,6 +2002,13 @@ static int path_lookupat(int dfd, const char *name,
53069 if (!err)
53070 err = complete_walk(nd);
53071
53072 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53073 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53074 + path_put(&nd->path);
53075 + err = -ENOENT;
53076 + }
53077 + }
53078 +
53079 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53080 if (!nd->inode->i_op->lookup) {
53081 path_put(&nd->path);
53082 @@ -2011,8 +2036,15 @@ static int filename_lookup(int dfd, struct filename *name,
53083 retval = path_lookupat(dfd, name->name,
53084 flags | LOOKUP_REVAL, nd);
53085
53086 - if (likely(!retval))
53087 + if (likely(!retval)) {
53088 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53089 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53090 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53091 + path_put(&nd->path);
53092 + return -ENOENT;
53093 + }
53094 + }
53095 + }
53096 return retval;
53097 }
53098
53099 @@ -2390,6 +2422,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53100 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53101 return -EPERM;
53102
53103 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53104 + return -EPERM;
53105 + if (gr_handle_rawio(inode))
53106 + return -EPERM;
53107 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53108 + return -EACCES;
53109 +
53110 return 0;
53111 }
53112
53113 @@ -2611,7 +2650,7 @@ looked_up:
53114 * cleared otherwise prior to returning.
53115 */
53116 static int lookup_open(struct nameidata *nd, struct path *path,
53117 - struct file *file,
53118 + struct path *link, struct file *file,
53119 const struct open_flags *op,
53120 bool got_write, int *opened)
53121 {
53122 @@ -2646,6 +2685,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53123 /* Negative dentry, just create the file */
53124 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53125 umode_t mode = op->mode;
53126 +
53127 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53128 + error = -EACCES;
53129 + goto out_dput;
53130 + }
53131 +
53132 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53133 + error = -EACCES;
53134 + goto out_dput;
53135 + }
53136 +
53137 if (!IS_POSIXACL(dir->d_inode))
53138 mode &= ~current_umask();
53139 /*
53140 @@ -2667,6 +2717,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53141 nd->flags & LOOKUP_EXCL);
53142 if (error)
53143 goto out_dput;
53144 + else
53145 + gr_handle_create(dentry, nd->path.mnt);
53146 }
53147 out_no_open:
53148 path->dentry = dentry;
53149 @@ -2681,7 +2733,7 @@ out_dput:
53150 /*
53151 * Handle the last step of open()
53152 */
53153 -static int do_last(struct nameidata *nd, struct path *path,
53154 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53155 struct file *file, const struct open_flags *op,
53156 int *opened, struct filename *name)
53157 {
53158 @@ -2710,16 +2762,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53159 error = complete_walk(nd);
53160 if (error)
53161 return error;
53162 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53163 + error = -ENOENT;
53164 + goto out;
53165 + }
53166 audit_inode(name, nd->path.dentry, 0);
53167 if (open_flag & O_CREAT) {
53168 error = -EISDIR;
53169 goto out;
53170 }
53171 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53172 + error = -EACCES;
53173 + goto out;
53174 + }
53175 goto finish_open;
53176 case LAST_BIND:
53177 error = complete_walk(nd);
53178 if (error)
53179 return error;
53180 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53181 + error = -ENOENT;
53182 + goto out;
53183 + }
53184 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53185 + error = -EACCES;
53186 + goto out;
53187 + }
53188 audit_inode(name, dir, 0);
53189 goto finish_open;
53190 }
53191 @@ -2768,7 +2836,7 @@ retry_lookup:
53192 */
53193 }
53194 mutex_lock(&dir->d_inode->i_mutex);
53195 - error = lookup_open(nd, path, file, op, got_write, opened);
53196 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53197 mutex_unlock(&dir->d_inode->i_mutex);
53198
53199 if (error <= 0) {
53200 @@ -2792,11 +2860,28 @@ retry_lookup:
53201 goto finish_open_created;
53202 }
53203
53204 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53205 + error = -ENOENT;
53206 + goto exit_dput;
53207 + }
53208 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53209 + error = -EACCES;
53210 + goto exit_dput;
53211 + }
53212 +
53213 /*
53214 * create/update audit record if it already exists.
53215 */
53216 - if (path->dentry->d_inode)
53217 + if (path->dentry->d_inode) {
53218 + /* only check if O_CREAT is specified, all other checks need to go
53219 + into may_open */
53220 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53221 + error = -EACCES;
53222 + goto exit_dput;
53223 + }
53224 +
53225 audit_inode(name, path->dentry, 0);
53226 + }
53227
53228 /*
53229 * If atomic_open() acquired write access it is dropped now due to
53230 @@ -2837,6 +2922,11 @@ finish_lookup:
53231 }
53232 }
53233 BUG_ON(inode != path->dentry->d_inode);
53234 + /* if we're resolving a symlink to another symlink */
53235 + if (link && gr_handle_symlink_owner(link, inode)) {
53236 + error = -EACCES;
53237 + goto out;
53238 + }
53239 return 1;
53240 }
53241
53242 @@ -2846,7 +2936,6 @@ finish_lookup:
53243 save_parent.dentry = nd->path.dentry;
53244 save_parent.mnt = mntget(path->mnt);
53245 nd->path.dentry = path->dentry;
53246 -
53247 }
53248 nd->inode = inode;
53249 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53250 @@ -2855,6 +2944,16 @@ finish_lookup:
53251 path_put(&save_parent);
53252 return error;
53253 }
53254 +
53255 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53256 + error = -ENOENT;
53257 + goto out;
53258 + }
53259 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53260 + error = -EACCES;
53261 + goto out;
53262 + }
53263 +
53264 error = -EISDIR;
53265 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53266 goto out;
53267 @@ -2953,7 +3052,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53268 if (unlikely(error))
53269 goto out;
53270
53271 - error = do_last(nd, &path, file, op, &opened, pathname);
53272 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53273 while (unlikely(error > 0)) { /* trailing symlink */
53274 struct path link = path;
53275 void *cookie;
53276 @@ -2971,7 +3070,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53277 error = follow_link(&link, nd, &cookie);
53278 if (unlikely(error))
53279 break;
53280 - error = do_last(nd, &path, file, op, &opened, pathname);
53281 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53282 put_link(nd, &link, cookie);
53283 }
53284 out:
53285 @@ -3071,8 +3170,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53286 goto unlock;
53287
53288 error = -EEXIST;
53289 - if (dentry->d_inode)
53290 + if (dentry->d_inode) {
53291 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53292 + error = -ENOENT;
53293 + }
53294 goto fail;
53295 + }
53296 /*
53297 * Special case - lookup gave negative, but... we had foo/bar/
53298 * From the vfs_mknod() POV we just have a negative dentry -
53299 @@ -3124,6 +3227,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53300 }
53301 EXPORT_SYMBOL(user_path_create);
53302
53303 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53304 +{
53305 + struct filename *tmp = getname(pathname);
53306 + struct dentry *res;
53307 + if (IS_ERR(tmp))
53308 + return ERR_CAST(tmp);
53309 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53310 + if (IS_ERR(res))
53311 + putname(tmp);
53312 + else
53313 + *to = tmp;
53314 + return res;
53315 +}
53316 +
53317 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53318 {
53319 int error = may_create(dir, dentry);
53320 @@ -3186,6 +3303,17 @@ retry:
53321
53322 if (!IS_POSIXACL(path.dentry->d_inode))
53323 mode &= ~current_umask();
53324 +
53325 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53326 + error = -EPERM;
53327 + goto out;
53328 + }
53329 +
53330 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53331 + error = -EACCES;
53332 + goto out;
53333 + }
53334 +
53335 error = security_path_mknod(&path, dentry, mode, dev);
53336 if (error)
53337 goto out;
53338 @@ -3202,6 +3330,8 @@ retry:
53339 break;
53340 }
53341 out:
53342 + if (!error)
53343 + gr_handle_create(dentry, path.mnt);
53344 done_path_create(&path, dentry);
53345 if (retry_estale(error, lookup_flags)) {
53346 lookup_flags |= LOOKUP_REVAL;
53347 @@ -3254,9 +3384,16 @@ retry:
53348
53349 if (!IS_POSIXACL(path.dentry->d_inode))
53350 mode &= ~current_umask();
53351 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53352 + error = -EACCES;
53353 + goto out;
53354 + }
53355 error = security_path_mkdir(&path, dentry, mode);
53356 if (!error)
53357 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53358 + if (!error)
53359 + gr_handle_create(dentry, path.mnt);
53360 +out:
53361 done_path_create(&path, dentry);
53362 if (retry_estale(error, lookup_flags)) {
53363 lookup_flags |= LOOKUP_REVAL;
53364 @@ -3337,6 +3474,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53365 struct filename *name;
53366 struct dentry *dentry;
53367 struct nameidata nd;
53368 + ino_t saved_ino = 0;
53369 + dev_t saved_dev = 0;
53370 unsigned int lookup_flags = 0;
53371 retry:
53372 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53373 @@ -3369,10 +3508,21 @@ retry:
53374 error = -ENOENT;
53375 goto exit3;
53376 }
53377 +
53378 + saved_ino = dentry->d_inode->i_ino;
53379 + saved_dev = gr_get_dev_from_dentry(dentry);
53380 +
53381 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53382 + error = -EACCES;
53383 + goto exit3;
53384 + }
53385 +
53386 error = security_path_rmdir(&nd.path, dentry);
53387 if (error)
53388 goto exit3;
53389 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53390 + if (!error && (saved_dev || saved_ino))
53391 + gr_handle_delete(saved_ino, saved_dev);
53392 exit3:
53393 dput(dentry);
53394 exit2:
53395 @@ -3438,6 +3588,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53396 struct dentry *dentry;
53397 struct nameidata nd;
53398 struct inode *inode = NULL;
53399 + ino_t saved_ino = 0;
53400 + dev_t saved_dev = 0;
53401 unsigned int lookup_flags = 0;
53402 retry:
53403 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53404 @@ -3464,10 +3616,22 @@ retry:
53405 if (!inode)
53406 goto slashes;
53407 ihold(inode);
53408 +
53409 + if (inode->i_nlink <= 1) {
53410 + saved_ino = inode->i_ino;
53411 + saved_dev = gr_get_dev_from_dentry(dentry);
53412 + }
53413 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53414 + error = -EACCES;
53415 + goto exit2;
53416 + }
53417 +
53418 error = security_path_unlink(&nd.path, dentry);
53419 if (error)
53420 goto exit2;
53421 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53422 + if (!error && (saved_ino || saved_dev))
53423 + gr_handle_delete(saved_ino, saved_dev);
53424 exit2:
53425 dput(dentry);
53426 }
53427 @@ -3545,9 +3709,17 @@ retry:
53428 if (IS_ERR(dentry))
53429 goto out_putname;
53430
53431 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53432 + error = -EACCES;
53433 + goto out;
53434 + }
53435 +
53436 error = security_path_symlink(&path, dentry, from->name);
53437 if (!error)
53438 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53439 + if (!error)
53440 + gr_handle_create(dentry, path.mnt);
53441 +out:
53442 done_path_create(&path, dentry);
53443 if (retry_estale(error, lookup_flags)) {
53444 lookup_flags |= LOOKUP_REVAL;
53445 @@ -3621,6 +3793,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53446 {
53447 struct dentry *new_dentry;
53448 struct path old_path, new_path;
53449 + struct filename *to = NULL;
53450 int how = 0;
53451 int error;
53452
53453 @@ -3644,7 +3817,7 @@ retry:
53454 if (error)
53455 return error;
53456
53457 - new_dentry = user_path_create(newdfd, newname, &new_path,
53458 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53459 (how & LOOKUP_REVAL));
53460 error = PTR_ERR(new_dentry);
53461 if (IS_ERR(new_dentry))
53462 @@ -3656,11 +3829,28 @@ retry:
53463 error = may_linkat(&old_path);
53464 if (unlikely(error))
53465 goto out_dput;
53466 +
53467 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53468 + old_path.dentry->d_inode,
53469 + old_path.dentry->d_inode->i_mode, to)) {
53470 + error = -EACCES;
53471 + goto out_dput;
53472 + }
53473 +
53474 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53475 + old_path.dentry, old_path.mnt, to)) {
53476 + error = -EACCES;
53477 + goto out_dput;
53478 + }
53479 +
53480 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53481 if (error)
53482 goto out_dput;
53483 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53484 + if (!error)
53485 + gr_handle_create(new_dentry, new_path.mnt);
53486 out_dput:
53487 + putname(to);
53488 done_path_create(&new_path, new_dentry);
53489 if (retry_estale(error, how)) {
53490 how |= LOOKUP_REVAL;
53491 @@ -3906,12 +4096,21 @@ retry:
53492 if (new_dentry == trap)
53493 goto exit5;
53494
53495 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53496 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53497 + to);
53498 + if (error)
53499 + goto exit5;
53500 +
53501 error = security_path_rename(&oldnd.path, old_dentry,
53502 &newnd.path, new_dentry);
53503 if (error)
53504 goto exit5;
53505 error = vfs_rename(old_dir->d_inode, old_dentry,
53506 new_dir->d_inode, new_dentry);
53507 + if (!error)
53508 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53509 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53510 exit5:
53511 dput(new_dentry);
53512 exit4:
53513 @@ -3943,6 +4142,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53514
53515 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53516 {
53517 + char tmpbuf[64];
53518 + const char *newlink;
53519 int len;
53520
53521 len = PTR_ERR(link);
53522 @@ -3952,7 +4153,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53523 len = strlen(link);
53524 if (len > (unsigned) buflen)
53525 len = buflen;
53526 - if (copy_to_user(buffer, link, len))
53527 +
53528 + if (len < sizeof(tmpbuf)) {
53529 + memcpy(tmpbuf, link, len);
53530 + newlink = tmpbuf;
53531 + } else
53532 + newlink = link;
53533 +
53534 + if (copy_to_user(buffer, newlink, len))
53535 len = -EFAULT;
53536 out:
53537 return len;
53538 diff --git a/fs/namespace.c b/fs/namespace.c
53539 index a51054f..f9b53e5 100644
53540 --- a/fs/namespace.c
53541 +++ b/fs/namespace.c
53542 @@ -1215,6 +1215,9 @@ static int do_umount(struct mount *mnt, int flags)
53543 if (!(sb->s_flags & MS_RDONLY))
53544 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
53545 up_write(&sb->s_umount);
53546 +
53547 + gr_log_remount(mnt->mnt_devname, retval);
53548 +
53549 return retval;
53550 }
53551
53552 @@ -1234,6 +1237,9 @@ static int do_umount(struct mount *mnt, int flags)
53553 br_write_unlock(&vfsmount_lock);
53554 up_write(&namespace_sem);
53555 release_mounts(&umount_list);
53556 +
53557 + gr_log_unmount(mnt->mnt_devname, retval);
53558 +
53559 return retval;
53560 }
53561
53562 @@ -2287,6 +2293,16 @@ long do_mount(const char *dev_name, const char *dir_name,
53563 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
53564 MS_STRICTATIME);
53565
53566 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
53567 + retval = -EPERM;
53568 + goto dput_out;
53569 + }
53570 +
53571 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
53572 + retval = -EPERM;
53573 + goto dput_out;
53574 + }
53575 +
53576 if (flags & MS_REMOUNT)
53577 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
53578 data_page);
53579 @@ -2301,6 +2317,9 @@ long do_mount(const char *dev_name, const char *dir_name,
53580 dev_name, data_page);
53581 dput_out:
53582 path_put(&path);
53583 +
53584 + gr_log_mount(dev_name, dir_name, retval);
53585 +
53586 return retval;
53587 }
53588
53589 @@ -2587,6 +2606,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
53590 if (error)
53591 goto out2;
53592
53593 + if (gr_handle_chroot_pivot()) {
53594 + error = -EPERM;
53595 + goto out2;
53596 + }
53597 +
53598 get_fs_root(current->fs, &root);
53599 error = lock_mount(&old);
53600 if (error)
53601 @@ -2790,7 +2814,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
53602 !nsown_capable(CAP_SYS_ADMIN))
53603 return -EPERM;
53604
53605 - if (fs->users != 1)
53606 + if (atomic_read(&fs->users) != 1)
53607 return -EINVAL;
53608
53609 get_mnt_ns(mnt_ns);
53610 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
53611 index 59461c9..b17c57e 100644
53612 --- a/fs/nfs/callback_xdr.c
53613 +++ b/fs/nfs/callback_xdr.c
53614 @@ -51,7 +51,7 @@ struct callback_op {
53615 callback_decode_arg_t decode_args;
53616 callback_encode_res_t encode_res;
53617 long res_maxsize;
53618 -};
53619 +} __do_const;
53620
53621 static struct callback_op callback_ops[];
53622
53623 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
53624 index ebeb94c..ff35337 100644
53625 --- a/fs/nfs/inode.c
53626 +++ b/fs/nfs/inode.c
53627 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
53628 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
53629 }
53630
53631 -static atomic_long_t nfs_attr_generation_counter;
53632 +static atomic_long_unchecked_t nfs_attr_generation_counter;
53633
53634 static unsigned long nfs_read_attr_generation_counter(void)
53635 {
53636 - return atomic_long_read(&nfs_attr_generation_counter);
53637 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
53638 }
53639
53640 unsigned long nfs_inc_attr_generation_counter(void)
53641 {
53642 - return atomic_long_inc_return(&nfs_attr_generation_counter);
53643 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
53644 }
53645
53646 void nfs_fattr_init(struct nfs_fattr *fattr)
53647 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
53648 index 9d1c5db..1e13db8 100644
53649 --- a/fs/nfsd/nfs4proc.c
53650 +++ b/fs/nfsd/nfs4proc.c
53651 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
53652 nfsd4op_rsize op_rsize_bop;
53653 stateid_getter op_get_currentstateid;
53654 stateid_setter op_set_currentstateid;
53655 -};
53656 +} __do_const;
53657
53658 static struct nfsd4_operation nfsd4_ops[];
53659
53660 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
53661 index 0dc1158..32ac0e8 100644
53662 --- a/fs/nfsd/nfs4xdr.c
53663 +++ b/fs/nfsd/nfs4xdr.c
53664 @@ -264,7 +264,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
53665 iattr->ia_valid |= ATTR_SIZE;
53666 }
53667 if (bmval[0] & FATTR4_WORD0_ACL) {
53668 - int nace;
53669 + u32 nace;
53670 struct nfs4_ace *ace;
53671
53672 READ_BUF(4); len += 4;
53673 @@ -1456,7 +1456,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
53674
53675 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
53676
53677 -static nfsd4_dec nfsd4_dec_ops[] = {
53678 +static const nfsd4_dec nfsd4_dec_ops[] = {
53679 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53680 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53681 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53682 @@ -1496,7 +1496,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
53683 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
53684 };
53685
53686 -static nfsd4_dec nfsd41_dec_ops[] = {
53687 +static const nfsd4_dec nfsd41_dec_ops[] = {
53688 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53689 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53690 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53691 @@ -1558,7 +1558,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
53692 };
53693
53694 struct nfsd4_minorversion_ops {
53695 - nfsd4_dec *decoders;
53696 + const nfsd4_dec *decoders;
53697 int nops;
53698 };
53699
53700 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
53701 index 69c6413..c0408d2 100644
53702 --- a/fs/nfsd/vfs.c
53703 +++ b/fs/nfsd/vfs.c
53704 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53705 } else {
53706 oldfs = get_fs();
53707 set_fs(KERNEL_DS);
53708 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
53709 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
53710 set_fs(oldfs);
53711 }
53712
53713 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53714
53715 /* Write the data. */
53716 oldfs = get_fs(); set_fs(KERNEL_DS);
53717 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
53718 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
53719 set_fs(oldfs);
53720 if (host_err < 0)
53721 goto out_nfserr;
53722 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
53723 */
53724
53725 oldfs = get_fs(); set_fs(KERNEL_DS);
53726 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
53727 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
53728 set_fs(oldfs);
53729
53730 if (host_err < 0)
53731 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
53732 index fea6bd5..8ee9d81 100644
53733 --- a/fs/nls/nls_base.c
53734 +++ b/fs/nls/nls_base.c
53735 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
53736
53737 int register_nls(struct nls_table * nls)
53738 {
53739 - struct nls_table ** tmp = &tables;
53740 + struct nls_table *tmp = tables;
53741
53742 if (nls->next)
53743 return -EBUSY;
53744
53745 spin_lock(&nls_lock);
53746 - while (*tmp) {
53747 - if (nls == *tmp) {
53748 + while (tmp) {
53749 + if (nls == tmp) {
53750 spin_unlock(&nls_lock);
53751 return -EBUSY;
53752 }
53753 - tmp = &(*tmp)->next;
53754 + tmp = tmp->next;
53755 }
53756 - nls->next = tables;
53757 + pax_open_kernel();
53758 + *(struct nls_table **)&nls->next = tables;
53759 + pax_close_kernel();
53760 tables = nls;
53761 spin_unlock(&nls_lock);
53762 return 0;
53763 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
53764
53765 int unregister_nls(struct nls_table * nls)
53766 {
53767 - struct nls_table ** tmp = &tables;
53768 + struct nls_table * const * tmp = &tables;
53769
53770 spin_lock(&nls_lock);
53771 while (*tmp) {
53772 if (nls == *tmp) {
53773 - *tmp = nls->next;
53774 + pax_open_kernel();
53775 + *(struct nls_table **)tmp = nls->next;
53776 + pax_close_kernel();
53777 spin_unlock(&nls_lock);
53778 return 0;
53779 }
53780 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
53781 index 7424929..35f6be5 100644
53782 --- a/fs/nls/nls_euc-jp.c
53783 +++ b/fs/nls/nls_euc-jp.c
53784 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
53785 p_nls = load_nls("cp932");
53786
53787 if (p_nls) {
53788 - table.charset2upper = p_nls->charset2upper;
53789 - table.charset2lower = p_nls->charset2lower;
53790 + pax_open_kernel();
53791 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53792 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53793 + pax_close_kernel();
53794 return register_nls(&table);
53795 }
53796
53797 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
53798 index e7bc1d7..06bd4bb 100644
53799 --- a/fs/nls/nls_koi8-ru.c
53800 +++ b/fs/nls/nls_koi8-ru.c
53801 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
53802 p_nls = load_nls("koi8-u");
53803
53804 if (p_nls) {
53805 - table.charset2upper = p_nls->charset2upper;
53806 - table.charset2lower = p_nls->charset2lower;
53807 + pax_open_kernel();
53808 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53809 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53810 + pax_close_kernel();
53811 return register_nls(&table);
53812 }
53813
53814 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
53815 index 9ff4a5e..deb1f0f 100644
53816 --- a/fs/notify/fanotify/fanotify_user.c
53817 +++ b/fs/notify/fanotify/fanotify_user.c
53818 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
53819
53820 fd = fanotify_event_metadata.fd;
53821 ret = -EFAULT;
53822 - if (copy_to_user(buf, &fanotify_event_metadata,
53823 - fanotify_event_metadata.event_len))
53824 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
53825 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
53826 goto out_close_fd;
53827
53828 ret = prepare_for_access_response(group, event, fd);
53829 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
53830 index 7b51b05..5ea5ef6 100644
53831 --- a/fs/notify/notification.c
53832 +++ b/fs/notify/notification.c
53833 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
53834 * get set to 0 so it will never get 'freed'
53835 */
53836 static struct fsnotify_event *q_overflow_event;
53837 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53838 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53839
53840 /**
53841 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
53842 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53843 */
53844 u32 fsnotify_get_cookie(void)
53845 {
53846 - return atomic_inc_return(&fsnotify_sync_cookie);
53847 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
53848 }
53849 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
53850
53851 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
53852 index 99e3610..02c1068 100644
53853 --- a/fs/ntfs/dir.c
53854 +++ b/fs/ntfs/dir.c
53855 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
53856 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
53857 ~(s64)(ndir->itype.index.block_size - 1)));
53858 /* Bounds checks. */
53859 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53860 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53861 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
53862 "inode 0x%lx or driver bug.", vdir->i_ino);
53863 goto err_out;
53864 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
53865 index 5b2d4f0..c6de396 100644
53866 --- a/fs/ntfs/file.c
53867 +++ b/fs/ntfs/file.c
53868 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
53869 #endif /* NTFS_RW */
53870 };
53871
53872 -const struct file_operations ntfs_empty_file_ops = {};
53873 +const struct file_operations ntfs_empty_file_ops __read_only;
53874
53875 -const struct inode_operations ntfs_empty_inode_ops = {};
53876 +const struct inode_operations ntfs_empty_inode_ops __read_only;
53877 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
53878 index a9f78c7..ed8a381 100644
53879 --- a/fs/ocfs2/localalloc.c
53880 +++ b/fs/ocfs2/localalloc.c
53881 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
53882 goto bail;
53883 }
53884
53885 - atomic_inc(&osb->alloc_stats.moves);
53886 + atomic_inc_unchecked(&osb->alloc_stats.moves);
53887
53888 bail:
53889 if (handle)
53890 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
53891 index d355e6e..578d905 100644
53892 --- a/fs/ocfs2/ocfs2.h
53893 +++ b/fs/ocfs2/ocfs2.h
53894 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
53895
53896 struct ocfs2_alloc_stats
53897 {
53898 - atomic_t moves;
53899 - atomic_t local_data;
53900 - atomic_t bitmap_data;
53901 - atomic_t bg_allocs;
53902 - atomic_t bg_extends;
53903 + atomic_unchecked_t moves;
53904 + atomic_unchecked_t local_data;
53905 + atomic_unchecked_t bitmap_data;
53906 + atomic_unchecked_t bg_allocs;
53907 + atomic_unchecked_t bg_extends;
53908 };
53909
53910 enum ocfs2_local_alloc_state
53911 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
53912 index b7e74b5..19c6536 100644
53913 --- a/fs/ocfs2/suballoc.c
53914 +++ b/fs/ocfs2/suballoc.c
53915 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
53916 mlog_errno(status);
53917 goto bail;
53918 }
53919 - atomic_inc(&osb->alloc_stats.bg_extends);
53920 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
53921
53922 /* You should never ask for this much metadata */
53923 BUG_ON(bits_wanted >
53924 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
53925 mlog_errno(status);
53926 goto bail;
53927 }
53928 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53929 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53930
53931 *suballoc_loc = res.sr_bg_blkno;
53932 *suballoc_bit_start = res.sr_bit_offset;
53933 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
53934 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
53935 res->sr_bits);
53936
53937 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53938 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53939
53940 BUG_ON(res->sr_bits != 1);
53941
53942 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
53943 mlog_errno(status);
53944 goto bail;
53945 }
53946 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53947 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53948
53949 BUG_ON(res.sr_bits != 1);
53950
53951 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
53952 cluster_start,
53953 num_clusters);
53954 if (!status)
53955 - atomic_inc(&osb->alloc_stats.local_data);
53956 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
53957 } else {
53958 if (min_clusters > (osb->bitmap_cpg - 1)) {
53959 /* The only paths asking for contiguousness
53960 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
53961 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
53962 res.sr_bg_blkno,
53963 res.sr_bit_offset);
53964 - atomic_inc(&osb->alloc_stats.bitmap_data);
53965 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
53966 *num_clusters = res.sr_bits;
53967 }
53968 }
53969 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
53970 index 0e91ec2..f4b3fc6 100644
53971 --- a/fs/ocfs2/super.c
53972 +++ b/fs/ocfs2/super.c
53973 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
53974 "%10s => GlobalAllocs: %d LocalAllocs: %d "
53975 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
53976 "Stats",
53977 - atomic_read(&osb->alloc_stats.bitmap_data),
53978 - atomic_read(&osb->alloc_stats.local_data),
53979 - atomic_read(&osb->alloc_stats.bg_allocs),
53980 - atomic_read(&osb->alloc_stats.moves),
53981 - atomic_read(&osb->alloc_stats.bg_extends));
53982 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
53983 + atomic_read_unchecked(&osb->alloc_stats.local_data),
53984 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
53985 + atomic_read_unchecked(&osb->alloc_stats.moves),
53986 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
53987
53988 out += snprintf(buf + out, len - out,
53989 "%10s => State: %u Descriptor: %llu Size: %u bits "
53990 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
53991 spin_lock_init(&osb->osb_xattr_lock);
53992 ocfs2_init_steal_slots(osb);
53993
53994 - atomic_set(&osb->alloc_stats.moves, 0);
53995 - atomic_set(&osb->alloc_stats.local_data, 0);
53996 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
53997 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
53998 - atomic_set(&osb->alloc_stats.bg_extends, 0);
53999 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54000 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54001 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54002 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54003 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54004
54005 /* Copy the blockcheck stats from the superblock probe */
54006 osb->osb_ecc_stats = *stats;
54007 diff --git a/fs/open.c b/fs/open.c
54008 index 9b33c0c..2ffcca2 100644
54009 --- a/fs/open.c
54010 +++ b/fs/open.c
54011 @@ -31,6 +31,8 @@
54012 #include <linux/ima.h>
54013 #include <linux/dnotify.h>
54014
54015 +#define CREATE_TRACE_POINTS
54016 +#include <trace/events/fs.h>
54017 #include "internal.h"
54018
54019 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54020 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
54021 error = locks_verify_truncate(inode, NULL, length);
54022 if (!error)
54023 error = security_path_truncate(path);
54024 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54025 + error = -EACCES;
54026 if (!error)
54027 error = do_truncate(path->dentry, length, 0, NULL);
54028
54029 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54030 error = locks_verify_truncate(inode, f.file, length);
54031 if (!error)
54032 error = security_path_truncate(&f.file->f_path);
54033 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54034 + error = -EACCES;
54035 if (!error)
54036 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54037 sb_end_write(inode->i_sb);
54038 @@ -373,6 +379,9 @@ retry:
54039 if (__mnt_is_readonly(path.mnt))
54040 res = -EROFS;
54041
54042 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54043 + res = -EACCES;
54044 +
54045 out_path_release:
54046 path_put(&path);
54047 if (retry_estale(res, lookup_flags)) {
54048 @@ -404,6 +413,8 @@ retry:
54049 if (error)
54050 goto dput_and_out;
54051
54052 + gr_log_chdir(path.dentry, path.mnt);
54053 +
54054 set_fs_pwd(current->fs, &path);
54055
54056 dput_and_out:
54057 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54058 goto out_putf;
54059
54060 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54061 +
54062 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54063 + error = -EPERM;
54064 +
54065 + if (!error)
54066 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54067 +
54068 if (!error)
54069 set_fs_pwd(current->fs, &f.file->f_path);
54070 out_putf:
54071 @@ -462,7 +480,13 @@ retry:
54072 if (error)
54073 goto dput_and_out;
54074
54075 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54076 + goto dput_and_out;
54077 +
54078 set_fs_root(current->fs, &path);
54079 +
54080 + gr_handle_chroot_chdir(&path);
54081 +
54082 error = 0;
54083 dput_and_out:
54084 path_put(&path);
54085 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
54086 if (error)
54087 return error;
54088 mutex_lock(&inode->i_mutex);
54089 +
54090 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54091 + error = -EACCES;
54092 + goto out_unlock;
54093 + }
54094 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54095 + error = -EACCES;
54096 + goto out_unlock;
54097 + }
54098 +
54099 error = security_path_chmod(path, mode);
54100 if (error)
54101 goto out_unlock;
54102 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54103 uid = make_kuid(current_user_ns(), user);
54104 gid = make_kgid(current_user_ns(), group);
54105
54106 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54107 + return -EACCES;
54108 +
54109 newattrs.ia_valid = ATTR_CTIME;
54110 if (user != (uid_t) -1) {
54111 if (!uid_valid(uid))
54112 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54113 } else {
54114 fsnotify_open(f);
54115 fd_install(fd, f);
54116 + trace_do_sys_open(tmp->name, flags, mode);
54117 }
54118 }
54119 putname(tmp);
54120 diff --git a/fs/pipe.c b/fs/pipe.c
54121 index 8e2e73f..1ef1048 100644
54122 --- a/fs/pipe.c
54123 +++ b/fs/pipe.c
54124 @@ -438,9 +438,9 @@ redo:
54125 }
54126 if (bufs) /* More to do? */
54127 continue;
54128 - if (!pipe->writers)
54129 + if (!atomic_read(&pipe->writers))
54130 break;
54131 - if (!pipe->waiting_writers) {
54132 + if (!atomic_read(&pipe->waiting_writers)) {
54133 /* syscall merging: Usually we must not sleep
54134 * if O_NONBLOCK is set, or if we got some data.
54135 * But if a writer sleeps in kernel space, then
54136 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54137 mutex_lock(&inode->i_mutex);
54138 pipe = inode->i_pipe;
54139
54140 - if (!pipe->readers) {
54141 + if (!atomic_read(&pipe->readers)) {
54142 send_sig(SIGPIPE, current, 0);
54143 ret = -EPIPE;
54144 goto out;
54145 @@ -553,7 +553,7 @@ redo1:
54146 for (;;) {
54147 int bufs;
54148
54149 - if (!pipe->readers) {
54150 + if (!atomic_read(&pipe->readers)) {
54151 send_sig(SIGPIPE, current, 0);
54152 if (!ret)
54153 ret = -EPIPE;
54154 @@ -644,9 +644,9 @@ redo2:
54155 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54156 do_wakeup = 0;
54157 }
54158 - pipe->waiting_writers++;
54159 + atomic_inc(&pipe->waiting_writers);
54160 pipe_wait(pipe);
54161 - pipe->waiting_writers--;
54162 + atomic_dec(&pipe->waiting_writers);
54163 }
54164 out:
54165 mutex_unlock(&inode->i_mutex);
54166 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54167 mask = 0;
54168 if (filp->f_mode & FMODE_READ) {
54169 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54170 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54171 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54172 mask |= POLLHUP;
54173 }
54174
54175 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54176 * Most Unices do not set POLLERR for FIFOs but on Linux they
54177 * behave exactly like pipes for poll().
54178 */
54179 - if (!pipe->readers)
54180 + if (!atomic_read(&pipe->readers))
54181 mask |= POLLERR;
54182 }
54183
54184 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54185
54186 mutex_lock(&inode->i_mutex);
54187 pipe = inode->i_pipe;
54188 - pipe->readers -= decr;
54189 - pipe->writers -= decw;
54190 + atomic_sub(decr, &pipe->readers);
54191 + atomic_sub(decw, &pipe->writers);
54192
54193 - if (!pipe->readers && !pipe->writers) {
54194 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54195 free_pipe_info(inode);
54196 } else {
54197 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54198 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54199
54200 if (inode->i_pipe) {
54201 ret = 0;
54202 - inode->i_pipe->readers++;
54203 + atomic_inc(&inode->i_pipe->readers);
54204 }
54205
54206 mutex_unlock(&inode->i_mutex);
54207 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54208
54209 if (inode->i_pipe) {
54210 ret = 0;
54211 - inode->i_pipe->writers++;
54212 + atomic_inc(&inode->i_pipe->writers);
54213 }
54214
54215 mutex_unlock(&inode->i_mutex);
54216 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54217 if (inode->i_pipe) {
54218 ret = 0;
54219 if (filp->f_mode & FMODE_READ)
54220 - inode->i_pipe->readers++;
54221 + atomic_inc(&inode->i_pipe->readers);
54222 if (filp->f_mode & FMODE_WRITE)
54223 - inode->i_pipe->writers++;
54224 + atomic_inc(&inode->i_pipe->writers);
54225 }
54226
54227 mutex_unlock(&inode->i_mutex);
54228 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54229 inode->i_pipe = NULL;
54230 }
54231
54232 -static struct vfsmount *pipe_mnt __read_mostly;
54233 +struct vfsmount *pipe_mnt __read_mostly;
54234
54235 /*
54236 * pipefs_dname() is called from d_path().
54237 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54238 goto fail_iput;
54239 inode->i_pipe = pipe;
54240
54241 - pipe->readers = pipe->writers = 1;
54242 + atomic_set(&pipe->readers, 1);
54243 + atomic_set(&pipe->writers, 1);
54244 inode->i_fop = &rdwr_pipefifo_fops;
54245
54246 /*
54247 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54248 index 15af622..0e9f4467 100644
54249 --- a/fs/proc/Kconfig
54250 +++ b/fs/proc/Kconfig
54251 @@ -30,12 +30,12 @@ config PROC_FS
54252
54253 config PROC_KCORE
54254 bool "/proc/kcore support" if !ARM
54255 - depends on PROC_FS && MMU
54256 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54257
54258 config PROC_VMCORE
54259 bool "/proc/vmcore support"
54260 - depends on PROC_FS && CRASH_DUMP
54261 - default y
54262 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54263 + default n
54264 help
54265 Exports the dump image of crashed kernel in ELF format.
54266
54267 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54268 limited in memory.
54269
54270 config PROC_PAGE_MONITOR
54271 - default y
54272 - depends on PROC_FS && MMU
54273 + default n
54274 + depends on PROC_FS && MMU && !GRKERNSEC
54275 bool "Enable /proc page monitoring" if EXPERT
54276 help
54277 Various /proc files exist to monitor process memory utilization:
54278 diff --git a/fs/proc/array.c b/fs/proc/array.c
54279 index 6a91e6f..e54dbc14 100644
54280 --- a/fs/proc/array.c
54281 +++ b/fs/proc/array.c
54282 @@ -60,6 +60,7 @@
54283 #include <linux/tty.h>
54284 #include <linux/string.h>
54285 #include <linux/mman.h>
54286 +#include <linux/grsecurity.h>
54287 #include <linux/proc_fs.h>
54288 #include <linux/ioport.h>
54289 #include <linux/uaccess.h>
54290 @@ -362,6 +363,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54291 seq_putc(m, '\n');
54292 }
54293
54294 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54295 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54296 +{
54297 + if (p->mm)
54298 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54299 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54300 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54301 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54302 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54303 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54304 + else
54305 + seq_printf(m, "PaX:\t-----\n");
54306 +}
54307 +#endif
54308 +
54309 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54310 struct pid *pid, struct task_struct *task)
54311 {
54312 @@ -380,9 +396,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54313 task_cpus_allowed(m, task);
54314 cpuset_task_status_allowed(m, task);
54315 task_context_switch_counts(m, task);
54316 +
54317 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54318 + task_pax(m, task);
54319 +#endif
54320 +
54321 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54322 + task_grsec_rbac(m, task);
54323 +#endif
54324 +
54325 return 0;
54326 }
54327
54328 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54329 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54330 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54331 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54332 +#endif
54333 +
54334 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54335 struct pid *pid, struct task_struct *task, int whole)
54336 {
54337 @@ -404,6 +435,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54338 char tcomm[sizeof(task->comm)];
54339 unsigned long flags;
54340
54341 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54342 + if (current->exec_id != m->exec_id) {
54343 + gr_log_badprocpid("stat");
54344 + return 0;
54345 + }
54346 +#endif
54347 +
54348 state = *get_task_state(task);
54349 vsize = eip = esp = 0;
54350 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54351 @@ -475,6 +513,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54352 gtime = task->gtime;
54353 }
54354
54355 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54356 + if (PAX_RAND_FLAGS(mm)) {
54357 + eip = 0;
54358 + esp = 0;
54359 + wchan = 0;
54360 + }
54361 +#endif
54362 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54363 + wchan = 0;
54364 + eip =0;
54365 + esp =0;
54366 +#endif
54367 +
54368 /* scale priority and nice values from timeslices to -20..20 */
54369 /* to make it look like a "normal" Unix priority/nice value */
54370 priority = task_prio(task);
54371 @@ -511,9 +562,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54372 seq_put_decimal_ull(m, ' ', vsize);
54373 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54374 seq_put_decimal_ull(m, ' ', rsslim);
54375 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54376 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54377 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54378 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54379 +#else
54380 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54381 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54382 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54383 +#endif
54384 seq_put_decimal_ull(m, ' ', esp);
54385 seq_put_decimal_ull(m, ' ', eip);
54386 /* The signal information here is obsolete.
54387 @@ -535,7 +592,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54388 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54389 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54390
54391 - if (mm && permitted) {
54392 + if (mm && permitted
54393 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54394 + && !PAX_RAND_FLAGS(mm)
54395 +#endif
54396 + ) {
54397 seq_put_decimal_ull(m, ' ', mm->start_data);
54398 seq_put_decimal_ull(m, ' ', mm->end_data);
54399 seq_put_decimal_ull(m, ' ', mm->start_brk);
54400 @@ -573,8 +634,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54401 struct pid *pid, struct task_struct *task)
54402 {
54403 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
54404 - struct mm_struct *mm = get_task_mm(task);
54405 + struct mm_struct *mm;
54406
54407 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54408 + if (current->exec_id != m->exec_id) {
54409 + gr_log_badprocpid("statm");
54410 + return 0;
54411 + }
54412 +#endif
54413 + mm = get_task_mm(task);
54414 if (mm) {
54415 size = task_statm(mm, &shared, &text, &data, &resident);
54416 mmput(mm);
54417 @@ -597,6 +665,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54418 return 0;
54419 }
54420
54421 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54422 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
54423 +{
54424 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
54425 +}
54426 +#endif
54427 +
54428 #ifdef CONFIG_CHECKPOINT_RESTORE
54429 static struct pid *
54430 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
54431 diff --git a/fs/proc/base.c b/fs/proc/base.c
54432 index 9b43ff77..ba3e990 100644
54433 --- a/fs/proc/base.c
54434 +++ b/fs/proc/base.c
54435 @@ -111,6 +111,14 @@ struct pid_entry {
54436 union proc_op op;
54437 };
54438
54439 +struct getdents_callback {
54440 + struct linux_dirent __user * current_dir;
54441 + struct linux_dirent __user * previous;
54442 + struct file * file;
54443 + int count;
54444 + int error;
54445 +};
54446 +
54447 #define NOD(NAME, MODE, IOP, FOP, OP) { \
54448 .name = (NAME), \
54449 .len = sizeof(NAME) - 1, \
54450 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
54451 if (!mm->arg_end)
54452 goto out_mm; /* Shh! No looking before we're done */
54453
54454 + if (gr_acl_handle_procpidmem(task))
54455 + goto out_mm;
54456 +
54457 len = mm->arg_end - mm->arg_start;
54458
54459 if (len > PAGE_SIZE)
54460 @@ -235,12 +246,28 @@ out:
54461 return res;
54462 }
54463
54464 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54465 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54466 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54467 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54468 +#endif
54469 +
54470 static int proc_pid_auxv(struct task_struct *task, char *buffer)
54471 {
54472 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
54473 int res = PTR_ERR(mm);
54474 if (mm && !IS_ERR(mm)) {
54475 unsigned int nwords = 0;
54476 +
54477 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54478 + /* allow if we're currently ptracing this task */
54479 + if (PAX_RAND_FLAGS(mm) &&
54480 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
54481 + mmput(mm);
54482 + return 0;
54483 + }
54484 +#endif
54485 +
54486 do {
54487 nwords += 2;
54488 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
54489 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
54490 }
54491
54492
54493 -#ifdef CONFIG_KALLSYMS
54494 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54495 /*
54496 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
54497 * Returns the resolved symbol. If that fails, simply return the address.
54498 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
54499 mutex_unlock(&task->signal->cred_guard_mutex);
54500 }
54501
54502 -#ifdef CONFIG_STACKTRACE
54503 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54504
54505 #define MAX_STACK_TRACE_DEPTH 64
54506
54507 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
54508 return count;
54509 }
54510
54511 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54512 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54513 static int proc_pid_syscall(struct task_struct *task, char *buffer)
54514 {
54515 long nr;
54516 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
54517 /************************************************************************/
54518
54519 /* permission checks */
54520 -static int proc_fd_access_allowed(struct inode *inode)
54521 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
54522 {
54523 struct task_struct *task;
54524 int allowed = 0;
54525 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
54526 */
54527 task = get_proc_task(inode);
54528 if (task) {
54529 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54530 + if (log)
54531 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54532 + else
54533 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54534 put_task_struct(task);
54535 }
54536 return allowed;
54537 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
54538 struct task_struct *task,
54539 int hide_pid_min)
54540 {
54541 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54542 + return false;
54543 +
54544 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54545 + rcu_read_lock();
54546 + {
54547 + const struct cred *tmpcred = current_cred();
54548 + const struct cred *cred = __task_cred(task);
54549 +
54550 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
54551 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54552 + || in_group_p(grsec_proc_gid)
54553 +#endif
54554 + ) {
54555 + rcu_read_unlock();
54556 + return true;
54557 + }
54558 + }
54559 + rcu_read_unlock();
54560 +
54561 + if (!pid->hide_pid)
54562 + return false;
54563 +#endif
54564 +
54565 if (pid->hide_pid < hide_pid_min)
54566 return true;
54567 if (in_group_p(pid->pid_gid))
54568 return true;
54569 +
54570 return ptrace_may_access(task, PTRACE_MODE_READ);
54571 }
54572
54573 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
54574 put_task_struct(task);
54575
54576 if (!has_perms) {
54577 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54578 + {
54579 +#else
54580 if (pid->hide_pid == 2) {
54581 +#endif
54582 /*
54583 * Let's make getdents(), stat(), and open()
54584 * consistent with each other. If a process
54585 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54586 if (!task)
54587 return -ESRCH;
54588
54589 + if (gr_acl_handle_procpidmem(task)) {
54590 + put_task_struct(task);
54591 + return -EPERM;
54592 + }
54593 +
54594 mm = mm_access(task, mode);
54595 put_task_struct(task);
54596
54597 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54598
54599 file->private_data = mm;
54600
54601 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54602 + file->f_version = current->exec_id;
54603 +#endif
54604 +
54605 return 0;
54606 }
54607
54608 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54609 ssize_t copied;
54610 char *page;
54611
54612 +#ifdef CONFIG_GRKERNSEC
54613 + if (write)
54614 + return -EPERM;
54615 +#endif
54616 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54617 + if (file->f_version != current->exec_id) {
54618 + gr_log_badprocpid("mem");
54619 + return 0;
54620 + }
54621 +#endif
54622 +
54623 if (!mm)
54624 return 0;
54625
54626 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54627 if (!mm)
54628 return 0;
54629
54630 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54631 + if (file->f_version != current->exec_id) {
54632 + gr_log_badprocpid("environ");
54633 + return 0;
54634 + }
54635 +#endif
54636 +
54637 page = (char *)__get_free_page(GFP_TEMPORARY);
54638 if (!page)
54639 return -ENOMEM;
54640 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
54641 int error = -EACCES;
54642
54643 /* Are we allowed to snoop on the tasks file descriptors? */
54644 - if (!proc_fd_access_allowed(inode))
54645 + if (!proc_fd_access_allowed(inode, 0))
54646 goto out;
54647
54648 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54649 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
54650 struct path path;
54651
54652 /* Are we allowed to snoop on the tasks file descriptors? */
54653 - if (!proc_fd_access_allowed(inode))
54654 - goto out;
54655 + /* logging this is needed for learning on chromium to work properly,
54656 + but we don't want to flood the logs from 'ps' which does a readlink
54657 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
54658 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
54659 + */
54660 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
54661 + if (!proc_fd_access_allowed(inode,0))
54662 + goto out;
54663 + } else {
54664 + if (!proc_fd_access_allowed(inode,1))
54665 + goto out;
54666 + }
54667
54668 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54669 if (error)
54670 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
54671 rcu_read_lock();
54672 cred = __task_cred(task);
54673 inode->i_uid = cred->euid;
54674 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54675 + inode->i_gid = grsec_proc_gid;
54676 +#else
54677 inode->i_gid = cred->egid;
54678 +#endif
54679 rcu_read_unlock();
54680 }
54681 security_task_to_inode(task, inode);
54682 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
54683 return -ENOENT;
54684 }
54685 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54686 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54687 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54688 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54689 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54690 +#endif
54691 task_dumpable(task)) {
54692 cred = __task_cred(task);
54693 stat->uid = cred->euid;
54694 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54695 + stat->gid = grsec_proc_gid;
54696 +#else
54697 stat->gid = cred->egid;
54698 +#endif
54699 }
54700 }
54701 rcu_read_unlock();
54702 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
54703
54704 if (task) {
54705 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54706 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54707 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54708 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54709 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54710 +#endif
54711 task_dumpable(task)) {
54712 rcu_read_lock();
54713 cred = __task_cred(task);
54714 inode->i_uid = cred->euid;
54715 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54716 + inode->i_gid = grsec_proc_gid;
54717 +#else
54718 inode->i_gid = cred->egid;
54719 +#endif
54720 rcu_read_unlock();
54721 } else {
54722 inode->i_uid = GLOBAL_ROOT_UID;
54723 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
54724 if (!task)
54725 goto out_no_task;
54726
54727 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54728 + goto out;
54729 +
54730 /*
54731 * Yes, it does not scale. And it should not. Don't add
54732 * new entries into /proc/<tgid>/ without very good reasons.
54733 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
54734 if (!task)
54735 goto out_no_task;
54736
54737 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54738 + goto out;
54739 +
54740 ret = 0;
54741 i = filp->f_pos;
54742 switch (i) {
54743 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
54744 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
54745 #endif
54746 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54747 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54748 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54749 INF("syscall", S_IRUGO, proc_pid_syscall),
54750 #endif
54751 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54752 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
54753 #ifdef CONFIG_SECURITY
54754 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54755 #endif
54756 -#ifdef CONFIG_KALLSYMS
54757 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54758 INF("wchan", S_IRUGO, proc_pid_wchan),
54759 #endif
54760 -#ifdef CONFIG_STACKTRACE
54761 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54762 ONE("stack", S_IRUGO, proc_pid_stack),
54763 #endif
54764 #ifdef CONFIG_SCHEDSTATS
54765 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
54766 #ifdef CONFIG_HARDWALL
54767 INF("hardwall", S_IRUGO, proc_pid_hardwall),
54768 #endif
54769 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54770 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
54771 +#endif
54772 #ifdef CONFIG_USER_NS
54773 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
54774 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
54775 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
54776 if (!inode)
54777 goto out;
54778
54779 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54780 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
54781 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54782 + inode->i_gid = grsec_proc_gid;
54783 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
54784 +#else
54785 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
54786 +#endif
54787 inode->i_op = &proc_tgid_base_inode_operations;
54788 inode->i_fop = &proc_tgid_base_operations;
54789 inode->i_flags|=S_IMMUTABLE;
54790 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
54791 if (!task)
54792 goto out;
54793
54794 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54795 + goto out_put_task;
54796 +
54797 result = proc_pid_instantiate(dir, dentry, task, NULL);
54798 +out_put_task:
54799 put_task_struct(task);
54800 out:
54801 return result;
54802 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
54803 static int fake_filldir(void *buf, const char *name, int namelen,
54804 loff_t offset, u64 ino, unsigned d_type)
54805 {
54806 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
54807 + __buf->error = -EINVAL;
54808 return 0;
54809 }
54810
54811 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
54812 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
54813 #endif
54814 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54815 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54816 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54817 INF("syscall", S_IRUGO, proc_pid_syscall),
54818 #endif
54819 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54820 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
54821 #ifdef CONFIG_SECURITY
54822 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54823 #endif
54824 -#ifdef CONFIG_KALLSYMS
54825 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54826 INF("wchan", S_IRUGO, proc_pid_wchan),
54827 #endif
54828 -#ifdef CONFIG_STACKTRACE
54829 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54830 ONE("stack", S_IRUGO, proc_pid_stack),
54831 #endif
54832 #ifdef CONFIG_SCHEDSTATS
54833 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
54834 index 82676e3..5f8518a 100644
54835 --- a/fs/proc/cmdline.c
54836 +++ b/fs/proc/cmdline.c
54837 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
54838
54839 static int __init proc_cmdline_init(void)
54840 {
54841 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54842 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
54843 +#else
54844 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
54845 +#endif
54846 return 0;
54847 }
54848 module_init(proc_cmdline_init);
54849 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
54850 index b143471..bb105e5 100644
54851 --- a/fs/proc/devices.c
54852 +++ b/fs/proc/devices.c
54853 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
54854
54855 static int __init proc_devices_init(void)
54856 {
54857 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54858 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
54859 +#else
54860 proc_create("devices", 0, NULL, &proc_devinfo_operations);
54861 +#endif
54862 return 0;
54863 }
54864 module_init(proc_devices_init);
54865 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
54866 index d7a4a28..0201742 100644
54867 --- a/fs/proc/fd.c
54868 +++ b/fs/proc/fd.c
54869 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
54870 if (!task)
54871 return -ENOENT;
54872
54873 - files = get_files_struct(task);
54874 + if (!gr_acl_handle_procpidmem(task))
54875 + files = get_files_struct(task);
54876 put_task_struct(task);
54877
54878 if (files) {
54879 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
54880 */
54881 int proc_fd_permission(struct inode *inode, int mask)
54882 {
54883 + struct task_struct *task;
54884 int rv = generic_permission(inode, mask);
54885 - if (rv == 0)
54886 - return 0;
54887 +
54888 if (task_pid(current) == proc_pid(inode))
54889 rv = 0;
54890 +
54891 + task = get_proc_task(inode);
54892 + if (task == NULL)
54893 + return rv;
54894 +
54895 + if (gr_acl_handle_procpidmem(task))
54896 + rv = -EACCES;
54897 +
54898 + put_task_struct(task);
54899 +
54900 return rv;
54901 }
54902
54903 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
54904 index 0ac1e1b..0497e58 100644
54905 --- a/fs/proc/inode.c
54906 +++ b/fs/proc/inode.c
54907 @@ -21,11 +21,17 @@
54908 #include <linux/seq_file.h>
54909 #include <linux/slab.h>
54910 #include <linux/mount.h>
54911 +#include <linux/grsecurity.h>
54912
54913 #include <asm/uaccess.h>
54914
54915 #include "internal.h"
54916
54917 +#ifdef CONFIG_PROC_SYSCTL
54918 +extern const struct inode_operations proc_sys_inode_operations;
54919 +extern const struct inode_operations proc_sys_dir_operations;
54920 +#endif
54921 +
54922 static void proc_evict_inode(struct inode *inode)
54923 {
54924 struct proc_dir_entry *de;
54925 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
54926 ns = PROC_I(inode)->ns;
54927 if (ns_ops && ns)
54928 ns_ops->put(ns);
54929 +
54930 +#ifdef CONFIG_PROC_SYSCTL
54931 + if (inode->i_op == &proc_sys_inode_operations ||
54932 + inode->i_op == &proc_sys_dir_operations)
54933 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
54934 +#endif
54935 +
54936 }
54937
54938 static struct kmem_cache * proc_inode_cachep;
54939 @@ -455,7 +468,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
54940 if (de->mode) {
54941 inode->i_mode = de->mode;
54942 inode->i_uid = de->uid;
54943 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54944 + inode->i_gid = grsec_proc_gid;
54945 +#else
54946 inode->i_gid = de->gid;
54947 +#endif
54948 }
54949 if (de->size)
54950 inode->i_size = de->size;
54951 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
54952 index 252544c..04395b9 100644
54953 --- a/fs/proc/internal.h
54954 +++ b/fs/proc/internal.h
54955 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54956 struct pid *pid, struct task_struct *task);
54957 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54958 struct pid *pid, struct task_struct *task);
54959 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54960 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
54961 +#endif
54962 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
54963
54964 extern const struct file_operations proc_tid_children_operations;
54965 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
54966 index e96d4f1..8b116ed 100644
54967 --- a/fs/proc/kcore.c
54968 +++ b/fs/proc/kcore.c
54969 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54970 * the addresses in the elf_phdr on our list.
54971 */
54972 start = kc_offset_to_vaddr(*fpos - elf_buflen);
54973 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
54974 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
54975 + if (tsz > buflen)
54976 tsz = buflen;
54977 -
54978 +
54979 while (buflen) {
54980 struct kcore_list *m;
54981
54982 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54983 kfree(elf_buf);
54984 } else {
54985 if (kern_addr_valid(start)) {
54986 - unsigned long n;
54987 + char *elf_buf;
54988 + mm_segment_t oldfs;
54989
54990 - n = copy_to_user(buffer, (char *)start, tsz);
54991 - /*
54992 - * We cannot distinguish between fault on source
54993 - * and fault on destination. When this happens
54994 - * we clear too and hope it will trigger the
54995 - * EFAULT again.
54996 - */
54997 - if (n) {
54998 - if (clear_user(buffer + tsz - n,
54999 - n))
55000 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55001 + if (!elf_buf)
55002 + return -ENOMEM;
55003 + oldfs = get_fs();
55004 + set_fs(KERNEL_DS);
55005 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55006 + set_fs(oldfs);
55007 + if (copy_to_user(buffer, elf_buf, tsz)) {
55008 + kfree(elf_buf);
55009 return -EFAULT;
55010 + }
55011 }
55012 + set_fs(oldfs);
55013 + kfree(elf_buf);
55014 } else {
55015 if (clear_user(buffer, tsz))
55016 return -EFAULT;
55017 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55018
55019 static int open_kcore(struct inode *inode, struct file *filp)
55020 {
55021 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55022 + return -EPERM;
55023 +#endif
55024 if (!capable(CAP_SYS_RAWIO))
55025 return -EPERM;
55026 if (kcore_need_update)
55027 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55028 index 80e4645..53e5fcf 100644
55029 --- a/fs/proc/meminfo.c
55030 +++ b/fs/proc/meminfo.c
55031 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55032 vmi.used >> 10,
55033 vmi.largest_chunk >> 10
55034 #ifdef CONFIG_MEMORY_FAILURE
55035 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
55036 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
55037 #endif
55038 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55039 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55040 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55041 index b1822dd..df622cb 100644
55042 --- a/fs/proc/nommu.c
55043 +++ b/fs/proc/nommu.c
55044 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55045 if (len < 1)
55046 len = 1;
55047 seq_printf(m, "%*c", len, ' ');
55048 - seq_path(m, &file->f_path, "");
55049 + seq_path(m, &file->f_path, "\n\\");
55050 }
55051
55052 seq_putc(m, '\n');
55053 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55054 index fe72cd0..21b52ff 100644
55055 --- a/fs/proc/proc_net.c
55056 +++ b/fs/proc/proc_net.c
55057 @@ -23,6 +23,7 @@
55058 #include <linux/nsproxy.h>
55059 #include <net/net_namespace.h>
55060 #include <linux/seq_file.h>
55061 +#include <linux/grsecurity.h>
55062
55063 #include "internal.h"
55064
55065 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55066 struct task_struct *task;
55067 struct nsproxy *ns;
55068 struct net *net = NULL;
55069 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55070 + const struct cred *cred = current_cred();
55071 +#endif
55072 +
55073 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55074 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55075 + return net;
55076 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55077 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55078 + return net;
55079 +#endif
55080
55081 rcu_read_lock();
55082 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55083 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55084 index 1827d88..43b0279 100644
55085 --- a/fs/proc/proc_sysctl.c
55086 +++ b/fs/proc/proc_sysctl.c
55087 @@ -12,11 +12,15 @@
55088 #include <linux/module.h>
55089 #include "internal.h"
55090
55091 +extern int gr_handle_chroot_sysctl(const int op);
55092 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55093 + const int op);
55094 +
55095 static const struct dentry_operations proc_sys_dentry_operations;
55096 static const struct file_operations proc_sys_file_operations;
55097 -static const struct inode_operations proc_sys_inode_operations;
55098 +const struct inode_operations proc_sys_inode_operations;
55099 static const struct file_operations proc_sys_dir_file_operations;
55100 -static const struct inode_operations proc_sys_dir_operations;
55101 +const struct inode_operations proc_sys_dir_operations;
55102
55103 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55104 {
55105 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55106
55107 err = NULL;
55108 d_set_d_op(dentry, &proc_sys_dentry_operations);
55109 +
55110 + gr_handle_proc_create(dentry, inode);
55111 +
55112 d_add(dentry, inode);
55113
55114 out:
55115 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55116 struct inode *inode = filp->f_path.dentry->d_inode;
55117 struct ctl_table_header *head = grab_header(inode);
55118 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55119 + int op = write ? MAY_WRITE : MAY_READ;
55120 ssize_t error;
55121 size_t res;
55122
55123 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55124 * and won't be until we finish.
55125 */
55126 error = -EPERM;
55127 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55128 + if (sysctl_perm(head, table, op))
55129 goto out;
55130
55131 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55132 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55133 if (!table->proc_handler)
55134 goto out;
55135
55136 +#ifdef CONFIG_GRKERNSEC
55137 + error = -EPERM;
55138 + if (gr_handle_chroot_sysctl(op))
55139 + goto out;
55140 + dget(filp->f_path.dentry);
55141 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55142 + dput(filp->f_path.dentry);
55143 + goto out;
55144 + }
55145 + dput(filp->f_path.dentry);
55146 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55147 + goto out;
55148 + if (write && !capable(CAP_SYS_ADMIN))
55149 + goto out;
55150 +#endif
55151 +
55152 /* careful: calling conventions are nasty here */
55153 res = count;
55154 error = table->proc_handler(table, write, buf, &res, ppos);
55155 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55156 return -ENOMEM;
55157 } else {
55158 d_set_d_op(child, &proc_sys_dentry_operations);
55159 +
55160 + gr_handle_proc_create(child, inode);
55161 +
55162 d_add(child, inode);
55163 }
55164 } else {
55165 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55166 if ((*pos)++ < file->f_pos)
55167 return 0;
55168
55169 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55170 + return 0;
55171 +
55172 if (unlikely(S_ISLNK(table->mode)))
55173 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55174 else
55175 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55176 if (IS_ERR(head))
55177 return PTR_ERR(head);
55178
55179 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55180 + return -ENOENT;
55181 +
55182 generic_fillattr(inode, stat);
55183 if (table)
55184 stat->mode = (stat->mode & S_IFMT) | table->mode;
55185 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55186 .llseek = generic_file_llseek,
55187 };
55188
55189 -static const struct inode_operations proc_sys_inode_operations = {
55190 +const struct inode_operations proc_sys_inode_operations = {
55191 .permission = proc_sys_permission,
55192 .setattr = proc_sys_setattr,
55193 .getattr = proc_sys_getattr,
55194 };
55195
55196 -static const struct inode_operations proc_sys_dir_operations = {
55197 +const struct inode_operations proc_sys_dir_operations = {
55198 .lookup = proc_sys_lookup,
55199 .permission = proc_sys_permission,
55200 .setattr = proc_sys_setattr,
55201 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55202 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55203 const char *name, int namelen)
55204 {
55205 - struct ctl_table *table;
55206 + ctl_table_no_const *table;
55207 struct ctl_dir *new;
55208 struct ctl_node *node;
55209 char *new_name;
55210 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55211 return NULL;
55212
55213 node = (struct ctl_node *)(new + 1);
55214 - table = (struct ctl_table *)(node + 1);
55215 + table = (ctl_table_no_const *)(node + 1);
55216 new_name = (char *)(table + 2);
55217 memcpy(new_name, name, namelen);
55218 new_name[namelen] = '\0';
55219 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55220 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55221 struct ctl_table_root *link_root)
55222 {
55223 - struct ctl_table *link_table, *entry, *link;
55224 + ctl_table_no_const *link_table, *link;
55225 + struct ctl_table *entry;
55226 struct ctl_table_header *links;
55227 struct ctl_node *node;
55228 char *link_name;
55229 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55230 return NULL;
55231
55232 node = (struct ctl_node *)(links + 1);
55233 - link_table = (struct ctl_table *)(node + nr_entries);
55234 + link_table = (ctl_table_no_const *)(node + nr_entries);
55235 link_name = (char *)&link_table[nr_entries + 1];
55236
55237 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55238 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55239 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55240 struct ctl_table *table)
55241 {
55242 - struct ctl_table *ctl_table_arg = NULL;
55243 - struct ctl_table *entry, *files;
55244 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55245 + struct ctl_table *entry;
55246 int nr_files = 0;
55247 int nr_dirs = 0;
55248 int err = -ENOMEM;
55249 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55250 nr_files++;
55251 }
55252
55253 - files = table;
55254 /* If there are mixed files and directories we need a new table */
55255 if (nr_dirs && nr_files) {
55256 - struct ctl_table *new;
55257 + ctl_table_no_const *new;
55258 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55259 GFP_KERNEL);
55260 if (!files)
55261 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55262 /* Register everything except a directory full of subdirectories */
55263 if (nr_files || !nr_dirs) {
55264 struct ctl_table_header *header;
55265 - header = __register_sysctl_table(set, path, files);
55266 + header = __register_sysctl_table(set, path, files ? files : table);
55267 if (!header) {
55268 kfree(ctl_table_arg);
55269 goto out;
55270 diff --git a/fs/proc/root.c b/fs/proc/root.c
55271 index c6e9fac..a740964 100644
55272 --- a/fs/proc/root.c
55273 +++ b/fs/proc/root.c
55274 @@ -176,7 +176,15 @@ void __init proc_root_init(void)
55275 #ifdef CONFIG_PROC_DEVICETREE
55276 proc_device_tree_init();
55277 #endif
55278 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55279 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55280 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55281 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55282 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55283 +#endif
55284 +#else
55285 proc_mkdir("bus", NULL);
55286 +#endif
55287 proc_sys_init();
55288 }
55289
55290 diff --git a/fs/proc/self.c b/fs/proc/self.c
55291 index aa5cc3b..c91a5d0 100644
55292 --- a/fs/proc/self.c
55293 +++ b/fs/proc/self.c
55294 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55295 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55296 void *cookie)
55297 {
55298 - char *s = nd_get_link(nd);
55299 + const char *s = nd_get_link(nd);
55300 if (!IS_ERR(s))
55301 kfree(s);
55302 }
55303 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55304 index ca5ce7f..02c1cf0 100644
55305 --- a/fs/proc/task_mmu.c
55306 +++ b/fs/proc/task_mmu.c
55307 @@ -11,12 +11,19 @@
55308 #include <linux/rmap.h>
55309 #include <linux/swap.h>
55310 #include <linux/swapops.h>
55311 +#include <linux/grsecurity.h>
55312
55313 #include <asm/elf.h>
55314 #include <asm/uaccess.h>
55315 #include <asm/tlbflush.h>
55316 #include "internal.h"
55317
55318 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55319 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55320 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55321 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55322 +#endif
55323 +
55324 void task_mem(struct seq_file *m, struct mm_struct *mm)
55325 {
55326 unsigned long data, text, lib, swap;
55327 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55328 "VmExe:\t%8lu kB\n"
55329 "VmLib:\t%8lu kB\n"
55330 "VmPTE:\t%8lu kB\n"
55331 - "VmSwap:\t%8lu kB\n",
55332 - hiwater_vm << (PAGE_SHIFT-10),
55333 + "VmSwap:\t%8lu kB\n"
55334 +
55335 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55336 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55337 +#endif
55338 +
55339 + ,hiwater_vm << (PAGE_SHIFT-10),
55340 total_vm << (PAGE_SHIFT-10),
55341 mm->locked_vm << (PAGE_SHIFT-10),
55342 mm->pinned_vm << (PAGE_SHIFT-10),
55343 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55344 data << (PAGE_SHIFT-10),
55345 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55346 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55347 - swap << (PAGE_SHIFT-10));
55348 + swap << (PAGE_SHIFT-10)
55349 +
55350 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55351 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55352 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55353 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55354 +#else
55355 + , mm->context.user_cs_base
55356 + , mm->context.user_cs_limit
55357 +#endif
55358 +#endif
55359 +
55360 + );
55361 }
55362
55363 unsigned long task_vsize(struct mm_struct *mm)
55364 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55365 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55366 }
55367
55368 - /* We don't show the stack guard page in /proc/maps */
55369 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55370 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55371 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55372 +#else
55373 start = vma->vm_start;
55374 - if (stack_guard_page_start(vma, start))
55375 - start += PAGE_SIZE;
55376 end = vma->vm_end;
55377 - if (stack_guard_page_end(vma, end))
55378 - end -= PAGE_SIZE;
55379 +#endif
55380
55381 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
55382 start,
55383 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55384 flags & VM_WRITE ? 'w' : '-',
55385 flags & VM_EXEC ? 'x' : '-',
55386 flags & VM_MAYSHARE ? 's' : 'p',
55387 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55388 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
55389 +#else
55390 pgoff,
55391 +#endif
55392 MAJOR(dev), MINOR(dev), ino, &len);
55393
55394 /*
55395 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55396 */
55397 if (file) {
55398 pad_len_spaces(m, len);
55399 - seq_path(m, &file->f_path, "\n");
55400 + seq_path(m, &file->f_path, "\n\\");
55401 goto done;
55402 }
55403
55404 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55405 * Thread stack in /proc/PID/task/TID/maps or
55406 * the main process stack.
55407 */
55408 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
55409 - vma->vm_end >= mm->start_stack)) {
55410 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
55411 + (vma->vm_start <= mm->start_stack &&
55412 + vma->vm_end >= mm->start_stack)) {
55413 name = "[stack]";
55414 } else {
55415 /* Thread stack in /proc/PID/maps */
55416 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
55417 struct proc_maps_private *priv = m->private;
55418 struct task_struct *task = priv->task;
55419
55420 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55421 + if (current->exec_id != m->exec_id) {
55422 + gr_log_badprocpid("maps");
55423 + return 0;
55424 + }
55425 +#endif
55426 +
55427 show_map_vma(m, vma, is_pid);
55428
55429 if (m->count < m->size) /* vma is copied successfully */
55430 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55431 .private = &mss,
55432 };
55433
55434 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55435 + if (current->exec_id != m->exec_id) {
55436 + gr_log_badprocpid("smaps");
55437 + return 0;
55438 + }
55439 +#endif
55440 memset(&mss, 0, sizeof mss);
55441 - mss.vma = vma;
55442 - /* mmap_sem is held in m_start */
55443 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55444 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55445 -
55446 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55447 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
55448 +#endif
55449 + mss.vma = vma;
55450 + /* mmap_sem is held in m_start */
55451 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55452 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55453 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55454 + }
55455 +#endif
55456 show_map_vma(m, vma, is_pid);
55457
55458 seq_printf(m,
55459 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55460 "KernelPageSize: %8lu kB\n"
55461 "MMUPageSize: %8lu kB\n"
55462 "Locked: %8lu kB\n",
55463 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55464 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
55465 +#else
55466 (vma->vm_end - vma->vm_start) >> 10,
55467 +#endif
55468 mss.resident >> 10,
55469 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
55470 mss.shared_clean >> 10,
55471 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55472 int n;
55473 char buffer[50];
55474
55475 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55476 + if (current->exec_id != m->exec_id) {
55477 + gr_log_badprocpid("numa_maps");
55478 + return 0;
55479 + }
55480 +#endif
55481 +
55482 if (!mm)
55483 return 0;
55484
55485 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55486 mpol_to_str(buffer, sizeof(buffer), pol);
55487 mpol_cond_put(pol);
55488
55489 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55490 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
55491 +#else
55492 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
55493 +#endif
55494
55495 if (file) {
55496 seq_printf(m, " file=");
55497 - seq_path(m, &file->f_path, "\n\t= ");
55498 + seq_path(m, &file->f_path, "\n\t\\= ");
55499 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
55500 seq_printf(m, " heap");
55501 } else {
55502 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
55503 index 1ccfa53..0848f95 100644
55504 --- a/fs/proc/task_nommu.c
55505 +++ b/fs/proc/task_nommu.c
55506 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55507 else
55508 bytes += kobjsize(mm);
55509
55510 - if (current->fs && current->fs->users > 1)
55511 + if (current->fs && atomic_read(&current->fs->users) > 1)
55512 sbytes += kobjsize(current->fs);
55513 else
55514 bytes += kobjsize(current->fs);
55515 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
55516
55517 if (file) {
55518 pad_len_spaces(m, len);
55519 - seq_path(m, &file->f_path, "");
55520 + seq_path(m, &file->f_path, "\n\\");
55521 } else if (mm) {
55522 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
55523
55524 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
55525 index b00fcc9..e0c6381 100644
55526 --- a/fs/qnx6/qnx6.h
55527 +++ b/fs/qnx6/qnx6.h
55528 @@ -74,7 +74,7 @@ enum {
55529 BYTESEX_BE,
55530 };
55531
55532 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55533 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55534 {
55535 if (sbi->s_bytesex == BYTESEX_LE)
55536 return le64_to_cpu((__force __le64)n);
55537 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
55538 return (__force __fs64)cpu_to_be64(n);
55539 }
55540
55541 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55542 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55543 {
55544 if (sbi->s_bytesex == BYTESEX_LE)
55545 return le32_to_cpu((__force __le32)n);
55546 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
55547 index 16e8abb..2dcf914 100644
55548 --- a/fs/quota/netlink.c
55549 +++ b/fs/quota/netlink.c
55550 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
55551 void quota_send_warning(struct kqid qid, dev_t dev,
55552 const char warntype)
55553 {
55554 - static atomic_t seq;
55555 + static atomic_unchecked_t seq;
55556 struct sk_buff *skb;
55557 void *msg_head;
55558 int ret;
55559 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
55560 "VFS: Not enough memory to send quota warning.\n");
55561 return;
55562 }
55563 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
55564 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
55565 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
55566 if (!msg_head) {
55567 printk(KERN_ERR
55568 diff --git a/fs/readdir.c b/fs/readdir.c
55569 index 5e69ef5..e5d9099 100644
55570 --- a/fs/readdir.c
55571 +++ b/fs/readdir.c
55572 @@ -17,6 +17,7 @@
55573 #include <linux/security.h>
55574 #include <linux/syscalls.h>
55575 #include <linux/unistd.h>
55576 +#include <linux/namei.h>
55577
55578 #include <asm/uaccess.h>
55579
55580 @@ -67,6 +68,7 @@ struct old_linux_dirent {
55581
55582 struct readdir_callback {
55583 struct old_linux_dirent __user * dirent;
55584 + struct file * file;
55585 int result;
55586 };
55587
55588 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
55589 buf->result = -EOVERFLOW;
55590 return -EOVERFLOW;
55591 }
55592 +
55593 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55594 + return 0;
55595 +
55596 buf->result++;
55597 dirent = buf->dirent;
55598 if (!access_ok(VERIFY_WRITE, dirent,
55599 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
55600
55601 buf.result = 0;
55602 buf.dirent = dirent;
55603 + buf.file = f.file;
55604
55605 error = vfs_readdir(f.file, fillonedir, &buf);
55606 if (buf.result)
55607 @@ -139,6 +146,7 @@ struct linux_dirent {
55608 struct getdents_callback {
55609 struct linux_dirent __user * current_dir;
55610 struct linux_dirent __user * previous;
55611 + struct file * file;
55612 int count;
55613 int error;
55614 };
55615 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
55616 buf->error = -EOVERFLOW;
55617 return -EOVERFLOW;
55618 }
55619 +
55620 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55621 + return 0;
55622 +
55623 dirent = buf->previous;
55624 if (dirent) {
55625 if (__put_user(offset, &dirent->d_off))
55626 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55627 buf.previous = NULL;
55628 buf.count = count;
55629 buf.error = 0;
55630 + buf.file = f.file;
55631
55632 error = vfs_readdir(f.file, filldir, &buf);
55633 if (error >= 0)
55634 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55635 struct getdents_callback64 {
55636 struct linux_dirent64 __user * current_dir;
55637 struct linux_dirent64 __user * previous;
55638 + struct file *file;
55639 int count;
55640 int error;
55641 };
55642 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
55643 buf->error = -EINVAL; /* only used if we fail.. */
55644 if (reclen > buf->count)
55645 return -EINVAL;
55646 +
55647 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55648 + return 0;
55649 +
55650 dirent = buf->previous;
55651 if (dirent) {
55652 if (__put_user(offset, &dirent->d_off))
55653 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55654
55655 buf.current_dir = dirent;
55656 buf.previous = NULL;
55657 + buf.file = f.file;
55658 buf.count = count;
55659 buf.error = 0;
55660
55661 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55662 error = buf.error;
55663 lastdirent = buf.previous;
55664 if (lastdirent) {
55665 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55666 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55667 if (__put_user(d_off, &lastdirent->d_off))
55668 error = -EFAULT;
55669 else
55670 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
55671 index 2b7882b..1c5ef48 100644
55672 --- a/fs/reiserfs/do_balan.c
55673 +++ b/fs/reiserfs/do_balan.c
55674 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
55675 return;
55676 }
55677
55678 - atomic_inc(&(fs_generation(tb->tb_sb)));
55679 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
55680 do_balance_starts(tb);
55681
55682 /* balance leaf returns 0 except if combining L R and S into
55683 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
55684 index e60e870..f40ac16 100644
55685 --- a/fs/reiserfs/procfs.c
55686 +++ b/fs/reiserfs/procfs.c
55687 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
55688 "SMALL_TAILS " : "NO_TAILS ",
55689 replay_only(sb) ? "REPLAY_ONLY " : "",
55690 convert_reiserfs(sb) ? "CONV " : "",
55691 - atomic_read(&r->s_generation_counter),
55692 + atomic_read_unchecked(&r->s_generation_counter),
55693 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
55694 SF(s_do_balance), SF(s_unneeded_left_neighbor),
55695 SF(s_good_search_by_key_reada), SF(s_bmaps),
55696 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
55697 index 157e474..65a6114 100644
55698 --- a/fs/reiserfs/reiserfs.h
55699 +++ b/fs/reiserfs/reiserfs.h
55700 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
55701 /* Comment? -Hans */
55702 wait_queue_head_t s_wait;
55703 /* To be obsoleted soon by per buffer seals.. -Hans */
55704 - atomic_t s_generation_counter; // increased by one every time the
55705 + atomic_unchecked_t s_generation_counter; // increased by one every time the
55706 // tree gets re-balanced
55707 unsigned long s_properties; /* File system properties. Currently holds
55708 on-disk FS format */
55709 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
55710 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
55711
55712 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
55713 -#define get_generation(s) atomic_read (&fs_generation(s))
55714 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
55715 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
55716 #define __fs_changed(gen,s) (gen != get_generation (s))
55717 #define fs_changed(gen,s) \
55718 diff --git a/fs/select.c b/fs/select.c
55719 index 2ef72d9..f213b17 100644
55720 --- a/fs/select.c
55721 +++ b/fs/select.c
55722 @@ -20,6 +20,7 @@
55723 #include <linux/export.h>
55724 #include <linux/slab.h>
55725 #include <linux/poll.h>
55726 +#include <linux/security.h>
55727 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
55728 #include <linux/file.h>
55729 #include <linux/fdtable.h>
55730 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
55731 struct poll_list *walk = head;
55732 unsigned long todo = nfds;
55733
55734 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
55735 if (nfds > rlimit(RLIMIT_NOFILE))
55736 return -EINVAL;
55737
55738 diff --git a/fs/seq_file.c b/fs/seq_file.c
55739 index f2bc3df..239d4f6 100644
55740 --- a/fs/seq_file.c
55741 +++ b/fs/seq_file.c
55742 @@ -10,6 +10,7 @@
55743 #include <linux/seq_file.h>
55744 #include <linux/slab.h>
55745 #include <linux/cred.h>
55746 +#include <linux/sched.h>
55747
55748 #include <asm/uaccess.h>
55749 #include <asm/page.h>
55750 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
55751 #ifdef CONFIG_USER_NS
55752 p->user_ns = file->f_cred->user_ns;
55753 #endif
55754 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55755 + p->exec_id = current->exec_id;
55756 +#endif
55757
55758 /*
55759 * Wrappers around seq_open(e.g. swaps_open) need to be
55760 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55761 return 0;
55762 }
55763 if (!m->buf) {
55764 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55765 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55766 if (!m->buf)
55767 return -ENOMEM;
55768 }
55769 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55770 Eoverflow:
55771 m->op->stop(m, p);
55772 kfree(m->buf);
55773 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55774 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55775 return !m->buf ? -ENOMEM : -EAGAIN;
55776 }
55777
55778 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55779
55780 /* grab buffer if we didn't have one */
55781 if (!m->buf) {
55782 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55783 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55784 if (!m->buf)
55785 goto Enomem;
55786 }
55787 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55788 goto Fill;
55789 m->op->stop(m, p);
55790 kfree(m->buf);
55791 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55792 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55793 if (!m->buf)
55794 goto Enomem;
55795 m->count = 0;
55796 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
55797 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
55798 void *data)
55799 {
55800 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
55801 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
55802 int res = -ENOMEM;
55803
55804 if (op) {
55805 diff --git a/fs/splice.c b/fs/splice.c
55806 index 6909d89..5b2e8f9 100644
55807 --- a/fs/splice.c
55808 +++ b/fs/splice.c
55809 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55810 pipe_lock(pipe);
55811
55812 for (;;) {
55813 - if (!pipe->readers) {
55814 + if (!atomic_read(&pipe->readers)) {
55815 send_sig(SIGPIPE, current, 0);
55816 if (!ret)
55817 ret = -EPIPE;
55818 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55819 do_wakeup = 0;
55820 }
55821
55822 - pipe->waiting_writers++;
55823 + atomic_inc(&pipe->waiting_writers);
55824 pipe_wait(pipe);
55825 - pipe->waiting_writers--;
55826 + atomic_dec(&pipe->waiting_writers);
55827 }
55828
55829 pipe_unlock(pipe);
55830 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
55831 old_fs = get_fs();
55832 set_fs(get_ds());
55833 /* The cast to a user pointer is valid due to the set_fs() */
55834 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
55835 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
55836 set_fs(old_fs);
55837
55838 return res;
55839 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
55840 old_fs = get_fs();
55841 set_fs(get_ds());
55842 /* The cast to a user pointer is valid due to the set_fs() */
55843 - res = vfs_write(file, (const char __user *)buf, count, &pos);
55844 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
55845 set_fs(old_fs);
55846
55847 return res;
55848 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
55849 goto err;
55850
55851 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
55852 - vec[i].iov_base = (void __user *) page_address(page);
55853 + vec[i].iov_base = (void __force_user *) page_address(page);
55854 vec[i].iov_len = this_len;
55855 spd.pages[i] = page;
55856 spd.nr_pages++;
55857 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
55858 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
55859 {
55860 while (!pipe->nrbufs) {
55861 - if (!pipe->writers)
55862 + if (!atomic_read(&pipe->writers))
55863 return 0;
55864
55865 - if (!pipe->waiting_writers && sd->num_spliced)
55866 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
55867 return 0;
55868
55869 if (sd->flags & SPLICE_F_NONBLOCK)
55870 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
55871 * out of the pipe right after the splice_to_pipe(). So set
55872 * PIPE_READERS appropriately.
55873 */
55874 - pipe->readers = 1;
55875 + atomic_set(&pipe->readers, 1);
55876
55877 current->splice_pipe = pipe;
55878 }
55879 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55880 ret = -ERESTARTSYS;
55881 break;
55882 }
55883 - if (!pipe->writers)
55884 + if (!atomic_read(&pipe->writers))
55885 break;
55886 - if (!pipe->waiting_writers) {
55887 + if (!atomic_read(&pipe->waiting_writers)) {
55888 if (flags & SPLICE_F_NONBLOCK) {
55889 ret = -EAGAIN;
55890 break;
55891 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55892 pipe_lock(pipe);
55893
55894 while (pipe->nrbufs >= pipe->buffers) {
55895 - if (!pipe->readers) {
55896 + if (!atomic_read(&pipe->readers)) {
55897 send_sig(SIGPIPE, current, 0);
55898 ret = -EPIPE;
55899 break;
55900 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55901 ret = -ERESTARTSYS;
55902 break;
55903 }
55904 - pipe->waiting_writers++;
55905 + atomic_inc(&pipe->waiting_writers);
55906 pipe_wait(pipe);
55907 - pipe->waiting_writers--;
55908 + atomic_dec(&pipe->waiting_writers);
55909 }
55910
55911 pipe_unlock(pipe);
55912 @@ -1823,14 +1823,14 @@ retry:
55913 pipe_double_lock(ipipe, opipe);
55914
55915 do {
55916 - if (!opipe->readers) {
55917 + if (!atomic_read(&opipe->readers)) {
55918 send_sig(SIGPIPE, current, 0);
55919 if (!ret)
55920 ret = -EPIPE;
55921 break;
55922 }
55923
55924 - if (!ipipe->nrbufs && !ipipe->writers)
55925 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
55926 break;
55927
55928 /*
55929 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
55930 pipe_double_lock(ipipe, opipe);
55931
55932 do {
55933 - if (!opipe->readers) {
55934 + if (!atomic_read(&opipe->readers)) {
55935 send_sig(SIGPIPE, current, 0);
55936 if (!ret)
55937 ret = -EPIPE;
55938 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
55939 * return EAGAIN if we have the potential of some data in the
55940 * future, otherwise just return 0
55941 */
55942 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
55943 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
55944 ret = -EAGAIN;
55945
55946 pipe_unlock(ipipe);
55947 diff --git a/fs/stat.c b/fs/stat.c
55948 index 14f4545..9b7f55b 100644
55949 --- a/fs/stat.c
55950 +++ b/fs/stat.c
55951 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
55952 stat->gid = inode->i_gid;
55953 stat->rdev = inode->i_rdev;
55954 stat->size = i_size_read(inode);
55955 - stat->atime = inode->i_atime;
55956 - stat->mtime = inode->i_mtime;
55957 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
55958 + stat->atime = inode->i_ctime;
55959 + stat->mtime = inode->i_ctime;
55960 + } else {
55961 + stat->atime = inode->i_atime;
55962 + stat->mtime = inode->i_mtime;
55963 + }
55964 stat->ctime = inode->i_ctime;
55965 stat->blksize = (1 << inode->i_blkbits);
55966 stat->blocks = inode->i_blocks;
55967 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55968 if (retval)
55969 return retval;
55970
55971 - if (inode->i_op->getattr)
55972 - return inode->i_op->getattr(mnt, dentry, stat);
55973 + if (inode->i_op->getattr) {
55974 + retval = inode->i_op->getattr(mnt, dentry, stat);
55975 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
55976 + stat->atime = stat->ctime;
55977 + stat->mtime = stat->ctime;
55978 + }
55979 + return retval;
55980 + }
55981
55982 generic_fillattr(inode, stat);
55983 return 0;
55984 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
55985 index 2fbdff6..5530a61 100644
55986 --- a/fs/sysfs/dir.c
55987 +++ b/fs/sysfs/dir.c
55988 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
55989 struct sysfs_dirent *sd;
55990 int rc;
55991
55992 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55993 + const char *parent_name = parent_sd->s_name;
55994 +
55995 + mode = S_IFDIR | S_IRWXU;
55996 +
55997 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
55998 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
55999 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56000 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56001 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56002 +#endif
56003 +
56004 /* allocate */
56005 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56006 if (!sd)
56007 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56008 index 602f56d..6853db8 100644
56009 --- a/fs/sysfs/file.c
56010 +++ b/fs/sysfs/file.c
56011 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56012
56013 struct sysfs_open_dirent {
56014 atomic_t refcnt;
56015 - atomic_t event;
56016 + atomic_unchecked_t event;
56017 wait_queue_head_t poll;
56018 struct list_head buffers; /* goes through sysfs_buffer.list */
56019 };
56020 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56021 if (!sysfs_get_active(attr_sd))
56022 return -ENODEV;
56023
56024 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56025 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56026 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56027
56028 sysfs_put_active(attr_sd);
56029 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56030 return -ENOMEM;
56031
56032 atomic_set(&new_od->refcnt, 0);
56033 - atomic_set(&new_od->event, 1);
56034 + atomic_set_unchecked(&new_od->event, 1);
56035 init_waitqueue_head(&new_od->poll);
56036 INIT_LIST_HEAD(&new_od->buffers);
56037 goto retry;
56038 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56039
56040 sysfs_put_active(attr_sd);
56041
56042 - if (buffer->event != atomic_read(&od->event))
56043 + if (buffer->event != atomic_read_unchecked(&od->event))
56044 goto trigger;
56045
56046 return DEFAULT_POLLMASK;
56047 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56048
56049 od = sd->s_attr.open;
56050 if (od) {
56051 - atomic_inc(&od->event);
56052 + atomic_inc_unchecked(&od->event);
56053 wake_up_interruptible(&od->poll);
56054 }
56055
56056 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56057 index 3c9eb56..9dea5be 100644
56058 --- a/fs/sysfs/symlink.c
56059 +++ b/fs/sysfs/symlink.c
56060 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56061
56062 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56063 {
56064 - char *page = nd_get_link(nd);
56065 + const char *page = nd_get_link(nd);
56066 if (!IS_ERR(page))
56067 free_page((unsigned long)page);
56068 }
56069 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56070 index 69d4889..a810bd4 100644
56071 --- a/fs/sysv/sysv.h
56072 +++ b/fs/sysv/sysv.h
56073 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56074 #endif
56075 }
56076
56077 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56078 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56079 {
56080 if (sbi->s_bytesex == BYTESEX_PDP)
56081 return PDP_swab((__force __u32)n);
56082 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56083 index e18b988..f1d4ad0f 100644
56084 --- a/fs/ubifs/io.c
56085 +++ b/fs/ubifs/io.c
56086 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56087 return err;
56088 }
56089
56090 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56091 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56092 {
56093 int err;
56094
56095 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56096 index c175b4d..8f36a16 100644
56097 --- a/fs/udf/misc.c
56098 +++ b/fs/udf/misc.c
56099 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56100
56101 u8 udf_tag_checksum(const struct tag *t)
56102 {
56103 - u8 *data = (u8 *)t;
56104 + const u8 *data = (const u8 *)t;
56105 u8 checksum = 0;
56106 int i;
56107 for (i = 0; i < sizeof(struct tag); ++i)
56108 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56109 index 8d974c4..b82f6ec 100644
56110 --- a/fs/ufs/swab.h
56111 +++ b/fs/ufs/swab.h
56112 @@ -22,7 +22,7 @@ enum {
56113 BYTESEX_BE
56114 };
56115
56116 -static inline u64
56117 +static inline u64 __intentional_overflow(-1)
56118 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56119 {
56120 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56121 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56122 return (__force __fs64)cpu_to_be64(n);
56123 }
56124
56125 -static inline u32
56126 +static inline u32 __intentional_overflow(-1)
56127 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56128 {
56129 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56130 diff --git a/fs/utimes.c b/fs/utimes.c
56131 index f4fb7ec..3fe03c0 100644
56132 --- a/fs/utimes.c
56133 +++ b/fs/utimes.c
56134 @@ -1,6 +1,7 @@
56135 #include <linux/compiler.h>
56136 #include <linux/file.h>
56137 #include <linux/fs.h>
56138 +#include <linux/security.h>
56139 #include <linux/linkage.h>
56140 #include <linux/mount.h>
56141 #include <linux/namei.h>
56142 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56143 goto mnt_drop_write_and_out;
56144 }
56145 }
56146 +
56147 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56148 + error = -EACCES;
56149 + goto mnt_drop_write_and_out;
56150 + }
56151 +
56152 mutex_lock(&inode->i_mutex);
56153 error = notify_change(path->dentry, &newattrs);
56154 mutex_unlock(&inode->i_mutex);
56155 diff --git a/fs/xattr.c b/fs/xattr.c
56156 index 3377dff..4feded6 100644
56157 --- a/fs/xattr.c
56158 +++ b/fs/xattr.c
56159 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56160 * Extended attribute SET operations
56161 */
56162 static long
56163 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56164 +setxattr(struct path *path, const char __user *name, const void __user *value,
56165 size_t size, int flags)
56166 {
56167 int error;
56168 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56169 posix_acl_fix_xattr_from_user(kvalue, size);
56170 }
56171
56172 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56173 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56174 + error = -EACCES;
56175 + goto out;
56176 + }
56177 +
56178 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56179 out:
56180 if (vvalue)
56181 vfree(vvalue);
56182 @@ -377,7 +382,7 @@ retry:
56183 return error;
56184 error = mnt_want_write(path.mnt);
56185 if (!error) {
56186 - error = setxattr(path.dentry, name, value, size, flags);
56187 + error = setxattr(&path, name, value, size, flags);
56188 mnt_drop_write(path.mnt);
56189 }
56190 path_put(&path);
56191 @@ -401,7 +406,7 @@ retry:
56192 return error;
56193 error = mnt_want_write(path.mnt);
56194 if (!error) {
56195 - error = setxattr(path.dentry, name, value, size, flags);
56196 + error = setxattr(&path, name, value, size, flags);
56197 mnt_drop_write(path.mnt);
56198 }
56199 path_put(&path);
56200 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56201 const void __user *,value, size_t, size, int, flags)
56202 {
56203 struct fd f = fdget(fd);
56204 - struct dentry *dentry;
56205 int error = -EBADF;
56206
56207 if (!f.file)
56208 return error;
56209 - dentry = f.file->f_path.dentry;
56210 - audit_inode(NULL, dentry, 0);
56211 + audit_inode(NULL, f.file->f_path.dentry, 0);
56212 error = mnt_want_write_file(f.file);
56213 if (!error) {
56214 - error = setxattr(dentry, name, value, size, flags);
56215 + error = setxattr(&f.file->f_path, name, value, size, flags);
56216 mnt_drop_write_file(f.file);
56217 }
56218 fdput(f);
56219 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56220 index 9fbea87..6b19972 100644
56221 --- a/fs/xattr_acl.c
56222 +++ b/fs/xattr_acl.c
56223 @@ -76,8 +76,8 @@ struct posix_acl *
56224 posix_acl_from_xattr(struct user_namespace *user_ns,
56225 const void *value, size_t size)
56226 {
56227 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56228 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56229 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56230 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56231 int count;
56232 struct posix_acl *acl;
56233 struct posix_acl_entry *acl_e;
56234 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56235 index 572a858..12a9b0d 100644
56236 --- a/fs/xfs/xfs_bmap.c
56237 +++ b/fs/xfs/xfs_bmap.c
56238 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56239 int nmap,
56240 int ret_nmap);
56241 #else
56242 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56243 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56244 #endif /* DEBUG */
56245
56246 STATIC int
56247 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56248 index 1b9fc3e..e1bdde0 100644
56249 --- a/fs/xfs/xfs_dir2_sf.c
56250 +++ b/fs/xfs/xfs_dir2_sf.c
56251 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56252 }
56253
56254 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56255 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56256 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56257 + char name[sfep->namelen];
56258 + memcpy(name, sfep->name, sfep->namelen);
56259 + if (filldir(dirent, name, sfep->namelen,
56260 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56261 + *offset = off & 0x7fffffff;
56262 + return 0;
56263 + }
56264 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56265 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56266 *offset = off & 0x7fffffff;
56267 return 0;
56268 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56269 index c1c3ef8..0952438 100644
56270 --- a/fs/xfs/xfs_ioctl.c
56271 +++ b/fs/xfs/xfs_ioctl.c
56272 @@ -127,7 +127,7 @@ xfs_find_handle(
56273 }
56274
56275 error = -EFAULT;
56276 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56277 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56278 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56279 goto out_put;
56280
56281 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56282 index d82efaa..0904a8e 100644
56283 --- a/fs/xfs/xfs_iops.c
56284 +++ b/fs/xfs/xfs_iops.c
56285 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56286 struct nameidata *nd,
56287 void *p)
56288 {
56289 - char *s = nd_get_link(nd);
56290 + const char *s = nd_get_link(nd);
56291
56292 if (!IS_ERR(s))
56293 kfree(s);
56294 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
56295 new file mode 100644
56296 index 0000000..92247e4
56297 --- /dev/null
56298 +++ b/grsecurity/Kconfig
56299 @@ -0,0 +1,1021 @@
56300 +#
56301 +# grecurity configuration
56302 +#
56303 +menu "Memory Protections"
56304 +depends on GRKERNSEC
56305 +
56306 +config GRKERNSEC_KMEM
56307 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
56308 + default y if GRKERNSEC_CONFIG_AUTO
56309 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
56310 + help
56311 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
56312 + be written to or read from to modify or leak the contents of the running
56313 + kernel. /dev/port will also not be allowed to be opened and support
56314 + for /dev/cpu/*/msr will be removed. If you have module
56315 + support disabled, enabling this will close up five ways that are
56316 + currently used to insert malicious code into the running kernel.
56317 +
56318 + Even with all these features enabled, we still highly recommend that
56319 + you use the RBAC system, as it is still possible for an attacker to
56320 + modify the running kernel through privileged I/O granted by ioperm/iopl.
56321 +
56322 + If you are not using XFree86, you may be able to stop this additional
56323 + case by enabling the 'Disable privileged I/O' option. Though nothing
56324 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
56325 + but only to video memory, which is the only writing we allow in this
56326 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
56327 + not be allowed to mprotect it with PROT_WRITE later.
56328 + Enabling this feature will prevent the "cpupower" and "powertop" tools
56329 + from working.
56330 +
56331 + It is highly recommended that you say Y here if you meet all the
56332 + conditions above.
56333 +
56334 +config GRKERNSEC_VM86
56335 + bool "Restrict VM86 mode"
56336 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56337 + depends on X86_32
56338 +
56339 + help
56340 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
56341 + make use of a special execution mode on 32bit x86 processors called
56342 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
56343 + video cards and will still work with this option enabled. The purpose
56344 + of the option is to prevent exploitation of emulation errors in
56345 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
56346 + Nearly all users should be able to enable this option.
56347 +
56348 +config GRKERNSEC_IO
56349 + bool "Disable privileged I/O"
56350 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56351 + depends on X86
56352 + select RTC_CLASS
56353 + select RTC_INTF_DEV
56354 + select RTC_DRV_CMOS
56355 +
56356 + help
56357 + If you say Y here, all ioperm and iopl calls will return an error.
56358 + Ioperm and iopl can be used to modify the running kernel.
56359 + Unfortunately, some programs need this access to operate properly,
56360 + the most notable of which are XFree86 and hwclock. hwclock can be
56361 + remedied by having RTC support in the kernel, so real-time
56362 + clock support is enabled if this option is enabled, to ensure
56363 + that hwclock operates correctly. XFree86 still will not
56364 + operate correctly with this option enabled, so DO NOT CHOOSE Y
56365 + IF YOU USE XFree86. If you use XFree86 and you still want to
56366 + protect your kernel against modification, use the RBAC system.
56367 +
56368 +config GRKERNSEC_JIT_HARDEN
56369 + bool "Harden BPF JIT against spray attacks"
56370 + default y if GRKERNSEC_CONFIG_AUTO
56371 + depends on BPF_JIT
56372 + help
56373 + If you say Y here, the native code generated by the kernel's Berkeley
56374 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
56375 + attacks that attempt to fit attacker-beneficial instructions in
56376 + 32bit immediate fields of JIT-generated native instructions. The
56377 + attacker will generally aim to cause an unintended instruction sequence
56378 + of JIT-generated native code to execute by jumping into the middle of
56379 + a generated instruction. This feature effectively randomizes the 32bit
56380 + immediate constants present in the generated code to thwart such attacks.
56381 +
56382 + If you're using KERNEXEC, it's recommended that you enable this option
56383 + to supplement the hardening of the kernel.
56384 +
56385 +config GRKERNSEC_RAND_THREADSTACK
56386 + bool "Insert random gaps between thread stacks"
56387 + default y if GRKERNSEC_CONFIG_AUTO
56388 + depends on PAX_RANDMMAP && !PPC
56389 + help
56390 + If you say Y here, a random-sized gap will be enforced between allocated
56391 + thread stacks. Glibc's NPTL and other threading libraries that
56392 + pass MAP_STACK to the kernel for thread stack allocation are supported.
56393 + The implementation currently provides 8 bits of entropy for the gap.
56394 +
56395 + Many distributions do not compile threaded remote services with the
56396 + -fstack-check argument to GCC, causing the variable-sized stack-based
56397 + allocator, alloca(), to not probe the stack on allocation. This
56398 + permits an unbounded alloca() to skip over any guard page and potentially
56399 + modify another thread's stack reliably. An enforced random gap
56400 + reduces the reliability of such an attack and increases the chance
56401 + that such a read/write to another thread's stack instead lands in
56402 + an unmapped area, causing a crash and triggering grsecurity's
56403 + anti-bruteforcing logic.
56404 +
56405 +config GRKERNSEC_PROC_MEMMAP
56406 + bool "Harden ASLR against information leaks and entropy reduction"
56407 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
56408 + depends on PAX_NOEXEC || PAX_ASLR
56409 + help
56410 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
56411 + give no information about the addresses of its mappings if
56412 + PaX features that rely on random addresses are enabled on the task.
56413 + In addition to sanitizing this information and disabling other
56414 + dangerous sources of information, this option causes reads of sensitive
56415 + /proc/<pid> entries where the file descriptor was opened in a different
56416 + task than the one performing the read. Such attempts are logged.
56417 + This option also limits argv/env strings for suid/sgid binaries
56418 + to 512KB to prevent a complete exhaustion of the stack entropy provided
56419 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
56420 + binaries to prevent alternative mmap layouts from being abused.
56421 +
56422 + If you use PaX it is essential that you say Y here as it closes up
56423 + several holes that make full ASLR useless locally.
56424 +
56425 +config GRKERNSEC_BRUTE
56426 + bool "Deter exploit bruteforcing"
56427 + default y if GRKERNSEC_CONFIG_AUTO
56428 + help
56429 + If you say Y here, attempts to bruteforce exploits against forking
56430 + daemons such as apache or sshd, as well as against suid/sgid binaries
56431 + will be deterred. When a child of a forking daemon is killed by PaX
56432 + or crashes due to an illegal instruction or other suspicious signal,
56433 + the parent process will be delayed 30 seconds upon every subsequent
56434 + fork until the administrator is able to assess the situation and
56435 + restart the daemon.
56436 + In the suid/sgid case, the attempt is logged, the user has all their
56437 + processes terminated, and they are prevented from executing any further
56438 + processes for 15 minutes.
56439 + It is recommended that you also enable signal logging in the auditing
56440 + section so that logs are generated when a process triggers a suspicious
56441 + signal.
56442 + If the sysctl option is enabled, a sysctl option with name
56443 + "deter_bruteforce" is created.
56444 +
56445 +
56446 +config GRKERNSEC_MODHARDEN
56447 + bool "Harden module auto-loading"
56448 + default y if GRKERNSEC_CONFIG_AUTO
56449 + depends on MODULES
56450 + help
56451 + If you say Y here, module auto-loading in response to use of some
56452 + feature implemented by an unloaded module will be restricted to
56453 + root users. Enabling this option helps defend against attacks
56454 + by unprivileged users who abuse the auto-loading behavior to
56455 + cause a vulnerable module to load that is then exploited.
56456 +
56457 + If this option prevents a legitimate use of auto-loading for a
56458 + non-root user, the administrator can execute modprobe manually
56459 + with the exact name of the module mentioned in the alert log.
56460 + Alternatively, the administrator can add the module to the list
56461 + of modules loaded at boot by modifying init scripts.
56462 +
56463 + Modification of init scripts will most likely be needed on
56464 + Ubuntu servers with encrypted home directory support enabled,
56465 + as the first non-root user logging in will cause the ecb(aes),
56466 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
56467 +
56468 +config GRKERNSEC_HIDESYM
56469 + bool "Hide kernel symbols"
56470 + default y if GRKERNSEC_CONFIG_AUTO
56471 + select PAX_USERCOPY_SLABS
56472 + help
56473 + If you say Y here, getting information on loaded modules, and
56474 + displaying all kernel symbols through a syscall will be restricted
56475 + to users with CAP_SYS_MODULE. For software compatibility reasons,
56476 + /proc/kallsyms will be restricted to the root user. The RBAC
56477 + system can hide that entry even from root.
56478 +
56479 + This option also prevents leaking of kernel addresses through
56480 + several /proc entries.
56481 +
56482 + Note that this option is only effective provided the following
56483 + conditions are met:
56484 + 1) The kernel using grsecurity is not precompiled by some distribution
56485 + 2) You have also enabled GRKERNSEC_DMESG
56486 + 3) You are using the RBAC system and hiding other files such as your
56487 + kernel image and System.map. Alternatively, enabling this option
56488 + causes the permissions on /boot, /lib/modules, and the kernel
56489 + source directory to change at compile time to prevent
56490 + reading by non-root users.
56491 + If the above conditions are met, this option will aid in providing a
56492 + useful protection against local kernel exploitation of overflows
56493 + and arbitrary read/write vulnerabilities.
56494 +
56495 +config GRKERNSEC_KERN_LOCKOUT
56496 + bool "Active kernel exploit response"
56497 + default y if GRKERNSEC_CONFIG_AUTO
56498 + depends on X86 || ARM || PPC || SPARC
56499 + help
56500 + If you say Y here, when a PaX alert is triggered due to suspicious
56501 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
56502 + or an OOPS occurs due to bad memory accesses, instead of just
56503 + terminating the offending process (and potentially allowing
56504 + a subsequent exploit from the same user), we will take one of two
56505 + actions:
56506 + If the user was root, we will panic the system
56507 + If the user was non-root, we will log the attempt, terminate
56508 + all processes owned by the user, then prevent them from creating
56509 + any new processes until the system is restarted
56510 + This deters repeated kernel exploitation/bruteforcing attempts
56511 + and is useful for later forensics.
56512 +
56513 +endmenu
56514 +menu "Role Based Access Control Options"
56515 +depends on GRKERNSEC
56516 +
56517 +config GRKERNSEC_RBAC_DEBUG
56518 + bool
56519 +
56520 +config GRKERNSEC_NO_RBAC
56521 + bool "Disable RBAC system"
56522 + help
56523 + If you say Y here, the /dev/grsec device will be removed from the kernel,
56524 + preventing the RBAC system from being enabled. You should only say Y
56525 + here if you have no intention of using the RBAC system, so as to prevent
56526 + an attacker with root access from misusing the RBAC system to hide files
56527 + and processes when loadable module support and /dev/[k]mem have been
56528 + locked down.
56529 +
56530 +config GRKERNSEC_ACL_HIDEKERN
56531 + bool "Hide kernel processes"
56532 + help
56533 + If you say Y here, all kernel threads will be hidden to all
56534 + processes but those whose subject has the "view hidden processes"
56535 + flag.
56536 +
56537 +config GRKERNSEC_ACL_MAXTRIES
56538 + int "Maximum tries before password lockout"
56539 + default 3
56540 + help
56541 + This option enforces the maximum number of times a user can attempt
56542 + to authorize themselves with the grsecurity RBAC system before being
56543 + denied the ability to attempt authorization again for a specified time.
56544 + The lower the number, the harder it will be to brute-force a password.
56545 +
56546 +config GRKERNSEC_ACL_TIMEOUT
56547 + int "Time to wait after max password tries, in seconds"
56548 + default 30
56549 + help
56550 + This option specifies the time the user must wait after attempting to
56551 + authorize to the RBAC system with the maximum number of invalid
56552 + passwords. The higher the number, the harder it will be to brute-force
56553 + a password.
56554 +
56555 +endmenu
56556 +menu "Filesystem Protections"
56557 +depends on GRKERNSEC
56558 +
56559 +config GRKERNSEC_PROC
56560 + bool "Proc restrictions"
56561 + default y if GRKERNSEC_CONFIG_AUTO
56562 + help
56563 + If you say Y here, the permissions of the /proc filesystem
56564 + will be altered to enhance system security and privacy. You MUST
56565 + choose either a user only restriction or a user and group restriction.
56566 + Depending upon the option you choose, you can either restrict users to
56567 + see only the processes they themselves run, or choose a group that can
56568 + view all processes and files normally restricted to root if you choose
56569 + the "restrict to user only" option. NOTE: If you're running identd or
56570 + ntpd as a non-root user, you will have to run it as the group you
56571 + specify here.
56572 +
56573 +config GRKERNSEC_PROC_USER
56574 + bool "Restrict /proc to user only"
56575 + depends on GRKERNSEC_PROC
56576 + help
56577 + If you say Y here, non-root users will only be able to view their own
56578 + processes, and restricts them from viewing network-related information,
56579 + and viewing kernel symbol and module information.
56580 +
56581 +config GRKERNSEC_PROC_USERGROUP
56582 + bool "Allow special group"
56583 + default y if GRKERNSEC_CONFIG_AUTO
56584 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
56585 + help
56586 + If you say Y here, you will be able to select a group that will be
56587 + able to view all processes and network-related information. If you've
56588 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
56589 + remain hidden. This option is useful if you want to run identd as
56590 + a non-root user. The group you select may also be chosen at boot time
56591 + via "grsec_proc_gid=" on the kernel commandline.
56592 +
56593 +config GRKERNSEC_PROC_GID
56594 + int "GID for special group"
56595 + depends on GRKERNSEC_PROC_USERGROUP
56596 + default 1001
56597 +
56598 +config GRKERNSEC_PROC_ADD
56599 + bool "Additional restrictions"
56600 + default y if GRKERNSEC_CONFIG_AUTO
56601 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
56602 + help
56603 + If you say Y here, additional restrictions will be placed on
56604 + /proc that keep normal users from viewing device information and
56605 + slabinfo information that could be useful for exploits.
56606 +
56607 +config GRKERNSEC_LINK
56608 + bool "Linking restrictions"
56609 + default y if GRKERNSEC_CONFIG_AUTO
56610 + help
56611 + If you say Y here, /tmp race exploits will be prevented, since users
56612 + will no longer be able to follow symlinks owned by other users in
56613 + world-writable +t directories (e.g. /tmp), unless the owner of the
56614 + symlink is the owner of the directory. users will also not be
56615 + able to hardlink to files they do not own. If the sysctl option is
56616 + enabled, a sysctl option with name "linking_restrictions" is created.
56617 +
56618 +config GRKERNSEC_SYMLINKOWN
56619 + bool "Kernel-enforced SymlinksIfOwnerMatch"
56620 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56621 + help
56622 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
56623 + that prevents it from being used as a security feature. As Apache
56624 + verifies the symlink by performing a stat() against the target of
56625 + the symlink before it is followed, an attacker can setup a symlink
56626 + to point to a same-owned file, then replace the symlink with one
56627 + that targets another user's file just after Apache "validates" the
56628 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
56629 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
56630 + will be in place for the group you specify. If the sysctl option
56631 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
56632 + created.
56633 +
56634 +config GRKERNSEC_SYMLINKOWN_GID
56635 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
56636 + depends on GRKERNSEC_SYMLINKOWN
56637 + default 1006
56638 + help
56639 + Setting this GID determines what group kernel-enforced
56640 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
56641 + is enabled, a sysctl option with name "symlinkown_gid" is created.
56642 +
56643 +config GRKERNSEC_FIFO
56644 + bool "FIFO restrictions"
56645 + default y if GRKERNSEC_CONFIG_AUTO
56646 + help
56647 + If you say Y here, users will not be able to write to FIFOs they don't
56648 + own in world-writable +t directories (e.g. /tmp), unless the owner of
56649 + the FIFO is the same owner of the directory it's held in. If the sysctl
56650 + option is enabled, a sysctl option with name "fifo_restrictions" is
56651 + created.
56652 +
56653 +config GRKERNSEC_SYSFS_RESTRICT
56654 + bool "Sysfs/debugfs restriction"
56655 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56656 + depends on SYSFS
56657 + help
56658 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
56659 + any filesystem normally mounted under it (e.g. debugfs) will be
56660 + mostly accessible only by root. These filesystems generally provide access
56661 + to hardware and debug information that isn't appropriate for unprivileged
56662 + users of the system. Sysfs and debugfs have also become a large source
56663 + of new vulnerabilities, ranging from infoleaks to local compromise.
56664 + There has been very little oversight with an eye toward security involved
56665 + in adding new exporters of information to these filesystems, so their
56666 + use is discouraged.
56667 + For reasons of compatibility, a few directories have been whitelisted
56668 + for access by non-root users:
56669 + /sys/fs/selinux
56670 + /sys/fs/fuse
56671 + /sys/devices/system/cpu
56672 +
56673 +config GRKERNSEC_ROFS
56674 + bool "Runtime read-only mount protection"
56675 + help
56676 + If you say Y here, a sysctl option with name "romount_protect" will
56677 + be created. By setting this option to 1 at runtime, filesystems
56678 + will be protected in the following ways:
56679 + * No new writable mounts will be allowed
56680 + * Existing read-only mounts won't be able to be remounted read/write
56681 + * Write operations will be denied on all block devices
56682 + This option acts independently of grsec_lock: once it is set to 1,
56683 + it cannot be turned off. Therefore, please be mindful of the resulting
56684 + behavior if this option is enabled in an init script on a read-only
56685 + filesystem. This feature is mainly intended for secure embedded systems.
56686 +
56687 +config GRKERNSEC_DEVICE_SIDECHANNEL
56688 + bool "Eliminate stat/notify-based device sidechannels"
56689 + default y if GRKERNSEC_CONFIG_AUTO
56690 + help
56691 + If you say Y here, timing analyses on block or character
56692 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
56693 + will be thwarted for unprivileged users. If a process without
56694 + CAP_MKNOD stats such a device, the last access and last modify times
56695 + will match the device's create time. No access or modify events
56696 + will be triggered through inotify/dnotify/fanotify for such devices.
56697 + This feature will prevent attacks that may at a minimum
56698 + allow an attacker to determine the administrator's password length.
56699 +
56700 +config GRKERNSEC_CHROOT
56701 + bool "Chroot jail restrictions"
56702 + default y if GRKERNSEC_CONFIG_AUTO
56703 + help
56704 + If you say Y here, you will be able to choose several options that will
56705 + make breaking out of a chrooted jail much more difficult. If you
56706 + encounter no software incompatibilities with the following options, it
56707 + is recommended that you enable each one.
56708 +
56709 +config GRKERNSEC_CHROOT_MOUNT
56710 + bool "Deny mounts"
56711 + default y if GRKERNSEC_CONFIG_AUTO
56712 + depends on GRKERNSEC_CHROOT
56713 + help
56714 + If you say Y here, processes inside a chroot will not be able to
56715 + mount or remount filesystems. If the sysctl option is enabled, a
56716 + sysctl option with name "chroot_deny_mount" is created.
56717 +
56718 +config GRKERNSEC_CHROOT_DOUBLE
56719 + bool "Deny double-chroots"
56720 + default y if GRKERNSEC_CONFIG_AUTO
56721 + depends on GRKERNSEC_CHROOT
56722 + help
56723 + If you say Y here, processes inside a chroot will not be able to chroot
56724 + again outside the chroot. This is a widely used method of breaking
56725 + out of a chroot jail and should not be allowed. If the sysctl
56726 + option is enabled, a sysctl option with name
56727 + "chroot_deny_chroot" is created.
56728 +
56729 +config GRKERNSEC_CHROOT_PIVOT
56730 + bool "Deny pivot_root in chroot"
56731 + default y if GRKERNSEC_CONFIG_AUTO
56732 + depends on GRKERNSEC_CHROOT
56733 + help
56734 + If you say Y here, processes inside a chroot will not be able to use
56735 + a function called pivot_root() that was introduced in Linux 2.3.41. It
56736 + works similar to chroot in that it changes the root filesystem. This
56737 + function could be misused in a chrooted process to attempt to break out
56738 + of the chroot, and therefore should not be allowed. If the sysctl
56739 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
56740 + created.
56741 +
56742 +config GRKERNSEC_CHROOT_CHDIR
56743 + bool "Enforce chdir(\"/\") on all chroots"
56744 + default y if GRKERNSEC_CONFIG_AUTO
56745 + depends on GRKERNSEC_CHROOT
56746 + help
56747 + If you say Y here, the current working directory of all newly-chrooted
56748 + applications will be set to the the root directory of the chroot.
56749 + The man page on chroot(2) states:
56750 + Note that this call does not change the current working
56751 + directory, so that `.' can be outside the tree rooted at
56752 + `/'. In particular, the super-user can escape from a
56753 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
56754 +
56755 + It is recommended that you say Y here, since it's not known to break
56756 + any software. If the sysctl option is enabled, a sysctl option with
56757 + name "chroot_enforce_chdir" is created.
56758 +
56759 +config GRKERNSEC_CHROOT_CHMOD
56760 + bool "Deny (f)chmod +s"
56761 + default y if GRKERNSEC_CONFIG_AUTO
56762 + depends on GRKERNSEC_CHROOT
56763 + help
56764 + If you say Y here, processes inside a chroot will not be able to chmod
56765 + or fchmod files to make them have suid or sgid bits. This protects
56766 + against another published method of breaking a chroot. If the sysctl
56767 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
56768 + created.
56769 +
56770 +config GRKERNSEC_CHROOT_FCHDIR
56771 + bool "Deny fchdir out of chroot"
56772 + default y if GRKERNSEC_CONFIG_AUTO
56773 + depends on GRKERNSEC_CHROOT
56774 + help
56775 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
56776 + to a file descriptor of the chrooting process that points to a directory
56777 + outside the filesystem will be stopped. If the sysctl option
56778 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
56779 +
56780 +config GRKERNSEC_CHROOT_MKNOD
56781 + bool "Deny mknod"
56782 + default y if GRKERNSEC_CONFIG_AUTO
56783 + depends on GRKERNSEC_CHROOT
56784 + help
56785 + If you say Y here, processes inside a chroot will not be allowed to
56786 + mknod. The problem with using mknod inside a chroot is that it
56787 + would allow an attacker to create a device entry that is the same
56788 + as one on the physical root of your system, which could range from
56789 + anything from the console device to a device for your harddrive (which
56790 + they could then use to wipe the drive or steal data). It is recommended
56791 + that you say Y here, unless you run into software incompatibilities.
56792 + If the sysctl option is enabled, a sysctl option with name
56793 + "chroot_deny_mknod" is created.
56794 +
56795 +config GRKERNSEC_CHROOT_SHMAT
56796 + bool "Deny shmat() out of chroot"
56797 + default y if GRKERNSEC_CONFIG_AUTO
56798 + depends on GRKERNSEC_CHROOT
56799 + help
56800 + If you say Y here, processes inside a chroot will not be able to attach
56801 + to shared memory segments that were created outside of the chroot jail.
56802 + It is recommended that you say Y here. If the sysctl option is enabled,
56803 + a sysctl option with name "chroot_deny_shmat" is created.
56804 +
56805 +config GRKERNSEC_CHROOT_UNIX
56806 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
56807 + default y if GRKERNSEC_CONFIG_AUTO
56808 + depends on GRKERNSEC_CHROOT
56809 + help
56810 + If you say Y here, processes inside a chroot will not be able to
56811 + connect to abstract (meaning not belonging to a filesystem) Unix
56812 + domain sockets that were bound outside of a chroot. It is recommended
56813 + that you say Y here. If the sysctl option is enabled, a sysctl option
56814 + with name "chroot_deny_unix" is created.
56815 +
56816 +config GRKERNSEC_CHROOT_FINDTASK
56817 + bool "Protect outside processes"
56818 + default y if GRKERNSEC_CONFIG_AUTO
56819 + depends on GRKERNSEC_CHROOT
56820 + help
56821 + If you say Y here, processes inside a chroot will not be able to
56822 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
56823 + getsid, or view any process outside of the chroot. If the sysctl
56824 + option is enabled, a sysctl option with name "chroot_findtask" is
56825 + created.
56826 +
56827 +config GRKERNSEC_CHROOT_NICE
56828 + bool "Restrict priority changes"
56829 + default y if GRKERNSEC_CONFIG_AUTO
56830 + depends on GRKERNSEC_CHROOT
56831 + help
56832 + If you say Y here, processes inside a chroot will not be able to raise
56833 + the priority of processes in the chroot, or alter the priority of
56834 + processes outside the chroot. This provides more security than simply
56835 + removing CAP_SYS_NICE from the process' capability set. If the
56836 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
56837 + is created.
56838 +
56839 +config GRKERNSEC_CHROOT_SYSCTL
56840 + bool "Deny sysctl writes"
56841 + default y if GRKERNSEC_CONFIG_AUTO
56842 + depends on GRKERNSEC_CHROOT
56843 + help
56844 + If you say Y here, an attacker in a chroot will not be able to
56845 + write to sysctl entries, either by sysctl(2) or through a /proc
56846 + interface. It is strongly recommended that you say Y here. If the
56847 + sysctl option is enabled, a sysctl option with name
56848 + "chroot_deny_sysctl" is created.
56849 +
56850 +config GRKERNSEC_CHROOT_CAPS
56851 + bool "Capability restrictions"
56852 + default y if GRKERNSEC_CONFIG_AUTO
56853 + depends on GRKERNSEC_CHROOT
56854 + help
56855 + If you say Y here, the capabilities on all processes within a
56856 + chroot jail will be lowered to stop module insertion, raw i/o,
56857 + system and net admin tasks, rebooting the system, modifying immutable
56858 + files, modifying IPC owned by another, and changing the system time.
56859 + This is left an option because it can break some apps. Disable this
56860 + if your chrooted apps are having problems performing those kinds of
56861 + tasks. If the sysctl option is enabled, a sysctl option with
56862 + name "chroot_caps" is created.
56863 +
56864 +endmenu
56865 +menu "Kernel Auditing"
56866 +depends on GRKERNSEC
56867 +
56868 +config GRKERNSEC_AUDIT_GROUP
56869 + bool "Single group for auditing"
56870 + help
56871 + If you say Y here, the exec and chdir logging features will only operate
56872 + on a group you specify. This option is recommended if you only want to
56873 + watch certain users instead of having a large amount of logs from the
56874 + entire system. If the sysctl option is enabled, a sysctl option with
56875 + name "audit_group" is created.
56876 +
56877 +config GRKERNSEC_AUDIT_GID
56878 + int "GID for auditing"
56879 + depends on GRKERNSEC_AUDIT_GROUP
56880 + default 1007
56881 +
56882 +config GRKERNSEC_EXECLOG
56883 + bool "Exec logging"
56884 + help
56885 + If you say Y here, all execve() calls will be logged (since the
56886 + other exec*() calls are frontends to execve(), all execution
56887 + will be logged). Useful for shell-servers that like to keep track
56888 + of their users. If the sysctl option is enabled, a sysctl option with
56889 + name "exec_logging" is created.
56890 + WARNING: This option when enabled will produce a LOT of logs, especially
56891 + on an active system.
56892 +
56893 +config GRKERNSEC_RESLOG
56894 + bool "Resource logging"
56895 + default y if GRKERNSEC_CONFIG_AUTO
56896 + help
56897 + If you say Y here, all attempts to overstep resource limits will
56898 + be logged with the resource name, the requested size, and the current
56899 + limit. It is highly recommended that you say Y here. If the sysctl
56900 + option is enabled, a sysctl option with name "resource_logging" is
56901 + created. If the RBAC system is enabled, the sysctl value is ignored.
56902 +
56903 +config GRKERNSEC_CHROOT_EXECLOG
56904 + bool "Log execs within chroot"
56905 + help
56906 + If you say Y here, all executions inside a chroot jail will be logged
56907 + to syslog. This can cause a large amount of logs if certain
56908 + applications (eg. djb's daemontools) are installed on the system, and
56909 + is therefore left as an option. If the sysctl option is enabled, a
56910 + sysctl option with name "chroot_execlog" is created.
56911 +
56912 +config GRKERNSEC_AUDIT_PTRACE
56913 + bool "Ptrace logging"
56914 + help
56915 + If you say Y here, all attempts to attach to a process via ptrace
56916 + will be logged. If the sysctl option is enabled, a sysctl option
56917 + with name "audit_ptrace" is created.
56918 +
56919 +config GRKERNSEC_AUDIT_CHDIR
56920 + bool "Chdir logging"
56921 + help
56922 + If you say Y here, all chdir() calls will be logged. If the sysctl
56923 + option is enabled, a sysctl option with name "audit_chdir" is created.
56924 +
56925 +config GRKERNSEC_AUDIT_MOUNT
56926 + bool "(Un)Mount logging"
56927 + help
56928 + If you say Y here, all mounts and unmounts will be logged. If the
56929 + sysctl option is enabled, a sysctl option with name "audit_mount" is
56930 + created.
56931 +
56932 +config GRKERNSEC_SIGNAL
56933 + bool "Signal logging"
56934 + default y if GRKERNSEC_CONFIG_AUTO
56935 + help
56936 + If you say Y here, certain important signals will be logged, such as
56937 + SIGSEGV, which will as a result inform you of when a error in a program
56938 + occurred, which in some cases could mean a possible exploit attempt.
56939 + If the sysctl option is enabled, a sysctl option with name
56940 + "signal_logging" is created.
56941 +
56942 +config GRKERNSEC_FORKFAIL
56943 + bool "Fork failure logging"
56944 + help
56945 + If you say Y here, all failed fork() attempts will be logged.
56946 + This could suggest a fork bomb, or someone attempting to overstep
56947 + their process limit. If the sysctl option is enabled, a sysctl option
56948 + with name "forkfail_logging" is created.
56949 +
56950 +config GRKERNSEC_TIME
56951 + bool "Time change logging"
56952 + default y if GRKERNSEC_CONFIG_AUTO
56953 + help
56954 + If you say Y here, any changes of the system clock will be logged.
56955 + If the sysctl option is enabled, a sysctl option with name
56956 + "timechange_logging" is created.
56957 +
56958 +config GRKERNSEC_PROC_IPADDR
56959 + bool "/proc/<pid>/ipaddr support"
56960 + default y if GRKERNSEC_CONFIG_AUTO
56961 + help
56962 + If you say Y here, a new entry will be added to each /proc/<pid>
56963 + directory that contains the IP address of the person using the task.
56964 + The IP is carried across local TCP and AF_UNIX stream sockets.
56965 + This information can be useful for IDS/IPSes to perform remote response
56966 + to a local attack. The entry is readable by only the owner of the
56967 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
56968 + the RBAC system), and thus does not create privacy concerns.
56969 +
56970 +config GRKERNSEC_RWXMAP_LOG
56971 + bool 'Denied RWX mmap/mprotect logging'
56972 + default y if GRKERNSEC_CONFIG_AUTO
56973 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
56974 + help
56975 + If you say Y here, calls to mmap() and mprotect() with explicit
56976 + usage of PROT_WRITE and PROT_EXEC together will be logged when
56977 + denied by the PAX_MPROTECT feature. If the sysctl option is
56978 + enabled, a sysctl option with name "rwxmap_logging" is created.
56979 +
56980 +config GRKERNSEC_AUDIT_TEXTREL
56981 + bool 'ELF text relocations logging (READ HELP)'
56982 + depends on PAX_MPROTECT
56983 + help
56984 + If you say Y here, text relocations will be logged with the filename
56985 + of the offending library or binary. The purpose of the feature is
56986 + to help Linux distribution developers get rid of libraries and
56987 + binaries that need text relocations which hinder the future progress
56988 + of PaX. Only Linux distribution developers should say Y here, and
56989 + never on a production machine, as this option creates an information
56990 + leak that could aid an attacker in defeating the randomization of
56991 + a single memory region. If the sysctl option is enabled, a sysctl
56992 + option with name "audit_textrel" is created.
56993 +
56994 +endmenu
56995 +
56996 +menu "Executable Protections"
56997 +depends on GRKERNSEC
56998 +
56999 +config GRKERNSEC_DMESG
57000 + bool "Dmesg(8) restriction"
57001 + default y if GRKERNSEC_CONFIG_AUTO
57002 + help
57003 + If you say Y here, non-root users will not be able to use dmesg(8)
57004 + to view the contents of the kernel's circular log buffer.
57005 + The kernel's log buffer often contains kernel addresses and other
57006 + identifying information useful to an attacker in fingerprinting a
57007 + system for a targeted exploit.
57008 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57009 + created.
57010 +
57011 +config GRKERNSEC_HARDEN_PTRACE
57012 + bool "Deter ptrace-based process snooping"
57013 + default y if GRKERNSEC_CONFIG_AUTO
57014 + help
57015 + If you say Y here, TTY sniffers and other malicious monitoring
57016 + programs implemented through ptrace will be defeated. If you
57017 + have been using the RBAC system, this option has already been
57018 + enabled for several years for all users, with the ability to make
57019 + fine-grained exceptions.
57020 +
57021 + This option only affects the ability of non-root users to ptrace
57022 + processes that are not a descendent of the ptracing process.
57023 + This means that strace ./binary and gdb ./binary will still work,
57024 + but attaching to arbitrary processes will not. If the sysctl
57025 + option is enabled, a sysctl option with name "harden_ptrace" is
57026 + created.
57027 +
57028 +config GRKERNSEC_PTRACE_READEXEC
57029 + bool "Require read access to ptrace sensitive binaries"
57030 + default y if GRKERNSEC_CONFIG_AUTO
57031 + help
57032 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57033 + binaries. This option is useful in environments that
57034 + remove the read bits (e.g. file mode 4711) from suid binaries to
57035 + prevent infoleaking of their contents. This option adds
57036 + consistency to the use of that file mode, as the binary could normally
57037 + be read out when run without privileges while ptracing.
57038 +
57039 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57040 + is created.
57041 +
57042 +config GRKERNSEC_SETXID
57043 + bool "Enforce consistent multithreaded privileges"
57044 + default y if GRKERNSEC_CONFIG_AUTO
57045 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57046 + help
57047 + If you say Y here, a change from a root uid to a non-root uid
57048 + in a multithreaded application will cause the resulting uids,
57049 + gids, supplementary groups, and capabilities in that thread
57050 + to be propagated to the other threads of the process. In most
57051 + cases this is unnecessary, as glibc will emulate this behavior
57052 + on behalf of the application. Other libcs do not act in the
57053 + same way, allowing the other threads of the process to continue
57054 + running with root privileges. If the sysctl option is enabled,
57055 + a sysctl option with name "consistent_setxid" is created.
57056 +
57057 +config GRKERNSEC_TPE
57058 + bool "Trusted Path Execution (TPE)"
57059 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57060 + help
57061 + If you say Y here, you will be able to choose a gid to add to the
57062 + supplementary groups of users you want to mark as "untrusted."
57063 + These users will not be able to execute any files that are not in
57064 + root-owned directories writable only by root. If the sysctl option
57065 + is enabled, a sysctl option with name "tpe" is created.
57066 +
57067 +config GRKERNSEC_TPE_ALL
57068 + bool "Partially restrict all non-root users"
57069 + depends on GRKERNSEC_TPE
57070 + help
57071 + If you say Y here, all non-root users will be covered under
57072 + a weaker TPE restriction. This is separate from, and in addition to,
57073 + the main TPE options that you have selected elsewhere. Thus, if a
57074 + "trusted" GID is chosen, this restriction applies to even that GID.
57075 + Under this restriction, all non-root users will only be allowed to
57076 + execute files in directories they own that are not group or
57077 + world-writable, or in directories owned by root and writable only by
57078 + root. If the sysctl option is enabled, a sysctl option with name
57079 + "tpe_restrict_all" is created.
57080 +
57081 +config GRKERNSEC_TPE_INVERT
57082 + bool "Invert GID option"
57083 + depends on GRKERNSEC_TPE
57084 + help
57085 + If you say Y here, the group you specify in the TPE configuration will
57086 + decide what group TPE restrictions will be *disabled* for. This
57087 + option is useful if you want TPE restrictions to be applied to most
57088 + users on the system. If the sysctl option is enabled, a sysctl option
57089 + with name "tpe_invert" is created. Unlike other sysctl options, this
57090 + entry will default to on for backward-compatibility.
57091 +
57092 +config GRKERNSEC_TPE_GID
57093 + int
57094 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57095 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57096 +
57097 +config GRKERNSEC_TPE_UNTRUSTED_GID
57098 + int "GID for TPE-untrusted users"
57099 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57100 + default 1005
57101 + help
57102 + Setting this GID determines what group TPE restrictions will be
57103 + *enabled* for. If the sysctl option is enabled, a sysctl option
57104 + with name "tpe_gid" is created.
57105 +
57106 +config GRKERNSEC_TPE_TRUSTED_GID
57107 + int "GID for TPE-trusted users"
57108 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57109 + default 1005
57110 + help
57111 + Setting this GID determines what group TPE restrictions will be
57112 + *disabled* for. If the sysctl option is enabled, a sysctl option
57113 + with name "tpe_gid" is created.
57114 +
57115 +endmenu
57116 +menu "Network Protections"
57117 +depends on GRKERNSEC
57118 +
57119 +config GRKERNSEC_RANDNET
57120 + bool "Larger entropy pools"
57121 + default y if GRKERNSEC_CONFIG_AUTO
57122 + help
57123 + If you say Y here, the entropy pools used for many features of Linux
57124 + and grsecurity will be doubled in size. Since several grsecurity
57125 + features use additional randomness, it is recommended that you say Y
57126 + here. Saying Y here has a similar effect as modifying
57127 + /proc/sys/kernel/random/poolsize.
57128 +
57129 +config GRKERNSEC_BLACKHOLE
57130 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57131 + default y if GRKERNSEC_CONFIG_AUTO
57132 + depends on NET
57133 + help
57134 + If you say Y here, neither TCP resets nor ICMP
57135 + destination-unreachable packets will be sent in response to packets
57136 + sent to ports for which no associated listening process exists.
57137 + This feature supports both IPV4 and IPV6 and exempts the
57138 + loopback interface from blackholing. Enabling this feature
57139 + makes a host more resilient to DoS attacks and reduces network
57140 + visibility against scanners.
57141 +
57142 + The blackhole feature as-implemented is equivalent to the FreeBSD
57143 + blackhole feature, as it prevents RST responses to all packets, not
57144 + just SYNs. Under most application behavior this causes no
57145 + problems, but applications (like haproxy) may not close certain
57146 + connections in a way that cleanly terminates them on the remote
57147 + end, leaving the remote host in LAST_ACK state. Because of this
57148 + side-effect and to prevent intentional LAST_ACK DoSes, this
57149 + feature also adds automatic mitigation against such attacks.
57150 + The mitigation drastically reduces the amount of time a socket
57151 + can spend in LAST_ACK state. If you're using haproxy and not
57152 + all servers it connects to have this option enabled, consider
57153 + disabling this feature on the haproxy host.
57154 +
57155 + If the sysctl option is enabled, two sysctl options with names
57156 + "ip_blackhole" and "lastack_retries" will be created.
57157 + While "ip_blackhole" takes the standard zero/non-zero on/off
57158 + toggle, "lastack_retries" uses the same kinds of values as
57159 + "tcp_retries1" and "tcp_retries2". The default value of 4
57160 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57161 + state.
57162 +
57163 +config GRKERNSEC_NO_SIMULT_CONNECT
57164 + bool "Disable TCP Simultaneous Connect"
57165 + default y if GRKERNSEC_CONFIG_AUTO
57166 + depends on NET
57167 + help
57168 + If you say Y here, a feature by Willy Tarreau will be enabled that
57169 + removes a weakness in Linux's strict implementation of TCP that
57170 + allows two clients to connect to each other without either entering
57171 + a listening state. The weakness allows an attacker to easily prevent
57172 + a client from connecting to a known server provided the source port
57173 + for the connection is guessed correctly.
57174 +
57175 + As the weakness could be used to prevent an antivirus or IPS from
57176 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57177 + it should be eliminated by enabling this option. Though Linux is
57178 + one of few operating systems supporting simultaneous connect, it
57179 + has no legitimate use in practice and is rarely supported by firewalls.
57180 +
57181 +config GRKERNSEC_SOCKET
57182 + bool "Socket restrictions"
57183 + depends on NET
57184 + help
57185 + If you say Y here, you will be able to choose from several options.
57186 + If you assign a GID on your system and add it to the supplementary
57187 + groups of users you want to restrict socket access to, this patch
57188 + will perform up to three things, based on the option(s) you choose.
57189 +
57190 +config GRKERNSEC_SOCKET_ALL
57191 + bool "Deny any sockets to group"
57192 + depends on GRKERNSEC_SOCKET
57193 + help
57194 + If you say Y here, you will be able to choose a GID of whose users will
57195 + be unable to connect to other hosts from your machine or run server
57196 + applications from your machine. If the sysctl option is enabled, a
57197 + sysctl option with name "socket_all" is created.
57198 +
57199 +config GRKERNSEC_SOCKET_ALL_GID
57200 + int "GID to deny all sockets for"
57201 + depends on GRKERNSEC_SOCKET_ALL
57202 + default 1004
57203 + help
57204 + Here you can choose the GID to disable socket access for. Remember to
57205 + add the users you want socket access disabled for to the GID
57206 + specified here. If the sysctl option is enabled, a sysctl option
57207 + with name "socket_all_gid" is created.
57208 +
57209 +config GRKERNSEC_SOCKET_CLIENT
57210 + bool "Deny client sockets to group"
57211 + depends on GRKERNSEC_SOCKET
57212 + help
57213 + If you say Y here, you will be able to choose a GID of whose users will
57214 + be unable to connect to other hosts from your machine, but will be
57215 + able to run servers. If this option is enabled, all users in the group
57216 + you specify will have to use passive mode when initiating ftp transfers
57217 + from the shell on your machine. If the sysctl option is enabled, a
57218 + sysctl option with name "socket_client" is created.
57219 +
57220 +config GRKERNSEC_SOCKET_CLIENT_GID
57221 + int "GID to deny client sockets for"
57222 + depends on GRKERNSEC_SOCKET_CLIENT
57223 + default 1003
57224 + help
57225 + Here you can choose the GID to disable client socket access for.
57226 + Remember to add the users you want client socket access disabled for to
57227 + the GID specified here. If the sysctl option is enabled, a sysctl
57228 + option with name "socket_client_gid" is created.
57229 +
57230 +config GRKERNSEC_SOCKET_SERVER
57231 + bool "Deny server sockets to group"
57232 + depends on GRKERNSEC_SOCKET
57233 + help
57234 + If you say Y here, you will be able to choose a GID of whose users will
57235 + be unable to run server applications from your machine. If the sysctl
57236 + option is enabled, a sysctl option with name "socket_server" is created.
57237 +
57238 +config GRKERNSEC_SOCKET_SERVER_GID
57239 + int "GID to deny server sockets for"
57240 + depends on GRKERNSEC_SOCKET_SERVER
57241 + default 1002
57242 + help
57243 + Here you can choose the GID to disable server socket access for.
57244 + Remember to add the users you want server socket access disabled for to
57245 + the GID specified here. If the sysctl option is enabled, a sysctl
57246 + option with name "socket_server_gid" is created.
57247 +
57248 +endmenu
57249 +menu "Sysctl Support"
57250 +depends on GRKERNSEC && SYSCTL
57251 +
57252 +config GRKERNSEC_SYSCTL
57253 + bool "Sysctl support"
57254 + default y if GRKERNSEC_CONFIG_AUTO
57255 + help
57256 + If you say Y here, you will be able to change the options that
57257 + grsecurity runs with at bootup, without having to recompile your
57258 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57259 + to enable (1) or disable (0) various features. All the sysctl entries
57260 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57261 + All features enabled in the kernel configuration are disabled at boot
57262 + if you do not say Y to the "Turn on features by default" option.
57263 + All options should be set at startup, and the grsec_lock entry should
57264 + be set to a non-zero value after all the options are set.
57265 + *THIS IS EXTREMELY IMPORTANT*
57266 +
57267 +config GRKERNSEC_SYSCTL_DISTRO
57268 + bool "Extra sysctl support for distro makers (READ HELP)"
57269 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57270 + help
57271 + If you say Y here, additional sysctl options will be created
57272 + for features that affect processes running as root. Therefore,
57273 + it is critical when using this option that the grsec_lock entry be
57274 + enabled after boot. Only distros with prebuilt kernel packages
57275 + with this option enabled that can ensure grsec_lock is enabled
57276 + after boot should use this option.
57277 + *Failure to set grsec_lock after boot makes all grsec features
57278 + this option covers useless*
57279 +
57280 + Currently this option creates the following sysctl entries:
57281 + "Disable Privileged I/O": "disable_priv_io"
57282 +
57283 +config GRKERNSEC_SYSCTL_ON
57284 + bool "Turn on features by default"
57285 + default y if GRKERNSEC_CONFIG_AUTO
57286 + depends on GRKERNSEC_SYSCTL
57287 + help
57288 + If you say Y here, instead of having all features enabled in the
57289 + kernel configuration disabled at boot time, the features will be
57290 + enabled at boot time. It is recommended you say Y here unless
57291 + there is some reason you would want all sysctl-tunable features to
57292 + be disabled by default. As mentioned elsewhere, it is important
57293 + to enable the grsec_lock entry once you have finished modifying
57294 + the sysctl entries.
57295 +
57296 +endmenu
57297 +menu "Logging Options"
57298 +depends on GRKERNSEC
57299 +
57300 +config GRKERNSEC_FLOODTIME
57301 + int "Seconds in between log messages (minimum)"
57302 + default 10
57303 + help
57304 + This option allows you to enforce the number of seconds between
57305 + grsecurity log messages. The default should be suitable for most
57306 + people, however, if you choose to change it, choose a value small enough
57307 + to allow informative logs to be produced, but large enough to
57308 + prevent flooding.
57309 +
57310 +config GRKERNSEC_FLOODBURST
57311 + int "Number of messages in a burst (maximum)"
57312 + default 6
57313 + help
57314 + This option allows you to choose the maximum number of messages allowed
57315 + within the flood time interval you chose in a separate option. The
57316 + default should be suitable for most people, however if you find that
57317 + many of your logs are being interpreted as flooding, you may want to
57318 + raise this value.
57319 +
57320 +endmenu
57321 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
57322 new file mode 100644
57323 index 0000000..1b9afa9
57324 --- /dev/null
57325 +++ b/grsecurity/Makefile
57326 @@ -0,0 +1,38 @@
57327 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
57328 +# during 2001-2009 it has been completely redesigned by Brad Spengler
57329 +# into an RBAC system
57330 +#
57331 +# All code in this directory and various hooks inserted throughout the kernel
57332 +# are copyright Brad Spengler - Open Source Security, Inc., and released
57333 +# under the GPL v2 or higher
57334 +
57335 +KBUILD_CFLAGS += -Werror
57336 +
57337 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
57338 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
57339 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
57340 +
57341 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
57342 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
57343 + gracl_learn.o grsec_log.o
57344 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
57345 +
57346 +ifdef CONFIG_NET
57347 +obj-y += grsec_sock.o
57348 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
57349 +endif
57350 +
57351 +ifndef CONFIG_GRKERNSEC
57352 +obj-y += grsec_disabled.o
57353 +endif
57354 +
57355 +ifdef CONFIG_GRKERNSEC_HIDESYM
57356 +extra-y := grsec_hidesym.o
57357 +$(obj)/grsec_hidesym.o:
57358 + @-chmod -f 500 /boot
57359 + @-chmod -f 500 /lib/modules
57360 + @-chmod -f 500 /lib64/modules
57361 + @-chmod -f 500 /lib32/modules
57362 + @-chmod -f 700 .
57363 + @echo ' grsec: protected kernel image paths'
57364 +endif
57365 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
57366 new file mode 100644
57367 index 0000000..d0e7b38
57368 --- /dev/null
57369 +++ b/grsecurity/gracl.c
57370 @@ -0,0 +1,4071 @@
57371 +#include <linux/kernel.h>
57372 +#include <linux/module.h>
57373 +#include <linux/sched.h>
57374 +#include <linux/mm.h>
57375 +#include <linux/file.h>
57376 +#include <linux/fs.h>
57377 +#include <linux/namei.h>
57378 +#include <linux/mount.h>
57379 +#include <linux/tty.h>
57380 +#include <linux/proc_fs.h>
57381 +#include <linux/lglock.h>
57382 +#include <linux/slab.h>
57383 +#include <linux/vmalloc.h>
57384 +#include <linux/types.h>
57385 +#include <linux/sysctl.h>
57386 +#include <linux/netdevice.h>
57387 +#include <linux/ptrace.h>
57388 +#include <linux/gracl.h>
57389 +#include <linux/gralloc.h>
57390 +#include <linux/security.h>
57391 +#include <linux/grinternal.h>
57392 +#include <linux/pid_namespace.h>
57393 +#include <linux/stop_machine.h>
57394 +#include <linux/fdtable.h>
57395 +#include <linux/percpu.h>
57396 +#include <linux/lglock.h>
57397 +#include <linux/hugetlb.h>
57398 +#include <linux/posix-timers.h>
57399 +#include "../fs/mount.h"
57400 +
57401 +#include <asm/uaccess.h>
57402 +#include <asm/errno.h>
57403 +#include <asm/mman.h>
57404 +
57405 +extern struct lglock vfsmount_lock;
57406 +
57407 +static struct acl_role_db acl_role_set;
57408 +static struct name_db name_set;
57409 +static struct inodev_db inodev_set;
57410 +
57411 +/* for keeping track of userspace pointers used for subjects, so we
57412 + can share references in the kernel as well
57413 +*/
57414 +
57415 +static struct path real_root;
57416 +
57417 +static struct acl_subj_map_db subj_map_set;
57418 +
57419 +static struct acl_role_label *default_role;
57420 +
57421 +static struct acl_role_label *role_list;
57422 +
57423 +static u16 acl_sp_role_value;
57424 +
57425 +extern char *gr_shared_page[4];
57426 +static DEFINE_MUTEX(gr_dev_mutex);
57427 +DEFINE_RWLOCK(gr_inode_lock);
57428 +
57429 +struct gr_arg *gr_usermode;
57430 +
57431 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
57432 +
57433 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
57434 +extern void gr_clear_learn_entries(void);
57435 +
57436 +unsigned char *gr_system_salt;
57437 +unsigned char *gr_system_sum;
57438 +
57439 +static struct sprole_pw **acl_special_roles = NULL;
57440 +static __u16 num_sprole_pws = 0;
57441 +
57442 +static struct acl_role_label *kernel_role = NULL;
57443 +
57444 +static unsigned int gr_auth_attempts = 0;
57445 +static unsigned long gr_auth_expires = 0UL;
57446 +
57447 +#ifdef CONFIG_NET
57448 +extern struct vfsmount *sock_mnt;
57449 +#endif
57450 +
57451 +extern struct vfsmount *pipe_mnt;
57452 +extern struct vfsmount *shm_mnt;
57453 +
57454 +#ifdef CONFIG_HUGETLBFS
57455 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57456 +#endif
57457 +
57458 +static struct acl_object_label *fakefs_obj_rw;
57459 +static struct acl_object_label *fakefs_obj_rwx;
57460 +
57461 +extern int gr_init_uidset(void);
57462 +extern void gr_free_uidset(void);
57463 +extern void gr_remove_uid(uid_t uid);
57464 +extern int gr_find_uid(uid_t uid);
57465 +
57466 +__inline__ int
57467 +gr_acl_is_enabled(void)
57468 +{
57469 + return (gr_status & GR_READY);
57470 +}
57471 +
57472 +#ifdef CONFIG_BTRFS_FS
57473 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
57474 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
57475 +#endif
57476 +
57477 +static inline dev_t __get_dev(const struct dentry *dentry)
57478 +{
57479 +#ifdef CONFIG_BTRFS_FS
57480 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
57481 + return get_btrfs_dev_from_inode(dentry->d_inode);
57482 + else
57483 +#endif
57484 + return dentry->d_inode->i_sb->s_dev;
57485 +}
57486 +
57487 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57488 +{
57489 + return __get_dev(dentry);
57490 +}
57491 +
57492 +static char gr_task_roletype_to_char(struct task_struct *task)
57493 +{
57494 + switch (task->role->roletype &
57495 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
57496 + GR_ROLE_SPECIAL)) {
57497 + case GR_ROLE_DEFAULT:
57498 + return 'D';
57499 + case GR_ROLE_USER:
57500 + return 'U';
57501 + case GR_ROLE_GROUP:
57502 + return 'G';
57503 + case GR_ROLE_SPECIAL:
57504 + return 'S';
57505 + }
57506 +
57507 + return 'X';
57508 +}
57509 +
57510 +char gr_roletype_to_char(void)
57511 +{
57512 + return gr_task_roletype_to_char(current);
57513 +}
57514 +
57515 +__inline__ int
57516 +gr_acl_tpe_check(void)
57517 +{
57518 + if (unlikely(!(gr_status & GR_READY)))
57519 + return 0;
57520 + if (current->role->roletype & GR_ROLE_TPE)
57521 + return 1;
57522 + else
57523 + return 0;
57524 +}
57525 +
57526 +int
57527 +gr_handle_rawio(const struct inode *inode)
57528 +{
57529 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
57530 + if (inode && S_ISBLK(inode->i_mode) &&
57531 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
57532 + !capable(CAP_SYS_RAWIO))
57533 + return 1;
57534 +#endif
57535 + return 0;
57536 +}
57537 +
57538 +static int
57539 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
57540 +{
57541 + if (likely(lena != lenb))
57542 + return 0;
57543 +
57544 + return !memcmp(a, b, lena);
57545 +}
57546 +
57547 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
57548 +{
57549 + *buflen -= namelen;
57550 + if (*buflen < 0)
57551 + return -ENAMETOOLONG;
57552 + *buffer -= namelen;
57553 + memcpy(*buffer, str, namelen);
57554 + return 0;
57555 +}
57556 +
57557 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
57558 +{
57559 + return prepend(buffer, buflen, name->name, name->len);
57560 +}
57561 +
57562 +static int prepend_path(const struct path *path, struct path *root,
57563 + char **buffer, int *buflen)
57564 +{
57565 + struct dentry *dentry = path->dentry;
57566 + struct vfsmount *vfsmnt = path->mnt;
57567 + struct mount *mnt = real_mount(vfsmnt);
57568 + bool slash = false;
57569 + int error = 0;
57570 +
57571 + while (dentry != root->dentry || vfsmnt != root->mnt) {
57572 + struct dentry * parent;
57573 +
57574 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
57575 + /* Global root? */
57576 + if (!mnt_has_parent(mnt)) {
57577 + goto out;
57578 + }
57579 + dentry = mnt->mnt_mountpoint;
57580 + mnt = mnt->mnt_parent;
57581 + vfsmnt = &mnt->mnt;
57582 + continue;
57583 + }
57584 + parent = dentry->d_parent;
57585 + prefetch(parent);
57586 + spin_lock(&dentry->d_lock);
57587 + error = prepend_name(buffer, buflen, &dentry->d_name);
57588 + spin_unlock(&dentry->d_lock);
57589 + if (!error)
57590 + error = prepend(buffer, buflen, "/", 1);
57591 + if (error)
57592 + break;
57593 +
57594 + slash = true;
57595 + dentry = parent;
57596 + }
57597 +
57598 +out:
57599 + if (!error && !slash)
57600 + error = prepend(buffer, buflen, "/", 1);
57601 +
57602 + return error;
57603 +}
57604 +
57605 +/* this must be called with vfsmount_lock and rename_lock held */
57606 +
57607 +static char *__our_d_path(const struct path *path, struct path *root,
57608 + char *buf, int buflen)
57609 +{
57610 + char *res = buf + buflen;
57611 + int error;
57612 +
57613 + prepend(&res, &buflen, "\0", 1);
57614 + error = prepend_path(path, root, &res, &buflen);
57615 + if (error)
57616 + return ERR_PTR(error);
57617 +
57618 + return res;
57619 +}
57620 +
57621 +static char *
57622 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
57623 +{
57624 + char *retval;
57625 +
57626 + retval = __our_d_path(path, root, buf, buflen);
57627 + if (unlikely(IS_ERR(retval)))
57628 + retval = strcpy(buf, "<path too long>");
57629 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
57630 + retval[1] = '\0';
57631 +
57632 + return retval;
57633 +}
57634 +
57635 +static char *
57636 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57637 + char *buf, int buflen)
57638 +{
57639 + struct path path;
57640 + char *res;
57641 +
57642 + path.dentry = (struct dentry *)dentry;
57643 + path.mnt = (struct vfsmount *)vfsmnt;
57644 +
57645 + /* we can use real_root.dentry, real_root.mnt, because this is only called
57646 + by the RBAC system */
57647 + res = gen_full_path(&path, &real_root, buf, buflen);
57648 +
57649 + return res;
57650 +}
57651 +
57652 +static char *
57653 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57654 + char *buf, int buflen)
57655 +{
57656 + char *res;
57657 + struct path path;
57658 + struct path root;
57659 + struct task_struct *reaper = init_pid_ns.child_reaper;
57660 +
57661 + path.dentry = (struct dentry *)dentry;
57662 + path.mnt = (struct vfsmount *)vfsmnt;
57663 +
57664 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
57665 + get_fs_root(reaper->fs, &root);
57666 +
57667 + br_read_lock(&vfsmount_lock);
57668 + write_seqlock(&rename_lock);
57669 + res = gen_full_path(&path, &root, buf, buflen);
57670 + write_sequnlock(&rename_lock);
57671 + br_read_unlock(&vfsmount_lock);
57672 +
57673 + path_put(&root);
57674 + return res;
57675 +}
57676 +
57677 +static char *
57678 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57679 +{
57680 + char *ret;
57681 + br_read_lock(&vfsmount_lock);
57682 + write_seqlock(&rename_lock);
57683 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57684 + PAGE_SIZE);
57685 + write_sequnlock(&rename_lock);
57686 + br_read_unlock(&vfsmount_lock);
57687 + return ret;
57688 +}
57689 +
57690 +static char *
57691 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57692 +{
57693 + char *ret;
57694 + char *buf;
57695 + int buflen;
57696 +
57697 + br_read_lock(&vfsmount_lock);
57698 + write_seqlock(&rename_lock);
57699 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
57700 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
57701 + buflen = (int)(ret - buf);
57702 + if (buflen >= 5)
57703 + prepend(&ret, &buflen, "/proc", 5);
57704 + else
57705 + ret = strcpy(buf, "<path too long>");
57706 + write_sequnlock(&rename_lock);
57707 + br_read_unlock(&vfsmount_lock);
57708 + return ret;
57709 +}
57710 +
57711 +char *
57712 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
57713 +{
57714 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57715 + PAGE_SIZE);
57716 +}
57717 +
57718 +char *
57719 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
57720 +{
57721 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
57722 + PAGE_SIZE);
57723 +}
57724 +
57725 +char *
57726 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
57727 +{
57728 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
57729 + PAGE_SIZE);
57730 +}
57731 +
57732 +char *
57733 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
57734 +{
57735 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
57736 + PAGE_SIZE);
57737 +}
57738 +
57739 +char *
57740 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
57741 +{
57742 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
57743 + PAGE_SIZE);
57744 +}
57745 +
57746 +__inline__ __u32
57747 +to_gr_audit(const __u32 reqmode)
57748 +{
57749 + /* masks off auditable permission flags, then shifts them to create
57750 + auditing flags, and adds the special case of append auditing if
57751 + we're requesting write */
57752 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
57753 +}
57754 +
57755 +struct acl_subject_label *
57756 +lookup_subject_map(const struct acl_subject_label *userp)
57757 +{
57758 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
57759 + struct subject_map *match;
57760 +
57761 + match = subj_map_set.s_hash[index];
57762 +
57763 + while (match && match->user != userp)
57764 + match = match->next;
57765 +
57766 + if (match != NULL)
57767 + return match->kernel;
57768 + else
57769 + return NULL;
57770 +}
57771 +
57772 +static void
57773 +insert_subj_map_entry(struct subject_map *subjmap)
57774 +{
57775 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
57776 + struct subject_map **curr;
57777 +
57778 + subjmap->prev = NULL;
57779 +
57780 + curr = &subj_map_set.s_hash[index];
57781 + if (*curr != NULL)
57782 + (*curr)->prev = subjmap;
57783 +
57784 + subjmap->next = *curr;
57785 + *curr = subjmap;
57786 +
57787 + return;
57788 +}
57789 +
57790 +static struct acl_role_label *
57791 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
57792 + const gid_t gid)
57793 +{
57794 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
57795 + struct acl_role_label *match;
57796 + struct role_allowed_ip *ipp;
57797 + unsigned int x;
57798 + u32 curr_ip = task->signal->curr_ip;
57799 +
57800 + task->signal->saved_ip = curr_ip;
57801 +
57802 + match = acl_role_set.r_hash[index];
57803 +
57804 + while (match) {
57805 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
57806 + for (x = 0; x < match->domain_child_num; x++) {
57807 + if (match->domain_children[x] == uid)
57808 + goto found;
57809 + }
57810 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
57811 + break;
57812 + match = match->next;
57813 + }
57814 +found:
57815 + if (match == NULL) {
57816 + try_group:
57817 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
57818 + match = acl_role_set.r_hash[index];
57819 +
57820 + while (match) {
57821 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
57822 + for (x = 0; x < match->domain_child_num; x++) {
57823 + if (match->domain_children[x] == gid)
57824 + goto found2;
57825 + }
57826 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
57827 + break;
57828 + match = match->next;
57829 + }
57830 +found2:
57831 + if (match == NULL)
57832 + match = default_role;
57833 + if (match->allowed_ips == NULL)
57834 + return match;
57835 + else {
57836 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
57837 + if (likely
57838 + ((ntohl(curr_ip) & ipp->netmask) ==
57839 + (ntohl(ipp->addr) & ipp->netmask)))
57840 + return match;
57841 + }
57842 + match = default_role;
57843 + }
57844 + } else if (match->allowed_ips == NULL) {
57845 + return match;
57846 + } else {
57847 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
57848 + if (likely
57849 + ((ntohl(curr_ip) & ipp->netmask) ==
57850 + (ntohl(ipp->addr) & ipp->netmask)))
57851 + return match;
57852 + }
57853 + goto try_group;
57854 + }
57855 +
57856 + return match;
57857 +}
57858 +
57859 +struct acl_subject_label *
57860 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
57861 + const struct acl_role_label *role)
57862 +{
57863 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
57864 + struct acl_subject_label *match;
57865 +
57866 + match = role->subj_hash[index];
57867 +
57868 + while (match && (match->inode != ino || match->device != dev ||
57869 + (match->mode & GR_DELETED))) {
57870 + match = match->next;
57871 + }
57872 +
57873 + if (match && !(match->mode & GR_DELETED))
57874 + return match;
57875 + else
57876 + return NULL;
57877 +}
57878 +
57879 +struct acl_subject_label *
57880 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
57881 + const struct acl_role_label *role)
57882 +{
57883 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
57884 + struct acl_subject_label *match;
57885 +
57886 + match = role->subj_hash[index];
57887 +
57888 + while (match && (match->inode != ino || match->device != dev ||
57889 + !(match->mode & GR_DELETED))) {
57890 + match = match->next;
57891 + }
57892 +
57893 + if (match && (match->mode & GR_DELETED))
57894 + return match;
57895 + else
57896 + return NULL;
57897 +}
57898 +
57899 +static struct acl_object_label *
57900 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
57901 + const struct acl_subject_label *subj)
57902 +{
57903 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
57904 + struct acl_object_label *match;
57905 +
57906 + match = subj->obj_hash[index];
57907 +
57908 + while (match && (match->inode != ino || match->device != dev ||
57909 + (match->mode & GR_DELETED))) {
57910 + match = match->next;
57911 + }
57912 +
57913 + if (match && !(match->mode & GR_DELETED))
57914 + return match;
57915 + else
57916 + return NULL;
57917 +}
57918 +
57919 +static struct acl_object_label *
57920 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
57921 + const struct acl_subject_label *subj)
57922 +{
57923 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
57924 + struct acl_object_label *match;
57925 +
57926 + match = subj->obj_hash[index];
57927 +
57928 + while (match && (match->inode != ino || match->device != dev ||
57929 + !(match->mode & GR_DELETED))) {
57930 + match = match->next;
57931 + }
57932 +
57933 + if (match && (match->mode & GR_DELETED))
57934 + return match;
57935 +
57936 + match = subj->obj_hash[index];
57937 +
57938 + while (match && (match->inode != ino || match->device != dev ||
57939 + (match->mode & GR_DELETED))) {
57940 + match = match->next;
57941 + }
57942 +
57943 + if (match && !(match->mode & GR_DELETED))
57944 + return match;
57945 + else
57946 + return NULL;
57947 +}
57948 +
57949 +static struct name_entry *
57950 +lookup_name_entry(const char *name)
57951 +{
57952 + unsigned int len = strlen(name);
57953 + unsigned int key = full_name_hash(name, len);
57954 + unsigned int index = key % name_set.n_size;
57955 + struct name_entry *match;
57956 +
57957 + match = name_set.n_hash[index];
57958 +
57959 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
57960 + match = match->next;
57961 +
57962 + return match;
57963 +}
57964 +
57965 +static struct name_entry *
57966 +lookup_name_entry_create(const char *name)
57967 +{
57968 + unsigned int len = strlen(name);
57969 + unsigned int key = full_name_hash(name, len);
57970 + unsigned int index = key % name_set.n_size;
57971 + struct name_entry *match;
57972 +
57973 + match = name_set.n_hash[index];
57974 +
57975 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
57976 + !match->deleted))
57977 + match = match->next;
57978 +
57979 + if (match && match->deleted)
57980 + return match;
57981 +
57982 + match = name_set.n_hash[index];
57983 +
57984 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
57985 + match->deleted))
57986 + match = match->next;
57987 +
57988 + if (match && !match->deleted)
57989 + return match;
57990 + else
57991 + return NULL;
57992 +}
57993 +
57994 +static struct inodev_entry *
57995 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
57996 +{
57997 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
57998 + struct inodev_entry *match;
57999 +
58000 + match = inodev_set.i_hash[index];
58001 +
58002 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58003 + match = match->next;
58004 +
58005 + return match;
58006 +}
58007 +
58008 +static void
58009 +insert_inodev_entry(struct inodev_entry *entry)
58010 +{
58011 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58012 + inodev_set.i_size);
58013 + struct inodev_entry **curr;
58014 +
58015 + entry->prev = NULL;
58016 +
58017 + curr = &inodev_set.i_hash[index];
58018 + if (*curr != NULL)
58019 + (*curr)->prev = entry;
58020 +
58021 + entry->next = *curr;
58022 + *curr = entry;
58023 +
58024 + return;
58025 +}
58026 +
58027 +static void
58028 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58029 +{
58030 + unsigned int index =
58031 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58032 + struct acl_role_label **curr;
58033 + struct acl_role_label *tmp, *tmp2;
58034 +
58035 + curr = &acl_role_set.r_hash[index];
58036 +
58037 + /* simple case, slot is empty, just set it to our role */
58038 + if (*curr == NULL) {
58039 + *curr = role;
58040 + } else {
58041 + /* example:
58042 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58043 + 2 -> 3
58044 + */
58045 + /* first check to see if we can already be reached via this slot */
58046 + tmp = *curr;
58047 + while (tmp && tmp != role)
58048 + tmp = tmp->next;
58049 + if (tmp == role) {
58050 + /* we don't need to add ourselves to this slot's chain */
58051 + return;
58052 + }
58053 + /* we need to add ourselves to this chain, two cases */
58054 + if (role->next == NULL) {
58055 + /* simple case, append the current chain to our role */
58056 + role->next = *curr;
58057 + *curr = role;
58058 + } else {
58059 + /* 1 -> 2 -> 3 -> 4
58060 + 2 -> 3 -> 4
58061 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58062 + */
58063 + /* trickier case: walk our role's chain until we find
58064 + the role for the start of the current slot's chain */
58065 + tmp = role;
58066 + tmp2 = *curr;
58067 + while (tmp->next && tmp->next != tmp2)
58068 + tmp = tmp->next;
58069 + if (tmp->next == tmp2) {
58070 + /* from example above, we found 3, so just
58071 + replace this slot's chain with ours */
58072 + *curr = role;
58073 + } else {
58074 + /* we didn't find a subset of our role's chain
58075 + in the current slot's chain, so append their
58076 + chain to ours, and set us as the first role in
58077 + the slot's chain
58078 +
58079 + we could fold this case with the case above,
58080 + but making it explicit for clarity
58081 + */
58082 + tmp->next = tmp2;
58083 + *curr = role;
58084 + }
58085 + }
58086 + }
58087 +
58088 + return;
58089 +}
58090 +
58091 +static void
58092 +insert_acl_role_label(struct acl_role_label *role)
58093 +{
58094 + int i;
58095 +
58096 + if (role_list == NULL) {
58097 + role_list = role;
58098 + role->prev = NULL;
58099 + } else {
58100 + role->prev = role_list;
58101 + role_list = role;
58102 + }
58103 +
58104 + /* used for hash chains */
58105 + role->next = NULL;
58106 +
58107 + if (role->roletype & GR_ROLE_DOMAIN) {
58108 + for (i = 0; i < role->domain_child_num; i++)
58109 + __insert_acl_role_label(role, role->domain_children[i]);
58110 + } else
58111 + __insert_acl_role_label(role, role->uidgid);
58112 +}
58113 +
58114 +static int
58115 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58116 +{
58117 + struct name_entry **curr, *nentry;
58118 + struct inodev_entry *ientry;
58119 + unsigned int len = strlen(name);
58120 + unsigned int key = full_name_hash(name, len);
58121 + unsigned int index = key % name_set.n_size;
58122 +
58123 + curr = &name_set.n_hash[index];
58124 +
58125 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58126 + curr = &((*curr)->next);
58127 +
58128 + if (*curr != NULL)
58129 + return 1;
58130 +
58131 + nentry = acl_alloc(sizeof (struct name_entry));
58132 + if (nentry == NULL)
58133 + return 0;
58134 + ientry = acl_alloc(sizeof (struct inodev_entry));
58135 + if (ientry == NULL)
58136 + return 0;
58137 + ientry->nentry = nentry;
58138 +
58139 + nentry->key = key;
58140 + nentry->name = name;
58141 + nentry->inode = inode;
58142 + nentry->device = device;
58143 + nentry->len = len;
58144 + nentry->deleted = deleted;
58145 +
58146 + nentry->prev = NULL;
58147 + curr = &name_set.n_hash[index];
58148 + if (*curr != NULL)
58149 + (*curr)->prev = nentry;
58150 + nentry->next = *curr;
58151 + *curr = nentry;
58152 +
58153 + /* insert us into the table searchable by inode/dev */
58154 + insert_inodev_entry(ientry);
58155 +
58156 + return 1;
58157 +}
58158 +
58159 +static void
58160 +insert_acl_obj_label(struct acl_object_label *obj,
58161 + struct acl_subject_label *subj)
58162 +{
58163 + unsigned int index =
58164 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58165 + struct acl_object_label **curr;
58166 +
58167 +
58168 + obj->prev = NULL;
58169 +
58170 + curr = &subj->obj_hash[index];
58171 + if (*curr != NULL)
58172 + (*curr)->prev = obj;
58173 +
58174 + obj->next = *curr;
58175 + *curr = obj;
58176 +
58177 + return;
58178 +}
58179 +
58180 +static void
58181 +insert_acl_subj_label(struct acl_subject_label *obj,
58182 + struct acl_role_label *role)
58183 +{
58184 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58185 + struct acl_subject_label **curr;
58186 +
58187 + obj->prev = NULL;
58188 +
58189 + curr = &role->subj_hash[index];
58190 + if (*curr != NULL)
58191 + (*curr)->prev = obj;
58192 +
58193 + obj->next = *curr;
58194 + *curr = obj;
58195 +
58196 + return;
58197 +}
58198 +
58199 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58200 +
58201 +static void *
58202 +create_table(__u32 * len, int elementsize)
58203 +{
58204 + unsigned int table_sizes[] = {
58205 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58206 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58207 + 4194301, 8388593, 16777213, 33554393, 67108859
58208 + };
58209 + void *newtable = NULL;
58210 + unsigned int pwr = 0;
58211 +
58212 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58213 + table_sizes[pwr] <= *len)
58214 + pwr++;
58215 +
58216 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58217 + return newtable;
58218 +
58219 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58220 + newtable =
58221 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58222 + else
58223 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58224 +
58225 + *len = table_sizes[pwr];
58226 +
58227 + return newtable;
58228 +}
58229 +
58230 +static int
58231 +init_variables(const struct gr_arg *arg)
58232 +{
58233 + struct task_struct *reaper = init_pid_ns.child_reaper;
58234 + unsigned int stacksize;
58235 +
58236 + subj_map_set.s_size = arg->role_db.num_subjects;
58237 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58238 + name_set.n_size = arg->role_db.num_objects;
58239 + inodev_set.i_size = arg->role_db.num_objects;
58240 +
58241 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58242 + !name_set.n_size || !inodev_set.i_size)
58243 + return 1;
58244 +
58245 + if (!gr_init_uidset())
58246 + return 1;
58247 +
58248 + /* set up the stack that holds allocation info */
58249 +
58250 + stacksize = arg->role_db.num_pointers + 5;
58251 +
58252 + if (!acl_alloc_stack_init(stacksize))
58253 + return 1;
58254 +
58255 + /* grab reference for the real root dentry and vfsmount */
58256 + get_fs_root(reaper->fs, &real_root);
58257 +
58258 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58259 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58260 +#endif
58261 +
58262 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58263 + if (fakefs_obj_rw == NULL)
58264 + return 1;
58265 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58266 +
58267 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58268 + if (fakefs_obj_rwx == NULL)
58269 + return 1;
58270 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58271 +
58272 + subj_map_set.s_hash =
58273 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58274 + acl_role_set.r_hash =
58275 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58276 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58277 + inodev_set.i_hash =
58278 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58279 +
58280 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58281 + !name_set.n_hash || !inodev_set.i_hash)
58282 + return 1;
58283 +
58284 + memset(subj_map_set.s_hash, 0,
58285 + sizeof(struct subject_map *) * subj_map_set.s_size);
58286 + memset(acl_role_set.r_hash, 0,
58287 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58288 + memset(name_set.n_hash, 0,
58289 + sizeof (struct name_entry *) * name_set.n_size);
58290 + memset(inodev_set.i_hash, 0,
58291 + sizeof (struct inodev_entry *) * inodev_set.i_size);
58292 +
58293 + return 0;
58294 +}
58295 +
58296 +/* free information not needed after startup
58297 + currently contains user->kernel pointer mappings for subjects
58298 +*/
58299 +
58300 +static void
58301 +free_init_variables(void)
58302 +{
58303 + __u32 i;
58304 +
58305 + if (subj_map_set.s_hash) {
58306 + for (i = 0; i < subj_map_set.s_size; i++) {
58307 + if (subj_map_set.s_hash[i]) {
58308 + kfree(subj_map_set.s_hash[i]);
58309 + subj_map_set.s_hash[i] = NULL;
58310 + }
58311 + }
58312 +
58313 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
58314 + PAGE_SIZE)
58315 + kfree(subj_map_set.s_hash);
58316 + else
58317 + vfree(subj_map_set.s_hash);
58318 + }
58319 +
58320 + return;
58321 +}
58322 +
58323 +static void
58324 +free_variables(void)
58325 +{
58326 + struct acl_subject_label *s;
58327 + struct acl_role_label *r;
58328 + struct task_struct *task, *task2;
58329 + unsigned int x;
58330 +
58331 + gr_clear_learn_entries();
58332 +
58333 + read_lock(&tasklist_lock);
58334 + do_each_thread(task2, task) {
58335 + task->acl_sp_role = 0;
58336 + task->acl_role_id = 0;
58337 + task->acl = NULL;
58338 + task->role = NULL;
58339 + } while_each_thread(task2, task);
58340 + read_unlock(&tasklist_lock);
58341 +
58342 + /* release the reference to the real root dentry and vfsmount */
58343 + path_put(&real_root);
58344 + memset(&real_root, 0, sizeof(real_root));
58345 +
58346 + /* free all object hash tables */
58347 +
58348 + FOR_EACH_ROLE_START(r)
58349 + if (r->subj_hash == NULL)
58350 + goto next_role;
58351 + FOR_EACH_SUBJECT_START(r, s, x)
58352 + if (s->obj_hash == NULL)
58353 + break;
58354 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58355 + kfree(s->obj_hash);
58356 + else
58357 + vfree(s->obj_hash);
58358 + FOR_EACH_SUBJECT_END(s, x)
58359 + FOR_EACH_NESTED_SUBJECT_START(r, s)
58360 + if (s->obj_hash == NULL)
58361 + break;
58362 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58363 + kfree(s->obj_hash);
58364 + else
58365 + vfree(s->obj_hash);
58366 + FOR_EACH_NESTED_SUBJECT_END(s)
58367 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
58368 + kfree(r->subj_hash);
58369 + else
58370 + vfree(r->subj_hash);
58371 + r->subj_hash = NULL;
58372 +next_role:
58373 + FOR_EACH_ROLE_END(r)
58374 +
58375 + acl_free_all();
58376 +
58377 + if (acl_role_set.r_hash) {
58378 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
58379 + PAGE_SIZE)
58380 + kfree(acl_role_set.r_hash);
58381 + else
58382 + vfree(acl_role_set.r_hash);
58383 + }
58384 + if (name_set.n_hash) {
58385 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
58386 + PAGE_SIZE)
58387 + kfree(name_set.n_hash);
58388 + else
58389 + vfree(name_set.n_hash);
58390 + }
58391 +
58392 + if (inodev_set.i_hash) {
58393 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
58394 + PAGE_SIZE)
58395 + kfree(inodev_set.i_hash);
58396 + else
58397 + vfree(inodev_set.i_hash);
58398 + }
58399 +
58400 + gr_free_uidset();
58401 +
58402 + memset(&name_set, 0, sizeof (struct name_db));
58403 + memset(&inodev_set, 0, sizeof (struct inodev_db));
58404 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
58405 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
58406 +
58407 + default_role = NULL;
58408 + kernel_role = NULL;
58409 + role_list = NULL;
58410 +
58411 + return;
58412 +}
58413 +
58414 +static __u32
58415 +count_user_objs(struct acl_object_label *userp)
58416 +{
58417 + struct acl_object_label o_tmp;
58418 + __u32 num = 0;
58419 +
58420 + while (userp) {
58421 + if (copy_from_user(&o_tmp, userp,
58422 + sizeof (struct acl_object_label)))
58423 + break;
58424 +
58425 + userp = o_tmp.prev;
58426 + num++;
58427 + }
58428 +
58429 + return num;
58430 +}
58431 +
58432 +static struct acl_subject_label *
58433 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
58434 +
58435 +static int
58436 +copy_user_glob(struct acl_object_label *obj)
58437 +{
58438 + struct acl_object_label *g_tmp, **guser;
58439 + unsigned int len;
58440 + char *tmp;
58441 +
58442 + if (obj->globbed == NULL)
58443 + return 0;
58444 +
58445 + guser = &obj->globbed;
58446 + while (*guser) {
58447 + g_tmp = (struct acl_object_label *)
58448 + acl_alloc(sizeof (struct acl_object_label));
58449 + if (g_tmp == NULL)
58450 + return -ENOMEM;
58451 +
58452 + if (copy_from_user(g_tmp, *guser,
58453 + sizeof (struct acl_object_label)))
58454 + return -EFAULT;
58455 +
58456 + len = strnlen_user(g_tmp->filename, PATH_MAX);
58457 +
58458 + if (!len || len >= PATH_MAX)
58459 + return -EINVAL;
58460 +
58461 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58462 + return -ENOMEM;
58463 +
58464 + if (copy_from_user(tmp, g_tmp->filename, len))
58465 + return -EFAULT;
58466 + tmp[len-1] = '\0';
58467 + g_tmp->filename = tmp;
58468 +
58469 + *guser = g_tmp;
58470 + guser = &(g_tmp->next);
58471 + }
58472 +
58473 + return 0;
58474 +}
58475 +
58476 +static int
58477 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
58478 + struct acl_role_label *role)
58479 +{
58480 + struct acl_object_label *o_tmp;
58481 + unsigned int len;
58482 + int ret;
58483 + char *tmp;
58484 +
58485 + while (userp) {
58486 + if ((o_tmp = (struct acl_object_label *)
58487 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
58488 + return -ENOMEM;
58489 +
58490 + if (copy_from_user(o_tmp, userp,
58491 + sizeof (struct acl_object_label)))
58492 + return -EFAULT;
58493 +
58494 + userp = o_tmp->prev;
58495 +
58496 + len = strnlen_user(o_tmp->filename, PATH_MAX);
58497 +
58498 + if (!len || len >= PATH_MAX)
58499 + return -EINVAL;
58500 +
58501 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58502 + return -ENOMEM;
58503 +
58504 + if (copy_from_user(tmp, o_tmp->filename, len))
58505 + return -EFAULT;
58506 + tmp[len-1] = '\0';
58507 + o_tmp->filename = tmp;
58508 +
58509 + insert_acl_obj_label(o_tmp, subj);
58510 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
58511 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
58512 + return -ENOMEM;
58513 +
58514 + ret = copy_user_glob(o_tmp);
58515 + if (ret)
58516 + return ret;
58517 +
58518 + if (o_tmp->nested) {
58519 + int already_copied;
58520 +
58521 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
58522 + if (IS_ERR(o_tmp->nested))
58523 + return PTR_ERR(o_tmp->nested);
58524 +
58525 + /* insert into nested subject list if we haven't copied this one yet
58526 + to prevent duplicate entries */
58527 + if (!already_copied) {
58528 + o_tmp->nested->next = role->hash->first;
58529 + role->hash->first = o_tmp->nested;
58530 + }
58531 + }
58532 + }
58533 +
58534 + return 0;
58535 +}
58536 +
58537 +static __u32
58538 +count_user_subjs(struct acl_subject_label *userp)
58539 +{
58540 + struct acl_subject_label s_tmp;
58541 + __u32 num = 0;
58542 +
58543 + while (userp) {
58544 + if (copy_from_user(&s_tmp, userp,
58545 + sizeof (struct acl_subject_label)))
58546 + break;
58547 +
58548 + userp = s_tmp.prev;
58549 + }
58550 +
58551 + return num;
58552 +}
58553 +
58554 +static int
58555 +copy_user_allowedips(struct acl_role_label *rolep)
58556 +{
58557 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
58558 +
58559 + ruserip = rolep->allowed_ips;
58560 +
58561 + while (ruserip) {
58562 + rlast = rtmp;
58563 +
58564 + if ((rtmp = (struct role_allowed_ip *)
58565 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
58566 + return -ENOMEM;
58567 +
58568 + if (copy_from_user(rtmp, ruserip,
58569 + sizeof (struct role_allowed_ip)))
58570 + return -EFAULT;
58571 +
58572 + ruserip = rtmp->prev;
58573 +
58574 + if (!rlast) {
58575 + rtmp->prev = NULL;
58576 + rolep->allowed_ips = rtmp;
58577 + } else {
58578 + rlast->next = rtmp;
58579 + rtmp->prev = rlast;
58580 + }
58581 +
58582 + if (!ruserip)
58583 + rtmp->next = NULL;
58584 + }
58585 +
58586 + return 0;
58587 +}
58588 +
58589 +static int
58590 +copy_user_transitions(struct acl_role_label *rolep)
58591 +{
58592 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
58593 +
58594 + unsigned int len;
58595 + char *tmp;
58596 +
58597 + rusertp = rolep->transitions;
58598 +
58599 + while (rusertp) {
58600 + rlast = rtmp;
58601 +
58602 + if ((rtmp = (struct role_transition *)
58603 + acl_alloc(sizeof (struct role_transition))) == NULL)
58604 + return -ENOMEM;
58605 +
58606 + if (copy_from_user(rtmp, rusertp,
58607 + sizeof (struct role_transition)))
58608 + return -EFAULT;
58609 +
58610 + rusertp = rtmp->prev;
58611 +
58612 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
58613 +
58614 + if (!len || len >= GR_SPROLE_LEN)
58615 + return -EINVAL;
58616 +
58617 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58618 + return -ENOMEM;
58619 +
58620 + if (copy_from_user(tmp, rtmp->rolename, len))
58621 + return -EFAULT;
58622 + tmp[len-1] = '\0';
58623 + rtmp->rolename = tmp;
58624 +
58625 + if (!rlast) {
58626 + rtmp->prev = NULL;
58627 + rolep->transitions = rtmp;
58628 + } else {
58629 + rlast->next = rtmp;
58630 + rtmp->prev = rlast;
58631 + }
58632 +
58633 + if (!rusertp)
58634 + rtmp->next = NULL;
58635 + }
58636 +
58637 + return 0;
58638 +}
58639 +
58640 +static struct acl_subject_label *
58641 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
58642 +{
58643 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
58644 + unsigned int len;
58645 + char *tmp;
58646 + __u32 num_objs;
58647 + struct acl_ip_label **i_tmp, *i_utmp2;
58648 + struct gr_hash_struct ghash;
58649 + struct subject_map *subjmap;
58650 + unsigned int i_num;
58651 + int err;
58652 +
58653 + if (already_copied != NULL)
58654 + *already_copied = 0;
58655 +
58656 + s_tmp = lookup_subject_map(userp);
58657 +
58658 + /* we've already copied this subject into the kernel, just return
58659 + the reference to it, and don't copy it over again
58660 + */
58661 + if (s_tmp) {
58662 + if (already_copied != NULL)
58663 + *already_copied = 1;
58664 + return(s_tmp);
58665 + }
58666 +
58667 + if ((s_tmp = (struct acl_subject_label *)
58668 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
58669 + return ERR_PTR(-ENOMEM);
58670 +
58671 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
58672 + if (subjmap == NULL)
58673 + return ERR_PTR(-ENOMEM);
58674 +
58675 + subjmap->user = userp;
58676 + subjmap->kernel = s_tmp;
58677 + insert_subj_map_entry(subjmap);
58678 +
58679 + if (copy_from_user(s_tmp, userp,
58680 + sizeof (struct acl_subject_label)))
58681 + return ERR_PTR(-EFAULT);
58682 +
58683 + len = strnlen_user(s_tmp->filename, PATH_MAX);
58684 +
58685 + if (!len || len >= PATH_MAX)
58686 + return ERR_PTR(-EINVAL);
58687 +
58688 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58689 + return ERR_PTR(-ENOMEM);
58690 +
58691 + if (copy_from_user(tmp, s_tmp->filename, len))
58692 + return ERR_PTR(-EFAULT);
58693 + tmp[len-1] = '\0';
58694 + s_tmp->filename = tmp;
58695 +
58696 + if (!strcmp(s_tmp->filename, "/"))
58697 + role->root_label = s_tmp;
58698 +
58699 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
58700 + return ERR_PTR(-EFAULT);
58701 +
58702 + /* copy user and group transition tables */
58703 +
58704 + if (s_tmp->user_trans_num) {
58705 + uid_t *uidlist;
58706 +
58707 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
58708 + if (uidlist == NULL)
58709 + return ERR_PTR(-ENOMEM);
58710 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
58711 + return ERR_PTR(-EFAULT);
58712 +
58713 + s_tmp->user_transitions = uidlist;
58714 + }
58715 +
58716 + if (s_tmp->group_trans_num) {
58717 + gid_t *gidlist;
58718 +
58719 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
58720 + if (gidlist == NULL)
58721 + return ERR_PTR(-ENOMEM);
58722 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
58723 + return ERR_PTR(-EFAULT);
58724 +
58725 + s_tmp->group_transitions = gidlist;
58726 + }
58727 +
58728 + /* set up object hash table */
58729 + num_objs = count_user_objs(ghash.first);
58730 +
58731 + s_tmp->obj_hash_size = num_objs;
58732 + s_tmp->obj_hash =
58733 + (struct acl_object_label **)
58734 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
58735 +
58736 + if (!s_tmp->obj_hash)
58737 + return ERR_PTR(-ENOMEM);
58738 +
58739 + memset(s_tmp->obj_hash, 0,
58740 + s_tmp->obj_hash_size *
58741 + sizeof (struct acl_object_label *));
58742 +
58743 + /* add in objects */
58744 + err = copy_user_objs(ghash.first, s_tmp, role);
58745 +
58746 + if (err)
58747 + return ERR_PTR(err);
58748 +
58749 + /* set pointer for parent subject */
58750 + if (s_tmp->parent_subject) {
58751 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
58752 +
58753 + if (IS_ERR(s_tmp2))
58754 + return s_tmp2;
58755 +
58756 + s_tmp->parent_subject = s_tmp2;
58757 + }
58758 +
58759 + /* add in ip acls */
58760 +
58761 + if (!s_tmp->ip_num) {
58762 + s_tmp->ips = NULL;
58763 + goto insert;
58764 + }
58765 +
58766 + i_tmp =
58767 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
58768 + sizeof (struct acl_ip_label *));
58769 +
58770 + if (!i_tmp)
58771 + return ERR_PTR(-ENOMEM);
58772 +
58773 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
58774 + *(i_tmp + i_num) =
58775 + (struct acl_ip_label *)
58776 + acl_alloc(sizeof (struct acl_ip_label));
58777 + if (!*(i_tmp + i_num))
58778 + return ERR_PTR(-ENOMEM);
58779 +
58780 + if (copy_from_user
58781 + (&i_utmp2, s_tmp->ips + i_num,
58782 + sizeof (struct acl_ip_label *)))
58783 + return ERR_PTR(-EFAULT);
58784 +
58785 + if (copy_from_user
58786 + (*(i_tmp + i_num), i_utmp2,
58787 + sizeof (struct acl_ip_label)))
58788 + return ERR_PTR(-EFAULT);
58789 +
58790 + if ((*(i_tmp + i_num))->iface == NULL)
58791 + continue;
58792 +
58793 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
58794 + if (!len || len >= IFNAMSIZ)
58795 + return ERR_PTR(-EINVAL);
58796 + tmp = acl_alloc(len);
58797 + if (tmp == NULL)
58798 + return ERR_PTR(-ENOMEM);
58799 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
58800 + return ERR_PTR(-EFAULT);
58801 + (*(i_tmp + i_num))->iface = tmp;
58802 + }
58803 +
58804 + s_tmp->ips = i_tmp;
58805 +
58806 +insert:
58807 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
58808 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
58809 + return ERR_PTR(-ENOMEM);
58810 +
58811 + return s_tmp;
58812 +}
58813 +
58814 +static int
58815 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
58816 +{
58817 + struct acl_subject_label s_pre;
58818 + struct acl_subject_label * ret;
58819 + int err;
58820 +
58821 + while (userp) {
58822 + if (copy_from_user(&s_pre, userp,
58823 + sizeof (struct acl_subject_label)))
58824 + return -EFAULT;
58825 +
58826 + ret = do_copy_user_subj(userp, role, NULL);
58827 +
58828 + err = PTR_ERR(ret);
58829 + if (IS_ERR(ret))
58830 + return err;
58831 +
58832 + insert_acl_subj_label(ret, role);
58833 +
58834 + userp = s_pre.prev;
58835 + }
58836 +
58837 + return 0;
58838 +}
58839 +
58840 +static int
58841 +copy_user_acl(struct gr_arg *arg)
58842 +{
58843 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
58844 + struct acl_subject_label *subj_list;
58845 + struct sprole_pw *sptmp;
58846 + struct gr_hash_struct *ghash;
58847 + uid_t *domainlist;
58848 + unsigned int r_num;
58849 + unsigned int len;
58850 + char *tmp;
58851 + int err = 0;
58852 + __u16 i;
58853 + __u32 num_subjs;
58854 +
58855 + /* we need a default and kernel role */
58856 + if (arg->role_db.num_roles < 2)
58857 + return -EINVAL;
58858 +
58859 + /* copy special role authentication info from userspace */
58860 +
58861 + num_sprole_pws = arg->num_sprole_pws;
58862 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
58863 +
58864 + if (!acl_special_roles && num_sprole_pws)
58865 + return -ENOMEM;
58866 +
58867 + for (i = 0; i < num_sprole_pws; i++) {
58868 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
58869 + if (!sptmp)
58870 + return -ENOMEM;
58871 + if (copy_from_user(sptmp, arg->sprole_pws + i,
58872 + sizeof (struct sprole_pw)))
58873 + return -EFAULT;
58874 +
58875 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
58876 +
58877 + if (!len || len >= GR_SPROLE_LEN)
58878 + return -EINVAL;
58879 +
58880 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58881 + return -ENOMEM;
58882 +
58883 + if (copy_from_user(tmp, sptmp->rolename, len))
58884 + return -EFAULT;
58885 +
58886 + tmp[len-1] = '\0';
58887 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58888 + printk(KERN_ALERT "Copying special role %s\n", tmp);
58889 +#endif
58890 + sptmp->rolename = tmp;
58891 + acl_special_roles[i] = sptmp;
58892 + }
58893 +
58894 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
58895 +
58896 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
58897 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
58898 +
58899 + if (!r_tmp)
58900 + return -ENOMEM;
58901 +
58902 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
58903 + sizeof (struct acl_role_label *)))
58904 + return -EFAULT;
58905 +
58906 + if (copy_from_user(r_tmp, r_utmp2,
58907 + sizeof (struct acl_role_label)))
58908 + return -EFAULT;
58909 +
58910 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
58911 +
58912 + if (!len || len >= PATH_MAX)
58913 + return -EINVAL;
58914 +
58915 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58916 + return -ENOMEM;
58917 +
58918 + if (copy_from_user(tmp, r_tmp->rolename, len))
58919 + return -EFAULT;
58920 +
58921 + tmp[len-1] = '\0';
58922 + r_tmp->rolename = tmp;
58923 +
58924 + if (!strcmp(r_tmp->rolename, "default")
58925 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
58926 + default_role = r_tmp;
58927 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
58928 + kernel_role = r_tmp;
58929 + }
58930 +
58931 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
58932 + return -ENOMEM;
58933 +
58934 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
58935 + return -EFAULT;
58936 +
58937 + r_tmp->hash = ghash;
58938 +
58939 + num_subjs = count_user_subjs(r_tmp->hash->first);
58940 +
58941 + r_tmp->subj_hash_size = num_subjs;
58942 + r_tmp->subj_hash =
58943 + (struct acl_subject_label **)
58944 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
58945 +
58946 + if (!r_tmp->subj_hash)
58947 + return -ENOMEM;
58948 +
58949 + err = copy_user_allowedips(r_tmp);
58950 + if (err)
58951 + return err;
58952 +
58953 + /* copy domain info */
58954 + if (r_tmp->domain_children != NULL) {
58955 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
58956 + if (domainlist == NULL)
58957 + return -ENOMEM;
58958 +
58959 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
58960 + return -EFAULT;
58961 +
58962 + r_tmp->domain_children = domainlist;
58963 + }
58964 +
58965 + err = copy_user_transitions(r_tmp);
58966 + if (err)
58967 + return err;
58968 +
58969 + memset(r_tmp->subj_hash, 0,
58970 + r_tmp->subj_hash_size *
58971 + sizeof (struct acl_subject_label *));
58972 +
58973 + /* acquire the list of subjects, then NULL out
58974 + the list prior to parsing the subjects for this role,
58975 + as during this parsing the list is replaced with a list
58976 + of *nested* subjects for the role
58977 + */
58978 + subj_list = r_tmp->hash->first;
58979 +
58980 + /* set nested subject list to null */
58981 + r_tmp->hash->first = NULL;
58982 +
58983 + err = copy_user_subjs(subj_list, r_tmp);
58984 +
58985 + if (err)
58986 + return err;
58987 +
58988 + insert_acl_role_label(r_tmp);
58989 + }
58990 +
58991 + if (default_role == NULL || kernel_role == NULL)
58992 + return -EINVAL;
58993 +
58994 + return err;
58995 +}
58996 +
58997 +static int
58998 +gracl_init(struct gr_arg *args)
58999 +{
59000 + int error = 0;
59001 +
59002 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59003 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59004 +
59005 + if (init_variables(args)) {
59006 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59007 + error = -ENOMEM;
59008 + free_variables();
59009 + goto out;
59010 + }
59011 +
59012 + error = copy_user_acl(args);
59013 + free_init_variables();
59014 + if (error) {
59015 + free_variables();
59016 + goto out;
59017 + }
59018 +
59019 + if ((error = gr_set_acls(0))) {
59020 + free_variables();
59021 + goto out;
59022 + }
59023 +
59024 + pax_open_kernel();
59025 + gr_status |= GR_READY;
59026 + pax_close_kernel();
59027 +
59028 + out:
59029 + return error;
59030 +}
59031 +
59032 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59033 +
59034 +static int
59035 +glob_match(const char *p, const char *n)
59036 +{
59037 + char c;
59038 +
59039 + while ((c = *p++) != '\0') {
59040 + switch (c) {
59041 + case '?':
59042 + if (*n == '\0')
59043 + return 1;
59044 + else if (*n == '/')
59045 + return 1;
59046 + break;
59047 + case '\\':
59048 + if (*n != c)
59049 + return 1;
59050 + break;
59051 + case '*':
59052 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59053 + if (*n == '/')
59054 + return 1;
59055 + else if (c == '?') {
59056 + if (*n == '\0')
59057 + return 1;
59058 + else
59059 + ++n;
59060 + }
59061 + }
59062 + if (c == '\0') {
59063 + return 0;
59064 + } else {
59065 + const char *endp;
59066 +
59067 + if ((endp = strchr(n, '/')) == NULL)
59068 + endp = n + strlen(n);
59069 +
59070 + if (c == '[') {
59071 + for (--p; n < endp; ++n)
59072 + if (!glob_match(p, n))
59073 + return 0;
59074 + } else if (c == '/') {
59075 + while (*n != '\0' && *n != '/')
59076 + ++n;
59077 + if (*n == '/' && !glob_match(p, n + 1))
59078 + return 0;
59079 + } else {
59080 + for (--p; n < endp; ++n)
59081 + if (*n == c && !glob_match(p, n))
59082 + return 0;
59083 + }
59084 +
59085 + return 1;
59086 + }
59087 + case '[':
59088 + {
59089 + int not;
59090 + char cold;
59091 +
59092 + if (*n == '\0' || *n == '/')
59093 + return 1;
59094 +
59095 + not = (*p == '!' || *p == '^');
59096 + if (not)
59097 + ++p;
59098 +
59099 + c = *p++;
59100 + for (;;) {
59101 + unsigned char fn = (unsigned char)*n;
59102 +
59103 + if (c == '\0')
59104 + return 1;
59105 + else {
59106 + if (c == fn)
59107 + goto matched;
59108 + cold = c;
59109 + c = *p++;
59110 +
59111 + if (c == '-' && *p != ']') {
59112 + unsigned char cend = *p++;
59113 +
59114 + if (cend == '\0')
59115 + return 1;
59116 +
59117 + if (cold <= fn && fn <= cend)
59118 + goto matched;
59119 +
59120 + c = *p++;
59121 + }
59122 + }
59123 +
59124 + if (c == ']')
59125 + break;
59126 + }
59127 + if (!not)
59128 + return 1;
59129 + break;
59130 + matched:
59131 + while (c != ']') {
59132 + if (c == '\0')
59133 + return 1;
59134 +
59135 + c = *p++;
59136 + }
59137 + if (not)
59138 + return 1;
59139 + }
59140 + break;
59141 + default:
59142 + if (c != *n)
59143 + return 1;
59144 + }
59145 +
59146 + ++n;
59147 + }
59148 +
59149 + if (*n == '\0')
59150 + return 0;
59151 +
59152 + if (*n == '/')
59153 + return 0;
59154 +
59155 + return 1;
59156 +}
59157 +
59158 +static struct acl_object_label *
59159 +chk_glob_label(struct acl_object_label *globbed,
59160 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59161 +{
59162 + struct acl_object_label *tmp;
59163 +
59164 + if (*path == NULL)
59165 + *path = gr_to_filename_nolock(dentry, mnt);
59166 +
59167 + tmp = globbed;
59168 +
59169 + while (tmp) {
59170 + if (!glob_match(tmp->filename, *path))
59171 + return tmp;
59172 + tmp = tmp->next;
59173 + }
59174 +
59175 + return NULL;
59176 +}
59177 +
59178 +static struct acl_object_label *
59179 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59180 + const ino_t curr_ino, const dev_t curr_dev,
59181 + const struct acl_subject_label *subj, char **path, const int checkglob)
59182 +{
59183 + struct acl_subject_label *tmpsubj;
59184 + struct acl_object_label *retval;
59185 + struct acl_object_label *retval2;
59186 +
59187 + tmpsubj = (struct acl_subject_label *) subj;
59188 + read_lock(&gr_inode_lock);
59189 + do {
59190 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59191 + if (retval) {
59192 + if (checkglob && retval->globbed) {
59193 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59194 + if (retval2)
59195 + retval = retval2;
59196 + }
59197 + break;
59198 + }
59199 + } while ((tmpsubj = tmpsubj->parent_subject));
59200 + read_unlock(&gr_inode_lock);
59201 +
59202 + return retval;
59203 +}
59204 +
59205 +static __inline__ struct acl_object_label *
59206 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59207 + struct dentry *curr_dentry,
59208 + const struct acl_subject_label *subj, char **path, const int checkglob)
59209 +{
59210 + int newglob = checkglob;
59211 + ino_t inode;
59212 + dev_t device;
59213 +
59214 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59215 + as we don't want a / * rule to match instead of the / object
59216 + don't do this for create lookups that call this function though, since they're looking up
59217 + on the parent and thus need globbing checks on all paths
59218 + */
59219 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59220 + newglob = GR_NO_GLOB;
59221 +
59222 + spin_lock(&curr_dentry->d_lock);
59223 + inode = curr_dentry->d_inode->i_ino;
59224 + device = __get_dev(curr_dentry);
59225 + spin_unlock(&curr_dentry->d_lock);
59226 +
59227 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59228 +}
59229 +
59230 +#ifdef CONFIG_HUGETLBFS
59231 +static inline bool
59232 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59233 +{
59234 + int i;
59235 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59236 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59237 + return true;
59238 + }
59239 +
59240 + return false;
59241 +}
59242 +#endif
59243 +
59244 +static struct acl_object_label *
59245 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59246 + const struct acl_subject_label *subj, char *path, const int checkglob)
59247 +{
59248 + struct dentry *dentry = (struct dentry *) l_dentry;
59249 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59250 + struct mount *real_mnt = real_mount(mnt);
59251 + struct acl_object_label *retval;
59252 + struct dentry *parent;
59253 +
59254 + br_read_lock(&vfsmount_lock);
59255 + write_seqlock(&rename_lock);
59256 +
59257 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59258 +#ifdef CONFIG_NET
59259 + mnt == sock_mnt ||
59260 +#endif
59261 +#ifdef CONFIG_HUGETLBFS
59262 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59263 +#endif
59264 + /* ignore Eric Biederman */
59265 + IS_PRIVATE(l_dentry->d_inode))) {
59266 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59267 + goto out;
59268 + }
59269 +
59270 + for (;;) {
59271 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59272 + break;
59273 +
59274 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59275 + if (!mnt_has_parent(real_mnt))
59276 + break;
59277 +
59278 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59279 + if (retval != NULL)
59280 + goto out;
59281 +
59282 + dentry = real_mnt->mnt_mountpoint;
59283 + real_mnt = real_mnt->mnt_parent;
59284 + mnt = &real_mnt->mnt;
59285 + continue;
59286 + }
59287 +
59288 + parent = dentry->d_parent;
59289 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59290 + if (retval != NULL)
59291 + goto out;
59292 +
59293 + dentry = parent;
59294 + }
59295 +
59296 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59297 +
59298 + /* real_root is pinned so we don't have to hold a reference */
59299 + if (retval == NULL)
59300 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
59301 +out:
59302 + write_sequnlock(&rename_lock);
59303 + br_read_unlock(&vfsmount_lock);
59304 +
59305 + BUG_ON(retval == NULL);
59306 +
59307 + return retval;
59308 +}
59309 +
59310 +static __inline__ struct acl_object_label *
59311 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59312 + const struct acl_subject_label *subj)
59313 +{
59314 + char *path = NULL;
59315 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
59316 +}
59317 +
59318 +static __inline__ struct acl_object_label *
59319 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59320 + const struct acl_subject_label *subj)
59321 +{
59322 + char *path = NULL;
59323 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
59324 +}
59325 +
59326 +static __inline__ struct acl_object_label *
59327 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59328 + const struct acl_subject_label *subj, char *path)
59329 +{
59330 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
59331 +}
59332 +
59333 +static struct acl_subject_label *
59334 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59335 + const struct acl_role_label *role)
59336 +{
59337 + struct dentry *dentry = (struct dentry *) l_dentry;
59338 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59339 + struct mount *real_mnt = real_mount(mnt);
59340 + struct acl_subject_label *retval;
59341 + struct dentry *parent;
59342 +
59343 + br_read_lock(&vfsmount_lock);
59344 + write_seqlock(&rename_lock);
59345 +
59346 + for (;;) {
59347 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59348 + break;
59349 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59350 + if (!mnt_has_parent(real_mnt))
59351 + break;
59352 +
59353 + spin_lock(&dentry->d_lock);
59354 + read_lock(&gr_inode_lock);
59355 + retval =
59356 + lookup_acl_subj_label(dentry->d_inode->i_ino,
59357 + __get_dev(dentry), role);
59358 + read_unlock(&gr_inode_lock);
59359 + spin_unlock(&dentry->d_lock);
59360 + if (retval != NULL)
59361 + goto out;
59362 +
59363 + dentry = real_mnt->mnt_mountpoint;
59364 + real_mnt = real_mnt->mnt_parent;
59365 + mnt = &real_mnt->mnt;
59366 + continue;
59367 + }
59368 +
59369 + spin_lock(&dentry->d_lock);
59370 + read_lock(&gr_inode_lock);
59371 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59372 + __get_dev(dentry), role);
59373 + read_unlock(&gr_inode_lock);
59374 + parent = dentry->d_parent;
59375 + spin_unlock(&dentry->d_lock);
59376 +
59377 + if (retval != NULL)
59378 + goto out;
59379 +
59380 + dentry = parent;
59381 + }
59382 +
59383 + spin_lock(&dentry->d_lock);
59384 + read_lock(&gr_inode_lock);
59385 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59386 + __get_dev(dentry), role);
59387 + read_unlock(&gr_inode_lock);
59388 + spin_unlock(&dentry->d_lock);
59389 +
59390 + if (unlikely(retval == NULL)) {
59391 + /* real_root is pinned, we don't need to hold a reference */
59392 + read_lock(&gr_inode_lock);
59393 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
59394 + __get_dev(real_root.dentry), role);
59395 + read_unlock(&gr_inode_lock);
59396 + }
59397 +out:
59398 + write_sequnlock(&rename_lock);
59399 + br_read_unlock(&vfsmount_lock);
59400 +
59401 + BUG_ON(retval == NULL);
59402 +
59403 + return retval;
59404 +}
59405 +
59406 +static void
59407 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
59408 +{
59409 + struct task_struct *task = current;
59410 + const struct cred *cred = current_cred();
59411 +
59412 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
59413 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59414 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59415 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
59416 +
59417 + return;
59418 +}
59419 +
59420 +static void
59421 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
59422 +{
59423 + struct task_struct *task = current;
59424 + const struct cred *cred = current_cred();
59425 +
59426 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59427 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59428 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59429 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
59430 +
59431 + return;
59432 +}
59433 +
59434 +static void
59435 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
59436 +{
59437 + struct task_struct *task = current;
59438 + const struct cred *cred = current_cred();
59439 +
59440 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59441 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59442 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59443 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
59444 +
59445 + return;
59446 +}
59447 +
59448 +__u32
59449 +gr_search_file(const struct dentry * dentry, const __u32 mode,
59450 + const struct vfsmount * mnt)
59451 +{
59452 + __u32 retval = mode;
59453 + struct acl_subject_label *curracl;
59454 + struct acl_object_label *currobj;
59455 +
59456 + if (unlikely(!(gr_status & GR_READY)))
59457 + return (mode & ~GR_AUDITS);
59458 +
59459 + curracl = current->acl;
59460 +
59461 + currobj = chk_obj_label(dentry, mnt, curracl);
59462 + retval = currobj->mode & mode;
59463 +
59464 + /* if we're opening a specified transfer file for writing
59465 + (e.g. /dev/initctl), then transfer our role to init
59466 + */
59467 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
59468 + current->role->roletype & GR_ROLE_PERSIST)) {
59469 + struct task_struct *task = init_pid_ns.child_reaper;
59470 +
59471 + if (task->role != current->role) {
59472 + task->acl_sp_role = 0;
59473 + task->acl_role_id = current->acl_role_id;
59474 + task->role = current->role;
59475 + rcu_read_lock();
59476 + read_lock(&grsec_exec_file_lock);
59477 + gr_apply_subject_to_task(task);
59478 + read_unlock(&grsec_exec_file_lock);
59479 + rcu_read_unlock();
59480 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
59481 + }
59482 + }
59483 +
59484 + if (unlikely
59485 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
59486 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
59487 + __u32 new_mode = mode;
59488 +
59489 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59490 +
59491 + retval = new_mode;
59492 +
59493 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
59494 + new_mode |= GR_INHERIT;
59495 +
59496 + if (!(mode & GR_NOLEARN))
59497 + gr_log_learn(dentry, mnt, new_mode);
59498 + }
59499 +
59500 + return retval;
59501 +}
59502 +
59503 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
59504 + const struct dentry *parent,
59505 + const struct vfsmount *mnt)
59506 +{
59507 + struct name_entry *match;
59508 + struct acl_object_label *matchpo;
59509 + struct acl_subject_label *curracl;
59510 + char *path;
59511 +
59512 + if (unlikely(!(gr_status & GR_READY)))
59513 + return NULL;
59514 +
59515 + preempt_disable();
59516 + path = gr_to_filename_rbac(new_dentry, mnt);
59517 + match = lookup_name_entry_create(path);
59518 +
59519 + curracl = current->acl;
59520 +
59521 + if (match) {
59522 + read_lock(&gr_inode_lock);
59523 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
59524 + read_unlock(&gr_inode_lock);
59525 +
59526 + if (matchpo) {
59527 + preempt_enable();
59528 + return matchpo;
59529 + }
59530 + }
59531 +
59532 + // lookup parent
59533 +
59534 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
59535 +
59536 + preempt_enable();
59537 + return matchpo;
59538 +}
59539 +
59540 +__u32
59541 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
59542 + const struct vfsmount * mnt, const __u32 mode)
59543 +{
59544 + struct acl_object_label *matchpo;
59545 + __u32 retval;
59546 +
59547 + if (unlikely(!(gr_status & GR_READY)))
59548 + return (mode & ~GR_AUDITS);
59549 +
59550 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
59551 +
59552 + retval = matchpo->mode & mode;
59553 +
59554 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
59555 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59556 + __u32 new_mode = mode;
59557 +
59558 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59559 +
59560 + gr_log_learn(new_dentry, mnt, new_mode);
59561 + return new_mode;
59562 + }
59563 +
59564 + return retval;
59565 +}
59566 +
59567 +__u32
59568 +gr_check_link(const struct dentry * new_dentry,
59569 + const struct dentry * parent_dentry,
59570 + const struct vfsmount * parent_mnt,
59571 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
59572 +{
59573 + struct acl_object_label *obj;
59574 + __u32 oldmode, newmode;
59575 + __u32 needmode;
59576 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
59577 + GR_DELETE | GR_INHERIT;
59578 +
59579 + if (unlikely(!(gr_status & GR_READY)))
59580 + return (GR_CREATE | GR_LINK);
59581 +
59582 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
59583 + oldmode = obj->mode;
59584 +
59585 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
59586 + newmode = obj->mode;
59587 +
59588 + needmode = newmode & checkmodes;
59589 +
59590 + // old name for hardlink must have at least the permissions of the new name
59591 + if ((oldmode & needmode) != needmode)
59592 + goto bad;
59593 +
59594 + // if old name had restrictions/auditing, make sure the new name does as well
59595 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
59596 +
59597 + // don't allow hardlinking of suid/sgid/fcapped files without permission
59598 + if (is_privileged_binary(old_dentry))
59599 + needmode |= GR_SETID;
59600 +
59601 + if ((newmode & needmode) != needmode)
59602 + goto bad;
59603 +
59604 + // enforce minimum permissions
59605 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
59606 + return newmode;
59607 +bad:
59608 + needmode = oldmode;
59609 + if (is_privileged_binary(old_dentry))
59610 + needmode |= GR_SETID;
59611 +
59612 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
59613 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
59614 + return (GR_CREATE | GR_LINK);
59615 + } else if (newmode & GR_SUPPRESS)
59616 + return GR_SUPPRESS;
59617 + else
59618 + return 0;
59619 +}
59620 +
59621 +int
59622 +gr_check_hidden_task(const struct task_struct *task)
59623 +{
59624 + if (unlikely(!(gr_status & GR_READY)))
59625 + return 0;
59626 +
59627 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
59628 + return 1;
59629 +
59630 + return 0;
59631 +}
59632 +
59633 +int
59634 +gr_check_protected_task(const struct task_struct *task)
59635 +{
59636 + if (unlikely(!(gr_status & GR_READY) || !task))
59637 + return 0;
59638 +
59639 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59640 + task->acl != current->acl)
59641 + return 1;
59642 +
59643 + return 0;
59644 +}
59645 +
59646 +int
59647 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
59648 +{
59649 + struct task_struct *p;
59650 + int ret = 0;
59651 +
59652 + if (unlikely(!(gr_status & GR_READY) || !pid))
59653 + return ret;
59654 +
59655 + read_lock(&tasklist_lock);
59656 + do_each_pid_task(pid, type, p) {
59657 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59658 + p->acl != current->acl) {
59659 + ret = 1;
59660 + goto out;
59661 + }
59662 + } while_each_pid_task(pid, type, p);
59663 +out:
59664 + read_unlock(&tasklist_lock);
59665 +
59666 + return ret;
59667 +}
59668 +
59669 +void
59670 +gr_copy_label(struct task_struct *tsk)
59671 +{
59672 + tsk->signal->used_accept = 0;
59673 + tsk->acl_sp_role = 0;
59674 + tsk->acl_role_id = current->acl_role_id;
59675 + tsk->acl = current->acl;
59676 + tsk->role = current->role;
59677 + tsk->signal->curr_ip = current->signal->curr_ip;
59678 + tsk->signal->saved_ip = current->signal->saved_ip;
59679 + if (current->exec_file)
59680 + get_file(current->exec_file);
59681 + tsk->exec_file = current->exec_file;
59682 + tsk->is_writable = current->is_writable;
59683 + if (unlikely(current->signal->used_accept)) {
59684 + current->signal->curr_ip = 0;
59685 + current->signal->saved_ip = 0;
59686 + }
59687 +
59688 + return;
59689 +}
59690 +
59691 +static void
59692 +gr_set_proc_res(struct task_struct *task)
59693 +{
59694 + struct acl_subject_label *proc;
59695 + unsigned short i;
59696 +
59697 + proc = task->acl;
59698 +
59699 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
59700 + return;
59701 +
59702 + for (i = 0; i < RLIM_NLIMITS; i++) {
59703 + if (!(proc->resmask & (1 << i)))
59704 + continue;
59705 +
59706 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
59707 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
59708 +
59709 + if (i == RLIMIT_CPU)
59710 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
59711 + }
59712 +
59713 + return;
59714 +}
59715 +
59716 +extern int __gr_process_user_ban(struct user_struct *user);
59717 +
59718 +int
59719 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
59720 +{
59721 + unsigned int i;
59722 + __u16 num;
59723 + uid_t *uidlist;
59724 + uid_t curuid;
59725 + int realok = 0;
59726 + int effectiveok = 0;
59727 + int fsok = 0;
59728 + uid_t globalreal, globaleffective, globalfs;
59729 +
59730 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
59731 + struct user_struct *user;
59732 +
59733 + if (!uid_valid(real))
59734 + goto skipit;
59735 +
59736 + /* find user based on global namespace */
59737 +
59738 + globalreal = GR_GLOBAL_UID(real);
59739 +
59740 + user = find_user(make_kuid(&init_user_ns, globalreal));
59741 + if (user == NULL)
59742 + goto skipit;
59743 +
59744 + if (__gr_process_user_ban(user)) {
59745 + /* for find_user */
59746 + free_uid(user);
59747 + return 1;
59748 + }
59749 +
59750 + /* for find_user */
59751 + free_uid(user);
59752 +
59753 +skipit:
59754 +#endif
59755 +
59756 + if (unlikely(!(gr_status & GR_READY)))
59757 + return 0;
59758 +
59759 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59760 + gr_log_learn_uid_change(real, effective, fs);
59761 +
59762 + num = current->acl->user_trans_num;
59763 + uidlist = current->acl->user_transitions;
59764 +
59765 + if (uidlist == NULL)
59766 + return 0;
59767 +
59768 + if (!uid_valid(real)) {
59769 + realok = 1;
59770 + globalreal = (uid_t)-1;
59771 + } else {
59772 + globalreal = GR_GLOBAL_UID(real);
59773 + }
59774 + if (!uid_valid(effective)) {
59775 + effectiveok = 1;
59776 + globaleffective = (uid_t)-1;
59777 + } else {
59778 + globaleffective = GR_GLOBAL_UID(effective);
59779 + }
59780 + if (!uid_valid(fs)) {
59781 + fsok = 1;
59782 + globalfs = (uid_t)-1;
59783 + } else {
59784 + globalfs = GR_GLOBAL_UID(fs);
59785 + }
59786 +
59787 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
59788 + for (i = 0; i < num; i++) {
59789 + curuid = uidlist[i];
59790 + if (globalreal == curuid)
59791 + realok = 1;
59792 + if (globaleffective == curuid)
59793 + effectiveok = 1;
59794 + if (globalfs == curuid)
59795 + fsok = 1;
59796 + }
59797 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
59798 + for (i = 0; i < num; i++) {
59799 + curuid = uidlist[i];
59800 + if (globalreal == curuid)
59801 + break;
59802 + if (globaleffective == curuid)
59803 + break;
59804 + if (globalfs == curuid)
59805 + break;
59806 + }
59807 + /* not in deny list */
59808 + if (i == num) {
59809 + realok = 1;
59810 + effectiveok = 1;
59811 + fsok = 1;
59812 + }
59813 + }
59814 +
59815 + if (realok && effectiveok && fsok)
59816 + return 0;
59817 + else {
59818 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
59819 + return 1;
59820 + }
59821 +}
59822 +
59823 +int
59824 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
59825 +{
59826 + unsigned int i;
59827 + __u16 num;
59828 + gid_t *gidlist;
59829 + gid_t curgid;
59830 + int realok = 0;
59831 + int effectiveok = 0;
59832 + int fsok = 0;
59833 + gid_t globalreal, globaleffective, globalfs;
59834 +
59835 + if (unlikely(!(gr_status & GR_READY)))
59836 + return 0;
59837 +
59838 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59839 + gr_log_learn_gid_change(real, effective, fs);
59840 +
59841 + num = current->acl->group_trans_num;
59842 + gidlist = current->acl->group_transitions;
59843 +
59844 + if (gidlist == NULL)
59845 + return 0;
59846 +
59847 + if (!gid_valid(real)) {
59848 + realok = 1;
59849 + globalreal = (gid_t)-1;
59850 + } else {
59851 + globalreal = GR_GLOBAL_GID(real);
59852 + }
59853 + if (!gid_valid(effective)) {
59854 + effectiveok = 1;
59855 + globaleffective = (gid_t)-1;
59856 + } else {
59857 + globaleffective = GR_GLOBAL_GID(effective);
59858 + }
59859 + if (!gid_valid(fs)) {
59860 + fsok = 1;
59861 + globalfs = (gid_t)-1;
59862 + } else {
59863 + globalfs = GR_GLOBAL_GID(fs);
59864 + }
59865 +
59866 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
59867 + for (i = 0; i < num; i++) {
59868 + curgid = gidlist[i];
59869 + if (globalreal == curgid)
59870 + realok = 1;
59871 + if (globaleffective == curgid)
59872 + effectiveok = 1;
59873 + if (globalfs == curgid)
59874 + fsok = 1;
59875 + }
59876 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
59877 + for (i = 0; i < num; i++) {
59878 + curgid = gidlist[i];
59879 + if (globalreal == curgid)
59880 + break;
59881 + if (globaleffective == curgid)
59882 + break;
59883 + if (globalfs == curgid)
59884 + break;
59885 + }
59886 + /* not in deny list */
59887 + if (i == num) {
59888 + realok = 1;
59889 + effectiveok = 1;
59890 + fsok = 1;
59891 + }
59892 + }
59893 +
59894 + if (realok && effectiveok && fsok)
59895 + return 0;
59896 + else {
59897 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
59898 + return 1;
59899 + }
59900 +}
59901 +
59902 +extern int gr_acl_is_capable(const int cap);
59903 +
59904 +void
59905 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
59906 +{
59907 + struct acl_role_label *role = task->role;
59908 + struct acl_subject_label *subj = NULL;
59909 + struct acl_object_label *obj;
59910 + struct file *filp;
59911 + uid_t uid;
59912 + gid_t gid;
59913 +
59914 + if (unlikely(!(gr_status & GR_READY)))
59915 + return;
59916 +
59917 + uid = GR_GLOBAL_UID(kuid);
59918 + gid = GR_GLOBAL_GID(kgid);
59919 +
59920 + filp = task->exec_file;
59921 +
59922 + /* kernel process, we'll give them the kernel role */
59923 + if (unlikely(!filp)) {
59924 + task->role = kernel_role;
59925 + task->acl = kernel_role->root_label;
59926 + return;
59927 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
59928 + role = lookup_acl_role_label(task, uid, gid);
59929 +
59930 + /* don't change the role if we're not a privileged process */
59931 + if (role && task->role != role &&
59932 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
59933 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
59934 + return;
59935 +
59936 + /* perform subject lookup in possibly new role
59937 + we can use this result below in the case where role == task->role
59938 + */
59939 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
59940 +
59941 + /* if we changed uid/gid, but result in the same role
59942 + and are using inheritance, don't lose the inherited subject
59943 + if current subject is other than what normal lookup
59944 + would result in, we arrived via inheritance, don't
59945 + lose subject
59946 + */
59947 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
59948 + (subj == task->acl)))
59949 + task->acl = subj;
59950 +
59951 + task->role = role;
59952 +
59953 + task->is_writable = 0;
59954 +
59955 + /* ignore additional mmap checks for processes that are writable
59956 + by the default ACL */
59957 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
59958 + if (unlikely(obj->mode & GR_WRITE))
59959 + task->is_writable = 1;
59960 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
59961 + if (unlikely(obj->mode & GR_WRITE))
59962 + task->is_writable = 1;
59963 +
59964 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59965 + 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);
59966 +#endif
59967 +
59968 + gr_set_proc_res(task);
59969 +
59970 + return;
59971 +}
59972 +
59973 +int
59974 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
59975 + const int unsafe_flags)
59976 +{
59977 + struct task_struct *task = current;
59978 + struct acl_subject_label *newacl;
59979 + struct acl_object_label *obj;
59980 + __u32 retmode;
59981 +
59982 + if (unlikely(!(gr_status & GR_READY)))
59983 + return 0;
59984 +
59985 + newacl = chk_subj_label(dentry, mnt, task->role);
59986 +
59987 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
59988 + did an exec
59989 + */
59990 + rcu_read_lock();
59991 + read_lock(&tasklist_lock);
59992 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
59993 + (task->parent->acl->mode & GR_POVERRIDE))) {
59994 + read_unlock(&tasklist_lock);
59995 + rcu_read_unlock();
59996 + goto skip_check;
59997 + }
59998 + read_unlock(&tasklist_lock);
59999 + rcu_read_unlock();
60000 +
60001 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60002 + !(task->role->roletype & GR_ROLE_GOD) &&
60003 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60004 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60005 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60006 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60007 + else
60008 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60009 + return -EACCES;
60010 + }
60011 +
60012 +skip_check:
60013 +
60014 + obj = chk_obj_label(dentry, mnt, task->acl);
60015 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60016 +
60017 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60018 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60019 + if (obj->nested)
60020 + task->acl = obj->nested;
60021 + else
60022 + task->acl = newacl;
60023 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60024 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60025 +
60026 + task->is_writable = 0;
60027 +
60028 + /* ignore additional mmap checks for processes that are writable
60029 + by the default ACL */
60030 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60031 + if (unlikely(obj->mode & GR_WRITE))
60032 + task->is_writable = 1;
60033 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60034 + if (unlikely(obj->mode & GR_WRITE))
60035 + task->is_writable = 1;
60036 +
60037 + gr_set_proc_res(task);
60038 +
60039 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60040 + 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);
60041 +#endif
60042 + return 0;
60043 +}
60044 +
60045 +/* always called with valid inodev ptr */
60046 +static void
60047 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60048 +{
60049 + struct acl_object_label *matchpo;
60050 + struct acl_subject_label *matchps;
60051 + struct acl_subject_label *subj;
60052 + struct acl_role_label *role;
60053 + unsigned int x;
60054 +
60055 + FOR_EACH_ROLE_START(role)
60056 + FOR_EACH_SUBJECT_START(role, subj, x)
60057 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60058 + matchpo->mode |= GR_DELETED;
60059 + FOR_EACH_SUBJECT_END(subj,x)
60060 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60061 + /* nested subjects aren't in the role's subj_hash table */
60062 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60063 + matchpo->mode |= GR_DELETED;
60064 + FOR_EACH_NESTED_SUBJECT_END(subj)
60065 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60066 + matchps->mode |= GR_DELETED;
60067 + FOR_EACH_ROLE_END(role)
60068 +
60069 + inodev->nentry->deleted = 1;
60070 +
60071 + return;
60072 +}
60073 +
60074 +void
60075 +gr_handle_delete(const ino_t ino, const dev_t dev)
60076 +{
60077 + struct inodev_entry *inodev;
60078 +
60079 + if (unlikely(!(gr_status & GR_READY)))
60080 + return;
60081 +
60082 + write_lock(&gr_inode_lock);
60083 + inodev = lookup_inodev_entry(ino, dev);
60084 + if (inodev != NULL)
60085 + do_handle_delete(inodev, ino, dev);
60086 + write_unlock(&gr_inode_lock);
60087 +
60088 + return;
60089 +}
60090 +
60091 +static void
60092 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60093 + const ino_t newinode, const dev_t newdevice,
60094 + struct acl_subject_label *subj)
60095 +{
60096 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60097 + struct acl_object_label *match;
60098 +
60099 + match = subj->obj_hash[index];
60100 +
60101 + while (match && (match->inode != oldinode ||
60102 + match->device != olddevice ||
60103 + !(match->mode & GR_DELETED)))
60104 + match = match->next;
60105 +
60106 + if (match && (match->inode == oldinode)
60107 + && (match->device == olddevice)
60108 + && (match->mode & GR_DELETED)) {
60109 + if (match->prev == NULL) {
60110 + subj->obj_hash[index] = match->next;
60111 + if (match->next != NULL)
60112 + match->next->prev = NULL;
60113 + } else {
60114 + match->prev->next = match->next;
60115 + if (match->next != NULL)
60116 + match->next->prev = match->prev;
60117 + }
60118 + match->prev = NULL;
60119 + match->next = NULL;
60120 + match->inode = newinode;
60121 + match->device = newdevice;
60122 + match->mode &= ~GR_DELETED;
60123 +
60124 + insert_acl_obj_label(match, subj);
60125 + }
60126 +
60127 + return;
60128 +}
60129 +
60130 +static void
60131 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60132 + const ino_t newinode, const dev_t newdevice,
60133 + struct acl_role_label *role)
60134 +{
60135 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60136 + struct acl_subject_label *match;
60137 +
60138 + match = role->subj_hash[index];
60139 +
60140 + while (match && (match->inode != oldinode ||
60141 + match->device != olddevice ||
60142 + !(match->mode & GR_DELETED)))
60143 + match = match->next;
60144 +
60145 + if (match && (match->inode == oldinode)
60146 + && (match->device == olddevice)
60147 + && (match->mode & GR_DELETED)) {
60148 + if (match->prev == NULL) {
60149 + role->subj_hash[index] = match->next;
60150 + if (match->next != NULL)
60151 + match->next->prev = NULL;
60152 + } else {
60153 + match->prev->next = match->next;
60154 + if (match->next != NULL)
60155 + match->next->prev = match->prev;
60156 + }
60157 + match->prev = NULL;
60158 + match->next = NULL;
60159 + match->inode = newinode;
60160 + match->device = newdevice;
60161 + match->mode &= ~GR_DELETED;
60162 +
60163 + insert_acl_subj_label(match, role);
60164 + }
60165 +
60166 + return;
60167 +}
60168 +
60169 +static void
60170 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60171 + const ino_t newinode, const dev_t newdevice)
60172 +{
60173 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60174 + struct inodev_entry *match;
60175 +
60176 + match = inodev_set.i_hash[index];
60177 +
60178 + while (match && (match->nentry->inode != oldinode ||
60179 + match->nentry->device != olddevice || !match->nentry->deleted))
60180 + match = match->next;
60181 +
60182 + if (match && (match->nentry->inode == oldinode)
60183 + && (match->nentry->device == olddevice) &&
60184 + match->nentry->deleted) {
60185 + if (match->prev == NULL) {
60186 + inodev_set.i_hash[index] = match->next;
60187 + if (match->next != NULL)
60188 + match->next->prev = NULL;
60189 + } else {
60190 + match->prev->next = match->next;
60191 + if (match->next != NULL)
60192 + match->next->prev = match->prev;
60193 + }
60194 + match->prev = NULL;
60195 + match->next = NULL;
60196 + match->nentry->inode = newinode;
60197 + match->nentry->device = newdevice;
60198 + match->nentry->deleted = 0;
60199 +
60200 + insert_inodev_entry(match);
60201 + }
60202 +
60203 + return;
60204 +}
60205 +
60206 +static void
60207 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60208 +{
60209 + struct acl_subject_label *subj;
60210 + struct acl_role_label *role;
60211 + unsigned int x;
60212 +
60213 + FOR_EACH_ROLE_START(role)
60214 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60215 +
60216 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60217 + if ((subj->inode == ino) && (subj->device == dev)) {
60218 + subj->inode = ino;
60219 + subj->device = dev;
60220 + }
60221 + /* nested subjects aren't in the role's subj_hash table */
60222 + update_acl_obj_label(matchn->inode, matchn->device,
60223 + ino, dev, subj);
60224 + FOR_EACH_NESTED_SUBJECT_END(subj)
60225 + FOR_EACH_SUBJECT_START(role, subj, x)
60226 + update_acl_obj_label(matchn->inode, matchn->device,
60227 + ino, dev, subj);
60228 + FOR_EACH_SUBJECT_END(subj,x)
60229 + FOR_EACH_ROLE_END(role)
60230 +
60231 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60232 +
60233 + return;
60234 +}
60235 +
60236 +static void
60237 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60238 + const struct vfsmount *mnt)
60239 +{
60240 + ino_t ino = dentry->d_inode->i_ino;
60241 + dev_t dev = __get_dev(dentry);
60242 +
60243 + __do_handle_create(matchn, ino, dev);
60244 +
60245 + return;
60246 +}
60247 +
60248 +void
60249 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60250 +{
60251 + struct name_entry *matchn;
60252 +
60253 + if (unlikely(!(gr_status & GR_READY)))
60254 + return;
60255 +
60256 + preempt_disable();
60257 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60258 +
60259 + if (unlikely((unsigned long)matchn)) {
60260 + write_lock(&gr_inode_lock);
60261 + do_handle_create(matchn, dentry, mnt);
60262 + write_unlock(&gr_inode_lock);
60263 + }
60264 + preempt_enable();
60265 +
60266 + return;
60267 +}
60268 +
60269 +void
60270 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60271 +{
60272 + struct name_entry *matchn;
60273 +
60274 + if (unlikely(!(gr_status & GR_READY)))
60275 + return;
60276 +
60277 + preempt_disable();
60278 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60279 +
60280 + if (unlikely((unsigned long)matchn)) {
60281 + write_lock(&gr_inode_lock);
60282 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60283 + write_unlock(&gr_inode_lock);
60284 + }
60285 + preempt_enable();
60286 +
60287 + return;
60288 +}
60289 +
60290 +void
60291 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
60292 + struct dentry *old_dentry,
60293 + struct dentry *new_dentry,
60294 + struct vfsmount *mnt, const __u8 replace)
60295 +{
60296 + struct name_entry *matchn;
60297 + struct inodev_entry *inodev;
60298 + struct inode *inode = new_dentry->d_inode;
60299 + ino_t old_ino = old_dentry->d_inode->i_ino;
60300 + dev_t old_dev = __get_dev(old_dentry);
60301 +
60302 + /* vfs_rename swaps the name and parent link for old_dentry and
60303 + new_dentry
60304 + at this point, old_dentry has the new name, parent link, and inode
60305 + for the renamed file
60306 + if a file is being replaced by a rename, new_dentry has the inode
60307 + and name for the replaced file
60308 + */
60309 +
60310 + if (unlikely(!(gr_status & GR_READY)))
60311 + return;
60312 +
60313 + preempt_disable();
60314 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
60315 +
60316 + /* we wouldn't have to check d_inode if it weren't for
60317 + NFS silly-renaming
60318 + */
60319 +
60320 + write_lock(&gr_inode_lock);
60321 + if (unlikely(replace && inode)) {
60322 + ino_t new_ino = inode->i_ino;
60323 + dev_t new_dev = __get_dev(new_dentry);
60324 +
60325 + inodev = lookup_inodev_entry(new_ino, new_dev);
60326 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
60327 + do_handle_delete(inodev, new_ino, new_dev);
60328 + }
60329 +
60330 + inodev = lookup_inodev_entry(old_ino, old_dev);
60331 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
60332 + do_handle_delete(inodev, old_ino, old_dev);
60333 +
60334 + if (unlikely((unsigned long)matchn))
60335 + do_handle_create(matchn, old_dentry, mnt);
60336 +
60337 + write_unlock(&gr_inode_lock);
60338 + preempt_enable();
60339 +
60340 + return;
60341 +}
60342 +
60343 +static int
60344 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
60345 + unsigned char **sum)
60346 +{
60347 + struct acl_role_label *r;
60348 + struct role_allowed_ip *ipp;
60349 + struct role_transition *trans;
60350 + unsigned int i;
60351 + int found = 0;
60352 + u32 curr_ip = current->signal->curr_ip;
60353 +
60354 + current->signal->saved_ip = curr_ip;
60355 +
60356 + /* check transition table */
60357 +
60358 + for (trans = current->role->transitions; trans; trans = trans->next) {
60359 + if (!strcmp(rolename, trans->rolename)) {
60360 + found = 1;
60361 + break;
60362 + }
60363 + }
60364 +
60365 + if (!found)
60366 + return 0;
60367 +
60368 + /* handle special roles that do not require authentication
60369 + and check ip */
60370 +
60371 + FOR_EACH_ROLE_START(r)
60372 + if (!strcmp(rolename, r->rolename) &&
60373 + (r->roletype & GR_ROLE_SPECIAL)) {
60374 + found = 0;
60375 + if (r->allowed_ips != NULL) {
60376 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
60377 + if ((ntohl(curr_ip) & ipp->netmask) ==
60378 + (ntohl(ipp->addr) & ipp->netmask))
60379 + found = 1;
60380 + }
60381 + } else
60382 + found = 2;
60383 + if (!found)
60384 + return 0;
60385 +
60386 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
60387 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
60388 + *salt = NULL;
60389 + *sum = NULL;
60390 + return 1;
60391 + }
60392 + }
60393 + FOR_EACH_ROLE_END(r)
60394 +
60395 + for (i = 0; i < num_sprole_pws; i++) {
60396 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
60397 + *salt = acl_special_roles[i]->salt;
60398 + *sum = acl_special_roles[i]->sum;
60399 + return 1;
60400 + }
60401 + }
60402 +
60403 + return 0;
60404 +}
60405 +
60406 +static void
60407 +assign_special_role(char *rolename)
60408 +{
60409 + struct acl_object_label *obj;
60410 + struct acl_role_label *r;
60411 + struct acl_role_label *assigned = NULL;
60412 + struct task_struct *tsk;
60413 + struct file *filp;
60414 +
60415 + FOR_EACH_ROLE_START(r)
60416 + if (!strcmp(rolename, r->rolename) &&
60417 + (r->roletype & GR_ROLE_SPECIAL)) {
60418 + assigned = r;
60419 + break;
60420 + }
60421 + FOR_EACH_ROLE_END(r)
60422 +
60423 + if (!assigned)
60424 + return;
60425 +
60426 + read_lock(&tasklist_lock);
60427 + read_lock(&grsec_exec_file_lock);
60428 +
60429 + tsk = current->real_parent;
60430 + if (tsk == NULL)
60431 + goto out_unlock;
60432 +
60433 + filp = tsk->exec_file;
60434 + if (filp == NULL)
60435 + goto out_unlock;
60436 +
60437 + tsk->is_writable = 0;
60438 +
60439 + tsk->acl_sp_role = 1;
60440 + tsk->acl_role_id = ++acl_sp_role_value;
60441 + tsk->role = assigned;
60442 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
60443 +
60444 + /* ignore additional mmap checks for processes that are writable
60445 + by the default ACL */
60446 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60447 + if (unlikely(obj->mode & GR_WRITE))
60448 + tsk->is_writable = 1;
60449 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
60450 + if (unlikely(obj->mode & GR_WRITE))
60451 + tsk->is_writable = 1;
60452 +
60453 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60454 + 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));
60455 +#endif
60456 +
60457 +out_unlock:
60458 + read_unlock(&grsec_exec_file_lock);
60459 + read_unlock(&tasklist_lock);
60460 + return;
60461 +}
60462 +
60463 +int gr_check_secure_terminal(struct task_struct *task)
60464 +{
60465 + struct task_struct *p, *p2, *p3;
60466 + struct files_struct *files;
60467 + struct fdtable *fdt;
60468 + struct file *our_file = NULL, *file;
60469 + int i;
60470 +
60471 + if (task->signal->tty == NULL)
60472 + return 1;
60473 +
60474 + files = get_files_struct(task);
60475 + if (files != NULL) {
60476 + rcu_read_lock();
60477 + fdt = files_fdtable(files);
60478 + for (i=0; i < fdt->max_fds; i++) {
60479 + file = fcheck_files(files, i);
60480 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
60481 + get_file(file);
60482 + our_file = file;
60483 + }
60484 + }
60485 + rcu_read_unlock();
60486 + put_files_struct(files);
60487 + }
60488 +
60489 + if (our_file == NULL)
60490 + return 1;
60491 +
60492 + read_lock(&tasklist_lock);
60493 + do_each_thread(p2, p) {
60494 + files = get_files_struct(p);
60495 + if (files == NULL ||
60496 + (p->signal && p->signal->tty == task->signal->tty)) {
60497 + if (files != NULL)
60498 + put_files_struct(files);
60499 + continue;
60500 + }
60501 + rcu_read_lock();
60502 + fdt = files_fdtable(files);
60503 + for (i=0; i < fdt->max_fds; i++) {
60504 + file = fcheck_files(files, i);
60505 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
60506 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
60507 + p3 = task;
60508 + while (task_pid_nr(p3) > 0) {
60509 + if (p3 == p)
60510 + break;
60511 + p3 = p3->real_parent;
60512 + }
60513 + if (p3 == p)
60514 + break;
60515 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
60516 + gr_handle_alertkill(p);
60517 + rcu_read_unlock();
60518 + put_files_struct(files);
60519 + read_unlock(&tasklist_lock);
60520 + fput(our_file);
60521 + return 0;
60522 + }
60523 + }
60524 + rcu_read_unlock();
60525 + put_files_struct(files);
60526 + } while_each_thread(p2, p);
60527 + read_unlock(&tasklist_lock);
60528 +
60529 + fput(our_file);
60530 + return 1;
60531 +}
60532 +
60533 +static int gr_rbac_disable(void *unused)
60534 +{
60535 + pax_open_kernel();
60536 + gr_status &= ~GR_READY;
60537 + pax_close_kernel();
60538 +
60539 + return 0;
60540 +}
60541 +
60542 +ssize_t
60543 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
60544 +{
60545 + struct gr_arg_wrapper uwrap;
60546 + unsigned char *sprole_salt = NULL;
60547 + unsigned char *sprole_sum = NULL;
60548 + int error = sizeof (struct gr_arg_wrapper);
60549 + int error2 = 0;
60550 +
60551 + mutex_lock(&gr_dev_mutex);
60552 +
60553 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
60554 + error = -EPERM;
60555 + goto out;
60556 + }
60557 +
60558 + if (count != sizeof (struct gr_arg_wrapper)) {
60559 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
60560 + error = -EINVAL;
60561 + goto out;
60562 + }
60563 +
60564 +
60565 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
60566 + gr_auth_expires = 0;
60567 + gr_auth_attempts = 0;
60568 + }
60569 +
60570 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
60571 + error = -EFAULT;
60572 + goto out;
60573 + }
60574 +
60575 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
60576 + error = -EINVAL;
60577 + goto out;
60578 + }
60579 +
60580 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
60581 + error = -EFAULT;
60582 + goto out;
60583 + }
60584 +
60585 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60586 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60587 + time_after(gr_auth_expires, get_seconds())) {
60588 + error = -EBUSY;
60589 + goto out;
60590 + }
60591 +
60592 + /* if non-root trying to do anything other than use a special role,
60593 + do not attempt authentication, do not count towards authentication
60594 + locking
60595 + */
60596 +
60597 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
60598 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60599 + gr_is_global_nonroot(current_uid())) {
60600 + error = -EPERM;
60601 + goto out;
60602 + }
60603 +
60604 + /* ensure pw and special role name are null terminated */
60605 +
60606 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
60607 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
60608 +
60609 + /* Okay.
60610 + * We have our enough of the argument structure..(we have yet
60611 + * to copy_from_user the tables themselves) . Copy the tables
60612 + * only if we need them, i.e. for loading operations. */
60613 +
60614 + switch (gr_usermode->mode) {
60615 + case GR_STATUS:
60616 + if (gr_status & GR_READY) {
60617 + error = 1;
60618 + if (!gr_check_secure_terminal(current))
60619 + error = 3;
60620 + } else
60621 + error = 2;
60622 + goto out;
60623 + case GR_SHUTDOWN:
60624 + if ((gr_status & GR_READY)
60625 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60626 + stop_machine(gr_rbac_disable, NULL, NULL);
60627 + free_variables();
60628 + memset(gr_usermode, 0, sizeof (struct gr_arg));
60629 + memset(gr_system_salt, 0, GR_SALT_LEN);
60630 + memset(gr_system_sum, 0, GR_SHA_LEN);
60631 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
60632 + } else if (gr_status & GR_READY) {
60633 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
60634 + error = -EPERM;
60635 + } else {
60636 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
60637 + error = -EAGAIN;
60638 + }
60639 + break;
60640 + case GR_ENABLE:
60641 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
60642 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
60643 + else {
60644 + if (gr_status & GR_READY)
60645 + error = -EAGAIN;
60646 + else
60647 + error = error2;
60648 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
60649 + }
60650 + break;
60651 + case GR_RELOAD:
60652 + if (!(gr_status & GR_READY)) {
60653 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
60654 + error = -EAGAIN;
60655 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60656 + stop_machine(gr_rbac_disable, NULL, NULL);
60657 + free_variables();
60658 + error2 = gracl_init(gr_usermode);
60659 + if (!error2)
60660 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
60661 + else {
60662 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60663 + error = error2;
60664 + }
60665 + } else {
60666 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60667 + error = -EPERM;
60668 + }
60669 + break;
60670 + case GR_SEGVMOD:
60671 + if (unlikely(!(gr_status & GR_READY))) {
60672 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
60673 + error = -EAGAIN;
60674 + break;
60675 + }
60676 +
60677 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60678 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
60679 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
60680 + struct acl_subject_label *segvacl;
60681 + segvacl =
60682 + lookup_acl_subj_label(gr_usermode->segv_inode,
60683 + gr_usermode->segv_device,
60684 + current->role);
60685 + if (segvacl) {
60686 + segvacl->crashes = 0;
60687 + segvacl->expires = 0;
60688 + }
60689 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
60690 + gr_remove_uid(gr_usermode->segv_uid);
60691 + }
60692 + } else {
60693 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
60694 + error = -EPERM;
60695 + }
60696 + break;
60697 + case GR_SPROLE:
60698 + case GR_SPROLEPAM:
60699 + if (unlikely(!(gr_status & GR_READY))) {
60700 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
60701 + error = -EAGAIN;
60702 + break;
60703 + }
60704 +
60705 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
60706 + current->role->expires = 0;
60707 + current->role->auth_attempts = 0;
60708 + }
60709 +
60710 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60711 + time_after(current->role->expires, get_seconds())) {
60712 + error = -EBUSY;
60713 + goto out;
60714 + }
60715 +
60716 + if (lookup_special_role_auth
60717 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
60718 + && ((!sprole_salt && !sprole_sum)
60719 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
60720 + char *p = "";
60721 + assign_special_role(gr_usermode->sp_role);
60722 + read_lock(&tasklist_lock);
60723 + if (current->real_parent)
60724 + p = current->real_parent->role->rolename;
60725 + read_unlock(&tasklist_lock);
60726 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
60727 + p, acl_sp_role_value);
60728 + } else {
60729 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
60730 + error = -EPERM;
60731 + if(!(current->role->auth_attempts++))
60732 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60733 +
60734 + goto out;
60735 + }
60736 + break;
60737 + case GR_UNSPROLE:
60738 + if (unlikely(!(gr_status & GR_READY))) {
60739 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
60740 + error = -EAGAIN;
60741 + break;
60742 + }
60743 +
60744 + if (current->role->roletype & GR_ROLE_SPECIAL) {
60745 + char *p = "";
60746 + int i = 0;
60747 +
60748 + read_lock(&tasklist_lock);
60749 + if (current->real_parent) {
60750 + p = current->real_parent->role->rolename;
60751 + i = current->real_parent->acl_role_id;
60752 + }
60753 + read_unlock(&tasklist_lock);
60754 +
60755 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
60756 + gr_set_acls(1);
60757 + } else {
60758 + error = -EPERM;
60759 + goto out;
60760 + }
60761 + break;
60762 + default:
60763 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
60764 + error = -EINVAL;
60765 + break;
60766 + }
60767 +
60768 + if (error != -EPERM)
60769 + goto out;
60770 +
60771 + if(!(gr_auth_attempts++))
60772 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60773 +
60774 + out:
60775 + mutex_unlock(&gr_dev_mutex);
60776 + return error;
60777 +}
60778 +
60779 +/* must be called with
60780 + rcu_read_lock();
60781 + read_lock(&tasklist_lock);
60782 + read_lock(&grsec_exec_file_lock);
60783 +*/
60784 +int gr_apply_subject_to_task(struct task_struct *task)
60785 +{
60786 + struct acl_object_label *obj;
60787 + char *tmpname;
60788 + struct acl_subject_label *tmpsubj;
60789 + struct file *filp;
60790 + struct name_entry *nmatch;
60791 +
60792 + filp = task->exec_file;
60793 + if (filp == NULL)
60794 + return 0;
60795 +
60796 + /* the following is to apply the correct subject
60797 + on binaries running when the RBAC system
60798 + is enabled, when the binaries have been
60799 + replaced or deleted since their execution
60800 + -----
60801 + when the RBAC system starts, the inode/dev
60802 + from exec_file will be one the RBAC system
60803 + is unaware of. It only knows the inode/dev
60804 + of the present file on disk, or the absence
60805 + of it.
60806 + */
60807 + preempt_disable();
60808 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
60809 +
60810 + nmatch = lookup_name_entry(tmpname);
60811 + preempt_enable();
60812 + tmpsubj = NULL;
60813 + if (nmatch) {
60814 + if (nmatch->deleted)
60815 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
60816 + else
60817 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
60818 + if (tmpsubj != NULL)
60819 + task->acl = tmpsubj;
60820 + }
60821 + if (tmpsubj == NULL)
60822 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
60823 + task->role);
60824 + if (task->acl) {
60825 + task->is_writable = 0;
60826 + /* ignore additional mmap checks for processes that are writable
60827 + by the default ACL */
60828 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60829 + if (unlikely(obj->mode & GR_WRITE))
60830 + task->is_writable = 1;
60831 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60832 + if (unlikely(obj->mode & GR_WRITE))
60833 + task->is_writable = 1;
60834 +
60835 + gr_set_proc_res(task);
60836 +
60837 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60838 + 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);
60839 +#endif
60840 + } else {
60841 + return 1;
60842 + }
60843 +
60844 + return 0;
60845 +}
60846 +
60847 +int
60848 +gr_set_acls(const int type)
60849 +{
60850 + struct task_struct *task, *task2;
60851 + struct acl_role_label *role = current->role;
60852 + __u16 acl_role_id = current->acl_role_id;
60853 + const struct cred *cred;
60854 + int ret;
60855 +
60856 + rcu_read_lock();
60857 + read_lock(&tasklist_lock);
60858 + read_lock(&grsec_exec_file_lock);
60859 + do_each_thread(task2, task) {
60860 + /* check to see if we're called from the exit handler,
60861 + if so, only replace ACLs that have inherited the admin
60862 + ACL */
60863 +
60864 + if (type && (task->role != role ||
60865 + task->acl_role_id != acl_role_id))
60866 + continue;
60867 +
60868 + task->acl_role_id = 0;
60869 + task->acl_sp_role = 0;
60870 +
60871 + if (task->exec_file) {
60872 + cred = __task_cred(task);
60873 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
60874 + ret = gr_apply_subject_to_task(task);
60875 + if (ret) {
60876 + read_unlock(&grsec_exec_file_lock);
60877 + read_unlock(&tasklist_lock);
60878 + rcu_read_unlock();
60879 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
60880 + return ret;
60881 + }
60882 + } else {
60883 + // it's a kernel process
60884 + task->role = kernel_role;
60885 + task->acl = kernel_role->root_label;
60886 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
60887 + task->acl->mode &= ~GR_PROCFIND;
60888 +#endif
60889 + }
60890 + } while_each_thread(task2, task);
60891 + read_unlock(&grsec_exec_file_lock);
60892 + read_unlock(&tasklist_lock);
60893 + rcu_read_unlock();
60894 +
60895 + return 0;
60896 +}
60897 +
60898 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
60899 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
60900 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
60901 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
60902 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
60903 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
60904 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
60905 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
60906 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
60907 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
60908 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
60909 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
60910 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
60911 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
60912 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
60913 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
60914 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
60915 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
60916 +};
60917 +
60918 +void
60919 +gr_learn_resource(const struct task_struct *task,
60920 + const int res, const unsigned long wanted, const int gt)
60921 +{
60922 + struct acl_subject_label *acl;
60923 + const struct cred *cred;
60924 +
60925 + if (unlikely((gr_status & GR_READY) &&
60926 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
60927 + goto skip_reslog;
60928 +
60929 + gr_log_resource(task, res, wanted, gt);
60930 +skip_reslog:
60931 +
60932 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
60933 + return;
60934 +
60935 + acl = task->acl;
60936 +
60937 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
60938 + !(acl->resmask & (1 << (unsigned short) res))))
60939 + return;
60940 +
60941 + if (wanted >= acl->res[res].rlim_cur) {
60942 + unsigned long res_add;
60943 +
60944 + res_add = wanted + res_learn_bumps[res];
60945 +
60946 + acl->res[res].rlim_cur = res_add;
60947 +
60948 + if (wanted > acl->res[res].rlim_max)
60949 + acl->res[res].rlim_max = res_add;
60950 +
60951 + /* only log the subject filename, since resource logging is supported for
60952 + single-subject learning only */
60953 + rcu_read_lock();
60954 + cred = __task_cred(task);
60955 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
60956 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
60957 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
60958 + "", (unsigned long) res, &task->signal->saved_ip);
60959 + rcu_read_unlock();
60960 + }
60961 +
60962 + return;
60963 +}
60964 +EXPORT_SYMBOL(gr_learn_resource);
60965 +#endif
60966 +
60967 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
60968 +void
60969 +pax_set_initial_flags(struct linux_binprm *bprm)
60970 +{
60971 + struct task_struct *task = current;
60972 + struct acl_subject_label *proc;
60973 + unsigned long flags;
60974 +
60975 + if (unlikely(!(gr_status & GR_READY)))
60976 + return;
60977 +
60978 + flags = pax_get_flags(task);
60979 +
60980 + proc = task->acl;
60981 +
60982 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
60983 + flags &= ~MF_PAX_PAGEEXEC;
60984 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
60985 + flags &= ~MF_PAX_SEGMEXEC;
60986 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
60987 + flags &= ~MF_PAX_RANDMMAP;
60988 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
60989 + flags &= ~MF_PAX_EMUTRAMP;
60990 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
60991 + flags &= ~MF_PAX_MPROTECT;
60992 +
60993 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
60994 + flags |= MF_PAX_PAGEEXEC;
60995 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
60996 + flags |= MF_PAX_SEGMEXEC;
60997 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
60998 + flags |= MF_PAX_RANDMMAP;
60999 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61000 + flags |= MF_PAX_EMUTRAMP;
61001 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61002 + flags |= MF_PAX_MPROTECT;
61003 +
61004 + pax_set_flags(task, flags);
61005 +
61006 + return;
61007 +}
61008 +#endif
61009 +
61010 +int
61011 +gr_handle_proc_ptrace(struct task_struct *task)
61012 +{
61013 + struct file *filp;
61014 + struct task_struct *tmp = task;
61015 + struct task_struct *curtemp = current;
61016 + __u32 retmode;
61017 +
61018 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61019 + if (unlikely(!(gr_status & GR_READY)))
61020 + return 0;
61021 +#endif
61022 +
61023 + read_lock(&tasklist_lock);
61024 + read_lock(&grsec_exec_file_lock);
61025 + filp = task->exec_file;
61026 +
61027 + while (task_pid_nr(tmp) > 0) {
61028 + if (tmp == curtemp)
61029 + break;
61030 + tmp = tmp->real_parent;
61031 + }
61032 +
61033 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61034 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61035 + read_unlock(&grsec_exec_file_lock);
61036 + read_unlock(&tasklist_lock);
61037 + return 1;
61038 + }
61039 +
61040 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61041 + if (!(gr_status & GR_READY)) {
61042 + read_unlock(&grsec_exec_file_lock);
61043 + read_unlock(&tasklist_lock);
61044 + return 0;
61045 + }
61046 +#endif
61047 +
61048 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61049 + read_unlock(&grsec_exec_file_lock);
61050 + read_unlock(&tasklist_lock);
61051 +
61052 + if (retmode & GR_NOPTRACE)
61053 + return 1;
61054 +
61055 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61056 + && (current->acl != task->acl || (current->acl != current->role->root_label
61057 + && task_pid_nr(current) != task_pid_nr(task))))
61058 + return 1;
61059 +
61060 + return 0;
61061 +}
61062 +
61063 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61064 +{
61065 + if (unlikely(!(gr_status & GR_READY)))
61066 + return;
61067 +
61068 + if (!(current->role->roletype & GR_ROLE_GOD))
61069 + return;
61070 +
61071 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61072 + p->role->rolename, gr_task_roletype_to_char(p),
61073 + p->acl->filename);
61074 +}
61075 +
61076 +int
61077 +gr_handle_ptrace(struct task_struct *task, const long request)
61078 +{
61079 + struct task_struct *tmp = task;
61080 + struct task_struct *curtemp = current;
61081 + __u32 retmode;
61082 +
61083 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61084 + if (unlikely(!(gr_status & GR_READY)))
61085 + return 0;
61086 +#endif
61087 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61088 + read_lock(&tasklist_lock);
61089 + while (task_pid_nr(tmp) > 0) {
61090 + if (tmp == curtemp)
61091 + break;
61092 + tmp = tmp->real_parent;
61093 + }
61094 +
61095 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61096 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61097 + read_unlock(&tasklist_lock);
61098 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61099 + return 1;
61100 + }
61101 + read_unlock(&tasklist_lock);
61102 + }
61103 +
61104 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61105 + if (!(gr_status & GR_READY))
61106 + return 0;
61107 +#endif
61108 +
61109 + read_lock(&grsec_exec_file_lock);
61110 + if (unlikely(!task->exec_file)) {
61111 + read_unlock(&grsec_exec_file_lock);
61112 + return 0;
61113 + }
61114 +
61115 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61116 + read_unlock(&grsec_exec_file_lock);
61117 +
61118 + if (retmode & GR_NOPTRACE) {
61119 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61120 + return 1;
61121 + }
61122 +
61123 + if (retmode & GR_PTRACERD) {
61124 + switch (request) {
61125 + case PTRACE_SEIZE:
61126 + case PTRACE_POKETEXT:
61127 + case PTRACE_POKEDATA:
61128 + case PTRACE_POKEUSR:
61129 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61130 + case PTRACE_SETREGS:
61131 + case PTRACE_SETFPREGS:
61132 +#endif
61133 +#ifdef CONFIG_X86
61134 + case PTRACE_SETFPXREGS:
61135 +#endif
61136 +#ifdef CONFIG_ALTIVEC
61137 + case PTRACE_SETVRREGS:
61138 +#endif
61139 + return 1;
61140 + default:
61141 + return 0;
61142 + }
61143 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61144 + !(current->role->roletype & GR_ROLE_GOD) &&
61145 + (current->acl != task->acl)) {
61146 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61147 + return 1;
61148 + }
61149 +
61150 + return 0;
61151 +}
61152 +
61153 +static int is_writable_mmap(const struct file *filp)
61154 +{
61155 + struct task_struct *task = current;
61156 + struct acl_object_label *obj, *obj2;
61157 +
61158 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61159 + !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))) {
61160 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61161 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61162 + task->role->root_label);
61163 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61164 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61165 + return 1;
61166 + }
61167 + }
61168 + return 0;
61169 +}
61170 +
61171 +int
61172 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61173 +{
61174 + __u32 mode;
61175 +
61176 + if (unlikely(!file || !(prot & PROT_EXEC)))
61177 + return 1;
61178 +
61179 + if (is_writable_mmap(file))
61180 + return 0;
61181 +
61182 + mode =
61183 + gr_search_file(file->f_path.dentry,
61184 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61185 + file->f_path.mnt);
61186 +
61187 + if (!gr_tpe_allow(file))
61188 + return 0;
61189 +
61190 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61191 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61192 + return 0;
61193 + } else if (unlikely(!(mode & GR_EXEC))) {
61194 + return 0;
61195 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61196 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61197 + return 1;
61198 + }
61199 +
61200 + return 1;
61201 +}
61202 +
61203 +int
61204 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61205 +{
61206 + __u32 mode;
61207 +
61208 + if (unlikely(!file || !(prot & PROT_EXEC)))
61209 + return 1;
61210 +
61211 + if (is_writable_mmap(file))
61212 + return 0;
61213 +
61214 + mode =
61215 + gr_search_file(file->f_path.dentry,
61216 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61217 + file->f_path.mnt);
61218 +
61219 + if (!gr_tpe_allow(file))
61220 + return 0;
61221 +
61222 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61223 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61224 + return 0;
61225 + } else if (unlikely(!(mode & GR_EXEC))) {
61226 + return 0;
61227 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61228 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61229 + return 1;
61230 + }
61231 +
61232 + return 1;
61233 +}
61234 +
61235 +void
61236 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61237 +{
61238 + unsigned long runtime;
61239 + unsigned long cputime;
61240 + unsigned int wday, cday;
61241 + __u8 whr, chr;
61242 + __u8 wmin, cmin;
61243 + __u8 wsec, csec;
61244 + struct timespec timeval;
61245 +
61246 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61247 + !(task->acl->mode & GR_PROCACCT)))
61248 + return;
61249 +
61250 + do_posix_clock_monotonic_gettime(&timeval);
61251 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61252 + wday = runtime / (3600 * 24);
61253 + runtime -= wday * (3600 * 24);
61254 + whr = runtime / 3600;
61255 + runtime -= whr * 3600;
61256 + wmin = runtime / 60;
61257 + runtime -= wmin * 60;
61258 + wsec = runtime;
61259 +
61260 + cputime = (task->utime + task->stime) / HZ;
61261 + cday = cputime / (3600 * 24);
61262 + cputime -= cday * (3600 * 24);
61263 + chr = cputime / 3600;
61264 + cputime -= chr * 3600;
61265 + cmin = cputime / 60;
61266 + cputime -= cmin * 60;
61267 + csec = cputime;
61268 +
61269 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61270 +
61271 + return;
61272 +}
61273 +
61274 +void gr_set_kernel_label(struct task_struct *task)
61275 +{
61276 + if (gr_status & GR_READY) {
61277 + task->role = kernel_role;
61278 + task->acl = kernel_role->root_label;
61279 + }
61280 + return;
61281 +}
61282 +
61283 +#ifdef CONFIG_TASKSTATS
61284 +int gr_is_taskstats_denied(int pid)
61285 +{
61286 + struct task_struct *task;
61287 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61288 + const struct cred *cred;
61289 +#endif
61290 + int ret = 0;
61291 +
61292 + /* restrict taskstats viewing to un-chrooted root users
61293 + who have the 'view' subject flag if the RBAC system is enabled
61294 + */
61295 +
61296 + rcu_read_lock();
61297 + read_lock(&tasklist_lock);
61298 + task = find_task_by_vpid(pid);
61299 + if (task) {
61300 +#ifdef CONFIG_GRKERNSEC_CHROOT
61301 + if (proc_is_chrooted(task))
61302 + ret = -EACCES;
61303 +#endif
61304 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61305 + cred = __task_cred(task);
61306 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61307 + if (gr_is_global_nonroot(cred->uid))
61308 + ret = -EACCES;
61309 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61310 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
61311 + ret = -EACCES;
61312 +#endif
61313 +#endif
61314 + if (gr_status & GR_READY) {
61315 + if (!(task->acl->mode & GR_VIEW))
61316 + ret = -EACCES;
61317 + }
61318 + } else
61319 + ret = -ENOENT;
61320 +
61321 + read_unlock(&tasklist_lock);
61322 + rcu_read_unlock();
61323 +
61324 + return ret;
61325 +}
61326 +#endif
61327 +
61328 +/* AUXV entries are filled via a descendant of search_binary_handler
61329 + after we've already applied the subject for the target
61330 +*/
61331 +int gr_acl_enable_at_secure(void)
61332 +{
61333 + if (unlikely(!(gr_status & GR_READY)))
61334 + return 0;
61335 +
61336 + if (current->acl->mode & GR_ATSECURE)
61337 + return 1;
61338 +
61339 + return 0;
61340 +}
61341 +
61342 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
61343 +{
61344 + struct task_struct *task = current;
61345 + struct dentry *dentry = file->f_path.dentry;
61346 + struct vfsmount *mnt = file->f_path.mnt;
61347 + struct acl_object_label *obj, *tmp;
61348 + struct acl_subject_label *subj;
61349 + unsigned int bufsize;
61350 + int is_not_root;
61351 + char *path;
61352 + dev_t dev = __get_dev(dentry);
61353 +
61354 + if (unlikely(!(gr_status & GR_READY)))
61355 + return 1;
61356 +
61357 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61358 + return 1;
61359 +
61360 + /* ignore Eric Biederman */
61361 + if (IS_PRIVATE(dentry->d_inode))
61362 + return 1;
61363 +
61364 + subj = task->acl;
61365 + read_lock(&gr_inode_lock);
61366 + do {
61367 + obj = lookup_acl_obj_label(ino, dev, subj);
61368 + if (obj != NULL) {
61369 + read_unlock(&gr_inode_lock);
61370 + return (obj->mode & GR_FIND) ? 1 : 0;
61371 + }
61372 + } while ((subj = subj->parent_subject));
61373 + read_unlock(&gr_inode_lock);
61374 +
61375 + /* this is purely an optimization since we're looking for an object
61376 + for the directory we're doing a readdir on
61377 + if it's possible for any globbed object to match the entry we're
61378 + filling into the directory, then the object we find here will be
61379 + an anchor point with attached globbed objects
61380 + */
61381 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
61382 + if (obj->globbed == NULL)
61383 + return (obj->mode & GR_FIND) ? 1 : 0;
61384 +
61385 + is_not_root = ((obj->filename[0] == '/') &&
61386 + (obj->filename[1] == '\0')) ? 0 : 1;
61387 + bufsize = PAGE_SIZE - namelen - is_not_root;
61388 +
61389 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
61390 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
61391 + return 1;
61392 +
61393 + preempt_disable();
61394 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61395 + bufsize);
61396 +
61397 + bufsize = strlen(path);
61398 +
61399 + /* if base is "/", don't append an additional slash */
61400 + if (is_not_root)
61401 + *(path + bufsize) = '/';
61402 + memcpy(path + bufsize + is_not_root, name, namelen);
61403 + *(path + bufsize + namelen + is_not_root) = '\0';
61404 +
61405 + tmp = obj->globbed;
61406 + while (tmp) {
61407 + if (!glob_match(tmp->filename, path)) {
61408 + preempt_enable();
61409 + return (tmp->mode & GR_FIND) ? 1 : 0;
61410 + }
61411 + tmp = tmp->next;
61412 + }
61413 + preempt_enable();
61414 + return (obj->mode & GR_FIND) ? 1 : 0;
61415 +}
61416 +
61417 +void gr_put_exec_file(struct task_struct *task)
61418 +{
61419 + struct file *filp;
61420 +
61421 + write_lock(&grsec_exec_file_lock);
61422 + filp = task->exec_file;
61423 + task->exec_file = NULL;
61424 + write_unlock(&grsec_exec_file_lock);
61425 +
61426 + if (filp)
61427 + fput(filp);
61428 +
61429 + return;
61430 +}
61431 +
61432 +
61433 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
61434 +EXPORT_SYMBOL(gr_acl_is_enabled);
61435 +#endif
61436 +EXPORT_SYMBOL(gr_set_kernel_label);
61437 +#ifdef CONFIG_SECURITY
61438 +EXPORT_SYMBOL(gr_check_user_change);
61439 +EXPORT_SYMBOL(gr_check_group_change);
61440 +#endif
61441 +
61442 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
61443 new file mode 100644
61444 index 0000000..34fefda
61445 --- /dev/null
61446 +++ b/grsecurity/gracl_alloc.c
61447 @@ -0,0 +1,105 @@
61448 +#include <linux/kernel.h>
61449 +#include <linux/mm.h>
61450 +#include <linux/slab.h>
61451 +#include <linux/vmalloc.h>
61452 +#include <linux/gracl.h>
61453 +#include <linux/grsecurity.h>
61454 +
61455 +static unsigned long alloc_stack_next = 1;
61456 +static unsigned long alloc_stack_size = 1;
61457 +static void **alloc_stack;
61458 +
61459 +static __inline__ int
61460 +alloc_pop(void)
61461 +{
61462 + if (alloc_stack_next == 1)
61463 + return 0;
61464 +
61465 + kfree(alloc_stack[alloc_stack_next - 2]);
61466 +
61467 + alloc_stack_next--;
61468 +
61469 + return 1;
61470 +}
61471 +
61472 +static __inline__ int
61473 +alloc_push(void *buf)
61474 +{
61475 + if (alloc_stack_next >= alloc_stack_size)
61476 + return 1;
61477 +
61478 + alloc_stack[alloc_stack_next - 1] = buf;
61479 +
61480 + alloc_stack_next++;
61481 +
61482 + return 0;
61483 +}
61484 +
61485 +void *
61486 +acl_alloc(unsigned long len)
61487 +{
61488 + void *ret = NULL;
61489 +
61490 + if (!len || len > PAGE_SIZE)
61491 + goto out;
61492 +
61493 + ret = kmalloc(len, GFP_KERNEL);
61494 +
61495 + if (ret) {
61496 + if (alloc_push(ret)) {
61497 + kfree(ret);
61498 + ret = NULL;
61499 + }
61500 + }
61501 +
61502 +out:
61503 + return ret;
61504 +}
61505 +
61506 +void *
61507 +acl_alloc_num(unsigned long num, unsigned long len)
61508 +{
61509 + if (!len || (num > (PAGE_SIZE / len)))
61510 + return NULL;
61511 +
61512 + return acl_alloc(num * len);
61513 +}
61514 +
61515 +void
61516 +acl_free_all(void)
61517 +{
61518 + if (gr_acl_is_enabled() || !alloc_stack)
61519 + return;
61520 +
61521 + while (alloc_pop()) ;
61522 +
61523 + if (alloc_stack) {
61524 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
61525 + kfree(alloc_stack);
61526 + else
61527 + vfree(alloc_stack);
61528 + }
61529 +
61530 + alloc_stack = NULL;
61531 + alloc_stack_size = 1;
61532 + alloc_stack_next = 1;
61533 +
61534 + return;
61535 +}
61536 +
61537 +int
61538 +acl_alloc_stack_init(unsigned long size)
61539 +{
61540 + if ((size * sizeof (void *)) <= PAGE_SIZE)
61541 + alloc_stack =
61542 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
61543 + else
61544 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
61545 +
61546 + alloc_stack_size = size;
61547 +
61548 + if (!alloc_stack)
61549 + return 0;
61550 + else
61551 + return 1;
61552 +}
61553 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
61554 new file mode 100644
61555 index 0000000..bdd51ea
61556 --- /dev/null
61557 +++ b/grsecurity/gracl_cap.c
61558 @@ -0,0 +1,110 @@
61559 +#include <linux/kernel.h>
61560 +#include <linux/module.h>
61561 +#include <linux/sched.h>
61562 +#include <linux/gracl.h>
61563 +#include <linux/grsecurity.h>
61564 +#include <linux/grinternal.h>
61565 +
61566 +extern const char *captab_log[];
61567 +extern int captab_log_entries;
61568 +
61569 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
61570 +{
61571 + struct acl_subject_label *curracl;
61572 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61573 + kernel_cap_t cap_audit = __cap_empty_set;
61574 +
61575 + if (!gr_acl_is_enabled())
61576 + return 1;
61577 +
61578 + curracl = task->acl;
61579 +
61580 + cap_drop = curracl->cap_lower;
61581 + cap_mask = curracl->cap_mask;
61582 + cap_audit = curracl->cap_invert_audit;
61583 +
61584 + while ((curracl = curracl->parent_subject)) {
61585 + /* if the cap isn't specified in the current computed mask but is specified in the
61586 + current level subject, and is lowered in the current level subject, then add
61587 + it to the set of dropped capabilities
61588 + otherwise, add the current level subject's mask to the current computed mask
61589 + */
61590 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61591 + cap_raise(cap_mask, cap);
61592 + if (cap_raised(curracl->cap_lower, cap))
61593 + cap_raise(cap_drop, cap);
61594 + if (cap_raised(curracl->cap_invert_audit, cap))
61595 + cap_raise(cap_audit, cap);
61596 + }
61597 + }
61598 +
61599 + if (!cap_raised(cap_drop, cap)) {
61600 + if (cap_raised(cap_audit, cap))
61601 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
61602 + return 1;
61603 + }
61604 +
61605 + curracl = task->acl;
61606 +
61607 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
61608 + && cap_raised(cred->cap_effective, cap)) {
61609 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61610 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
61611 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
61612 + gr_to_filename(task->exec_file->f_path.dentry,
61613 + task->exec_file->f_path.mnt) : curracl->filename,
61614 + curracl->filename, 0UL,
61615 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
61616 + return 1;
61617 + }
61618 +
61619 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
61620 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
61621 +
61622 + return 0;
61623 +}
61624 +
61625 +int
61626 +gr_acl_is_capable(const int cap)
61627 +{
61628 + return gr_task_acl_is_capable(current, current_cred(), cap);
61629 +}
61630 +
61631 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
61632 +{
61633 + struct acl_subject_label *curracl;
61634 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61635 +
61636 + if (!gr_acl_is_enabled())
61637 + return 1;
61638 +
61639 + curracl = task->acl;
61640 +
61641 + cap_drop = curracl->cap_lower;
61642 + cap_mask = curracl->cap_mask;
61643 +
61644 + while ((curracl = curracl->parent_subject)) {
61645 + /* if the cap isn't specified in the current computed mask but is specified in the
61646 + current level subject, and is lowered in the current level subject, then add
61647 + it to the set of dropped capabilities
61648 + otherwise, add the current level subject's mask to the current computed mask
61649 + */
61650 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61651 + cap_raise(cap_mask, cap);
61652 + if (cap_raised(curracl->cap_lower, cap))
61653 + cap_raise(cap_drop, cap);
61654 + }
61655 + }
61656 +
61657 + if (!cap_raised(cap_drop, cap))
61658 + return 1;
61659 +
61660 + return 0;
61661 +}
61662 +
61663 +int
61664 +gr_acl_is_capable_nolog(const int cap)
61665 +{
61666 + return gr_task_acl_is_capable_nolog(current, cap);
61667 +}
61668 +
61669 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
61670 new file mode 100644
61671 index 0000000..a340c17
61672 --- /dev/null
61673 +++ b/grsecurity/gracl_fs.c
61674 @@ -0,0 +1,431 @@
61675 +#include <linux/kernel.h>
61676 +#include <linux/sched.h>
61677 +#include <linux/types.h>
61678 +#include <linux/fs.h>
61679 +#include <linux/file.h>
61680 +#include <linux/stat.h>
61681 +#include <linux/grsecurity.h>
61682 +#include <linux/grinternal.h>
61683 +#include <linux/gracl.h>
61684 +
61685 +umode_t
61686 +gr_acl_umask(void)
61687 +{
61688 + if (unlikely(!gr_acl_is_enabled()))
61689 + return 0;
61690 +
61691 + return current->role->umask;
61692 +}
61693 +
61694 +__u32
61695 +gr_acl_handle_hidden_file(const struct dentry * dentry,
61696 + const struct vfsmount * mnt)
61697 +{
61698 + __u32 mode;
61699 +
61700 + if (unlikely(!dentry->d_inode))
61701 + return GR_FIND;
61702 +
61703 + mode =
61704 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
61705 +
61706 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
61707 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61708 + return mode;
61709 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
61710 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61711 + return 0;
61712 + } else if (unlikely(!(mode & GR_FIND)))
61713 + return 0;
61714 +
61715 + return GR_FIND;
61716 +}
61717 +
61718 +__u32
61719 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
61720 + int acc_mode)
61721 +{
61722 + __u32 reqmode = GR_FIND;
61723 + __u32 mode;
61724 +
61725 + if (unlikely(!dentry->d_inode))
61726 + return reqmode;
61727 +
61728 + if (acc_mode & MAY_APPEND)
61729 + reqmode |= GR_APPEND;
61730 + else if (acc_mode & MAY_WRITE)
61731 + reqmode |= GR_WRITE;
61732 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
61733 + reqmode |= GR_READ;
61734 +
61735 + mode =
61736 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61737 + mnt);
61738 +
61739 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61740 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61741 + reqmode & GR_READ ? " reading" : "",
61742 + reqmode & GR_WRITE ? " writing" : reqmode &
61743 + GR_APPEND ? " appending" : "");
61744 + return reqmode;
61745 + } else
61746 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61747 + {
61748 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61749 + reqmode & GR_READ ? " reading" : "",
61750 + reqmode & GR_WRITE ? " writing" : reqmode &
61751 + GR_APPEND ? " appending" : "");
61752 + return 0;
61753 + } else if (unlikely((mode & reqmode) != reqmode))
61754 + return 0;
61755 +
61756 + return reqmode;
61757 +}
61758 +
61759 +__u32
61760 +gr_acl_handle_creat(const struct dentry * dentry,
61761 + const struct dentry * p_dentry,
61762 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
61763 + const int imode)
61764 +{
61765 + __u32 reqmode = GR_WRITE | GR_CREATE;
61766 + __u32 mode;
61767 +
61768 + if (acc_mode & MAY_APPEND)
61769 + reqmode |= GR_APPEND;
61770 + // if a directory was required or the directory already exists, then
61771 + // don't count this open as a read
61772 + if ((acc_mode & MAY_READ) &&
61773 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
61774 + reqmode |= GR_READ;
61775 + if ((open_flags & O_CREAT) &&
61776 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
61777 + reqmode |= GR_SETID;
61778 +
61779 + mode =
61780 + gr_check_create(dentry, p_dentry, p_mnt,
61781 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
61782 +
61783 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61784 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
61785 + reqmode & GR_READ ? " reading" : "",
61786 + reqmode & GR_WRITE ? " writing" : reqmode &
61787 + GR_APPEND ? " appending" : "");
61788 + return reqmode;
61789 + } else
61790 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61791 + {
61792 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
61793 + reqmode & GR_READ ? " reading" : "",
61794 + reqmode & GR_WRITE ? " writing" : reqmode &
61795 + GR_APPEND ? " appending" : "");
61796 + return 0;
61797 + } else if (unlikely((mode & reqmode) != reqmode))
61798 + return 0;
61799 +
61800 + return reqmode;
61801 +}
61802 +
61803 +__u32
61804 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
61805 + const int fmode)
61806 +{
61807 + __u32 mode, reqmode = GR_FIND;
61808 +
61809 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
61810 + reqmode |= GR_EXEC;
61811 + if (fmode & S_IWOTH)
61812 + reqmode |= GR_WRITE;
61813 + if (fmode & S_IROTH)
61814 + reqmode |= GR_READ;
61815 +
61816 + mode =
61817 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61818 + mnt);
61819 +
61820 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61821 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
61822 + reqmode & GR_READ ? " reading" : "",
61823 + reqmode & GR_WRITE ? " writing" : "",
61824 + reqmode & GR_EXEC ? " executing" : "");
61825 + return reqmode;
61826 + } else
61827 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61828 + {
61829 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
61830 + reqmode & GR_READ ? " reading" : "",
61831 + reqmode & GR_WRITE ? " writing" : "",
61832 + reqmode & GR_EXEC ? " executing" : "");
61833 + return 0;
61834 + } else if (unlikely((mode & reqmode) != reqmode))
61835 + return 0;
61836 +
61837 + return reqmode;
61838 +}
61839 +
61840 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
61841 +{
61842 + __u32 mode;
61843 +
61844 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
61845 +
61846 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
61847 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
61848 + return mode;
61849 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
61850 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
61851 + return 0;
61852 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
61853 + return 0;
61854 +
61855 + return (reqmode);
61856 +}
61857 +
61858 +__u32
61859 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
61860 +{
61861 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
61862 +}
61863 +
61864 +__u32
61865 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
61866 +{
61867 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
61868 +}
61869 +
61870 +__u32
61871 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
61872 +{
61873 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
61874 +}
61875 +
61876 +__u32
61877 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
61878 +{
61879 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
61880 +}
61881 +
61882 +__u32
61883 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
61884 + umode_t *modeptr)
61885 +{
61886 + umode_t mode;
61887 +
61888 + *modeptr &= ~gr_acl_umask();
61889 + mode = *modeptr;
61890 +
61891 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
61892 + return 1;
61893 +
61894 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
61895 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
61896 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
61897 + GR_CHMOD_ACL_MSG);
61898 + } else {
61899 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
61900 + }
61901 +}
61902 +
61903 +__u32
61904 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
61905 +{
61906 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
61907 +}
61908 +
61909 +__u32
61910 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
61911 +{
61912 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
61913 +}
61914 +
61915 +__u32
61916 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
61917 +{
61918 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
61919 +}
61920 +
61921 +__u32
61922 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
61923 +{
61924 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
61925 + GR_UNIXCONNECT_ACL_MSG);
61926 +}
61927 +
61928 +/* hardlinks require at minimum create and link permission,
61929 + any additional privilege required is based on the
61930 + privilege of the file being linked to
61931 +*/
61932 +__u32
61933 +gr_acl_handle_link(const struct dentry * new_dentry,
61934 + const struct dentry * parent_dentry,
61935 + const struct vfsmount * parent_mnt,
61936 + const struct dentry * old_dentry,
61937 + const struct vfsmount * old_mnt, const struct filename *to)
61938 +{
61939 + __u32 mode;
61940 + __u32 needmode = GR_CREATE | GR_LINK;
61941 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
61942 +
61943 + mode =
61944 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
61945 + old_mnt);
61946 +
61947 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
61948 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
61949 + return mode;
61950 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
61951 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
61952 + return 0;
61953 + } else if (unlikely((mode & needmode) != needmode))
61954 + return 0;
61955 +
61956 + return 1;
61957 +}
61958 +
61959 +__u32
61960 +gr_acl_handle_symlink(const struct dentry * new_dentry,
61961 + const struct dentry * parent_dentry,
61962 + const struct vfsmount * parent_mnt, const struct filename *from)
61963 +{
61964 + __u32 needmode = GR_WRITE | GR_CREATE;
61965 + __u32 mode;
61966 +
61967 + mode =
61968 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
61969 + GR_CREATE | GR_AUDIT_CREATE |
61970 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
61971 +
61972 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
61973 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
61974 + return mode;
61975 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
61976 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
61977 + return 0;
61978 + } else if (unlikely((mode & needmode) != needmode))
61979 + return 0;
61980 +
61981 + return (GR_WRITE | GR_CREATE);
61982 +}
61983 +
61984 +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)
61985 +{
61986 + __u32 mode;
61987 +
61988 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
61989 +
61990 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
61991 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
61992 + return mode;
61993 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
61994 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
61995 + return 0;
61996 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
61997 + return 0;
61998 +
61999 + return (reqmode);
62000 +}
62001 +
62002 +__u32
62003 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62004 + const struct dentry * parent_dentry,
62005 + const struct vfsmount * parent_mnt,
62006 + const int mode)
62007 +{
62008 + __u32 reqmode = GR_WRITE | GR_CREATE;
62009 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62010 + reqmode |= GR_SETID;
62011 +
62012 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62013 + reqmode, GR_MKNOD_ACL_MSG);
62014 +}
62015 +
62016 +__u32
62017 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62018 + const struct dentry *parent_dentry,
62019 + const struct vfsmount *parent_mnt)
62020 +{
62021 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62022 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62023 +}
62024 +
62025 +#define RENAME_CHECK_SUCCESS(old, new) \
62026 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62027 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62028 +
62029 +int
62030 +gr_acl_handle_rename(struct dentry *new_dentry,
62031 + struct dentry *parent_dentry,
62032 + const struct vfsmount *parent_mnt,
62033 + struct dentry *old_dentry,
62034 + struct inode *old_parent_inode,
62035 + struct vfsmount *old_mnt, const struct filename *newname)
62036 +{
62037 + __u32 comp1, comp2;
62038 + int error = 0;
62039 +
62040 + if (unlikely(!gr_acl_is_enabled()))
62041 + return 0;
62042 +
62043 + if (!new_dentry->d_inode) {
62044 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62045 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62046 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62047 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62048 + GR_DELETE | GR_AUDIT_DELETE |
62049 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62050 + GR_SUPPRESS, old_mnt);
62051 + } else {
62052 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62053 + GR_CREATE | GR_DELETE |
62054 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62055 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62056 + GR_SUPPRESS, parent_mnt);
62057 + comp2 =
62058 + gr_search_file(old_dentry,
62059 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62060 + GR_DELETE | GR_AUDIT_DELETE |
62061 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62062 + }
62063 +
62064 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62065 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62066 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62067 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62068 + && !(comp2 & GR_SUPPRESS)) {
62069 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62070 + error = -EACCES;
62071 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62072 + error = -EACCES;
62073 +
62074 + return error;
62075 +}
62076 +
62077 +void
62078 +gr_acl_handle_exit(void)
62079 +{
62080 + u16 id;
62081 + char *rolename;
62082 +
62083 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62084 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62085 + id = current->acl_role_id;
62086 + rolename = current->role->rolename;
62087 + gr_set_acls(1);
62088 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62089 + }
62090 +
62091 + gr_put_exec_file(current);
62092 + return;
62093 +}
62094 +
62095 +int
62096 +gr_acl_handle_procpidmem(const struct task_struct *task)
62097 +{
62098 + if (unlikely(!gr_acl_is_enabled()))
62099 + return 0;
62100 +
62101 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62102 + return -EACCES;
62103 +
62104 + return 0;
62105 +}
62106 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62107 new file mode 100644
62108 index 0000000..4699807
62109 --- /dev/null
62110 +++ b/grsecurity/gracl_ip.c
62111 @@ -0,0 +1,384 @@
62112 +#include <linux/kernel.h>
62113 +#include <asm/uaccess.h>
62114 +#include <asm/errno.h>
62115 +#include <net/sock.h>
62116 +#include <linux/file.h>
62117 +#include <linux/fs.h>
62118 +#include <linux/net.h>
62119 +#include <linux/in.h>
62120 +#include <linux/skbuff.h>
62121 +#include <linux/ip.h>
62122 +#include <linux/udp.h>
62123 +#include <linux/types.h>
62124 +#include <linux/sched.h>
62125 +#include <linux/netdevice.h>
62126 +#include <linux/inetdevice.h>
62127 +#include <linux/gracl.h>
62128 +#include <linux/grsecurity.h>
62129 +#include <linux/grinternal.h>
62130 +
62131 +#define GR_BIND 0x01
62132 +#define GR_CONNECT 0x02
62133 +#define GR_INVERT 0x04
62134 +#define GR_BINDOVERRIDE 0x08
62135 +#define GR_CONNECTOVERRIDE 0x10
62136 +#define GR_SOCK_FAMILY 0x20
62137 +
62138 +static const char * gr_protocols[IPPROTO_MAX] = {
62139 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62140 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62141 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62142 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62143 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62144 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62145 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62146 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62147 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62148 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62149 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62150 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62151 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62152 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62153 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62154 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62155 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62156 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62157 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62158 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62159 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62160 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62161 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62162 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62163 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62164 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62165 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62166 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62167 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62168 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62169 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62170 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62171 + };
62172 +
62173 +static const char * gr_socktypes[SOCK_MAX] = {
62174 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62175 + "unknown:7", "unknown:8", "unknown:9", "packet"
62176 + };
62177 +
62178 +static const char * gr_sockfamilies[AF_MAX+1] = {
62179 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62180 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62181 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62182 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62183 + };
62184 +
62185 +const char *
62186 +gr_proto_to_name(unsigned char proto)
62187 +{
62188 + return gr_protocols[proto];
62189 +}
62190 +
62191 +const char *
62192 +gr_socktype_to_name(unsigned char type)
62193 +{
62194 + return gr_socktypes[type];
62195 +}
62196 +
62197 +const char *
62198 +gr_sockfamily_to_name(unsigned char family)
62199 +{
62200 + return gr_sockfamilies[family];
62201 +}
62202 +
62203 +int
62204 +gr_search_socket(const int domain, const int type, const int protocol)
62205 +{
62206 + struct acl_subject_label *curr;
62207 + const struct cred *cred = current_cred();
62208 +
62209 + if (unlikely(!gr_acl_is_enabled()))
62210 + goto exit;
62211 +
62212 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62213 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62214 + goto exit; // let the kernel handle it
62215 +
62216 + curr = current->acl;
62217 +
62218 + if (curr->sock_families[domain / 32] & (1 << (domain % 32))) {
62219 + /* the family is allowed, if this is PF_INET allow it only if
62220 + the extra sock type/protocol checks pass */
62221 + if (domain == PF_INET)
62222 + goto inet_check;
62223 + goto exit;
62224 + } else {
62225 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62226 + __u32 fakeip = 0;
62227 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62228 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62229 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62230 + gr_to_filename(current->exec_file->f_path.dentry,
62231 + current->exec_file->f_path.mnt) :
62232 + curr->filename, curr->filename,
62233 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62234 + &current->signal->saved_ip);
62235 + goto exit;
62236 + }
62237 + goto exit_fail;
62238 + }
62239 +
62240 +inet_check:
62241 + /* the rest of this checking is for IPv4 only */
62242 + if (!curr->ips)
62243 + goto exit;
62244 +
62245 + if ((curr->ip_type & (1 << type)) &&
62246 + (curr->ip_proto[protocol / 32] & (1 << (protocol % 32))))
62247 + goto exit;
62248 +
62249 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62250 + /* we don't place acls on raw sockets , and sometimes
62251 + dgram/ip sockets are opened for ioctl and not
62252 + bind/connect, so we'll fake a bind learn log */
62253 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62254 + __u32 fakeip = 0;
62255 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62256 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62257 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62258 + gr_to_filename(current->exec_file->f_path.dentry,
62259 + current->exec_file->f_path.mnt) :
62260 + curr->filename, curr->filename,
62261 + &fakeip, 0, type,
62262 + protocol, GR_CONNECT, &current->signal->saved_ip);
62263 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62264 + __u32 fakeip = 0;
62265 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62266 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62267 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62268 + gr_to_filename(current->exec_file->f_path.dentry,
62269 + current->exec_file->f_path.mnt) :
62270 + curr->filename, curr->filename,
62271 + &fakeip, 0, type,
62272 + protocol, GR_BIND, &current->signal->saved_ip);
62273 + }
62274 + /* we'll log when they use connect or bind */
62275 + goto exit;
62276 + }
62277 +
62278 +exit_fail:
62279 + if (domain == PF_INET)
62280 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62281 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62282 + else
62283 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62284 + gr_socktype_to_name(type), protocol);
62285 +
62286 + return 0;
62287 +exit:
62288 + return 1;
62289 +}
62290 +
62291 +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)
62292 +{
62293 + if ((ip->mode & mode) &&
62294 + (ip_port >= ip->low) &&
62295 + (ip_port <= ip->high) &&
62296 + ((ntohl(ip_addr) & our_netmask) ==
62297 + (ntohl(our_addr) & our_netmask))
62298 + && (ip->proto[protocol / 32] & (1 << (protocol % 32)))
62299 + && (ip->type & (1 << type))) {
62300 + if (ip->mode & GR_INVERT)
62301 + return 2; // specifically denied
62302 + else
62303 + return 1; // allowed
62304 + }
62305 +
62306 + return 0; // not specifically allowed, may continue parsing
62307 +}
62308 +
62309 +static int
62310 +gr_search_connectbind(const int full_mode, struct sock *sk,
62311 + struct sockaddr_in *addr, const int type)
62312 +{
62313 + char iface[IFNAMSIZ] = {0};
62314 + struct acl_subject_label *curr;
62315 + struct acl_ip_label *ip;
62316 + struct inet_sock *isk;
62317 + struct net_device *dev;
62318 + struct in_device *idev;
62319 + unsigned long i;
62320 + int ret;
62321 + int mode = full_mode & (GR_BIND | GR_CONNECT);
62322 + __u32 ip_addr = 0;
62323 + __u32 our_addr;
62324 + __u32 our_netmask;
62325 + char *p;
62326 + __u16 ip_port = 0;
62327 + const struct cred *cred = current_cred();
62328 +
62329 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
62330 + return 0;
62331 +
62332 + curr = current->acl;
62333 + isk = inet_sk(sk);
62334 +
62335 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
62336 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
62337 + addr->sin_addr.s_addr = curr->inaddr_any_override;
62338 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
62339 + struct sockaddr_in saddr;
62340 + int err;
62341 +
62342 + saddr.sin_family = AF_INET;
62343 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
62344 + saddr.sin_port = isk->inet_sport;
62345 +
62346 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62347 + if (err)
62348 + return err;
62349 +
62350 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62351 + if (err)
62352 + return err;
62353 + }
62354 +
62355 + if (!curr->ips)
62356 + return 0;
62357 +
62358 + ip_addr = addr->sin_addr.s_addr;
62359 + ip_port = ntohs(addr->sin_port);
62360 +
62361 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62362 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62363 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62364 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62365 + gr_to_filename(current->exec_file->f_path.dentry,
62366 + current->exec_file->f_path.mnt) :
62367 + curr->filename, curr->filename,
62368 + &ip_addr, ip_port, type,
62369 + sk->sk_protocol, mode, &current->signal->saved_ip);
62370 + return 0;
62371 + }
62372 +
62373 + for (i = 0; i < curr->ip_num; i++) {
62374 + ip = *(curr->ips + i);
62375 + if (ip->iface != NULL) {
62376 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
62377 + p = strchr(iface, ':');
62378 + if (p != NULL)
62379 + *p = '\0';
62380 + dev = dev_get_by_name(sock_net(sk), iface);
62381 + if (dev == NULL)
62382 + continue;
62383 + idev = in_dev_get(dev);
62384 + if (idev == NULL) {
62385 + dev_put(dev);
62386 + continue;
62387 + }
62388 + rcu_read_lock();
62389 + for_ifa(idev) {
62390 + if (!strcmp(ip->iface, ifa->ifa_label)) {
62391 + our_addr = ifa->ifa_address;
62392 + our_netmask = 0xffffffff;
62393 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62394 + if (ret == 1) {
62395 + rcu_read_unlock();
62396 + in_dev_put(idev);
62397 + dev_put(dev);
62398 + return 0;
62399 + } else if (ret == 2) {
62400 + rcu_read_unlock();
62401 + in_dev_put(idev);
62402 + dev_put(dev);
62403 + goto denied;
62404 + }
62405 + }
62406 + } endfor_ifa(idev);
62407 + rcu_read_unlock();
62408 + in_dev_put(idev);
62409 + dev_put(dev);
62410 + } else {
62411 + our_addr = ip->addr;
62412 + our_netmask = ip->netmask;
62413 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62414 + if (ret == 1)
62415 + return 0;
62416 + else if (ret == 2)
62417 + goto denied;
62418 + }
62419 + }
62420 +
62421 +denied:
62422 + if (mode == GR_BIND)
62423 + 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));
62424 + else if (mode == GR_CONNECT)
62425 + 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));
62426 +
62427 + return -EACCES;
62428 +}
62429 +
62430 +int
62431 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
62432 +{
62433 + /* always allow disconnection of dgram sockets with connect */
62434 + if (addr->sin_family == AF_UNSPEC)
62435 + return 0;
62436 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
62437 +}
62438 +
62439 +int
62440 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
62441 +{
62442 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
62443 +}
62444 +
62445 +int gr_search_listen(struct socket *sock)
62446 +{
62447 + struct sock *sk = sock->sk;
62448 + struct sockaddr_in addr;
62449 +
62450 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62451 + addr.sin_port = inet_sk(sk)->inet_sport;
62452 +
62453 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62454 +}
62455 +
62456 +int gr_search_accept(struct socket *sock)
62457 +{
62458 + struct sock *sk = sock->sk;
62459 + struct sockaddr_in addr;
62460 +
62461 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62462 + addr.sin_port = inet_sk(sk)->inet_sport;
62463 +
62464 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62465 +}
62466 +
62467 +int
62468 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
62469 +{
62470 + if (addr)
62471 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
62472 + else {
62473 + struct sockaddr_in sin;
62474 + const struct inet_sock *inet = inet_sk(sk);
62475 +
62476 + sin.sin_addr.s_addr = inet->inet_daddr;
62477 + sin.sin_port = inet->inet_dport;
62478 +
62479 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62480 + }
62481 +}
62482 +
62483 +int
62484 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
62485 +{
62486 + struct sockaddr_in sin;
62487 +
62488 + if (unlikely(skb->len < sizeof (struct udphdr)))
62489 + return 0; // skip this packet
62490 +
62491 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
62492 + sin.sin_port = udp_hdr(skb)->source;
62493 +
62494 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62495 +}
62496 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
62497 new file mode 100644
62498 index 0000000..25f54ef
62499 --- /dev/null
62500 +++ b/grsecurity/gracl_learn.c
62501 @@ -0,0 +1,207 @@
62502 +#include <linux/kernel.h>
62503 +#include <linux/mm.h>
62504 +#include <linux/sched.h>
62505 +#include <linux/poll.h>
62506 +#include <linux/string.h>
62507 +#include <linux/file.h>
62508 +#include <linux/types.h>
62509 +#include <linux/vmalloc.h>
62510 +#include <linux/grinternal.h>
62511 +
62512 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
62513 + size_t count, loff_t *ppos);
62514 +extern int gr_acl_is_enabled(void);
62515 +
62516 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
62517 +static int gr_learn_attached;
62518 +
62519 +/* use a 512k buffer */
62520 +#define LEARN_BUFFER_SIZE (512 * 1024)
62521 +
62522 +static DEFINE_SPINLOCK(gr_learn_lock);
62523 +static DEFINE_MUTEX(gr_learn_user_mutex);
62524 +
62525 +/* we need to maintain two buffers, so that the kernel context of grlearn
62526 + uses a semaphore around the userspace copying, and the other kernel contexts
62527 + use a spinlock when copying into the buffer, since they cannot sleep
62528 +*/
62529 +static char *learn_buffer;
62530 +static char *learn_buffer_user;
62531 +static int learn_buffer_len;
62532 +static int learn_buffer_user_len;
62533 +
62534 +static ssize_t
62535 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
62536 +{
62537 + DECLARE_WAITQUEUE(wait, current);
62538 + ssize_t retval = 0;
62539 +
62540 + add_wait_queue(&learn_wait, &wait);
62541 + set_current_state(TASK_INTERRUPTIBLE);
62542 + do {
62543 + mutex_lock(&gr_learn_user_mutex);
62544 + spin_lock(&gr_learn_lock);
62545 + if (learn_buffer_len)
62546 + break;
62547 + spin_unlock(&gr_learn_lock);
62548 + mutex_unlock(&gr_learn_user_mutex);
62549 + if (file->f_flags & O_NONBLOCK) {
62550 + retval = -EAGAIN;
62551 + goto out;
62552 + }
62553 + if (signal_pending(current)) {
62554 + retval = -ERESTARTSYS;
62555 + goto out;
62556 + }
62557 +
62558 + schedule();
62559 + } while (1);
62560 +
62561 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
62562 + learn_buffer_user_len = learn_buffer_len;
62563 + retval = learn_buffer_len;
62564 + learn_buffer_len = 0;
62565 +
62566 + spin_unlock(&gr_learn_lock);
62567 +
62568 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
62569 + retval = -EFAULT;
62570 +
62571 + mutex_unlock(&gr_learn_user_mutex);
62572 +out:
62573 + set_current_state(TASK_RUNNING);
62574 + remove_wait_queue(&learn_wait, &wait);
62575 + return retval;
62576 +}
62577 +
62578 +static unsigned int
62579 +poll_learn(struct file * file, poll_table * wait)
62580 +{
62581 + poll_wait(file, &learn_wait, wait);
62582 +
62583 + if (learn_buffer_len)
62584 + return (POLLIN | POLLRDNORM);
62585 +
62586 + return 0;
62587 +}
62588 +
62589 +void
62590 +gr_clear_learn_entries(void)
62591 +{
62592 + char *tmp;
62593 +
62594 + mutex_lock(&gr_learn_user_mutex);
62595 + spin_lock(&gr_learn_lock);
62596 + tmp = learn_buffer;
62597 + learn_buffer = NULL;
62598 + spin_unlock(&gr_learn_lock);
62599 + if (tmp)
62600 + vfree(tmp);
62601 + if (learn_buffer_user != NULL) {
62602 + vfree(learn_buffer_user);
62603 + learn_buffer_user = NULL;
62604 + }
62605 + learn_buffer_len = 0;
62606 + mutex_unlock(&gr_learn_user_mutex);
62607 +
62608 + return;
62609 +}
62610 +
62611 +void
62612 +gr_add_learn_entry(const char *fmt, ...)
62613 +{
62614 + va_list args;
62615 + unsigned int len;
62616 +
62617 + if (!gr_learn_attached)
62618 + return;
62619 +
62620 + spin_lock(&gr_learn_lock);
62621 +
62622 + /* leave a gap at the end so we know when it's "full" but don't have to
62623 + compute the exact length of the string we're trying to append
62624 + */
62625 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
62626 + spin_unlock(&gr_learn_lock);
62627 + wake_up_interruptible(&learn_wait);
62628 + return;
62629 + }
62630 + if (learn_buffer == NULL) {
62631 + spin_unlock(&gr_learn_lock);
62632 + return;
62633 + }
62634 +
62635 + va_start(args, fmt);
62636 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
62637 + va_end(args);
62638 +
62639 + learn_buffer_len += len + 1;
62640 +
62641 + spin_unlock(&gr_learn_lock);
62642 + wake_up_interruptible(&learn_wait);
62643 +
62644 + return;
62645 +}
62646 +
62647 +static int
62648 +open_learn(struct inode *inode, struct file *file)
62649 +{
62650 + if (file->f_mode & FMODE_READ && gr_learn_attached)
62651 + return -EBUSY;
62652 + if (file->f_mode & FMODE_READ) {
62653 + int retval = 0;
62654 + mutex_lock(&gr_learn_user_mutex);
62655 + if (learn_buffer == NULL)
62656 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
62657 + if (learn_buffer_user == NULL)
62658 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
62659 + if (learn_buffer == NULL) {
62660 + retval = -ENOMEM;
62661 + goto out_error;
62662 + }
62663 + if (learn_buffer_user == NULL) {
62664 + retval = -ENOMEM;
62665 + goto out_error;
62666 + }
62667 + learn_buffer_len = 0;
62668 + learn_buffer_user_len = 0;
62669 + gr_learn_attached = 1;
62670 +out_error:
62671 + mutex_unlock(&gr_learn_user_mutex);
62672 + return retval;
62673 + }
62674 + return 0;
62675 +}
62676 +
62677 +static int
62678 +close_learn(struct inode *inode, struct file *file)
62679 +{
62680 + if (file->f_mode & FMODE_READ) {
62681 + char *tmp = NULL;
62682 + mutex_lock(&gr_learn_user_mutex);
62683 + spin_lock(&gr_learn_lock);
62684 + tmp = learn_buffer;
62685 + learn_buffer = NULL;
62686 + spin_unlock(&gr_learn_lock);
62687 + if (tmp)
62688 + vfree(tmp);
62689 + if (learn_buffer_user != NULL) {
62690 + vfree(learn_buffer_user);
62691 + learn_buffer_user = NULL;
62692 + }
62693 + learn_buffer_len = 0;
62694 + learn_buffer_user_len = 0;
62695 + gr_learn_attached = 0;
62696 + mutex_unlock(&gr_learn_user_mutex);
62697 + }
62698 +
62699 + return 0;
62700 +}
62701 +
62702 +const struct file_operations grsec_fops = {
62703 + .read = read_learn,
62704 + .write = write_grsec_handler,
62705 + .open = open_learn,
62706 + .release = close_learn,
62707 + .poll = poll_learn,
62708 +};
62709 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
62710 new file mode 100644
62711 index 0000000..39645c9
62712 --- /dev/null
62713 +++ b/grsecurity/gracl_res.c
62714 @@ -0,0 +1,68 @@
62715 +#include <linux/kernel.h>
62716 +#include <linux/sched.h>
62717 +#include <linux/gracl.h>
62718 +#include <linux/grinternal.h>
62719 +
62720 +static const char *restab_log[] = {
62721 + [RLIMIT_CPU] = "RLIMIT_CPU",
62722 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
62723 + [RLIMIT_DATA] = "RLIMIT_DATA",
62724 + [RLIMIT_STACK] = "RLIMIT_STACK",
62725 + [RLIMIT_CORE] = "RLIMIT_CORE",
62726 + [RLIMIT_RSS] = "RLIMIT_RSS",
62727 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
62728 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
62729 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
62730 + [RLIMIT_AS] = "RLIMIT_AS",
62731 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
62732 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
62733 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
62734 + [RLIMIT_NICE] = "RLIMIT_NICE",
62735 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
62736 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
62737 + [GR_CRASH_RES] = "RLIMIT_CRASH"
62738 +};
62739 +
62740 +void
62741 +gr_log_resource(const struct task_struct *task,
62742 + const int res, const unsigned long wanted, const int gt)
62743 +{
62744 + const struct cred *cred;
62745 + unsigned long rlim;
62746 +
62747 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
62748 + return;
62749 +
62750 + // not yet supported resource
62751 + if (unlikely(!restab_log[res]))
62752 + return;
62753 +
62754 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
62755 + rlim = task_rlimit_max(task, res);
62756 + else
62757 + rlim = task_rlimit(task, res);
62758 +
62759 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
62760 + return;
62761 +
62762 + rcu_read_lock();
62763 + cred = __task_cred(task);
62764 +
62765 + if (res == RLIMIT_NPROC &&
62766 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
62767 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
62768 + goto out_rcu_unlock;
62769 + else if (res == RLIMIT_MEMLOCK &&
62770 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
62771 + goto out_rcu_unlock;
62772 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
62773 + goto out_rcu_unlock;
62774 + rcu_read_unlock();
62775 +
62776 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
62777 +
62778 + return;
62779 +out_rcu_unlock:
62780 + rcu_read_unlock();
62781 + return;
62782 +}
62783 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
62784 new file mode 100644
62785 index 0000000..8c8fc9d
62786 --- /dev/null
62787 +++ b/grsecurity/gracl_segv.c
62788 @@ -0,0 +1,303 @@
62789 +#include <linux/kernel.h>
62790 +#include <linux/mm.h>
62791 +#include <asm/uaccess.h>
62792 +#include <asm/errno.h>
62793 +#include <asm/mman.h>
62794 +#include <net/sock.h>
62795 +#include <linux/file.h>
62796 +#include <linux/fs.h>
62797 +#include <linux/net.h>
62798 +#include <linux/in.h>
62799 +#include <linux/slab.h>
62800 +#include <linux/types.h>
62801 +#include <linux/sched.h>
62802 +#include <linux/timer.h>
62803 +#include <linux/gracl.h>
62804 +#include <linux/grsecurity.h>
62805 +#include <linux/grinternal.h>
62806 +
62807 +static struct crash_uid *uid_set;
62808 +static unsigned short uid_used;
62809 +static DEFINE_SPINLOCK(gr_uid_lock);
62810 +extern rwlock_t gr_inode_lock;
62811 +extern struct acl_subject_label *
62812 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
62813 + struct acl_role_label *role);
62814 +
62815 +#ifdef CONFIG_BTRFS_FS
62816 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
62817 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
62818 +#endif
62819 +
62820 +static inline dev_t __get_dev(const struct dentry *dentry)
62821 +{
62822 +#ifdef CONFIG_BTRFS_FS
62823 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
62824 + return get_btrfs_dev_from_inode(dentry->d_inode);
62825 + else
62826 +#endif
62827 + return dentry->d_inode->i_sb->s_dev;
62828 +}
62829 +
62830 +int
62831 +gr_init_uidset(void)
62832 +{
62833 + uid_set =
62834 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
62835 + uid_used = 0;
62836 +
62837 + return uid_set ? 1 : 0;
62838 +}
62839 +
62840 +void
62841 +gr_free_uidset(void)
62842 +{
62843 + if (uid_set)
62844 + kfree(uid_set);
62845 +
62846 + return;
62847 +}
62848 +
62849 +int
62850 +gr_find_uid(const uid_t uid)
62851 +{
62852 + struct crash_uid *tmp = uid_set;
62853 + uid_t buid;
62854 + int low = 0, high = uid_used - 1, mid;
62855 +
62856 + while (high >= low) {
62857 + mid = (low + high) >> 1;
62858 + buid = tmp[mid].uid;
62859 + if (buid == uid)
62860 + return mid;
62861 + if (buid > uid)
62862 + high = mid - 1;
62863 + if (buid < uid)
62864 + low = mid + 1;
62865 + }
62866 +
62867 + return -1;
62868 +}
62869 +
62870 +static __inline__ void
62871 +gr_insertsort(void)
62872 +{
62873 + unsigned short i, j;
62874 + struct crash_uid index;
62875 +
62876 + for (i = 1; i < uid_used; i++) {
62877 + index = uid_set[i];
62878 + j = i;
62879 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
62880 + uid_set[j] = uid_set[j - 1];
62881 + j--;
62882 + }
62883 + uid_set[j] = index;
62884 + }
62885 +
62886 + return;
62887 +}
62888 +
62889 +static __inline__ void
62890 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
62891 +{
62892 + int loc;
62893 + uid_t uid = GR_GLOBAL_UID(kuid);
62894 +
62895 + if (uid_used == GR_UIDTABLE_MAX)
62896 + return;
62897 +
62898 + loc = gr_find_uid(uid);
62899 +
62900 + if (loc >= 0) {
62901 + uid_set[loc].expires = expires;
62902 + return;
62903 + }
62904 +
62905 + uid_set[uid_used].uid = uid;
62906 + uid_set[uid_used].expires = expires;
62907 + uid_used++;
62908 +
62909 + gr_insertsort();
62910 +
62911 + return;
62912 +}
62913 +
62914 +void
62915 +gr_remove_uid(const unsigned short loc)
62916 +{
62917 + unsigned short i;
62918 +
62919 + for (i = loc + 1; i < uid_used; i++)
62920 + uid_set[i - 1] = uid_set[i];
62921 +
62922 + uid_used--;
62923 +
62924 + return;
62925 +}
62926 +
62927 +int
62928 +gr_check_crash_uid(const kuid_t kuid)
62929 +{
62930 + int loc;
62931 + int ret = 0;
62932 + uid_t uid;
62933 +
62934 + if (unlikely(!gr_acl_is_enabled()))
62935 + return 0;
62936 +
62937 + uid = GR_GLOBAL_UID(kuid);
62938 +
62939 + spin_lock(&gr_uid_lock);
62940 + loc = gr_find_uid(uid);
62941 +
62942 + if (loc < 0)
62943 + goto out_unlock;
62944 +
62945 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
62946 + gr_remove_uid(loc);
62947 + else
62948 + ret = 1;
62949 +
62950 +out_unlock:
62951 + spin_unlock(&gr_uid_lock);
62952 + return ret;
62953 +}
62954 +
62955 +static __inline__ int
62956 +proc_is_setxid(const struct cred *cred)
62957 +{
62958 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
62959 + !uid_eq(cred->uid, cred->fsuid))
62960 + return 1;
62961 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
62962 + !gid_eq(cred->gid, cred->fsgid))
62963 + return 1;
62964 +
62965 + return 0;
62966 +}
62967 +
62968 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
62969 +
62970 +void
62971 +gr_handle_crash(struct task_struct *task, const int sig)
62972 +{
62973 + struct acl_subject_label *curr;
62974 + struct task_struct *tsk, *tsk2;
62975 + const struct cred *cred;
62976 + const struct cred *cred2;
62977 +
62978 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
62979 + return;
62980 +
62981 + if (unlikely(!gr_acl_is_enabled()))
62982 + return;
62983 +
62984 + curr = task->acl;
62985 +
62986 + if (!(curr->resmask & (1 << GR_CRASH_RES)))
62987 + return;
62988 +
62989 + if (time_before_eq(curr->expires, get_seconds())) {
62990 + curr->expires = 0;
62991 + curr->crashes = 0;
62992 + }
62993 +
62994 + curr->crashes++;
62995 +
62996 + if (!curr->expires)
62997 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
62998 +
62999 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63000 + time_after(curr->expires, get_seconds())) {
63001 + rcu_read_lock();
63002 + cred = __task_cred(task);
63003 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63004 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63005 + spin_lock(&gr_uid_lock);
63006 + gr_insert_uid(cred->uid, curr->expires);
63007 + spin_unlock(&gr_uid_lock);
63008 + curr->expires = 0;
63009 + curr->crashes = 0;
63010 + read_lock(&tasklist_lock);
63011 + do_each_thread(tsk2, tsk) {
63012 + cred2 = __task_cred(tsk);
63013 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63014 + gr_fake_force_sig(SIGKILL, tsk);
63015 + } while_each_thread(tsk2, tsk);
63016 + read_unlock(&tasklist_lock);
63017 + } else {
63018 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63019 + read_lock(&tasklist_lock);
63020 + read_lock(&grsec_exec_file_lock);
63021 + do_each_thread(tsk2, tsk) {
63022 + if (likely(tsk != task)) {
63023 + // if this thread has the same subject as the one that triggered
63024 + // RES_CRASH and it's the same binary, kill it
63025 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63026 + gr_fake_force_sig(SIGKILL, tsk);
63027 + }
63028 + } while_each_thread(tsk2, tsk);
63029 + read_unlock(&grsec_exec_file_lock);
63030 + read_unlock(&tasklist_lock);
63031 + }
63032 + rcu_read_unlock();
63033 + }
63034 +
63035 + return;
63036 +}
63037 +
63038 +int
63039 +gr_check_crash_exec(const struct file *filp)
63040 +{
63041 + struct acl_subject_label *curr;
63042 +
63043 + if (unlikely(!gr_acl_is_enabled()))
63044 + return 0;
63045 +
63046 + read_lock(&gr_inode_lock);
63047 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63048 + __get_dev(filp->f_path.dentry),
63049 + current->role);
63050 + read_unlock(&gr_inode_lock);
63051 +
63052 + if (!curr || !(curr->resmask & (1 << GR_CRASH_RES)) ||
63053 + (!curr->crashes && !curr->expires))
63054 + return 0;
63055 +
63056 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63057 + time_after(curr->expires, get_seconds()))
63058 + return 1;
63059 + else if (time_before_eq(curr->expires, get_seconds())) {
63060 + curr->crashes = 0;
63061 + curr->expires = 0;
63062 + }
63063 +
63064 + return 0;
63065 +}
63066 +
63067 +void
63068 +gr_handle_alertkill(struct task_struct *task)
63069 +{
63070 + struct acl_subject_label *curracl;
63071 + __u32 curr_ip;
63072 + struct task_struct *p, *p2;
63073 +
63074 + if (unlikely(!gr_acl_is_enabled()))
63075 + return;
63076 +
63077 + curracl = task->acl;
63078 + curr_ip = task->signal->curr_ip;
63079 +
63080 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63081 + read_lock(&tasklist_lock);
63082 + do_each_thread(p2, p) {
63083 + if (p->signal->curr_ip == curr_ip)
63084 + gr_fake_force_sig(SIGKILL, p);
63085 + } while_each_thread(p2, p);
63086 + read_unlock(&tasklist_lock);
63087 + } else if (curracl->mode & GR_KILLPROC)
63088 + gr_fake_force_sig(SIGKILL, task);
63089 +
63090 + return;
63091 +}
63092 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63093 new file mode 100644
63094 index 0000000..98011b0
63095 --- /dev/null
63096 +++ b/grsecurity/gracl_shm.c
63097 @@ -0,0 +1,40 @@
63098 +#include <linux/kernel.h>
63099 +#include <linux/mm.h>
63100 +#include <linux/sched.h>
63101 +#include <linux/file.h>
63102 +#include <linux/ipc.h>
63103 +#include <linux/gracl.h>
63104 +#include <linux/grsecurity.h>
63105 +#include <linux/grinternal.h>
63106 +
63107 +int
63108 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63109 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63110 +{
63111 + struct task_struct *task;
63112 +
63113 + if (!gr_acl_is_enabled())
63114 + return 1;
63115 +
63116 + rcu_read_lock();
63117 + read_lock(&tasklist_lock);
63118 +
63119 + task = find_task_by_vpid(shm_cprid);
63120 +
63121 + if (unlikely(!task))
63122 + task = find_task_by_vpid(shm_lapid);
63123 +
63124 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63125 + (task_pid_nr(task) == shm_lapid)) &&
63126 + (task->acl->mode & GR_PROTSHM) &&
63127 + (task->acl != current->acl))) {
63128 + read_unlock(&tasklist_lock);
63129 + rcu_read_unlock();
63130 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63131 + return 0;
63132 + }
63133 + read_unlock(&tasklist_lock);
63134 + rcu_read_unlock();
63135 +
63136 + return 1;
63137 +}
63138 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63139 new file mode 100644
63140 index 0000000..bc0be01
63141 --- /dev/null
63142 +++ b/grsecurity/grsec_chdir.c
63143 @@ -0,0 +1,19 @@
63144 +#include <linux/kernel.h>
63145 +#include <linux/sched.h>
63146 +#include <linux/fs.h>
63147 +#include <linux/file.h>
63148 +#include <linux/grsecurity.h>
63149 +#include <linux/grinternal.h>
63150 +
63151 +void
63152 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63153 +{
63154 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63155 + if ((grsec_enable_chdir && grsec_enable_group &&
63156 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63157 + !grsec_enable_group)) {
63158 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63159 + }
63160 +#endif
63161 + return;
63162 +}
63163 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63164 new file mode 100644
63165 index 0000000..6d2de57
63166 --- /dev/null
63167 +++ b/grsecurity/grsec_chroot.c
63168 @@ -0,0 +1,357 @@
63169 +#include <linux/kernel.h>
63170 +#include <linux/module.h>
63171 +#include <linux/sched.h>
63172 +#include <linux/file.h>
63173 +#include <linux/fs.h>
63174 +#include <linux/mount.h>
63175 +#include <linux/types.h>
63176 +#include "../fs/mount.h"
63177 +#include <linux/grsecurity.h>
63178 +#include <linux/grinternal.h>
63179 +
63180 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
63181 +{
63182 +#ifdef CONFIG_GRKERNSEC
63183 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63184 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
63185 + task->gr_is_chrooted = 1;
63186 + else
63187 + task->gr_is_chrooted = 0;
63188 +
63189 + task->gr_chroot_dentry = path->dentry;
63190 +#endif
63191 + return;
63192 +}
63193 +
63194 +void gr_clear_chroot_entries(struct task_struct *task)
63195 +{
63196 +#ifdef CONFIG_GRKERNSEC
63197 + task->gr_is_chrooted = 0;
63198 + task->gr_chroot_dentry = NULL;
63199 +#endif
63200 + return;
63201 +}
63202 +
63203 +int
63204 +gr_handle_chroot_unix(const pid_t pid)
63205 +{
63206 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63207 + struct task_struct *p;
63208 +
63209 + if (unlikely(!grsec_enable_chroot_unix))
63210 + return 1;
63211 +
63212 + if (likely(!proc_is_chrooted(current)))
63213 + return 1;
63214 +
63215 + rcu_read_lock();
63216 + read_lock(&tasklist_lock);
63217 + p = find_task_by_vpid_unrestricted(pid);
63218 + if (unlikely(p && !have_same_root(current, p))) {
63219 + read_unlock(&tasklist_lock);
63220 + rcu_read_unlock();
63221 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63222 + return 0;
63223 + }
63224 + read_unlock(&tasklist_lock);
63225 + rcu_read_unlock();
63226 +#endif
63227 + return 1;
63228 +}
63229 +
63230 +int
63231 +gr_handle_chroot_nice(void)
63232 +{
63233 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63234 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63235 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63236 + return -EPERM;
63237 + }
63238 +#endif
63239 + return 0;
63240 +}
63241 +
63242 +int
63243 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63244 +{
63245 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63246 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63247 + && proc_is_chrooted(current)) {
63248 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63249 + return -EACCES;
63250 + }
63251 +#endif
63252 + return 0;
63253 +}
63254 +
63255 +int
63256 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63257 +{
63258 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63259 + struct task_struct *p;
63260 + int ret = 0;
63261 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63262 + return ret;
63263 +
63264 + read_lock(&tasklist_lock);
63265 + do_each_pid_task(pid, type, p) {
63266 + if (!have_same_root(current, p)) {
63267 + ret = 1;
63268 + goto out;
63269 + }
63270 + } while_each_pid_task(pid, type, p);
63271 +out:
63272 + read_unlock(&tasklist_lock);
63273 + return ret;
63274 +#endif
63275 + return 0;
63276 +}
63277 +
63278 +int
63279 +gr_pid_is_chrooted(struct task_struct *p)
63280 +{
63281 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63282 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
63283 + return 0;
63284 +
63285 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
63286 + !have_same_root(current, p)) {
63287 + return 1;
63288 + }
63289 +#endif
63290 + return 0;
63291 +}
63292 +
63293 +EXPORT_SYMBOL(gr_pid_is_chrooted);
63294 +
63295 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
63296 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
63297 +{
63298 + struct path path, currentroot;
63299 + int ret = 0;
63300 +
63301 + path.dentry = (struct dentry *)u_dentry;
63302 + path.mnt = (struct vfsmount *)u_mnt;
63303 + get_fs_root(current->fs, &currentroot);
63304 + if (path_is_under(&path, &currentroot))
63305 + ret = 1;
63306 + path_put(&currentroot);
63307 +
63308 + return ret;
63309 +}
63310 +#endif
63311 +
63312 +int
63313 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
63314 +{
63315 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
63316 + if (!grsec_enable_chroot_fchdir)
63317 + return 1;
63318 +
63319 + if (!proc_is_chrooted(current))
63320 + return 1;
63321 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
63322 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
63323 + return 0;
63324 + }
63325 +#endif
63326 + return 1;
63327 +}
63328 +
63329 +int
63330 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63331 + const time_t shm_createtime)
63332 +{
63333 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
63334 + struct task_struct *p;
63335 + time_t starttime;
63336 +
63337 + if (unlikely(!grsec_enable_chroot_shmat))
63338 + return 1;
63339 +
63340 + if (likely(!proc_is_chrooted(current)))
63341 + return 1;
63342 +
63343 + rcu_read_lock();
63344 + read_lock(&tasklist_lock);
63345 +
63346 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
63347 + starttime = p->start_time.tv_sec;
63348 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
63349 + if (have_same_root(current, p)) {
63350 + goto allow;
63351 + } else {
63352 + read_unlock(&tasklist_lock);
63353 + rcu_read_unlock();
63354 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63355 + return 0;
63356 + }
63357 + }
63358 + /* creator exited, pid reuse, fall through to next check */
63359 + }
63360 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
63361 + if (unlikely(!have_same_root(current, p))) {
63362 + read_unlock(&tasklist_lock);
63363 + rcu_read_unlock();
63364 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63365 + return 0;
63366 + }
63367 + }
63368 +
63369 +allow:
63370 + read_unlock(&tasklist_lock);
63371 + rcu_read_unlock();
63372 +#endif
63373 + return 1;
63374 +}
63375 +
63376 +void
63377 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
63378 +{
63379 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
63380 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
63381 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
63382 +#endif
63383 + return;
63384 +}
63385 +
63386 +int
63387 +gr_handle_chroot_mknod(const struct dentry *dentry,
63388 + const struct vfsmount *mnt, const int mode)
63389 +{
63390 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
63391 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
63392 + proc_is_chrooted(current)) {
63393 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
63394 + return -EPERM;
63395 + }
63396 +#endif
63397 + return 0;
63398 +}
63399 +
63400 +int
63401 +gr_handle_chroot_mount(const struct dentry *dentry,
63402 + const struct vfsmount *mnt, const char *dev_name)
63403 +{
63404 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
63405 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
63406 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
63407 + return -EPERM;
63408 + }
63409 +#endif
63410 + return 0;
63411 +}
63412 +
63413 +int
63414 +gr_handle_chroot_pivot(void)
63415 +{
63416 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
63417 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
63418 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
63419 + return -EPERM;
63420 + }
63421 +#endif
63422 + return 0;
63423 +}
63424 +
63425 +int
63426 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
63427 +{
63428 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
63429 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
63430 + !gr_is_outside_chroot(dentry, mnt)) {
63431 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
63432 + return -EPERM;
63433 + }
63434 +#endif
63435 + return 0;
63436 +}
63437 +
63438 +extern const char *captab_log[];
63439 +extern int captab_log_entries;
63440 +
63441 +int
63442 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63443 +{
63444 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63445 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63446 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63447 + if (cap_raised(chroot_caps, cap)) {
63448 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
63449 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
63450 + }
63451 + return 0;
63452 + }
63453 + }
63454 +#endif
63455 + return 1;
63456 +}
63457 +
63458 +int
63459 +gr_chroot_is_capable(const int cap)
63460 +{
63461 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63462 + return gr_task_chroot_is_capable(current, current_cred(), cap);
63463 +#endif
63464 + return 1;
63465 +}
63466 +
63467 +int
63468 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
63469 +{
63470 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63471 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63472 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63473 + if (cap_raised(chroot_caps, cap)) {
63474 + return 0;
63475 + }
63476 + }
63477 +#endif
63478 + return 1;
63479 +}
63480 +
63481 +int
63482 +gr_chroot_is_capable_nolog(const int cap)
63483 +{
63484 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63485 + return gr_task_chroot_is_capable_nolog(current, cap);
63486 +#endif
63487 + return 1;
63488 +}
63489 +
63490 +int
63491 +gr_handle_chroot_sysctl(const int op)
63492 +{
63493 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
63494 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
63495 + proc_is_chrooted(current))
63496 + return -EACCES;
63497 +#endif
63498 + return 0;
63499 +}
63500 +
63501 +void
63502 +gr_handle_chroot_chdir(struct path *path)
63503 +{
63504 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
63505 + if (grsec_enable_chroot_chdir)
63506 + set_fs_pwd(current->fs, path);
63507 +#endif
63508 + return;
63509 +}
63510 +
63511 +int
63512 +gr_handle_chroot_chmod(const struct dentry *dentry,
63513 + const struct vfsmount *mnt, const int mode)
63514 +{
63515 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
63516 + /* allow chmod +s on directories, but not files */
63517 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
63518 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
63519 + proc_is_chrooted(current)) {
63520 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
63521 + return -EPERM;
63522 + }
63523 +#endif
63524 + return 0;
63525 +}
63526 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
63527 new file mode 100644
63528 index 0000000..207d409
63529 --- /dev/null
63530 +++ b/grsecurity/grsec_disabled.c
63531 @@ -0,0 +1,434 @@
63532 +#include <linux/kernel.h>
63533 +#include <linux/module.h>
63534 +#include <linux/sched.h>
63535 +#include <linux/file.h>
63536 +#include <linux/fs.h>
63537 +#include <linux/kdev_t.h>
63538 +#include <linux/net.h>
63539 +#include <linux/in.h>
63540 +#include <linux/ip.h>
63541 +#include <linux/skbuff.h>
63542 +#include <linux/sysctl.h>
63543 +
63544 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
63545 +void
63546 +pax_set_initial_flags(struct linux_binprm *bprm)
63547 +{
63548 + return;
63549 +}
63550 +#endif
63551 +
63552 +#ifdef CONFIG_SYSCTL
63553 +__u32
63554 +gr_handle_sysctl(const struct ctl_table * table, const int op)
63555 +{
63556 + return 0;
63557 +}
63558 +#endif
63559 +
63560 +#ifdef CONFIG_TASKSTATS
63561 +int gr_is_taskstats_denied(int pid)
63562 +{
63563 + return 0;
63564 +}
63565 +#endif
63566 +
63567 +int
63568 +gr_acl_is_enabled(void)
63569 +{
63570 + return 0;
63571 +}
63572 +
63573 +void
63574 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
63575 +{
63576 + return;
63577 +}
63578 +
63579 +int
63580 +gr_handle_rawio(const struct inode *inode)
63581 +{
63582 + return 0;
63583 +}
63584 +
63585 +void
63586 +gr_acl_handle_psacct(struct task_struct *task, const long code)
63587 +{
63588 + return;
63589 +}
63590 +
63591 +int
63592 +gr_handle_ptrace(struct task_struct *task, const long request)
63593 +{
63594 + return 0;
63595 +}
63596 +
63597 +int
63598 +gr_handle_proc_ptrace(struct task_struct *task)
63599 +{
63600 + return 0;
63601 +}
63602 +
63603 +int
63604 +gr_set_acls(const int type)
63605 +{
63606 + return 0;
63607 +}
63608 +
63609 +int
63610 +gr_check_hidden_task(const struct task_struct *tsk)
63611 +{
63612 + return 0;
63613 +}
63614 +
63615 +int
63616 +gr_check_protected_task(const struct task_struct *task)
63617 +{
63618 + return 0;
63619 +}
63620 +
63621 +int
63622 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
63623 +{
63624 + return 0;
63625 +}
63626 +
63627 +void
63628 +gr_copy_label(struct task_struct *tsk)
63629 +{
63630 + return;
63631 +}
63632 +
63633 +void
63634 +gr_set_pax_flags(struct task_struct *task)
63635 +{
63636 + return;
63637 +}
63638 +
63639 +int
63640 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63641 + const int unsafe_share)
63642 +{
63643 + return 0;
63644 +}
63645 +
63646 +void
63647 +gr_handle_delete(const ino_t ino, const dev_t dev)
63648 +{
63649 + return;
63650 +}
63651 +
63652 +void
63653 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
63654 +{
63655 + return;
63656 +}
63657 +
63658 +void
63659 +gr_handle_crash(struct task_struct *task, const int sig)
63660 +{
63661 + return;
63662 +}
63663 +
63664 +int
63665 +gr_check_crash_exec(const struct file *filp)
63666 +{
63667 + return 0;
63668 +}
63669 +
63670 +int
63671 +gr_check_crash_uid(const kuid_t uid)
63672 +{
63673 + return 0;
63674 +}
63675 +
63676 +void
63677 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
63678 + struct dentry *old_dentry,
63679 + struct dentry *new_dentry,
63680 + struct vfsmount *mnt, const __u8 replace)
63681 +{
63682 + return;
63683 +}
63684 +
63685 +int
63686 +gr_search_socket(const int family, const int type, const int protocol)
63687 +{
63688 + return 1;
63689 +}
63690 +
63691 +int
63692 +gr_search_connectbind(const int mode, const struct socket *sock,
63693 + const struct sockaddr_in *addr)
63694 +{
63695 + return 0;
63696 +}
63697 +
63698 +void
63699 +gr_handle_alertkill(struct task_struct *task)
63700 +{
63701 + return;
63702 +}
63703 +
63704 +__u32
63705 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
63706 +{
63707 + return 1;
63708 +}
63709 +
63710 +__u32
63711 +gr_acl_handle_hidden_file(const struct dentry * dentry,
63712 + const struct vfsmount * mnt)
63713 +{
63714 + return 1;
63715 +}
63716 +
63717 +__u32
63718 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
63719 + int acc_mode)
63720 +{
63721 + return 1;
63722 +}
63723 +
63724 +__u32
63725 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
63726 +{
63727 + return 1;
63728 +}
63729 +
63730 +__u32
63731 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
63732 +{
63733 + return 1;
63734 +}
63735 +
63736 +int
63737 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
63738 + unsigned int *vm_flags)
63739 +{
63740 + return 1;
63741 +}
63742 +
63743 +__u32
63744 +gr_acl_handle_truncate(const struct dentry * dentry,
63745 + const struct vfsmount * mnt)
63746 +{
63747 + return 1;
63748 +}
63749 +
63750 +__u32
63751 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
63752 +{
63753 + return 1;
63754 +}
63755 +
63756 +__u32
63757 +gr_acl_handle_access(const struct dentry * dentry,
63758 + const struct vfsmount * mnt, const int fmode)
63759 +{
63760 + return 1;
63761 +}
63762 +
63763 +__u32
63764 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
63765 + umode_t *mode)
63766 +{
63767 + return 1;
63768 +}
63769 +
63770 +__u32
63771 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
63772 +{
63773 + return 1;
63774 +}
63775 +
63776 +__u32
63777 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
63778 +{
63779 + return 1;
63780 +}
63781 +
63782 +void
63783 +grsecurity_init(void)
63784 +{
63785 + return;
63786 +}
63787 +
63788 +umode_t gr_acl_umask(void)
63789 +{
63790 + return 0;
63791 +}
63792 +
63793 +__u32
63794 +gr_acl_handle_mknod(const struct dentry * new_dentry,
63795 + const struct dentry * parent_dentry,
63796 + const struct vfsmount * parent_mnt,
63797 + const int mode)
63798 +{
63799 + return 1;
63800 +}
63801 +
63802 +__u32
63803 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
63804 + const struct dentry * parent_dentry,
63805 + const struct vfsmount * parent_mnt)
63806 +{
63807 + return 1;
63808 +}
63809 +
63810 +__u32
63811 +gr_acl_handle_symlink(const struct dentry * new_dentry,
63812 + const struct dentry * parent_dentry,
63813 + const struct vfsmount * parent_mnt, const struct filename *from)
63814 +{
63815 + return 1;
63816 +}
63817 +
63818 +__u32
63819 +gr_acl_handle_link(const struct dentry * new_dentry,
63820 + const struct dentry * parent_dentry,
63821 + const struct vfsmount * parent_mnt,
63822 + const struct dentry * old_dentry,
63823 + const struct vfsmount * old_mnt, const struct filename *to)
63824 +{
63825 + return 1;
63826 +}
63827 +
63828 +int
63829 +gr_acl_handle_rename(const struct dentry *new_dentry,
63830 + const struct dentry *parent_dentry,
63831 + const struct vfsmount *parent_mnt,
63832 + const struct dentry *old_dentry,
63833 + const struct inode *old_parent_inode,
63834 + const struct vfsmount *old_mnt, const struct filename *newname)
63835 +{
63836 + return 0;
63837 +}
63838 +
63839 +int
63840 +gr_acl_handle_filldir(const struct file *file, const char *name,
63841 + const int namelen, const ino_t ino)
63842 +{
63843 + return 1;
63844 +}
63845 +
63846 +int
63847 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63848 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63849 +{
63850 + return 1;
63851 +}
63852 +
63853 +int
63854 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
63855 +{
63856 + return 0;
63857 +}
63858 +
63859 +int
63860 +gr_search_accept(const struct socket *sock)
63861 +{
63862 + return 0;
63863 +}
63864 +
63865 +int
63866 +gr_search_listen(const struct socket *sock)
63867 +{
63868 + return 0;
63869 +}
63870 +
63871 +int
63872 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
63873 +{
63874 + return 0;
63875 +}
63876 +
63877 +__u32
63878 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
63879 +{
63880 + return 1;
63881 +}
63882 +
63883 +__u32
63884 +gr_acl_handle_creat(const struct dentry * dentry,
63885 + const struct dentry * p_dentry,
63886 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
63887 + const int imode)
63888 +{
63889 + return 1;
63890 +}
63891 +
63892 +void
63893 +gr_acl_handle_exit(void)
63894 +{
63895 + return;
63896 +}
63897 +
63898 +int
63899 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
63900 +{
63901 + return 1;
63902 +}
63903 +
63904 +void
63905 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
63906 +{
63907 + return;
63908 +}
63909 +
63910 +int
63911 +gr_acl_handle_procpidmem(const struct task_struct *task)
63912 +{
63913 + return 0;
63914 +}
63915 +
63916 +int
63917 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
63918 +{
63919 + return 0;
63920 +}
63921 +
63922 +int
63923 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
63924 +{
63925 + return 0;
63926 +}
63927 +
63928 +void
63929 +gr_set_kernel_label(struct task_struct *task)
63930 +{
63931 + return;
63932 +}
63933 +
63934 +int
63935 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
63936 +{
63937 + return 0;
63938 +}
63939 +
63940 +int
63941 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
63942 +{
63943 + return 0;
63944 +}
63945 +
63946 +int gr_acl_enable_at_secure(void)
63947 +{
63948 + return 0;
63949 +}
63950 +
63951 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
63952 +{
63953 + return dentry->d_inode->i_sb->s_dev;
63954 +}
63955 +
63956 +void gr_put_exec_file(struct task_struct *task)
63957 +{
63958 + return;
63959 +}
63960 +
63961 +EXPORT_SYMBOL(gr_set_kernel_label);
63962 +#ifdef CONFIG_SECURITY
63963 +EXPORT_SYMBOL(gr_check_user_change);
63964 +EXPORT_SYMBOL(gr_check_group_change);
63965 +#endif
63966 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
63967 new file mode 100644
63968 index 0000000..387032b
63969 --- /dev/null
63970 +++ b/grsecurity/grsec_exec.c
63971 @@ -0,0 +1,187 @@
63972 +#include <linux/kernel.h>
63973 +#include <linux/sched.h>
63974 +#include <linux/file.h>
63975 +#include <linux/binfmts.h>
63976 +#include <linux/fs.h>
63977 +#include <linux/types.h>
63978 +#include <linux/grdefs.h>
63979 +#include <linux/grsecurity.h>
63980 +#include <linux/grinternal.h>
63981 +#include <linux/capability.h>
63982 +#include <linux/module.h>
63983 +#include <linux/compat.h>
63984 +
63985 +#include <asm/uaccess.h>
63986 +
63987 +#ifdef CONFIG_GRKERNSEC_EXECLOG
63988 +static char gr_exec_arg_buf[132];
63989 +static DEFINE_MUTEX(gr_exec_arg_mutex);
63990 +#endif
63991 +
63992 +struct user_arg_ptr {
63993 +#ifdef CONFIG_COMPAT
63994 + bool is_compat;
63995 +#endif
63996 + union {
63997 + const char __user *const __user *native;
63998 +#ifdef CONFIG_COMPAT
63999 + const compat_uptr_t __user *compat;
64000 +#endif
64001 + } ptr;
64002 +};
64003 +
64004 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64005 +
64006 +void
64007 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64008 +{
64009 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64010 + char *grarg = gr_exec_arg_buf;
64011 + unsigned int i, x, execlen = 0;
64012 + char c;
64013 +
64014 + if (!((grsec_enable_execlog && grsec_enable_group &&
64015 + in_group_p(grsec_audit_gid))
64016 + || (grsec_enable_execlog && !grsec_enable_group)))
64017 + return;
64018 +
64019 + mutex_lock(&gr_exec_arg_mutex);
64020 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64021 +
64022 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64023 + const char __user *p;
64024 + unsigned int len;
64025 +
64026 + p = get_user_arg_ptr(argv, i);
64027 + if (IS_ERR(p))
64028 + goto log;
64029 +
64030 + len = strnlen_user(p, 128 - execlen);
64031 + if (len > 128 - execlen)
64032 + len = 128 - execlen;
64033 + else if (len > 0)
64034 + len--;
64035 + if (copy_from_user(grarg + execlen, p, len))
64036 + goto log;
64037 +
64038 + /* rewrite unprintable characters */
64039 + for (x = 0; x < len; x++) {
64040 + c = *(grarg + execlen + x);
64041 + if (c < 32 || c > 126)
64042 + *(grarg + execlen + x) = ' ';
64043 + }
64044 +
64045 + execlen += len;
64046 + *(grarg + execlen) = ' ';
64047 + *(grarg + execlen + 1) = '\0';
64048 + execlen++;
64049 + }
64050 +
64051 + log:
64052 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64053 + bprm->file->f_path.mnt, grarg);
64054 + mutex_unlock(&gr_exec_arg_mutex);
64055 +#endif
64056 + return;
64057 +}
64058 +
64059 +#ifdef CONFIG_GRKERNSEC
64060 +extern int gr_acl_is_capable(const int cap);
64061 +extern int gr_acl_is_capable_nolog(const int cap);
64062 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64063 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64064 +extern int gr_chroot_is_capable(const int cap);
64065 +extern int gr_chroot_is_capable_nolog(const int cap);
64066 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64067 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64068 +#endif
64069 +
64070 +const char *captab_log[] = {
64071 + "CAP_CHOWN",
64072 + "CAP_DAC_OVERRIDE",
64073 + "CAP_DAC_READ_SEARCH",
64074 + "CAP_FOWNER",
64075 + "CAP_FSETID",
64076 + "CAP_KILL",
64077 + "CAP_SETGID",
64078 + "CAP_SETUID",
64079 + "CAP_SETPCAP",
64080 + "CAP_LINUX_IMMUTABLE",
64081 + "CAP_NET_BIND_SERVICE",
64082 + "CAP_NET_BROADCAST",
64083 + "CAP_NET_ADMIN",
64084 + "CAP_NET_RAW",
64085 + "CAP_IPC_LOCK",
64086 + "CAP_IPC_OWNER",
64087 + "CAP_SYS_MODULE",
64088 + "CAP_SYS_RAWIO",
64089 + "CAP_SYS_CHROOT",
64090 + "CAP_SYS_PTRACE",
64091 + "CAP_SYS_PACCT",
64092 + "CAP_SYS_ADMIN",
64093 + "CAP_SYS_BOOT",
64094 + "CAP_SYS_NICE",
64095 + "CAP_SYS_RESOURCE",
64096 + "CAP_SYS_TIME",
64097 + "CAP_SYS_TTY_CONFIG",
64098 + "CAP_MKNOD",
64099 + "CAP_LEASE",
64100 + "CAP_AUDIT_WRITE",
64101 + "CAP_AUDIT_CONTROL",
64102 + "CAP_SETFCAP",
64103 + "CAP_MAC_OVERRIDE",
64104 + "CAP_MAC_ADMIN",
64105 + "CAP_SYSLOG",
64106 + "CAP_WAKE_ALARM"
64107 +};
64108 +
64109 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64110 +
64111 +int gr_is_capable(const int cap)
64112 +{
64113 +#ifdef CONFIG_GRKERNSEC
64114 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64115 + return 1;
64116 + return 0;
64117 +#else
64118 + return 1;
64119 +#endif
64120 +}
64121 +
64122 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64123 +{
64124 +#ifdef CONFIG_GRKERNSEC
64125 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64126 + return 1;
64127 + return 0;
64128 +#else
64129 + return 1;
64130 +#endif
64131 +}
64132 +
64133 +int gr_is_capable_nolog(const int cap)
64134 +{
64135 +#ifdef CONFIG_GRKERNSEC
64136 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64137 + return 1;
64138 + return 0;
64139 +#else
64140 + return 1;
64141 +#endif
64142 +}
64143 +
64144 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64145 +{
64146 +#ifdef CONFIG_GRKERNSEC
64147 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64148 + return 1;
64149 + return 0;
64150 +#else
64151 + return 1;
64152 +#endif
64153 +}
64154 +
64155 +EXPORT_SYMBOL(gr_is_capable);
64156 +EXPORT_SYMBOL(gr_is_capable_nolog);
64157 +EXPORT_SYMBOL(gr_task_is_capable);
64158 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64159 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64160 new file mode 100644
64161 index 0000000..06cc6ea
64162 --- /dev/null
64163 +++ b/grsecurity/grsec_fifo.c
64164 @@ -0,0 +1,24 @@
64165 +#include <linux/kernel.h>
64166 +#include <linux/sched.h>
64167 +#include <linux/fs.h>
64168 +#include <linux/file.h>
64169 +#include <linux/grinternal.h>
64170 +
64171 +int
64172 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64173 + const struct dentry *dir, const int flag, const int acc_mode)
64174 +{
64175 +#ifdef CONFIG_GRKERNSEC_FIFO
64176 + const struct cred *cred = current_cred();
64177 +
64178 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64179 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64180 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64181 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64182 + if (!inode_permission(dentry->d_inode, acc_mode))
64183 + 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));
64184 + return -EACCES;
64185 + }
64186 +#endif
64187 + return 0;
64188 +}
64189 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64190 new file mode 100644
64191 index 0000000..8ca18bf
64192 --- /dev/null
64193 +++ b/grsecurity/grsec_fork.c
64194 @@ -0,0 +1,23 @@
64195 +#include <linux/kernel.h>
64196 +#include <linux/sched.h>
64197 +#include <linux/grsecurity.h>
64198 +#include <linux/grinternal.h>
64199 +#include <linux/errno.h>
64200 +
64201 +void
64202 +gr_log_forkfail(const int retval)
64203 +{
64204 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64205 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64206 + switch (retval) {
64207 + case -EAGAIN:
64208 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64209 + break;
64210 + case -ENOMEM:
64211 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64212 + break;
64213 + }
64214 + }
64215 +#endif
64216 + return;
64217 +}
64218 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64219 new file mode 100644
64220 index 0000000..a862e9f
64221 --- /dev/null
64222 +++ b/grsecurity/grsec_init.c
64223 @@ -0,0 +1,283 @@
64224 +#include <linux/kernel.h>
64225 +#include <linux/sched.h>
64226 +#include <linux/mm.h>
64227 +#include <linux/gracl.h>
64228 +#include <linux/slab.h>
64229 +#include <linux/vmalloc.h>
64230 +#include <linux/percpu.h>
64231 +#include <linux/module.h>
64232 +
64233 +int grsec_enable_ptrace_readexec;
64234 +int grsec_enable_setxid;
64235 +int grsec_enable_symlinkown;
64236 +kgid_t grsec_symlinkown_gid;
64237 +int grsec_enable_brute;
64238 +int grsec_enable_link;
64239 +int grsec_enable_dmesg;
64240 +int grsec_enable_harden_ptrace;
64241 +int grsec_enable_fifo;
64242 +int grsec_enable_execlog;
64243 +int grsec_enable_signal;
64244 +int grsec_enable_forkfail;
64245 +int grsec_enable_audit_ptrace;
64246 +int grsec_enable_time;
64247 +int grsec_enable_audit_textrel;
64248 +int grsec_enable_group;
64249 +kgid_t grsec_audit_gid;
64250 +int grsec_enable_chdir;
64251 +int grsec_enable_mount;
64252 +int grsec_enable_rofs;
64253 +int grsec_enable_chroot_findtask;
64254 +int grsec_enable_chroot_mount;
64255 +int grsec_enable_chroot_shmat;
64256 +int grsec_enable_chroot_fchdir;
64257 +int grsec_enable_chroot_double;
64258 +int grsec_enable_chroot_pivot;
64259 +int grsec_enable_chroot_chdir;
64260 +int grsec_enable_chroot_chmod;
64261 +int grsec_enable_chroot_mknod;
64262 +int grsec_enable_chroot_nice;
64263 +int grsec_enable_chroot_execlog;
64264 +int grsec_enable_chroot_caps;
64265 +int grsec_enable_chroot_sysctl;
64266 +int grsec_enable_chroot_unix;
64267 +int grsec_enable_tpe;
64268 +kgid_t grsec_tpe_gid;
64269 +int grsec_enable_blackhole;
64270 +#ifdef CONFIG_IPV6_MODULE
64271 +EXPORT_SYMBOL(grsec_enable_blackhole);
64272 +#endif
64273 +int grsec_lastack_retries;
64274 +int grsec_enable_tpe_all;
64275 +int grsec_enable_tpe_invert;
64276 +int grsec_enable_socket_all;
64277 +kgid_t grsec_socket_all_gid;
64278 +int grsec_enable_socket_client;
64279 +kgid_t grsec_socket_client_gid;
64280 +int grsec_enable_socket_server;
64281 +kgid_t grsec_socket_server_gid;
64282 +int grsec_resource_logging;
64283 +int grsec_disable_privio;
64284 +int grsec_enable_log_rwxmaps;
64285 +int grsec_lock;
64286 +
64287 +DEFINE_SPINLOCK(grsec_alert_lock);
64288 +unsigned long grsec_alert_wtime = 0;
64289 +unsigned long grsec_alert_fyet = 0;
64290 +
64291 +DEFINE_SPINLOCK(grsec_audit_lock);
64292 +
64293 +DEFINE_RWLOCK(grsec_exec_file_lock);
64294 +
64295 +char *gr_shared_page[4];
64296 +
64297 +char *gr_alert_log_fmt;
64298 +char *gr_audit_log_fmt;
64299 +char *gr_alert_log_buf;
64300 +char *gr_audit_log_buf;
64301 +
64302 +extern struct gr_arg *gr_usermode;
64303 +extern unsigned char *gr_system_salt;
64304 +extern unsigned char *gr_system_sum;
64305 +
64306 +void __init
64307 +grsecurity_init(void)
64308 +{
64309 + int j;
64310 + /* create the per-cpu shared pages */
64311 +
64312 +#ifdef CONFIG_X86
64313 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
64314 +#endif
64315 +
64316 + for (j = 0; j < 4; j++) {
64317 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
64318 + if (gr_shared_page[j] == NULL) {
64319 + panic("Unable to allocate grsecurity shared page");
64320 + return;
64321 + }
64322 + }
64323 +
64324 + /* allocate log buffers */
64325 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
64326 + if (!gr_alert_log_fmt) {
64327 + panic("Unable to allocate grsecurity alert log format buffer");
64328 + return;
64329 + }
64330 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
64331 + if (!gr_audit_log_fmt) {
64332 + panic("Unable to allocate grsecurity audit log format buffer");
64333 + return;
64334 + }
64335 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64336 + if (!gr_alert_log_buf) {
64337 + panic("Unable to allocate grsecurity alert log buffer");
64338 + return;
64339 + }
64340 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64341 + if (!gr_audit_log_buf) {
64342 + panic("Unable to allocate grsecurity audit log buffer");
64343 + return;
64344 + }
64345 +
64346 + /* allocate memory for authentication structure */
64347 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
64348 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
64349 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
64350 +
64351 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
64352 + panic("Unable to allocate grsecurity authentication structure");
64353 + return;
64354 + }
64355 +
64356 +
64357 +#ifdef CONFIG_GRKERNSEC_IO
64358 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
64359 + grsec_disable_privio = 1;
64360 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64361 + grsec_disable_privio = 1;
64362 +#else
64363 + grsec_disable_privio = 0;
64364 +#endif
64365 +#endif
64366 +
64367 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
64368 + /* for backward compatibility, tpe_invert always defaults to on if
64369 + enabled in the kernel
64370 + */
64371 + grsec_enable_tpe_invert = 1;
64372 +#endif
64373 +
64374 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64375 +#ifndef CONFIG_GRKERNSEC_SYSCTL
64376 + grsec_lock = 1;
64377 +#endif
64378 +
64379 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64380 + grsec_enable_audit_textrel = 1;
64381 +#endif
64382 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64383 + grsec_enable_log_rwxmaps = 1;
64384 +#endif
64385 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
64386 + grsec_enable_group = 1;
64387 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
64388 +#endif
64389 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64390 + grsec_enable_ptrace_readexec = 1;
64391 +#endif
64392 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64393 + grsec_enable_chdir = 1;
64394 +#endif
64395 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64396 + grsec_enable_harden_ptrace = 1;
64397 +#endif
64398 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64399 + grsec_enable_mount = 1;
64400 +#endif
64401 +#ifdef CONFIG_GRKERNSEC_LINK
64402 + grsec_enable_link = 1;
64403 +#endif
64404 +#ifdef CONFIG_GRKERNSEC_BRUTE
64405 + grsec_enable_brute = 1;
64406 +#endif
64407 +#ifdef CONFIG_GRKERNSEC_DMESG
64408 + grsec_enable_dmesg = 1;
64409 +#endif
64410 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
64411 + grsec_enable_blackhole = 1;
64412 + grsec_lastack_retries = 4;
64413 +#endif
64414 +#ifdef CONFIG_GRKERNSEC_FIFO
64415 + grsec_enable_fifo = 1;
64416 +#endif
64417 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64418 + grsec_enable_execlog = 1;
64419 +#endif
64420 +#ifdef CONFIG_GRKERNSEC_SETXID
64421 + grsec_enable_setxid = 1;
64422 +#endif
64423 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64424 + grsec_enable_signal = 1;
64425 +#endif
64426 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64427 + grsec_enable_forkfail = 1;
64428 +#endif
64429 +#ifdef CONFIG_GRKERNSEC_TIME
64430 + grsec_enable_time = 1;
64431 +#endif
64432 +#ifdef CONFIG_GRKERNSEC_RESLOG
64433 + grsec_resource_logging = 1;
64434 +#endif
64435 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64436 + grsec_enable_chroot_findtask = 1;
64437 +#endif
64438 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64439 + grsec_enable_chroot_unix = 1;
64440 +#endif
64441 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64442 + grsec_enable_chroot_mount = 1;
64443 +#endif
64444 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64445 + grsec_enable_chroot_fchdir = 1;
64446 +#endif
64447 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64448 + grsec_enable_chroot_shmat = 1;
64449 +#endif
64450 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64451 + grsec_enable_audit_ptrace = 1;
64452 +#endif
64453 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64454 + grsec_enable_chroot_double = 1;
64455 +#endif
64456 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64457 + grsec_enable_chroot_pivot = 1;
64458 +#endif
64459 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64460 + grsec_enable_chroot_chdir = 1;
64461 +#endif
64462 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64463 + grsec_enable_chroot_chmod = 1;
64464 +#endif
64465 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64466 + grsec_enable_chroot_mknod = 1;
64467 +#endif
64468 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64469 + grsec_enable_chroot_nice = 1;
64470 +#endif
64471 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64472 + grsec_enable_chroot_execlog = 1;
64473 +#endif
64474 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64475 + grsec_enable_chroot_caps = 1;
64476 +#endif
64477 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64478 + grsec_enable_chroot_sysctl = 1;
64479 +#endif
64480 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64481 + grsec_enable_symlinkown = 1;
64482 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
64483 +#endif
64484 +#ifdef CONFIG_GRKERNSEC_TPE
64485 + grsec_enable_tpe = 1;
64486 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
64487 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
64488 + grsec_enable_tpe_all = 1;
64489 +#endif
64490 +#endif
64491 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
64492 + grsec_enable_socket_all = 1;
64493 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
64494 +#endif
64495 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
64496 + grsec_enable_socket_client = 1;
64497 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
64498 +#endif
64499 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
64500 + grsec_enable_socket_server = 1;
64501 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
64502 +#endif
64503 +#endif
64504 +
64505 + return;
64506 +}
64507 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
64508 new file mode 100644
64509 index 0000000..5e05e20
64510 --- /dev/null
64511 +++ b/grsecurity/grsec_link.c
64512 @@ -0,0 +1,58 @@
64513 +#include <linux/kernel.h>
64514 +#include <linux/sched.h>
64515 +#include <linux/fs.h>
64516 +#include <linux/file.h>
64517 +#include <linux/grinternal.h>
64518 +
64519 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
64520 +{
64521 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64522 + const struct inode *link_inode = link->dentry->d_inode;
64523 +
64524 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
64525 + /* ignore root-owned links, e.g. /proc/self */
64526 + gr_is_global_nonroot(link_inode->i_uid) && target &&
64527 + !uid_eq(link_inode->i_uid, target->i_uid)) {
64528 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
64529 + return 1;
64530 + }
64531 +#endif
64532 + return 0;
64533 +}
64534 +
64535 +int
64536 +gr_handle_follow_link(const struct inode *parent,
64537 + const struct inode *inode,
64538 + const struct dentry *dentry, const struct vfsmount *mnt)
64539 +{
64540 +#ifdef CONFIG_GRKERNSEC_LINK
64541 + const struct cred *cred = current_cred();
64542 +
64543 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
64544 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
64545 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
64546 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
64547 + return -EACCES;
64548 + }
64549 +#endif
64550 + return 0;
64551 +}
64552 +
64553 +int
64554 +gr_handle_hardlink(const struct dentry *dentry,
64555 + const struct vfsmount *mnt,
64556 + struct inode *inode, const int mode, const struct filename *to)
64557 +{
64558 +#ifdef CONFIG_GRKERNSEC_LINK
64559 + const struct cred *cred = current_cred();
64560 +
64561 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
64562 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
64563 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
64564 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
64565 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
64566 + return -EPERM;
64567 + }
64568 +#endif
64569 + return 0;
64570 +}
64571 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
64572 new file mode 100644
64573 index 0000000..7c06085
64574 --- /dev/null
64575 +++ b/grsecurity/grsec_log.c
64576 @@ -0,0 +1,326 @@
64577 +#include <linux/kernel.h>
64578 +#include <linux/sched.h>
64579 +#include <linux/file.h>
64580 +#include <linux/tty.h>
64581 +#include <linux/fs.h>
64582 +#include <linux/grinternal.h>
64583 +
64584 +#ifdef CONFIG_TREE_PREEMPT_RCU
64585 +#define DISABLE_PREEMPT() preempt_disable()
64586 +#define ENABLE_PREEMPT() preempt_enable()
64587 +#else
64588 +#define DISABLE_PREEMPT()
64589 +#define ENABLE_PREEMPT()
64590 +#endif
64591 +
64592 +#define BEGIN_LOCKS(x) \
64593 + DISABLE_PREEMPT(); \
64594 + rcu_read_lock(); \
64595 + read_lock(&tasklist_lock); \
64596 + read_lock(&grsec_exec_file_lock); \
64597 + if (x != GR_DO_AUDIT) \
64598 + spin_lock(&grsec_alert_lock); \
64599 + else \
64600 + spin_lock(&grsec_audit_lock)
64601 +
64602 +#define END_LOCKS(x) \
64603 + if (x != GR_DO_AUDIT) \
64604 + spin_unlock(&grsec_alert_lock); \
64605 + else \
64606 + spin_unlock(&grsec_audit_lock); \
64607 + read_unlock(&grsec_exec_file_lock); \
64608 + read_unlock(&tasklist_lock); \
64609 + rcu_read_unlock(); \
64610 + ENABLE_PREEMPT(); \
64611 + if (x == GR_DONT_AUDIT) \
64612 + gr_handle_alertkill(current)
64613 +
64614 +enum {
64615 + FLOODING,
64616 + NO_FLOODING
64617 +};
64618 +
64619 +extern char *gr_alert_log_fmt;
64620 +extern char *gr_audit_log_fmt;
64621 +extern char *gr_alert_log_buf;
64622 +extern char *gr_audit_log_buf;
64623 +
64624 +static int gr_log_start(int audit)
64625 +{
64626 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
64627 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
64628 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64629 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
64630 + unsigned long curr_secs = get_seconds();
64631 +
64632 + if (audit == GR_DO_AUDIT)
64633 + goto set_fmt;
64634 +
64635 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
64636 + grsec_alert_wtime = curr_secs;
64637 + grsec_alert_fyet = 0;
64638 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
64639 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
64640 + grsec_alert_fyet++;
64641 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
64642 + grsec_alert_wtime = curr_secs;
64643 + grsec_alert_fyet++;
64644 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
64645 + return FLOODING;
64646 + }
64647 + else return FLOODING;
64648 +
64649 +set_fmt:
64650 +#endif
64651 + memset(buf, 0, PAGE_SIZE);
64652 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
64653 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
64654 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64655 + } else if (current->signal->curr_ip) {
64656 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
64657 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
64658 + } else if (gr_acl_is_enabled()) {
64659 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
64660 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64661 + } else {
64662 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
64663 + strcpy(buf, fmt);
64664 + }
64665 +
64666 + return NO_FLOODING;
64667 +}
64668 +
64669 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64670 + __attribute__ ((format (printf, 2, 0)));
64671 +
64672 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64673 +{
64674 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64675 + unsigned int len = strlen(buf);
64676 +
64677 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64678 +
64679 + return;
64680 +}
64681 +
64682 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64683 + __attribute__ ((format (printf, 2, 3)));
64684 +
64685 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64686 +{
64687 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64688 + unsigned int len = strlen(buf);
64689 + va_list ap;
64690 +
64691 + va_start(ap, msg);
64692 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64693 + va_end(ap);
64694 +
64695 + return;
64696 +}
64697 +
64698 +static void gr_log_end(int audit, int append_default)
64699 +{
64700 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64701 + if (append_default) {
64702 + struct task_struct *task = current;
64703 + struct task_struct *parent = task->real_parent;
64704 + const struct cred *cred = __task_cred(task);
64705 + const struct cred *pcred = __task_cred(parent);
64706 + unsigned int len = strlen(buf);
64707 +
64708 + 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));
64709 + }
64710 +
64711 + printk("%s\n", buf);
64712 +
64713 + return;
64714 +}
64715 +
64716 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
64717 +{
64718 + int logtype;
64719 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
64720 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
64721 + void *voidptr = NULL;
64722 + int num1 = 0, num2 = 0;
64723 + unsigned long ulong1 = 0, ulong2 = 0;
64724 + struct dentry *dentry = NULL;
64725 + struct vfsmount *mnt = NULL;
64726 + struct file *file = NULL;
64727 + struct task_struct *task = NULL;
64728 + const struct cred *cred, *pcred;
64729 + va_list ap;
64730 +
64731 + BEGIN_LOCKS(audit);
64732 + logtype = gr_log_start(audit);
64733 + if (logtype == FLOODING) {
64734 + END_LOCKS(audit);
64735 + return;
64736 + }
64737 + va_start(ap, argtypes);
64738 + switch (argtypes) {
64739 + case GR_TTYSNIFF:
64740 + task = va_arg(ap, struct task_struct *);
64741 + 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));
64742 + break;
64743 + case GR_SYSCTL_HIDDEN:
64744 + str1 = va_arg(ap, char *);
64745 + gr_log_middle_varargs(audit, msg, result, str1);
64746 + break;
64747 + case GR_RBAC:
64748 + dentry = va_arg(ap, struct dentry *);
64749 + mnt = va_arg(ap, struct vfsmount *);
64750 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
64751 + break;
64752 + case GR_RBAC_STR:
64753 + dentry = va_arg(ap, struct dentry *);
64754 + mnt = va_arg(ap, struct vfsmount *);
64755 + str1 = va_arg(ap, char *);
64756 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
64757 + break;
64758 + case GR_STR_RBAC:
64759 + str1 = va_arg(ap, char *);
64760 + dentry = va_arg(ap, struct dentry *);
64761 + mnt = va_arg(ap, struct vfsmount *);
64762 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
64763 + break;
64764 + case GR_RBAC_MODE2:
64765 + dentry = va_arg(ap, struct dentry *);
64766 + mnt = va_arg(ap, struct vfsmount *);
64767 + str1 = va_arg(ap, char *);
64768 + str2 = va_arg(ap, char *);
64769 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
64770 + break;
64771 + case GR_RBAC_MODE3:
64772 + dentry = va_arg(ap, struct dentry *);
64773 + mnt = va_arg(ap, struct vfsmount *);
64774 + str1 = va_arg(ap, char *);
64775 + str2 = va_arg(ap, char *);
64776 + str3 = va_arg(ap, char *);
64777 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
64778 + break;
64779 + case GR_FILENAME:
64780 + dentry = va_arg(ap, struct dentry *);
64781 + mnt = va_arg(ap, struct vfsmount *);
64782 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
64783 + break;
64784 + case GR_STR_FILENAME:
64785 + str1 = va_arg(ap, char *);
64786 + dentry = va_arg(ap, struct dentry *);
64787 + mnt = va_arg(ap, struct vfsmount *);
64788 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
64789 + break;
64790 + case GR_FILENAME_STR:
64791 + dentry = va_arg(ap, struct dentry *);
64792 + mnt = va_arg(ap, struct vfsmount *);
64793 + str1 = va_arg(ap, char *);
64794 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
64795 + break;
64796 + case GR_FILENAME_TWO_INT:
64797 + dentry = va_arg(ap, struct dentry *);
64798 + mnt = va_arg(ap, struct vfsmount *);
64799 + num1 = va_arg(ap, int);
64800 + num2 = va_arg(ap, int);
64801 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
64802 + break;
64803 + case GR_FILENAME_TWO_INT_STR:
64804 + dentry = va_arg(ap, struct dentry *);
64805 + mnt = va_arg(ap, struct vfsmount *);
64806 + num1 = va_arg(ap, int);
64807 + num2 = va_arg(ap, int);
64808 + str1 = va_arg(ap, char *);
64809 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
64810 + break;
64811 + case GR_TEXTREL:
64812 + file = va_arg(ap, struct file *);
64813 + ulong1 = va_arg(ap, unsigned long);
64814 + ulong2 = va_arg(ap, unsigned long);
64815 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
64816 + break;
64817 + case GR_PTRACE:
64818 + task = va_arg(ap, struct task_struct *);
64819 + 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));
64820 + break;
64821 + case GR_RESOURCE:
64822 + task = va_arg(ap, struct task_struct *);
64823 + cred = __task_cred(task);
64824 + pcred = __task_cred(task->real_parent);
64825 + ulong1 = va_arg(ap, unsigned long);
64826 + str1 = va_arg(ap, char *);
64827 + ulong2 = va_arg(ap, unsigned long);
64828 + 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));
64829 + break;
64830 + case GR_CAP:
64831 + task = va_arg(ap, struct task_struct *);
64832 + cred = __task_cred(task);
64833 + pcred = __task_cred(task->real_parent);
64834 + str1 = va_arg(ap, char *);
64835 + 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));
64836 + break;
64837 + case GR_SIG:
64838 + str1 = va_arg(ap, char *);
64839 + voidptr = va_arg(ap, void *);
64840 + gr_log_middle_varargs(audit, msg, str1, voidptr);
64841 + break;
64842 + case GR_SIG2:
64843 + task = va_arg(ap, struct task_struct *);
64844 + cred = __task_cred(task);
64845 + pcred = __task_cred(task->real_parent);
64846 + num1 = va_arg(ap, int);
64847 + 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));
64848 + break;
64849 + case GR_CRASH1:
64850 + task = va_arg(ap, struct task_struct *);
64851 + cred = __task_cred(task);
64852 + pcred = __task_cred(task->real_parent);
64853 + ulong1 = va_arg(ap, unsigned long);
64854 + 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);
64855 + break;
64856 + case GR_CRASH2:
64857 + task = va_arg(ap, struct task_struct *);
64858 + cred = __task_cred(task);
64859 + pcred = __task_cred(task->real_parent);
64860 + ulong1 = va_arg(ap, unsigned long);
64861 + 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);
64862 + break;
64863 + case GR_RWXMAP:
64864 + file = va_arg(ap, struct file *);
64865 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
64866 + break;
64867 + case GR_PSACCT:
64868 + {
64869 + unsigned int wday, cday;
64870 + __u8 whr, chr;
64871 + __u8 wmin, cmin;
64872 + __u8 wsec, csec;
64873 + char cur_tty[64] = { 0 };
64874 + char parent_tty[64] = { 0 };
64875 +
64876 + task = va_arg(ap, struct task_struct *);
64877 + wday = va_arg(ap, unsigned int);
64878 + cday = va_arg(ap, unsigned int);
64879 + whr = va_arg(ap, int);
64880 + chr = va_arg(ap, int);
64881 + wmin = va_arg(ap, int);
64882 + cmin = va_arg(ap, int);
64883 + wsec = va_arg(ap, int);
64884 + csec = va_arg(ap, int);
64885 + ulong1 = va_arg(ap, unsigned long);
64886 + cred = __task_cred(task);
64887 + pcred = __task_cred(task->real_parent);
64888 +
64889 + 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));
64890 + }
64891 + break;
64892 + default:
64893 + gr_log_middle(audit, msg, ap);
64894 + }
64895 + va_end(ap);
64896 + // these don't need DEFAULTSECARGS printed on the end
64897 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
64898 + gr_log_end(audit, 0);
64899 + else
64900 + gr_log_end(audit, 1);
64901 + END_LOCKS(audit);
64902 +}
64903 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
64904 new file mode 100644
64905 index 0000000..f536303
64906 --- /dev/null
64907 +++ b/grsecurity/grsec_mem.c
64908 @@ -0,0 +1,40 @@
64909 +#include <linux/kernel.h>
64910 +#include <linux/sched.h>
64911 +#include <linux/mm.h>
64912 +#include <linux/mman.h>
64913 +#include <linux/grinternal.h>
64914 +
64915 +void
64916 +gr_handle_ioperm(void)
64917 +{
64918 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
64919 + return;
64920 +}
64921 +
64922 +void
64923 +gr_handle_iopl(void)
64924 +{
64925 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
64926 + return;
64927 +}
64928 +
64929 +void
64930 +gr_handle_mem_readwrite(u64 from, u64 to)
64931 +{
64932 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
64933 + return;
64934 +}
64935 +
64936 +void
64937 +gr_handle_vm86(void)
64938 +{
64939 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
64940 + return;
64941 +}
64942 +
64943 +void
64944 +gr_log_badprocpid(const char *entry)
64945 +{
64946 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
64947 + return;
64948 +}
64949 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
64950 new file mode 100644
64951 index 0000000..2131422
64952 --- /dev/null
64953 +++ b/grsecurity/grsec_mount.c
64954 @@ -0,0 +1,62 @@
64955 +#include <linux/kernel.h>
64956 +#include <linux/sched.h>
64957 +#include <linux/mount.h>
64958 +#include <linux/grsecurity.h>
64959 +#include <linux/grinternal.h>
64960 +
64961 +void
64962 +gr_log_remount(const char *devname, const int retval)
64963 +{
64964 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64965 + if (grsec_enable_mount && (retval >= 0))
64966 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
64967 +#endif
64968 + return;
64969 +}
64970 +
64971 +void
64972 +gr_log_unmount(const char *devname, const int retval)
64973 +{
64974 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64975 + if (grsec_enable_mount && (retval >= 0))
64976 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
64977 +#endif
64978 + return;
64979 +}
64980 +
64981 +void
64982 +gr_log_mount(const char *from, const char *to, const int retval)
64983 +{
64984 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64985 + if (grsec_enable_mount && (retval >= 0))
64986 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
64987 +#endif
64988 + return;
64989 +}
64990 +
64991 +int
64992 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
64993 +{
64994 +#ifdef CONFIG_GRKERNSEC_ROFS
64995 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
64996 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
64997 + return -EPERM;
64998 + } else
64999 + return 0;
65000 +#endif
65001 + return 0;
65002 +}
65003 +
65004 +int
65005 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65006 +{
65007 +#ifdef CONFIG_GRKERNSEC_ROFS
65008 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65009 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65010 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65011 + return -EPERM;
65012 + } else
65013 + return 0;
65014 +#endif
65015 + return 0;
65016 +}
65017 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65018 new file mode 100644
65019 index 0000000..a3b12a0
65020 --- /dev/null
65021 +++ b/grsecurity/grsec_pax.c
65022 @@ -0,0 +1,36 @@
65023 +#include <linux/kernel.h>
65024 +#include <linux/sched.h>
65025 +#include <linux/mm.h>
65026 +#include <linux/file.h>
65027 +#include <linux/grinternal.h>
65028 +#include <linux/grsecurity.h>
65029 +
65030 +void
65031 +gr_log_textrel(struct vm_area_struct * vma)
65032 +{
65033 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65034 + if (grsec_enable_audit_textrel)
65035 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65036 +#endif
65037 + return;
65038 +}
65039 +
65040 +void
65041 +gr_log_rwxmmap(struct file *file)
65042 +{
65043 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65044 + if (grsec_enable_log_rwxmaps)
65045 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65046 +#endif
65047 + return;
65048 +}
65049 +
65050 +void
65051 +gr_log_rwxmprotect(struct file *file)
65052 +{
65053 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65054 + if (grsec_enable_log_rwxmaps)
65055 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65056 +#endif
65057 + return;
65058 +}
65059 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65060 new file mode 100644
65061 index 0000000..f7f29aa
65062 --- /dev/null
65063 +++ b/grsecurity/grsec_ptrace.c
65064 @@ -0,0 +1,30 @@
65065 +#include <linux/kernel.h>
65066 +#include <linux/sched.h>
65067 +#include <linux/grinternal.h>
65068 +#include <linux/security.h>
65069 +
65070 +void
65071 +gr_audit_ptrace(struct task_struct *task)
65072 +{
65073 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65074 + if (grsec_enable_audit_ptrace)
65075 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65076 +#endif
65077 + return;
65078 +}
65079 +
65080 +int
65081 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65082 +{
65083 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65084 + const struct dentry *dentry = file->f_path.dentry;
65085 + const struct vfsmount *mnt = file->f_path.mnt;
65086 +
65087 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65088 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65089 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65090 + return -EACCES;
65091 + }
65092 +#endif
65093 + return 0;
65094 +}
65095 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65096 new file mode 100644
65097 index 0000000..e09715a
65098 --- /dev/null
65099 +++ b/grsecurity/grsec_sig.c
65100 @@ -0,0 +1,222 @@
65101 +#include <linux/kernel.h>
65102 +#include <linux/sched.h>
65103 +#include <linux/delay.h>
65104 +#include <linux/grsecurity.h>
65105 +#include <linux/grinternal.h>
65106 +#include <linux/hardirq.h>
65107 +
65108 +char *signames[] = {
65109 + [SIGSEGV] = "Segmentation fault",
65110 + [SIGILL] = "Illegal instruction",
65111 + [SIGABRT] = "Abort",
65112 + [SIGBUS] = "Invalid alignment/Bus error"
65113 +};
65114 +
65115 +void
65116 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65117 +{
65118 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65119 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65120 + (sig == SIGABRT) || (sig == SIGBUS))) {
65121 + if (task_pid_nr(t) == task_pid_nr(current)) {
65122 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65123 + } else {
65124 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65125 + }
65126 + }
65127 +#endif
65128 + return;
65129 +}
65130 +
65131 +int
65132 +gr_handle_signal(const struct task_struct *p, const int sig)
65133 +{
65134 +#ifdef CONFIG_GRKERNSEC
65135 + /* ignore the 0 signal for protected task checks */
65136 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65137 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65138 + return -EPERM;
65139 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65140 + return -EPERM;
65141 + }
65142 +#endif
65143 + return 0;
65144 +}
65145 +
65146 +#ifdef CONFIG_GRKERNSEC
65147 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65148 +
65149 +int gr_fake_force_sig(int sig, struct task_struct *t)
65150 +{
65151 + unsigned long int flags;
65152 + int ret, blocked, ignored;
65153 + struct k_sigaction *action;
65154 +
65155 + spin_lock_irqsave(&t->sighand->siglock, flags);
65156 + action = &t->sighand->action[sig-1];
65157 + ignored = action->sa.sa_handler == SIG_IGN;
65158 + blocked = sigismember(&t->blocked, sig);
65159 + if (blocked || ignored) {
65160 + action->sa.sa_handler = SIG_DFL;
65161 + if (blocked) {
65162 + sigdelset(&t->blocked, sig);
65163 + recalc_sigpending_and_wake(t);
65164 + }
65165 + }
65166 + if (action->sa.sa_handler == SIG_DFL)
65167 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65168 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65169 +
65170 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65171 +
65172 + return ret;
65173 +}
65174 +#endif
65175 +
65176 +#ifdef CONFIG_GRKERNSEC_BRUTE
65177 +#define GR_USER_BAN_TIME (15 * 60)
65178 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65179 +
65180 +static int __get_dumpable(unsigned long mm_flags)
65181 +{
65182 + int ret;
65183 +
65184 + ret = mm_flags & MMF_DUMPABLE_MASK;
65185 + return (ret >= 2) ? 2 : ret;
65186 +}
65187 +#endif
65188 +
65189 +void gr_handle_brute_attach(unsigned long mm_flags)
65190 +{
65191 +#ifdef CONFIG_GRKERNSEC_BRUTE
65192 + struct task_struct *p = current;
65193 + kuid_t uid = GLOBAL_ROOT_UID;
65194 + int daemon = 0;
65195 +
65196 + if (!grsec_enable_brute)
65197 + return;
65198 +
65199 + rcu_read_lock();
65200 + read_lock(&tasklist_lock);
65201 + read_lock(&grsec_exec_file_lock);
65202 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65203 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65204 + p->real_parent->brute = 1;
65205 + daemon = 1;
65206 + } else {
65207 + const struct cred *cred = __task_cred(p), *cred2;
65208 + struct task_struct *tsk, *tsk2;
65209 +
65210 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65211 + struct user_struct *user;
65212 +
65213 + uid = cred->uid;
65214 +
65215 + /* this is put upon execution past expiration */
65216 + user = find_user(uid);
65217 + if (user == NULL)
65218 + goto unlock;
65219 + user->banned = 1;
65220 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65221 + if (user->ban_expires == ~0UL)
65222 + user->ban_expires--;
65223 +
65224 + do_each_thread(tsk2, tsk) {
65225 + cred2 = __task_cred(tsk);
65226 + if (tsk != p && uid_eq(cred2->uid, uid))
65227 + gr_fake_force_sig(SIGKILL, tsk);
65228 + } while_each_thread(tsk2, tsk);
65229 + }
65230 + }
65231 +unlock:
65232 + read_unlock(&grsec_exec_file_lock);
65233 + read_unlock(&tasklist_lock);
65234 + rcu_read_unlock();
65235 +
65236 + if (gr_is_global_nonroot(uid))
65237 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65238 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65239 + else if (daemon)
65240 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65241 +
65242 +#endif
65243 + return;
65244 +}
65245 +
65246 +void gr_handle_brute_check(void)
65247 +{
65248 +#ifdef CONFIG_GRKERNSEC_BRUTE
65249 + struct task_struct *p = current;
65250 +
65251 + if (unlikely(p->brute)) {
65252 + if (!grsec_enable_brute)
65253 + p->brute = 0;
65254 + else if (time_before(get_seconds(), p->brute_expires))
65255 + msleep(30 * 1000);
65256 + }
65257 +#endif
65258 + return;
65259 +}
65260 +
65261 +void gr_handle_kernel_exploit(void)
65262 +{
65263 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65264 + const struct cred *cred;
65265 + struct task_struct *tsk, *tsk2;
65266 + struct user_struct *user;
65267 + kuid_t uid;
65268 +
65269 + if (in_irq() || in_serving_softirq() || in_nmi())
65270 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65271 +
65272 + uid = current_uid();
65273 +
65274 + if (gr_is_global_root(uid))
65275 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65276 + else {
65277 + /* kill all the processes of this user, hold a reference
65278 + to their creds struct, and prevent them from creating
65279 + another process until system reset
65280 + */
65281 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
65282 + GR_GLOBAL_UID(uid));
65283 + /* we intentionally leak this ref */
65284 + user = get_uid(current->cred->user);
65285 + if (user) {
65286 + user->banned = 1;
65287 + user->ban_expires = ~0UL;
65288 + }
65289 +
65290 + read_lock(&tasklist_lock);
65291 + do_each_thread(tsk2, tsk) {
65292 + cred = __task_cred(tsk);
65293 + if (uid_eq(cred->uid, uid))
65294 + gr_fake_force_sig(SIGKILL, tsk);
65295 + } while_each_thread(tsk2, tsk);
65296 + read_unlock(&tasklist_lock);
65297 + }
65298 +#endif
65299 +}
65300 +
65301 +int __gr_process_user_ban(struct user_struct *user)
65302 +{
65303 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65304 + if (unlikely(user->banned)) {
65305 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
65306 + user->banned = 0;
65307 + user->ban_expires = 0;
65308 + free_uid(user);
65309 + } else
65310 + return -EPERM;
65311 + }
65312 +#endif
65313 + return 0;
65314 +}
65315 +
65316 +int gr_process_user_ban(void)
65317 +{
65318 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65319 + return __gr_process_user_ban(current->cred->user);
65320 +#endif
65321 + return 0;
65322 +}
65323 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
65324 new file mode 100644
65325 index 0000000..4030d57
65326 --- /dev/null
65327 +++ b/grsecurity/grsec_sock.c
65328 @@ -0,0 +1,244 @@
65329 +#include <linux/kernel.h>
65330 +#include <linux/module.h>
65331 +#include <linux/sched.h>
65332 +#include <linux/file.h>
65333 +#include <linux/net.h>
65334 +#include <linux/in.h>
65335 +#include <linux/ip.h>
65336 +#include <net/sock.h>
65337 +#include <net/inet_sock.h>
65338 +#include <linux/grsecurity.h>
65339 +#include <linux/grinternal.h>
65340 +#include <linux/gracl.h>
65341 +
65342 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
65343 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
65344 +
65345 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
65346 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
65347 +
65348 +#ifdef CONFIG_UNIX_MODULE
65349 +EXPORT_SYMBOL(gr_acl_handle_unix);
65350 +EXPORT_SYMBOL(gr_acl_handle_mknod);
65351 +EXPORT_SYMBOL(gr_handle_chroot_unix);
65352 +EXPORT_SYMBOL(gr_handle_create);
65353 +#endif
65354 +
65355 +#ifdef CONFIG_GRKERNSEC
65356 +#define gr_conn_table_size 32749
65357 +struct conn_table_entry {
65358 + struct conn_table_entry *next;
65359 + struct signal_struct *sig;
65360 +};
65361 +
65362 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
65363 +DEFINE_SPINLOCK(gr_conn_table_lock);
65364 +
65365 +extern const char * gr_socktype_to_name(unsigned char type);
65366 +extern const char * gr_proto_to_name(unsigned char proto);
65367 +extern const char * gr_sockfamily_to_name(unsigned char family);
65368 +
65369 +static __inline__ int
65370 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
65371 +{
65372 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
65373 +}
65374 +
65375 +static __inline__ int
65376 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
65377 + __u16 sport, __u16 dport)
65378 +{
65379 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
65380 + sig->gr_sport == sport && sig->gr_dport == dport))
65381 + return 1;
65382 + else
65383 + return 0;
65384 +}
65385 +
65386 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
65387 +{
65388 + struct conn_table_entry **match;
65389 + unsigned int index;
65390 +
65391 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65392 + sig->gr_sport, sig->gr_dport,
65393 + gr_conn_table_size);
65394 +
65395 + newent->sig = sig;
65396 +
65397 + match = &gr_conn_table[index];
65398 + newent->next = *match;
65399 + *match = newent;
65400 +
65401 + return;
65402 +}
65403 +
65404 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
65405 +{
65406 + struct conn_table_entry *match, *last = NULL;
65407 + unsigned int index;
65408 +
65409 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65410 + sig->gr_sport, sig->gr_dport,
65411 + gr_conn_table_size);
65412 +
65413 + match = gr_conn_table[index];
65414 + while (match && !conn_match(match->sig,
65415 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
65416 + sig->gr_dport)) {
65417 + last = match;
65418 + match = match->next;
65419 + }
65420 +
65421 + if (match) {
65422 + if (last)
65423 + last->next = match->next;
65424 + else
65425 + gr_conn_table[index] = NULL;
65426 + kfree(match);
65427 + }
65428 +
65429 + return;
65430 +}
65431 +
65432 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
65433 + __u16 sport, __u16 dport)
65434 +{
65435 + struct conn_table_entry *match;
65436 + unsigned int index;
65437 +
65438 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
65439 +
65440 + match = gr_conn_table[index];
65441 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
65442 + match = match->next;
65443 +
65444 + if (match)
65445 + return match->sig;
65446 + else
65447 + return NULL;
65448 +}
65449 +
65450 +#endif
65451 +
65452 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
65453 +{
65454 +#ifdef CONFIG_GRKERNSEC
65455 + struct signal_struct *sig = task->signal;
65456 + struct conn_table_entry *newent;
65457 +
65458 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
65459 + if (newent == NULL)
65460 + return;
65461 + /* no bh lock needed since we are called with bh disabled */
65462 + spin_lock(&gr_conn_table_lock);
65463 + gr_del_task_from_ip_table_nolock(sig);
65464 + sig->gr_saddr = inet->inet_rcv_saddr;
65465 + sig->gr_daddr = inet->inet_daddr;
65466 + sig->gr_sport = inet->inet_sport;
65467 + sig->gr_dport = inet->inet_dport;
65468 + gr_add_to_task_ip_table_nolock(sig, newent);
65469 + spin_unlock(&gr_conn_table_lock);
65470 +#endif
65471 + return;
65472 +}
65473 +
65474 +void gr_del_task_from_ip_table(struct task_struct *task)
65475 +{
65476 +#ifdef CONFIG_GRKERNSEC
65477 + spin_lock_bh(&gr_conn_table_lock);
65478 + gr_del_task_from_ip_table_nolock(task->signal);
65479 + spin_unlock_bh(&gr_conn_table_lock);
65480 +#endif
65481 + return;
65482 +}
65483 +
65484 +void
65485 +gr_attach_curr_ip(const struct sock *sk)
65486 +{
65487 +#ifdef CONFIG_GRKERNSEC
65488 + struct signal_struct *p, *set;
65489 + const struct inet_sock *inet = inet_sk(sk);
65490 +
65491 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
65492 + return;
65493 +
65494 + set = current->signal;
65495 +
65496 + spin_lock_bh(&gr_conn_table_lock);
65497 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
65498 + inet->inet_dport, inet->inet_sport);
65499 + if (unlikely(p != NULL)) {
65500 + set->curr_ip = p->curr_ip;
65501 + set->used_accept = 1;
65502 + gr_del_task_from_ip_table_nolock(p);
65503 + spin_unlock_bh(&gr_conn_table_lock);
65504 + return;
65505 + }
65506 + spin_unlock_bh(&gr_conn_table_lock);
65507 +
65508 + set->curr_ip = inet->inet_daddr;
65509 + set->used_accept = 1;
65510 +#endif
65511 + return;
65512 +}
65513 +
65514 +int
65515 +gr_handle_sock_all(const int family, const int type, const int protocol)
65516 +{
65517 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65518 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
65519 + (family != AF_UNIX)) {
65520 + if (family == AF_INET)
65521 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
65522 + else
65523 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
65524 + return -EACCES;
65525 + }
65526 +#endif
65527 + return 0;
65528 +}
65529 +
65530 +int
65531 +gr_handle_sock_server(const struct sockaddr *sck)
65532 +{
65533 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65534 + if (grsec_enable_socket_server &&
65535 + in_group_p(grsec_socket_server_gid) &&
65536 + sck && (sck->sa_family != AF_UNIX) &&
65537 + (sck->sa_family != AF_LOCAL)) {
65538 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65539 + return -EACCES;
65540 + }
65541 +#endif
65542 + return 0;
65543 +}
65544 +
65545 +int
65546 +gr_handle_sock_server_other(const struct sock *sck)
65547 +{
65548 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65549 + if (grsec_enable_socket_server &&
65550 + in_group_p(grsec_socket_server_gid) &&
65551 + sck && (sck->sk_family != AF_UNIX) &&
65552 + (sck->sk_family != AF_LOCAL)) {
65553 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65554 + return -EACCES;
65555 + }
65556 +#endif
65557 + return 0;
65558 +}
65559 +
65560 +int
65561 +gr_handle_sock_client(const struct sockaddr *sck)
65562 +{
65563 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65564 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
65565 + sck && (sck->sa_family != AF_UNIX) &&
65566 + (sck->sa_family != AF_LOCAL)) {
65567 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
65568 + return -EACCES;
65569 + }
65570 +#endif
65571 + return 0;
65572 +}
65573 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
65574 new file mode 100644
65575 index 0000000..f55ef0f
65576 --- /dev/null
65577 +++ b/grsecurity/grsec_sysctl.c
65578 @@ -0,0 +1,469 @@
65579 +#include <linux/kernel.h>
65580 +#include <linux/sched.h>
65581 +#include <linux/sysctl.h>
65582 +#include <linux/grsecurity.h>
65583 +#include <linux/grinternal.h>
65584 +
65585 +int
65586 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
65587 +{
65588 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65589 + if (dirname == NULL || name == NULL)
65590 + return 0;
65591 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
65592 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
65593 + return -EACCES;
65594 + }
65595 +#endif
65596 + return 0;
65597 +}
65598 +
65599 +#ifdef CONFIG_GRKERNSEC_ROFS
65600 +static int __maybe_unused one = 1;
65601 +#endif
65602 +
65603 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
65604 +struct ctl_table grsecurity_table[] = {
65605 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65606 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
65607 +#ifdef CONFIG_GRKERNSEC_IO
65608 + {
65609 + .procname = "disable_priv_io",
65610 + .data = &grsec_disable_privio,
65611 + .maxlen = sizeof(int),
65612 + .mode = 0600,
65613 + .proc_handler = &proc_dointvec,
65614 + },
65615 +#endif
65616 +#endif
65617 +#ifdef CONFIG_GRKERNSEC_LINK
65618 + {
65619 + .procname = "linking_restrictions",
65620 + .data = &grsec_enable_link,
65621 + .maxlen = sizeof(int),
65622 + .mode = 0600,
65623 + .proc_handler = &proc_dointvec,
65624 + },
65625 +#endif
65626 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65627 + {
65628 + .procname = "enforce_symlinksifowner",
65629 + .data = &grsec_enable_symlinkown,
65630 + .maxlen = sizeof(int),
65631 + .mode = 0600,
65632 + .proc_handler = &proc_dointvec,
65633 + },
65634 + {
65635 + .procname = "symlinkown_gid",
65636 + .data = &grsec_symlinkown_gid,
65637 + .maxlen = sizeof(int),
65638 + .mode = 0600,
65639 + .proc_handler = &proc_dointvec,
65640 + },
65641 +#endif
65642 +#ifdef CONFIG_GRKERNSEC_BRUTE
65643 + {
65644 + .procname = "deter_bruteforce",
65645 + .data = &grsec_enable_brute,
65646 + .maxlen = sizeof(int),
65647 + .mode = 0600,
65648 + .proc_handler = &proc_dointvec,
65649 + },
65650 +#endif
65651 +#ifdef CONFIG_GRKERNSEC_FIFO
65652 + {
65653 + .procname = "fifo_restrictions",
65654 + .data = &grsec_enable_fifo,
65655 + .maxlen = sizeof(int),
65656 + .mode = 0600,
65657 + .proc_handler = &proc_dointvec,
65658 + },
65659 +#endif
65660 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65661 + {
65662 + .procname = "ptrace_readexec",
65663 + .data = &grsec_enable_ptrace_readexec,
65664 + .maxlen = sizeof(int),
65665 + .mode = 0600,
65666 + .proc_handler = &proc_dointvec,
65667 + },
65668 +#endif
65669 +#ifdef CONFIG_GRKERNSEC_SETXID
65670 + {
65671 + .procname = "consistent_setxid",
65672 + .data = &grsec_enable_setxid,
65673 + .maxlen = sizeof(int),
65674 + .mode = 0600,
65675 + .proc_handler = &proc_dointvec,
65676 + },
65677 +#endif
65678 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65679 + {
65680 + .procname = "ip_blackhole",
65681 + .data = &grsec_enable_blackhole,
65682 + .maxlen = sizeof(int),
65683 + .mode = 0600,
65684 + .proc_handler = &proc_dointvec,
65685 + },
65686 + {
65687 + .procname = "lastack_retries",
65688 + .data = &grsec_lastack_retries,
65689 + .maxlen = sizeof(int),
65690 + .mode = 0600,
65691 + .proc_handler = &proc_dointvec,
65692 + },
65693 +#endif
65694 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65695 + {
65696 + .procname = "exec_logging",
65697 + .data = &grsec_enable_execlog,
65698 + .maxlen = sizeof(int),
65699 + .mode = 0600,
65700 + .proc_handler = &proc_dointvec,
65701 + },
65702 +#endif
65703 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65704 + {
65705 + .procname = "rwxmap_logging",
65706 + .data = &grsec_enable_log_rwxmaps,
65707 + .maxlen = sizeof(int),
65708 + .mode = 0600,
65709 + .proc_handler = &proc_dointvec,
65710 + },
65711 +#endif
65712 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65713 + {
65714 + .procname = "signal_logging",
65715 + .data = &grsec_enable_signal,
65716 + .maxlen = sizeof(int),
65717 + .mode = 0600,
65718 + .proc_handler = &proc_dointvec,
65719 + },
65720 +#endif
65721 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65722 + {
65723 + .procname = "forkfail_logging",
65724 + .data = &grsec_enable_forkfail,
65725 + .maxlen = sizeof(int),
65726 + .mode = 0600,
65727 + .proc_handler = &proc_dointvec,
65728 + },
65729 +#endif
65730 +#ifdef CONFIG_GRKERNSEC_TIME
65731 + {
65732 + .procname = "timechange_logging",
65733 + .data = &grsec_enable_time,
65734 + .maxlen = sizeof(int),
65735 + .mode = 0600,
65736 + .proc_handler = &proc_dointvec,
65737 + },
65738 +#endif
65739 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65740 + {
65741 + .procname = "chroot_deny_shmat",
65742 + .data = &grsec_enable_chroot_shmat,
65743 + .maxlen = sizeof(int),
65744 + .mode = 0600,
65745 + .proc_handler = &proc_dointvec,
65746 + },
65747 +#endif
65748 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65749 + {
65750 + .procname = "chroot_deny_unix",
65751 + .data = &grsec_enable_chroot_unix,
65752 + .maxlen = sizeof(int),
65753 + .mode = 0600,
65754 + .proc_handler = &proc_dointvec,
65755 + },
65756 +#endif
65757 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65758 + {
65759 + .procname = "chroot_deny_mount",
65760 + .data = &grsec_enable_chroot_mount,
65761 + .maxlen = sizeof(int),
65762 + .mode = 0600,
65763 + .proc_handler = &proc_dointvec,
65764 + },
65765 +#endif
65766 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65767 + {
65768 + .procname = "chroot_deny_fchdir",
65769 + .data = &grsec_enable_chroot_fchdir,
65770 + .maxlen = sizeof(int),
65771 + .mode = 0600,
65772 + .proc_handler = &proc_dointvec,
65773 + },
65774 +#endif
65775 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65776 + {
65777 + .procname = "chroot_deny_chroot",
65778 + .data = &grsec_enable_chroot_double,
65779 + .maxlen = sizeof(int),
65780 + .mode = 0600,
65781 + .proc_handler = &proc_dointvec,
65782 + },
65783 +#endif
65784 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65785 + {
65786 + .procname = "chroot_deny_pivot",
65787 + .data = &grsec_enable_chroot_pivot,
65788 + .maxlen = sizeof(int),
65789 + .mode = 0600,
65790 + .proc_handler = &proc_dointvec,
65791 + },
65792 +#endif
65793 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65794 + {
65795 + .procname = "chroot_enforce_chdir",
65796 + .data = &grsec_enable_chroot_chdir,
65797 + .maxlen = sizeof(int),
65798 + .mode = 0600,
65799 + .proc_handler = &proc_dointvec,
65800 + },
65801 +#endif
65802 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65803 + {
65804 + .procname = "chroot_deny_chmod",
65805 + .data = &grsec_enable_chroot_chmod,
65806 + .maxlen = sizeof(int),
65807 + .mode = 0600,
65808 + .proc_handler = &proc_dointvec,
65809 + },
65810 +#endif
65811 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65812 + {
65813 + .procname = "chroot_deny_mknod",
65814 + .data = &grsec_enable_chroot_mknod,
65815 + .maxlen = sizeof(int),
65816 + .mode = 0600,
65817 + .proc_handler = &proc_dointvec,
65818 + },
65819 +#endif
65820 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65821 + {
65822 + .procname = "chroot_restrict_nice",
65823 + .data = &grsec_enable_chroot_nice,
65824 + .maxlen = sizeof(int),
65825 + .mode = 0600,
65826 + .proc_handler = &proc_dointvec,
65827 + },
65828 +#endif
65829 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65830 + {
65831 + .procname = "chroot_execlog",
65832 + .data = &grsec_enable_chroot_execlog,
65833 + .maxlen = sizeof(int),
65834 + .mode = 0600,
65835 + .proc_handler = &proc_dointvec,
65836 + },
65837 +#endif
65838 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65839 + {
65840 + .procname = "chroot_caps",
65841 + .data = &grsec_enable_chroot_caps,
65842 + .maxlen = sizeof(int),
65843 + .mode = 0600,
65844 + .proc_handler = &proc_dointvec,
65845 + },
65846 +#endif
65847 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65848 + {
65849 + .procname = "chroot_deny_sysctl",
65850 + .data = &grsec_enable_chroot_sysctl,
65851 + .maxlen = sizeof(int),
65852 + .mode = 0600,
65853 + .proc_handler = &proc_dointvec,
65854 + },
65855 +#endif
65856 +#ifdef CONFIG_GRKERNSEC_TPE
65857 + {
65858 + .procname = "tpe",
65859 + .data = &grsec_enable_tpe,
65860 + .maxlen = sizeof(int),
65861 + .mode = 0600,
65862 + .proc_handler = &proc_dointvec,
65863 + },
65864 + {
65865 + .procname = "tpe_gid",
65866 + .data = &grsec_tpe_gid,
65867 + .maxlen = sizeof(int),
65868 + .mode = 0600,
65869 + .proc_handler = &proc_dointvec,
65870 + },
65871 +#endif
65872 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65873 + {
65874 + .procname = "tpe_invert",
65875 + .data = &grsec_enable_tpe_invert,
65876 + .maxlen = sizeof(int),
65877 + .mode = 0600,
65878 + .proc_handler = &proc_dointvec,
65879 + },
65880 +#endif
65881 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65882 + {
65883 + .procname = "tpe_restrict_all",
65884 + .data = &grsec_enable_tpe_all,
65885 + .maxlen = sizeof(int),
65886 + .mode = 0600,
65887 + .proc_handler = &proc_dointvec,
65888 + },
65889 +#endif
65890 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65891 + {
65892 + .procname = "socket_all",
65893 + .data = &grsec_enable_socket_all,
65894 + .maxlen = sizeof(int),
65895 + .mode = 0600,
65896 + .proc_handler = &proc_dointvec,
65897 + },
65898 + {
65899 + .procname = "socket_all_gid",
65900 + .data = &grsec_socket_all_gid,
65901 + .maxlen = sizeof(int),
65902 + .mode = 0600,
65903 + .proc_handler = &proc_dointvec,
65904 + },
65905 +#endif
65906 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65907 + {
65908 + .procname = "socket_client",
65909 + .data = &grsec_enable_socket_client,
65910 + .maxlen = sizeof(int),
65911 + .mode = 0600,
65912 + .proc_handler = &proc_dointvec,
65913 + },
65914 + {
65915 + .procname = "socket_client_gid",
65916 + .data = &grsec_socket_client_gid,
65917 + .maxlen = sizeof(int),
65918 + .mode = 0600,
65919 + .proc_handler = &proc_dointvec,
65920 + },
65921 +#endif
65922 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65923 + {
65924 + .procname = "socket_server",
65925 + .data = &grsec_enable_socket_server,
65926 + .maxlen = sizeof(int),
65927 + .mode = 0600,
65928 + .proc_handler = &proc_dointvec,
65929 + },
65930 + {
65931 + .procname = "socket_server_gid",
65932 + .data = &grsec_socket_server_gid,
65933 + .maxlen = sizeof(int),
65934 + .mode = 0600,
65935 + .proc_handler = &proc_dointvec,
65936 + },
65937 +#endif
65938 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65939 + {
65940 + .procname = "audit_group",
65941 + .data = &grsec_enable_group,
65942 + .maxlen = sizeof(int),
65943 + .mode = 0600,
65944 + .proc_handler = &proc_dointvec,
65945 + },
65946 + {
65947 + .procname = "audit_gid",
65948 + .data = &grsec_audit_gid,
65949 + .maxlen = sizeof(int),
65950 + .mode = 0600,
65951 + .proc_handler = &proc_dointvec,
65952 + },
65953 +#endif
65954 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65955 + {
65956 + .procname = "audit_chdir",
65957 + .data = &grsec_enable_chdir,
65958 + .maxlen = sizeof(int),
65959 + .mode = 0600,
65960 + .proc_handler = &proc_dointvec,
65961 + },
65962 +#endif
65963 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65964 + {
65965 + .procname = "audit_mount",
65966 + .data = &grsec_enable_mount,
65967 + .maxlen = sizeof(int),
65968 + .mode = 0600,
65969 + .proc_handler = &proc_dointvec,
65970 + },
65971 +#endif
65972 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65973 + {
65974 + .procname = "audit_textrel",
65975 + .data = &grsec_enable_audit_textrel,
65976 + .maxlen = sizeof(int),
65977 + .mode = 0600,
65978 + .proc_handler = &proc_dointvec,
65979 + },
65980 +#endif
65981 +#ifdef CONFIG_GRKERNSEC_DMESG
65982 + {
65983 + .procname = "dmesg",
65984 + .data = &grsec_enable_dmesg,
65985 + .maxlen = sizeof(int),
65986 + .mode = 0600,
65987 + .proc_handler = &proc_dointvec,
65988 + },
65989 +#endif
65990 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65991 + {
65992 + .procname = "chroot_findtask",
65993 + .data = &grsec_enable_chroot_findtask,
65994 + .maxlen = sizeof(int),
65995 + .mode = 0600,
65996 + .proc_handler = &proc_dointvec,
65997 + },
65998 +#endif
65999 +#ifdef CONFIG_GRKERNSEC_RESLOG
66000 + {
66001 + .procname = "resource_logging",
66002 + .data = &grsec_resource_logging,
66003 + .maxlen = sizeof(int),
66004 + .mode = 0600,
66005 + .proc_handler = &proc_dointvec,
66006 + },
66007 +#endif
66008 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66009 + {
66010 + .procname = "audit_ptrace",
66011 + .data = &grsec_enable_audit_ptrace,
66012 + .maxlen = sizeof(int),
66013 + .mode = 0600,
66014 + .proc_handler = &proc_dointvec,
66015 + },
66016 +#endif
66017 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66018 + {
66019 + .procname = "harden_ptrace",
66020 + .data = &grsec_enable_harden_ptrace,
66021 + .maxlen = sizeof(int),
66022 + .mode = 0600,
66023 + .proc_handler = &proc_dointvec,
66024 + },
66025 +#endif
66026 + {
66027 + .procname = "grsec_lock",
66028 + .data = &grsec_lock,
66029 + .maxlen = sizeof(int),
66030 + .mode = 0600,
66031 + .proc_handler = &proc_dointvec,
66032 + },
66033 +#endif
66034 +#ifdef CONFIG_GRKERNSEC_ROFS
66035 + {
66036 + .procname = "romount_protect",
66037 + .data = &grsec_enable_rofs,
66038 + .maxlen = sizeof(int),
66039 + .mode = 0600,
66040 + .proc_handler = &proc_dointvec_minmax,
66041 + .extra1 = &one,
66042 + .extra2 = &one,
66043 + },
66044 +#endif
66045 + { }
66046 +};
66047 +#endif
66048 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66049 new file mode 100644
66050 index 0000000..0dc13c3
66051 --- /dev/null
66052 +++ b/grsecurity/grsec_time.c
66053 @@ -0,0 +1,16 @@
66054 +#include <linux/kernel.h>
66055 +#include <linux/sched.h>
66056 +#include <linux/grinternal.h>
66057 +#include <linux/module.h>
66058 +
66059 +void
66060 +gr_log_timechange(void)
66061 +{
66062 +#ifdef CONFIG_GRKERNSEC_TIME
66063 + if (grsec_enable_time)
66064 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66065 +#endif
66066 + return;
66067 +}
66068 +
66069 +EXPORT_SYMBOL(gr_log_timechange);
66070 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66071 new file mode 100644
66072 index 0000000..ee57dcf
66073 --- /dev/null
66074 +++ b/grsecurity/grsec_tpe.c
66075 @@ -0,0 +1,73 @@
66076 +#include <linux/kernel.h>
66077 +#include <linux/sched.h>
66078 +#include <linux/file.h>
66079 +#include <linux/fs.h>
66080 +#include <linux/grinternal.h>
66081 +
66082 +extern int gr_acl_tpe_check(void);
66083 +
66084 +int
66085 +gr_tpe_allow(const struct file *file)
66086 +{
66087 +#ifdef CONFIG_GRKERNSEC
66088 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66089 + const struct cred *cred = current_cred();
66090 + char *msg = NULL;
66091 + char *msg2 = NULL;
66092 +
66093 + // never restrict root
66094 + if (gr_is_global_root(cred->uid))
66095 + return 1;
66096 +
66097 + if (grsec_enable_tpe) {
66098 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66099 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66100 + msg = "not being in trusted group";
66101 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66102 + msg = "being in untrusted group";
66103 +#else
66104 + if (in_group_p(grsec_tpe_gid))
66105 + msg = "being in untrusted group";
66106 +#endif
66107 + }
66108 + if (!msg && gr_acl_tpe_check())
66109 + msg = "being in untrusted role";
66110 +
66111 + // not in any affected group/role
66112 + if (!msg)
66113 + goto next_check;
66114 +
66115 + if (gr_is_global_nonroot(inode->i_uid))
66116 + msg2 = "file in non-root-owned directory";
66117 + else if (inode->i_mode & S_IWOTH)
66118 + msg2 = "file in world-writable directory";
66119 + else if (inode->i_mode & S_IWGRP)
66120 + msg2 = "file in group-writable directory";
66121 +
66122 + if (msg && msg2) {
66123 + char fullmsg[70] = {0};
66124 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66125 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66126 + return 0;
66127 + }
66128 + msg = NULL;
66129 +next_check:
66130 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66131 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66132 + return 1;
66133 +
66134 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66135 + msg = "directory not owned by user";
66136 + else if (inode->i_mode & S_IWOTH)
66137 + msg = "file in world-writable directory";
66138 + else if (inode->i_mode & S_IWGRP)
66139 + msg = "file in group-writable directory";
66140 +
66141 + if (msg) {
66142 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66143 + return 0;
66144 + }
66145 +#endif
66146 +#endif
66147 + return 1;
66148 +}
66149 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66150 new file mode 100644
66151 index 0000000..9f7b1ac
66152 --- /dev/null
66153 +++ b/grsecurity/grsum.c
66154 @@ -0,0 +1,61 @@
66155 +#include <linux/err.h>
66156 +#include <linux/kernel.h>
66157 +#include <linux/sched.h>
66158 +#include <linux/mm.h>
66159 +#include <linux/scatterlist.h>
66160 +#include <linux/crypto.h>
66161 +#include <linux/gracl.h>
66162 +
66163 +
66164 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66165 +#error "crypto and sha256 must be built into the kernel"
66166 +#endif
66167 +
66168 +int
66169 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66170 +{
66171 + char *p;
66172 + struct crypto_hash *tfm;
66173 + struct hash_desc desc;
66174 + struct scatterlist sg;
66175 + unsigned char temp_sum[GR_SHA_LEN];
66176 + volatile int retval = 0;
66177 + volatile int dummy = 0;
66178 + unsigned int i;
66179 +
66180 + sg_init_table(&sg, 1);
66181 +
66182 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66183 + if (IS_ERR(tfm)) {
66184 + /* should never happen, since sha256 should be built in */
66185 + return 1;
66186 + }
66187 +
66188 + desc.tfm = tfm;
66189 + desc.flags = 0;
66190 +
66191 + crypto_hash_init(&desc);
66192 +
66193 + p = salt;
66194 + sg_set_buf(&sg, p, GR_SALT_LEN);
66195 + crypto_hash_update(&desc, &sg, sg.length);
66196 +
66197 + p = entry->pw;
66198 + sg_set_buf(&sg, p, strlen(p));
66199 +
66200 + crypto_hash_update(&desc, &sg, sg.length);
66201 +
66202 + crypto_hash_final(&desc, temp_sum);
66203 +
66204 + memset(entry->pw, 0, GR_PW_LEN);
66205 +
66206 + for (i = 0; i < GR_SHA_LEN; i++)
66207 + if (sum[i] != temp_sum[i])
66208 + retval = 1;
66209 + else
66210 + dummy = 1; // waste a cycle
66211 +
66212 + crypto_free_hash(tfm);
66213 +
66214 + return retval;
66215 +}
66216 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66217 index 77ff547..181834f 100644
66218 --- a/include/asm-generic/4level-fixup.h
66219 +++ b/include/asm-generic/4level-fixup.h
66220 @@ -13,8 +13,10 @@
66221 #define pmd_alloc(mm, pud, address) \
66222 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66223 NULL: pmd_offset(pud, address))
66224 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66225
66226 #define pud_alloc(mm, pgd, address) (pgd)
66227 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66228 #define pud_offset(pgd, start) (pgd)
66229 #define pud_none(pud) 0
66230 #define pud_bad(pud) 0
66231 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66232 index b7babf0..04ad282 100644
66233 --- a/include/asm-generic/atomic-long.h
66234 +++ b/include/asm-generic/atomic-long.h
66235 @@ -22,6 +22,12 @@
66236
66237 typedef atomic64_t atomic_long_t;
66238
66239 +#ifdef CONFIG_PAX_REFCOUNT
66240 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66241 +#else
66242 +typedef atomic64_t atomic_long_unchecked_t;
66243 +#endif
66244 +
66245 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66246
66247 static inline long atomic_long_read(atomic_long_t *l)
66248 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66249 return (long)atomic64_read(v);
66250 }
66251
66252 +#ifdef CONFIG_PAX_REFCOUNT
66253 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66254 +{
66255 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66256 +
66257 + return (long)atomic64_read_unchecked(v);
66258 +}
66259 +#endif
66260 +
66261 static inline void atomic_long_set(atomic_long_t *l, long i)
66262 {
66263 atomic64_t *v = (atomic64_t *)l;
66264 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66265 atomic64_set(v, i);
66266 }
66267
66268 +#ifdef CONFIG_PAX_REFCOUNT
66269 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66270 +{
66271 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66272 +
66273 + atomic64_set_unchecked(v, i);
66274 +}
66275 +#endif
66276 +
66277 static inline void atomic_long_inc(atomic_long_t *l)
66278 {
66279 atomic64_t *v = (atomic64_t *)l;
66280 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66281 atomic64_inc(v);
66282 }
66283
66284 +#ifdef CONFIG_PAX_REFCOUNT
66285 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66286 +{
66287 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66288 +
66289 + atomic64_inc_unchecked(v);
66290 +}
66291 +#endif
66292 +
66293 static inline void atomic_long_dec(atomic_long_t *l)
66294 {
66295 atomic64_t *v = (atomic64_t *)l;
66296 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66297 atomic64_dec(v);
66298 }
66299
66300 +#ifdef CONFIG_PAX_REFCOUNT
66301 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66302 +{
66303 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66304 +
66305 + atomic64_dec_unchecked(v);
66306 +}
66307 +#endif
66308 +
66309 static inline void atomic_long_add(long i, atomic_long_t *l)
66310 {
66311 atomic64_t *v = (atomic64_t *)l;
66312 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66313 atomic64_add(i, v);
66314 }
66315
66316 +#ifdef CONFIG_PAX_REFCOUNT
66317 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66318 +{
66319 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66320 +
66321 + atomic64_add_unchecked(i, v);
66322 +}
66323 +#endif
66324 +
66325 static inline void atomic_long_sub(long i, atomic_long_t *l)
66326 {
66327 atomic64_t *v = (atomic64_t *)l;
66328 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66329 atomic64_sub(i, v);
66330 }
66331
66332 +#ifdef CONFIG_PAX_REFCOUNT
66333 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66334 +{
66335 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66336 +
66337 + atomic64_sub_unchecked(i, v);
66338 +}
66339 +#endif
66340 +
66341 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66342 {
66343 atomic64_t *v = (atomic64_t *)l;
66344 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66345 return (long)atomic64_add_return(i, v);
66346 }
66347
66348 +#ifdef CONFIG_PAX_REFCOUNT
66349 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66350 +{
66351 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66352 +
66353 + return (long)atomic64_add_return_unchecked(i, v);
66354 +}
66355 +#endif
66356 +
66357 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66358 {
66359 atomic64_t *v = (atomic64_t *)l;
66360 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66361 return (long)atomic64_inc_return(v);
66362 }
66363
66364 +#ifdef CONFIG_PAX_REFCOUNT
66365 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66366 +{
66367 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66368 +
66369 + return (long)atomic64_inc_return_unchecked(v);
66370 +}
66371 +#endif
66372 +
66373 static inline long atomic_long_dec_return(atomic_long_t *l)
66374 {
66375 atomic64_t *v = (atomic64_t *)l;
66376 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66377
66378 typedef atomic_t atomic_long_t;
66379
66380 +#ifdef CONFIG_PAX_REFCOUNT
66381 +typedef atomic_unchecked_t atomic_long_unchecked_t;
66382 +#else
66383 +typedef atomic_t atomic_long_unchecked_t;
66384 +#endif
66385 +
66386 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
66387 static inline long atomic_long_read(atomic_long_t *l)
66388 {
66389 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66390 return (long)atomic_read(v);
66391 }
66392
66393 +#ifdef CONFIG_PAX_REFCOUNT
66394 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66395 +{
66396 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66397 +
66398 + return (long)atomic_read_unchecked(v);
66399 +}
66400 +#endif
66401 +
66402 static inline void atomic_long_set(atomic_long_t *l, long i)
66403 {
66404 atomic_t *v = (atomic_t *)l;
66405 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66406 atomic_set(v, i);
66407 }
66408
66409 +#ifdef CONFIG_PAX_REFCOUNT
66410 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66411 +{
66412 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66413 +
66414 + atomic_set_unchecked(v, i);
66415 +}
66416 +#endif
66417 +
66418 static inline void atomic_long_inc(atomic_long_t *l)
66419 {
66420 atomic_t *v = (atomic_t *)l;
66421 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66422 atomic_inc(v);
66423 }
66424
66425 +#ifdef CONFIG_PAX_REFCOUNT
66426 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66427 +{
66428 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66429 +
66430 + atomic_inc_unchecked(v);
66431 +}
66432 +#endif
66433 +
66434 static inline void atomic_long_dec(atomic_long_t *l)
66435 {
66436 atomic_t *v = (atomic_t *)l;
66437 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66438 atomic_dec(v);
66439 }
66440
66441 +#ifdef CONFIG_PAX_REFCOUNT
66442 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66443 +{
66444 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66445 +
66446 + atomic_dec_unchecked(v);
66447 +}
66448 +#endif
66449 +
66450 static inline void atomic_long_add(long i, atomic_long_t *l)
66451 {
66452 atomic_t *v = (atomic_t *)l;
66453 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66454 atomic_add(i, v);
66455 }
66456
66457 +#ifdef CONFIG_PAX_REFCOUNT
66458 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66459 +{
66460 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66461 +
66462 + atomic_add_unchecked(i, v);
66463 +}
66464 +#endif
66465 +
66466 static inline void atomic_long_sub(long i, atomic_long_t *l)
66467 {
66468 atomic_t *v = (atomic_t *)l;
66469 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66470 atomic_sub(i, v);
66471 }
66472
66473 +#ifdef CONFIG_PAX_REFCOUNT
66474 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66475 +{
66476 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66477 +
66478 + atomic_sub_unchecked(i, v);
66479 +}
66480 +#endif
66481 +
66482 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66483 {
66484 atomic_t *v = (atomic_t *)l;
66485 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66486 return (long)atomic_add_return(i, v);
66487 }
66488
66489 +#ifdef CONFIG_PAX_REFCOUNT
66490 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66491 +{
66492 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66493 +
66494 + return (long)atomic_add_return_unchecked(i, v);
66495 +}
66496 +
66497 +#endif
66498 +
66499 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66500 {
66501 atomic_t *v = (atomic_t *)l;
66502 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66503 return (long)atomic_inc_return(v);
66504 }
66505
66506 +#ifdef CONFIG_PAX_REFCOUNT
66507 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66508 +{
66509 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66510 +
66511 + return (long)atomic_inc_return_unchecked(v);
66512 +}
66513 +#endif
66514 +
66515 static inline long atomic_long_dec_return(atomic_long_t *l)
66516 {
66517 atomic_t *v = (atomic_t *)l;
66518 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66519
66520 #endif /* BITS_PER_LONG == 64 */
66521
66522 +#ifdef CONFIG_PAX_REFCOUNT
66523 +static inline void pax_refcount_needs_these_functions(void)
66524 +{
66525 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
66526 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
66527 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
66528 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
66529 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
66530 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
66531 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
66532 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
66533 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
66534 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
66535 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
66536 +#ifdef CONFIG_X86
66537 + atomic_clear_mask_unchecked(0, NULL);
66538 + atomic_set_mask_unchecked(0, NULL);
66539 +#endif
66540 +
66541 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
66542 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
66543 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
66544 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
66545 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
66546 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
66547 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
66548 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
66549 +}
66550 +#else
66551 +#define atomic_read_unchecked(v) atomic_read(v)
66552 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
66553 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
66554 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
66555 +#define atomic_inc_unchecked(v) atomic_inc(v)
66556 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
66557 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
66558 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
66559 +#define atomic_dec_unchecked(v) atomic_dec(v)
66560 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
66561 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
66562 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
66563 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
66564 +
66565 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
66566 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
66567 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
66568 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
66569 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
66570 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
66571 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
66572 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
66573 +#endif
66574 +
66575 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
66576 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
66577 index 1ced641..c896ee8 100644
66578 --- a/include/asm-generic/atomic.h
66579 +++ b/include/asm-generic/atomic.h
66580 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
66581 * Atomically clears the bits set in @mask from @v
66582 */
66583 #ifndef atomic_clear_mask
66584 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
66585 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
66586 {
66587 unsigned long flags;
66588
66589 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
66590 index b18ce4f..2ee2843 100644
66591 --- a/include/asm-generic/atomic64.h
66592 +++ b/include/asm-generic/atomic64.h
66593 @@ -16,6 +16,8 @@ typedef struct {
66594 long long counter;
66595 } atomic64_t;
66596
66597 +typedef atomic64_t atomic64_unchecked_t;
66598 +
66599 #define ATOMIC64_INIT(i) { (i) }
66600
66601 extern long long atomic64_read(const atomic64_t *v);
66602 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
66603 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
66604 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
66605
66606 +#define atomic64_read_unchecked(v) atomic64_read(v)
66607 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
66608 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
66609 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
66610 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
66611 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
66612 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
66613 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
66614 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
66615 +
66616 #endif /* _ASM_GENERIC_ATOMIC64_H */
66617 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
66618 index 1bfcfe5..e04c5c9 100644
66619 --- a/include/asm-generic/cache.h
66620 +++ b/include/asm-generic/cache.h
66621 @@ -6,7 +6,7 @@
66622 * cache lines need to provide their own cache.h.
66623 */
66624
66625 -#define L1_CACHE_SHIFT 5
66626 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
66627 +#define L1_CACHE_SHIFT 5UL
66628 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
66629
66630 #endif /* __ASM_GENERIC_CACHE_H */
66631 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
66632 index 0d68a1e..b74a761 100644
66633 --- a/include/asm-generic/emergency-restart.h
66634 +++ b/include/asm-generic/emergency-restart.h
66635 @@ -1,7 +1,7 @@
66636 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
66637 #define _ASM_GENERIC_EMERGENCY_RESTART_H
66638
66639 -static inline void machine_emergency_restart(void)
66640 +static inline __noreturn void machine_emergency_restart(void)
66641 {
66642 machine_restart(NULL);
66643 }
66644 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
66645 index 90f99c7..00ce236 100644
66646 --- a/include/asm-generic/kmap_types.h
66647 +++ b/include/asm-generic/kmap_types.h
66648 @@ -2,9 +2,9 @@
66649 #define _ASM_GENERIC_KMAP_TYPES_H
66650
66651 #ifdef __WITH_KM_FENCE
66652 -# define KM_TYPE_NR 41
66653 +# define KM_TYPE_NR 42
66654 #else
66655 -# define KM_TYPE_NR 20
66656 +# define KM_TYPE_NR 21
66657 #endif
66658
66659 #endif
66660 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
66661 index 9ceb03b..62b0b8f 100644
66662 --- a/include/asm-generic/local.h
66663 +++ b/include/asm-generic/local.h
66664 @@ -23,24 +23,37 @@ typedef struct
66665 atomic_long_t a;
66666 } local_t;
66667
66668 +typedef struct {
66669 + atomic_long_unchecked_t a;
66670 +} local_unchecked_t;
66671 +
66672 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
66673
66674 #define local_read(l) atomic_long_read(&(l)->a)
66675 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
66676 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
66677 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
66678 #define local_inc(l) atomic_long_inc(&(l)->a)
66679 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
66680 #define local_dec(l) atomic_long_dec(&(l)->a)
66681 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
66682 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
66683 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
66684 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
66685 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
66686
66687 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
66688 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
66689 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
66690 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
66691 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
66692 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
66693 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
66694 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
66695 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
66696
66697 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66698 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66699 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
66700 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
66701 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
66702 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
66703 index 725612b..9cc513a 100644
66704 --- a/include/asm-generic/pgtable-nopmd.h
66705 +++ b/include/asm-generic/pgtable-nopmd.h
66706 @@ -1,14 +1,19 @@
66707 #ifndef _PGTABLE_NOPMD_H
66708 #define _PGTABLE_NOPMD_H
66709
66710 -#ifndef __ASSEMBLY__
66711 -
66712 #include <asm-generic/pgtable-nopud.h>
66713
66714 -struct mm_struct;
66715 -
66716 #define __PAGETABLE_PMD_FOLDED
66717
66718 +#define PMD_SHIFT PUD_SHIFT
66719 +#define PTRS_PER_PMD 1
66720 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
66721 +#define PMD_MASK (~(PMD_SIZE-1))
66722 +
66723 +#ifndef __ASSEMBLY__
66724 +
66725 +struct mm_struct;
66726 +
66727 /*
66728 * Having the pmd type consist of a pud gets the size right, and allows
66729 * us to conceptually access the pud entry that this pmd is folded into
66730 @@ -16,11 +21,6 @@ struct mm_struct;
66731 */
66732 typedef struct { pud_t pud; } pmd_t;
66733
66734 -#define PMD_SHIFT PUD_SHIFT
66735 -#define PTRS_PER_PMD 1
66736 -#define PMD_SIZE (1UL << PMD_SHIFT)
66737 -#define PMD_MASK (~(PMD_SIZE-1))
66738 -
66739 /*
66740 * The "pud_xxx()" functions here are trivial for a folded two-level
66741 * setup: the pmd is never bad, and a pmd always exists (as it's folded
66742 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
66743 index 810431d..0ec4804f 100644
66744 --- a/include/asm-generic/pgtable-nopud.h
66745 +++ b/include/asm-generic/pgtable-nopud.h
66746 @@ -1,10 +1,15 @@
66747 #ifndef _PGTABLE_NOPUD_H
66748 #define _PGTABLE_NOPUD_H
66749
66750 -#ifndef __ASSEMBLY__
66751 -
66752 #define __PAGETABLE_PUD_FOLDED
66753
66754 +#define PUD_SHIFT PGDIR_SHIFT
66755 +#define PTRS_PER_PUD 1
66756 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
66757 +#define PUD_MASK (~(PUD_SIZE-1))
66758 +
66759 +#ifndef __ASSEMBLY__
66760 +
66761 /*
66762 * Having the pud type consist of a pgd gets the size right, and allows
66763 * us to conceptually access the pgd entry that this pud is folded into
66764 @@ -12,11 +17,6 @@
66765 */
66766 typedef struct { pgd_t pgd; } pud_t;
66767
66768 -#define PUD_SHIFT PGDIR_SHIFT
66769 -#define PTRS_PER_PUD 1
66770 -#define PUD_SIZE (1UL << PUD_SHIFT)
66771 -#define PUD_MASK (~(PUD_SIZE-1))
66772 -
66773 /*
66774 * The "pgd_xxx()" functions here are trivial for a folded two-level
66775 * setup: the pud is never bad, and a pud always exists (as it's folded
66776 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
66777 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
66778
66779 #define pgd_populate(mm, pgd, pud) do { } while (0)
66780 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
66781 /*
66782 * (puds are folded into pgds so this doesn't get actually called,
66783 * but the define is needed for a generic inline function.)
66784 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
66785 index 5cf680a..4b74d62 100644
66786 --- a/include/asm-generic/pgtable.h
66787 +++ b/include/asm-generic/pgtable.h
66788 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
66789 }
66790 #endif /* CONFIG_NUMA_BALANCING */
66791
66792 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
66793 +static inline unsigned long pax_open_kernel(void) { return 0; }
66794 +#endif
66795 +
66796 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
66797 +static inline unsigned long pax_close_kernel(void) { return 0; }
66798 +#endif
66799 +
66800 #endif /* CONFIG_MMU */
66801
66802 #endif /* !__ASSEMBLY__ */
66803 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
66804 index d1ea7ce..b1ebf2a 100644
66805 --- a/include/asm-generic/vmlinux.lds.h
66806 +++ b/include/asm-generic/vmlinux.lds.h
66807 @@ -218,6 +218,7 @@
66808 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
66809 VMLINUX_SYMBOL(__start_rodata) = .; \
66810 *(.rodata) *(.rodata.*) \
66811 + *(.data..read_only) \
66812 *(__vermagic) /* Kernel version magic */ \
66813 . = ALIGN(8); \
66814 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
66815 @@ -725,17 +726,18 @@
66816 * section in the linker script will go there too. @phdr should have
66817 * a leading colon.
66818 *
66819 - * Note that this macros defines __per_cpu_load as an absolute symbol.
66820 + * Note that this macros defines per_cpu_load as an absolute symbol.
66821 * If there is no need to put the percpu section at a predetermined
66822 * address, use PERCPU_SECTION.
66823 */
66824 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
66825 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
66826 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
66827 + per_cpu_load = .; \
66828 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
66829 - LOAD_OFFSET) { \
66830 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
66831 PERCPU_INPUT(cacheline) \
66832 } phdr \
66833 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
66834 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
66835
66836 /**
66837 * PERCPU_SECTION - define output section for percpu area, simple version
66838 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
66839 index 418d270..bfd2794 100644
66840 --- a/include/crypto/algapi.h
66841 +++ b/include/crypto/algapi.h
66842 @@ -34,7 +34,7 @@ struct crypto_type {
66843 unsigned int maskclear;
66844 unsigned int maskset;
66845 unsigned int tfmsize;
66846 -};
66847 +} __do_const;
66848
66849 struct crypto_instance {
66850 struct crypto_alg alg;
66851 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
66852 index fad21c9..ab858bc 100644
66853 --- a/include/drm/drmP.h
66854 +++ b/include/drm/drmP.h
66855 @@ -72,6 +72,7 @@
66856 #include <linux/workqueue.h>
66857 #include <linux/poll.h>
66858 #include <asm/pgalloc.h>
66859 +#include <asm/local.h>
66860 #include <drm/drm.h>
66861 #include <drm/drm_sarea.h>
66862
66863 @@ -293,10 +294,12 @@ do { \
66864 * \param cmd command.
66865 * \param arg argument.
66866 */
66867 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
66868 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
66869 + struct drm_file *file_priv);
66870 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
66871 struct drm_file *file_priv);
66872
66873 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
66874 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
66875 unsigned long arg);
66876
66877 #define DRM_IOCTL_NR(n) _IOC_NR(n)
66878 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
66879 struct drm_ioctl_desc {
66880 unsigned int cmd;
66881 int flags;
66882 - drm_ioctl_t *func;
66883 + drm_ioctl_t func;
66884 unsigned int cmd_drv;
66885 -};
66886 +} __do_const;
66887
66888 /**
66889 * Creates a driver or general drm_ioctl_desc array entry for the given
66890 @@ -995,7 +998,7 @@ struct drm_info_list {
66891 int (*show)(struct seq_file*, void*); /** show callback */
66892 u32 driver_features; /**< Required driver features for this entry */
66893 void *data;
66894 -};
66895 +} __do_const;
66896
66897 /**
66898 * debugfs node structure. This structure represents a debugfs file.
66899 @@ -1068,7 +1071,7 @@ struct drm_device {
66900
66901 /** \name Usage Counters */
66902 /*@{ */
66903 - int open_count; /**< Outstanding files open */
66904 + local_t open_count; /**< Outstanding files open */
66905 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
66906 atomic_t vma_count; /**< Outstanding vma areas open */
66907 int buf_use; /**< Buffers in use -- cannot alloc */
66908 @@ -1079,7 +1082,7 @@ struct drm_device {
66909 /*@{ */
66910 unsigned long counters;
66911 enum drm_stat_type types[15];
66912 - atomic_t counts[15];
66913 + atomic_unchecked_t counts[15];
66914 /*@} */
66915
66916 struct list_head filelist;
66917 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
66918 index f43d556..94d9343 100644
66919 --- a/include/drm/drm_crtc_helper.h
66920 +++ b/include/drm/drm_crtc_helper.h
66921 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
66922 struct drm_connector *connector);
66923 /* disable encoder when not in use - more explicit than dpms off */
66924 void (*disable)(struct drm_encoder *encoder);
66925 -};
66926 +} __no_const;
66927
66928 /**
66929 * drm_connector_helper_funcs - helper operations for connectors
66930 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
66931 index 72dcbe8..8db58d7 100644
66932 --- a/include/drm/ttm/ttm_memory.h
66933 +++ b/include/drm/ttm/ttm_memory.h
66934 @@ -48,7 +48,7 @@
66935
66936 struct ttm_mem_shrink {
66937 int (*do_shrink) (struct ttm_mem_shrink *);
66938 -};
66939 +} __no_const;
66940
66941 /**
66942 * struct ttm_mem_global - Global memory accounting structure.
66943 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
66944 index 4b840e8..155d235 100644
66945 --- a/include/keys/asymmetric-subtype.h
66946 +++ b/include/keys/asymmetric-subtype.h
66947 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
66948 /* Verify the signature on a key of this subtype (optional) */
66949 int (*verify_signature)(const struct key *key,
66950 const struct public_key_signature *sig);
66951 -};
66952 +} __do_const;
66953
66954 /**
66955 * asymmetric_key_subtype - Get the subtype from an asymmetric key
66956 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
66957 index c1da539..1dcec55 100644
66958 --- a/include/linux/atmdev.h
66959 +++ b/include/linux/atmdev.h
66960 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
66961 #endif
66962
66963 struct k_atm_aal_stats {
66964 -#define __HANDLE_ITEM(i) atomic_t i
66965 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
66966 __AAL_STAT_ITEMS
66967 #undef __HANDLE_ITEM
66968 };
66969 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
66970 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
66971 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
66972 struct module *owner;
66973 -};
66974 +} __do_const ;
66975
66976 struct atmphy_ops {
66977 int (*start)(struct atm_dev *dev);
66978 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
66979 index 0530b98..96a8ac0 100644
66980 --- a/include/linux/binfmts.h
66981 +++ b/include/linux/binfmts.h
66982 @@ -73,8 +73,9 @@ struct linux_binfmt {
66983 int (*load_binary)(struct linux_binprm *);
66984 int (*load_shlib)(struct file *);
66985 int (*core_dump)(struct coredump_params *cprm);
66986 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
66987 unsigned long min_coredump; /* minimal dump size */
66988 -};
66989 +} __do_const;
66990
66991 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
66992
66993 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
66994 index f94bc83..62b9cfe 100644
66995 --- a/include/linux/blkdev.h
66996 +++ b/include/linux/blkdev.h
66997 @@ -1498,7 +1498,7 @@ struct block_device_operations {
66998 /* this callback is with swap_lock and sometimes page table lock held */
66999 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67000 struct module *owner;
67001 -};
67002 +} __do_const;
67003
67004 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67005 unsigned long);
67006 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67007 index 7c2e030..b72475d 100644
67008 --- a/include/linux/blktrace_api.h
67009 +++ b/include/linux/blktrace_api.h
67010 @@ -23,7 +23,7 @@ struct blk_trace {
67011 struct dentry *dir;
67012 struct dentry *dropped_file;
67013 struct dentry *msg_file;
67014 - atomic_t dropped;
67015 + atomic_unchecked_t dropped;
67016 };
67017
67018 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67019 diff --git a/include/linux/cache.h b/include/linux/cache.h
67020 index 4c57065..4307975 100644
67021 --- a/include/linux/cache.h
67022 +++ b/include/linux/cache.h
67023 @@ -16,6 +16,10 @@
67024 #define __read_mostly
67025 #endif
67026
67027 +#ifndef __read_only
67028 +#define __read_only __read_mostly
67029 +#endif
67030 +
67031 #ifndef ____cacheline_aligned
67032 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67033 #endif
67034 diff --git a/include/linux/capability.h b/include/linux/capability.h
67035 index 98503b7..cc36d18 100644
67036 --- a/include/linux/capability.h
67037 +++ b/include/linux/capability.h
67038 @@ -211,8 +211,13 @@ extern bool capable(int cap);
67039 extern bool ns_capable(struct user_namespace *ns, int cap);
67040 extern bool nsown_capable(int cap);
67041 extern bool inode_capable(const struct inode *inode, int cap);
67042 +extern bool capable_nolog(int cap);
67043 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67044 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67045
67046 /* audit system wants to get cap info from files as well */
67047 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67048
67049 +extern int is_privileged_binary(const struct dentry *dentry);
67050 +
67051 #endif /* !_LINUX_CAPABILITY_H */
67052 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67053 index 8609d57..86e4d79 100644
67054 --- a/include/linux/cdrom.h
67055 +++ b/include/linux/cdrom.h
67056 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67057
67058 /* driver specifications */
67059 const int capability; /* capability flags */
67060 - int n_minors; /* number of active minor devices */
67061 /* handle uniform packets for scsi type devices (scsi,atapi) */
67062 int (*generic_packet) (struct cdrom_device_info *,
67063 struct packet_command *);
67064 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67065 index 42e55de..1cd0e66 100644
67066 --- a/include/linux/cleancache.h
67067 +++ b/include/linux/cleancache.h
67068 @@ -31,7 +31,7 @@ struct cleancache_ops {
67069 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67070 void (*invalidate_inode)(int, struct cleancache_filekey);
67071 void (*invalidate_fs)(int);
67072 -};
67073 +} __no_const;
67074
67075 extern struct cleancache_ops
67076 cleancache_register_ops(struct cleancache_ops *ops);
67077 diff --git a/include/linux/compat.h b/include/linux/compat.h
67078 index dec7e2d..45db13f 100644
67079 --- a/include/linux/compat.h
67080 +++ b/include/linux/compat.h
67081 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67082 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67083 int version, void __user *uptr);
67084 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67085 - void __user *uptr);
67086 + void __user *uptr) __intentional_overflow(0);
67087 #else
67088 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67089 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67090 compat_ssize_t msgsz, int msgflg);
67091 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67092 compat_ssize_t msgsz, long msgtyp, int msgflg);
67093 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67094 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67095 #endif
67096 long compat_sys_msgctl(int first, int second, void __user *uptr);
67097 long compat_sys_shmctl(int first, int second, void __user *uptr);
67098 @@ -414,7 +414,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67099 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67100 compat_ulong_t addr, compat_ulong_t data);
67101 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67102 - compat_long_t addr, compat_long_t data);
67103 + compat_ulong_t addr, compat_ulong_t data);
67104
67105 /*
67106 * epoll (fs/eventpoll.c) compat bits follow ...
67107 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67108 index 662fd1b..e801992 100644
67109 --- a/include/linux/compiler-gcc4.h
67110 +++ b/include/linux/compiler-gcc4.h
67111 @@ -34,6 +34,21 @@
67112 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
67113
67114 #if __GNUC_MINOR__ >= 5
67115 +
67116 +#ifdef CONSTIFY_PLUGIN
67117 +#define __no_const __attribute__((no_const))
67118 +#define __do_const __attribute__((do_const))
67119 +#endif
67120 +
67121 +#ifdef SIZE_OVERFLOW_PLUGIN
67122 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67123 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67124 +#endif
67125 +
67126 +#ifdef LATENT_ENTROPY_PLUGIN
67127 +#define __latent_entropy __attribute__((latent_entropy))
67128 +#endif
67129 +
67130 /*
67131 * Mark a position in code as unreachable. This can be used to
67132 * suppress control flow warnings after asm blocks that transfer
67133 @@ -49,6 +64,11 @@
67134 #define __noclone __attribute__((__noclone__))
67135
67136 #endif
67137 +
67138 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67139 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67140 +#define __bos0(ptr) __bos((ptr), 0)
67141 +#define __bos1(ptr) __bos((ptr), 1)
67142 #endif
67143
67144 #if __GNUC_MINOR__ >= 6
67145 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67146 index dd852b7..1ad5fba 100644
67147 --- a/include/linux/compiler.h
67148 +++ b/include/linux/compiler.h
67149 @@ -5,11 +5,14 @@
67150
67151 #ifdef __CHECKER__
67152 # define __user __attribute__((noderef, address_space(1)))
67153 +# define __force_user __force __user
67154 # define __kernel __attribute__((address_space(0)))
67155 +# define __force_kernel __force __kernel
67156 # define __safe __attribute__((safe))
67157 # define __force __attribute__((force))
67158 # define __nocast __attribute__((nocast))
67159 # define __iomem __attribute__((noderef, address_space(2)))
67160 +# define __force_iomem __force __iomem
67161 # define __must_hold(x) __attribute__((context(x,1,1)))
67162 # define __acquires(x) __attribute__((context(x,0,1)))
67163 # define __releases(x) __attribute__((context(x,1,0)))
67164 @@ -17,20 +20,37 @@
67165 # define __release(x) __context__(x,-1)
67166 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67167 # define __percpu __attribute__((noderef, address_space(3)))
67168 +# define __force_percpu __force __percpu
67169 #ifdef CONFIG_SPARSE_RCU_POINTER
67170 # define __rcu __attribute__((noderef, address_space(4)))
67171 +# define __force_rcu __force __rcu
67172 #else
67173 # define __rcu
67174 +# define __force_rcu
67175 #endif
67176 extern void __chk_user_ptr(const volatile void __user *);
67177 extern void __chk_io_ptr(const volatile void __iomem *);
67178 #else
67179 -# define __user
67180 -# define __kernel
67181 +# ifdef CHECKER_PLUGIN
67182 +//# define __user
67183 +//# define __force_user
67184 +//# define __kernel
67185 +//# define __force_kernel
67186 +# else
67187 +# ifdef STRUCTLEAK_PLUGIN
67188 +# define __user __attribute__((user))
67189 +# else
67190 +# define __user
67191 +# endif
67192 +# define __force_user
67193 +# define __kernel
67194 +# define __force_kernel
67195 +# endif
67196 # define __safe
67197 # define __force
67198 # define __nocast
67199 # define __iomem
67200 +# define __force_iomem
67201 # define __chk_user_ptr(x) (void)0
67202 # define __chk_io_ptr(x) (void)0
67203 # define __builtin_warning(x, y...) (1)
67204 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67205 # define __release(x) (void)0
67206 # define __cond_lock(x,c) (c)
67207 # define __percpu
67208 +# define __force_percpu
67209 # define __rcu
67210 +# define __force_rcu
67211 #endif
67212
67213 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67214 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67215 # define __attribute_const__ /* unimplemented */
67216 #endif
67217
67218 +#ifndef __no_const
67219 +# define __no_const
67220 +#endif
67221 +
67222 +#ifndef __do_const
67223 +# define __do_const
67224 +#endif
67225 +
67226 +#ifndef __size_overflow
67227 +# define __size_overflow(...)
67228 +#endif
67229 +
67230 +#ifndef __intentional_overflow
67231 +# define __intentional_overflow(...)
67232 +#endif
67233 +
67234 +#ifndef __latent_entropy
67235 +# define __latent_entropy
67236 +#endif
67237 +
67238 /*
67239 * Tell gcc if a function is cold. The compiler will assume any path
67240 * directly leading to the call is unlikely.
67241 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67242 #define __cold
67243 #endif
67244
67245 +#ifndef __alloc_size
67246 +#define __alloc_size(...)
67247 +#endif
67248 +
67249 +#ifndef __bos
67250 +#define __bos(ptr, arg)
67251 +#endif
67252 +
67253 +#ifndef __bos0
67254 +#define __bos0(ptr)
67255 +#endif
67256 +
67257 +#ifndef __bos1
67258 +#define __bos1(ptr)
67259 +#endif
67260 +
67261 /* Simple shorthand for a section definition */
67262 #ifndef __section
67263 # define __section(S) __attribute__ ((__section__(#S)))
67264 @@ -323,6 +381,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67265 * use is to mediate communication between process-level code and irq/NMI
67266 * handlers, all running on the same CPU.
67267 */
67268 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67269 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67270 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67271
67272 #endif /* __LINUX_COMPILER_H */
67273 diff --git a/include/linux/completion.h b/include/linux/completion.h
67274 index 51494e6..0fd1b61 100644
67275 --- a/include/linux/completion.h
67276 +++ b/include/linux/completion.h
67277 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
67278
67279 extern void wait_for_completion(struct completion *);
67280 extern int wait_for_completion_interruptible(struct completion *x);
67281 -extern int wait_for_completion_killable(struct completion *x);
67282 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
67283 extern unsigned long wait_for_completion_timeout(struct completion *x,
67284 unsigned long timeout);
67285 extern long wait_for_completion_interruptible_timeout(
67286 - struct completion *x, unsigned long timeout);
67287 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67288 extern long wait_for_completion_killable_timeout(
67289 - struct completion *x, unsigned long timeout);
67290 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67291 extern bool try_wait_for_completion(struct completion *x);
67292 extern bool completion_done(struct completion *x);
67293
67294 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
67295 index 34025df..d94bbbc 100644
67296 --- a/include/linux/configfs.h
67297 +++ b/include/linux/configfs.h
67298 @@ -125,7 +125,7 @@ struct configfs_attribute {
67299 const char *ca_name;
67300 struct module *ca_owner;
67301 umode_t ca_mode;
67302 -};
67303 +} __do_const;
67304
67305 /*
67306 * Users often need to create attribute structures for their configurable
67307 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
67308 index ce7a074..01ab8ac 100644
67309 --- a/include/linux/cpu.h
67310 +++ b/include/linux/cpu.h
67311 @@ -115,7 +115,7 @@ enum {
67312 /* Need to know about CPUs going up/down? */
67313 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
67314 #define cpu_notifier(fn, pri) { \
67315 - static struct notifier_block fn##_nb __cpuinitdata = \
67316 + static struct notifier_block fn##_nb = \
67317 { .notifier_call = fn, .priority = pri }; \
67318 register_cpu_notifier(&fn##_nb); \
67319 }
67320 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
67321 index a55b88e..fba90c5 100644
67322 --- a/include/linux/cpufreq.h
67323 +++ b/include/linux/cpufreq.h
67324 @@ -240,7 +240,7 @@ struct cpufreq_driver {
67325 int (*suspend) (struct cpufreq_policy *policy);
67326 int (*resume) (struct cpufreq_policy *policy);
67327 struct freq_attr **attr;
67328 -};
67329 +} __do_const;
67330
67331 /* flags */
67332
67333 @@ -299,6 +299,7 @@ struct global_attr {
67334 ssize_t (*store)(struct kobject *a, struct attribute *b,
67335 const char *c, size_t count);
67336 };
67337 +typedef struct global_attr __no_const global_attr_no_const;
67338
67339 #define define_one_global_ro(_name) \
67340 static struct global_attr _name = \
67341 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
67342 index 24cd1037..20a63aae 100644
67343 --- a/include/linux/cpuidle.h
67344 +++ b/include/linux/cpuidle.h
67345 @@ -54,7 +54,8 @@ struct cpuidle_state {
67346 int index);
67347
67348 int (*enter_dead) (struct cpuidle_device *dev, int index);
67349 -};
67350 +} __do_const;
67351 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
67352
67353 /* Idle State Flags */
67354 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
67355 @@ -216,7 +217,7 @@ struct cpuidle_governor {
67356 void (*reflect) (struct cpuidle_device *dev, int index);
67357
67358 struct module *owner;
67359 -};
67360 +} __do_const;
67361
67362 #ifdef CONFIG_CPU_IDLE
67363
67364 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
67365 index 0325602..5e9feff 100644
67366 --- a/include/linux/cpumask.h
67367 +++ b/include/linux/cpumask.h
67368 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67369 }
67370
67371 /* Valid inputs for n are -1 and 0. */
67372 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67373 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67374 {
67375 return n+1;
67376 }
67377
67378 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67379 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67380 {
67381 return n+1;
67382 }
67383
67384 -static inline unsigned int cpumask_next_and(int n,
67385 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
67386 const struct cpumask *srcp,
67387 const struct cpumask *andp)
67388 {
67389 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67390 *
67391 * Returns >= nr_cpu_ids if no further cpus set.
67392 */
67393 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67394 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67395 {
67396 /* -1 is a legal arg here. */
67397 if (n != -1)
67398 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67399 *
67400 * Returns >= nr_cpu_ids if no further cpus unset.
67401 */
67402 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67403 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67404 {
67405 /* -1 is a legal arg here. */
67406 if (n != -1)
67407 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67408 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
67409 }
67410
67411 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
67412 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
67413 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
67414
67415 /**
67416 diff --git a/include/linux/cred.h b/include/linux/cred.h
67417 index 04421e8..6bce4ef 100644
67418 --- a/include/linux/cred.h
67419 +++ b/include/linux/cred.h
67420 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
67421 static inline void validate_process_creds(void)
67422 {
67423 }
67424 +static inline void validate_task_creds(struct task_struct *task)
67425 +{
67426 +}
67427 #endif
67428
67429 /**
67430 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
67431 index b92eadf..b4ecdc1 100644
67432 --- a/include/linux/crypto.h
67433 +++ b/include/linux/crypto.h
67434 @@ -373,7 +373,7 @@ struct cipher_tfm {
67435 const u8 *key, unsigned int keylen);
67436 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67437 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67438 -};
67439 +} __no_const;
67440
67441 struct hash_tfm {
67442 int (*init)(struct hash_desc *desc);
67443 @@ -394,13 +394,13 @@ struct compress_tfm {
67444 int (*cot_decompress)(struct crypto_tfm *tfm,
67445 const u8 *src, unsigned int slen,
67446 u8 *dst, unsigned int *dlen);
67447 -};
67448 +} __no_const;
67449
67450 struct rng_tfm {
67451 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
67452 unsigned int dlen);
67453 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
67454 -};
67455 +} __no_const;
67456
67457 #define crt_ablkcipher crt_u.ablkcipher
67458 #define crt_aead crt_u.aead
67459 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
67460 index 8acfe31..6ffccd63 100644
67461 --- a/include/linux/ctype.h
67462 +++ b/include/linux/ctype.h
67463 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
67464 * Fast implementation of tolower() for internal usage. Do not use in your
67465 * code.
67466 */
67467 -static inline char _tolower(const char c)
67468 +static inline unsigned char _tolower(const unsigned char c)
67469 {
67470 return c | 0x20;
67471 }
67472 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
67473 index 7925bf0..d5143d2 100644
67474 --- a/include/linux/decompress/mm.h
67475 +++ b/include/linux/decompress/mm.h
67476 @@ -77,7 +77,7 @@ static void free(void *where)
67477 * warnings when not needed (indeed large_malloc / large_free are not
67478 * needed by inflate */
67479
67480 -#define malloc(a) kmalloc(a, GFP_KERNEL)
67481 +#define malloc(a) kmalloc((a), GFP_KERNEL)
67482 #define free(a) kfree(a)
67483
67484 #define large_malloc(a) vmalloc(a)
67485 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
67486 index e83ef39..33e0eb3 100644
67487 --- a/include/linux/devfreq.h
67488 +++ b/include/linux/devfreq.h
67489 @@ -114,7 +114,7 @@ struct devfreq_governor {
67490 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
67491 int (*event_handler)(struct devfreq *devfreq,
67492 unsigned int event, void *data);
67493 -};
67494 +} __do_const;
67495
67496 /**
67497 * struct devfreq - Device devfreq structure
67498 diff --git a/include/linux/device.h b/include/linux/device.h
67499 index 43dcda9..7a1fb65 100644
67500 --- a/include/linux/device.h
67501 +++ b/include/linux/device.h
67502 @@ -294,7 +294,7 @@ struct subsys_interface {
67503 struct list_head node;
67504 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
67505 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
67506 -};
67507 +} __do_const;
67508
67509 int subsys_interface_register(struct subsys_interface *sif);
67510 void subsys_interface_unregister(struct subsys_interface *sif);
67511 @@ -474,7 +474,7 @@ struct device_type {
67512 void (*release)(struct device *dev);
67513
67514 const struct dev_pm_ops *pm;
67515 -};
67516 +} __do_const;
67517
67518 /* interface for exporting device attributes */
67519 struct device_attribute {
67520 @@ -484,11 +484,12 @@ struct device_attribute {
67521 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
67522 const char *buf, size_t count);
67523 };
67524 +typedef struct device_attribute __no_const device_attribute_no_const;
67525
67526 struct dev_ext_attribute {
67527 struct device_attribute attr;
67528 void *var;
67529 -};
67530 +} __do_const;
67531
67532 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
67533 char *buf);
67534 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
67535 index 94af418..b1ca7a2 100644
67536 --- a/include/linux/dma-mapping.h
67537 +++ b/include/linux/dma-mapping.h
67538 @@ -54,7 +54,7 @@ struct dma_map_ops {
67539 u64 (*get_required_mask)(struct device *dev);
67540 #endif
67541 int is_phys;
67542 -};
67543 +} __do_const;
67544
67545 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
67546
67547 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
67548 index d3201e4..8281e63 100644
67549 --- a/include/linux/dmaengine.h
67550 +++ b/include/linux/dmaengine.h
67551 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
67552 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
67553 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
67554
67555 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67556 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67557 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
67558 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67559 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67560 struct dma_pinned_list *pinned_list, struct page *page,
67561 unsigned int offset, size_t len);
67562
67563 diff --git a/include/linux/efi.h b/include/linux/efi.h
67564 index 7a9498a..155713d 100644
67565 --- a/include/linux/efi.h
67566 +++ b/include/linux/efi.h
67567 @@ -733,6 +733,7 @@ struct efivar_operations {
67568 efi_set_variable_t *set_variable;
67569 efi_query_variable_info_t *query_variable_info;
67570 };
67571 +typedef struct efivar_operations __no_const efivar_operations_no_const;
67572
67573 struct efivars {
67574 /*
67575 diff --git a/include/linux/elf.h b/include/linux/elf.h
67576 index 8c9048e..16a4665 100644
67577 --- a/include/linux/elf.h
67578 +++ b/include/linux/elf.h
67579 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
67580 #define elf_note elf32_note
67581 #define elf_addr_t Elf32_Off
67582 #define Elf_Half Elf32_Half
67583 +#define elf_dyn Elf32_Dyn
67584
67585 #else
67586
67587 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
67588 #define elf_note elf64_note
67589 #define elf_addr_t Elf64_Off
67590 #define Elf_Half Elf64_Half
67591 +#define elf_dyn Elf64_Dyn
67592
67593 #endif
67594
67595 diff --git a/include/linux/err.h b/include/linux/err.h
67596 index f2edce2..cc2082c 100644
67597 --- a/include/linux/err.h
67598 +++ b/include/linux/err.h
67599 @@ -19,12 +19,12 @@
67600
67601 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
67602
67603 -static inline void * __must_check ERR_PTR(long error)
67604 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
67605 {
67606 return (void *) error;
67607 }
67608
67609 -static inline long __must_check PTR_ERR(const void *ptr)
67610 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
67611 {
67612 return (long) ptr;
67613 }
67614 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
67615 index fcb51c8..bdafcf6 100644
67616 --- a/include/linux/extcon.h
67617 +++ b/include/linux/extcon.h
67618 @@ -134,7 +134,7 @@ struct extcon_dev {
67619 /* /sys/class/extcon/.../mutually_exclusive/... */
67620 struct attribute_group attr_g_muex;
67621 struct attribute **attrs_muex;
67622 - struct device_attribute *d_attrs_muex;
67623 + device_attribute_no_const *d_attrs_muex;
67624 };
67625
67626 /**
67627 diff --git a/include/linux/fb.h b/include/linux/fb.h
67628 index c7a9571..02eeffe 100644
67629 --- a/include/linux/fb.h
67630 +++ b/include/linux/fb.h
67631 @@ -302,7 +302,7 @@ struct fb_ops {
67632 /* called at KDB enter and leave time to prepare the console */
67633 int (*fb_debug_enter)(struct fb_info *info);
67634 int (*fb_debug_leave)(struct fb_info *info);
67635 -};
67636 +} __do_const;
67637
67638 #ifdef CONFIG_FB_TILEBLITTING
67639 #define FB_TILE_CURSOR_NONE 0
67640 diff --git a/include/linux/filter.h b/include/linux/filter.h
67641 index c45eabc..baa0be5 100644
67642 --- a/include/linux/filter.h
67643 +++ b/include/linux/filter.h
67644 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
67645
67646 struct sk_buff;
67647 struct sock;
67648 +struct bpf_jit_work;
67649
67650 struct sk_filter
67651 {
67652 @@ -27,6 +28,9 @@ struct sk_filter
67653 unsigned int len; /* Number of filter blocks */
67654 unsigned int (*bpf_func)(const struct sk_buff *skb,
67655 const struct sock_filter *filter);
67656 +#ifdef CONFIG_BPF_JIT
67657 + struct bpf_jit_work *work;
67658 +#endif
67659 struct rcu_head rcu;
67660 struct sock_filter insns[0];
67661 };
67662 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
67663 index 3044254..9767f41 100644
67664 --- a/include/linux/frontswap.h
67665 +++ b/include/linux/frontswap.h
67666 @@ -11,7 +11,7 @@ struct frontswap_ops {
67667 int (*load)(unsigned, pgoff_t, struct page *);
67668 void (*invalidate_page)(unsigned, pgoff_t);
67669 void (*invalidate_area)(unsigned);
67670 -};
67671 +} __no_const;
67672
67673 extern bool frontswap_enabled;
67674 extern struct frontswap_ops
67675 diff --git a/include/linux/fs.h b/include/linux/fs.h
67676 index 7617ee0..b575199 100644
67677 --- a/include/linux/fs.h
67678 +++ b/include/linux/fs.h
67679 @@ -1541,7 +1541,8 @@ struct file_operations {
67680 long (*fallocate)(struct file *file, int mode, loff_t offset,
67681 loff_t len);
67682 int (*show_fdinfo)(struct seq_file *m, struct file *f);
67683 -};
67684 +} __do_const;
67685 +typedef struct file_operations __no_const file_operations_no_const;
67686
67687 struct inode_operations {
67688 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
67689 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
67690 inode->i_flags |= S_NOSEC;
67691 }
67692
67693 +static inline bool is_sidechannel_device(const struct inode *inode)
67694 +{
67695 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
67696 + umode_t mode = inode->i_mode;
67697 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
67698 +#else
67699 + return false;
67700 +#endif
67701 +}
67702 +
67703 #endif /* _LINUX_FS_H */
67704 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
67705 index d0ae3a8..0244b34 100644
67706 --- a/include/linux/fs_struct.h
67707 +++ b/include/linux/fs_struct.h
67708 @@ -6,7 +6,7 @@
67709 #include <linux/seqlock.h>
67710
67711 struct fs_struct {
67712 - int users;
67713 + atomic_t users;
67714 spinlock_t lock;
67715 seqcount_t seq;
67716 int umask;
67717 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
67718 index 5dfa0aa..6acf322 100644
67719 --- a/include/linux/fscache-cache.h
67720 +++ b/include/linux/fscache-cache.h
67721 @@ -112,7 +112,7 @@ struct fscache_operation {
67722 fscache_operation_release_t release;
67723 };
67724
67725 -extern atomic_t fscache_op_debug_id;
67726 +extern atomic_unchecked_t fscache_op_debug_id;
67727 extern void fscache_op_work_func(struct work_struct *work);
67728
67729 extern void fscache_enqueue_operation(struct fscache_operation *);
67730 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
67731 INIT_WORK(&op->work, fscache_op_work_func);
67732 atomic_set(&op->usage, 1);
67733 op->state = FSCACHE_OP_ST_INITIALISED;
67734 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
67735 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
67736 op->processor = processor;
67737 op->release = release;
67738 INIT_LIST_HEAD(&op->pend_link);
67739 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
67740 index 7a08623..4c07b0f 100644
67741 --- a/include/linux/fscache.h
67742 +++ b/include/linux/fscache.h
67743 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
67744 * - this is mandatory for any object that may have data
67745 */
67746 void (*now_uncached)(void *cookie_netfs_data);
67747 -};
67748 +} __do_const;
67749
67750 /*
67751 * fscache cached network filesystem type
67752 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
67753 index 0fbfb46..508eb0d 100644
67754 --- a/include/linux/fsnotify.h
67755 +++ b/include/linux/fsnotify.h
67756 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
67757 struct inode *inode = path->dentry->d_inode;
67758 __u32 mask = FS_ACCESS;
67759
67760 + if (is_sidechannel_device(inode))
67761 + return;
67762 +
67763 if (S_ISDIR(inode->i_mode))
67764 mask |= FS_ISDIR;
67765
67766 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
67767 struct inode *inode = path->dentry->d_inode;
67768 __u32 mask = FS_MODIFY;
67769
67770 + if (is_sidechannel_device(inode))
67771 + return;
67772 +
67773 if (S_ISDIR(inode->i_mode))
67774 mask |= FS_ISDIR;
67775
67776 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
67777 */
67778 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
67779 {
67780 - return kstrdup(name, GFP_KERNEL);
67781 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
67782 }
67783
67784 /*
67785 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
67786 index a3d4895..ddd2a50 100644
67787 --- a/include/linux/ftrace_event.h
67788 +++ b/include/linux/ftrace_event.h
67789 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
67790 extern int trace_add_event_call(struct ftrace_event_call *call);
67791 extern void trace_remove_event_call(struct ftrace_event_call *call);
67792
67793 -#define is_signed_type(type) (((type)(-1)) < 0)
67794 +#define is_signed_type(type) (((type)(-1)) < (type)1)
67795
67796 int trace_set_clr_event(const char *system, const char *event, int set);
67797
67798 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
67799 index 79b8bba..86b539e 100644
67800 --- a/include/linux/genhd.h
67801 +++ b/include/linux/genhd.h
67802 @@ -194,7 +194,7 @@ struct gendisk {
67803 struct kobject *slave_dir;
67804
67805 struct timer_rand_state *random;
67806 - atomic_t sync_io; /* RAID */
67807 + atomic_unchecked_t sync_io; /* RAID */
67808 struct disk_events *ev;
67809 #ifdef CONFIG_BLK_DEV_INTEGRITY
67810 struct blk_integrity *integrity;
67811 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
67812 index 023bc34..b02b46a 100644
67813 --- a/include/linux/genl_magic_func.h
67814 +++ b/include/linux/genl_magic_func.h
67815 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
67816 },
67817
67818 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
67819 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
67820 +static struct genl_ops ZZZ_genl_ops[] = {
67821 #include GENL_MAGIC_INCLUDE_FILE
67822 };
67823
67824 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
67825 index 0f615eb..5c3832f 100644
67826 --- a/include/linux/gfp.h
67827 +++ b/include/linux/gfp.h
67828 @@ -35,6 +35,13 @@ struct vm_area_struct;
67829 #define ___GFP_NO_KSWAPD 0x400000u
67830 #define ___GFP_OTHER_NODE 0x800000u
67831 #define ___GFP_WRITE 0x1000000u
67832 +
67833 +#ifdef CONFIG_PAX_USERCOPY_SLABS
67834 +#define ___GFP_USERCOPY 0x2000000u
67835 +#else
67836 +#define ___GFP_USERCOPY 0
67837 +#endif
67838 +
67839 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
67840
67841 /*
67842 @@ -92,6 +99,7 @@ struct vm_area_struct;
67843 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
67844 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
67845 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
67846 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
67847
67848 /*
67849 * This may seem redundant, but it's a way of annotating false positives vs.
67850 @@ -99,7 +107,7 @@ struct vm_area_struct;
67851 */
67852 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
67853
67854 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
67855 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
67856 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
67857
67858 /* This equals 0, but use constants in case they ever change */
67859 @@ -153,6 +161,8 @@ struct vm_area_struct;
67860 /* 4GB DMA on some platforms */
67861 #define GFP_DMA32 __GFP_DMA32
67862
67863 +#define GFP_USERCOPY __GFP_USERCOPY
67864 +
67865 /* Convert GFP flags to their corresponding migrate type */
67866 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
67867 {
67868 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
67869 new file mode 100644
67870 index 0000000..ebe6d72
67871 --- /dev/null
67872 +++ b/include/linux/gracl.h
67873 @@ -0,0 +1,319 @@
67874 +#ifndef GR_ACL_H
67875 +#define GR_ACL_H
67876 +
67877 +#include <linux/grdefs.h>
67878 +#include <linux/resource.h>
67879 +#include <linux/capability.h>
67880 +#include <linux/dcache.h>
67881 +#include <asm/resource.h>
67882 +
67883 +/* Major status information */
67884 +
67885 +#define GR_VERSION "grsecurity 2.9.1"
67886 +#define GRSECURITY_VERSION 0x2901
67887 +
67888 +enum {
67889 + GR_SHUTDOWN = 0,
67890 + GR_ENABLE = 1,
67891 + GR_SPROLE = 2,
67892 + GR_RELOAD = 3,
67893 + GR_SEGVMOD = 4,
67894 + GR_STATUS = 5,
67895 + GR_UNSPROLE = 6,
67896 + GR_PASSSET = 7,
67897 + GR_SPROLEPAM = 8,
67898 +};
67899 +
67900 +/* Password setup definitions
67901 + * kernel/grhash.c */
67902 +enum {
67903 + GR_PW_LEN = 128,
67904 + GR_SALT_LEN = 16,
67905 + GR_SHA_LEN = 32,
67906 +};
67907 +
67908 +enum {
67909 + GR_SPROLE_LEN = 64,
67910 +};
67911 +
67912 +enum {
67913 + GR_NO_GLOB = 0,
67914 + GR_REG_GLOB,
67915 + GR_CREATE_GLOB
67916 +};
67917 +
67918 +#define GR_NLIMITS 32
67919 +
67920 +/* Begin Data Structures */
67921 +
67922 +struct sprole_pw {
67923 + unsigned char *rolename;
67924 + unsigned char salt[GR_SALT_LEN];
67925 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
67926 +};
67927 +
67928 +struct name_entry {
67929 + __u32 key;
67930 + ino_t inode;
67931 + dev_t device;
67932 + char *name;
67933 + __u16 len;
67934 + __u8 deleted;
67935 + struct name_entry *prev;
67936 + struct name_entry *next;
67937 +};
67938 +
67939 +struct inodev_entry {
67940 + struct name_entry *nentry;
67941 + struct inodev_entry *prev;
67942 + struct inodev_entry *next;
67943 +};
67944 +
67945 +struct acl_role_db {
67946 + struct acl_role_label **r_hash;
67947 + __u32 r_size;
67948 +};
67949 +
67950 +struct inodev_db {
67951 + struct inodev_entry **i_hash;
67952 + __u32 i_size;
67953 +};
67954 +
67955 +struct name_db {
67956 + struct name_entry **n_hash;
67957 + __u32 n_size;
67958 +};
67959 +
67960 +struct crash_uid {
67961 + uid_t uid;
67962 + unsigned long expires;
67963 +};
67964 +
67965 +struct gr_hash_struct {
67966 + void **table;
67967 + void **nametable;
67968 + void *first;
67969 + __u32 table_size;
67970 + __u32 used_size;
67971 + int type;
67972 +};
67973 +
67974 +/* Userspace Grsecurity ACL data structures */
67975 +
67976 +struct acl_subject_label {
67977 + char *filename;
67978 + ino_t inode;
67979 + dev_t device;
67980 + __u32 mode;
67981 + kernel_cap_t cap_mask;
67982 + kernel_cap_t cap_lower;
67983 + kernel_cap_t cap_invert_audit;
67984 +
67985 + struct rlimit res[GR_NLIMITS];
67986 + __u32 resmask;
67987 +
67988 + __u8 user_trans_type;
67989 + __u8 group_trans_type;
67990 + uid_t *user_transitions;
67991 + gid_t *group_transitions;
67992 + __u16 user_trans_num;
67993 + __u16 group_trans_num;
67994 +
67995 + __u32 sock_families[2];
67996 + __u32 ip_proto[8];
67997 + __u32 ip_type;
67998 + struct acl_ip_label **ips;
67999 + __u32 ip_num;
68000 + __u32 inaddr_any_override;
68001 +
68002 + __u32 crashes;
68003 + unsigned long expires;
68004 +
68005 + struct acl_subject_label *parent_subject;
68006 + struct gr_hash_struct *hash;
68007 + struct acl_subject_label *prev;
68008 + struct acl_subject_label *next;
68009 +
68010 + struct acl_object_label **obj_hash;
68011 + __u32 obj_hash_size;
68012 + __u16 pax_flags;
68013 +};
68014 +
68015 +struct role_allowed_ip {
68016 + __u32 addr;
68017 + __u32 netmask;
68018 +
68019 + struct role_allowed_ip *prev;
68020 + struct role_allowed_ip *next;
68021 +};
68022 +
68023 +struct role_transition {
68024 + char *rolename;
68025 +
68026 + struct role_transition *prev;
68027 + struct role_transition *next;
68028 +};
68029 +
68030 +struct acl_role_label {
68031 + char *rolename;
68032 + uid_t uidgid;
68033 + __u16 roletype;
68034 +
68035 + __u16 auth_attempts;
68036 + unsigned long expires;
68037 +
68038 + struct acl_subject_label *root_label;
68039 + struct gr_hash_struct *hash;
68040 +
68041 + struct acl_role_label *prev;
68042 + struct acl_role_label *next;
68043 +
68044 + struct role_transition *transitions;
68045 + struct role_allowed_ip *allowed_ips;
68046 + uid_t *domain_children;
68047 + __u16 domain_child_num;
68048 +
68049 + umode_t umask;
68050 +
68051 + struct acl_subject_label **subj_hash;
68052 + __u32 subj_hash_size;
68053 +};
68054 +
68055 +struct user_acl_role_db {
68056 + struct acl_role_label **r_table;
68057 + __u32 num_pointers; /* Number of allocations to track */
68058 + __u32 num_roles; /* Number of roles */
68059 + __u32 num_domain_children; /* Number of domain children */
68060 + __u32 num_subjects; /* Number of subjects */
68061 + __u32 num_objects; /* Number of objects */
68062 +};
68063 +
68064 +struct acl_object_label {
68065 + char *filename;
68066 + ino_t inode;
68067 + dev_t device;
68068 + __u32 mode;
68069 +
68070 + struct acl_subject_label *nested;
68071 + struct acl_object_label *globbed;
68072 +
68073 + /* next two structures not used */
68074 +
68075 + struct acl_object_label *prev;
68076 + struct acl_object_label *next;
68077 +};
68078 +
68079 +struct acl_ip_label {
68080 + char *iface;
68081 + __u32 addr;
68082 + __u32 netmask;
68083 + __u16 low, high;
68084 + __u8 mode;
68085 + __u32 type;
68086 + __u32 proto[8];
68087 +
68088 + /* next two structures not used */
68089 +
68090 + struct acl_ip_label *prev;
68091 + struct acl_ip_label *next;
68092 +};
68093 +
68094 +struct gr_arg {
68095 + struct user_acl_role_db role_db;
68096 + unsigned char pw[GR_PW_LEN];
68097 + unsigned char salt[GR_SALT_LEN];
68098 + unsigned char sum[GR_SHA_LEN];
68099 + unsigned char sp_role[GR_SPROLE_LEN];
68100 + struct sprole_pw *sprole_pws;
68101 + dev_t segv_device;
68102 + ino_t segv_inode;
68103 + uid_t segv_uid;
68104 + __u16 num_sprole_pws;
68105 + __u16 mode;
68106 +};
68107 +
68108 +struct gr_arg_wrapper {
68109 + struct gr_arg *arg;
68110 + __u32 version;
68111 + __u32 size;
68112 +};
68113 +
68114 +struct subject_map {
68115 + struct acl_subject_label *user;
68116 + struct acl_subject_label *kernel;
68117 + struct subject_map *prev;
68118 + struct subject_map *next;
68119 +};
68120 +
68121 +struct acl_subj_map_db {
68122 + struct subject_map **s_hash;
68123 + __u32 s_size;
68124 +};
68125 +
68126 +/* End Data Structures Section */
68127 +
68128 +/* Hash functions generated by empirical testing by Brad Spengler
68129 + Makes good use of the low bits of the inode. Generally 0-1 times
68130 + in loop for successful match. 0-3 for unsuccessful match.
68131 + Shift/add algorithm with modulus of table size and an XOR*/
68132 +
68133 +static __inline__ unsigned int
68134 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68135 +{
68136 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68137 +}
68138 +
68139 + static __inline__ unsigned int
68140 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68141 +{
68142 + return ((const unsigned long)userp % sz);
68143 +}
68144 +
68145 +static __inline__ unsigned int
68146 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68147 +{
68148 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68149 +}
68150 +
68151 +static __inline__ unsigned int
68152 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68153 +{
68154 + return full_name_hash((const unsigned char *)name, len) % sz;
68155 +}
68156 +
68157 +#define FOR_EACH_ROLE_START(role) \
68158 + role = role_list; \
68159 + while (role) {
68160 +
68161 +#define FOR_EACH_ROLE_END(role) \
68162 + role = role->prev; \
68163 + }
68164 +
68165 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68166 + subj = NULL; \
68167 + iter = 0; \
68168 + while (iter < role->subj_hash_size) { \
68169 + if (subj == NULL) \
68170 + subj = role->subj_hash[iter]; \
68171 + if (subj == NULL) { \
68172 + iter++; \
68173 + continue; \
68174 + }
68175 +
68176 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68177 + subj = subj->next; \
68178 + if (subj == NULL) \
68179 + iter++; \
68180 + }
68181 +
68182 +
68183 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68184 + subj = role->hash->first; \
68185 + while (subj != NULL) {
68186 +
68187 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68188 + subj = subj->next; \
68189 + }
68190 +
68191 +#endif
68192 +
68193 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68194 new file mode 100644
68195 index 0000000..323ecf2
68196 --- /dev/null
68197 +++ b/include/linux/gralloc.h
68198 @@ -0,0 +1,9 @@
68199 +#ifndef __GRALLOC_H
68200 +#define __GRALLOC_H
68201 +
68202 +void acl_free_all(void);
68203 +int acl_alloc_stack_init(unsigned long size);
68204 +void *acl_alloc(unsigned long len);
68205 +void *acl_alloc_num(unsigned long num, unsigned long len);
68206 +
68207 +#endif
68208 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68209 new file mode 100644
68210 index 0000000..be66033
68211 --- /dev/null
68212 +++ b/include/linux/grdefs.h
68213 @@ -0,0 +1,140 @@
68214 +#ifndef GRDEFS_H
68215 +#define GRDEFS_H
68216 +
68217 +/* Begin grsecurity status declarations */
68218 +
68219 +enum {
68220 + GR_READY = 0x01,
68221 + GR_STATUS_INIT = 0x00 // disabled state
68222 +};
68223 +
68224 +/* Begin ACL declarations */
68225 +
68226 +/* Role flags */
68227 +
68228 +enum {
68229 + GR_ROLE_USER = 0x0001,
68230 + GR_ROLE_GROUP = 0x0002,
68231 + GR_ROLE_DEFAULT = 0x0004,
68232 + GR_ROLE_SPECIAL = 0x0008,
68233 + GR_ROLE_AUTH = 0x0010,
68234 + GR_ROLE_NOPW = 0x0020,
68235 + GR_ROLE_GOD = 0x0040,
68236 + GR_ROLE_LEARN = 0x0080,
68237 + GR_ROLE_TPE = 0x0100,
68238 + GR_ROLE_DOMAIN = 0x0200,
68239 + GR_ROLE_PAM = 0x0400,
68240 + GR_ROLE_PERSIST = 0x0800
68241 +};
68242 +
68243 +/* ACL Subject and Object mode flags */
68244 +enum {
68245 + GR_DELETED = 0x80000000
68246 +};
68247 +
68248 +/* ACL Object-only mode flags */
68249 +enum {
68250 + GR_READ = 0x00000001,
68251 + GR_APPEND = 0x00000002,
68252 + GR_WRITE = 0x00000004,
68253 + GR_EXEC = 0x00000008,
68254 + GR_FIND = 0x00000010,
68255 + GR_INHERIT = 0x00000020,
68256 + GR_SETID = 0x00000040,
68257 + GR_CREATE = 0x00000080,
68258 + GR_DELETE = 0x00000100,
68259 + GR_LINK = 0x00000200,
68260 + GR_AUDIT_READ = 0x00000400,
68261 + GR_AUDIT_APPEND = 0x00000800,
68262 + GR_AUDIT_WRITE = 0x00001000,
68263 + GR_AUDIT_EXEC = 0x00002000,
68264 + GR_AUDIT_FIND = 0x00004000,
68265 + GR_AUDIT_INHERIT= 0x00008000,
68266 + GR_AUDIT_SETID = 0x00010000,
68267 + GR_AUDIT_CREATE = 0x00020000,
68268 + GR_AUDIT_DELETE = 0x00040000,
68269 + GR_AUDIT_LINK = 0x00080000,
68270 + GR_PTRACERD = 0x00100000,
68271 + GR_NOPTRACE = 0x00200000,
68272 + GR_SUPPRESS = 0x00400000,
68273 + GR_NOLEARN = 0x00800000,
68274 + GR_INIT_TRANSFER= 0x01000000
68275 +};
68276 +
68277 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
68278 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
68279 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
68280 +
68281 +/* ACL subject-only mode flags */
68282 +enum {
68283 + GR_KILL = 0x00000001,
68284 + GR_VIEW = 0x00000002,
68285 + GR_PROTECTED = 0x00000004,
68286 + GR_LEARN = 0x00000008,
68287 + GR_OVERRIDE = 0x00000010,
68288 + /* just a placeholder, this mode is only used in userspace */
68289 + GR_DUMMY = 0x00000020,
68290 + GR_PROTSHM = 0x00000040,
68291 + GR_KILLPROC = 0x00000080,
68292 + GR_KILLIPPROC = 0x00000100,
68293 + /* just a placeholder, this mode is only used in userspace */
68294 + GR_NOTROJAN = 0x00000200,
68295 + GR_PROTPROCFD = 0x00000400,
68296 + GR_PROCACCT = 0x00000800,
68297 + GR_RELAXPTRACE = 0x00001000,
68298 + //GR_NESTED = 0x00002000,
68299 + GR_INHERITLEARN = 0x00004000,
68300 + GR_PROCFIND = 0x00008000,
68301 + GR_POVERRIDE = 0x00010000,
68302 + GR_KERNELAUTH = 0x00020000,
68303 + GR_ATSECURE = 0x00040000,
68304 + GR_SHMEXEC = 0x00080000
68305 +};
68306 +
68307 +enum {
68308 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
68309 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
68310 + GR_PAX_ENABLE_MPROTECT = 0x0004,
68311 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
68312 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
68313 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
68314 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
68315 + GR_PAX_DISABLE_MPROTECT = 0x0400,
68316 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
68317 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
68318 +};
68319 +
68320 +enum {
68321 + GR_ID_USER = 0x01,
68322 + GR_ID_GROUP = 0x02,
68323 +};
68324 +
68325 +enum {
68326 + GR_ID_ALLOW = 0x01,
68327 + GR_ID_DENY = 0x02,
68328 +};
68329 +
68330 +#define GR_CRASH_RES 31
68331 +#define GR_UIDTABLE_MAX 500
68332 +
68333 +/* begin resource learning section */
68334 +enum {
68335 + GR_RLIM_CPU_BUMP = 60,
68336 + GR_RLIM_FSIZE_BUMP = 50000,
68337 + GR_RLIM_DATA_BUMP = 10000,
68338 + GR_RLIM_STACK_BUMP = 1000,
68339 + GR_RLIM_CORE_BUMP = 10000,
68340 + GR_RLIM_RSS_BUMP = 500000,
68341 + GR_RLIM_NPROC_BUMP = 1,
68342 + GR_RLIM_NOFILE_BUMP = 5,
68343 + GR_RLIM_MEMLOCK_BUMP = 50000,
68344 + GR_RLIM_AS_BUMP = 500000,
68345 + GR_RLIM_LOCKS_BUMP = 2,
68346 + GR_RLIM_SIGPENDING_BUMP = 5,
68347 + GR_RLIM_MSGQUEUE_BUMP = 10000,
68348 + GR_RLIM_NICE_BUMP = 1,
68349 + GR_RLIM_RTPRIO_BUMP = 1,
68350 + GR_RLIM_RTTIME_BUMP = 1000000
68351 +};
68352 +
68353 +#endif
68354 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
68355 new file mode 100644
68356 index 0000000..9bb6662
68357 --- /dev/null
68358 +++ b/include/linux/grinternal.h
68359 @@ -0,0 +1,215 @@
68360 +#ifndef __GRINTERNAL_H
68361 +#define __GRINTERNAL_H
68362 +
68363 +#ifdef CONFIG_GRKERNSEC
68364 +
68365 +#include <linux/fs.h>
68366 +#include <linux/mnt_namespace.h>
68367 +#include <linux/nsproxy.h>
68368 +#include <linux/gracl.h>
68369 +#include <linux/grdefs.h>
68370 +#include <linux/grmsg.h>
68371 +
68372 +void gr_add_learn_entry(const char *fmt, ...)
68373 + __attribute__ ((format (printf, 1, 2)));
68374 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
68375 + const struct vfsmount *mnt);
68376 +__u32 gr_check_create(const struct dentry *new_dentry,
68377 + const struct dentry *parent,
68378 + const struct vfsmount *mnt, const __u32 mode);
68379 +int gr_check_protected_task(const struct task_struct *task);
68380 +__u32 to_gr_audit(const __u32 reqmode);
68381 +int gr_set_acls(const int type);
68382 +int gr_apply_subject_to_task(struct task_struct *task);
68383 +int gr_acl_is_enabled(void);
68384 +char gr_roletype_to_char(void);
68385 +
68386 +void gr_handle_alertkill(struct task_struct *task);
68387 +char *gr_to_filename(const struct dentry *dentry,
68388 + const struct vfsmount *mnt);
68389 +char *gr_to_filename1(const struct dentry *dentry,
68390 + const struct vfsmount *mnt);
68391 +char *gr_to_filename2(const struct dentry *dentry,
68392 + const struct vfsmount *mnt);
68393 +char *gr_to_filename3(const struct dentry *dentry,
68394 + const struct vfsmount *mnt);
68395 +
68396 +extern int grsec_enable_ptrace_readexec;
68397 +extern int grsec_enable_harden_ptrace;
68398 +extern int grsec_enable_link;
68399 +extern int grsec_enable_fifo;
68400 +extern int grsec_enable_execve;
68401 +extern int grsec_enable_shm;
68402 +extern int grsec_enable_execlog;
68403 +extern int grsec_enable_signal;
68404 +extern int grsec_enable_audit_ptrace;
68405 +extern int grsec_enable_forkfail;
68406 +extern int grsec_enable_time;
68407 +extern int grsec_enable_rofs;
68408 +extern int grsec_enable_chroot_shmat;
68409 +extern int grsec_enable_chroot_mount;
68410 +extern int grsec_enable_chroot_double;
68411 +extern int grsec_enable_chroot_pivot;
68412 +extern int grsec_enable_chroot_chdir;
68413 +extern int grsec_enable_chroot_chmod;
68414 +extern int grsec_enable_chroot_mknod;
68415 +extern int grsec_enable_chroot_fchdir;
68416 +extern int grsec_enable_chroot_nice;
68417 +extern int grsec_enable_chroot_execlog;
68418 +extern int grsec_enable_chroot_caps;
68419 +extern int grsec_enable_chroot_sysctl;
68420 +extern int grsec_enable_chroot_unix;
68421 +extern int grsec_enable_symlinkown;
68422 +extern kgid_t grsec_symlinkown_gid;
68423 +extern int grsec_enable_tpe;
68424 +extern kgid_t grsec_tpe_gid;
68425 +extern int grsec_enable_tpe_all;
68426 +extern int grsec_enable_tpe_invert;
68427 +extern int grsec_enable_socket_all;
68428 +extern kgid_t grsec_socket_all_gid;
68429 +extern int grsec_enable_socket_client;
68430 +extern kgid_t grsec_socket_client_gid;
68431 +extern int grsec_enable_socket_server;
68432 +extern kgid_t grsec_socket_server_gid;
68433 +extern kgid_t grsec_audit_gid;
68434 +extern int grsec_enable_group;
68435 +extern int grsec_enable_audit_textrel;
68436 +extern int grsec_enable_log_rwxmaps;
68437 +extern int grsec_enable_mount;
68438 +extern int grsec_enable_chdir;
68439 +extern int grsec_resource_logging;
68440 +extern int grsec_enable_blackhole;
68441 +extern int grsec_lastack_retries;
68442 +extern int grsec_enable_brute;
68443 +extern int grsec_lock;
68444 +
68445 +extern spinlock_t grsec_alert_lock;
68446 +extern unsigned long grsec_alert_wtime;
68447 +extern unsigned long grsec_alert_fyet;
68448 +
68449 +extern spinlock_t grsec_audit_lock;
68450 +
68451 +extern rwlock_t grsec_exec_file_lock;
68452 +
68453 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
68454 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
68455 + (tsk)->exec_file->f_vfsmnt) : "/")
68456 +
68457 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
68458 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
68459 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
68460 +
68461 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
68462 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
68463 + (tsk)->exec_file->f_vfsmnt) : "/")
68464 +
68465 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
68466 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
68467 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
68468 +
68469 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
68470 +
68471 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
68472 +
68473 +#define GR_CHROOT_CAPS {{ \
68474 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
68475 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
68476 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
68477 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
68478 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
68479 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
68480 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
68481 +
68482 +#define security_learn(normal_msg,args...) \
68483 +({ \
68484 + read_lock(&grsec_exec_file_lock); \
68485 + gr_add_learn_entry(normal_msg "\n", ## args); \
68486 + read_unlock(&grsec_exec_file_lock); \
68487 +})
68488 +
68489 +enum {
68490 + GR_DO_AUDIT,
68491 + GR_DONT_AUDIT,
68492 + /* used for non-audit messages that we shouldn't kill the task on */
68493 + GR_DONT_AUDIT_GOOD
68494 +};
68495 +
68496 +enum {
68497 + GR_TTYSNIFF,
68498 + GR_RBAC,
68499 + GR_RBAC_STR,
68500 + GR_STR_RBAC,
68501 + GR_RBAC_MODE2,
68502 + GR_RBAC_MODE3,
68503 + GR_FILENAME,
68504 + GR_SYSCTL_HIDDEN,
68505 + GR_NOARGS,
68506 + GR_ONE_INT,
68507 + GR_ONE_INT_TWO_STR,
68508 + GR_ONE_STR,
68509 + GR_STR_INT,
68510 + GR_TWO_STR_INT,
68511 + GR_TWO_INT,
68512 + GR_TWO_U64,
68513 + GR_THREE_INT,
68514 + GR_FIVE_INT_TWO_STR,
68515 + GR_TWO_STR,
68516 + GR_THREE_STR,
68517 + GR_FOUR_STR,
68518 + GR_STR_FILENAME,
68519 + GR_FILENAME_STR,
68520 + GR_FILENAME_TWO_INT,
68521 + GR_FILENAME_TWO_INT_STR,
68522 + GR_TEXTREL,
68523 + GR_PTRACE,
68524 + GR_RESOURCE,
68525 + GR_CAP,
68526 + GR_SIG,
68527 + GR_SIG2,
68528 + GR_CRASH1,
68529 + GR_CRASH2,
68530 + GR_PSACCT,
68531 + GR_RWXMAP
68532 +};
68533 +
68534 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
68535 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
68536 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
68537 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
68538 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
68539 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
68540 +#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)
68541 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
68542 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
68543 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
68544 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
68545 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
68546 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
68547 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
68548 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
68549 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
68550 +#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)
68551 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
68552 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
68553 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
68554 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
68555 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
68556 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
68557 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
68558 +#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)
68559 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
68560 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
68561 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
68562 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
68563 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
68564 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
68565 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
68566 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
68567 +#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)
68568 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
68569 +
68570 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
68571 +
68572 +#endif
68573 +
68574 +#endif
68575 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
68576 new file mode 100644
68577 index 0000000..2bd4c8d
68578 --- /dev/null
68579 +++ b/include/linux/grmsg.h
68580 @@ -0,0 +1,111 @@
68581 +#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"
68582 +#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"
68583 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
68584 +#define GR_STOPMOD_MSG "denied modification of module state by "
68585 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
68586 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
68587 +#define GR_IOPERM_MSG "denied use of ioperm() by "
68588 +#define GR_IOPL_MSG "denied use of iopl() by "
68589 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
68590 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
68591 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
68592 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
68593 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
68594 +#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"
68595 +#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"
68596 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
68597 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
68598 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
68599 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
68600 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
68601 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
68602 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
68603 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
68604 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
68605 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
68606 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
68607 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
68608 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
68609 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
68610 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
68611 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
68612 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
68613 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
68614 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
68615 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
68616 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
68617 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
68618 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
68619 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
68620 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
68621 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
68622 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
68623 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
68624 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
68625 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
68626 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
68627 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
68628 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
68629 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
68630 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
68631 +#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"
68632 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
68633 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
68634 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
68635 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
68636 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
68637 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
68638 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
68639 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
68640 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
68641 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
68642 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
68643 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
68644 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
68645 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
68646 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
68647 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
68648 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
68649 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
68650 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
68651 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
68652 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
68653 +#define GR_NICE_CHROOT_MSG "denied priority change by "
68654 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
68655 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
68656 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
68657 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
68658 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
68659 +#define GR_TIME_MSG "time set by "
68660 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
68661 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
68662 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
68663 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
68664 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
68665 +#define GR_BIND_MSG "denied bind() by "
68666 +#define GR_CONNECT_MSG "denied connect() by "
68667 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
68668 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
68669 +#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"
68670 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
68671 +#define GR_CAP_ACL_MSG "use of %s denied for "
68672 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
68673 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
68674 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
68675 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
68676 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
68677 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
68678 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
68679 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
68680 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
68681 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
68682 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
68683 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
68684 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
68685 +#define GR_VM86_MSG "denied use of vm86 by "
68686 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
68687 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
68688 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
68689 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
68690 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
68691 +#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 "
68692 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
68693 new file mode 100644
68694 index 0000000..8da63a4
68695 --- /dev/null
68696 +++ b/include/linux/grsecurity.h
68697 @@ -0,0 +1,242 @@
68698 +#ifndef GR_SECURITY_H
68699 +#define GR_SECURITY_H
68700 +#include <linux/fs.h>
68701 +#include <linux/fs_struct.h>
68702 +#include <linux/binfmts.h>
68703 +#include <linux/gracl.h>
68704 +
68705 +/* notify of brain-dead configs */
68706 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
68707 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
68708 +#endif
68709 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
68710 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
68711 +#endif
68712 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
68713 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
68714 +#endif
68715 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
68716 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
68717 +#endif
68718 +
68719 +void gr_handle_brute_attach(unsigned long mm_flags);
68720 +void gr_handle_brute_check(void);
68721 +void gr_handle_kernel_exploit(void);
68722 +int gr_process_user_ban(void);
68723 +
68724 +char gr_roletype_to_char(void);
68725 +
68726 +int gr_acl_enable_at_secure(void);
68727 +
68728 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
68729 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
68730 +
68731 +void gr_del_task_from_ip_table(struct task_struct *p);
68732 +
68733 +int gr_pid_is_chrooted(struct task_struct *p);
68734 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
68735 +int gr_handle_chroot_nice(void);
68736 +int gr_handle_chroot_sysctl(const int op);
68737 +int gr_handle_chroot_setpriority(struct task_struct *p,
68738 + const int niceval);
68739 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
68740 +int gr_handle_chroot_chroot(const struct dentry *dentry,
68741 + const struct vfsmount *mnt);
68742 +void gr_handle_chroot_chdir(struct path *path);
68743 +int gr_handle_chroot_chmod(const struct dentry *dentry,
68744 + const struct vfsmount *mnt, const int mode);
68745 +int gr_handle_chroot_mknod(const struct dentry *dentry,
68746 + const struct vfsmount *mnt, const int mode);
68747 +int gr_handle_chroot_mount(const struct dentry *dentry,
68748 + const struct vfsmount *mnt,
68749 + const char *dev_name);
68750 +int gr_handle_chroot_pivot(void);
68751 +int gr_handle_chroot_unix(const pid_t pid);
68752 +
68753 +int gr_handle_rawio(const struct inode *inode);
68754 +
68755 +void gr_handle_ioperm(void);
68756 +void gr_handle_iopl(void);
68757 +
68758 +umode_t gr_acl_umask(void);
68759 +
68760 +int gr_tpe_allow(const struct file *file);
68761 +
68762 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
68763 +void gr_clear_chroot_entries(struct task_struct *task);
68764 +
68765 +void gr_log_forkfail(const int retval);
68766 +void gr_log_timechange(void);
68767 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
68768 +void gr_log_chdir(const struct dentry *dentry,
68769 + const struct vfsmount *mnt);
68770 +void gr_log_chroot_exec(const struct dentry *dentry,
68771 + const struct vfsmount *mnt);
68772 +void gr_log_remount(const char *devname, const int retval);
68773 +void gr_log_unmount(const char *devname, const int retval);
68774 +void gr_log_mount(const char *from, const char *to, const int retval);
68775 +void gr_log_textrel(struct vm_area_struct *vma);
68776 +void gr_log_rwxmmap(struct file *file);
68777 +void gr_log_rwxmprotect(struct file *file);
68778 +
68779 +int gr_handle_follow_link(const struct inode *parent,
68780 + const struct inode *inode,
68781 + const struct dentry *dentry,
68782 + const struct vfsmount *mnt);
68783 +int gr_handle_fifo(const struct dentry *dentry,
68784 + const struct vfsmount *mnt,
68785 + const struct dentry *dir, const int flag,
68786 + const int acc_mode);
68787 +int gr_handle_hardlink(const struct dentry *dentry,
68788 + const struct vfsmount *mnt,
68789 + struct inode *inode,
68790 + const int mode, const struct filename *to);
68791 +
68792 +int gr_is_capable(const int cap);
68793 +int gr_is_capable_nolog(const int cap);
68794 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
68795 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
68796 +
68797 +void gr_copy_label(struct task_struct *tsk);
68798 +void gr_handle_crash(struct task_struct *task, const int sig);
68799 +int gr_handle_signal(const struct task_struct *p, const int sig);
68800 +int gr_check_crash_uid(const kuid_t uid);
68801 +int gr_check_protected_task(const struct task_struct *task);
68802 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
68803 +int gr_acl_handle_mmap(const struct file *file,
68804 + const unsigned long prot);
68805 +int gr_acl_handle_mprotect(const struct file *file,
68806 + const unsigned long prot);
68807 +int gr_check_hidden_task(const struct task_struct *tsk);
68808 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
68809 + const struct vfsmount *mnt);
68810 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
68811 + const struct vfsmount *mnt);
68812 +__u32 gr_acl_handle_access(const struct dentry *dentry,
68813 + const struct vfsmount *mnt, const int fmode);
68814 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
68815 + const struct vfsmount *mnt, umode_t *mode);
68816 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
68817 + const struct vfsmount *mnt);
68818 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
68819 + const struct vfsmount *mnt);
68820 +int gr_handle_ptrace(struct task_struct *task, const long request);
68821 +int gr_handle_proc_ptrace(struct task_struct *task);
68822 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
68823 + const struct vfsmount *mnt);
68824 +int gr_check_crash_exec(const struct file *filp);
68825 +int gr_acl_is_enabled(void);
68826 +void gr_set_kernel_label(struct task_struct *task);
68827 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
68828 + const kgid_t gid);
68829 +int gr_set_proc_label(const struct dentry *dentry,
68830 + const struct vfsmount *mnt,
68831 + const int unsafe_flags);
68832 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
68833 + const struct vfsmount *mnt);
68834 +__u32 gr_acl_handle_open(const struct dentry *dentry,
68835 + const struct vfsmount *mnt, int acc_mode);
68836 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
68837 + const struct dentry *p_dentry,
68838 + const struct vfsmount *p_mnt,
68839 + int open_flags, int acc_mode, const int imode);
68840 +void gr_handle_create(const struct dentry *dentry,
68841 + const struct vfsmount *mnt);
68842 +void gr_handle_proc_create(const struct dentry *dentry,
68843 + const struct inode *inode);
68844 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
68845 + const struct dentry *parent_dentry,
68846 + const struct vfsmount *parent_mnt,
68847 + const int mode);
68848 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
68849 + const struct dentry *parent_dentry,
68850 + const struct vfsmount *parent_mnt);
68851 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
68852 + const struct vfsmount *mnt);
68853 +void gr_handle_delete(const ino_t ino, const dev_t dev);
68854 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
68855 + const struct vfsmount *mnt);
68856 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
68857 + const struct dentry *parent_dentry,
68858 + const struct vfsmount *parent_mnt,
68859 + const struct filename *from);
68860 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
68861 + const struct dentry *parent_dentry,
68862 + const struct vfsmount *parent_mnt,
68863 + const struct dentry *old_dentry,
68864 + const struct vfsmount *old_mnt, const struct filename *to);
68865 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
68866 +int gr_acl_handle_rename(struct dentry *new_dentry,
68867 + struct dentry *parent_dentry,
68868 + const struct vfsmount *parent_mnt,
68869 + struct dentry *old_dentry,
68870 + struct inode *old_parent_inode,
68871 + struct vfsmount *old_mnt, const struct filename *newname);
68872 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68873 + struct dentry *old_dentry,
68874 + struct dentry *new_dentry,
68875 + struct vfsmount *mnt, const __u8 replace);
68876 +__u32 gr_check_link(const struct dentry *new_dentry,
68877 + const struct dentry *parent_dentry,
68878 + const struct vfsmount *parent_mnt,
68879 + const struct dentry *old_dentry,
68880 + const struct vfsmount *old_mnt);
68881 +int gr_acl_handle_filldir(const struct file *file, const char *name,
68882 + const unsigned int namelen, const ino_t ino);
68883 +
68884 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
68885 + const struct vfsmount *mnt);
68886 +void gr_acl_handle_exit(void);
68887 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
68888 +int gr_acl_handle_procpidmem(const struct task_struct *task);
68889 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
68890 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
68891 +void gr_audit_ptrace(struct task_struct *task);
68892 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
68893 +void gr_put_exec_file(struct task_struct *task);
68894 +
68895 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
68896 +
68897 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
68898 +extern void gr_learn_resource(const struct task_struct *task, const int res,
68899 + const unsigned long wanted, const int gt);
68900 +#else
68901 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
68902 + const unsigned long wanted, const int gt)
68903 +{
68904 +}
68905 +#endif
68906 +
68907 +#ifdef CONFIG_GRKERNSEC_RESLOG
68908 +extern void gr_log_resource(const struct task_struct *task, const int res,
68909 + const unsigned long wanted, const int gt);
68910 +#else
68911 +static inline void gr_log_resource(const struct task_struct *task, const int res,
68912 + const unsigned long wanted, const int gt)
68913 +{
68914 +}
68915 +#endif
68916 +
68917 +#ifdef CONFIG_GRKERNSEC
68918 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
68919 +void gr_handle_vm86(void);
68920 +void gr_handle_mem_readwrite(u64 from, u64 to);
68921 +
68922 +void gr_log_badprocpid(const char *entry);
68923 +
68924 +extern int grsec_enable_dmesg;
68925 +extern int grsec_disable_privio;
68926 +
68927 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
68928 +extern kgid_t grsec_proc_gid;
68929 +#endif
68930 +
68931 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68932 +extern int grsec_enable_chroot_findtask;
68933 +#endif
68934 +#ifdef CONFIG_GRKERNSEC_SETXID
68935 +extern int grsec_enable_setxid;
68936 +#endif
68937 +#endif
68938 +
68939 +#endif
68940 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
68941 new file mode 100644
68942 index 0000000..e7ffaaf
68943 --- /dev/null
68944 +++ b/include/linux/grsock.h
68945 @@ -0,0 +1,19 @@
68946 +#ifndef __GRSOCK_H
68947 +#define __GRSOCK_H
68948 +
68949 +extern void gr_attach_curr_ip(const struct sock *sk);
68950 +extern int gr_handle_sock_all(const int family, const int type,
68951 + const int protocol);
68952 +extern int gr_handle_sock_server(const struct sockaddr *sck);
68953 +extern int gr_handle_sock_server_other(const struct sock *sck);
68954 +extern int gr_handle_sock_client(const struct sockaddr *sck);
68955 +extern int gr_search_connect(struct socket * sock,
68956 + struct sockaddr_in * addr);
68957 +extern int gr_search_bind(struct socket * sock,
68958 + struct sockaddr_in * addr);
68959 +extern int gr_search_listen(struct socket * sock);
68960 +extern int gr_search_accept(struct socket * sock);
68961 +extern int gr_search_socket(const int domain, const int type,
68962 + const int protocol);
68963 +
68964 +#endif
68965 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
68966 index ef788b5..ac41b7b 100644
68967 --- a/include/linux/highmem.h
68968 +++ b/include/linux/highmem.h
68969 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
68970 kunmap_atomic(kaddr);
68971 }
68972
68973 +static inline void sanitize_highpage(struct page *page)
68974 +{
68975 + void *kaddr;
68976 + unsigned long flags;
68977 +
68978 + local_irq_save(flags);
68979 + kaddr = kmap_atomic(page);
68980 + clear_page(kaddr);
68981 + kunmap_atomic(kaddr);
68982 + local_irq_restore(flags);
68983 +}
68984 +
68985 static inline void zero_user_segments(struct page *page,
68986 unsigned start1, unsigned end1,
68987 unsigned start2, unsigned end2)
68988 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
68989 index 1c7b89a..7f52502 100644
68990 --- a/include/linux/hwmon-sysfs.h
68991 +++ b/include/linux/hwmon-sysfs.h
68992 @@ -25,7 +25,8 @@
68993 struct sensor_device_attribute{
68994 struct device_attribute dev_attr;
68995 int index;
68996 -};
68997 +} __do_const;
68998 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
68999 #define to_sensor_dev_attr(_dev_attr) \
69000 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69001
69002 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69003 struct device_attribute dev_attr;
69004 u8 index;
69005 u8 nr;
69006 -};
69007 +} __do_const;
69008 #define to_sensor_dev_attr_2(_dev_attr) \
69009 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69010
69011 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69012 index d0c4db7..61b3577 100644
69013 --- a/include/linux/i2c.h
69014 +++ b/include/linux/i2c.h
69015 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69016 /* To determine what the adapter supports */
69017 u32 (*functionality) (struct i2c_adapter *);
69018 };
69019 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69020
69021 /*
69022 * i2c_adapter is the structure used to identify a physical i2c bus along
69023 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69024 index d23c3c2..eb63c81 100644
69025 --- a/include/linux/i2o.h
69026 +++ b/include/linux/i2o.h
69027 @@ -565,7 +565,7 @@ struct i2o_controller {
69028 struct i2o_device *exec; /* Executive */
69029 #if BITS_PER_LONG == 64
69030 spinlock_t context_list_lock; /* lock for context_list */
69031 - atomic_t context_list_counter; /* needed for unique contexts */
69032 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69033 struct list_head context_list; /* list of context id's
69034 and pointers */
69035 #endif
69036 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69037 index aff7ad8..3942bbd 100644
69038 --- a/include/linux/if_pppox.h
69039 +++ b/include/linux/if_pppox.h
69040 @@ -76,7 +76,7 @@ struct pppox_proto {
69041 int (*ioctl)(struct socket *sock, unsigned int cmd,
69042 unsigned long arg);
69043 struct module *owner;
69044 -};
69045 +} __do_const;
69046
69047 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69048 extern void unregister_pppox_proto(int proto_num);
69049 diff --git a/include/linux/init.h b/include/linux/init.h
69050 index 10ed4f4..8e8490d 100644
69051 --- a/include/linux/init.h
69052 +++ b/include/linux/init.h
69053 @@ -39,9 +39,36 @@
69054 * Also note, that this data cannot be "const".
69055 */
69056
69057 +#ifdef MODULE
69058 +#define add_init_latent_entropy
69059 +#define add_devinit_latent_entropy
69060 +#define add_cpuinit_latent_entropy
69061 +#define add_meminit_latent_entropy
69062 +#else
69063 +#define add_init_latent_entropy __latent_entropy
69064 +
69065 +#ifdef CONFIG_HOTPLUG
69066 +#define add_devinit_latent_entropy
69067 +#else
69068 +#define add_devinit_latent_entropy __latent_entropy
69069 +#endif
69070 +
69071 +#ifdef CONFIG_HOTPLUG_CPU
69072 +#define add_cpuinit_latent_entropy
69073 +#else
69074 +#define add_cpuinit_latent_entropy __latent_entropy
69075 +#endif
69076 +
69077 +#ifdef CONFIG_MEMORY_HOTPLUG
69078 +#define add_meminit_latent_entropy
69079 +#else
69080 +#define add_meminit_latent_entropy __latent_entropy
69081 +#endif
69082 +#endif
69083 +
69084 /* These are for everybody (although not all archs will actually
69085 discard it in modules) */
69086 -#define __init __section(.init.text) __cold notrace
69087 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69088 #define __initdata __section(.init.data)
69089 #define __initconst __constsection(.init.rodata)
69090 #define __exitdata __section(.exit.data)
69091 @@ -94,7 +121,7 @@
69092 #define __exit __section(.exit.text) __exitused __cold notrace
69093
69094 /* Used for HOTPLUG_CPU */
69095 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69096 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69097 #define __cpuinitdata __section(.cpuinit.data)
69098 #define __cpuinitconst __constsection(.cpuinit.rodata)
69099 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69100 @@ -102,7 +129,7 @@
69101 #define __cpuexitconst __constsection(.cpuexit.rodata)
69102
69103 /* Used for MEMORY_HOTPLUG */
69104 -#define __meminit __section(.meminit.text) __cold notrace
69105 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69106 #define __meminitdata __section(.meminit.data)
69107 #define __meminitconst __constsection(.meminit.rodata)
69108 #define __memexit __section(.memexit.text) __exitused __cold notrace
69109 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69110 index 6d087c5..401cab8 100644
69111 --- a/include/linux/init_task.h
69112 +++ b/include/linux/init_task.h
69113 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
69114
69115 #define INIT_TASK_COMM "swapper"
69116
69117 +#ifdef CONFIG_X86
69118 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69119 +#else
69120 +#define INIT_TASK_THREAD_INFO
69121 +#endif
69122 +
69123 /*
69124 * INIT_TASK is used to set up the first task table, touch at
69125 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69126 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
69127 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69128 .comm = INIT_TASK_COMM, \
69129 .thread = INIT_THREAD, \
69130 + INIT_TASK_THREAD_INFO \
69131 .fs = &init_fs, \
69132 .files = &init_files, \
69133 .signal = &init_signals, \
69134 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69135 index 5fa5afe..ac55b25 100644
69136 --- a/include/linux/interrupt.h
69137 +++ b/include/linux/interrupt.h
69138 @@ -430,7 +430,7 @@ enum
69139 /* map softirq index to softirq name. update 'softirq_to_name' in
69140 * kernel/softirq.c when adding a new softirq.
69141 */
69142 -extern char *softirq_to_name[NR_SOFTIRQS];
69143 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69144
69145 /* softirq mask and active fields moved to irq_cpustat_t in
69146 * asm/hardirq.h to get better cache usage. KAO
69147 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69148
69149 struct softirq_action
69150 {
69151 - void (*action)(struct softirq_action *);
69152 -};
69153 + void (*action)(void);
69154 +} __no_const;
69155
69156 asmlinkage void do_softirq(void);
69157 asmlinkage void __do_softirq(void);
69158 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69159 +extern void open_softirq(int nr, void (*action)(void));
69160 extern void softirq_init(void);
69161 extern void __raise_softirq_irqoff(unsigned int nr);
69162
69163 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69164 index f3b99e1..9b73cee 100644
69165 --- a/include/linux/iommu.h
69166 +++ b/include/linux/iommu.h
69167 @@ -101,7 +101,7 @@ struct iommu_ops {
69168 int (*domain_set_attr)(struct iommu_domain *domain,
69169 enum iommu_attr attr, void *data);
69170 unsigned long pgsize_bitmap;
69171 -};
69172 +} __do_const;
69173
69174 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69175 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69176 diff --git a/include/linux/irq.h b/include/linux/irq.h
69177 index fdf2c4a..5332486 100644
69178 --- a/include/linux/irq.h
69179 +++ b/include/linux/irq.h
69180 @@ -328,7 +328,8 @@ struct irq_chip {
69181 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69182
69183 unsigned long flags;
69184 -};
69185 +} __do_const;
69186 +typedef struct irq_chip __no_const irq_chip_no_const;
69187
69188 /*
69189 * irq_chip specific flags
69190 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69191 index 6883e19..06992b1 100644
69192 --- a/include/linux/kallsyms.h
69193 +++ b/include/linux/kallsyms.h
69194 @@ -15,7 +15,8 @@
69195
69196 struct module;
69197
69198 -#ifdef CONFIG_KALLSYMS
69199 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69200 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69201 /* Lookup the address for a symbol. Returns 0 if not found. */
69202 unsigned long kallsyms_lookup_name(const char *name);
69203
69204 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69205 /* Stupid that this does nothing, but I didn't create this mess. */
69206 #define __print_symbol(fmt, addr)
69207 #endif /*CONFIG_KALLSYMS*/
69208 +#else /* when included by kallsyms.c, vsnprintf.c, or
69209 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69210 +extern void __print_symbol(const char *fmt, unsigned long address);
69211 +extern int sprint_backtrace(char *buffer, unsigned long address);
69212 +extern int sprint_symbol(char *buffer, unsigned long address);
69213 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69214 +const char *kallsyms_lookup(unsigned long addr,
69215 + unsigned long *symbolsize,
69216 + unsigned long *offset,
69217 + char **modname, char *namebuf);
69218 +#endif
69219
69220 /* This macro allows us to keep printk typechecking */
69221 static __printf(1, 2)
69222 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69223 index 518a53a..5e28358 100644
69224 --- a/include/linux/key-type.h
69225 +++ b/include/linux/key-type.h
69226 @@ -125,7 +125,7 @@ struct key_type {
69227 /* internal fields */
69228 struct list_head link; /* link in types list */
69229 struct lock_class_key lock_class; /* key->sem lock class */
69230 -};
69231 +} __do_const;
69232
69233 extern struct key_type key_type_keyring;
69234
69235 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69236 index 4dff0c6..1ca9b72 100644
69237 --- a/include/linux/kgdb.h
69238 +++ b/include/linux/kgdb.h
69239 @@ -53,7 +53,7 @@ extern int kgdb_connected;
69240 extern int kgdb_io_module_registered;
69241
69242 extern atomic_t kgdb_setting_breakpoint;
69243 -extern atomic_t kgdb_cpu_doing_single_step;
69244 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69245
69246 extern struct task_struct *kgdb_usethread;
69247 extern struct task_struct *kgdb_contthread;
69248 @@ -255,7 +255,7 @@ struct kgdb_arch {
69249 void (*correct_hw_break)(void);
69250
69251 void (*enable_nmi)(bool on);
69252 -};
69253 +} __do_const;
69254
69255 /**
69256 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69257 @@ -280,7 +280,7 @@ struct kgdb_io {
69258 void (*pre_exception) (void);
69259 void (*post_exception) (void);
69260 int is_console;
69261 -};
69262 +} __do_const;
69263
69264 extern struct kgdb_arch arch_kgdb_ops;
69265
69266 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
69267 index 5398d58..5883a34 100644
69268 --- a/include/linux/kmod.h
69269 +++ b/include/linux/kmod.h
69270 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
69271 * usually useless though. */
69272 extern __printf(2, 3)
69273 int __request_module(bool wait, const char *name, ...);
69274 +extern __printf(3, 4)
69275 +int ___request_module(bool wait, char *param_name, const char *name, ...);
69276 #define request_module(mod...) __request_module(true, mod)
69277 #define request_module_nowait(mod...) __request_module(false, mod)
69278 #define try_then_request_module(x, mod...) \
69279 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
69280 index 939b112..ed6ed51 100644
69281 --- a/include/linux/kobject.h
69282 +++ b/include/linux/kobject.h
69283 @@ -111,7 +111,7 @@ struct kobj_type {
69284 struct attribute **default_attrs;
69285 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
69286 const void *(*namespace)(struct kobject *kobj);
69287 -};
69288 +} __do_const;
69289
69290 struct kobj_uevent_env {
69291 char *envp[UEVENT_NUM_ENVP];
69292 @@ -134,6 +134,7 @@ struct kobj_attribute {
69293 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
69294 const char *buf, size_t count);
69295 };
69296 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
69297
69298 extern const struct sysfs_ops kobj_sysfs_ops;
69299
69300 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
69301 index f66b065..c2c29b4 100644
69302 --- a/include/linux/kobject_ns.h
69303 +++ b/include/linux/kobject_ns.h
69304 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
69305 const void *(*netlink_ns)(struct sock *sk);
69306 const void *(*initial_ns)(void);
69307 void (*drop_ns)(void *);
69308 -};
69309 +} __do_const;
69310
69311 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
69312 int kobj_ns_type_registered(enum kobj_ns_type type);
69313 diff --git a/include/linux/kref.h b/include/linux/kref.h
69314 index 4972e6e..de4d19b 100644
69315 --- a/include/linux/kref.h
69316 +++ b/include/linux/kref.h
69317 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
69318 static inline int kref_sub(struct kref *kref, unsigned int count,
69319 void (*release)(struct kref *kref))
69320 {
69321 - WARN_ON(release == NULL);
69322 + BUG_ON(release == NULL);
69323
69324 if (atomic_sub_and_test((int) count, &kref->refcount)) {
69325 release(kref);
69326 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
69327 index 2c497ab..afe32f5 100644
69328 --- a/include/linux/kvm_host.h
69329 +++ b/include/linux/kvm_host.h
69330 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
69331 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
69332 void vcpu_put(struct kvm_vcpu *vcpu);
69333
69334 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69335 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69336 struct module *module);
69337 void kvm_exit(void);
69338
69339 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
69340 struct kvm_guest_debug *dbg);
69341 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
69342
69343 -int kvm_arch_init(void *opaque);
69344 +int kvm_arch_init(const void *opaque);
69345 void kvm_arch_exit(void);
69346
69347 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
69348 diff --git a/include/linux/libata.h b/include/linux/libata.h
69349 index 649e5f8..ead5194 100644
69350 --- a/include/linux/libata.h
69351 +++ b/include/linux/libata.h
69352 @@ -915,7 +915,7 @@ struct ata_port_operations {
69353 * fields must be pointers.
69354 */
69355 const struct ata_port_operations *inherits;
69356 -};
69357 +} __do_const;
69358
69359 struct ata_port_info {
69360 unsigned long flags;
69361 diff --git a/include/linux/list.h b/include/linux/list.h
69362 index cc6d2aa..c10ee83 100644
69363 --- a/include/linux/list.h
69364 +++ b/include/linux/list.h
69365 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
69366 extern void list_del(struct list_head *entry);
69367 #endif
69368
69369 +extern void __pax_list_add(struct list_head *new,
69370 + struct list_head *prev,
69371 + struct list_head *next);
69372 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
69373 +{
69374 + __pax_list_add(new, head, head->next);
69375 +}
69376 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
69377 +{
69378 + __pax_list_add(new, head->prev, head);
69379 +}
69380 +extern void pax_list_del(struct list_head *entry);
69381 +
69382 /**
69383 * list_replace - replace old entry by new one
69384 * @old : the element to be replaced
69385 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
69386 INIT_LIST_HEAD(entry);
69387 }
69388
69389 +extern void pax_list_del_init(struct list_head *entry);
69390 +
69391 /**
69392 * list_move - delete from one list and add as another's head
69393 * @list: the entry to move
69394 diff --git a/include/linux/math64.h b/include/linux/math64.h
69395 index b8ba855..0148090 100644
69396 --- a/include/linux/math64.h
69397 +++ b/include/linux/math64.h
69398 @@ -14,7 +14,7 @@
69399 * This is commonly provided by 32bit archs to provide an optimized 64bit
69400 * divide.
69401 */
69402 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69403 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69404 {
69405 *remainder = dividend % divisor;
69406 return dividend / divisor;
69407 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
69408 #define div64_long(x,y) div_s64((x),(y))
69409
69410 #ifndef div_u64_rem
69411 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69412 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69413 {
69414 *remainder = do_div(dividend, divisor);
69415 return dividend;
69416 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
69417 * divide.
69418 */
69419 #ifndef div_u64
69420 -static inline u64 div_u64(u64 dividend, u32 divisor)
69421 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
69422 {
69423 u32 remainder;
69424 return div_u64_rem(dividend, divisor, &remainder);
69425 diff --git a/include/linux/mm.h b/include/linux/mm.h
69426 index 66e2f7c..a398fb2 100644
69427 --- a/include/linux/mm.h
69428 +++ b/include/linux/mm.h
69429 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
69430 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
69431 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
69432 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
69433 +
69434 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
69435 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
69436 +#endif
69437 +
69438 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
69439
69440 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
69441 @@ -231,6 +236,7 @@ struct vm_operations_struct {
69442 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
69443 unsigned long size, pgoff_t pgoff);
69444 };
69445 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
69446
69447 struct mmu_gather;
69448 struct inode;
69449 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
69450 int set_page_dirty_lock(struct page *page);
69451 int clear_page_dirty_for_io(struct page *page);
69452
69453 -/* Is the vma a continuation of the stack vma above it? */
69454 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
69455 -{
69456 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
69457 -}
69458 -
69459 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
69460 - unsigned long addr)
69461 -{
69462 - return (vma->vm_flags & VM_GROWSDOWN) &&
69463 - (vma->vm_start == addr) &&
69464 - !vma_growsdown(vma->vm_prev, addr);
69465 -}
69466 -
69467 -/* Is the vma a continuation of the stack vma below it? */
69468 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
69469 -{
69470 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
69471 -}
69472 -
69473 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
69474 - unsigned long addr)
69475 -{
69476 - return (vma->vm_flags & VM_GROWSUP) &&
69477 - (vma->vm_end == addr) &&
69478 - !vma_growsup(vma->vm_next, addr);
69479 -}
69480 -
69481 extern pid_t
69482 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
69483
69484 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
69485 }
69486 #endif
69487
69488 +#ifdef CONFIG_MMU
69489 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
69490 +#else
69491 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
69492 +{
69493 + return __pgprot(0);
69494 +}
69495 +#endif
69496 +
69497 int vma_wants_writenotify(struct vm_area_struct *vma);
69498
69499 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
69500 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
69501 {
69502 return 0;
69503 }
69504 +
69505 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
69506 + unsigned long address)
69507 +{
69508 + return 0;
69509 +}
69510 #else
69511 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69512 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69513 #endif
69514
69515 #ifdef __PAGETABLE_PMD_FOLDED
69516 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
69517 {
69518 return 0;
69519 }
69520 +
69521 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
69522 + unsigned long address)
69523 +{
69524 + return 0;
69525 +}
69526 #else
69527 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
69528 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
69529 #endif
69530
69531 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
69532 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
69533 NULL: pud_offset(pgd, address);
69534 }
69535
69536 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
69537 +{
69538 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
69539 + NULL: pud_offset(pgd, address);
69540 +}
69541 +
69542 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
69543 {
69544 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
69545 NULL: pmd_offset(pud, address);
69546 }
69547 +
69548 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
69549 +{
69550 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
69551 + NULL: pmd_offset(pud, address);
69552 +}
69553 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
69554
69555 #if USE_SPLIT_PTLOCKS
69556 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
69557 unsigned long, unsigned long,
69558 unsigned long, unsigned long);
69559 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
69560 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
69561
69562 /* These take the mm semaphore themselves */
69563 extern unsigned long vm_brk(unsigned long, unsigned long);
69564 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
69565 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
69566 struct vm_area_struct **pprev);
69567
69568 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
69569 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
69570 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
69571 +
69572 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
69573 NULL if none. Assume start_addr < end_addr. */
69574 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
69575 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
69576 return vma;
69577 }
69578
69579 -#ifdef CONFIG_MMU
69580 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
69581 -#else
69582 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
69583 -{
69584 - return __pgprot(0);
69585 -}
69586 -#endif
69587 -
69588 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
69589 unsigned long change_prot_numa(struct vm_area_struct *vma,
69590 unsigned long start, unsigned long end);
69591 @@ -1649,6 +1658,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
69592 static inline void vm_stat_account(struct mm_struct *mm,
69593 unsigned long flags, struct file *file, long pages)
69594 {
69595 +
69596 +#ifdef CONFIG_PAX_RANDMMAP
69597 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
69598 +#endif
69599 +
69600 mm->total_vm += pages;
69601 }
69602 #endif /* CONFIG_PROC_FS */
69603 @@ -1721,7 +1735,7 @@ extern int unpoison_memory(unsigned long pfn);
69604 extern int sysctl_memory_failure_early_kill;
69605 extern int sysctl_memory_failure_recovery;
69606 extern void shake_page(struct page *p, int access);
69607 -extern atomic_long_t mce_bad_pages;
69608 +extern atomic_long_unchecked_t mce_bad_pages;
69609 extern int soft_offline_page(struct page *page, int flags);
69610
69611 extern void dump_page(struct page *page);
69612 @@ -1752,5 +1766,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
69613 static inline bool page_is_guard(struct page *page) { return false; }
69614 #endif /* CONFIG_DEBUG_PAGEALLOC */
69615
69616 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
69617 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
69618 +#else
69619 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
69620 +#endif
69621 +
69622 #endif /* __KERNEL__ */
69623 #endif /* _LINUX_MM_H */
69624 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
69625 index f8f5162..3aaf20f 100644
69626 --- a/include/linux/mm_types.h
69627 +++ b/include/linux/mm_types.h
69628 @@ -288,6 +288,8 @@ struct vm_area_struct {
69629 #ifdef CONFIG_NUMA
69630 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
69631 #endif
69632 +
69633 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
69634 };
69635
69636 struct core_thread {
69637 @@ -436,6 +438,24 @@ struct mm_struct {
69638 int first_nid;
69639 #endif
69640 struct uprobes_state uprobes_state;
69641 +
69642 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
69643 + unsigned long pax_flags;
69644 +#endif
69645 +
69646 +#ifdef CONFIG_PAX_DLRESOLVE
69647 + unsigned long call_dl_resolve;
69648 +#endif
69649 +
69650 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
69651 + unsigned long call_syscall;
69652 +#endif
69653 +
69654 +#ifdef CONFIG_PAX_ASLR
69655 + unsigned long delta_mmap; /* randomized offset */
69656 + unsigned long delta_stack; /* randomized offset */
69657 +#endif
69658 +
69659 };
69660
69661 /* first nid will either be a valid NID or one of these values */
69662 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
69663 index c5d5278..f0b68c8 100644
69664 --- a/include/linux/mmiotrace.h
69665 +++ b/include/linux/mmiotrace.h
69666 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
69667 /* Called from ioremap.c */
69668 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
69669 void __iomem *addr);
69670 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
69671 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
69672
69673 /* For anyone to insert markers. Remember trailing newline. */
69674 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
69675 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
69676 {
69677 }
69678
69679 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
69680 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
69681 {
69682 }
69683
69684 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
69685 index 73b64a3..6562925 100644
69686 --- a/include/linux/mmzone.h
69687 +++ b/include/linux/mmzone.h
69688 @@ -412,7 +412,7 @@ struct zone {
69689 unsigned long flags; /* zone flags, see below */
69690
69691 /* Zone statistics */
69692 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69693 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69694
69695 /*
69696 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
69697 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
69698 index fed3def..c933f99 100644
69699 --- a/include/linux/mod_devicetable.h
69700 +++ b/include/linux/mod_devicetable.h
69701 @@ -12,7 +12,7 @@
69702 typedef unsigned long kernel_ulong_t;
69703 #endif
69704
69705 -#define PCI_ANY_ID (~0)
69706 +#define PCI_ANY_ID ((__u16)~0)
69707
69708 struct pci_device_id {
69709 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
69710 @@ -139,7 +139,7 @@ struct usb_device_id {
69711 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
69712 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
69713
69714 -#define HID_ANY_ID (~0)
69715 +#define HID_ANY_ID (~0U)
69716 #define HID_BUS_ANY 0xffff
69717 #define HID_GROUP_ANY 0x0000
69718
69719 @@ -498,7 +498,7 @@ struct dmi_system_id {
69720 const char *ident;
69721 struct dmi_strmatch matches[4];
69722 void *driver_data;
69723 -};
69724 +} __do_const;
69725 /*
69726 * struct dmi_device_id appears during expansion of
69727 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
69728 diff --git a/include/linux/module.h b/include/linux/module.h
69729 index 1375ee3..ced8177 100644
69730 --- a/include/linux/module.h
69731 +++ b/include/linux/module.h
69732 @@ -17,9 +17,11 @@
69733 #include <linux/moduleparam.h>
69734 #include <linux/tracepoint.h>
69735 #include <linux/export.h>
69736 +#include <linux/fs.h>
69737
69738 #include <linux/percpu.h>
69739 #include <asm/module.h>
69740 +#include <asm/pgtable.h>
69741
69742 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
69743 #define MODULE_SIG_STRING "~Module signature appended~\n"
69744 @@ -54,12 +56,13 @@ struct module_attribute {
69745 int (*test)(struct module *);
69746 void (*free)(struct module *);
69747 };
69748 +typedef struct module_attribute __no_const module_attribute_no_const;
69749
69750 struct module_version_attribute {
69751 struct module_attribute mattr;
69752 const char *module_name;
69753 const char *version;
69754 -} __attribute__ ((__aligned__(sizeof(void *))));
69755 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
69756
69757 extern ssize_t __modver_version_show(struct module_attribute *,
69758 struct module_kobject *, char *);
69759 @@ -232,7 +235,7 @@ struct module
69760
69761 /* Sysfs stuff. */
69762 struct module_kobject mkobj;
69763 - struct module_attribute *modinfo_attrs;
69764 + module_attribute_no_const *modinfo_attrs;
69765 const char *version;
69766 const char *srcversion;
69767 struct kobject *holders_dir;
69768 @@ -281,19 +284,16 @@ struct module
69769 int (*init)(void);
69770
69771 /* If this is non-NULL, vfree after init() returns */
69772 - void *module_init;
69773 + void *module_init_rx, *module_init_rw;
69774
69775 /* Here is the actual code + data, vfree'd on unload. */
69776 - void *module_core;
69777 + void *module_core_rx, *module_core_rw;
69778
69779 /* Here are the sizes of the init and core sections */
69780 - unsigned int init_size, core_size;
69781 + unsigned int init_size_rw, core_size_rw;
69782
69783 /* The size of the executable code in each section. */
69784 - unsigned int init_text_size, core_text_size;
69785 -
69786 - /* Size of RO sections of the module (text+rodata) */
69787 - unsigned int init_ro_size, core_ro_size;
69788 + unsigned int init_size_rx, core_size_rx;
69789
69790 /* Arch-specific module values */
69791 struct mod_arch_specific arch;
69792 @@ -349,6 +349,10 @@ struct module
69793 #ifdef CONFIG_EVENT_TRACING
69794 struct ftrace_event_call **trace_events;
69795 unsigned int num_trace_events;
69796 + struct file_operations trace_id;
69797 + struct file_operations trace_enable;
69798 + struct file_operations trace_format;
69799 + struct file_operations trace_filter;
69800 #endif
69801 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
69802 unsigned int num_ftrace_callsites;
69803 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
69804 bool is_module_percpu_address(unsigned long addr);
69805 bool is_module_text_address(unsigned long addr);
69806
69807 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
69808 +{
69809 +
69810 +#ifdef CONFIG_PAX_KERNEXEC
69811 + if (ktla_ktva(addr) >= (unsigned long)start &&
69812 + ktla_ktva(addr) < (unsigned long)start + size)
69813 + return 1;
69814 +#endif
69815 +
69816 + return ((void *)addr >= start && (void *)addr < start + size);
69817 +}
69818 +
69819 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
69820 +{
69821 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
69822 +}
69823 +
69824 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
69825 +{
69826 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
69827 +}
69828 +
69829 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
69830 +{
69831 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
69832 +}
69833 +
69834 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
69835 +{
69836 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
69837 +}
69838 +
69839 static inline int within_module_core(unsigned long addr, struct module *mod)
69840 {
69841 - return (unsigned long)mod->module_core <= addr &&
69842 - addr < (unsigned long)mod->module_core + mod->core_size;
69843 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
69844 }
69845
69846 static inline int within_module_init(unsigned long addr, struct module *mod)
69847 {
69848 - return (unsigned long)mod->module_init <= addr &&
69849 - addr < (unsigned long)mod->module_init + mod->init_size;
69850 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
69851 }
69852
69853 /* Search for module by name: must hold module_mutex. */
69854 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
69855 index 560ca53..ef621ef 100644
69856 --- a/include/linux/moduleloader.h
69857 +++ b/include/linux/moduleloader.h
69858 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
69859 sections. Returns NULL on failure. */
69860 void *module_alloc(unsigned long size);
69861
69862 +#ifdef CONFIG_PAX_KERNEXEC
69863 +void *module_alloc_exec(unsigned long size);
69864 +#else
69865 +#define module_alloc_exec(x) module_alloc(x)
69866 +#endif
69867 +
69868 /* Free memory returned from module_alloc. */
69869 void module_free(struct module *mod, void *module_region);
69870
69871 +#ifdef CONFIG_PAX_KERNEXEC
69872 +void module_free_exec(struct module *mod, void *module_region);
69873 +#else
69874 +#define module_free_exec(x, y) module_free((x), (y))
69875 +#endif
69876 +
69877 /*
69878 * Apply the given relocation to the (simplified) ELF. Return -error
69879 * or 0.
69880 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
69881 unsigned int relsec,
69882 struct module *me)
69883 {
69884 +#ifdef CONFIG_MODULES
69885 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
69886 +#endif
69887 return -ENOEXEC;
69888 }
69889 #endif
69890 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
69891 unsigned int relsec,
69892 struct module *me)
69893 {
69894 +#ifdef CONFIG_MODULES
69895 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
69896 +#endif
69897 return -ENOEXEC;
69898 }
69899 #endif
69900 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
69901 index 137b419..fe663ec 100644
69902 --- a/include/linux/moduleparam.h
69903 +++ b/include/linux/moduleparam.h
69904 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
69905 * @len is usually just sizeof(string).
69906 */
69907 #define module_param_string(name, string, len, perm) \
69908 - static const struct kparam_string __param_string_##name \
69909 + static const struct kparam_string __param_string_##name __used \
69910 = { len, string }; \
69911 __module_param_call(MODULE_PARAM_PREFIX, name, \
69912 &param_ops_string, \
69913 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
69914 */
69915 #define module_param_array_named(name, array, type, nump, perm) \
69916 param_check_##type(name, &(array)[0]); \
69917 - static const struct kparam_array __param_arr_##name \
69918 + static const struct kparam_array __param_arr_##name __used \
69919 = { .max = ARRAY_SIZE(array), .num = nump, \
69920 .ops = &param_ops_##type, \
69921 .elemsize = sizeof(array[0]), .elem = array }; \
69922 diff --git a/include/linux/namei.h b/include/linux/namei.h
69923 index 5a5ff57..5ae5070 100644
69924 --- a/include/linux/namei.h
69925 +++ b/include/linux/namei.h
69926 @@ -19,7 +19,7 @@ struct nameidata {
69927 unsigned seq;
69928 int last_type;
69929 unsigned depth;
69930 - char *saved_names[MAX_NESTED_LINKS + 1];
69931 + const char *saved_names[MAX_NESTED_LINKS + 1];
69932 };
69933
69934 /*
69935 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
69936
69937 extern void nd_jump_link(struct nameidata *nd, struct path *path);
69938
69939 -static inline void nd_set_link(struct nameidata *nd, char *path)
69940 +static inline void nd_set_link(struct nameidata *nd, const char *path)
69941 {
69942 nd->saved_names[nd->depth] = path;
69943 }
69944
69945 -static inline char *nd_get_link(struct nameidata *nd)
69946 +static inline const char *nd_get_link(const struct nameidata *nd)
69947 {
69948 return nd->saved_names[nd->depth];
69949 }
69950 diff --git a/include/linux/net.h b/include/linux/net.h
69951 index aa16731..514b875 100644
69952 --- a/include/linux/net.h
69953 +++ b/include/linux/net.h
69954 @@ -183,7 +183,7 @@ struct net_proto_family {
69955 int (*create)(struct net *net, struct socket *sock,
69956 int protocol, int kern);
69957 struct module *owner;
69958 -};
69959 +} __do_const;
69960
69961 struct iovec;
69962 struct kvec;
69963 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
69964 index 9ef07d0..130a5d9 100644
69965 --- a/include/linux/netdevice.h
69966 +++ b/include/linux/netdevice.h
69967 @@ -1012,6 +1012,7 @@ struct net_device_ops {
69968 u32 pid, u32 seq,
69969 struct net_device *dev);
69970 };
69971 +typedef struct net_device_ops __no_const net_device_ops_no_const;
69972
69973 /*
69974 * The DEVICE structure.
69975 @@ -1078,7 +1079,7 @@ struct net_device {
69976 int iflink;
69977
69978 struct net_device_stats stats;
69979 - atomic_long_t rx_dropped; /* dropped packets by core network
69980 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
69981 * Do not use this in drivers.
69982 */
69983
69984 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
69985 index ee14284..bc65d63 100644
69986 --- a/include/linux/netfilter.h
69987 +++ b/include/linux/netfilter.h
69988 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
69989 #endif
69990 /* Use the module struct to lock set/get code in place */
69991 struct module *owner;
69992 -};
69993 +} __do_const;
69994
69995 /* Function to register/unregister hook points. */
69996 int nf_register_hook(struct nf_hook_ops *reg);
69997 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
69998 index 7958e84..ed74d7a 100644
69999 --- a/include/linux/netfilter/ipset/ip_set.h
70000 +++ b/include/linux/netfilter/ipset/ip_set.h
70001 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70002 /* Return true if "b" set is the same as "a"
70003 * according to the create set parameters */
70004 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70005 -};
70006 +} __do_const;
70007
70008 /* The core set type structure */
70009 struct ip_set_type {
70010 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70011 index 4966dde..7d8ce06 100644
70012 --- a/include/linux/netfilter/nfnetlink.h
70013 +++ b/include/linux/netfilter/nfnetlink.h
70014 @@ -16,7 +16,7 @@ struct nfnl_callback {
70015 const struct nlattr * const cda[]);
70016 const struct nla_policy *policy; /* netlink attribute policy */
70017 const u_int16_t attr_count; /* number of nlattr's */
70018 -};
70019 +} __do_const;
70020
70021 struct nfnetlink_subsystem {
70022 const char *name;
70023 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70024 new file mode 100644
70025 index 0000000..33f4af8
70026 --- /dev/null
70027 +++ b/include/linux/netfilter/xt_gradm.h
70028 @@ -0,0 +1,9 @@
70029 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70030 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70031 +
70032 +struct xt_gradm_mtinfo {
70033 + __u16 flags;
70034 + __u16 invflags;
70035 +};
70036 +
70037 +#endif
70038 diff --git a/include/linux/nls.h b/include/linux/nls.h
70039 index 5dc635f..35f5e11 100644
70040 --- a/include/linux/nls.h
70041 +++ b/include/linux/nls.h
70042 @@ -31,7 +31,7 @@ struct nls_table {
70043 const unsigned char *charset2upper;
70044 struct module *owner;
70045 struct nls_table *next;
70046 -};
70047 +} __do_const;
70048
70049 /* this value hold the maximum octet of charset */
70050 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70051 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70052 index d65746e..62e72c2 100644
70053 --- a/include/linux/notifier.h
70054 +++ b/include/linux/notifier.h
70055 @@ -51,7 +51,8 @@ struct notifier_block {
70056 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70057 struct notifier_block __rcu *next;
70058 int priority;
70059 -};
70060 +} __do_const;
70061 +typedef struct notifier_block __no_const notifier_block_no_const;
70062
70063 struct atomic_notifier_head {
70064 spinlock_t lock;
70065 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70066 index a4c5624..79d6d88 100644
70067 --- a/include/linux/oprofile.h
70068 +++ b/include/linux/oprofile.h
70069 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70070 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70071 char const * name, ulong * val);
70072
70073 -/** Create a file for read-only access to an atomic_t. */
70074 +/** Create a file for read-only access to an atomic_unchecked_t. */
70075 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70076 - char const * name, atomic_t * val);
70077 + char const * name, atomic_unchecked_t * val);
70078
70079 /** create a directory */
70080 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70081 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70082 index 45fc162..01a4068 100644
70083 --- a/include/linux/pci_hotplug.h
70084 +++ b/include/linux/pci_hotplug.h
70085 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70086 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70087 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70088 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70089 -};
70090 +} __do_const;
70091 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70092
70093 /**
70094 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70095 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70096 index a280650..2b67b91 100644
70097 --- a/include/linux/perf_event.h
70098 +++ b/include/linux/perf_event.h
70099 @@ -328,8 +328,8 @@ struct perf_event {
70100
70101 enum perf_event_active_state state;
70102 unsigned int attach_state;
70103 - local64_t count;
70104 - atomic64_t child_count;
70105 + local64_t count; /* PaX: fix it one day */
70106 + atomic64_unchecked_t child_count;
70107
70108 /*
70109 * These are the total time in nanoseconds that the event
70110 @@ -380,8 +380,8 @@ struct perf_event {
70111 * These accumulate total time (in nanoseconds) that children
70112 * events have been enabled and running, respectively.
70113 */
70114 - atomic64_t child_total_time_enabled;
70115 - atomic64_t child_total_time_running;
70116 + atomic64_unchecked_t child_total_time_enabled;
70117 + atomic64_unchecked_t child_total_time_running;
70118
70119 /*
70120 * Protect attach/detach and child_list:
70121 @@ -807,7 +807,7 @@ static inline void perf_restore_debug_store(void) { }
70122 */
70123 #define perf_cpu_notifier(fn) \
70124 do { \
70125 - static struct notifier_block fn##_nb __cpuinitdata = \
70126 + static struct notifier_block fn##_nb = \
70127 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70128 unsigned long cpu = smp_processor_id(); \
70129 unsigned long flags; \
70130 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70131 index ad1a427..6419649 100644
70132 --- a/include/linux/pipe_fs_i.h
70133 +++ b/include/linux/pipe_fs_i.h
70134 @@ -45,9 +45,9 @@ struct pipe_buffer {
70135 struct pipe_inode_info {
70136 wait_queue_head_t wait;
70137 unsigned int nrbufs, curbuf, buffers;
70138 - unsigned int readers;
70139 - unsigned int writers;
70140 - unsigned int waiting_writers;
70141 + atomic_t readers;
70142 + atomic_t writers;
70143 + atomic_t waiting_writers;
70144 unsigned int r_counter;
70145 unsigned int w_counter;
70146 struct page *tmp_page;
70147 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
70148 index 5f28cae..3d23723 100644
70149 --- a/include/linux/platform_data/usb-ehci-s5p.h
70150 +++ b/include/linux/platform_data/usb-ehci-s5p.h
70151 @@ -14,7 +14,7 @@
70152 struct s5p_ehci_platdata {
70153 int (*phy_init)(struct platform_device *pdev, int type);
70154 int (*phy_exit)(struct platform_device *pdev, int type);
70155 -};
70156 +} __no_const;
70157
70158 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
70159
70160 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
70161 index c256c59..8ea94c7 100644
70162 --- a/include/linux/platform_data/usb-exynos.h
70163 +++ b/include/linux/platform_data/usb-exynos.h
70164 @@ -14,7 +14,7 @@
70165 struct exynos4_ohci_platdata {
70166 int (*phy_init)(struct platform_device *pdev, int type);
70167 int (*phy_exit)(struct platform_device *pdev, int type);
70168 -};
70169 +} __no_const;
70170
70171 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70172
70173 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70174 index 7c1d252..c5c773e 100644
70175 --- a/include/linux/pm_domain.h
70176 +++ b/include/linux/pm_domain.h
70177 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70178
70179 struct gpd_cpu_data {
70180 unsigned int saved_exit_latency;
70181 - struct cpuidle_state *idle_state;
70182 + cpuidle_state_no_const *idle_state;
70183 };
70184
70185 struct generic_pm_domain {
70186 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
70187 index f271860..6b3bec5 100644
70188 --- a/include/linux/pm_runtime.h
70189 +++ b/include/linux/pm_runtime.h
70190 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
70191
70192 static inline void pm_runtime_mark_last_busy(struct device *dev)
70193 {
70194 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
70195 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
70196 }
70197
70198 #else /* !CONFIG_PM_RUNTIME */
70199 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
70200 index 195aafc..49a7bc2 100644
70201 --- a/include/linux/pnp.h
70202 +++ b/include/linux/pnp.h
70203 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
70204 struct pnp_fixup {
70205 char id[7];
70206 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
70207 -};
70208 +} __do_const;
70209
70210 /* config parameters */
70211 #define PNP_CONFIG_NORMAL 0x0001
70212 diff --git a/include/linux/poison.h b/include/linux/poison.h
70213 index 2110a81..13a11bb 100644
70214 --- a/include/linux/poison.h
70215 +++ b/include/linux/poison.h
70216 @@ -19,8 +19,8 @@
70217 * under normal circumstances, used to verify that nobody uses
70218 * non-initialized list entries.
70219 */
70220 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70221 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70222 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70223 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70224
70225 /********** include/linux/timer.h **********/
70226 /*
70227 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
70228 index c0f44c2..1572583 100644
70229 --- a/include/linux/power/smartreflex.h
70230 +++ b/include/linux/power/smartreflex.h
70231 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
70232 int (*notify)(struct omap_sr *sr, u32 status);
70233 u8 notify_flags;
70234 u8 class_type;
70235 -};
70236 +} __do_const;
70237
70238 /**
70239 * struct omap_sr_nvalue_table - Smartreflex n-target value info
70240 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
70241 index 4ea1d37..80f4b33 100644
70242 --- a/include/linux/ppp-comp.h
70243 +++ b/include/linux/ppp-comp.h
70244 @@ -84,7 +84,7 @@ struct compressor {
70245 struct module *owner;
70246 /* Extra skb space needed by the compressor algorithm */
70247 unsigned int comp_extra;
70248 -};
70249 +} __do_const;
70250
70251 /*
70252 * The return value from decompress routine is the length of the
70253 diff --git a/include/linux/printk.h b/include/linux/printk.h
70254 index 9afc01e..92c32e8 100644
70255 --- a/include/linux/printk.h
70256 +++ b/include/linux/printk.h
70257 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
70258 extern int printk_needs_cpu(int cpu);
70259 extern void printk_tick(void);
70260
70261 +extern int kptr_restrict;
70262 +
70263 #ifdef CONFIG_PRINTK
70264 asmlinkage __printf(5, 0)
70265 int vprintk_emit(int facility, int level,
70266 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
70267
70268 extern int printk_delay_msec;
70269 extern int dmesg_restrict;
70270 -extern int kptr_restrict;
70271
70272 void log_buf_kexec_setup(void);
70273 void __init setup_log_buf(int early);
70274 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
70275 index 32676b3..e46f2c0 100644
70276 --- a/include/linux/proc_fs.h
70277 +++ b/include/linux/proc_fs.h
70278 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
70279 return proc_create_data(name, mode, parent, proc_fops, NULL);
70280 }
70281
70282 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
70283 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
70284 +{
70285 +#ifdef CONFIG_GRKERNSEC_PROC_USER
70286 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
70287 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70288 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
70289 +#else
70290 + return proc_create_data(name, mode, parent, proc_fops, NULL);
70291 +#endif
70292 +}
70293 +
70294 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
70295 umode_t mode, struct proc_dir_entry *base,
70296 read_proc_t *read_proc, void * data)
70297 @@ -268,7 +280,7 @@ struct proc_ns_operations {
70298 void (*put)(void *ns);
70299 int (*install)(struct nsproxy *nsproxy, void *ns);
70300 unsigned int (*inum)(void *ns);
70301 -};
70302 +} __do_const;
70303 extern const struct proc_ns_operations netns_operations;
70304 extern const struct proc_ns_operations utsns_operations;
70305 extern const struct proc_ns_operations ipcns_operations;
70306 diff --git a/include/linux/random.h b/include/linux/random.h
70307 index d984608..d6f0042 100644
70308 --- a/include/linux/random.h
70309 +++ b/include/linux/random.h
70310 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
70311 u32 prandom_u32_state(struct rnd_state *);
70312 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
70313
70314 +static inline unsigned long pax_get_random_long(void)
70315 +{
70316 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
70317 +}
70318 +
70319 /*
70320 * Handle minimum values for seeds
70321 */
70322 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
70323 index c92dd28..08f4eab 100644
70324 --- a/include/linux/rculist.h
70325 +++ b/include/linux/rculist.h
70326 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
70327 struct list_head *prev, struct list_head *next);
70328 #endif
70329
70330 +extern void __pax_list_add_rcu(struct list_head *new,
70331 + struct list_head *prev, struct list_head *next);
70332 +
70333 /**
70334 * list_add_rcu - add a new entry to rcu-protected list
70335 * @new: new entry to be added
70336 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
70337 __list_add_rcu(new, head, head->next);
70338 }
70339
70340 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
70341 +{
70342 + __pax_list_add_rcu(new, head, head->next);
70343 +}
70344 +
70345 /**
70346 * list_add_tail_rcu - add a new entry to rcu-protected list
70347 * @new: new entry to be added
70348 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
70349 __list_add_rcu(new, head->prev, head);
70350 }
70351
70352 +static inline void pax_list_add_tail_rcu(struct list_head *new,
70353 + struct list_head *head)
70354 +{
70355 + __pax_list_add_rcu(new, head->prev, head);
70356 +}
70357 +
70358 /**
70359 * list_del_rcu - deletes entry from list without re-initialization
70360 * @entry: the element to delete from the list.
70361 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
70362 entry->prev = LIST_POISON2;
70363 }
70364
70365 +extern void pax_list_del_rcu(struct list_head *entry);
70366 +
70367 /**
70368 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
70369 * @n: the element to delete from the hash list.
70370 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
70371 index 23b3630..e1bc12b 100644
70372 --- a/include/linux/reboot.h
70373 +++ b/include/linux/reboot.h
70374 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
70375 * Architecture-specific implementations of sys_reboot commands.
70376 */
70377
70378 -extern void machine_restart(char *cmd);
70379 -extern void machine_halt(void);
70380 -extern void machine_power_off(void);
70381 +extern void machine_restart(char *cmd) __noreturn;
70382 +extern void machine_halt(void) __noreturn;
70383 +extern void machine_power_off(void) __noreturn;
70384
70385 extern void machine_shutdown(void);
70386 struct pt_regs;
70387 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
70388 */
70389
70390 extern void kernel_restart_prepare(char *cmd);
70391 -extern void kernel_restart(char *cmd);
70392 -extern void kernel_halt(void);
70393 -extern void kernel_power_off(void);
70394 +extern void kernel_restart(char *cmd) __noreturn;
70395 +extern void kernel_halt(void) __noreturn;
70396 +extern void kernel_power_off(void) __noreturn;
70397
70398 extern int C_A_D; /* for sysctl */
70399 void ctrl_alt_del(void);
70400 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
70401 * Emergency restart, callable from an interrupt handler.
70402 */
70403
70404 -extern void emergency_restart(void);
70405 +extern void emergency_restart(void) __noreturn;
70406 #include <asm/emergency-restart.h>
70407
70408 #endif /* _LINUX_REBOOT_H */
70409 diff --git a/include/linux/regset.h b/include/linux/regset.h
70410 index 8e0c9fe..ac4d221 100644
70411 --- a/include/linux/regset.h
70412 +++ b/include/linux/regset.h
70413 @@ -161,7 +161,8 @@ struct user_regset {
70414 unsigned int align;
70415 unsigned int bias;
70416 unsigned int core_note_type;
70417 -};
70418 +} __do_const;
70419 +typedef struct user_regset __no_const user_regset_no_const;
70420
70421 /**
70422 * struct user_regset_view - available regsets
70423 diff --git a/include/linux/relay.h b/include/linux/relay.h
70424 index 91cacc3..b55ff74 100644
70425 --- a/include/linux/relay.h
70426 +++ b/include/linux/relay.h
70427 @@ -160,7 +160,7 @@ struct rchan_callbacks
70428 * The callback should return 0 if successful, negative if not.
70429 */
70430 int (*remove_buf_file)(struct dentry *dentry);
70431 -};
70432 +} __no_const;
70433
70434 /*
70435 * CONFIG_RELAY kernel API, kernel/relay.c
70436 diff --git a/include/linux/rio.h b/include/linux/rio.h
70437 index a3e7842..d973ca6 100644
70438 --- a/include/linux/rio.h
70439 +++ b/include/linux/rio.h
70440 @@ -339,7 +339,7 @@ struct rio_ops {
70441 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
70442 u64 rstart, u32 size, u32 flags);
70443 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
70444 -};
70445 +} __no_const;
70446
70447 #define RIO_RESOURCE_MEM 0x00000100
70448 #define RIO_RESOURCE_DOORBELL 0x00000200
70449 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
70450 index c20635c..2f5def4 100644
70451 --- a/include/linux/rmap.h
70452 +++ b/include/linux/rmap.h
70453 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
70454 void anon_vma_init(void); /* create anon_vma_cachep */
70455 int anon_vma_prepare(struct vm_area_struct *);
70456 void unlink_anon_vmas(struct vm_area_struct *);
70457 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
70458 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
70459 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
70460 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
70461
70462 static inline void anon_vma_merge(struct vm_area_struct *vma,
70463 struct vm_area_struct *next)
70464 diff --git a/include/linux/sched.h b/include/linux/sched.h
70465 index d211247..eac6c2c 100644
70466 --- a/include/linux/sched.h
70467 +++ b/include/linux/sched.h
70468 @@ -61,6 +61,7 @@ struct bio_list;
70469 struct fs_struct;
70470 struct perf_event_context;
70471 struct blk_plug;
70472 +struct linux_binprm;
70473
70474 /*
70475 * List of flags we want to share for kernel threads,
70476 @@ -327,7 +328,7 @@ extern char __sched_text_start[], __sched_text_end[];
70477 extern int in_sched_functions(unsigned long addr);
70478
70479 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
70480 -extern signed long schedule_timeout(signed long timeout);
70481 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
70482 extern signed long schedule_timeout_interruptible(signed long timeout);
70483 extern signed long schedule_timeout_killable(signed long timeout);
70484 extern signed long schedule_timeout_uninterruptible(signed long timeout);
70485 @@ -354,10 +355,23 @@ struct user_namespace;
70486 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
70487
70488 extern int sysctl_max_map_count;
70489 +extern unsigned long sysctl_heap_stack_gap;
70490
70491 #include <linux/aio.h>
70492
70493 #ifdef CONFIG_MMU
70494 +
70495 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
70496 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
70497 +#else
70498 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
70499 +{
70500 + return 0;
70501 +}
70502 +#endif
70503 +
70504 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
70505 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
70506 extern void arch_pick_mmap_layout(struct mm_struct *mm);
70507 extern unsigned long
70508 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
70509 @@ -639,6 +653,17 @@ struct signal_struct {
70510 #ifdef CONFIG_TASKSTATS
70511 struct taskstats *stats;
70512 #endif
70513 +
70514 +#ifdef CONFIG_GRKERNSEC
70515 + u32 curr_ip;
70516 + u32 saved_ip;
70517 + u32 gr_saddr;
70518 + u32 gr_daddr;
70519 + u16 gr_sport;
70520 + u16 gr_dport;
70521 + u8 used_accept:1;
70522 +#endif
70523 +
70524 #ifdef CONFIG_AUDIT
70525 unsigned audit_tty;
70526 struct tty_audit_buf *tty_audit_buf;
70527 @@ -717,6 +742,11 @@ struct user_struct {
70528 struct key *session_keyring; /* UID's default session keyring */
70529 #endif
70530
70531 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
70532 + unsigned int banned;
70533 + unsigned long ban_expires;
70534 +#endif
70535 +
70536 /* Hash table maintenance information */
70537 struct hlist_node uidhash_node;
70538 kuid_t uid;
70539 @@ -1116,7 +1146,7 @@ struct sched_class {
70540 #ifdef CONFIG_FAIR_GROUP_SCHED
70541 void (*task_move_group) (struct task_struct *p, int on_rq);
70542 #endif
70543 -};
70544 +} __do_const;
70545
70546 struct load_weight {
70547 unsigned long weight, inv_weight;
70548 @@ -1360,8 +1390,8 @@ struct task_struct {
70549 struct list_head thread_group;
70550
70551 struct completion *vfork_done; /* for vfork() */
70552 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
70553 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70554 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
70555 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70556
70557 cputime_t utime, stime, utimescaled, stimescaled;
70558 cputime_t gtime;
70559 @@ -1377,11 +1407,6 @@ struct task_struct {
70560 struct task_cputime cputime_expires;
70561 struct list_head cpu_timers[3];
70562
70563 -/* process credentials */
70564 - const struct cred __rcu *real_cred; /* objective and real subjective task
70565 - * credentials (COW) */
70566 - const struct cred __rcu *cred; /* effective (overridable) subjective task
70567 - * credentials (COW) */
70568 char comm[TASK_COMM_LEN]; /* executable name excluding path
70569 - access with [gs]et_task_comm (which lock
70570 it with task_lock())
70571 @@ -1398,6 +1423,10 @@ struct task_struct {
70572 #endif
70573 /* CPU-specific state of this task */
70574 struct thread_struct thread;
70575 +/* thread_info moved to task_struct */
70576 +#ifdef CONFIG_X86
70577 + struct thread_info tinfo;
70578 +#endif
70579 /* filesystem information */
70580 struct fs_struct *fs;
70581 /* open file information */
70582 @@ -1471,6 +1500,10 @@ struct task_struct {
70583 gfp_t lockdep_reclaim_gfp;
70584 #endif
70585
70586 +/* process credentials */
70587 + const struct cred __rcu *real_cred; /* objective and real subjective task
70588 + * credentials (COW) */
70589 +
70590 /* journalling filesystem info */
70591 void *journal_info;
70592
70593 @@ -1509,6 +1542,10 @@ struct task_struct {
70594 /* cg_list protected by css_set_lock and tsk->alloc_lock */
70595 struct list_head cg_list;
70596 #endif
70597 +
70598 + const struct cred __rcu *cred; /* effective (overridable) subjective task
70599 + * credentials (COW) */
70600 +
70601 #ifdef CONFIG_FUTEX
70602 struct robust_list_head __user *robust_list;
70603 #ifdef CONFIG_COMPAT
70604 @@ -1605,8 +1642,74 @@ struct task_struct {
70605 #ifdef CONFIG_UPROBES
70606 struct uprobe_task *utask;
70607 #endif
70608 +
70609 +#ifdef CONFIG_GRKERNSEC
70610 + /* grsecurity */
70611 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70612 + u64 exec_id;
70613 +#endif
70614 +#ifdef CONFIG_GRKERNSEC_SETXID
70615 + const struct cred *delayed_cred;
70616 +#endif
70617 + struct dentry *gr_chroot_dentry;
70618 + struct acl_subject_label *acl;
70619 + struct acl_role_label *role;
70620 + struct file *exec_file;
70621 + unsigned long brute_expires;
70622 + u16 acl_role_id;
70623 + /* is this the task that authenticated to the special role */
70624 + u8 acl_sp_role;
70625 + u8 is_writable;
70626 + u8 brute;
70627 + u8 gr_is_chrooted;
70628 +#endif
70629 +
70630 };
70631
70632 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
70633 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
70634 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
70635 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
70636 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
70637 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
70638 +
70639 +#ifdef CONFIG_PAX_SOFTMODE
70640 +extern int pax_softmode;
70641 +#endif
70642 +
70643 +extern int pax_check_flags(unsigned long *);
70644 +
70645 +/* if tsk != current then task_lock must be held on it */
70646 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70647 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
70648 +{
70649 + if (likely(tsk->mm))
70650 + return tsk->mm->pax_flags;
70651 + else
70652 + return 0UL;
70653 +}
70654 +
70655 +/* if tsk != current then task_lock must be held on it */
70656 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
70657 +{
70658 + if (likely(tsk->mm)) {
70659 + tsk->mm->pax_flags = flags;
70660 + return 0;
70661 + }
70662 + return -EINVAL;
70663 +}
70664 +#endif
70665 +
70666 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
70667 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
70668 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
70669 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
70670 +#endif
70671 +
70672 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
70673 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
70674 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
70675 +
70676 /* Future-safe accessor for struct task_struct's cpus_allowed. */
70677 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
70678
70679 @@ -1696,7 +1799,7 @@ struct pid_namespace;
70680 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
70681 struct pid_namespace *ns);
70682
70683 -static inline pid_t task_pid_nr(struct task_struct *tsk)
70684 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
70685 {
70686 return tsk->pid;
70687 }
70688 @@ -2155,7 +2258,9 @@ void yield(void);
70689 extern struct exec_domain default_exec_domain;
70690
70691 union thread_union {
70692 +#ifndef CONFIG_X86
70693 struct thread_info thread_info;
70694 +#endif
70695 unsigned long stack[THREAD_SIZE/sizeof(long)];
70696 };
70697
70698 @@ -2188,6 +2293,7 @@ extern struct pid_namespace init_pid_ns;
70699 */
70700
70701 extern struct task_struct *find_task_by_vpid(pid_t nr);
70702 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
70703 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
70704 struct pid_namespace *ns);
70705
70706 @@ -2344,7 +2450,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
70707 extern void exit_itimers(struct signal_struct *);
70708 extern void flush_itimer_signals(void);
70709
70710 -extern void do_group_exit(int);
70711 +extern __noreturn void do_group_exit(int);
70712
70713 extern int allow_signal(int);
70714 extern int disallow_signal(int);
70715 @@ -2545,9 +2651,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
70716
70717 #endif
70718
70719 -static inline int object_is_on_stack(void *obj)
70720 +static inline int object_starts_on_stack(void *obj)
70721 {
70722 - void *stack = task_stack_page(current);
70723 + const void *stack = task_stack_page(current);
70724
70725 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
70726 }
70727 diff --git a/include/linux/security.h b/include/linux/security.h
70728 index eee7478..290f7ba 100644
70729 --- a/include/linux/security.h
70730 +++ b/include/linux/security.h
70731 @@ -26,6 +26,7 @@
70732 #include <linux/capability.h>
70733 #include <linux/slab.h>
70734 #include <linux/err.h>
70735 +#include <linux/grsecurity.h>
70736
70737 struct linux_binprm;
70738 struct cred;
70739 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
70740 index 68a04a3..866e6a1 100644
70741 --- a/include/linux/seq_file.h
70742 +++ b/include/linux/seq_file.h
70743 @@ -26,6 +26,9 @@ struct seq_file {
70744 struct mutex lock;
70745 const struct seq_operations *op;
70746 int poll_event;
70747 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70748 + u64 exec_id;
70749 +#endif
70750 #ifdef CONFIG_USER_NS
70751 struct user_namespace *user_ns;
70752 #endif
70753 @@ -38,6 +41,7 @@ struct seq_operations {
70754 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
70755 int (*show) (struct seq_file *m, void *v);
70756 };
70757 +typedef struct seq_operations __no_const seq_operations_no_const;
70758
70759 #define SEQ_SKIP 1
70760
70761 diff --git a/include/linux/shm.h b/include/linux/shm.h
70762 index 429c199..4d42e38 100644
70763 --- a/include/linux/shm.h
70764 +++ b/include/linux/shm.h
70765 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
70766
70767 /* The task created the shm object. NULL if the task is dead. */
70768 struct task_struct *shm_creator;
70769 +#ifdef CONFIG_GRKERNSEC
70770 + time_t shm_createtime;
70771 + pid_t shm_lapid;
70772 +#endif
70773 };
70774
70775 /* shm_mode upper byte flags */
70776 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
70777 index 98399e2..6e225e9 100644
70778 --- a/include/linux/skbuff.h
70779 +++ b/include/linux/skbuff.h
70780 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
70781 extern struct sk_buff *__alloc_skb(unsigned int size,
70782 gfp_t priority, int flags, int node);
70783 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
70784 -static inline struct sk_buff *alloc_skb(unsigned int size,
70785 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
70786 gfp_t priority)
70787 {
70788 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
70789 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
70790 */
70791 static inline int skb_queue_empty(const struct sk_buff_head *list)
70792 {
70793 - return list->next == (struct sk_buff *)list;
70794 + return list->next == (const struct sk_buff *)list;
70795 }
70796
70797 /**
70798 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
70799 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
70800 const struct sk_buff *skb)
70801 {
70802 - return skb->next == (struct sk_buff *)list;
70803 + return skb->next == (const struct sk_buff *)list;
70804 }
70805
70806 /**
70807 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
70808 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
70809 const struct sk_buff *skb)
70810 {
70811 - return skb->prev == (struct sk_buff *)list;
70812 + return skb->prev == (const struct sk_buff *)list;
70813 }
70814
70815 /**
70816 @@ -1727,7 +1727,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
70817 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
70818 */
70819 #ifndef NET_SKB_PAD
70820 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
70821 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
70822 #endif
70823
70824 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
70825 @@ -2305,7 +2305,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
70826 int noblock, int *err);
70827 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
70828 struct poll_table_struct *wait);
70829 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
70830 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
70831 int offset, struct iovec *to,
70832 int size);
70833 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
70834 diff --git a/include/linux/slab.h b/include/linux/slab.h
70835 index 5d168d7..720bff3 100644
70836 --- a/include/linux/slab.h
70837 +++ b/include/linux/slab.h
70838 @@ -12,13 +12,20 @@
70839 #include <linux/gfp.h>
70840 #include <linux/types.h>
70841 #include <linux/workqueue.h>
70842 -
70843 +#include <linux/err.h>
70844
70845 /*
70846 * Flags to pass to kmem_cache_create().
70847 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
70848 */
70849 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
70850 +
70851 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70852 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
70853 +#else
70854 +#define SLAB_USERCOPY 0x00000000UL
70855 +#endif
70856 +
70857 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
70858 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
70859 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
70860 @@ -89,10 +96,13 @@
70861 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
70862 * Both make kfree a no-op.
70863 */
70864 -#define ZERO_SIZE_PTR ((void *)16)
70865 +#define ZERO_SIZE_PTR \
70866 +({ \
70867 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
70868 + (void *)(-MAX_ERRNO-1L); \
70869 +})
70870
70871 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
70872 - (unsigned long)ZERO_SIZE_PTR)
70873 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
70874
70875 /*
70876 * Common fields provided in kmem_cache by all slab allocators
70877 @@ -112,7 +122,7 @@ struct kmem_cache {
70878 unsigned int align; /* Alignment as calculated */
70879 unsigned long flags; /* Active flags on the slab */
70880 const char *name; /* Slab name for sysfs */
70881 - int refcount; /* Use counter */
70882 + atomic_t refcount; /* Use counter */
70883 void (*ctor)(void *); /* Called on object slot creation */
70884 struct list_head list; /* List of all slab caches on the system */
70885 };
70886 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
70887 void kfree(const void *);
70888 void kzfree(const void *);
70889 size_t ksize(const void *);
70890 +const char *check_heap_object(const void *ptr, unsigned long n);
70891 +bool is_usercopy_object(const void *ptr);
70892
70893 /*
70894 * Allocator specific definitions. These are mainly used to establish optimized
70895 @@ -311,6 +323,7 @@ size_t ksize(const void *);
70896 * for general use, and so are not documented here. For a full list of
70897 * potential flags, always refer to linux/gfp.h.
70898 */
70899 +
70900 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
70901 {
70902 if (size != 0 && n > SIZE_MAX / size)
70903 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
70904 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
70905 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
70906 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
70907 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
70908 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
70909 #define kmalloc_track_caller(size, flags) \
70910 __kmalloc_track_caller(size, flags, _RET_IP_)
70911 #else
70912 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
70913 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
70914 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
70915 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
70916 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
70917 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
70918 #define kmalloc_node_track_caller(size, flags, node) \
70919 __kmalloc_node_track_caller(size, flags, node, \
70920 _RET_IP_)
70921 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
70922 index 8bb6e0e..8eb0dbe 100644
70923 --- a/include/linux/slab_def.h
70924 +++ b/include/linux/slab_def.h
70925 @@ -52,7 +52,7 @@ struct kmem_cache {
70926 /* 4) cache creation/removal */
70927 const char *name;
70928 struct list_head list;
70929 - int refcount;
70930 + atomic_t refcount;
70931 int object_size;
70932 int align;
70933
70934 @@ -68,10 +68,10 @@ struct kmem_cache {
70935 unsigned long node_allocs;
70936 unsigned long node_frees;
70937 unsigned long node_overflow;
70938 - atomic_t allochit;
70939 - atomic_t allocmiss;
70940 - atomic_t freehit;
70941 - atomic_t freemiss;
70942 + atomic_unchecked_t allochit;
70943 + atomic_unchecked_t allocmiss;
70944 + atomic_unchecked_t freehit;
70945 + atomic_unchecked_t freemiss;
70946
70947 /*
70948 * If debugging is enabled, then the allocator can add additional
70949 @@ -111,11 +111,16 @@ struct cache_sizes {
70950 #ifdef CONFIG_ZONE_DMA
70951 struct kmem_cache *cs_dmacachep;
70952 #endif
70953 +
70954 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70955 + struct kmem_cache *cs_usercopycachep;
70956 +#endif
70957 +
70958 };
70959 extern struct cache_sizes malloc_sizes[];
70960
70961 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
70962 -void *__kmalloc(size_t size, gfp_t flags);
70963 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
70964
70965 #ifdef CONFIG_TRACING
70966 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
70967 @@ -152,6 +157,13 @@ found:
70968 cachep = malloc_sizes[i].cs_dmacachep;
70969 else
70970 #endif
70971 +
70972 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70973 + if (flags & GFP_USERCOPY)
70974 + cachep = malloc_sizes[i].cs_usercopycachep;
70975 + else
70976 +#endif
70977 +
70978 cachep = malloc_sizes[i].cs_cachep;
70979
70980 ret = kmem_cache_alloc_trace(cachep, flags, size);
70981 @@ -162,7 +174,7 @@ found:
70982 }
70983
70984 #ifdef CONFIG_NUMA
70985 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
70986 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70987 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
70988
70989 #ifdef CONFIG_TRACING
70990 @@ -205,6 +217,13 @@ found:
70991 cachep = malloc_sizes[i].cs_dmacachep;
70992 else
70993 #endif
70994 +
70995 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70996 + if (flags & GFP_USERCOPY)
70997 + cachep = malloc_sizes[i].cs_usercopycachep;
70998 + else
70999 +#endif
71000 +
71001 cachep = malloc_sizes[i].cs_cachep;
71002
71003 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71004 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71005 index f28e14a..7831211 100644
71006 --- a/include/linux/slob_def.h
71007 +++ b/include/linux/slob_def.h
71008 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71009 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71010 }
71011
71012 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71013 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71014
71015 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71016 {
71017 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71018 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71019 }
71020
71021 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71022 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71023 {
71024 return kmalloc(size, flags);
71025 }
71026 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71027 index 9db4825..ed42fb5 100644
71028 --- a/include/linux/slub_def.h
71029 +++ b/include/linux/slub_def.h
71030 @@ -91,7 +91,7 @@ struct kmem_cache {
71031 struct kmem_cache_order_objects max;
71032 struct kmem_cache_order_objects min;
71033 gfp_t allocflags; /* gfp flags to use on each alloc */
71034 - int refcount; /* Refcount for slab cache destroy */
71035 + atomic_t refcount; /* Refcount for slab cache destroy */
71036 void (*ctor)(void *);
71037 int inuse; /* Offset to metadata */
71038 int align; /* Alignment */
71039 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71040 * Sorry that the following has to be that ugly but some versions of GCC
71041 * have trouble with constant propagation and loops.
71042 */
71043 -static __always_inline int kmalloc_index(size_t size)
71044 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71045 {
71046 if (!size)
71047 return 0;
71048 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71049 }
71050
71051 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71052 -void *__kmalloc(size_t size, gfp_t flags);
71053 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71054
71055 static __always_inline void *
71056 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71057 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71058 }
71059 #endif
71060
71061 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71062 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71063 {
71064 unsigned int order = get_order(size);
71065 return kmalloc_order_trace(size, flags, order);
71066 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71067 }
71068
71069 #ifdef CONFIG_NUMA
71070 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71071 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71072 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71073
71074 #ifdef CONFIG_TRACING
71075 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71076 index e8d702e..0a56eb4 100644
71077 --- a/include/linux/sock_diag.h
71078 +++ b/include/linux/sock_diag.h
71079 @@ -10,7 +10,7 @@ struct sock;
71080 struct sock_diag_handler {
71081 __u8 family;
71082 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71083 -};
71084 +} __do_const;
71085
71086 int sock_diag_register(const struct sock_diag_handler *h);
71087 void sock_diag_unregister(const struct sock_diag_handler *h);
71088 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71089 index 680f9a3..f13aeb0 100644
71090 --- a/include/linux/sonet.h
71091 +++ b/include/linux/sonet.h
71092 @@ -7,7 +7,7 @@
71093 #include <uapi/linux/sonet.h>
71094
71095 struct k_sonet_stats {
71096 -#define __HANDLE_ITEM(i) atomic_t i
71097 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71098 __SONET_ITEMS
71099 #undef __HANDLE_ITEM
71100 };
71101 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71102 index 34206b8..3db7f1c 100644
71103 --- a/include/linux/sunrpc/clnt.h
71104 +++ b/include/linux/sunrpc/clnt.h
71105 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71106 unsigned int p_timer; /* Which RTT timer to use */
71107 u32 p_statidx; /* Which procedure to account */
71108 const char * p_name; /* name of procedure */
71109 -};
71110 +} __do_const;
71111
71112 #ifdef __KERNEL__
71113
71114 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71115 {
71116 switch (sap->sa_family) {
71117 case AF_INET:
71118 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
71119 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
71120 case AF_INET6:
71121 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
71122 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
71123 }
71124 return 0;
71125 }
71126 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
71127 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
71128 const struct sockaddr *src)
71129 {
71130 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
71131 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
71132 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
71133
71134 dsin->sin_family = ssin->sin_family;
71135 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
71136 if (sa->sa_family != AF_INET6)
71137 return 0;
71138
71139 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
71140 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
71141 }
71142
71143 #endif /* __KERNEL__ */
71144 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
71145 index 676ddf5..4c519a1 100644
71146 --- a/include/linux/sunrpc/svc.h
71147 +++ b/include/linux/sunrpc/svc.h
71148 @@ -410,7 +410,7 @@ struct svc_procedure {
71149 unsigned int pc_count; /* call count */
71150 unsigned int pc_cachetype; /* cache info (NFS) */
71151 unsigned int pc_xdrressize; /* maximum size of XDR reply */
71152 -};
71153 +} __do_const;
71154
71155 /*
71156 * Function prototypes.
71157 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
71158 index 0b8e3e6..33e0a01 100644
71159 --- a/include/linux/sunrpc/svc_rdma.h
71160 +++ b/include/linux/sunrpc/svc_rdma.h
71161 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
71162 extern unsigned int svcrdma_max_requests;
71163 extern unsigned int svcrdma_max_req_size;
71164
71165 -extern atomic_t rdma_stat_recv;
71166 -extern atomic_t rdma_stat_read;
71167 -extern atomic_t rdma_stat_write;
71168 -extern atomic_t rdma_stat_sq_starve;
71169 -extern atomic_t rdma_stat_rq_starve;
71170 -extern atomic_t rdma_stat_rq_poll;
71171 -extern atomic_t rdma_stat_rq_prod;
71172 -extern atomic_t rdma_stat_sq_poll;
71173 -extern atomic_t rdma_stat_sq_prod;
71174 +extern atomic_unchecked_t rdma_stat_recv;
71175 +extern atomic_unchecked_t rdma_stat_read;
71176 +extern atomic_unchecked_t rdma_stat_write;
71177 +extern atomic_unchecked_t rdma_stat_sq_starve;
71178 +extern atomic_unchecked_t rdma_stat_rq_starve;
71179 +extern atomic_unchecked_t rdma_stat_rq_poll;
71180 +extern atomic_unchecked_t rdma_stat_rq_prod;
71181 +extern atomic_unchecked_t rdma_stat_sq_poll;
71182 +extern atomic_unchecked_t rdma_stat_sq_prod;
71183
71184 #define RPCRDMA_VERSION 1
71185
71186 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
71187 index dd74084a..7f509d5 100644
71188 --- a/include/linux/sunrpc/svcauth.h
71189 +++ b/include/linux/sunrpc/svcauth.h
71190 @@ -109,7 +109,7 @@ struct auth_ops {
71191 int (*release)(struct svc_rqst *rq);
71192 void (*domain_release)(struct auth_domain *);
71193 int (*set_client)(struct svc_rqst *rq);
71194 -};
71195 +} __do_const;
71196
71197 #define SVC_GARBAGE 1
71198 #define SVC_SYSERR 2
71199 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
71200 index 071d62c..4ccc7ac 100644
71201 --- a/include/linux/swiotlb.h
71202 +++ b/include/linux/swiotlb.h
71203 @@ -59,7 +59,8 @@ extern void
71204
71205 extern void
71206 swiotlb_free_coherent(struct device *hwdev, size_t size,
71207 - void *vaddr, dma_addr_t dma_handle);
71208 + void *vaddr, dma_addr_t dma_handle,
71209 + struct dma_attrs *attrs);
71210
71211 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
71212 unsigned long offset, size_t size,
71213 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
71214 index 45e2db2..1635156a 100644
71215 --- a/include/linux/syscalls.h
71216 +++ b/include/linux/syscalls.h
71217 @@ -615,7 +615,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
71218 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
71219 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
71220 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
71221 - struct sockaddr __user *, int);
71222 + struct sockaddr __user *, int) __intentional_overflow(0);
71223 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
71224 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
71225 unsigned int vlen, unsigned flags);
71226 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
71227 index 27b3b0b..e093dd9 100644
71228 --- a/include/linux/syscore_ops.h
71229 +++ b/include/linux/syscore_ops.h
71230 @@ -16,7 +16,7 @@ struct syscore_ops {
71231 int (*suspend)(void);
71232 void (*resume)(void);
71233 void (*shutdown)(void);
71234 -};
71235 +} __do_const;
71236
71237 extern void register_syscore_ops(struct syscore_ops *ops);
71238 extern void unregister_syscore_ops(struct syscore_ops *ops);
71239 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
71240 index 14a8ff2..af52bad 100644
71241 --- a/include/linux/sysctl.h
71242 +++ b/include/linux/sysctl.h
71243 @@ -34,13 +34,13 @@ struct ctl_table_root;
71244 struct ctl_table_header;
71245 struct ctl_dir;
71246
71247 -typedef struct ctl_table ctl_table;
71248 -
71249 typedef int proc_handler (struct ctl_table *ctl, int write,
71250 void __user *buffer, size_t *lenp, loff_t *ppos);
71251
71252 extern int proc_dostring(struct ctl_table *, int,
71253 void __user *, size_t *, loff_t *);
71254 +extern int proc_dostring_modpriv(struct ctl_table *, int,
71255 + void __user *, size_t *, loff_t *);
71256 extern int proc_dointvec(struct ctl_table *, int,
71257 void __user *, size_t *, loff_t *);
71258 extern int proc_dointvec_minmax(struct ctl_table *, int,
71259 @@ -115,7 +115,9 @@ struct ctl_table
71260 struct ctl_table_poll *poll;
71261 void *extra1;
71262 void *extra2;
71263 -};
71264 +} __do_const;
71265 +typedef struct ctl_table __no_const ctl_table_no_const;
71266 +typedef struct ctl_table ctl_table;
71267
71268 struct ctl_node {
71269 struct rb_node node;
71270 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
71271 index 381f06d..dc16cc7 100644
71272 --- a/include/linux/sysfs.h
71273 +++ b/include/linux/sysfs.h
71274 @@ -31,7 +31,8 @@ struct attribute {
71275 struct lock_class_key *key;
71276 struct lock_class_key skey;
71277 #endif
71278 -};
71279 +} __do_const;
71280 +typedef struct attribute __no_const attribute_no_const;
71281
71282 /**
71283 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
71284 @@ -59,8 +60,8 @@ struct attribute_group {
71285 umode_t (*is_visible)(struct kobject *,
71286 struct attribute *, int);
71287 struct attribute **attrs;
71288 -};
71289 -
71290 +} __do_const;
71291 +typedef struct attribute_group __no_const attribute_group_no_const;
71292
71293
71294 /**
71295 @@ -107,7 +108,8 @@ struct bin_attribute {
71296 char *, loff_t, size_t);
71297 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
71298 struct vm_area_struct *vma);
71299 -};
71300 +} __do_const;
71301 +typedef struct bin_attribute __no_const bin_attribute_no_const;
71302
71303 /**
71304 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
71305 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
71306 index 7faf933..9b85a0c 100644
71307 --- a/include/linux/sysrq.h
71308 +++ b/include/linux/sysrq.h
71309 @@ -16,6 +16,7 @@
71310
71311 #include <linux/errno.h>
71312 #include <linux/types.h>
71313 +#include <linux/compiler.h>
71314
71315 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
71316 #define SYSRQ_DEFAULT_ENABLE 1
71317 @@ -36,7 +37,7 @@ struct sysrq_key_op {
71318 char *help_msg;
71319 char *action_msg;
71320 int enable_mask;
71321 -};
71322 +} __do_const;
71323
71324 #ifdef CONFIG_MAGIC_SYSRQ
71325
71326 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
71327 index e7e0473..7989295 100644
71328 --- a/include/linux/thread_info.h
71329 +++ b/include/linux/thread_info.h
71330 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
71331 #error "no set_restore_sigmask() provided and default one won't work"
71332 #endif
71333
71334 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
71335 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
71336 +{
71337 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
71338 + if (!__builtin_constant_p(n))
71339 +#endif
71340 + __check_object_size(ptr, n, to_user);
71341 +}
71342 +
71343 #endif /* __KERNEL__ */
71344
71345 #endif /* _LINUX_THREAD_INFO_H */
71346 diff --git a/include/linux/tty.h b/include/linux/tty.h
71347 index 8db1b56..c16a040 100644
71348 --- a/include/linux/tty.h
71349 +++ b/include/linux/tty.h
71350 @@ -194,7 +194,7 @@ struct tty_port {
71351 const struct tty_port_operations *ops; /* Port operations */
71352 spinlock_t lock; /* Lock protecting tty field */
71353 int blocked_open; /* Waiting to open */
71354 - int count; /* Usage count */
71355 + atomic_t count; /* Usage count */
71356 wait_queue_head_t open_wait; /* Open waiters */
71357 wait_queue_head_t close_wait; /* Close waiters */
71358 wait_queue_head_t delta_msr_wait; /* Modem status change */
71359 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
71360 struct tty_struct *tty, struct file *filp);
71361 static inline int tty_port_users(struct tty_port *port)
71362 {
71363 - return port->count + port->blocked_open;
71364 + return atomic_read(&port->count) + port->blocked_open;
71365 }
71366
71367 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
71368 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
71369 index dd976cf..e272742 100644
71370 --- a/include/linux/tty_driver.h
71371 +++ b/include/linux/tty_driver.h
71372 @@ -284,7 +284,7 @@ struct tty_operations {
71373 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
71374 #endif
71375 const struct file_operations *proc_fops;
71376 -};
71377 +} __do_const;
71378
71379 struct tty_driver {
71380 int magic; /* magic number for this structure */
71381 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
71382 index fb79dd8d..07d4773 100644
71383 --- a/include/linux/tty_ldisc.h
71384 +++ b/include/linux/tty_ldisc.h
71385 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
71386
71387 struct module *owner;
71388
71389 - int refcount;
71390 + atomic_t refcount;
71391 };
71392
71393 struct tty_ldisc {
71394 diff --git a/include/linux/types.h b/include/linux/types.h
71395 index 4d118ba..c3ee9bf 100644
71396 --- a/include/linux/types.h
71397 +++ b/include/linux/types.h
71398 @@ -176,10 +176,26 @@ typedef struct {
71399 int counter;
71400 } atomic_t;
71401
71402 +#ifdef CONFIG_PAX_REFCOUNT
71403 +typedef struct {
71404 + int counter;
71405 +} atomic_unchecked_t;
71406 +#else
71407 +typedef atomic_t atomic_unchecked_t;
71408 +#endif
71409 +
71410 #ifdef CONFIG_64BIT
71411 typedef struct {
71412 long counter;
71413 } atomic64_t;
71414 +
71415 +#ifdef CONFIG_PAX_REFCOUNT
71416 +typedef struct {
71417 + long counter;
71418 +} atomic64_unchecked_t;
71419 +#else
71420 +typedef atomic64_t atomic64_unchecked_t;
71421 +#endif
71422 #endif
71423
71424 struct list_head {
71425 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
71426 index 5ca0951..ab496a5 100644
71427 --- a/include/linux/uaccess.h
71428 +++ b/include/linux/uaccess.h
71429 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
71430 long ret; \
71431 mm_segment_t old_fs = get_fs(); \
71432 \
71433 - set_fs(KERNEL_DS); \
71434 pagefault_disable(); \
71435 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
71436 - pagefault_enable(); \
71437 + set_fs(KERNEL_DS); \
71438 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
71439 set_fs(old_fs); \
71440 + pagefault_enable(); \
71441 ret; \
71442 })
71443
71444 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
71445 index 8e522cbc..aa8572d 100644
71446 --- a/include/linux/uidgid.h
71447 +++ b/include/linux/uidgid.h
71448 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
71449
71450 #endif /* CONFIG_USER_NS */
71451
71452 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
71453 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
71454 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
71455 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
71456 +
71457 #endif /* _LINUX_UIDGID_H */
71458 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
71459 index 99c1b4d..562e6f3 100644
71460 --- a/include/linux/unaligned/access_ok.h
71461 +++ b/include/linux/unaligned/access_ok.h
71462 @@ -4,34 +4,34 @@
71463 #include <linux/kernel.h>
71464 #include <asm/byteorder.h>
71465
71466 -static inline u16 get_unaligned_le16(const void *p)
71467 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
71468 {
71469 - return le16_to_cpup((__le16 *)p);
71470 + return le16_to_cpup((const __le16 *)p);
71471 }
71472
71473 -static inline u32 get_unaligned_le32(const void *p)
71474 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
71475 {
71476 - return le32_to_cpup((__le32 *)p);
71477 + return le32_to_cpup((const __le32 *)p);
71478 }
71479
71480 -static inline u64 get_unaligned_le64(const void *p)
71481 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
71482 {
71483 - return le64_to_cpup((__le64 *)p);
71484 + return le64_to_cpup((const __le64 *)p);
71485 }
71486
71487 -static inline u16 get_unaligned_be16(const void *p)
71488 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
71489 {
71490 - return be16_to_cpup((__be16 *)p);
71491 + return be16_to_cpup((const __be16 *)p);
71492 }
71493
71494 -static inline u32 get_unaligned_be32(const void *p)
71495 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
71496 {
71497 - return be32_to_cpup((__be32 *)p);
71498 + return be32_to_cpup((const __be32 *)p);
71499 }
71500
71501 -static inline u64 get_unaligned_be64(const void *p)
71502 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
71503 {
71504 - return be64_to_cpup((__be64 *)p);
71505 + return be64_to_cpup((const __be64 *)p);
71506 }
71507
71508 static inline void put_unaligned_le16(u16 val, void *p)
71509 diff --git a/include/linux/usb.h b/include/linux/usb.h
71510 index 4d22d0f..8d0e8f8 100644
71511 --- a/include/linux/usb.h
71512 +++ b/include/linux/usb.h
71513 @@ -554,7 +554,7 @@ struct usb_device {
71514 int maxchild;
71515
71516 u32 quirks;
71517 - atomic_t urbnum;
71518 + atomic_unchecked_t urbnum;
71519
71520 unsigned long active_duration;
71521
71522 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
71523
71524 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
71525 __u8 request, __u8 requesttype, __u16 value, __u16 index,
71526 - void *data, __u16 size, int timeout);
71527 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
71528 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
71529 void *data, int len, int *actual_length, int timeout);
71530 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
71531 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
71532 index c5d36c6..108f4f9 100644
71533 --- a/include/linux/usb/renesas_usbhs.h
71534 +++ b/include/linux/usb/renesas_usbhs.h
71535 @@ -39,7 +39,7 @@ enum {
71536 */
71537 struct renesas_usbhs_driver_callback {
71538 int (*notify_hotplug)(struct platform_device *pdev);
71539 -};
71540 +} __no_const;
71541
71542 /*
71543 * callback functions for platform
71544 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
71545 index b9bd2e6..4ce0093 100644
71546 --- a/include/linux/user_namespace.h
71547 +++ b/include/linux/user_namespace.h
71548 @@ -21,7 +21,7 @@ struct user_namespace {
71549 struct uid_gid_map uid_map;
71550 struct uid_gid_map gid_map;
71551 struct uid_gid_map projid_map;
71552 - struct kref kref;
71553 + atomic_t count;
71554 struct user_namespace *parent;
71555 kuid_t owner;
71556 kgid_t group;
71557 @@ -35,18 +35,18 @@ extern struct user_namespace init_user_ns;
71558 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
71559 {
71560 if (ns)
71561 - kref_get(&ns->kref);
71562 + atomic_inc(&ns->count);
71563 return ns;
71564 }
71565
71566 extern int create_user_ns(struct cred *new);
71567 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
71568 -extern void free_user_ns(struct kref *kref);
71569 +extern void free_user_ns(struct user_namespace *ns);
71570
71571 static inline void put_user_ns(struct user_namespace *ns)
71572 {
71573 - if (ns)
71574 - kref_put(&ns->kref, free_user_ns);
71575 + if (ns && atomic_dec_and_test(&ns->count))
71576 + free_user_ns(ns);
71577 }
71578
71579 struct seq_operations;
71580 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
71581 index 6f8fbcf..8259001 100644
71582 --- a/include/linux/vermagic.h
71583 +++ b/include/linux/vermagic.h
71584 @@ -25,9 +25,35 @@
71585 #define MODULE_ARCH_VERMAGIC ""
71586 #endif
71587
71588 +#ifdef CONFIG_PAX_REFCOUNT
71589 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
71590 +#else
71591 +#define MODULE_PAX_REFCOUNT ""
71592 +#endif
71593 +
71594 +#ifdef CONSTIFY_PLUGIN
71595 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
71596 +#else
71597 +#define MODULE_CONSTIFY_PLUGIN ""
71598 +#endif
71599 +
71600 +#ifdef STACKLEAK_PLUGIN
71601 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
71602 +#else
71603 +#define MODULE_STACKLEAK_PLUGIN ""
71604 +#endif
71605 +
71606 +#ifdef CONFIG_GRKERNSEC
71607 +#define MODULE_GRSEC "GRSEC "
71608 +#else
71609 +#define MODULE_GRSEC ""
71610 +#endif
71611 +
71612 #define VERMAGIC_STRING \
71613 UTS_RELEASE " " \
71614 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
71615 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
71616 - MODULE_ARCH_VERMAGIC
71617 + MODULE_ARCH_VERMAGIC \
71618 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
71619 + MODULE_GRSEC
71620
71621 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
71622 index 6071e91..ca6a489 100644
71623 --- a/include/linux/vmalloc.h
71624 +++ b/include/linux/vmalloc.h
71625 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
71626 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
71627 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
71628 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
71629 +
71630 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
71631 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
71632 +#endif
71633 +
71634 /* bits [20..32] reserved for arch specific ioremap internals */
71635
71636 /*
71637 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
71638 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
71639 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
71640 unsigned long start, unsigned long end, gfp_t gfp_mask,
71641 - pgprot_t prot, int node, const void *caller);
71642 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
71643 extern void vfree(const void *addr);
71644
71645 extern void *vmap(struct page **pages, unsigned int count,
71646 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
71647 extern void free_vm_area(struct vm_struct *area);
71648
71649 /* for /dev/kmem */
71650 -extern long vread(char *buf, char *addr, unsigned long count);
71651 -extern long vwrite(char *buf, char *addr, unsigned long count);
71652 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
71653 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
71654
71655 /*
71656 * Internals. Dont't use..
71657 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
71658 index a13291f..af51fa3 100644
71659 --- a/include/linux/vmstat.h
71660 +++ b/include/linux/vmstat.h
71661 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
71662 /*
71663 * Zone based page accounting with per cpu differentials.
71664 */
71665 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71666 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71667
71668 static inline void zone_page_state_add(long x, struct zone *zone,
71669 enum zone_stat_item item)
71670 {
71671 - atomic_long_add(x, &zone->vm_stat[item]);
71672 - atomic_long_add(x, &vm_stat[item]);
71673 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
71674 + atomic_long_add_unchecked(x, &vm_stat[item]);
71675 }
71676
71677 static inline unsigned long global_page_state(enum zone_stat_item item)
71678 {
71679 - long x = atomic_long_read(&vm_stat[item]);
71680 + long x = atomic_long_read_unchecked(&vm_stat[item]);
71681 #ifdef CONFIG_SMP
71682 if (x < 0)
71683 x = 0;
71684 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
71685 static inline unsigned long zone_page_state(struct zone *zone,
71686 enum zone_stat_item item)
71687 {
71688 - long x = atomic_long_read(&zone->vm_stat[item]);
71689 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
71690 #ifdef CONFIG_SMP
71691 if (x < 0)
71692 x = 0;
71693 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
71694 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
71695 enum zone_stat_item item)
71696 {
71697 - long x = atomic_long_read(&zone->vm_stat[item]);
71698 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
71699
71700 #ifdef CONFIG_SMP
71701 int cpu;
71702 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
71703
71704 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
71705 {
71706 - atomic_long_inc(&zone->vm_stat[item]);
71707 - atomic_long_inc(&vm_stat[item]);
71708 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
71709 + atomic_long_inc_unchecked(&vm_stat[item]);
71710 }
71711
71712 static inline void __inc_zone_page_state(struct page *page,
71713 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
71714
71715 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
71716 {
71717 - atomic_long_dec(&zone->vm_stat[item]);
71718 - atomic_long_dec(&vm_stat[item]);
71719 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
71720 + atomic_long_dec_unchecked(&vm_stat[item]);
71721 }
71722
71723 static inline void __dec_zone_page_state(struct page *page,
71724 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
71725 index fdbafc6..b7ffd47 100644
71726 --- a/include/linux/xattr.h
71727 +++ b/include/linux/xattr.h
71728 @@ -28,7 +28,7 @@ struct xattr_handler {
71729 size_t size, int handler_flags);
71730 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
71731 size_t size, int flags, int handler_flags);
71732 -};
71733 +} __do_const;
71734
71735 struct xattr {
71736 char *name;
71737 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
71738 index 9c5a6b4..09c9438 100644
71739 --- a/include/linux/zlib.h
71740 +++ b/include/linux/zlib.h
71741 @@ -31,6 +31,7 @@
71742 #define _ZLIB_H
71743
71744 #include <linux/zconf.h>
71745 +#include <linux/compiler.h>
71746
71747 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
71748 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
71749 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
71750
71751 /* basic functions */
71752
71753 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
71754 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
71755 /*
71756 Returns the number of bytes that needs to be allocated for a per-
71757 stream workspace with the specified parameters. A pointer to this
71758 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
71759 index 95d1c91..6798cca 100644
71760 --- a/include/media/v4l2-dev.h
71761 +++ b/include/media/v4l2-dev.h
71762 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
71763 int (*mmap) (struct file *, struct vm_area_struct *);
71764 int (*open) (struct file *);
71765 int (*release) (struct file *);
71766 -};
71767 +} __do_const;
71768
71769 /*
71770 * Newer version of video_device, handled by videodev2.c
71771 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
71772 index 4118ad1..cb7e25f 100644
71773 --- a/include/media/v4l2-ioctl.h
71774 +++ b/include/media/v4l2-ioctl.h
71775 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
71776 bool valid_prio, int cmd, void *arg);
71777 };
71778
71779 -
71780 /* v4l debugging and diagnostics */
71781
71782 /* Debug bitmask flags to be used on V4L2 */
71783 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
71784 index adcbb20..62c2559 100644
71785 --- a/include/net/9p/transport.h
71786 +++ b/include/net/9p/transport.h
71787 @@ -57,7 +57,7 @@ struct p9_trans_module {
71788 int (*cancel) (struct p9_client *, struct p9_req_t *req);
71789 int (*zc_request)(struct p9_client *, struct p9_req_t *,
71790 char *, char *, int , int, int, int);
71791 -};
71792 +} __do_const;
71793
71794 void v9fs_register_trans(struct p9_trans_module *m);
71795 void v9fs_unregister_trans(struct p9_trans_module *m);
71796 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
71797 index 7588ef4..e62d35f 100644
71798 --- a/include/net/bluetooth/l2cap.h
71799 +++ b/include/net/bluetooth/l2cap.h
71800 @@ -552,7 +552,7 @@ struct l2cap_ops {
71801 void (*defer) (struct l2cap_chan *chan);
71802 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
71803 unsigned long len, int nb);
71804 -};
71805 +} __do_const;
71806
71807 struct l2cap_conn {
71808 struct hci_conn *hcon;
71809 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
71810 index 9e5425b..8136ffc 100644
71811 --- a/include/net/caif/cfctrl.h
71812 +++ b/include/net/caif/cfctrl.h
71813 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
71814 void (*radioset_rsp)(void);
71815 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
71816 struct cflayer *client_layer);
71817 -};
71818 +} __no_const;
71819
71820 /* Link Setup Parameters for CAIF-Links. */
71821 struct cfctrl_link_param {
71822 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
71823 struct cfctrl {
71824 struct cfsrvl serv;
71825 struct cfctrl_rsp res;
71826 - atomic_t req_seq_no;
71827 - atomic_t rsp_seq_no;
71828 + atomic_unchecked_t req_seq_no;
71829 + atomic_unchecked_t rsp_seq_no;
71830 struct list_head list;
71831 /* Protects from simultaneous access to first_req list */
71832 spinlock_t info_list_lock;
71833 diff --git a/include/net/flow.h b/include/net/flow.h
71834 index 628e11b..4c475df 100644
71835 --- a/include/net/flow.h
71836 +++ b/include/net/flow.h
71837 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
71838
71839 extern void flow_cache_flush(void);
71840 extern void flow_cache_flush_deferred(void);
71841 -extern atomic_t flow_cache_genid;
71842 +extern atomic_unchecked_t flow_cache_genid;
71843
71844 #endif
71845 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
71846 index bdfbe68..4402ebe 100644
71847 --- a/include/net/genetlink.h
71848 +++ b/include/net/genetlink.h
71849 @@ -118,7 +118,7 @@ struct genl_ops {
71850 struct netlink_callback *cb);
71851 int (*done)(struct netlink_callback *cb);
71852 struct list_head ops_list;
71853 -};
71854 +} __do_const;
71855
71856 extern int genl_register_family(struct genl_family *family);
71857 extern int genl_register_family_with_ops(struct genl_family *family,
71858 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
71859 index e5062c9..48a9a4b 100644
71860 --- a/include/net/gro_cells.h
71861 +++ b/include/net/gro_cells.h
71862 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
71863 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
71864
71865 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
71866 - atomic_long_inc(&dev->rx_dropped);
71867 + atomic_long_inc_unchecked(&dev->rx_dropped);
71868 kfree_skb(skb);
71869 return;
71870 }
71871 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
71872 int i;
71873
71874 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
71875 - gcells->cells = kcalloc(sizeof(struct gro_cell),
71876 - gcells->gro_cells_mask + 1,
71877 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
71878 + sizeof(struct gro_cell),
71879 GFP_KERNEL);
71880 if (!gcells->cells)
71881 return -ENOMEM;
71882 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
71883 index 1832927..ce39aea 100644
71884 --- a/include/net/inet_connection_sock.h
71885 +++ b/include/net/inet_connection_sock.h
71886 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
71887 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
71888 int (*bind_conflict)(const struct sock *sk,
71889 const struct inet_bind_bucket *tb, bool relax);
71890 -};
71891 +} __do_const;
71892
71893 /** inet_connection_sock - INET connection oriented sock
71894 *
71895 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
71896 index 53f464d..ba76aaa 100644
71897 --- a/include/net/inetpeer.h
71898 +++ b/include/net/inetpeer.h
71899 @@ -47,8 +47,8 @@ struct inet_peer {
71900 */
71901 union {
71902 struct {
71903 - atomic_t rid; /* Frag reception counter */
71904 - atomic_t ip_id_count; /* IP ID for the next packet */
71905 + atomic_unchecked_t rid; /* Frag reception counter */
71906 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
71907 };
71908 struct rcu_head rcu;
71909 struct inet_peer *gc_next;
71910 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
71911 more++;
71912 inet_peer_refcheck(p);
71913 do {
71914 - old = atomic_read(&p->ip_id_count);
71915 + old = atomic_read_unchecked(&p->ip_id_count);
71916 new = old + more;
71917 if (!new)
71918 new = 1;
71919 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
71920 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
71921 return new;
71922 }
71923
71924 diff --git a/include/net/ip.h b/include/net/ip.h
71925 index a68f838..74518ab 100644
71926 --- a/include/net/ip.h
71927 +++ b/include/net/ip.h
71928 @@ -202,7 +202,7 @@ extern struct local_ports {
71929 } sysctl_local_ports;
71930 extern void inet_get_local_port_range(int *low, int *high);
71931
71932 -extern unsigned long *sysctl_local_reserved_ports;
71933 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
71934 static inline int inet_is_reserved_local_port(int port)
71935 {
71936 return test_bit(port, sysctl_local_reserved_ports);
71937 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
71938 index e49db91..76a81de 100644
71939 --- a/include/net/ip_fib.h
71940 +++ b/include/net/ip_fib.h
71941 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
71942
71943 #define FIB_RES_SADDR(net, res) \
71944 ((FIB_RES_NH(res).nh_saddr_genid == \
71945 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
71946 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
71947 FIB_RES_NH(res).nh_saddr : \
71948 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
71949 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
71950 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
71951 index 68c69d5..bdab192 100644
71952 --- a/include/net/ip_vs.h
71953 +++ b/include/net/ip_vs.h
71954 @@ -599,7 +599,7 @@ struct ip_vs_conn {
71955 struct ip_vs_conn *control; /* Master control connection */
71956 atomic_t n_control; /* Number of controlled ones */
71957 struct ip_vs_dest *dest; /* real server */
71958 - atomic_t in_pkts; /* incoming packet counter */
71959 + atomic_unchecked_t in_pkts; /* incoming packet counter */
71960
71961 /* packet transmitter for different forwarding methods. If it
71962 mangles the packet, it must return NF_DROP or better NF_STOLEN,
71963 @@ -737,7 +737,7 @@ struct ip_vs_dest {
71964 __be16 port; /* port number of the server */
71965 union nf_inet_addr addr; /* IP address of the server */
71966 volatile unsigned int flags; /* dest status flags */
71967 - atomic_t conn_flags; /* flags to copy to conn */
71968 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
71969 atomic_t weight; /* server weight */
71970
71971 atomic_t refcnt; /* reference counter */
71972 @@ -980,11 +980,11 @@ struct netns_ipvs {
71973 /* ip_vs_lblc */
71974 int sysctl_lblc_expiration;
71975 struct ctl_table_header *lblc_ctl_header;
71976 - struct ctl_table *lblc_ctl_table;
71977 + ctl_table_no_const *lblc_ctl_table;
71978 /* ip_vs_lblcr */
71979 int sysctl_lblcr_expiration;
71980 struct ctl_table_header *lblcr_ctl_header;
71981 - struct ctl_table *lblcr_ctl_table;
71982 + ctl_table_no_const *lblcr_ctl_table;
71983 /* ip_vs_est */
71984 struct list_head est_list; /* estimator list */
71985 spinlock_t est_lock;
71986 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
71987 index 80ffde3..968b0f4 100644
71988 --- a/include/net/irda/ircomm_tty.h
71989 +++ b/include/net/irda/ircomm_tty.h
71990 @@ -35,6 +35,7 @@
71991 #include <linux/termios.h>
71992 #include <linux/timer.h>
71993 #include <linux/tty.h> /* struct tty_struct */
71994 +#include <asm/local.h>
71995
71996 #include <net/irda/irias_object.h>
71997 #include <net/irda/ircomm_core.h>
71998 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
71999 index cc7c197..9f2da2a 100644
72000 --- a/include/net/iucv/af_iucv.h
72001 +++ b/include/net/iucv/af_iucv.h
72002 @@ -141,7 +141,7 @@ struct iucv_sock {
72003 struct iucv_sock_list {
72004 struct hlist_head head;
72005 rwlock_t lock;
72006 - atomic_t autobind_name;
72007 + atomic_unchecked_t autobind_name;
72008 };
72009
72010 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72011 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72012 index df83f69..9b640b8 100644
72013 --- a/include/net/llc_c_ac.h
72014 +++ b/include/net/llc_c_ac.h
72015 @@ -87,7 +87,7 @@
72016 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72017 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72018
72019 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72020 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72021
72022 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72023 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72024 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72025 index 6ca3113..f8026dd 100644
72026 --- a/include/net/llc_c_ev.h
72027 +++ b/include/net/llc_c_ev.h
72028 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72029 return (struct llc_conn_state_ev *)skb->cb;
72030 }
72031
72032 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72033 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72034 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72035 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72036
72037 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72038 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72039 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72040 index 0e79cfb..f46db31 100644
72041 --- a/include/net/llc_c_st.h
72042 +++ b/include/net/llc_c_st.h
72043 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72044 u8 next_state;
72045 llc_conn_ev_qfyr_t *ev_qualifiers;
72046 llc_conn_action_t *ev_actions;
72047 -};
72048 +} __do_const;
72049
72050 struct llc_conn_state {
72051 u8 current_state;
72052 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72053 index 37a3bbd..55a4241 100644
72054 --- a/include/net/llc_s_ac.h
72055 +++ b/include/net/llc_s_ac.h
72056 @@ -23,7 +23,7 @@
72057 #define SAP_ACT_TEST_IND 9
72058
72059 /* All action functions must look like this */
72060 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72061 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72062
72063 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72064 struct sk_buff *skb);
72065 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72066 index 567c681..cd73ac0 100644
72067 --- a/include/net/llc_s_st.h
72068 +++ b/include/net/llc_s_st.h
72069 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72070 llc_sap_ev_t ev;
72071 u8 next_state;
72072 llc_sap_action_t *ev_actions;
72073 -};
72074 +} __do_const;
72075
72076 struct llc_sap_state {
72077 u8 curr_state;
72078 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72079 index ee50c5e..1bc3b1a 100644
72080 --- a/include/net/mac80211.h
72081 +++ b/include/net/mac80211.h
72082 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
72083 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72084 struct dentry *dir);
72085 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72086 -};
72087 +} __do_const;
72088
72089 static inline int rate_supported(struct ieee80211_sta *sta,
72090 enum ieee80211_band band,
72091 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72092 index 0dab173..1b76af0 100644
72093 --- a/include/net/neighbour.h
72094 +++ b/include/net/neighbour.h
72095 @@ -123,7 +123,7 @@ struct neigh_ops {
72096 void (*error_report)(struct neighbour *, struct sk_buff *);
72097 int (*output)(struct neighbour *, struct sk_buff *);
72098 int (*connected_output)(struct neighbour *, struct sk_buff *);
72099 -};
72100 +} __do_const;
72101
72102 struct pneigh_entry {
72103 struct pneigh_entry *next;
72104 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72105 index de644bc..dfbcc4c 100644
72106 --- a/include/net/net_namespace.h
72107 +++ b/include/net/net_namespace.h
72108 @@ -115,7 +115,7 @@ struct net {
72109 #endif
72110 struct netns_ipvs *ipvs;
72111 struct sock *diag_nlsk;
72112 - atomic_t rt_genid;
72113 + atomic_unchecked_t rt_genid;
72114 };
72115
72116 /*
72117 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72118 #define __net_init __init
72119 #define __net_exit __exit_refok
72120 #define __net_initdata __initdata
72121 +#ifdef CONSTIFY_PLUGIN
72122 #define __net_initconst __initconst
72123 +#else
72124 +#define __net_initconst __initdata
72125 +#endif
72126 #endif
72127
72128 struct pernet_operations {
72129 @@ -282,7 +286,7 @@ struct pernet_operations {
72130 void (*exit_batch)(struct list_head *net_exit_list);
72131 int *id;
72132 size_t size;
72133 -};
72134 +} __do_const;
72135
72136 /*
72137 * Use these carefully. If you implement a network device and it
72138 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
72139
72140 static inline int rt_genid(struct net *net)
72141 {
72142 - return atomic_read(&net->rt_genid);
72143 + return atomic_read_unchecked(&net->rt_genid);
72144 }
72145
72146 static inline void rt_genid_bump(struct net *net)
72147 {
72148 - atomic_inc(&net->rt_genid);
72149 + atomic_inc_unchecked(&net->rt_genid);
72150 }
72151
72152 #endif /* __NET_NET_NAMESPACE_H */
72153 diff --git a/include/net/netdma.h b/include/net/netdma.h
72154 index 8ba8ce2..99b7fff 100644
72155 --- a/include/net/netdma.h
72156 +++ b/include/net/netdma.h
72157 @@ -24,7 +24,7 @@
72158 #include <linux/dmaengine.h>
72159 #include <linux/skbuff.h>
72160
72161 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72162 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72163 struct sk_buff *skb, int offset, struct iovec *to,
72164 size_t len, struct dma_pinned_list *pinned_list);
72165
72166 diff --git a/include/net/netlink.h b/include/net/netlink.h
72167 index 9690b0f..87aded7 100644
72168 --- a/include/net/netlink.h
72169 +++ b/include/net/netlink.h
72170 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
72171 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
72172 {
72173 if (mark)
72174 - skb_trim(skb, (unsigned char *) mark - skb->data);
72175 + skb_trim(skb, (const unsigned char *) mark - skb->data);
72176 }
72177
72178 /**
72179 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
72180 index 923cb20..deae816 100644
72181 --- a/include/net/netns/conntrack.h
72182 +++ b/include/net/netns/conntrack.h
72183 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
72184 struct nf_proto_net {
72185 #ifdef CONFIG_SYSCTL
72186 struct ctl_table_header *ctl_table_header;
72187 - struct ctl_table *ctl_table;
72188 + ctl_table_no_const *ctl_table;
72189 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
72190 struct ctl_table_header *ctl_compat_header;
72191 - struct ctl_table *ctl_compat_table;
72192 + ctl_table_no_const *ctl_compat_table;
72193 #endif
72194 #endif
72195 unsigned int users;
72196 @@ -58,7 +58,7 @@ struct nf_ip_net {
72197 struct nf_icmp_net icmpv6;
72198 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
72199 struct ctl_table_header *ctl_table_header;
72200 - struct ctl_table *ctl_table;
72201 + ctl_table_no_const *ctl_table;
72202 #endif
72203 };
72204
72205 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
72206 index 2ae2b83..dbdc85e 100644
72207 --- a/include/net/netns/ipv4.h
72208 +++ b/include/net/netns/ipv4.h
72209 @@ -64,7 +64,7 @@ struct netns_ipv4 {
72210 kgid_t sysctl_ping_group_range[2];
72211 long sysctl_tcp_mem[3];
72212
72213 - atomic_t dev_addr_genid;
72214 + atomic_unchecked_t dev_addr_genid;
72215
72216 #ifdef CONFIG_IP_MROUTE
72217 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
72218 diff --git a/include/net/protocol.h b/include/net/protocol.h
72219 index 047c047..b9dad15 100644
72220 --- a/include/net/protocol.h
72221 +++ b/include/net/protocol.h
72222 @@ -44,7 +44,7 @@ struct net_protocol {
72223 void (*err_handler)(struct sk_buff *skb, u32 info);
72224 unsigned int no_policy:1,
72225 netns_ok:1;
72226 -};
72227 +} __do_const;
72228
72229 #if IS_ENABLED(CONFIG_IPV6)
72230 struct inet6_protocol {
72231 @@ -57,7 +57,7 @@ struct inet6_protocol {
72232 u8 type, u8 code, int offset,
72233 __be32 info);
72234 unsigned int flags; /* INET6_PROTO_xxx */
72235 -};
72236 +} __do_const;
72237
72238 #define INET6_PROTO_NOPOLICY 0x1
72239 #define INET6_PROTO_FINAL 0x2
72240 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
72241 index 5a15fab..d799ea7 100644
72242 --- a/include/net/rtnetlink.h
72243 +++ b/include/net/rtnetlink.h
72244 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
72245 const struct net_device *dev);
72246 unsigned int (*get_num_tx_queues)(void);
72247 unsigned int (*get_num_rx_queues)(void);
72248 -};
72249 +} __do_const;
72250
72251 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
72252 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
72253 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
72254 index 7fdf298..197e9f7 100644
72255 --- a/include/net/sctp/sctp.h
72256 +++ b/include/net/sctp/sctp.h
72257 @@ -330,9 +330,9 @@ do { \
72258
72259 #else /* SCTP_DEBUG */
72260
72261 -#define SCTP_DEBUG_PRINTK(whatever...)
72262 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
72263 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
72264 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
72265 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
72266 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
72267 #define SCTP_ENABLE_DEBUG
72268 #define SCTP_DISABLE_DEBUG
72269 #define SCTP_ASSERT(expr, str, func)
72270 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
72271 index 2a82d13..62a31c2 100644
72272 --- a/include/net/sctp/sm.h
72273 +++ b/include/net/sctp/sm.h
72274 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
72275 typedef struct {
72276 sctp_state_fn_t *fn;
72277 const char *name;
72278 -} sctp_sm_table_entry_t;
72279 +} __do_const sctp_sm_table_entry_t;
72280
72281 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
72282 * currently in use.
72283 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
72284 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
72285
72286 /* Extern declarations for major data structures. */
72287 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72288 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72289
72290
72291 /* Get the size of a DATA chunk payload. */
72292 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
72293 index fdeb85a..1329d95 100644
72294 --- a/include/net/sctp/structs.h
72295 +++ b/include/net/sctp/structs.h
72296 @@ -517,7 +517,7 @@ struct sctp_pf {
72297 struct sctp_association *asoc);
72298 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
72299 struct sctp_af *af;
72300 -};
72301 +} __do_const;
72302
72303
72304 /* Structure to track chunk fragments that have been acked, but peer
72305 diff --git a/include/net/sock.h b/include/net/sock.h
72306 index 25afaa0..8bb0070 100644
72307 --- a/include/net/sock.h
72308 +++ b/include/net/sock.h
72309 @@ -322,7 +322,7 @@ struct sock {
72310 #ifdef CONFIG_RPS
72311 __u32 sk_rxhash;
72312 #endif
72313 - atomic_t sk_drops;
72314 + atomic_unchecked_t sk_drops;
72315 int sk_rcvbuf;
72316
72317 struct sk_filter __rcu *sk_filter;
72318 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
72319 }
72320
72321 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
72322 - char __user *from, char *to,
72323 + char __user *from, unsigned char *to,
72324 int copy, int offset)
72325 {
72326 if (skb->ip_summed == CHECKSUM_NONE) {
72327 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
72328 }
72329 }
72330
72331 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72332 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72333
72334 /**
72335 * sk_page_frag - return an appropriate page_frag
72336 diff --git a/include/net/tcp.h b/include/net/tcp.h
72337 index aed42c7..43890c6 100644
72338 --- a/include/net/tcp.h
72339 +++ b/include/net/tcp.h
72340 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
72341 extern void tcp_xmit_retransmit_queue(struct sock *);
72342 extern void tcp_simple_retransmit(struct sock *);
72343 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
72344 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72345 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72346
72347 extern void tcp_send_probe0(struct sock *);
72348 extern void tcp_send_partial(struct sock *);
72349 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
72350 struct inet6_skb_parm h6;
72351 #endif
72352 } header; /* For incoming frames */
72353 - __u32 seq; /* Starting sequence number */
72354 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
72355 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
72356 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
72357 __u32 when; /* used to compute rtt's */
72358 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
72359
72360 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
72361
72362 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
72363 /* 1 byte hole */
72364 - __u32 ack_seq; /* Sequence number ACK'd */
72365 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
72366 };
72367
72368 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
72369 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
72370 index 63445ed..d6fc34f 100644
72371 --- a/include/net/xfrm.h
72372 +++ b/include/net/xfrm.h
72373 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
72374 struct net_device *dev,
72375 const struct flowi *fl);
72376 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
72377 -};
72378 +} __do_const;
72379
72380 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
72381 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
72382 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
72383 struct sk_buff *skb);
72384 int (*transport_finish)(struct sk_buff *skb,
72385 int async);
72386 -};
72387 +} __do_const;
72388
72389 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
72390 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
72391 @@ -423,7 +423,7 @@ struct xfrm_mode {
72392 struct module *owner;
72393 unsigned int encap;
72394 int flags;
72395 -};
72396 +} __do_const;
72397
72398 /* Flags for xfrm_mode. */
72399 enum {
72400 @@ -514,7 +514,7 @@ struct xfrm_policy {
72401 struct timer_list timer;
72402
72403 struct flow_cache_object flo;
72404 - atomic_t genid;
72405 + atomic_unchecked_t genid;
72406 u32 priority;
72407 u32 index;
72408 struct xfrm_mark mark;
72409 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
72410 index 1a046b1..ee0bef0 100644
72411 --- a/include/rdma/iw_cm.h
72412 +++ b/include/rdma/iw_cm.h
72413 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
72414 int backlog);
72415
72416 int (*destroy_listen)(struct iw_cm_id *cm_id);
72417 -};
72418 +} __no_const;
72419
72420 /**
72421 * iw_create_cm_id - Create an IW CM identifier.
72422 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
72423 index 399162b..b337f1a 100644
72424 --- a/include/scsi/libfc.h
72425 +++ b/include/scsi/libfc.h
72426 @@ -762,6 +762,7 @@ struct libfc_function_template {
72427 */
72428 void (*disc_stop_final) (struct fc_lport *);
72429 };
72430 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
72431
72432 /**
72433 * struct fc_disc - Discovery context
72434 @@ -866,7 +867,7 @@ struct fc_lport {
72435 struct fc_vport *vport;
72436
72437 /* Operational Information */
72438 - struct libfc_function_template tt;
72439 + libfc_function_template_no_const tt;
72440 u8 link_up;
72441 u8 qfull;
72442 enum fc_lport_state state;
72443 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
72444 index e65c62e..aa2e5a2 100644
72445 --- a/include/scsi/scsi_device.h
72446 +++ b/include/scsi/scsi_device.h
72447 @@ -170,9 +170,9 @@ struct scsi_device {
72448 unsigned int max_device_blocked; /* what device_blocked counts down from */
72449 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
72450
72451 - atomic_t iorequest_cnt;
72452 - atomic_t iodone_cnt;
72453 - atomic_t ioerr_cnt;
72454 + atomic_unchecked_t iorequest_cnt;
72455 + atomic_unchecked_t iodone_cnt;
72456 + atomic_unchecked_t ioerr_cnt;
72457
72458 struct device sdev_gendev,
72459 sdev_dev;
72460 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
72461 index b797e8f..8e2c3aa 100644
72462 --- a/include/scsi/scsi_transport_fc.h
72463 +++ b/include/scsi/scsi_transport_fc.h
72464 @@ -751,7 +751,8 @@ struct fc_function_template {
72465 unsigned long show_host_system_hostname:1;
72466
72467 unsigned long disable_target_scan:1;
72468 -};
72469 +} __do_const;
72470 +typedef struct fc_function_template __no_const fc_function_template_no_const;
72471
72472
72473 /**
72474 diff --git a/include/sound/soc.h b/include/sound/soc.h
72475 index bc56738..a4be132 100644
72476 --- a/include/sound/soc.h
72477 +++ b/include/sound/soc.h
72478 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
72479 /* probe ordering - for components with runtime dependencies */
72480 int probe_order;
72481 int remove_order;
72482 -};
72483 +} __do_const;
72484
72485 /* SoC platform interface */
72486 struct snd_soc_platform_driver {
72487 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
72488 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
72489 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
72490 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
72491 -};
72492 +} __do_const;
72493
72494 struct snd_soc_platform {
72495 const char *name;
72496 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
72497 index 663e34a..91b306a 100644
72498 --- a/include/target/target_core_base.h
72499 +++ b/include/target/target_core_base.h
72500 @@ -654,7 +654,7 @@ struct se_device {
72501 spinlock_t stats_lock;
72502 /* Active commands on this virtual SE device */
72503 atomic_t simple_cmds;
72504 - atomic_t dev_ordered_id;
72505 + atomic_unchecked_t dev_ordered_id;
72506 atomic_t dev_ordered_sync;
72507 atomic_t dev_qf_count;
72508 int export_count;
72509 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
72510 new file mode 100644
72511 index 0000000..fb634b7
72512 --- /dev/null
72513 +++ b/include/trace/events/fs.h
72514 @@ -0,0 +1,53 @@
72515 +#undef TRACE_SYSTEM
72516 +#define TRACE_SYSTEM fs
72517 +
72518 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
72519 +#define _TRACE_FS_H
72520 +
72521 +#include <linux/fs.h>
72522 +#include <linux/tracepoint.h>
72523 +
72524 +TRACE_EVENT(do_sys_open,
72525 +
72526 + TP_PROTO(const char *filename, int flags, int mode),
72527 +
72528 + TP_ARGS(filename, flags, mode),
72529 +
72530 + TP_STRUCT__entry(
72531 + __string( filename, filename )
72532 + __field( int, flags )
72533 + __field( int, mode )
72534 + ),
72535 +
72536 + TP_fast_assign(
72537 + __assign_str(filename, filename);
72538 + __entry->flags = flags;
72539 + __entry->mode = mode;
72540 + ),
72541 +
72542 + TP_printk("\"%s\" %x %o",
72543 + __get_str(filename), __entry->flags, __entry->mode)
72544 +);
72545 +
72546 +TRACE_EVENT(open_exec,
72547 +
72548 + TP_PROTO(const char *filename),
72549 +
72550 + TP_ARGS(filename),
72551 +
72552 + TP_STRUCT__entry(
72553 + __string( filename, filename )
72554 + ),
72555 +
72556 + TP_fast_assign(
72557 + __assign_str(filename, filename);
72558 + ),
72559 +
72560 + TP_printk("\"%s\"",
72561 + __get_str(filename))
72562 +);
72563 +
72564 +#endif /* _TRACE_FS_H */
72565 +
72566 +/* This part must be outside protection */
72567 +#include <trace/define_trace.h>
72568 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
72569 index 1c09820..7f5ec79 100644
72570 --- a/include/trace/events/irq.h
72571 +++ b/include/trace/events/irq.h
72572 @@ -36,7 +36,7 @@ struct softirq_action;
72573 */
72574 TRACE_EVENT(irq_handler_entry,
72575
72576 - TP_PROTO(int irq, struct irqaction *action),
72577 + TP_PROTO(int irq, const struct irqaction *action),
72578
72579 TP_ARGS(irq, action),
72580
72581 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
72582 */
72583 TRACE_EVENT(irq_handler_exit,
72584
72585 - TP_PROTO(int irq, struct irqaction *action, int ret),
72586 + TP_PROTO(int irq, const struct irqaction *action, int ret),
72587
72588 TP_ARGS(irq, action, ret),
72589
72590 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
72591 index 7caf44c..23c6f27 100644
72592 --- a/include/uapi/linux/a.out.h
72593 +++ b/include/uapi/linux/a.out.h
72594 @@ -39,6 +39,14 @@ enum machine_type {
72595 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
72596 };
72597
72598 +/* Constants for the N_FLAGS field */
72599 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72600 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
72601 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
72602 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
72603 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72604 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72605 +
72606 #if !defined (N_MAGIC)
72607 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
72608 #endif
72609 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
72610 index d876736..ccce5c0 100644
72611 --- a/include/uapi/linux/byteorder/little_endian.h
72612 +++ b/include/uapi/linux/byteorder/little_endian.h
72613 @@ -42,51 +42,51 @@
72614
72615 static inline __le64 __cpu_to_le64p(const __u64 *p)
72616 {
72617 - return (__force __le64)*p;
72618 + return (__force const __le64)*p;
72619 }
72620 -static inline __u64 __le64_to_cpup(const __le64 *p)
72621 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
72622 {
72623 - return (__force __u64)*p;
72624 + return (__force const __u64)*p;
72625 }
72626 static inline __le32 __cpu_to_le32p(const __u32 *p)
72627 {
72628 - return (__force __le32)*p;
72629 + return (__force const __le32)*p;
72630 }
72631 static inline __u32 __le32_to_cpup(const __le32 *p)
72632 {
72633 - return (__force __u32)*p;
72634 + return (__force const __u32)*p;
72635 }
72636 static inline __le16 __cpu_to_le16p(const __u16 *p)
72637 {
72638 - return (__force __le16)*p;
72639 + return (__force const __le16)*p;
72640 }
72641 static inline __u16 __le16_to_cpup(const __le16 *p)
72642 {
72643 - return (__force __u16)*p;
72644 + return (__force const __u16)*p;
72645 }
72646 static inline __be64 __cpu_to_be64p(const __u64 *p)
72647 {
72648 - return (__force __be64)__swab64p(p);
72649 + return (__force const __be64)__swab64p(p);
72650 }
72651 static inline __u64 __be64_to_cpup(const __be64 *p)
72652 {
72653 - return __swab64p((__u64 *)p);
72654 + return __swab64p((const __u64 *)p);
72655 }
72656 static inline __be32 __cpu_to_be32p(const __u32 *p)
72657 {
72658 - return (__force __be32)__swab32p(p);
72659 + return (__force const __be32)__swab32p(p);
72660 }
72661 -static inline __u32 __be32_to_cpup(const __be32 *p)
72662 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
72663 {
72664 - return __swab32p((__u32 *)p);
72665 + return __swab32p((const __u32 *)p);
72666 }
72667 static inline __be16 __cpu_to_be16p(const __u16 *p)
72668 {
72669 - return (__force __be16)__swab16p(p);
72670 + return (__force const __be16)__swab16p(p);
72671 }
72672 static inline __u16 __be16_to_cpup(const __be16 *p)
72673 {
72674 - return __swab16p((__u16 *)p);
72675 + return __swab16p((const __u16 *)p);
72676 }
72677 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
72678 #define __le64_to_cpus(x) do { (void)(x); } while (0)
72679 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
72680 index 126a817..d522bd1 100644
72681 --- a/include/uapi/linux/elf.h
72682 +++ b/include/uapi/linux/elf.h
72683 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
72684 #define PT_GNU_EH_FRAME 0x6474e550
72685
72686 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
72687 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
72688 +
72689 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
72690 +
72691 +/* Constants for the e_flags field */
72692 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72693 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
72694 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
72695 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
72696 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72697 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72698
72699 /*
72700 * Extended Numbering
72701 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
72702 #define DT_DEBUG 21
72703 #define DT_TEXTREL 22
72704 #define DT_JMPREL 23
72705 +#define DT_FLAGS 30
72706 + #define DF_TEXTREL 0x00000004
72707 #define DT_ENCODING 32
72708 #define OLD_DT_LOOS 0x60000000
72709 #define DT_LOOS 0x6000000d
72710 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
72711 #define PF_W 0x2
72712 #define PF_X 0x1
72713
72714 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
72715 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
72716 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
72717 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
72718 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
72719 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
72720 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
72721 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
72722 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
72723 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
72724 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
72725 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
72726 +
72727 typedef struct elf32_phdr{
72728 Elf32_Word p_type;
72729 Elf32_Off p_offset;
72730 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
72731 #define EI_OSABI 7
72732 #define EI_PAD 8
72733
72734 +#define EI_PAX 14
72735 +
72736 #define ELFMAG0 0x7f /* EI_MAG */
72737 #define ELFMAG1 'E'
72738 #define ELFMAG2 'L'
72739 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
72740 index aa169c4..6a2771d 100644
72741 --- a/include/uapi/linux/personality.h
72742 +++ b/include/uapi/linux/personality.h
72743 @@ -30,6 +30,7 @@ enum {
72744 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
72745 ADDR_NO_RANDOMIZE | \
72746 ADDR_COMPAT_LAYOUT | \
72747 + ADDR_LIMIT_3GB | \
72748 MMAP_PAGE_ZERO)
72749
72750 /*
72751 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
72752 index 7530e74..e714828 100644
72753 --- a/include/uapi/linux/screen_info.h
72754 +++ b/include/uapi/linux/screen_info.h
72755 @@ -43,7 +43,8 @@ struct screen_info {
72756 __u16 pages; /* 0x32 */
72757 __u16 vesa_attributes; /* 0x34 */
72758 __u32 capabilities; /* 0x36 */
72759 - __u8 _reserved[6]; /* 0x3a */
72760 + __u16 vesapm_size; /* 0x3a */
72761 + __u8 _reserved[4]; /* 0x3c */
72762 } __attribute__((packed));
72763
72764 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
72765 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
72766 index 0e011eb..82681b1 100644
72767 --- a/include/uapi/linux/swab.h
72768 +++ b/include/uapi/linux/swab.h
72769 @@ -43,7 +43,7 @@
72770 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
72771 */
72772
72773 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
72774 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
72775 {
72776 #ifdef __HAVE_BUILTIN_BSWAP16__
72777 return __builtin_bswap16(val);
72778 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
72779 #endif
72780 }
72781
72782 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
72783 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
72784 {
72785 #ifdef __HAVE_BUILTIN_BSWAP32__
72786 return __builtin_bswap32(val);
72787 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
72788 #endif
72789 }
72790
72791 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
72792 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
72793 {
72794 #ifdef __HAVE_BUILTIN_BSWAP64__
72795 return __builtin_bswap64(val);
72796 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
72797 index 6d67213..8dab561 100644
72798 --- a/include/uapi/linux/sysctl.h
72799 +++ b/include/uapi/linux/sysctl.h
72800 @@ -155,7 +155,11 @@ enum
72801 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
72802 };
72803
72804 -
72805 +#ifdef CONFIG_PAX_SOFTMODE
72806 +enum {
72807 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
72808 +};
72809 +#endif
72810
72811 /* CTL_VM names: */
72812 enum
72813 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
72814 index 26607bd..588b65f 100644
72815 --- a/include/uapi/linux/xattr.h
72816 +++ b/include/uapi/linux/xattr.h
72817 @@ -60,5 +60,9 @@
72818 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
72819 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
72820
72821 +/* User namespace */
72822 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
72823 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
72824 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
72825
72826 #endif /* _UAPI_LINUX_XATTR_H */
72827 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
72828 index f9466fa..f4e2b81 100644
72829 --- a/include/video/udlfb.h
72830 +++ b/include/video/udlfb.h
72831 @@ -53,10 +53,10 @@ struct dlfb_data {
72832 u32 pseudo_palette[256];
72833 int blank_mode; /*one of FB_BLANK_ */
72834 /* blit-only rendering path metrics, exposed through sysfs */
72835 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
72836 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
72837 - atomic_t bytes_sent; /* to usb, after compression including overhead */
72838 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
72839 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
72840 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
72841 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
72842 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
72843 };
72844
72845 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
72846 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
72847 index 0993a22..32ba2fe 100644
72848 --- a/include/video/uvesafb.h
72849 +++ b/include/video/uvesafb.h
72850 @@ -177,6 +177,7 @@ struct uvesafb_par {
72851 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
72852 u8 pmi_setpal; /* PMI for palette changes */
72853 u16 *pmi_base; /* protected mode interface location */
72854 + u8 *pmi_code; /* protected mode code location */
72855 void *pmi_start;
72856 void *pmi_pal;
72857 u8 *vbe_state_orig; /*
72858 diff --git a/init/Kconfig b/init/Kconfig
72859 index be8b7f5..1eeca9b 100644
72860 --- a/init/Kconfig
72861 +++ b/init/Kconfig
72862 @@ -990,6 +990,7 @@ endif # CGROUPS
72863
72864 config CHECKPOINT_RESTORE
72865 bool "Checkpoint/restore support" if EXPERT
72866 + depends on !GRKERNSEC
72867 default n
72868 help
72869 Enables additional kernel features in a sake of checkpoint/restore.
72870 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
72871
72872 config COMPAT_BRK
72873 bool "Disable heap randomization"
72874 - default y
72875 + default n
72876 help
72877 Randomizing heap placement makes heap exploits harder, but it
72878 also breaks ancient binaries (including anything libc5 based).
72879 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
72880 config STOP_MACHINE
72881 bool
72882 default y
72883 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
72884 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
72885 help
72886 Need stop_machine() primitive.
72887
72888 diff --git a/init/Makefile b/init/Makefile
72889 index 7bc47ee..6da2dc7 100644
72890 --- a/init/Makefile
72891 +++ b/init/Makefile
72892 @@ -2,6 +2,9 @@
72893 # Makefile for the linux kernel.
72894 #
72895
72896 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
72897 +asflags-y := $(GCC_PLUGINS_AFLAGS)
72898 +
72899 obj-y := main.o version.o mounts.o
72900 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
72901 obj-y += noinitramfs.o
72902 diff --git a/init/do_mounts.c b/init/do_mounts.c
72903 index 1d1b634..a1c810f 100644
72904 --- a/init/do_mounts.c
72905 +++ b/init/do_mounts.c
72906 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
72907 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
72908 {
72909 struct super_block *s;
72910 - int err = sys_mount(name, "/root", fs, flags, data);
72911 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
72912 if (err)
72913 return err;
72914
72915 - sys_chdir("/root");
72916 + sys_chdir((const char __force_user *)"/root");
72917 s = current->fs->pwd.dentry->d_sb;
72918 ROOT_DEV = s->s_dev;
72919 printk(KERN_INFO
72920 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
72921 va_start(args, fmt);
72922 vsprintf(buf, fmt, args);
72923 va_end(args);
72924 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
72925 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
72926 if (fd >= 0) {
72927 sys_ioctl(fd, FDEJECT, 0);
72928 sys_close(fd);
72929 }
72930 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
72931 - fd = sys_open("/dev/console", O_RDWR, 0);
72932 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
72933 if (fd >= 0) {
72934 sys_ioctl(fd, TCGETS, (long)&termios);
72935 termios.c_lflag &= ~ICANON;
72936 sys_ioctl(fd, TCSETSF, (long)&termios);
72937 - sys_read(fd, &c, 1);
72938 + sys_read(fd, (char __user *)&c, 1);
72939 termios.c_lflag |= ICANON;
72940 sys_ioctl(fd, TCSETSF, (long)&termios);
72941 sys_close(fd);
72942 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
72943 mount_root();
72944 out:
72945 devtmpfs_mount("dev");
72946 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
72947 - sys_chroot(".");
72948 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
72949 + sys_chroot((const char __force_user *)".");
72950 }
72951 diff --git a/init/do_mounts.h b/init/do_mounts.h
72952 index f5b978a..69dbfe8 100644
72953 --- a/init/do_mounts.h
72954 +++ b/init/do_mounts.h
72955 @@ -15,15 +15,15 @@ extern int root_mountflags;
72956
72957 static inline int create_dev(char *name, dev_t dev)
72958 {
72959 - sys_unlink(name);
72960 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
72961 + sys_unlink((char __force_user *)name);
72962 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
72963 }
72964
72965 #if BITS_PER_LONG == 32
72966 static inline u32 bstat(char *name)
72967 {
72968 struct stat64 stat;
72969 - if (sys_stat64(name, &stat) != 0)
72970 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
72971 return 0;
72972 if (!S_ISBLK(stat.st_mode))
72973 return 0;
72974 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
72975 static inline u32 bstat(char *name)
72976 {
72977 struct stat stat;
72978 - if (sys_newstat(name, &stat) != 0)
72979 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
72980 return 0;
72981 if (!S_ISBLK(stat.st_mode))
72982 return 0;
72983 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
72984 index f9acf71..1e19144 100644
72985 --- a/init/do_mounts_initrd.c
72986 +++ b/init/do_mounts_initrd.c
72987 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
72988 create_dev("/dev/root.old", Root_RAM0);
72989 /* mount initrd on rootfs' /root */
72990 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
72991 - sys_mkdir("/old", 0700);
72992 - sys_chdir("/old");
72993 + sys_mkdir((const char __force_user *)"/old", 0700);
72994 + sys_chdir((const char __force_user *)"/old");
72995
72996 /*
72997 * In case that a resume from disk is carried out by linuxrc or one of
72998 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
72999 current->flags &= ~PF_FREEZER_SKIP;
73000
73001 /* move initrd to rootfs' /old */
73002 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73003 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73004 /* switch root and cwd back to / of rootfs */
73005 - sys_chroot("..");
73006 + sys_chroot((const char __force_user *)"..");
73007
73008 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73009 - sys_chdir("/old");
73010 + sys_chdir((const char __force_user *)"/old");
73011 return;
73012 }
73013
73014 - sys_chdir("/");
73015 + sys_chdir((const char __force_user *)"/");
73016 ROOT_DEV = new_decode_dev(real_root_dev);
73017 mount_root();
73018
73019 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73020 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73021 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73022 if (!error)
73023 printk("okay\n");
73024 else {
73025 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73026 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73027 if (error == -ENOENT)
73028 printk("/initrd does not exist. Ignored.\n");
73029 else
73030 printk("failed\n");
73031 printk(KERN_NOTICE "Unmounting old root\n");
73032 - sys_umount("/old", MNT_DETACH);
73033 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73034 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73035 if (fd < 0) {
73036 error = fd;
73037 @@ -120,11 +120,11 @@ int __init initrd_load(void)
73038 * mounted in the normal path.
73039 */
73040 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73041 - sys_unlink("/initrd.image");
73042 + sys_unlink((const char __force_user *)"/initrd.image");
73043 handle_initrd();
73044 return 1;
73045 }
73046 }
73047 - sys_unlink("/initrd.image");
73048 + sys_unlink((const char __force_user *)"/initrd.image");
73049 return 0;
73050 }
73051 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73052 index 8cb6db5..d729f50 100644
73053 --- a/init/do_mounts_md.c
73054 +++ b/init/do_mounts_md.c
73055 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73056 partitioned ? "_d" : "", minor,
73057 md_setup_args[ent].device_names);
73058
73059 - fd = sys_open(name, 0, 0);
73060 + fd = sys_open((char __force_user *)name, 0, 0);
73061 if (fd < 0) {
73062 printk(KERN_ERR "md: open failed - cannot start "
73063 "array %s\n", name);
73064 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73065 * array without it
73066 */
73067 sys_close(fd);
73068 - fd = sys_open(name, 0, 0);
73069 + fd = sys_open((char __force_user *)name, 0, 0);
73070 sys_ioctl(fd, BLKRRPART, 0);
73071 }
73072 sys_close(fd);
73073 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73074
73075 wait_for_device_probe();
73076
73077 - fd = sys_open("/dev/md0", 0, 0);
73078 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73079 if (fd >= 0) {
73080 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73081 sys_close(fd);
73082 diff --git a/init/init_task.c b/init/init_task.c
73083 index 8b2f399..f0797c9 100644
73084 --- a/init/init_task.c
73085 +++ b/init/init_task.c
73086 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
73087 * Initial thread structure. Alignment of this is handled by a special
73088 * linker map entry.
73089 */
73090 +#ifdef CONFIG_X86
73091 +union thread_union init_thread_union __init_task_data;
73092 +#else
73093 union thread_union init_thread_union __init_task_data =
73094 { INIT_THREAD_INFO(init_task) };
73095 +#endif
73096 diff --git a/init/initramfs.c b/init/initramfs.c
73097 index 84c6bf1..8899338 100644
73098 --- a/init/initramfs.c
73099 +++ b/init/initramfs.c
73100 @@ -84,7 +84,7 @@ static void __init free_hash(void)
73101 }
73102 }
73103
73104 -static long __init do_utime(char *filename, time_t mtime)
73105 +static long __init do_utime(char __force_user *filename, time_t mtime)
73106 {
73107 struct timespec t[2];
73108
73109 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
73110 struct dir_entry *de, *tmp;
73111 list_for_each_entry_safe(de, tmp, &dir_list, list) {
73112 list_del(&de->list);
73113 - do_utime(de->name, de->mtime);
73114 + do_utime((char __force_user *)de->name, de->mtime);
73115 kfree(de->name);
73116 kfree(de);
73117 }
73118 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
73119 if (nlink >= 2) {
73120 char *old = find_link(major, minor, ino, mode, collected);
73121 if (old)
73122 - return (sys_link(old, collected) < 0) ? -1 : 1;
73123 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
73124 }
73125 return 0;
73126 }
73127 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
73128 {
73129 struct stat st;
73130
73131 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
73132 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
73133 if (S_ISDIR(st.st_mode))
73134 - sys_rmdir(path);
73135 + sys_rmdir((char __force_user *)path);
73136 else
73137 - sys_unlink(path);
73138 + sys_unlink((char __force_user *)path);
73139 }
73140 }
73141
73142 @@ -315,7 +315,7 @@ static int __init do_name(void)
73143 int openflags = O_WRONLY|O_CREAT;
73144 if (ml != 1)
73145 openflags |= O_TRUNC;
73146 - wfd = sys_open(collected, openflags, mode);
73147 + wfd = sys_open((char __force_user *)collected, openflags, mode);
73148
73149 if (wfd >= 0) {
73150 sys_fchown(wfd, uid, gid);
73151 @@ -327,17 +327,17 @@ static int __init do_name(void)
73152 }
73153 }
73154 } else if (S_ISDIR(mode)) {
73155 - sys_mkdir(collected, mode);
73156 - sys_chown(collected, uid, gid);
73157 - sys_chmod(collected, mode);
73158 + sys_mkdir((char __force_user *)collected, mode);
73159 + sys_chown((char __force_user *)collected, uid, gid);
73160 + sys_chmod((char __force_user *)collected, mode);
73161 dir_add(collected, mtime);
73162 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
73163 S_ISFIFO(mode) || S_ISSOCK(mode)) {
73164 if (maybe_link() == 0) {
73165 - sys_mknod(collected, mode, rdev);
73166 - sys_chown(collected, uid, gid);
73167 - sys_chmod(collected, mode);
73168 - do_utime(collected, mtime);
73169 + sys_mknod((char __force_user *)collected, mode, rdev);
73170 + sys_chown((char __force_user *)collected, uid, gid);
73171 + sys_chmod((char __force_user *)collected, mode);
73172 + do_utime((char __force_user *)collected, mtime);
73173 }
73174 }
73175 return 0;
73176 @@ -346,15 +346,15 @@ static int __init do_name(void)
73177 static int __init do_copy(void)
73178 {
73179 if (count >= body_len) {
73180 - sys_write(wfd, victim, body_len);
73181 + sys_write(wfd, (char __force_user *)victim, body_len);
73182 sys_close(wfd);
73183 - do_utime(vcollected, mtime);
73184 + do_utime((char __force_user *)vcollected, mtime);
73185 kfree(vcollected);
73186 eat(body_len);
73187 state = SkipIt;
73188 return 0;
73189 } else {
73190 - sys_write(wfd, victim, count);
73191 + sys_write(wfd, (char __force_user *)victim, count);
73192 body_len -= count;
73193 eat(count);
73194 return 1;
73195 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
73196 {
73197 collected[N_ALIGN(name_len) + body_len] = '\0';
73198 clean_path(collected, 0);
73199 - sys_symlink(collected + N_ALIGN(name_len), collected);
73200 - sys_lchown(collected, uid, gid);
73201 - do_utime(collected, mtime);
73202 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
73203 + sys_lchown((char __force_user *)collected, uid, gid);
73204 + do_utime((char __force_user *)collected, mtime);
73205 state = SkipIt;
73206 next_state = Reset;
73207 return 0;
73208 diff --git a/init/main.c b/init/main.c
73209 index cee4b5c..360e10a 100644
73210 --- a/init/main.c
73211 +++ b/init/main.c
73212 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
73213 extern void tc_init(void);
73214 #endif
73215
73216 +extern void grsecurity_init(void);
73217 +
73218 /*
73219 * Debug helper: via this flag we know that we are in 'early bootup code'
73220 * where only the boot processor is running with IRQ disabled. This means
73221 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
73222
73223 __setup("reset_devices", set_reset_devices);
73224
73225 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
73226 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
73227 +static int __init setup_grsec_proc_gid(char *str)
73228 +{
73229 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
73230 + return 1;
73231 +}
73232 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
73233 +#endif
73234 +
73235 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
73236 +extern char pax_enter_kernel_user[];
73237 +extern char pax_exit_kernel_user[];
73238 +extern pgdval_t clone_pgd_mask;
73239 +#endif
73240 +
73241 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
73242 +static int __init setup_pax_nouderef(char *str)
73243 +{
73244 +#ifdef CONFIG_X86_32
73245 + unsigned int cpu;
73246 + struct desc_struct *gdt;
73247 +
73248 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
73249 + gdt = get_cpu_gdt_table(cpu);
73250 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
73251 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
73252 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
73253 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
73254 + }
73255 + loadsegment(ds, __KERNEL_DS);
73256 + loadsegment(es, __KERNEL_DS);
73257 + loadsegment(ss, __KERNEL_DS);
73258 +#else
73259 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
73260 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
73261 + clone_pgd_mask = ~(pgdval_t)0UL;
73262 +#endif
73263 +
73264 + return 0;
73265 +}
73266 +early_param("pax_nouderef", setup_pax_nouderef);
73267 +#endif
73268 +
73269 +#ifdef CONFIG_PAX_SOFTMODE
73270 +int pax_softmode;
73271 +
73272 +static int __init setup_pax_softmode(char *str)
73273 +{
73274 + get_option(&str, &pax_softmode);
73275 + return 1;
73276 +}
73277 +__setup("pax_softmode=", setup_pax_softmode);
73278 +#endif
73279 +
73280 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
73281 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
73282 static const char *panic_later, *panic_param;
73283 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
73284 {
73285 int count = preempt_count();
73286 int ret;
73287 + const char *msg1 = "", *msg2 = "";
73288
73289 if (initcall_debug)
73290 ret = do_one_initcall_debug(fn);
73291 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
73292 sprintf(msgbuf, "error code %d ", ret);
73293
73294 if (preempt_count() != count) {
73295 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
73296 + msg1 = " preemption imbalance";
73297 preempt_count() = count;
73298 }
73299 if (irqs_disabled()) {
73300 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
73301 + msg2 = " disabled interrupts";
73302 local_irq_enable();
73303 }
73304 - if (msgbuf[0]) {
73305 - printk("initcall %pF returned with %s\n", fn, msgbuf);
73306 + if (msgbuf[0] || *msg1 || *msg2) {
73307 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
73308 }
73309
73310 return ret;
73311 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
73312 level, level,
73313 &repair_env_string);
73314
73315 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
73316 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
73317 do_one_initcall(*fn);
73318 +
73319 +#ifdef LATENT_ENTROPY_PLUGIN
73320 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73321 +#endif
73322 +
73323 + }
73324 }
73325
73326 static void __init do_initcalls(void)
73327 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
73328 {
73329 initcall_t *fn;
73330
73331 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
73332 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
73333 do_one_initcall(*fn);
73334 +
73335 +#ifdef LATENT_ENTROPY_PLUGIN
73336 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73337 +#endif
73338 +
73339 + }
73340 }
73341
73342 static int run_init_process(const char *init_filename)
73343 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
73344 do_basic_setup();
73345
73346 /* Open the /dev/console on the rootfs, this should never fail */
73347 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
73348 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
73349 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
73350
73351 (void) sys_dup(0);
73352 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
73353 if (!ramdisk_execute_command)
73354 ramdisk_execute_command = "/init";
73355
73356 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
73357 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
73358 ramdisk_execute_command = NULL;
73359 prepare_namespace();
73360 }
73361
73362 + grsecurity_init();
73363 +
73364 /*
73365 * Ok, we have completed the initial bootup, and
73366 * we're essentially up and running. Get rid of the
73367 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
73368 index 130dfec..cc88451 100644
73369 --- a/ipc/ipc_sysctl.c
73370 +++ b/ipc/ipc_sysctl.c
73371 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
73372 static int proc_ipc_dointvec(ctl_table *table, int write,
73373 void __user *buffer, size_t *lenp, loff_t *ppos)
73374 {
73375 - struct ctl_table ipc_table;
73376 + ctl_table_no_const ipc_table;
73377
73378 memcpy(&ipc_table, table, sizeof(ipc_table));
73379 ipc_table.data = get_ipc(table);
73380 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
73381 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
73382 void __user *buffer, size_t *lenp, loff_t *ppos)
73383 {
73384 - struct ctl_table ipc_table;
73385 + ctl_table_no_const ipc_table;
73386
73387 memcpy(&ipc_table, table, sizeof(ipc_table));
73388 ipc_table.data = get_ipc(table);
73389 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
73390 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73391 void __user *buffer, size_t *lenp, loff_t *ppos)
73392 {
73393 - struct ctl_table ipc_table;
73394 + ctl_table_no_const ipc_table;
73395 size_t lenp_bef = *lenp;
73396 int rc;
73397
73398 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73399 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
73400 void __user *buffer, size_t *lenp, loff_t *ppos)
73401 {
73402 - struct ctl_table ipc_table;
73403 + ctl_table_no_const ipc_table;
73404 memcpy(&ipc_table, table, sizeof(ipc_table));
73405 ipc_table.data = get_ipc(table);
73406
73407 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
73408 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
73409 void __user *buffer, size_t *lenp, loff_t *ppos)
73410 {
73411 - struct ctl_table ipc_table;
73412 + ctl_table_no_const ipc_table;
73413 size_t lenp_bef = *lenp;
73414 int oldval;
73415 int rc;
73416 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
73417 index 383d638..943fdbb 100644
73418 --- a/ipc/mq_sysctl.c
73419 +++ b/ipc/mq_sysctl.c
73420 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
73421 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
73422 void __user *buffer, size_t *lenp, loff_t *ppos)
73423 {
73424 - struct ctl_table mq_table;
73425 + ctl_table_no_const mq_table;
73426 memcpy(&mq_table, table, sizeof(mq_table));
73427 mq_table.data = get_mq(table);
73428
73429 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
73430 index 6ebfbf5..c750fff 100644
73431 --- a/ipc/mqueue.c
73432 +++ b/ipc/mqueue.c
73433 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
73434 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
73435 info->attr.mq_msgsize);
73436
73437 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
73438 spin_lock(&mq_lock);
73439 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
73440 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
73441 diff --git a/ipc/msg.c b/ipc/msg.c
73442 index 31cd1bf..362ea07 100644
73443 --- a/ipc/msg.c
73444 +++ b/ipc/msg.c
73445 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
73446 return security_msg_queue_associate(msq, msgflg);
73447 }
73448
73449 +static struct ipc_ops msg_ops = {
73450 + .getnew = newque,
73451 + .associate = msg_security,
73452 + .more_checks = NULL
73453 +};
73454 +
73455 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
73456 {
73457 struct ipc_namespace *ns;
73458 - struct ipc_ops msg_ops;
73459 struct ipc_params msg_params;
73460
73461 ns = current->nsproxy->ipc_ns;
73462
73463 - msg_ops.getnew = newque;
73464 - msg_ops.associate = msg_security;
73465 - msg_ops.more_checks = NULL;
73466 -
73467 msg_params.key = key;
73468 msg_params.flg = msgflg;
73469
73470 diff --git a/ipc/sem.c b/ipc/sem.c
73471 index 58d31f1..cce7a55 100644
73472 --- a/ipc/sem.c
73473 +++ b/ipc/sem.c
73474 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
73475 return 0;
73476 }
73477
73478 +static struct ipc_ops sem_ops = {
73479 + .getnew = newary,
73480 + .associate = sem_security,
73481 + .more_checks = sem_more_checks
73482 +};
73483 +
73484 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73485 {
73486 struct ipc_namespace *ns;
73487 - struct ipc_ops sem_ops;
73488 struct ipc_params sem_params;
73489
73490 ns = current->nsproxy->ipc_ns;
73491 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73492 if (nsems < 0 || nsems > ns->sc_semmsl)
73493 return -EINVAL;
73494
73495 - sem_ops.getnew = newary;
73496 - sem_ops.associate = sem_security;
73497 - sem_ops.more_checks = sem_more_checks;
73498 -
73499 sem_params.key = key;
73500 sem_params.flg = semflg;
73501 sem_params.u.nsems = nsems;
73502 diff --git a/ipc/shm.c b/ipc/shm.c
73503 index 4fa6d8f..55cff14 100644
73504 --- a/ipc/shm.c
73505 +++ b/ipc/shm.c
73506 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
73507 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
73508 #endif
73509
73510 +#ifdef CONFIG_GRKERNSEC
73511 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73512 + const time_t shm_createtime, const kuid_t cuid,
73513 + const int shmid);
73514 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73515 + const time_t shm_createtime);
73516 +#endif
73517 +
73518 void shm_init_ns(struct ipc_namespace *ns)
73519 {
73520 ns->shm_ctlmax = SHMMAX;
73521 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
73522 shp->shm_lprid = 0;
73523 shp->shm_atim = shp->shm_dtim = 0;
73524 shp->shm_ctim = get_seconds();
73525 +#ifdef CONFIG_GRKERNSEC
73526 + {
73527 + struct timespec timeval;
73528 + do_posix_clock_monotonic_gettime(&timeval);
73529 +
73530 + shp->shm_createtime = timeval.tv_sec;
73531 + }
73532 +#endif
73533 shp->shm_segsz = size;
73534 shp->shm_nattch = 0;
73535 shp->shm_file = file;
73536 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
73537 return 0;
73538 }
73539
73540 +static struct ipc_ops shm_ops = {
73541 + .getnew = newseg,
73542 + .associate = shm_security,
73543 + .more_checks = shm_more_checks
73544 +};
73545 +
73546 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
73547 {
73548 struct ipc_namespace *ns;
73549 - struct ipc_ops shm_ops;
73550 struct ipc_params shm_params;
73551
73552 ns = current->nsproxy->ipc_ns;
73553
73554 - shm_ops.getnew = newseg;
73555 - shm_ops.associate = shm_security;
73556 - shm_ops.more_checks = shm_more_checks;
73557 -
73558 shm_params.key = key;
73559 shm_params.flg = shmflg;
73560 shm_params.u.size = size;
73561 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73562 f_mode = FMODE_READ | FMODE_WRITE;
73563 }
73564 if (shmflg & SHM_EXEC) {
73565 +
73566 +#ifdef CONFIG_PAX_MPROTECT
73567 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
73568 + goto out;
73569 +#endif
73570 +
73571 prot |= PROT_EXEC;
73572 acc_mode |= S_IXUGO;
73573 }
73574 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73575 if (err)
73576 goto out_unlock;
73577
73578 +#ifdef CONFIG_GRKERNSEC
73579 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
73580 + shp->shm_perm.cuid, shmid) ||
73581 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
73582 + err = -EACCES;
73583 + goto out_unlock;
73584 + }
73585 +#endif
73586 +
73587 path = shp->shm_file->f_path;
73588 path_get(&path);
73589 shp->shm_nattch++;
73590 +#ifdef CONFIG_GRKERNSEC
73591 + shp->shm_lapid = current->pid;
73592 +#endif
73593 size = i_size_read(path.dentry->d_inode);
73594 shm_unlock(shp);
73595
73596 diff --git a/kernel/acct.c b/kernel/acct.c
73597 index 051e071..15e0920 100644
73598 --- a/kernel/acct.c
73599 +++ b/kernel/acct.c
73600 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
73601 */
73602 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
73603 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
73604 - file->f_op->write(file, (char *)&ac,
73605 + file->f_op->write(file, (char __force_user *)&ac,
73606 sizeof(acct_t), &file->f_pos);
73607 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
73608 set_fs(fs);
73609 diff --git a/kernel/audit.c b/kernel/audit.c
73610 index d596e53..dbef3c3 100644
73611 --- a/kernel/audit.c
73612 +++ b/kernel/audit.c
73613 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
73614 3) suppressed due to audit_rate_limit
73615 4) suppressed due to audit_backlog_limit
73616 */
73617 -static atomic_t audit_lost = ATOMIC_INIT(0);
73618 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
73619
73620 /* The netlink socket. */
73621 static struct sock *audit_sock;
73622 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
73623 unsigned long now;
73624 int print;
73625
73626 - atomic_inc(&audit_lost);
73627 + atomic_inc_unchecked(&audit_lost);
73628
73629 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
73630
73631 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
73632 printk(KERN_WARNING
73633 "audit: audit_lost=%d audit_rate_limit=%d "
73634 "audit_backlog_limit=%d\n",
73635 - atomic_read(&audit_lost),
73636 + atomic_read_unchecked(&audit_lost),
73637 audit_rate_limit,
73638 audit_backlog_limit);
73639 audit_panic(message);
73640 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
73641 status_set.pid = audit_pid;
73642 status_set.rate_limit = audit_rate_limit;
73643 status_set.backlog_limit = audit_backlog_limit;
73644 - status_set.lost = atomic_read(&audit_lost);
73645 + status_set.lost = atomic_read_unchecked(&audit_lost);
73646 status_set.backlog = skb_queue_len(&audit_skb_queue);
73647 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
73648 &status_set, sizeof(status_set));
73649 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
73650 index a371f85..da826c1 100644
73651 --- a/kernel/auditsc.c
73652 +++ b/kernel/auditsc.c
73653 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
73654 }
73655
73656 /* global counter which is incremented every time something logs in */
73657 -static atomic_t session_id = ATOMIC_INIT(0);
73658 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
73659
73660 /**
73661 * audit_set_loginuid - set current task's audit_context loginuid
73662 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
73663 return -EPERM;
73664 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
73665
73666 - sessionid = atomic_inc_return(&session_id);
73667 + sessionid = atomic_inc_return_unchecked(&session_id);
73668 if (context && context->in_syscall) {
73669 struct audit_buffer *ab;
73670
73671 diff --git a/kernel/capability.c b/kernel/capability.c
73672 index 493d972..f87dfbd 100644
73673 --- a/kernel/capability.c
73674 +++ b/kernel/capability.c
73675 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
73676 * before modification is attempted and the application
73677 * fails.
73678 */
73679 + if (tocopy > ARRAY_SIZE(kdata))
73680 + return -EFAULT;
73681 +
73682 if (copy_to_user(dataptr, kdata, tocopy
73683 * sizeof(struct __user_cap_data_struct))) {
73684 return -EFAULT;
73685 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
73686 int ret;
73687
73688 rcu_read_lock();
73689 - ret = security_capable(__task_cred(t), ns, cap);
73690 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
73691 + gr_task_is_capable(t, __task_cred(t), cap);
73692 rcu_read_unlock();
73693
73694 - return (ret == 0);
73695 + return ret;
73696 }
73697
73698 /**
73699 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
73700 int ret;
73701
73702 rcu_read_lock();
73703 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
73704 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
73705 rcu_read_unlock();
73706
73707 - return (ret == 0);
73708 + return ret;
73709 }
73710
73711 /**
73712 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
73713 BUG();
73714 }
73715
73716 - if (security_capable(current_cred(), ns, cap) == 0) {
73717 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
73718 current->flags |= PF_SUPERPRIV;
73719 return true;
73720 }
73721 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
73722 }
73723 EXPORT_SYMBOL(ns_capable);
73724
73725 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
73726 +{
73727 + if (unlikely(!cap_valid(cap))) {
73728 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
73729 + BUG();
73730 + }
73731 +
73732 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
73733 + current->flags |= PF_SUPERPRIV;
73734 + return true;
73735 + }
73736 + return false;
73737 +}
73738 +EXPORT_SYMBOL(ns_capable_nolog);
73739 +
73740 /**
73741 * capable - Determine if the current task has a superior capability in effect
73742 * @cap: The capability to be tested for
73743 @@ -408,6 +427,12 @@ bool capable(int cap)
73744 }
73745 EXPORT_SYMBOL(capable);
73746
73747 +bool capable_nolog(int cap)
73748 +{
73749 + return ns_capable_nolog(&init_user_ns, cap);
73750 +}
73751 +EXPORT_SYMBOL(capable_nolog);
73752 +
73753 /**
73754 * nsown_capable - Check superior capability to one's own user_ns
73755 * @cap: The capability in question
73756 @@ -440,3 +465,10 @@ bool inode_capable(const struct inode *inode, int cap)
73757
73758 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
73759 }
73760 +
73761 +bool inode_capable_nolog(const struct inode *inode, int cap)
73762 +{
73763 + struct user_namespace *ns = current_user_ns();
73764 +
73765 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
73766 +}
73767 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
73768 index 1e23664..570a83d 100644
73769 --- a/kernel/cgroup.c
73770 +++ b/kernel/cgroup.c
73771 @@ -5543,7 +5543,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
73772 struct css_set *cg = link->cg;
73773 struct task_struct *task;
73774 int count = 0;
73775 - seq_printf(seq, "css_set %p\n", cg);
73776 + seq_printf(seq, "css_set %pK\n", cg);
73777 list_for_each_entry(task, &cg->tasks, cg_list) {
73778 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
73779 seq_puts(seq, " ...\n");
73780 diff --git a/kernel/compat.c b/kernel/compat.c
73781 index 36700e9..73d770c 100644
73782 --- a/kernel/compat.c
73783 +++ b/kernel/compat.c
73784 @@ -13,6 +13,7 @@
73785
73786 #include <linux/linkage.h>
73787 #include <linux/compat.h>
73788 +#include <linux/module.h>
73789 #include <linux/errno.h>
73790 #include <linux/time.h>
73791 #include <linux/signal.h>
73792 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
73793 mm_segment_t oldfs;
73794 long ret;
73795
73796 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
73797 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
73798 oldfs = get_fs();
73799 set_fs(KERNEL_DS);
73800 ret = hrtimer_nanosleep_restart(restart);
73801 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
73802 oldfs = get_fs();
73803 set_fs(KERNEL_DS);
73804 ret = hrtimer_nanosleep(&tu,
73805 - rmtp ? (struct timespec __user *)&rmt : NULL,
73806 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
73807 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
73808 set_fs(oldfs);
73809
73810 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
73811 mm_segment_t old_fs = get_fs();
73812
73813 set_fs(KERNEL_DS);
73814 - ret = sys_sigpending((old_sigset_t __user *) &s);
73815 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
73816 set_fs(old_fs);
73817 if (ret == 0)
73818 ret = put_user(s, set);
73819 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
73820 mm_segment_t old_fs = get_fs();
73821
73822 set_fs(KERNEL_DS);
73823 - ret = sys_old_getrlimit(resource, &r);
73824 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
73825 set_fs(old_fs);
73826
73827 if (!ret) {
73828 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
73829 mm_segment_t old_fs = get_fs();
73830
73831 set_fs(KERNEL_DS);
73832 - ret = sys_getrusage(who, (struct rusage __user *) &r);
73833 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
73834 set_fs(old_fs);
73835
73836 if (ret)
73837 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
73838 set_fs (KERNEL_DS);
73839 ret = sys_wait4(pid,
73840 (stat_addr ?
73841 - (unsigned int __user *) &status : NULL),
73842 - options, (struct rusage __user *) &r);
73843 + (unsigned int __force_user *) &status : NULL),
73844 + options, (struct rusage __force_user *) &r);
73845 set_fs (old_fs);
73846
73847 if (ret > 0) {
73848 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
73849 memset(&info, 0, sizeof(info));
73850
73851 set_fs(KERNEL_DS);
73852 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
73853 - uru ? (struct rusage __user *)&ru : NULL);
73854 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
73855 + uru ? (struct rusage __force_user *)&ru : NULL);
73856 set_fs(old_fs);
73857
73858 if ((ret < 0) || (info.si_signo == 0))
73859 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
73860 oldfs = get_fs();
73861 set_fs(KERNEL_DS);
73862 err = sys_timer_settime(timer_id, flags,
73863 - (struct itimerspec __user *) &newts,
73864 - (struct itimerspec __user *) &oldts);
73865 + (struct itimerspec __force_user *) &newts,
73866 + (struct itimerspec __force_user *) &oldts);
73867 set_fs(oldfs);
73868 if (!err && old && put_compat_itimerspec(old, &oldts))
73869 return -EFAULT;
73870 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
73871 oldfs = get_fs();
73872 set_fs(KERNEL_DS);
73873 err = sys_timer_gettime(timer_id,
73874 - (struct itimerspec __user *) &ts);
73875 + (struct itimerspec __force_user *) &ts);
73876 set_fs(oldfs);
73877 if (!err && put_compat_itimerspec(setting, &ts))
73878 return -EFAULT;
73879 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
73880 oldfs = get_fs();
73881 set_fs(KERNEL_DS);
73882 err = sys_clock_settime(which_clock,
73883 - (struct timespec __user *) &ts);
73884 + (struct timespec __force_user *) &ts);
73885 set_fs(oldfs);
73886 return err;
73887 }
73888 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
73889 oldfs = get_fs();
73890 set_fs(KERNEL_DS);
73891 err = sys_clock_gettime(which_clock,
73892 - (struct timespec __user *) &ts);
73893 + (struct timespec __force_user *) &ts);
73894 set_fs(oldfs);
73895 if (!err && put_compat_timespec(&ts, tp))
73896 return -EFAULT;
73897 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
73898
73899 oldfs = get_fs();
73900 set_fs(KERNEL_DS);
73901 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
73902 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
73903 set_fs(oldfs);
73904
73905 err = compat_put_timex(utp, &txc);
73906 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
73907 oldfs = get_fs();
73908 set_fs(KERNEL_DS);
73909 err = sys_clock_getres(which_clock,
73910 - (struct timespec __user *) &ts);
73911 + (struct timespec __force_user *) &ts);
73912 set_fs(oldfs);
73913 if (!err && tp && put_compat_timespec(&ts, tp))
73914 return -EFAULT;
73915 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
73916 long err;
73917 mm_segment_t oldfs;
73918 struct timespec tu;
73919 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
73920 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
73921
73922 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
73923 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
73924 oldfs = get_fs();
73925 set_fs(KERNEL_DS);
73926 err = clock_nanosleep_restart(restart);
73927 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
73928 oldfs = get_fs();
73929 set_fs(KERNEL_DS);
73930 err = sys_clock_nanosleep(which_clock, flags,
73931 - (struct timespec __user *) &in,
73932 - (struct timespec __user *) &out);
73933 + (struct timespec __force_user *) &in,
73934 + (struct timespec __force_user *) &out);
73935 set_fs(oldfs);
73936
73937 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
73938 diff --git a/kernel/configs.c b/kernel/configs.c
73939 index 42e8fa0..9e7406b 100644
73940 --- a/kernel/configs.c
73941 +++ b/kernel/configs.c
73942 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
73943 struct proc_dir_entry *entry;
73944
73945 /* create the current config file */
73946 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
73947 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
73948 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
73949 + &ikconfig_file_ops);
73950 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
73951 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
73952 + &ikconfig_file_ops);
73953 +#endif
73954 +#else
73955 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
73956 &ikconfig_file_ops);
73957 +#endif
73958 +
73959 if (!entry)
73960 return -ENOMEM;
73961
73962 diff --git a/kernel/cred.c b/kernel/cred.c
73963 index e0573a4..3874e41 100644
73964 --- a/kernel/cred.c
73965 +++ b/kernel/cred.c
73966 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
73967 validate_creds(cred);
73968 alter_cred_subscribers(cred, -1);
73969 put_cred(cred);
73970 +
73971 +#ifdef CONFIG_GRKERNSEC_SETXID
73972 + cred = (struct cred *) tsk->delayed_cred;
73973 + if (cred != NULL) {
73974 + tsk->delayed_cred = NULL;
73975 + validate_creds(cred);
73976 + alter_cred_subscribers(cred, -1);
73977 + put_cred(cred);
73978 + }
73979 +#endif
73980 }
73981
73982 /**
73983 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
73984 * Always returns 0 thus allowing this function to be tail-called at the end
73985 * of, say, sys_setgid().
73986 */
73987 -int commit_creds(struct cred *new)
73988 +static int __commit_creds(struct cred *new)
73989 {
73990 struct task_struct *task = current;
73991 const struct cred *old = task->real_cred;
73992 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
73993
73994 get_cred(new); /* we will require a ref for the subj creds too */
73995
73996 + gr_set_role_label(task, new->uid, new->gid);
73997 +
73998 /* dumpability changes */
73999 if (!uid_eq(old->euid, new->euid) ||
74000 !gid_eq(old->egid, new->egid) ||
74001 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74002 put_cred(old);
74003 return 0;
74004 }
74005 +#ifdef CONFIG_GRKERNSEC_SETXID
74006 +extern int set_user(struct cred *new);
74007 +
74008 +void gr_delayed_cred_worker(void)
74009 +{
74010 + const struct cred *new = current->delayed_cred;
74011 + struct cred *ncred;
74012 +
74013 + current->delayed_cred = NULL;
74014 +
74015 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74016 + // from doing get_cred on it when queueing this
74017 + put_cred(new);
74018 + return;
74019 + } else if (new == NULL)
74020 + return;
74021 +
74022 + ncred = prepare_creds();
74023 + if (!ncred)
74024 + goto die;
74025 + // uids
74026 + ncred->uid = new->uid;
74027 + ncred->euid = new->euid;
74028 + ncred->suid = new->suid;
74029 + ncred->fsuid = new->fsuid;
74030 + // gids
74031 + ncred->gid = new->gid;
74032 + ncred->egid = new->egid;
74033 + ncred->sgid = new->sgid;
74034 + ncred->fsgid = new->fsgid;
74035 + // groups
74036 + if (set_groups(ncred, new->group_info) < 0) {
74037 + abort_creds(ncred);
74038 + goto die;
74039 + }
74040 + // caps
74041 + ncred->securebits = new->securebits;
74042 + ncred->cap_inheritable = new->cap_inheritable;
74043 + ncred->cap_permitted = new->cap_permitted;
74044 + ncred->cap_effective = new->cap_effective;
74045 + ncred->cap_bset = new->cap_bset;
74046 +
74047 + if (set_user(ncred)) {
74048 + abort_creds(ncred);
74049 + goto die;
74050 + }
74051 +
74052 + // from doing get_cred on it when queueing this
74053 + put_cred(new);
74054 +
74055 + __commit_creds(ncred);
74056 + return;
74057 +die:
74058 + // from doing get_cred on it when queueing this
74059 + put_cred(new);
74060 + do_group_exit(SIGKILL);
74061 +}
74062 +#endif
74063 +
74064 +int commit_creds(struct cred *new)
74065 +{
74066 +#ifdef CONFIG_GRKERNSEC_SETXID
74067 + int ret;
74068 + int schedule_it = 0;
74069 + struct task_struct *t;
74070 +
74071 + /* we won't get called with tasklist_lock held for writing
74072 + and interrupts disabled as the cred struct in that case is
74073 + init_cred
74074 + */
74075 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74076 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74077 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74078 + schedule_it = 1;
74079 + }
74080 + ret = __commit_creds(new);
74081 + if (schedule_it) {
74082 + rcu_read_lock();
74083 + read_lock(&tasklist_lock);
74084 + for (t = next_thread(current); t != current;
74085 + t = next_thread(t)) {
74086 + if (t->delayed_cred == NULL) {
74087 + t->delayed_cred = get_cred(new);
74088 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74089 + set_tsk_need_resched(t);
74090 + }
74091 + }
74092 + read_unlock(&tasklist_lock);
74093 + rcu_read_unlock();
74094 + }
74095 + return ret;
74096 +#else
74097 + return __commit_creds(new);
74098 +#endif
74099 +}
74100 +
74101 EXPORT_SYMBOL(commit_creds);
74102
74103 /**
74104 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
74105 index 9a61738..c5c8f3a 100644
74106 --- a/kernel/debug/debug_core.c
74107 +++ b/kernel/debug/debug_core.c
74108 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
74109 */
74110 static atomic_t masters_in_kgdb;
74111 static atomic_t slaves_in_kgdb;
74112 -static atomic_t kgdb_break_tasklet_var;
74113 +static atomic_unchecked_t kgdb_break_tasklet_var;
74114 atomic_t kgdb_setting_breakpoint;
74115
74116 struct task_struct *kgdb_usethread;
74117 @@ -132,7 +132,7 @@ int kgdb_single_step;
74118 static pid_t kgdb_sstep_pid;
74119
74120 /* to keep track of the CPU which is doing the single stepping*/
74121 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74122 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74123
74124 /*
74125 * If you are debugging a problem where roundup (the collection of
74126 @@ -540,7 +540,7 @@ return_normal:
74127 * kernel will only try for the value of sstep_tries before
74128 * giving up and continuing on.
74129 */
74130 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
74131 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
74132 (kgdb_info[cpu].task &&
74133 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
74134 atomic_set(&kgdb_active, -1);
74135 @@ -634,8 +634,8 @@ cpu_master_loop:
74136 }
74137
74138 kgdb_restore:
74139 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
74140 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
74141 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
74142 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
74143 if (kgdb_info[sstep_cpu].task)
74144 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
74145 else
74146 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
74147 static void kgdb_tasklet_bpt(unsigned long ing)
74148 {
74149 kgdb_breakpoint();
74150 - atomic_set(&kgdb_break_tasklet_var, 0);
74151 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
74152 }
74153
74154 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
74155
74156 void kgdb_schedule_breakpoint(void)
74157 {
74158 - if (atomic_read(&kgdb_break_tasklet_var) ||
74159 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
74160 atomic_read(&kgdb_active) != -1 ||
74161 atomic_read(&kgdb_setting_breakpoint))
74162 return;
74163 - atomic_inc(&kgdb_break_tasklet_var);
74164 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
74165 tasklet_schedule(&kgdb_tasklet_breakpoint);
74166 }
74167 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
74168 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
74169 index 8875254..7cf4928 100644
74170 --- a/kernel/debug/kdb/kdb_main.c
74171 +++ b/kernel/debug/kdb/kdb_main.c
74172 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
74173 continue;
74174
74175 kdb_printf("%-20s%8u 0x%p ", mod->name,
74176 - mod->core_size, (void *)mod);
74177 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
74178 #ifdef CONFIG_MODULE_UNLOAD
74179 kdb_printf("%4ld ", module_refcount(mod));
74180 #endif
74181 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
74182 kdb_printf(" (Loading)");
74183 else
74184 kdb_printf(" (Live)");
74185 - kdb_printf(" 0x%p", mod->module_core);
74186 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
74187
74188 #ifdef CONFIG_MODULE_UNLOAD
74189 {
74190 diff --git a/kernel/events/core.c b/kernel/events/core.c
74191 index 7b6646a..3cb1135 100644
74192 --- a/kernel/events/core.c
74193 +++ b/kernel/events/core.c
74194 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
74195 return 0;
74196 }
74197
74198 -static atomic64_t perf_event_id;
74199 +static atomic64_unchecked_t perf_event_id;
74200
74201 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
74202 enum event_type_t event_type);
74203 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
74204
74205 static inline u64 perf_event_count(struct perf_event *event)
74206 {
74207 - return local64_read(&event->count) + atomic64_read(&event->child_count);
74208 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
74209 }
74210
74211 static u64 perf_event_read(struct perf_event *event)
74212 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
74213 mutex_lock(&event->child_mutex);
74214 total += perf_event_read(event);
74215 *enabled += event->total_time_enabled +
74216 - atomic64_read(&event->child_total_time_enabled);
74217 + atomic64_read_unchecked(&event->child_total_time_enabled);
74218 *running += event->total_time_running +
74219 - atomic64_read(&event->child_total_time_running);
74220 + atomic64_read_unchecked(&event->child_total_time_running);
74221
74222 list_for_each_entry(child, &event->child_list, child_list) {
74223 total += perf_event_read(child);
74224 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
74225 userpg->offset -= local64_read(&event->hw.prev_count);
74226
74227 userpg->time_enabled = enabled +
74228 - atomic64_read(&event->child_total_time_enabled);
74229 + atomic64_read_unchecked(&event->child_total_time_enabled);
74230
74231 userpg->time_running = running +
74232 - atomic64_read(&event->child_total_time_running);
74233 + atomic64_read_unchecked(&event->child_total_time_running);
74234
74235 arch_perf_update_userpage(userpg, now);
74236
74237 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
74238 values[n++] = perf_event_count(event);
74239 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
74240 values[n++] = enabled +
74241 - atomic64_read(&event->child_total_time_enabled);
74242 + atomic64_read_unchecked(&event->child_total_time_enabled);
74243 }
74244 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
74245 values[n++] = running +
74246 - atomic64_read(&event->child_total_time_running);
74247 + atomic64_read_unchecked(&event->child_total_time_running);
74248 }
74249 if (read_format & PERF_FORMAT_ID)
74250 values[n++] = primary_event_id(event);
74251 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
74252 * need to add enough zero bytes after the string to handle
74253 * the 64bit alignment we do later.
74254 */
74255 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
74256 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
74257 if (!buf) {
74258 name = strncpy(tmp, "//enomem", sizeof(tmp));
74259 goto got_name;
74260 }
74261 - name = d_path(&file->f_path, buf, PATH_MAX);
74262 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
74263 if (IS_ERR(name)) {
74264 name = strncpy(tmp, "//toolong", sizeof(tmp));
74265 goto got_name;
74266 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
74267 event->parent = parent_event;
74268
74269 event->ns = get_pid_ns(task_active_pid_ns(current));
74270 - event->id = atomic64_inc_return(&perf_event_id);
74271 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
74272
74273 event->state = PERF_EVENT_STATE_INACTIVE;
74274
74275 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
74276 /*
74277 * Add back the child's count to the parent's count:
74278 */
74279 - atomic64_add(child_val, &parent_event->child_count);
74280 - atomic64_add(child_event->total_time_enabled,
74281 + atomic64_add_unchecked(child_val, &parent_event->child_count);
74282 + atomic64_add_unchecked(child_event->total_time_enabled,
74283 &parent_event->child_total_time_enabled);
74284 - atomic64_add(child_event->total_time_running,
74285 + atomic64_add_unchecked(child_event->total_time_running,
74286 &parent_event->child_total_time_running);
74287
74288 /*
74289 diff --git a/kernel/exit.c b/kernel/exit.c
74290 index b4df219..f13c02d 100644
74291 --- a/kernel/exit.c
74292 +++ b/kernel/exit.c
74293 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
74294 struct task_struct *leader;
74295 int zap_leader;
74296 repeat:
74297 +#ifdef CONFIG_NET
74298 + gr_del_task_from_ip_table(p);
74299 +#endif
74300 +
74301 /* don't need to get the RCU readlock here - the process is dead and
74302 * can't be modifying its own credentials. But shut RCU-lockdep up */
74303 rcu_read_lock();
74304 @@ -338,7 +342,7 @@ int allow_signal(int sig)
74305 * know it'll be handled, so that they don't get converted to
74306 * SIGKILL or just silently dropped.
74307 */
74308 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
74309 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
74310 recalc_sigpending();
74311 spin_unlock_irq(&current->sighand->siglock);
74312 return 0;
74313 @@ -708,6 +712,8 @@ void do_exit(long code)
74314 struct task_struct *tsk = current;
74315 int group_dead;
74316
74317 + set_fs(USER_DS);
74318 +
74319 profile_task_exit(tsk);
74320
74321 WARN_ON(blk_needs_flush_plug(tsk));
74322 @@ -724,7 +730,6 @@ void do_exit(long code)
74323 * mm_release()->clear_child_tid() from writing to a user-controlled
74324 * kernel address.
74325 */
74326 - set_fs(USER_DS);
74327
74328 ptrace_event(PTRACE_EVENT_EXIT, code);
74329
74330 @@ -783,6 +788,9 @@ void do_exit(long code)
74331 tsk->exit_code = code;
74332 taskstats_exit(tsk, group_dead);
74333
74334 + gr_acl_handle_psacct(tsk, code);
74335 + gr_acl_handle_exit();
74336 +
74337 exit_mm(tsk);
74338
74339 if (group_dead)
74340 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
74341 * Take down every thread in the group. This is called by fatal signals
74342 * as well as by sys_exit_group (below).
74343 */
74344 -void
74345 +__noreturn void
74346 do_group_exit(int exit_code)
74347 {
74348 struct signal_struct *sig = current->signal;
74349 diff --git a/kernel/fork.c b/kernel/fork.c
74350 index 5630e52..0cee608 100644
74351 --- a/kernel/fork.c
74352 +++ b/kernel/fork.c
74353 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
74354 *stackend = STACK_END_MAGIC; /* for overflow detection */
74355
74356 #ifdef CONFIG_CC_STACKPROTECTOR
74357 - tsk->stack_canary = get_random_int();
74358 + tsk->stack_canary = pax_get_random_long();
74359 #endif
74360
74361 /*
74362 @@ -344,13 +344,81 @@ free_tsk:
74363 }
74364
74365 #ifdef CONFIG_MMU
74366 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
74367 +{
74368 + struct vm_area_struct *tmp;
74369 + unsigned long charge;
74370 + struct mempolicy *pol;
74371 + struct file *file;
74372 +
74373 + charge = 0;
74374 + if (mpnt->vm_flags & VM_ACCOUNT) {
74375 + unsigned long len = vma_pages(mpnt);
74376 +
74377 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74378 + goto fail_nomem;
74379 + charge = len;
74380 + }
74381 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74382 + if (!tmp)
74383 + goto fail_nomem;
74384 + *tmp = *mpnt;
74385 + tmp->vm_mm = mm;
74386 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
74387 + pol = mpol_dup(vma_policy(mpnt));
74388 + if (IS_ERR(pol))
74389 + goto fail_nomem_policy;
74390 + vma_set_policy(tmp, pol);
74391 + if (anon_vma_fork(tmp, mpnt))
74392 + goto fail_nomem_anon_vma_fork;
74393 + tmp->vm_flags &= ~VM_LOCKED;
74394 + tmp->vm_next = tmp->vm_prev = NULL;
74395 + tmp->vm_mirror = NULL;
74396 + file = tmp->vm_file;
74397 + if (file) {
74398 + struct inode *inode = file->f_path.dentry->d_inode;
74399 + struct address_space *mapping = file->f_mapping;
74400 +
74401 + get_file(file);
74402 + if (tmp->vm_flags & VM_DENYWRITE)
74403 + atomic_dec(&inode->i_writecount);
74404 + mutex_lock(&mapping->i_mmap_mutex);
74405 + if (tmp->vm_flags & VM_SHARED)
74406 + mapping->i_mmap_writable++;
74407 + flush_dcache_mmap_lock(mapping);
74408 + /* insert tmp into the share list, just after mpnt */
74409 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74410 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
74411 + else
74412 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
74413 + flush_dcache_mmap_unlock(mapping);
74414 + mutex_unlock(&mapping->i_mmap_mutex);
74415 + }
74416 +
74417 + /*
74418 + * Clear hugetlb-related page reserves for children. This only
74419 + * affects MAP_PRIVATE mappings. Faults generated by the child
74420 + * are not guaranteed to succeed, even if read-only
74421 + */
74422 + if (is_vm_hugetlb_page(tmp))
74423 + reset_vma_resv_huge_pages(tmp);
74424 +
74425 + return tmp;
74426 +
74427 +fail_nomem_anon_vma_fork:
74428 + mpol_put(pol);
74429 +fail_nomem_policy:
74430 + kmem_cache_free(vm_area_cachep, tmp);
74431 +fail_nomem:
74432 + vm_unacct_memory(charge);
74433 + return NULL;
74434 +}
74435 +
74436 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74437 {
74438 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
74439 struct rb_node **rb_link, *rb_parent;
74440 int retval;
74441 - unsigned long charge;
74442 - struct mempolicy *pol;
74443
74444 uprobe_start_dup_mmap();
74445 down_write(&oldmm->mmap_sem);
74446 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74447 mm->locked_vm = 0;
74448 mm->mmap = NULL;
74449 mm->mmap_cache = NULL;
74450 - mm->free_area_cache = oldmm->mmap_base;
74451 - mm->cached_hole_size = ~0UL;
74452 + mm->free_area_cache = oldmm->free_area_cache;
74453 + mm->cached_hole_size = oldmm->cached_hole_size;
74454 mm->map_count = 0;
74455 cpumask_clear(mm_cpumask(mm));
74456 mm->mm_rb = RB_ROOT;
74457 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74458
74459 prev = NULL;
74460 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
74461 - struct file *file;
74462 -
74463 if (mpnt->vm_flags & VM_DONTCOPY) {
74464 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
74465 -vma_pages(mpnt));
74466 continue;
74467 }
74468 - charge = 0;
74469 - if (mpnt->vm_flags & VM_ACCOUNT) {
74470 - unsigned long len = vma_pages(mpnt);
74471 -
74472 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74473 - goto fail_nomem;
74474 - charge = len;
74475 - }
74476 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74477 - if (!tmp)
74478 - goto fail_nomem;
74479 - *tmp = *mpnt;
74480 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
74481 - pol = mpol_dup(vma_policy(mpnt));
74482 - retval = PTR_ERR(pol);
74483 - if (IS_ERR(pol))
74484 - goto fail_nomem_policy;
74485 - vma_set_policy(tmp, pol);
74486 - tmp->vm_mm = mm;
74487 - if (anon_vma_fork(tmp, mpnt))
74488 - goto fail_nomem_anon_vma_fork;
74489 - tmp->vm_flags &= ~VM_LOCKED;
74490 - tmp->vm_next = tmp->vm_prev = NULL;
74491 - file = tmp->vm_file;
74492 - if (file) {
74493 - struct inode *inode = file->f_path.dentry->d_inode;
74494 - struct address_space *mapping = file->f_mapping;
74495 -
74496 - get_file(file);
74497 - if (tmp->vm_flags & VM_DENYWRITE)
74498 - atomic_dec(&inode->i_writecount);
74499 - mutex_lock(&mapping->i_mmap_mutex);
74500 - if (tmp->vm_flags & VM_SHARED)
74501 - mapping->i_mmap_writable++;
74502 - flush_dcache_mmap_lock(mapping);
74503 - /* insert tmp into the share list, just after mpnt */
74504 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74505 - vma_nonlinear_insert(tmp,
74506 - &mapping->i_mmap_nonlinear);
74507 - else
74508 - vma_interval_tree_insert_after(tmp, mpnt,
74509 - &mapping->i_mmap);
74510 - flush_dcache_mmap_unlock(mapping);
74511 - mutex_unlock(&mapping->i_mmap_mutex);
74512 + tmp = dup_vma(mm, oldmm, mpnt);
74513 + if (!tmp) {
74514 + retval = -ENOMEM;
74515 + goto out;
74516 }
74517
74518 /*
74519 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74520 if (retval)
74521 goto out;
74522 }
74523 +
74524 +#ifdef CONFIG_PAX_SEGMEXEC
74525 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
74526 + struct vm_area_struct *mpnt_m;
74527 +
74528 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
74529 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
74530 +
74531 + if (!mpnt->vm_mirror)
74532 + continue;
74533 +
74534 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
74535 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
74536 + mpnt->vm_mirror = mpnt_m;
74537 + } else {
74538 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
74539 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
74540 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
74541 + mpnt->vm_mirror->vm_mirror = mpnt;
74542 + }
74543 + }
74544 + BUG_ON(mpnt_m);
74545 + }
74546 +#endif
74547 +
74548 /* a new mm has just been created */
74549 arch_dup_mmap(oldmm, mm);
74550 retval = 0;
74551 @@ -472,14 +523,6 @@ out:
74552 up_write(&oldmm->mmap_sem);
74553 uprobe_end_dup_mmap();
74554 return retval;
74555 -fail_nomem_anon_vma_fork:
74556 - mpol_put(pol);
74557 -fail_nomem_policy:
74558 - kmem_cache_free(vm_area_cachep, tmp);
74559 -fail_nomem:
74560 - retval = -ENOMEM;
74561 - vm_unacct_memory(charge);
74562 - goto out;
74563 }
74564
74565 static inline int mm_alloc_pgd(struct mm_struct *mm)
74566 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
74567 return ERR_PTR(err);
74568
74569 mm = get_task_mm(task);
74570 - if (mm && mm != current->mm &&
74571 - !ptrace_may_access(task, mode)) {
74572 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
74573 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
74574 mmput(mm);
74575 mm = ERR_PTR(-EACCES);
74576 }
74577 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
74578 spin_unlock(&fs->lock);
74579 return -EAGAIN;
74580 }
74581 - fs->users++;
74582 + atomic_inc(&fs->users);
74583 spin_unlock(&fs->lock);
74584 return 0;
74585 }
74586 tsk->fs = copy_fs_struct(fs);
74587 if (!tsk->fs)
74588 return -ENOMEM;
74589 + /* Carry through gr_chroot_dentry and is_chrooted instead
74590 + of recomputing it here. Already copied when the task struct
74591 + is duplicated. This allows pivot_root to not be treated as
74592 + a chroot
74593 + */
74594 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
74595 +
74596 return 0;
74597 }
74598
74599 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74600 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
74601 #endif
74602 retval = -EAGAIN;
74603 +
74604 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
74605 +
74606 if (atomic_read(&p->real_cred->user->processes) >=
74607 task_rlimit(p, RLIMIT_NPROC)) {
74608 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
74609 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74610 goto bad_fork_free_pid;
74611 }
74612
74613 + /* synchronizes with gr_set_acls()
74614 + we need to call this past the point of no return for fork()
74615 + */
74616 + gr_copy_label(p);
74617 +
74618 if (clone_flags & CLONE_THREAD) {
74619 current->signal->nr_threads++;
74620 atomic_inc(&current->signal->live);
74621 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
74622 bad_fork_free:
74623 free_task(p);
74624 fork_out:
74625 + gr_log_forkfail(retval);
74626 +
74627 return ERR_PTR(retval);
74628 }
74629
74630 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
74631 return -EINVAL;
74632 }
74633
74634 +#ifdef CONFIG_GRKERNSEC
74635 + if (clone_flags & CLONE_NEWUSER) {
74636 + /*
74637 + * This doesn't really inspire confidence:
74638 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
74639 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
74640 + * Increases kernel attack surface in areas developers
74641 + * previously cared little about ("low importance due
74642 + * to requiring "root" capability")
74643 + * To be removed when this code receives *proper* review
74644 + */
74645 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
74646 + !capable(CAP_SETGID))
74647 + return -EPERM;
74648 + }
74649 +#endif
74650 +
74651 /*
74652 * Determine whether and which event to report to ptracer. When
74653 * called from kernel_thread or CLONE_UNTRACED is explicitly
74654 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
74655 if (clone_flags & CLONE_PARENT_SETTID)
74656 put_user(nr, parent_tidptr);
74657
74658 + gr_handle_brute_check();
74659 +
74660 if (clone_flags & CLONE_VFORK) {
74661 p->vfork_done = &vfork;
74662 init_completion(&vfork);
74663 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
74664 return 0;
74665
74666 /* don't need lock here; in the worst case we'll do useless copy */
74667 - if (fs->users == 1)
74668 + if (atomic_read(&fs->users) == 1)
74669 return 0;
74670
74671 *new_fsp = copy_fs_struct(fs);
74672 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
74673 fs = current->fs;
74674 spin_lock(&fs->lock);
74675 current->fs = new_fs;
74676 - if (--fs->users)
74677 + gr_set_chroot_entries(current, &current->fs->root);
74678 + if (atomic_dec_return(&fs->users))
74679 new_fs = NULL;
74680 else
74681 new_fs = fs;
74682 diff --git a/kernel/futex.c b/kernel/futex.c
74683 index 8879430..31696f1 100644
74684 --- a/kernel/futex.c
74685 +++ b/kernel/futex.c
74686 @@ -54,6 +54,7 @@
74687 #include <linux/mount.h>
74688 #include <linux/pagemap.h>
74689 #include <linux/syscalls.h>
74690 +#include <linux/ptrace.h>
74691 #include <linux/signal.h>
74692 #include <linux/export.h>
74693 #include <linux/magic.h>
74694 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
74695 struct page *page, *page_head;
74696 int err, ro = 0;
74697
74698 +#ifdef CONFIG_PAX_SEGMEXEC
74699 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
74700 + return -EFAULT;
74701 +#endif
74702 +
74703 /*
74704 * The futex address must be "naturally" aligned.
74705 */
74706 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
74707 {
74708 u32 curval;
74709 int i;
74710 + mm_segment_t oldfs;
74711
74712 /*
74713 * This will fail and we want it. Some arch implementations do
74714 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
74715 * implementation, the non-functional ones will return
74716 * -ENOSYS.
74717 */
74718 + oldfs = get_fs();
74719 + set_fs(USER_DS);
74720 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
74721 futex_cmpxchg_enabled = 1;
74722 + set_fs(oldfs);
74723
74724 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
74725 plist_head_init(&futex_queues[i].chain);
74726 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
74727 index a9642d5..51eb98c 100644
74728 --- a/kernel/futex_compat.c
74729 +++ b/kernel/futex_compat.c
74730 @@ -31,7 +31,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
74731 return 0;
74732 }
74733
74734 -static void __user *futex_uaddr(struct robust_list __user *entry,
74735 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
74736 compat_long_t futex_offset)
74737 {
74738 compat_uptr_t base = ptr_to_compat(entry);
74739 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
74740 index 9b22d03..6295b62 100644
74741 --- a/kernel/gcov/base.c
74742 +++ b/kernel/gcov/base.c
74743 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
74744 }
74745
74746 #ifdef CONFIG_MODULES
74747 -static inline int within(void *addr, void *start, unsigned long size)
74748 -{
74749 - return ((addr >= start) && (addr < start + size));
74750 -}
74751 -
74752 /* Update list and generate events when modules are unloaded. */
74753 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
74754 void *data)
74755 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
74756 prev = NULL;
74757 /* Remove entries located in module from linked list. */
74758 for (info = gcov_info_head; info; info = info->next) {
74759 - if (within(info, mod->module_core, mod->core_size)) {
74760 + if (within_module_core_rw((unsigned long)info, mod)) {
74761 if (prev)
74762 prev->next = info->next;
74763 else
74764 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
74765 index cdd5607..c3fc919 100644
74766 --- a/kernel/hrtimer.c
74767 +++ b/kernel/hrtimer.c
74768 @@ -1407,7 +1407,7 @@ void hrtimer_peek_ahead_timers(void)
74769 local_irq_restore(flags);
74770 }
74771
74772 -static void run_hrtimer_softirq(struct softirq_action *h)
74773 +static void run_hrtimer_softirq(void)
74774 {
74775 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
74776
74777 @@ -1751,7 +1751,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
74778 return NOTIFY_OK;
74779 }
74780
74781 -static struct notifier_block __cpuinitdata hrtimers_nb = {
74782 +static struct notifier_block hrtimers_nb = {
74783 .notifier_call = hrtimer_cpu_notify,
74784 };
74785
74786 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
74787 index 60f48fa..7f3a770 100644
74788 --- a/kernel/jump_label.c
74789 +++ b/kernel/jump_label.c
74790 @@ -13,6 +13,7 @@
74791 #include <linux/sort.h>
74792 #include <linux/err.h>
74793 #include <linux/static_key.h>
74794 +#include <linux/mm.h>
74795
74796 #ifdef HAVE_JUMP_LABEL
74797
74798 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
74799
74800 size = (((unsigned long)stop - (unsigned long)start)
74801 / sizeof(struct jump_entry));
74802 + pax_open_kernel();
74803 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
74804 + pax_close_kernel();
74805 }
74806
74807 static void jump_label_update(struct static_key *key, int enable);
74808 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
74809 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
74810 struct jump_entry *iter;
74811
74812 + pax_open_kernel();
74813 for (iter = iter_start; iter < iter_stop; iter++) {
74814 if (within_module_init(iter->code, mod))
74815 iter->code = 0;
74816 }
74817 + pax_close_kernel();
74818 }
74819
74820 static int
74821 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
74822 index 2169fee..706ccca 100644
74823 --- a/kernel/kallsyms.c
74824 +++ b/kernel/kallsyms.c
74825 @@ -11,6 +11,9 @@
74826 * Changed the compression method from stem compression to "table lookup"
74827 * compression (see scripts/kallsyms.c for a more complete description)
74828 */
74829 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74830 +#define __INCLUDED_BY_HIDESYM 1
74831 +#endif
74832 #include <linux/kallsyms.h>
74833 #include <linux/module.h>
74834 #include <linux/init.h>
74835 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
74836
74837 static inline int is_kernel_inittext(unsigned long addr)
74838 {
74839 + if (system_state != SYSTEM_BOOTING)
74840 + return 0;
74841 +
74842 if (addr >= (unsigned long)_sinittext
74843 && addr <= (unsigned long)_einittext)
74844 return 1;
74845 return 0;
74846 }
74847
74848 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74849 +#ifdef CONFIG_MODULES
74850 +static inline int is_module_text(unsigned long addr)
74851 +{
74852 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
74853 + return 1;
74854 +
74855 + addr = ktla_ktva(addr);
74856 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
74857 +}
74858 +#else
74859 +static inline int is_module_text(unsigned long addr)
74860 +{
74861 + return 0;
74862 +}
74863 +#endif
74864 +#endif
74865 +
74866 static inline int is_kernel_text(unsigned long addr)
74867 {
74868 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
74869 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
74870
74871 static inline int is_kernel(unsigned long addr)
74872 {
74873 +
74874 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74875 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
74876 + return 1;
74877 +
74878 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
74879 +#else
74880 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
74881 +#endif
74882 +
74883 return 1;
74884 return in_gate_area_no_mm(addr);
74885 }
74886
74887 static int is_ksym_addr(unsigned long addr)
74888 {
74889 +
74890 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74891 + if (is_module_text(addr))
74892 + return 0;
74893 +#endif
74894 +
74895 if (all_var)
74896 return is_kernel(addr);
74897
74898 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
74899
74900 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
74901 {
74902 - iter->name[0] = '\0';
74903 iter->nameoff = get_symbol_offset(new_pos);
74904 iter->pos = new_pos;
74905 }
74906 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
74907 {
74908 struct kallsym_iter *iter = m->private;
74909
74910 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74911 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
74912 + return 0;
74913 +#endif
74914 +
74915 /* Some debugging symbols have no name. Ignore them. */
74916 if (!iter->name[0])
74917 return 0;
74918 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
74919 */
74920 type = iter->exported ? toupper(iter->type) :
74921 tolower(iter->type);
74922 +
74923 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
74924 type, iter->name, iter->module_name);
74925 } else
74926 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
74927 struct kallsym_iter *iter;
74928 int ret;
74929
74930 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
74931 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
74932 if (!iter)
74933 return -ENOMEM;
74934 reset_iter(iter, 0);
74935 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
74936 index e30ac0f..3528cac 100644
74937 --- a/kernel/kcmp.c
74938 +++ b/kernel/kcmp.c
74939 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
74940 struct task_struct *task1, *task2;
74941 int ret;
74942
74943 +#ifdef CONFIG_GRKERNSEC
74944 + return -ENOSYS;
74945 +#endif
74946 +
74947 rcu_read_lock();
74948
74949 /*
74950 diff --git a/kernel/kexec.c b/kernel/kexec.c
74951 index 5e4bd78..00c5b91 100644
74952 --- a/kernel/kexec.c
74953 +++ b/kernel/kexec.c
74954 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
74955 unsigned long flags)
74956 {
74957 struct compat_kexec_segment in;
74958 - struct kexec_segment out, __user *ksegments;
74959 + struct kexec_segment out;
74960 + struct kexec_segment __user *ksegments;
74961 unsigned long i, result;
74962
74963 /* Don't allow clients that don't understand the native
74964 diff --git a/kernel/kmod.c b/kernel/kmod.c
74965 index 0023a87..9c0c068 100644
74966 --- a/kernel/kmod.c
74967 +++ b/kernel/kmod.c
74968 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
74969 kfree(info->argv);
74970 }
74971
74972 -static int call_modprobe(char *module_name, int wait)
74973 +static int call_modprobe(char *module_name, char *module_param, int wait)
74974 {
74975 static char *envp[] = {
74976 "HOME=/",
74977 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
74978 NULL
74979 };
74980
74981 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
74982 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
74983 if (!argv)
74984 goto out;
74985
74986 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
74987 argv[1] = "-q";
74988 argv[2] = "--";
74989 argv[3] = module_name; /* check free_modprobe_argv() */
74990 - argv[4] = NULL;
74991 + argv[4] = module_param;
74992 + argv[5] = NULL;
74993
74994 return call_usermodehelper_fns(modprobe_path, argv, envp,
74995 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
74996 @@ -120,9 +121,8 @@ out:
74997 * If module auto-loading support is disabled then this function
74998 * becomes a no-operation.
74999 */
75000 -int __request_module(bool wait, const char *fmt, ...)
75001 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75002 {
75003 - va_list args;
75004 char module_name[MODULE_NAME_LEN];
75005 unsigned int max_modprobes;
75006 int ret;
75007 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
75008 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
75009 static int kmod_loop_msg;
75010
75011 - va_start(args, fmt);
75012 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75013 - va_end(args);
75014 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75015 if (ret >= MODULE_NAME_LEN)
75016 return -ENAMETOOLONG;
75017
75018 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
75019 if (ret)
75020 return ret;
75021
75022 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75023 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75024 + /* hack to workaround consolekit/udisks stupidity */
75025 + read_lock(&tasklist_lock);
75026 + if (!strcmp(current->comm, "mount") &&
75027 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75028 + read_unlock(&tasklist_lock);
75029 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75030 + return -EPERM;
75031 + }
75032 + read_unlock(&tasklist_lock);
75033 + }
75034 +#endif
75035 +
75036 /* If modprobe needs a service that is in a module, we get a recursive
75037 * loop. Limit the number of running kmod threads to max_threads/2 or
75038 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75039 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
75040
75041 trace_module_request(module_name, wait, _RET_IP_);
75042
75043 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75044 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75045
75046 atomic_dec(&kmod_concurrent);
75047 return ret;
75048 }
75049 +
75050 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75051 +{
75052 + va_list args;
75053 + int ret;
75054 +
75055 + va_start(args, fmt);
75056 + ret = ____request_module(wait, module_param, fmt, args);
75057 + va_end(args);
75058 +
75059 + return ret;
75060 +}
75061 +
75062 +int __request_module(bool wait, const char *fmt, ...)
75063 +{
75064 + va_list args;
75065 + int ret;
75066 +
75067 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75068 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75069 + char module_param[MODULE_NAME_LEN];
75070 +
75071 + memset(module_param, 0, sizeof(module_param));
75072 +
75073 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75074 +
75075 + va_start(args, fmt);
75076 + ret = ____request_module(wait, module_param, fmt, args);
75077 + va_end(args);
75078 +
75079 + return ret;
75080 + }
75081 +#endif
75082 +
75083 + va_start(args, fmt);
75084 + ret = ____request_module(wait, NULL, fmt, args);
75085 + va_end(args);
75086 +
75087 + return ret;
75088 +}
75089 +
75090 EXPORT_SYMBOL(__request_module);
75091 #endif /* CONFIG_MODULES */
75092
75093 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
75094 *
75095 * Thus the __user pointer cast is valid here.
75096 */
75097 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75098 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75099
75100 /*
75101 * If ret is 0, either ____call_usermodehelper failed and the
75102 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
75103 static int proc_cap_handler(struct ctl_table *table, int write,
75104 void __user *buffer, size_t *lenp, loff_t *ppos)
75105 {
75106 - struct ctl_table t;
75107 + ctl_table_no_const t;
75108 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
75109 kernel_cap_t new_cap;
75110 int err, i;
75111 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
75112 index 098f396..fe85ff1 100644
75113 --- a/kernel/kprobes.c
75114 +++ b/kernel/kprobes.c
75115 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
75116 * kernel image and loaded module images reside. This is required
75117 * so x86_64 can correctly handle the %rip-relative fixups.
75118 */
75119 - kip->insns = module_alloc(PAGE_SIZE);
75120 + kip->insns = module_alloc_exec(PAGE_SIZE);
75121 if (!kip->insns) {
75122 kfree(kip);
75123 return NULL;
75124 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
75125 */
75126 if (!list_is_singular(&kip->list)) {
75127 list_del(&kip->list);
75128 - module_free(NULL, kip->insns);
75129 + module_free_exec(NULL, kip->insns);
75130 kfree(kip);
75131 }
75132 return 1;
75133 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
75134 {
75135 int i, err = 0;
75136 unsigned long offset = 0, size = 0;
75137 - char *modname, namebuf[128];
75138 + char *modname, namebuf[KSYM_NAME_LEN];
75139 const char *symbol_name;
75140 void *addr;
75141 struct kprobe_blackpoint *kb;
75142 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
75143 kprobe_type = "k";
75144
75145 if (sym)
75146 - seq_printf(pi, "%p %s %s+0x%x %s ",
75147 + seq_printf(pi, "%pK %s %s+0x%x %s ",
75148 p->addr, kprobe_type, sym, offset,
75149 (modname ? modname : " "));
75150 else
75151 - seq_printf(pi, "%p %s %p ",
75152 + seq_printf(pi, "%pK %s %pK ",
75153 p->addr, kprobe_type, p->addr);
75154
75155 if (!pp)
75156 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
75157 const char *sym = NULL;
75158 unsigned int i = *(loff_t *) v;
75159 unsigned long offset = 0;
75160 - char *modname, namebuf[128];
75161 + char *modname, namebuf[KSYM_NAME_LEN];
75162
75163 head = &kprobe_table[i];
75164 preempt_disable();
75165 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
75166 index 6ada93c..dce7d5d 100644
75167 --- a/kernel/ksysfs.c
75168 +++ b/kernel/ksysfs.c
75169 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
75170 {
75171 if (count+1 > UEVENT_HELPER_PATH_LEN)
75172 return -ENOENT;
75173 + if (!capable(CAP_SYS_ADMIN))
75174 + return -EPERM;
75175 memcpy(uevent_helper, buf, count);
75176 uevent_helper[count] = '\0';
75177 if (count && uevent_helper[count-1] == '\n')
75178 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
75179 return count;
75180 }
75181
75182 -static struct bin_attribute notes_attr = {
75183 +static bin_attribute_no_const notes_attr __read_only = {
75184 .attr = {
75185 .name = "notes",
75186 .mode = S_IRUGO,
75187 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
75188 index 7981e5b..7f2105c 100644
75189 --- a/kernel/lockdep.c
75190 +++ b/kernel/lockdep.c
75191 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
75192 end = (unsigned long) &_end,
75193 addr = (unsigned long) obj;
75194
75195 +#ifdef CONFIG_PAX_KERNEXEC
75196 + start = ktla_ktva(start);
75197 +#endif
75198 +
75199 /*
75200 * static variable?
75201 */
75202 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
75203 if (!static_obj(lock->key)) {
75204 debug_locks_off();
75205 printk("INFO: trying to register non-static key.\n");
75206 + printk("lock:%pS key:%pS.\n", lock, lock->key);
75207 printk("the code is fine but needs lockdep annotation.\n");
75208 printk("turning off the locking correctness validator.\n");
75209 dump_stack();
75210 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
75211 if (!class)
75212 return 0;
75213 }
75214 - atomic_inc((atomic_t *)&class->ops);
75215 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
75216 if (very_verbose(class)) {
75217 printk("\nacquire class [%p] %s", class->key, class->name);
75218 if (class->name_version > 1)
75219 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
75220 index b2c71c5..7b88d63 100644
75221 --- a/kernel/lockdep_proc.c
75222 +++ b/kernel/lockdep_proc.c
75223 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
75224 return 0;
75225 }
75226
75227 - seq_printf(m, "%p", class->key);
75228 + seq_printf(m, "%pK", class->key);
75229 #ifdef CONFIG_DEBUG_LOCKDEP
75230 seq_printf(m, " OPS:%8ld", class->ops);
75231 #endif
75232 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
75233
75234 list_for_each_entry(entry, &class->locks_after, entry) {
75235 if (entry->distance == 1) {
75236 - seq_printf(m, " -> [%p] ", entry->class->key);
75237 + seq_printf(m, " -> [%pK] ", entry->class->key);
75238 print_name(m, entry->class);
75239 seq_puts(m, "\n");
75240 }
75241 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
75242 if (!class->key)
75243 continue;
75244
75245 - seq_printf(m, "[%p] ", class->key);
75246 + seq_printf(m, "[%pK] ", class->key);
75247 print_name(m, class);
75248 seq_puts(m, "\n");
75249 }
75250 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75251 if (!i)
75252 seq_line(m, '-', 40-namelen, namelen);
75253
75254 - snprintf(ip, sizeof(ip), "[<%p>]",
75255 + snprintf(ip, sizeof(ip), "[<%pK>]",
75256 (void *)class->contention_point[i]);
75257 seq_printf(m, "%40s %14lu %29s %pS\n",
75258 name, stats->contention_point[i],
75259 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75260 if (!i)
75261 seq_line(m, '-', 40-namelen, namelen);
75262
75263 - snprintf(ip, sizeof(ip), "[<%p>]",
75264 + snprintf(ip, sizeof(ip), "[<%pK>]",
75265 (void *)class->contending_point[i]);
75266 seq_printf(m, "%40s %14lu %29s %pS\n",
75267 name, stats->contending_point[i],
75268 diff --git a/kernel/module.c b/kernel/module.c
75269 index eab0827..f488603 100644
75270 --- a/kernel/module.c
75271 +++ b/kernel/module.c
75272 @@ -61,6 +61,7 @@
75273 #include <linux/pfn.h>
75274 #include <linux/bsearch.h>
75275 #include <linux/fips.h>
75276 +#include <linux/grsecurity.h>
75277 #include <uapi/linux/module.h>
75278 #include "module-internal.h"
75279
75280 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
75281
75282 /* Bounds of module allocation, for speeding __module_address.
75283 * Protected by module_mutex. */
75284 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
75285 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
75286 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
75287
75288 int register_module_notifier(struct notifier_block * nb)
75289 {
75290 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75291 return true;
75292
75293 list_for_each_entry_rcu(mod, &modules, list) {
75294 - struct symsearch arr[] = {
75295 + struct symsearch modarr[] = {
75296 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
75297 NOT_GPL_ONLY, false },
75298 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
75299 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75300 if (mod->state == MODULE_STATE_UNFORMED)
75301 continue;
75302
75303 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
75304 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
75305 return true;
75306 }
75307 return false;
75308 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
75309 static int percpu_modalloc(struct module *mod,
75310 unsigned long size, unsigned long align)
75311 {
75312 - if (align > PAGE_SIZE) {
75313 + if (align-1 >= PAGE_SIZE) {
75314 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
75315 mod->name, align, PAGE_SIZE);
75316 align = PAGE_SIZE;
75317 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
75318 static ssize_t show_coresize(struct module_attribute *mattr,
75319 struct module_kobject *mk, char *buffer)
75320 {
75321 - return sprintf(buffer, "%u\n", mk->mod->core_size);
75322 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
75323 }
75324
75325 static struct module_attribute modinfo_coresize =
75326 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
75327 static ssize_t show_initsize(struct module_attribute *mattr,
75328 struct module_kobject *mk, char *buffer)
75329 {
75330 - return sprintf(buffer, "%u\n", mk->mod->init_size);
75331 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
75332 }
75333
75334 static struct module_attribute modinfo_initsize =
75335 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
75336 */
75337 #ifdef CONFIG_SYSFS
75338
75339 -#ifdef CONFIG_KALLSYMS
75340 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75341 static inline bool sect_empty(const Elf_Shdr *sect)
75342 {
75343 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
75344 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
75345 {
75346 unsigned int notes, loaded, i;
75347 struct module_notes_attrs *notes_attrs;
75348 - struct bin_attribute *nattr;
75349 + bin_attribute_no_const *nattr;
75350
75351 /* failed to create section attributes, so can't create notes */
75352 if (!mod->sect_attrs)
75353 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
75354 static int module_add_modinfo_attrs(struct module *mod)
75355 {
75356 struct module_attribute *attr;
75357 - struct module_attribute *temp_attr;
75358 + module_attribute_no_const *temp_attr;
75359 int error = 0;
75360 int i;
75361
75362 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
75363
75364 static void unset_module_core_ro_nx(struct module *mod)
75365 {
75366 - set_page_attributes(mod->module_core + mod->core_text_size,
75367 - mod->module_core + mod->core_size,
75368 + set_page_attributes(mod->module_core_rw,
75369 + mod->module_core_rw + mod->core_size_rw,
75370 set_memory_x);
75371 - set_page_attributes(mod->module_core,
75372 - mod->module_core + mod->core_ro_size,
75373 + set_page_attributes(mod->module_core_rx,
75374 + mod->module_core_rx + mod->core_size_rx,
75375 set_memory_rw);
75376 }
75377
75378 static void unset_module_init_ro_nx(struct module *mod)
75379 {
75380 - set_page_attributes(mod->module_init + mod->init_text_size,
75381 - mod->module_init + mod->init_size,
75382 + set_page_attributes(mod->module_init_rw,
75383 + mod->module_init_rw + mod->init_size_rw,
75384 set_memory_x);
75385 - set_page_attributes(mod->module_init,
75386 - mod->module_init + mod->init_ro_size,
75387 + set_page_attributes(mod->module_init_rx,
75388 + mod->module_init_rx + mod->init_size_rx,
75389 set_memory_rw);
75390 }
75391
75392 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
75393 list_for_each_entry_rcu(mod, &modules, list) {
75394 if (mod->state == MODULE_STATE_UNFORMED)
75395 continue;
75396 - if ((mod->module_core) && (mod->core_text_size)) {
75397 - set_page_attributes(mod->module_core,
75398 - mod->module_core + mod->core_text_size,
75399 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75400 + set_page_attributes(mod->module_core_rx,
75401 + mod->module_core_rx + mod->core_size_rx,
75402 set_memory_rw);
75403 }
75404 - if ((mod->module_init) && (mod->init_text_size)) {
75405 - set_page_attributes(mod->module_init,
75406 - mod->module_init + mod->init_text_size,
75407 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75408 + set_page_attributes(mod->module_init_rx,
75409 + mod->module_init_rx + mod->init_size_rx,
75410 set_memory_rw);
75411 }
75412 }
75413 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
75414 list_for_each_entry_rcu(mod, &modules, list) {
75415 if (mod->state == MODULE_STATE_UNFORMED)
75416 continue;
75417 - if ((mod->module_core) && (mod->core_text_size)) {
75418 - set_page_attributes(mod->module_core,
75419 - mod->module_core + mod->core_text_size,
75420 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75421 + set_page_attributes(mod->module_core_rx,
75422 + mod->module_core_rx + mod->core_size_rx,
75423 set_memory_ro);
75424 }
75425 - if ((mod->module_init) && (mod->init_text_size)) {
75426 - set_page_attributes(mod->module_init,
75427 - mod->module_init + mod->init_text_size,
75428 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75429 + set_page_attributes(mod->module_init_rx,
75430 + mod->module_init_rx + mod->init_size_rx,
75431 set_memory_ro);
75432 }
75433 }
75434 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
75435
75436 /* This may be NULL, but that's OK */
75437 unset_module_init_ro_nx(mod);
75438 - module_free(mod, mod->module_init);
75439 + module_free(mod, mod->module_init_rw);
75440 + module_free_exec(mod, mod->module_init_rx);
75441 kfree(mod->args);
75442 percpu_modfree(mod);
75443
75444 /* Free lock-classes: */
75445 - lockdep_free_key_range(mod->module_core, mod->core_size);
75446 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
75447 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
75448
75449 /* Finally, free the core (containing the module structure) */
75450 unset_module_core_ro_nx(mod);
75451 - module_free(mod, mod->module_core);
75452 + module_free_exec(mod, mod->module_core_rx);
75453 + module_free(mod, mod->module_core_rw);
75454
75455 #ifdef CONFIG_MPU
75456 update_protections(current->mm);
75457 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75458 int ret = 0;
75459 const struct kernel_symbol *ksym;
75460
75461 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75462 + int is_fs_load = 0;
75463 + int register_filesystem_found = 0;
75464 + char *p;
75465 +
75466 + p = strstr(mod->args, "grsec_modharden_fs");
75467 + if (p) {
75468 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
75469 + /* copy \0 as well */
75470 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
75471 + is_fs_load = 1;
75472 + }
75473 +#endif
75474 +
75475 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
75476 const char *name = info->strtab + sym[i].st_name;
75477
75478 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75479 + /* it's a real shame this will never get ripped and copied
75480 + upstream! ;(
75481 + */
75482 + if (is_fs_load && !strcmp(name, "register_filesystem"))
75483 + register_filesystem_found = 1;
75484 +#endif
75485 +
75486 switch (sym[i].st_shndx) {
75487 case SHN_COMMON:
75488 /* We compiled with -fno-common. These are not
75489 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75490 ksym = resolve_symbol_wait(mod, info, name);
75491 /* Ok if resolved. */
75492 if (ksym && !IS_ERR(ksym)) {
75493 + pax_open_kernel();
75494 sym[i].st_value = ksym->value;
75495 + pax_close_kernel();
75496 break;
75497 }
75498
75499 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75500 secbase = (unsigned long)mod_percpu(mod);
75501 else
75502 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
75503 + pax_open_kernel();
75504 sym[i].st_value += secbase;
75505 + pax_close_kernel();
75506 break;
75507 }
75508 }
75509
75510 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75511 + if (is_fs_load && !register_filesystem_found) {
75512 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
75513 + ret = -EPERM;
75514 + }
75515 +#endif
75516 +
75517 return ret;
75518 }
75519
75520 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
75521 || s->sh_entsize != ~0UL
75522 || strstarts(sname, ".init"))
75523 continue;
75524 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
75525 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75526 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
75527 + else
75528 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
75529 pr_debug("\t%s\n", sname);
75530 }
75531 - switch (m) {
75532 - case 0: /* executable */
75533 - mod->core_size = debug_align(mod->core_size);
75534 - mod->core_text_size = mod->core_size;
75535 - break;
75536 - case 1: /* RO: text and ro-data */
75537 - mod->core_size = debug_align(mod->core_size);
75538 - mod->core_ro_size = mod->core_size;
75539 - break;
75540 - case 3: /* whole core */
75541 - mod->core_size = debug_align(mod->core_size);
75542 - break;
75543 - }
75544 }
75545
75546 pr_debug("Init section allocation order:\n");
75547 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
75548 || s->sh_entsize != ~0UL
75549 || !strstarts(sname, ".init"))
75550 continue;
75551 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
75552 - | INIT_OFFSET_MASK);
75553 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75554 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
75555 + else
75556 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
75557 + s->sh_entsize |= INIT_OFFSET_MASK;
75558 pr_debug("\t%s\n", sname);
75559 }
75560 - switch (m) {
75561 - case 0: /* executable */
75562 - mod->init_size = debug_align(mod->init_size);
75563 - mod->init_text_size = mod->init_size;
75564 - break;
75565 - case 1: /* RO: text and ro-data */
75566 - mod->init_size = debug_align(mod->init_size);
75567 - mod->init_ro_size = mod->init_size;
75568 - break;
75569 - case 3: /* whole init */
75570 - mod->init_size = debug_align(mod->init_size);
75571 - break;
75572 - }
75573 }
75574 }
75575
75576 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75577
75578 /* Put symbol section at end of init part of module. */
75579 symsect->sh_flags |= SHF_ALLOC;
75580 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
75581 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
75582 info->index.sym) | INIT_OFFSET_MASK;
75583 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
75584
75585 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75586 }
75587
75588 /* Append room for core symbols at end of core part. */
75589 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
75590 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
75591 - mod->core_size += strtab_size;
75592 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
75593 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
75594 + mod->core_size_rx += strtab_size;
75595
75596 /* Put string table section at end of init part of module. */
75597 strsect->sh_flags |= SHF_ALLOC;
75598 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
75599 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
75600 info->index.str) | INIT_OFFSET_MASK;
75601 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
75602 }
75603 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75604 /* Make sure we get permanent strtab: don't use info->strtab. */
75605 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
75606
75607 + pax_open_kernel();
75608 +
75609 /* Set types up while we still have access to sections. */
75610 for (i = 0; i < mod->num_symtab; i++)
75611 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
75612
75613 - mod->core_symtab = dst = mod->module_core + info->symoffs;
75614 - mod->core_strtab = s = mod->module_core + info->stroffs;
75615 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
75616 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
75617 src = mod->symtab;
75618 for (ndst = i = 0; i < mod->num_symtab; i++) {
75619 if (i == 0 ||
75620 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75621 }
75622 }
75623 mod->core_num_syms = ndst;
75624 +
75625 + pax_close_kernel();
75626 }
75627 #else
75628 static inline void layout_symtab(struct module *mod, struct load_info *info)
75629 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
75630 return vmalloc_exec(size);
75631 }
75632
75633 -static void *module_alloc_update_bounds(unsigned long size)
75634 +static void *module_alloc_update_bounds_rw(unsigned long size)
75635 {
75636 void *ret = module_alloc(size);
75637
75638 if (ret) {
75639 mutex_lock(&module_mutex);
75640 /* Update module bounds. */
75641 - if ((unsigned long)ret < module_addr_min)
75642 - module_addr_min = (unsigned long)ret;
75643 - if ((unsigned long)ret + size > module_addr_max)
75644 - module_addr_max = (unsigned long)ret + size;
75645 + if ((unsigned long)ret < module_addr_min_rw)
75646 + module_addr_min_rw = (unsigned long)ret;
75647 + if ((unsigned long)ret + size > module_addr_max_rw)
75648 + module_addr_max_rw = (unsigned long)ret + size;
75649 + mutex_unlock(&module_mutex);
75650 + }
75651 + return ret;
75652 +}
75653 +
75654 +static void *module_alloc_update_bounds_rx(unsigned long size)
75655 +{
75656 + void *ret = module_alloc_exec(size);
75657 +
75658 + if (ret) {
75659 + mutex_lock(&module_mutex);
75660 + /* Update module bounds. */
75661 + if ((unsigned long)ret < module_addr_min_rx)
75662 + module_addr_min_rx = (unsigned long)ret;
75663 + if ((unsigned long)ret + size > module_addr_max_rx)
75664 + module_addr_max_rx = (unsigned long)ret + size;
75665 mutex_unlock(&module_mutex);
75666 }
75667 return ret;
75668 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
75669 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
75670 {
75671 const char *modmagic = get_modinfo(info, "vermagic");
75672 + const char *license = get_modinfo(info, "license");
75673 int err;
75674
75675 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
75676 + if (!license || !license_is_gpl_compatible(license))
75677 + return -ENOEXEC;
75678 +#endif
75679 +
75680 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
75681 modmagic = NULL;
75682
75683 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
75684 }
75685
75686 /* Set up license info based on the info section */
75687 - set_license(mod, get_modinfo(info, "license"));
75688 + set_license(mod, license);
75689
75690 return 0;
75691 }
75692 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
75693 void *ptr;
75694
75695 /* Do the allocs. */
75696 - ptr = module_alloc_update_bounds(mod->core_size);
75697 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
75698 /*
75699 * The pointer to this block is stored in the module structure
75700 * which is inside the block. Just mark it as not being a
75701 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
75702 if (!ptr)
75703 return -ENOMEM;
75704
75705 - memset(ptr, 0, mod->core_size);
75706 - mod->module_core = ptr;
75707 + memset(ptr, 0, mod->core_size_rw);
75708 + mod->module_core_rw = ptr;
75709
75710 - if (mod->init_size) {
75711 - ptr = module_alloc_update_bounds(mod->init_size);
75712 + if (mod->init_size_rw) {
75713 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
75714 /*
75715 * The pointer to this block is stored in the module structure
75716 * which is inside the block. This block doesn't need to be
75717 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
75718 */
75719 kmemleak_ignore(ptr);
75720 if (!ptr) {
75721 - module_free(mod, mod->module_core);
75722 + module_free(mod, mod->module_core_rw);
75723 return -ENOMEM;
75724 }
75725 - memset(ptr, 0, mod->init_size);
75726 - mod->module_init = ptr;
75727 + memset(ptr, 0, mod->init_size_rw);
75728 + mod->module_init_rw = ptr;
75729 } else
75730 - mod->module_init = NULL;
75731 + mod->module_init_rw = NULL;
75732 +
75733 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
75734 + kmemleak_not_leak(ptr);
75735 + if (!ptr) {
75736 + if (mod->module_init_rw)
75737 + module_free(mod, mod->module_init_rw);
75738 + module_free(mod, mod->module_core_rw);
75739 + return -ENOMEM;
75740 + }
75741 +
75742 + pax_open_kernel();
75743 + memset(ptr, 0, mod->core_size_rx);
75744 + pax_close_kernel();
75745 + mod->module_core_rx = ptr;
75746 +
75747 + if (mod->init_size_rx) {
75748 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
75749 + kmemleak_ignore(ptr);
75750 + if (!ptr && mod->init_size_rx) {
75751 + module_free_exec(mod, mod->module_core_rx);
75752 + if (mod->module_init_rw)
75753 + module_free(mod, mod->module_init_rw);
75754 + module_free(mod, mod->module_core_rw);
75755 + return -ENOMEM;
75756 + }
75757 +
75758 + pax_open_kernel();
75759 + memset(ptr, 0, mod->init_size_rx);
75760 + pax_close_kernel();
75761 + mod->module_init_rx = ptr;
75762 + } else
75763 + mod->module_init_rx = NULL;
75764
75765 /* Transfer each section which specifies SHF_ALLOC */
75766 pr_debug("final section addresses:\n");
75767 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
75768 if (!(shdr->sh_flags & SHF_ALLOC))
75769 continue;
75770
75771 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
75772 - dest = mod->module_init
75773 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75774 - else
75775 - dest = mod->module_core + shdr->sh_entsize;
75776 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
75777 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
75778 + dest = mod->module_init_rw
75779 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75780 + else
75781 + dest = mod->module_init_rx
75782 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75783 + } else {
75784 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
75785 + dest = mod->module_core_rw + shdr->sh_entsize;
75786 + else
75787 + dest = mod->module_core_rx + shdr->sh_entsize;
75788 + }
75789 +
75790 + if (shdr->sh_type != SHT_NOBITS) {
75791 +
75792 +#ifdef CONFIG_PAX_KERNEXEC
75793 +#ifdef CONFIG_X86_64
75794 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
75795 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
75796 +#endif
75797 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
75798 + pax_open_kernel();
75799 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
75800 + pax_close_kernel();
75801 + } else
75802 +#endif
75803
75804 - if (shdr->sh_type != SHT_NOBITS)
75805 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
75806 + }
75807 /* Update sh_addr to point to copy in image. */
75808 - shdr->sh_addr = (unsigned long)dest;
75809 +
75810 +#ifdef CONFIG_PAX_KERNEXEC
75811 + if (shdr->sh_flags & SHF_EXECINSTR)
75812 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
75813 + else
75814 +#endif
75815 +
75816 + shdr->sh_addr = (unsigned long)dest;
75817 pr_debug("\t0x%lx %s\n",
75818 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
75819 }
75820 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
75821 * Do it before processing of module parameters, so the module
75822 * can provide parameter accessor functions of its own.
75823 */
75824 - if (mod->module_init)
75825 - flush_icache_range((unsigned long)mod->module_init,
75826 - (unsigned long)mod->module_init
75827 - + mod->init_size);
75828 - flush_icache_range((unsigned long)mod->module_core,
75829 - (unsigned long)mod->module_core + mod->core_size);
75830 + if (mod->module_init_rx)
75831 + flush_icache_range((unsigned long)mod->module_init_rx,
75832 + (unsigned long)mod->module_init_rx
75833 + + mod->init_size_rx);
75834 + flush_icache_range((unsigned long)mod->module_core_rx,
75835 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
75836
75837 set_fs(old_fs);
75838 }
75839 @@ -2983,8 +3088,10 @@ out:
75840 static void module_deallocate(struct module *mod, struct load_info *info)
75841 {
75842 percpu_modfree(mod);
75843 - module_free(mod, mod->module_init);
75844 - module_free(mod, mod->module_core);
75845 + module_free_exec(mod, mod->module_init_rx);
75846 + module_free_exec(mod, mod->module_core_rx);
75847 + module_free(mod, mod->module_init_rw);
75848 + module_free(mod, mod->module_core_rw);
75849 }
75850
75851 int __weak module_finalize(const Elf_Ehdr *hdr,
75852 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
75853 static int post_relocation(struct module *mod, const struct load_info *info)
75854 {
75855 /* Sort exception table now relocations are done. */
75856 + pax_open_kernel();
75857 sort_extable(mod->extable, mod->extable + mod->num_exentries);
75858 + pax_close_kernel();
75859
75860 /* Copy relocated percpu area over. */
75861 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
75862 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
75863 MODULE_STATE_COMING, mod);
75864
75865 /* Set RO and NX regions for core */
75866 - set_section_ro_nx(mod->module_core,
75867 - mod->core_text_size,
75868 - mod->core_ro_size,
75869 - mod->core_size);
75870 + set_section_ro_nx(mod->module_core_rx,
75871 + mod->core_size_rx,
75872 + mod->core_size_rx,
75873 + mod->core_size_rx);
75874
75875 /* Set RO and NX regions for init */
75876 - set_section_ro_nx(mod->module_init,
75877 - mod->init_text_size,
75878 - mod->init_ro_size,
75879 - mod->init_size);
75880 + set_section_ro_nx(mod->module_init_rx,
75881 + mod->init_size_rx,
75882 + mod->init_size_rx,
75883 + mod->init_size_rx);
75884
75885 do_mod_ctors(mod);
75886 /* Start the module */
75887 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
75888 mod->strtab = mod->core_strtab;
75889 #endif
75890 unset_module_init_ro_nx(mod);
75891 - module_free(mod, mod->module_init);
75892 - mod->module_init = NULL;
75893 - mod->init_size = 0;
75894 - mod->init_ro_size = 0;
75895 - mod->init_text_size = 0;
75896 + module_free(mod, mod->module_init_rw);
75897 + module_free_exec(mod, mod->module_init_rx);
75898 + mod->module_init_rw = NULL;
75899 + mod->module_init_rx = NULL;
75900 + mod->init_size_rw = 0;
75901 + mod->init_size_rx = 0;
75902 mutex_unlock(&module_mutex);
75903 wake_up_all(&module_wq);
75904
75905 @@ -3209,9 +3319,38 @@ again:
75906 if (err)
75907 goto free_unload;
75908
75909 + /* Now copy in args */
75910 + mod->args = strndup_user(uargs, ~0UL >> 1);
75911 + if (IS_ERR(mod->args)) {
75912 + err = PTR_ERR(mod->args);
75913 + goto free_unload;
75914 + }
75915 +
75916 /* Set up MODINFO_ATTR fields */
75917 setup_modinfo(mod, info);
75918
75919 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75920 + {
75921 + char *p, *p2;
75922 +
75923 + if (strstr(mod->args, "grsec_modharden_netdev")) {
75924 + 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);
75925 + err = -EPERM;
75926 + goto free_modinfo;
75927 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
75928 + p += sizeof("grsec_modharden_normal") - 1;
75929 + p2 = strstr(p, "_");
75930 + if (p2) {
75931 + *p2 = '\0';
75932 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
75933 + *p2 = '_';
75934 + }
75935 + err = -EPERM;
75936 + goto free_modinfo;
75937 + }
75938 + }
75939 +#endif
75940 +
75941 /* Fix up syms, so that st_value is a pointer to location. */
75942 err = simplify_symbols(mod, info);
75943 if (err < 0)
75944 @@ -3227,13 +3366,6 @@ again:
75945
75946 flush_module_icache(mod);
75947
75948 - /* Now copy in args */
75949 - mod->args = strndup_user(uargs, ~0UL >> 1);
75950 - if (IS_ERR(mod->args)) {
75951 - err = PTR_ERR(mod->args);
75952 - goto free_arch_cleanup;
75953 - }
75954 -
75955 dynamic_debug_setup(info->debug, info->num_debug);
75956
75957 mutex_lock(&module_mutex);
75958 @@ -3278,11 +3410,10 @@ again:
75959 mutex_unlock(&module_mutex);
75960 dynamic_debug_remove(info->debug);
75961 synchronize_sched();
75962 - kfree(mod->args);
75963 - free_arch_cleanup:
75964 module_arch_cleanup(mod);
75965 free_modinfo:
75966 free_modinfo(mod);
75967 + kfree(mod->args);
75968 free_unload:
75969 module_unload_free(mod);
75970 unlink_mod:
75971 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
75972 unsigned long nextval;
75973
75974 /* At worse, next value is at end of module */
75975 - if (within_module_init(addr, mod))
75976 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
75977 + if (within_module_init_rx(addr, mod))
75978 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
75979 + else if (within_module_init_rw(addr, mod))
75980 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
75981 + else if (within_module_core_rx(addr, mod))
75982 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
75983 + else if (within_module_core_rw(addr, mod))
75984 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
75985 else
75986 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
75987 + return NULL;
75988
75989 /* Scan for closest preceding symbol, and next symbol. (ELF
75990 starts real symbols at 1). */
75991 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
75992 return 0;
75993
75994 seq_printf(m, "%s %u",
75995 - mod->name, mod->init_size + mod->core_size);
75996 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
75997 print_unload_info(m, mod);
75998
75999 /* Informative for users. */
76000 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
76001 mod->state == MODULE_STATE_COMING ? "Loading":
76002 "Live");
76003 /* Used by oprofile and other similar tools. */
76004 - seq_printf(m, " 0x%pK", mod->module_core);
76005 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76006
76007 /* Taints info */
76008 if (mod->taints)
76009 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
76010
76011 static int __init proc_modules_init(void)
76012 {
76013 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76014 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76015 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76016 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76017 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76018 +#else
76019 proc_create("modules", 0, NULL, &proc_modules_operations);
76020 +#endif
76021 +#else
76022 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76023 +#endif
76024 return 0;
76025 }
76026 module_init(proc_modules_init);
76027 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
76028 {
76029 struct module *mod;
76030
76031 - if (addr < module_addr_min || addr > module_addr_max)
76032 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76033 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76034 return NULL;
76035
76036 list_for_each_entry_rcu(mod, &modules, list) {
76037 if (mod->state == MODULE_STATE_UNFORMED)
76038 continue;
76039 - if (within_module_core(addr, mod)
76040 - || within_module_init(addr, mod))
76041 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76042 return mod;
76043 }
76044 return NULL;
76045 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
76046 */
76047 struct module *__module_text_address(unsigned long addr)
76048 {
76049 - struct module *mod = __module_address(addr);
76050 + struct module *mod;
76051 +
76052 +#ifdef CONFIG_X86_32
76053 + addr = ktla_ktva(addr);
76054 +#endif
76055 +
76056 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76057 + return NULL;
76058 +
76059 + mod = __module_address(addr);
76060 +
76061 if (mod) {
76062 /* Make sure it's within the text section. */
76063 - if (!within(addr, mod->module_init, mod->init_text_size)
76064 - && !within(addr, mod->module_core, mod->core_text_size))
76065 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76066 mod = NULL;
76067 }
76068 return mod;
76069 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76070 index 7e3443f..b2a1e6b 100644
76071 --- a/kernel/mutex-debug.c
76072 +++ b/kernel/mutex-debug.c
76073 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76074 }
76075
76076 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76077 - struct thread_info *ti)
76078 + struct task_struct *task)
76079 {
76080 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76081
76082 /* Mark the current thread as blocked on the lock: */
76083 - ti->task->blocked_on = waiter;
76084 + task->blocked_on = waiter;
76085 }
76086
76087 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76088 - struct thread_info *ti)
76089 + struct task_struct *task)
76090 {
76091 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76092 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76093 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76094 - ti->task->blocked_on = NULL;
76095 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76096 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76097 + task->blocked_on = NULL;
76098
76099 list_del_init(&waiter->list);
76100 waiter->task = NULL;
76101 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
76102 index 0799fd3..d06ae3b 100644
76103 --- a/kernel/mutex-debug.h
76104 +++ b/kernel/mutex-debug.h
76105 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
76106 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
76107 extern void debug_mutex_add_waiter(struct mutex *lock,
76108 struct mutex_waiter *waiter,
76109 - struct thread_info *ti);
76110 + struct task_struct *task);
76111 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76112 - struct thread_info *ti);
76113 + struct task_struct *task);
76114 extern void debug_mutex_unlock(struct mutex *lock);
76115 extern void debug_mutex_init(struct mutex *lock, const char *name,
76116 struct lock_class_key *key);
76117 diff --git a/kernel/mutex.c b/kernel/mutex.c
76118 index a307cc9..27fd2e9 100644
76119 --- a/kernel/mutex.c
76120 +++ b/kernel/mutex.c
76121 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76122 spin_lock_mutex(&lock->wait_lock, flags);
76123
76124 debug_mutex_lock_common(lock, &waiter);
76125 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
76126 + debug_mutex_add_waiter(lock, &waiter, task);
76127
76128 /* add waiting tasks to the end of the waitqueue (FIFO): */
76129 list_add_tail(&waiter.list, &lock->wait_list);
76130 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76131 * TASK_UNINTERRUPTIBLE case.)
76132 */
76133 if (unlikely(signal_pending_state(state, task))) {
76134 - mutex_remove_waiter(lock, &waiter,
76135 - task_thread_info(task));
76136 + mutex_remove_waiter(lock, &waiter, task);
76137 mutex_release(&lock->dep_map, 1, ip);
76138 spin_unlock_mutex(&lock->wait_lock, flags);
76139
76140 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76141 done:
76142 lock_acquired(&lock->dep_map, ip);
76143 /* got the lock - rejoice! */
76144 - mutex_remove_waiter(lock, &waiter, current_thread_info());
76145 + mutex_remove_waiter(lock, &waiter, task);
76146 mutex_set_owner(lock);
76147
76148 /* set it to 0 if there are no waiters left: */
76149 diff --git a/kernel/notifier.c b/kernel/notifier.c
76150 index 2d5cc4c..d9ea600 100644
76151 --- a/kernel/notifier.c
76152 +++ b/kernel/notifier.c
76153 @@ -5,6 +5,7 @@
76154 #include <linux/rcupdate.h>
76155 #include <linux/vmalloc.h>
76156 #include <linux/reboot.h>
76157 +#include <linux/mm.h>
76158
76159 /*
76160 * Notifier list for kernel code which wants to be called
76161 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
76162 while ((*nl) != NULL) {
76163 if (n->priority > (*nl)->priority)
76164 break;
76165 - nl = &((*nl)->next);
76166 + nl = (struct notifier_block **)&((*nl)->next);
76167 }
76168 - n->next = *nl;
76169 + pax_open_kernel();
76170 + *(const void **)&n->next = *nl;
76171 rcu_assign_pointer(*nl, n);
76172 + pax_close_kernel();
76173 return 0;
76174 }
76175
76176 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
76177 return 0;
76178 if (n->priority > (*nl)->priority)
76179 break;
76180 - nl = &((*nl)->next);
76181 + nl = (struct notifier_block **)&((*nl)->next);
76182 }
76183 - n->next = *nl;
76184 + pax_open_kernel();
76185 + *(const void **)&n->next = *nl;
76186 rcu_assign_pointer(*nl, n);
76187 + pax_close_kernel();
76188 return 0;
76189 }
76190
76191 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
76192 {
76193 while ((*nl) != NULL) {
76194 if ((*nl) == n) {
76195 + pax_open_kernel();
76196 rcu_assign_pointer(*nl, n->next);
76197 + pax_close_kernel();
76198 return 0;
76199 }
76200 - nl = &((*nl)->next);
76201 + nl = (struct notifier_block **)&((*nl)->next);
76202 }
76203 return -ENOENT;
76204 }
76205 diff --git a/kernel/panic.c b/kernel/panic.c
76206 index e1b2822..5edc1d9 100644
76207 --- a/kernel/panic.c
76208 +++ b/kernel/panic.c
76209 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
76210 const char *board;
76211
76212 printk(KERN_WARNING "------------[ cut here ]------------\n");
76213 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
76214 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
76215 board = dmi_get_system_info(DMI_PRODUCT_NAME);
76216 if (board)
76217 printk(KERN_WARNING "Hardware name: %s\n", board);
76218 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
76219 */
76220 void __stack_chk_fail(void)
76221 {
76222 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
76223 + dump_stack();
76224 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
76225 __builtin_return_address(0));
76226 }
76227 EXPORT_SYMBOL(__stack_chk_fail);
76228 diff --git a/kernel/pid.c b/kernel/pid.c
76229 index f2c6a68..4922d97 100644
76230 --- a/kernel/pid.c
76231 +++ b/kernel/pid.c
76232 @@ -33,6 +33,7 @@
76233 #include <linux/rculist.h>
76234 #include <linux/bootmem.h>
76235 #include <linux/hash.h>
76236 +#include <linux/security.h>
76237 #include <linux/pid_namespace.h>
76238 #include <linux/init_task.h>
76239 #include <linux/syscalls.h>
76240 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
76241
76242 int pid_max = PID_MAX_DEFAULT;
76243
76244 -#define RESERVED_PIDS 300
76245 +#define RESERVED_PIDS 500
76246
76247 int pid_max_min = RESERVED_PIDS + 1;
76248 int pid_max_max = PID_MAX_LIMIT;
76249 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
76250 */
76251 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
76252 {
76253 + struct task_struct *task;
76254 +
76255 rcu_lockdep_assert(rcu_read_lock_held(),
76256 "find_task_by_pid_ns() needs rcu_read_lock()"
76257 " protection");
76258 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76259 +
76260 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76261 +
76262 + if (gr_pid_is_chrooted(task))
76263 + return NULL;
76264 +
76265 + return task;
76266 }
76267
76268 struct task_struct *find_task_by_vpid(pid_t vnr)
76269 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
76270 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
76271 }
76272
76273 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
76274 +{
76275 + rcu_lockdep_assert(rcu_read_lock_held(),
76276 + "find_task_by_pid_ns() needs rcu_read_lock()"
76277 + " protection");
76278 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
76279 +}
76280 +
76281 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
76282 {
76283 struct pid *pid;
76284 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
76285 index c1c3dc1..bbeaf31 100644
76286 --- a/kernel/pid_namespace.c
76287 +++ b/kernel/pid_namespace.c
76288 @@ -248,7 +248,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
76289 void __user *buffer, size_t *lenp, loff_t *ppos)
76290 {
76291 struct pid_namespace *pid_ns = task_active_pid_ns(current);
76292 - struct ctl_table tmp = *table;
76293 + ctl_table_no_const tmp = *table;
76294
76295 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
76296 return -EPERM;
76297 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
76298 index 942ca27..111e609 100644
76299 --- a/kernel/posix-cpu-timers.c
76300 +++ b/kernel/posix-cpu-timers.c
76301 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
76302
76303 static __init int init_posix_cpu_timers(void)
76304 {
76305 - struct k_clock process = {
76306 + static struct k_clock process = {
76307 .clock_getres = process_cpu_clock_getres,
76308 .clock_get = process_cpu_clock_get,
76309 .timer_create = process_cpu_timer_create,
76310 .nsleep = process_cpu_nsleep,
76311 .nsleep_restart = process_cpu_nsleep_restart,
76312 };
76313 - struct k_clock thread = {
76314 + static struct k_clock thread = {
76315 .clock_getres = thread_cpu_clock_getres,
76316 .clock_get = thread_cpu_clock_get,
76317 .timer_create = thread_cpu_timer_create,
76318 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
76319 index e885be1..380fe76 100644
76320 --- a/kernel/posix-timers.c
76321 +++ b/kernel/posix-timers.c
76322 @@ -43,6 +43,7 @@
76323 #include <linux/idr.h>
76324 #include <linux/posix-clock.h>
76325 #include <linux/posix-timers.h>
76326 +#include <linux/grsecurity.h>
76327 #include <linux/syscalls.h>
76328 #include <linux/wait.h>
76329 #include <linux/workqueue.h>
76330 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
76331 * which we beg off on and pass to do_sys_settimeofday().
76332 */
76333
76334 -static struct k_clock posix_clocks[MAX_CLOCKS];
76335 +static struct k_clock *posix_clocks[MAX_CLOCKS];
76336
76337 /*
76338 * These ones are defined below.
76339 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
76340 */
76341 static __init int init_posix_timers(void)
76342 {
76343 - struct k_clock clock_realtime = {
76344 + static struct k_clock clock_realtime = {
76345 .clock_getres = hrtimer_get_res,
76346 .clock_get = posix_clock_realtime_get,
76347 .clock_set = posix_clock_realtime_set,
76348 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
76349 .timer_get = common_timer_get,
76350 .timer_del = common_timer_del,
76351 };
76352 - struct k_clock clock_monotonic = {
76353 + static struct k_clock clock_monotonic = {
76354 .clock_getres = hrtimer_get_res,
76355 .clock_get = posix_ktime_get_ts,
76356 .nsleep = common_nsleep,
76357 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
76358 .timer_get = common_timer_get,
76359 .timer_del = common_timer_del,
76360 };
76361 - struct k_clock clock_monotonic_raw = {
76362 + static struct k_clock clock_monotonic_raw = {
76363 .clock_getres = hrtimer_get_res,
76364 .clock_get = posix_get_monotonic_raw,
76365 };
76366 - struct k_clock clock_realtime_coarse = {
76367 + static struct k_clock clock_realtime_coarse = {
76368 .clock_getres = posix_get_coarse_res,
76369 .clock_get = posix_get_realtime_coarse,
76370 };
76371 - struct k_clock clock_monotonic_coarse = {
76372 + static struct k_clock clock_monotonic_coarse = {
76373 .clock_getres = posix_get_coarse_res,
76374 .clock_get = posix_get_monotonic_coarse,
76375 };
76376 - struct k_clock clock_boottime = {
76377 + static struct k_clock clock_boottime = {
76378 .clock_getres = hrtimer_get_res,
76379 .clock_get = posix_get_boottime,
76380 .nsleep = common_nsleep,
76381 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
76382 return;
76383 }
76384
76385 - posix_clocks[clock_id] = *new_clock;
76386 + posix_clocks[clock_id] = new_clock;
76387 }
76388 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
76389
76390 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
76391 return (id & CLOCKFD_MASK) == CLOCKFD ?
76392 &clock_posix_dynamic : &clock_posix_cpu;
76393
76394 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
76395 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
76396 return NULL;
76397 - return &posix_clocks[id];
76398 + return posix_clocks[id];
76399 }
76400
76401 static int common_timer_create(struct k_itimer *new_timer)
76402 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
76403 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
76404 return -EFAULT;
76405
76406 + /* only the CLOCK_REALTIME clock can be set, all other clocks
76407 + have their clock_set fptr set to a nosettime dummy function
76408 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
76409 + call common_clock_set, which calls do_sys_settimeofday, which
76410 + we hook
76411 + */
76412 +
76413 return kc->clock_set(which_clock, &new_tp);
76414 }
76415
76416 diff --git a/kernel/power/process.c b/kernel/power/process.c
76417 index d5a258b..4271191 100644
76418 --- a/kernel/power/process.c
76419 +++ b/kernel/power/process.c
76420 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
76421 u64 elapsed_csecs64;
76422 unsigned int elapsed_csecs;
76423 bool wakeup = false;
76424 + bool timedout = false;
76425
76426 do_gettimeofday(&start);
76427
76428 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
76429
76430 while (true) {
76431 todo = 0;
76432 + if (time_after(jiffies, end_time))
76433 + timedout = true;
76434 read_lock(&tasklist_lock);
76435 do_each_thread(g, p) {
76436 if (p == current || !freeze_task(p))
76437 continue;
76438
76439 - if (!freezer_should_skip(p))
76440 + if (!freezer_should_skip(p)) {
76441 todo++;
76442 + if (timedout) {
76443 + printk(KERN_ERR "Task refusing to freeze:\n");
76444 + sched_show_task(p);
76445 + }
76446 + }
76447 } while_each_thread(g, p);
76448 read_unlock(&tasklist_lock);
76449
76450 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
76451 todo += wq_busy;
76452 }
76453
76454 - if (!todo || time_after(jiffies, end_time))
76455 + if (!todo || timedout)
76456 break;
76457
76458 if (pm_wakeup_pending()) {
76459 diff --git a/kernel/printk.c b/kernel/printk.c
76460 index 267ce78..2487112 100644
76461 --- a/kernel/printk.c
76462 +++ b/kernel/printk.c
76463 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
76464 return ret;
76465 }
76466
76467 +static int check_syslog_permissions(int type, bool from_file);
76468 +
76469 static int devkmsg_open(struct inode *inode, struct file *file)
76470 {
76471 struct devkmsg_user *user;
76472 int err;
76473
76474 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
76475 + if (err)
76476 + return err;
76477 +
76478 /* write-only does not need any file context */
76479 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
76480 return 0;
76481 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
76482 if (dmesg_restrict)
76483 return 1;
76484 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
76485 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76486 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76487 }
76488
76489 static int check_syslog_permissions(int type, bool from_file)
76490 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
76491 if (from_file && type != SYSLOG_ACTION_OPEN)
76492 return 0;
76493
76494 +#ifdef CONFIG_GRKERNSEC_DMESG
76495 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
76496 + return -EPERM;
76497 +#endif
76498 +
76499 if (syslog_action_restricted(type)) {
76500 if (capable(CAP_SYSLOG))
76501 return 0;
76502 diff --git a/kernel/profile.c b/kernel/profile.c
76503 index 1f39181..86093471 100644
76504 --- a/kernel/profile.c
76505 +++ b/kernel/profile.c
76506 @@ -40,7 +40,7 @@ struct profile_hit {
76507 /* Oprofile timer tick hook */
76508 static int (*timer_hook)(struct pt_regs *) __read_mostly;
76509
76510 -static atomic_t *prof_buffer;
76511 +static atomic_unchecked_t *prof_buffer;
76512 static unsigned long prof_len, prof_shift;
76513
76514 int prof_on __read_mostly;
76515 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
76516 hits[i].pc = 0;
76517 continue;
76518 }
76519 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76520 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76521 hits[i].hits = hits[i].pc = 0;
76522 }
76523 }
76524 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76525 * Add the current hit(s) and flush the write-queue out
76526 * to the global buffer:
76527 */
76528 - atomic_add(nr_hits, &prof_buffer[pc]);
76529 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
76530 for (i = 0; i < NR_PROFILE_HIT; ++i) {
76531 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76532 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76533 hits[i].pc = hits[i].hits = 0;
76534 }
76535 out:
76536 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76537 {
76538 unsigned long pc;
76539 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
76540 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76541 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76542 }
76543 #endif /* !CONFIG_SMP */
76544
76545 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
76546 return -EFAULT;
76547 buf++; p++; count--; read++;
76548 }
76549 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
76550 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
76551 if (copy_to_user(buf, (void *)pnt, count))
76552 return -EFAULT;
76553 read += count;
76554 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
76555 }
76556 #endif
76557 profile_discard_flip_buffers();
76558 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
76559 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
76560 return count;
76561 }
76562
76563 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
76564 index 6cbeaae..cfe7ff0 100644
76565 --- a/kernel/ptrace.c
76566 +++ b/kernel/ptrace.c
76567 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
76568 if (seize)
76569 flags |= PT_SEIZED;
76570 rcu_read_lock();
76571 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76572 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76573 flags |= PT_PTRACE_CAP;
76574 rcu_read_unlock();
76575 task->ptrace = flags;
76576 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
76577 break;
76578 return -EIO;
76579 }
76580 - if (copy_to_user(dst, buf, retval))
76581 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
76582 return -EFAULT;
76583 copied += retval;
76584 src += retval;
76585 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
76586 bool seized = child->ptrace & PT_SEIZED;
76587 int ret = -EIO;
76588 siginfo_t siginfo, *si;
76589 - void __user *datavp = (void __user *) data;
76590 + void __user *datavp = (__force void __user *) data;
76591 unsigned long __user *datalp = datavp;
76592 unsigned long flags;
76593
76594 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
76595 goto out;
76596 }
76597
76598 + if (gr_handle_ptrace(child, request)) {
76599 + ret = -EPERM;
76600 + goto out_put_task_struct;
76601 + }
76602 +
76603 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
76604 ret = ptrace_attach(child, request, addr, data);
76605 /*
76606 * Some architectures need to do book-keeping after
76607 * a ptrace attach.
76608 */
76609 - if (!ret)
76610 + if (!ret) {
76611 arch_ptrace_attach(child);
76612 + gr_audit_ptrace(child);
76613 + }
76614 goto out_put_task_struct;
76615 }
76616
76617 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
76618 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
76619 if (copied != sizeof(tmp))
76620 return -EIO;
76621 - return put_user(tmp, (unsigned long __user *)data);
76622 + return put_user(tmp, (__force unsigned long __user *)data);
76623 }
76624
76625 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
76626 @@ -1051,7 +1058,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
76627 }
76628
76629 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
76630 - compat_long_t addr, compat_long_t data)
76631 + compat_ulong_t addr, compat_ulong_t data)
76632 {
76633 struct task_struct *child;
76634 long ret;
76635 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
76636 goto out;
76637 }
76638
76639 + if (gr_handle_ptrace(child, request)) {
76640 + ret = -EPERM;
76641 + goto out_put_task_struct;
76642 + }
76643 +
76644 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
76645 ret = ptrace_attach(child, request, addr, data);
76646 /*
76647 * Some architectures need to do book-keeping after
76648 * a ptrace attach.
76649 */
76650 - if (!ret)
76651 + if (!ret) {
76652 arch_ptrace_attach(child);
76653 + gr_audit_ptrace(child);
76654 + }
76655 goto out_put_task_struct;
76656 }
76657
76658 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
76659 index e7dce58..ad0d7b7 100644
76660 --- a/kernel/rcutiny.c
76661 +++ b/kernel/rcutiny.c
76662 @@ -46,7 +46,7 @@
76663 struct rcu_ctrlblk;
76664 static void invoke_rcu_callbacks(void);
76665 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
76666 -static void rcu_process_callbacks(struct softirq_action *unused);
76667 +static void rcu_process_callbacks(void);
76668 static void __call_rcu(struct rcu_head *head,
76669 void (*func)(struct rcu_head *rcu),
76670 struct rcu_ctrlblk *rcp);
76671 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
76672 rcu_is_callbacks_kthread()));
76673 }
76674
76675 -static void rcu_process_callbacks(struct softirq_action *unused)
76676 +static void rcu_process_callbacks(void)
76677 {
76678 __rcu_process_callbacks(&rcu_sched_ctrlblk);
76679 __rcu_process_callbacks(&rcu_bh_ctrlblk);
76680 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
76681 index f85016a..91cb03b 100644
76682 --- a/kernel/rcutiny_plugin.h
76683 +++ b/kernel/rcutiny_plugin.h
76684 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
76685 have_rcu_kthread_work = morework;
76686 local_irq_restore(flags);
76687 if (work)
76688 - rcu_process_callbacks(NULL);
76689 + rcu_process_callbacks();
76690 schedule_timeout_interruptible(1); /* Leave CPU for others. */
76691 }
76692
76693 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
76694 index 31dea01..ad91ffb 100644
76695 --- a/kernel/rcutorture.c
76696 +++ b/kernel/rcutorture.c
76697 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
76698 { 0 };
76699 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
76700 { 0 };
76701 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
76702 -static atomic_t n_rcu_torture_alloc;
76703 -static atomic_t n_rcu_torture_alloc_fail;
76704 -static atomic_t n_rcu_torture_free;
76705 -static atomic_t n_rcu_torture_mberror;
76706 -static atomic_t n_rcu_torture_error;
76707 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
76708 +static atomic_unchecked_t n_rcu_torture_alloc;
76709 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
76710 +static atomic_unchecked_t n_rcu_torture_free;
76711 +static atomic_unchecked_t n_rcu_torture_mberror;
76712 +static atomic_unchecked_t n_rcu_torture_error;
76713 static long n_rcu_torture_barrier_error;
76714 static long n_rcu_torture_boost_ktrerror;
76715 static long n_rcu_torture_boost_rterror;
76716 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
76717
76718 spin_lock_bh(&rcu_torture_lock);
76719 if (list_empty(&rcu_torture_freelist)) {
76720 - atomic_inc(&n_rcu_torture_alloc_fail);
76721 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
76722 spin_unlock_bh(&rcu_torture_lock);
76723 return NULL;
76724 }
76725 - atomic_inc(&n_rcu_torture_alloc);
76726 + atomic_inc_unchecked(&n_rcu_torture_alloc);
76727 p = rcu_torture_freelist.next;
76728 list_del_init(p);
76729 spin_unlock_bh(&rcu_torture_lock);
76730 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
76731 static void
76732 rcu_torture_free(struct rcu_torture *p)
76733 {
76734 - atomic_inc(&n_rcu_torture_free);
76735 + atomic_inc_unchecked(&n_rcu_torture_free);
76736 spin_lock_bh(&rcu_torture_lock);
76737 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
76738 spin_unlock_bh(&rcu_torture_lock);
76739 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *p)
76740 i = rp->rtort_pipe_count;
76741 if (i > RCU_TORTURE_PIPE_LEN)
76742 i = RCU_TORTURE_PIPE_LEN;
76743 - atomic_inc(&rcu_torture_wcount[i]);
76744 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76745 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
76746 rp->rtort_mbtest = 0;
76747 rcu_torture_free(rp);
76748 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
76749 i = rp->rtort_pipe_count;
76750 if (i > RCU_TORTURE_PIPE_LEN)
76751 i = RCU_TORTURE_PIPE_LEN;
76752 - atomic_inc(&rcu_torture_wcount[i]);
76753 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76754 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
76755 rp->rtort_mbtest = 0;
76756 list_del(&rp->rtort_free);
76757 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
76758 i = old_rp->rtort_pipe_count;
76759 if (i > RCU_TORTURE_PIPE_LEN)
76760 i = RCU_TORTURE_PIPE_LEN;
76761 - atomic_inc(&rcu_torture_wcount[i]);
76762 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76763 old_rp->rtort_pipe_count++;
76764 cur_ops->deferred_free(old_rp);
76765 }
76766 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
76767 }
76768 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
76769 if (p->rtort_mbtest == 0)
76770 - atomic_inc(&n_rcu_torture_mberror);
76771 + atomic_inc_unchecked(&n_rcu_torture_mberror);
76772 spin_lock(&rand_lock);
76773 cur_ops->read_delay(&rand);
76774 n_rcu_torture_timers++;
76775 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
76776 }
76777 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
76778 if (p->rtort_mbtest == 0)
76779 - atomic_inc(&n_rcu_torture_mberror);
76780 + atomic_inc_unchecked(&n_rcu_torture_mberror);
76781 cur_ops->read_delay(&rand);
76782 preempt_disable();
76783 pipe_count = p->rtort_pipe_count;
76784 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
76785 rcu_torture_current,
76786 rcu_torture_current_version,
76787 list_empty(&rcu_torture_freelist),
76788 - atomic_read(&n_rcu_torture_alloc),
76789 - atomic_read(&n_rcu_torture_alloc_fail),
76790 - atomic_read(&n_rcu_torture_free));
76791 + atomic_read_unchecked(&n_rcu_torture_alloc),
76792 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
76793 + atomic_read_unchecked(&n_rcu_torture_free));
76794 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
76795 - atomic_read(&n_rcu_torture_mberror),
76796 + atomic_read_unchecked(&n_rcu_torture_mberror),
76797 n_rcu_torture_boost_ktrerror,
76798 n_rcu_torture_boost_rterror);
76799 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
76800 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
76801 n_barrier_attempts,
76802 n_rcu_torture_barrier_error);
76803 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
76804 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
76805 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
76806 n_rcu_torture_barrier_error != 0 ||
76807 n_rcu_torture_boost_ktrerror != 0 ||
76808 n_rcu_torture_boost_rterror != 0 ||
76809 n_rcu_torture_boost_failure != 0 ||
76810 i > 1) {
76811 cnt += sprintf(&page[cnt], "!!! ");
76812 - atomic_inc(&n_rcu_torture_error);
76813 + atomic_inc_unchecked(&n_rcu_torture_error);
76814 WARN_ON_ONCE(1);
76815 }
76816 cnt += sprintf(&page[cnt], "Reader Pipe: ");
76817 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
76818 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
76819 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
76820 cnt += sprintf(&page[cnt], " %d",
76821 - atomic_read(&rcu_torture_wcount[i]));
76822 + atomic_read_unchecked(&rcu_torture_wcount[i]));
76823 }
76824 cnt += sprintf(&page[cnt], "\n");
76825 if (cur_ops->stats)
76826 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
76827
76828 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
76829
76830 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
76831 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
76832 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
76833 else if (n_online_successes != n_online_attempts ||
76834 n_offline_successes != n_offline_attempts)
76835 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
76836
76837 rcu_torture_current = NULL;
76838 rcu_torture_current_version = 0;
76839 - atomic_set(&n_rcu_torture_alloc, 0);
76840 - atomic_set(&n_rcu_torture_alloc_fail, 0);
76841 - atomic_set(&n_rcu_torture_free, 0);
76842 - atomic_set(&n_rcu_torture_mberror, 0);
76843 - atomic_set(&n_rcu_torture_error, 0);
76844 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
76845 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
76846 + atomic_set_unchecked(&n_rcu_torture_free, 0);
76847 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
76848 + atomic_set_unchecked(&n_rcu_torture_error, 0);
76849 n_rcu_torture_barrier_error = 0;
76850 n_rcu_torture_boost_ktrerror = 0;
76851 n_rcu_torture_boost_rterror = 0;
76852 n_rcu_torture_boost_failure = 0;
76853 n_rcu_torture_boosts = 0;
76854 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
76855 - atomic_set(&rcu_torture_wcount[i], 0);
76856 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
76857 for_each_possible_cpu(cpu) {
76858 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
76859 per_cpu(rcu_torture_count, cpu)[i] = 0;
76860 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
76861 index e441b77..dd54f17 100644
76862 --- a/kernel/rcutree.c
76863 +++ b/kernel/rcutree.c
76864 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
76865 rcu_prepare_for_idle(smp_processor_id());
76866 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
76867 smp_mb__before_atomic_inc(); /* See above. */
76868 - atomic_inc(&rdtp->dynticks);
76869 + atomic_inc_unchecked(&rdtp->dynticks);
76870 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
76871 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
76872 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
76873
76874 /*
76875 * It is illegal to enter an extended quiescent state while
76876 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
76877 int user)
76878 {
76879 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
76880 - atomic_inc(&rdtp->dynticks);
76881 + atomic_inc_unchecked(&rdtp->dynticks);
76882 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
76883 smp_mb__after_atomic_inc(); /* See above. */
76884 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
76885 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
76886 rcu_cleanup_after_idle(smp_processor_id());
76887 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
76888 if (!user && !is_idle_task(current)) {
76889 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
76890 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
76891
76892 if (rdtp->dynticks_nmi_nesting == 0 &&
76893 - (atomic_read(&rdtp->dynticks) & 0x1))
76894 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
76895 return;
76896 rdtp->dynticks_nmi_nesting++;
76897 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
76898 - atomic_inc(&rdtp->dynticks);
76899 + atomic_inc_unchecked(&rdtp->dynticks);
76900 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
76901 smp_mb__after_atomic_inc(); /* See above. */
76902 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
76903 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
76904 }
76905
76906 /**
76907 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
76908 return;
76909 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
76910 smp_mb__before_atomic_inc(); /* See above. */
76911 - atomic_inc(&rdtp->dynticks);
76912 + atomic_inc_unchecked(&rdtp->dynticks);
76913 smp_mb__after_atomic_inc(); /* Force delay to next write. */
76914 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
76915 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
76916 }
76917
76918 /**
76919 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
76920 int ret;
76921
76922 preempt_disable();
76923 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
76924 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
76925 preempt_enable();
76926 return ret;
76927 }
76928 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
76929 */
76930 static int dyntick_save_progress_counter(struct rcu_data *rdp)
76931 {
76932 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
76933 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
76934 return (rdp->dynticks_snap & 0x1) == 0;
76935 }
76936
76937 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
76938 unsigned int curr;
76939 unsigned int snap;
76940
76941 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
76942 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
76943 snap = (unsigned int)rdp->dynticks_snap;
76944
76945 /*
76946 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
76947 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
76948 */
76949 if (till_stall_check < 3) {
76950 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
76951 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
76952 till_stall_check = 3;
76953 } else if (till_stall_check > 300) {
76954 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
76955 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
76956 till_stall_check = 300;
76957 }
76958 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
76959 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
76960 rsp->qlen += rdp->qlen;
76961 rdp->n_cbs_orphaned += rdp->qlen;
76962 rdp->qlen_lazy = 0;
76963 - ACCESS_ONCE(rdp->qlen) = 0;
76964 + ACCESS_ONCE_RW(rdp->qlen) = 0;
76965 }
76966
76967 /*
76968 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
76969 }
76970 smp_mb(); /* List handling before counting for rcu_barrier(). */
76971 rdp->qlen_lazy -= count_lazy;
76972 - ACCESS_ONCE(rdp->qlen) -= count;
76973 + ACCESS_ONCE_RW(rdp->qlen) -= count;
76974 rdp->n_cbs_invoked += count;
76975
76976 /* Reinstate batch limit if we have worked down the excess. */
76977 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
76978 /*
76979 * Do RCU core processing for the current CPU.
76980 */
76981 -static void rcu_process_callbacks(struct softirq_action *unused)
76982 +static void rcu_process_callbacks(void)
76983 {
76984 struct rcu_state *rsp;
76985
76986 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
76987 local_irq_restore(flags);
76988 return;
76989 }
76990 - ACCESS_ONCE(rdp->qlen)++;
76991 + ACCESS_ONCE_RW(rdp->qlen)++;
76992 if (lazy)
76993 rdp->qlen_lazy++;
76994 else
76995 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
76996 * counter wrap on a 32-bit system. Quite a few more CPUs would of
76997 * course be required on a 64-bit system.
76998 */
76999 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77000 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77001 (ulong)atomic_long_read(&rsp->expedited_done) +
77002 ULONG_MAX / 8)) {
77003 synchronize_sched();
77004 - atomic_long_inc(&rsp->expedited_wrap);
77005 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77006 return;
77007 }
77008
77009 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
77010 * Take a ticket. Note that atomic_inc_return() implies a
77011 * full memory barrier.
77012 */
77013 - snap = atomic_long_inc_return(&rsp->expedited_start);
77014 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77015 firstsnap = snap;
77016 get_online_cpus();
77017 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77018 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
77019 synchronize_sched_expedited_cpu_stop,
77020 NULL) == -EAGAIN) {
77021 put_online_cpus();
77022 - atomic_long_inc(&rsp->expedited_tryfail);
77023 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77024
77025 /* Check to see if someone else did our work for us. */
77026 s = atomic_long_read(&rsp->expedited_done);
77027 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77028 /* ensure test happens before caller kfree */
77029 smp_mb__before_atomic_inc(); /* ^^^ */
77030 - atomic_long_inc(&rsp->expedited_workdone1);
77031 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77032 return;
77033 }
77034
77035 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
77036 udelay(trycount * num_online_cpus());
77037 } else {
77038 wait_rcu_gp(call_rcu_sched);
77039 - atomic_long_inc(&rsp->expedited_normal);
77040 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77041 return;
77042 }
77043
77044 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
77045 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77046 /* ensure test happens before caller kfree */
77047 smp_mb__before_atomic_inc(); /* ^^^ */
77048 - atomic_long_inc(&rsp->expedited_workdone2);
77049 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77050 return;
77051 }
77052
77053 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
77054 * period works for us.
77055 */
77056 get_online_cpus();
77057 - snap = atomic_long_read(&rsp->expedited_start);
77058 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77059 smp_mb(); /* ensure read is before try_stop_cpus(). */
77060 }
77061 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77062 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77063
77064 /*
77065 * Everyone up to our most recent fetch is covered by our grace
77066 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
77067 * than we did already did their update.
77068 */
77069 do {
77070 - atomic_long_inc(&rsp->expedited_done_tries);
77071 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77072 s = atomic_long_read(&rsp->expedited_done);
77073 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77074 /* ensure test happens before caller kfree */
77075 smp_mb__before_atomic_inc(); /* ^^^ */
77076 - atomic_long_inc(&rsp->expedited_done_lost);
77077 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77078 break;
77079 }
77080 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77081 - atomic_long_inc(&rsp->expedited_done_exit);
77082 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77083
77084 put_online_cpus();
77085 }
77086 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77087 * ACCESS_ONCE() to prevent the compiler from speculating
77088 * the increment to precede the early-exit check.
77089 */
77090 - ACCESS_ONCE(rsp->n_barrier_done)++;
77091 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77092 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77093 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77094 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77095 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77096
77097 /* Increment ->n_barrier_done to prevent duplicate work. */
77098 smp_mb(); /* Keep increment after above mechanism. */
77099 - ACCESS_ONCE(rsp->n_barrier_done)++;
77100 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77101 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
77102 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
77103 smp_mb(); /* Keep increment before caller's subsequent code. */
77104 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
77105 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
77106 init_callback_list(rdp);
77107 rdp->qlen_lazy = 0;
77108 - ACCESS_ONCE(rdp->qlen) = 0;
77109 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77110 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
77111 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
77112 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
77113 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
77114 #ifdef CONFIG_RCU_USER_QS
77115 WARN_ON_ONCE(rdp->dynticks->in_user);
77116 #endif
77117 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
77118 rdp->blimit = blimit;
77119 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
77120 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
77121 - atomic_set(&rdp->dynticks->dynticks,
77122 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
77123 + atomic_set_unchecked(&rdp->dynticks->dynticks,
77124 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
77125 rcu_prepare_for_idle_init(cpu);
77126 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
77127
77128 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
77129 index 4b69291..704c92e 100644
77130 --- a/kernel/rcutree.h
77131 +++ b/kernel/rcutree.h
77132 @@ -86,7 +86,7 @@ struct rcu_dynticks {
77133 long long dynticks_nesting; /* Track irq/process nesting level. */
77134 /* Process level is worth LLONG_MAX/2. */
77135 int dynticks_nmi_nesting; /* Track NMI nesting level. */
77136 - atomic_t dynticks; /* Even value for idle, else odd. */
77137 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
77138 #ifdef CONFIG_RCU_FAST_NO_HZ
77139 int dyntick_drain; /* Prepare-for-idle state variable. */
77140 unsigned long dyntick_holdoff;
77141 @@ -423,17 +423,17 @@ struct rcu_state {
77142 /* _rcu_barrier(). */
77143 /* End of fields guarded by barrier_mutex. */
77144
77145 - atomic_long_t expedited_start; /* Starting ticket. */
77146 - atomic_long_t expedited_done; /* Done ticket. */
77147 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
77148 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
77149 - atomic_long_t expedited_workdone1; /* # done by others #1. */
77150 - atomic_long_t expedited_workdone2; /* # done by others #2. */
77151 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
77152 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
77153 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
77154 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
77155 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
77156 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
77157 + atomic_long_t expedited_done; /* Done ticket. */
77158 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
77159 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
77160 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
77161 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
77162 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
77163 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
77164 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
77165 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
77166 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
77167
77168 unsigned long jiffies_force_qs; /* Time at which to invoke */
77169 /* force_quiescent_state(). */
77170 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
77171 index c1cc7e1..f62e436 100644
77172 --- a/kernel/rcutree_plugin.h
77173 +++ b/kernel/rcutree_plugin.h
77174 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
77175
77176 /* Clean up and exit. */
77177 smp_mb(); /* ensure expedited GP seen before counter increment. */
77178 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
77179 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
77180 unlock_mb_ret:
77181 mutex_unlock(&sync_rcu_preempt_exp_mutex);
77182 mb_ret:
77183 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
77184 free_cpumask_var(cm);
77185 }
77186
77187 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
77188 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
77189 .store = &rcu_cpu_kthread_task,
77190 .thread_should_run = rcu_cpu_kthread_should_run,
77191 .thread_fn = rcu_cpu_kthread,
77192 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
77193 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
77194 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
77195 cpu, ticks_value, ticks_title,
77196 - atomic_read(&rdtp->dynticks) & 0xfff,
77197 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
77198 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
77199 fast_no_hz);
77200 }
77201 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
77202
77203 /* Enqueue the callback on the nocb list and update counts. */
77204 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
77205 - ACCESS_ONCE(*old_rhpp) = rhp;
77206 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
77207 atomic_long_add(rhcount, &rdp->nocb_q_count);
77208 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
77209
77210 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
77211 * Extract queued callbacks, update counts, and wait
77212 * for a grace period to elapse.
77213 */
77214 - ACCESS_ONCE(rdp->nocb_head) = NULL;
77215 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
77216 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
77217 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
77218 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
77219 - ACCESS_ONCE(rdp->nocb_p_count) += c;
77220 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
77221 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
77222 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
77223 wait_rcu_gp(rdp->rsp->call_remote);
77224
77225 /* Each pass through the following loop invokes a callback. */
77226 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
77227 list = next;
77228 }
77229 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
77230 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
77231 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
77232 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
77233 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
77234 rdp->n_nocbs_invoked += c;
77235 }
77236 return 0;
77237 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
77238 rdp = per_cpu_ptr(rsp->rda, cpu);
77239 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
77240 BUG_ON(IS_ERR(t));
77241 - ACCESS_ONCE(rdp->nocb_kthread) = t;
77242 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
77243 }
77244 }
77245
77246 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
77247 index 0d095dc..1985b19 100644
77248 --- a/kernel/rcutree_trace.c
77249 +++ b/kernel/rcutree_trace.c
77250 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
77251 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
77252 rdp->passed_quiesce, rdp->qs_pending);
77253 seq_printf(m, " dt=%d/%llx/%d df=%lu",
77254 - atomic_read(&rdp->dynticks->dynticks),
77255 + atomic_read_unchecked(&rdp->dynticks->dynticks),
77256 rdp->dynticks->dynticks_nesting,
77257 rdp->dynticks->dynticks_nmi_nesting,
77258 rdp->dynticks_fqs);
77259 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
77260 struct rcu_state *rsp = (struct rcu_state *)m->private;
77261
77262 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",
77263 - atomic_long_read(&rsp->expedited_start),
77264 + atomic_long_read_unchecked(&rsp->expedited_start),
77265 atomic_long_read(&rsp->expedited_done),
77266 - atomic_long_read(&rsp->expedited_wrap),
77267 - atomic_long_read(&rsp->expedited_tryfail),
77268 - atomic_long_read(&rsp->expedited_workdone1),
77269 - atomic_long_read(&rsp->expedited_workdone2),
77270 - atomic_long_read(&rsp->expedited_normal),
77271 - atomic_long_read(&rsp->expedited_stoppedcpus),
77272 - atomic_long_read(&rsp->expedited_done_tries),
77273 - atomic_long_read(&rsp->expedited_done_lost),
77274 - atomic_long_read(&rsp->expedited_done_exit));
77275 + atomic_long_read_unchecked(&rsp->expedited_wrap),
77276 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
77277 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
77278 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
77279 + atomic_long_read_unchecked(&rsp->expedited_normal),
77280 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
77281 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
77282 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
77283 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
77284 return 0;
77285 }
77286
77287 diff --git a/kernel/resource.c b/kernel/resource.c
77288 index 73f35d4..4684fc4 100644
77289 --- a/kernel/resource.c
77290 +++ b/kernel/resource.c
77291 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
77292
77293 static int __init ioresources_init(void)
77294 {
77295 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
77296 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77297 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
77298 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
77299 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77300 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
77301 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
77302 +#endif
77303 +#else
77304 proc_create("ioports", 0, NULL, &proc_ioports_operations);
77305 proc_create("iomem", 0, NULL, &proc_iomem_operations);
77306 +#endif
77307 return 0;
77308 }
77309 __initcall(ioresources_init);
77310 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
77311 index 98ec494..4241d6d 100644
77312 --- a/kernel/rtmutex-tester.c
77313 +++ b/kernel/rtmutex-tester.c
77314 @@ -20,7 +20,7 @@
77315 #define MAX_RT_TEST_MUTEXES 8
77316
77317 static spinlock_t rttest_lock;
77318 -static atomic_t rttest_event;
77319 +static atomic_unchecked_t rttest_event;
77320
77321 struct test_thread_data {
77322 int opcode;
77323 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77324
77325 case RTTEST_LOCKCONT:
77326 td->mutexes[td->opdata] = 1;
77327 - td->event = atomic_add_return(1, &rttest_event);
77328 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77329 return 0;
77330
77331 case RTTEST_RESET:
77332 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77333 return 0;
77334
77335 case RTTEST_RESETEVENT:
77336 - atomic_set(&rttest_event, 0);
77337 + atomic_set_unchecked(&rttest_event, 0);
77338 return 0;
77339
77340 default:
77341 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77342 return ret;
77343
77344 td->mutexes[id] = 1;
77345 - td->event = atomic_add_return(1, &rttest_event);
77346 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77347 rt_mutex_lock(&mutexes[id]);
77348 - td->event = atomic_add_return(1, &rttest_event);
77349 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77350 td->mutexes[id] = 4;
77351 return 0;
77352
77353 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77354 return ret;
77355
77356 td->mutexes[id] = 1;
77357 - td->event = atomic_add_return(1, &rttest_event);
77358 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77359 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
77360 - td->event = atomic_add_return(1, &rttest_event);
77361 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77362 td->mutexes[id] = ret ? 0 : 4;
77363 return ret ? -EINTR : 0;
77364
77365 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77366 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
77367 return ret;
77368
77369 - td->event = atomic_add_return(1, &rttest_event);
77370 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77371 rt_mutex_unlock(&mutexes[id]);
77372 - td->event = atomic_add_return(1, &rttest_event);
77373 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77374 td->mutexes[id] = 0;
77375 return 0;
77376
77377 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77378 break;
77379
77380 td->mutexes[dat] = 2;
77381 - td->event = atomic_add_return(1, &rttest_event);
77382 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77383 break;
77384
77385 default:
77386 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77387 return;
77388
77389 td->mutexes[dat] = 3;
77390 - td->event = atomic_add_return(1, &rttest_event);
77391 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77392 break;
77393
77394 case RTTEST_LOCKNOWAIT:
77395 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77396 return;
77397
77398 td->mutexes[dat] = 1;
77399 - td->event = atomic_add_return(1, &rttest_event);
77400 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77401 return;
77402
77403 default:
77404 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
77405 index 0984a21..939f183 100644
77406 --- a/kernel/sched/auto_group.c
77407 +++ b/kernel/sched/auto_group.c
77408 @@ -11,7 +11,7 @@
77409
77410 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
77411 static struct autogroup autogroup_default;
77412 -static atomic_t autogroup_seq_nr;
77413 +static atomic_unchecked_t autogroup_seq_nr;
77414
77415 void __init autogroup_init(struct task_struct *init_task)
77416 {
77417 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
77418
77419 kref_init(&ag->kref);
77420 init_rwsem(&ag->lock);
77421 - ag->id = atomic_inc_return(&autogroup_seq_nr);
77422 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
77423 ag->tg = tg;
77424 #ifdef CONFIG_RT_GROUP_SCHED
77425 /*
77426 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
77427 index 26058d0..e315889 100644
77428 --- a/kernel/sched/core.c
77429 +++ b/kernel/sched/core.c
77430 @@ -3367,7 +3367,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
77431 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77432 * positive (at least 1, or number of jiffies left till timeout) if completed.
77433 */
77434 -long __sched
77435 +long __sched __intentional_overflow(-1)
77436 wait_for_completion_interruptible_timeout(struct completion *x,
77437 unsigned long timeout)
77438 {
77439 @@ -3384,7 +3384,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
77440 *
77441 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
77442 */
77443 -int __sched wait_for_completion_killable(struct completion *x)
77444 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
77445 {
77446 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
77447 if (t == -ERESTARTSYS)
77448 @@ -3405,7 +3405,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
77449 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77450 * positive (at least 1, or number of jiffies left till timeout) if completed.
77451 */
77452 -long __sched
77453 +long __sched __intentional_overflow(-1)
77454 wait_for_completion_killable_timeout(struct completion *x,
77455 unsigned long timeout)
77456 {
77457 @@ -3631,6 +3631,8 @@ int can_nice(const struct task_struct *p, const int nice)
77458 /* convert nice value [19,-20] to rlimit style value [1,40] */
77459 int nice_rlim = 20 - nice;
77460
77461 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
77462 +
77463 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
77464 capable(CAP_SYS_NICE));
77465 }
77466 @@ -3664,7 +3666,8 @@ SYSCALL_DEFINE1(nice, int, increment)
77467 if (nice > 19)
77468 nice = 19;
77469
77470 - if (increment < 0 && !can_nice(current, nice))
77471 + if (increment < 0 && (!can_nice(current, nice) ||
77472 + gr_handle_chroot_nice()))
77473 return -EPERM;
77474
77475 retval = security_task_setnice(current, nice);
77476 @@ -3818,6 +3821,7 @@ recheck:
77477 unsigned long rlim_rtprio =
77478 task_rlimit(p, RLIMIT_RTPRIO);
77479
77480 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
77481 /* can't set/change the rt policy */
77482 if (policy != p->policy && !rlim_rtprio)
77483 return -EPERM;
77484 @@ -4901,7 +4905,7 @@ static void migrate_tasks(unsigned int dead_cpu)
77485
77486 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
77487
77488 -static struct ctl_table sd_ctl_dir[] = {
77489 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
77490 {
77491 .procname = "sched_domain",
77492 .mode = 0555,
77493 @@ -4918,17 +4922,17 @@ static struct ctl_table sd_ctl_root[] = {
77494 {}
77495 };
77496
77497 -static struct ctl_table *sd_alloc_ctl_entry(int n)
77498 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
77499 {
77500 - struct ctl_table *entry =
77501 + ctl_table_no_const *entry =
77502 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
77503
77504 return entry;
77505 }
77506
77507 -static void sd_free_ctl_entry(struct ctl_table **tablep)
77508 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
77509 {
77510 - struct ctl_table *entry;
77511 + ctl_table_no_const *entry;
77512
77513 /*
77514 * In the intermediate directories, both the child directory and
77515 @@ -4936,22 +4940,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
77516 * will always be set. In the lowest directory the names are
77517 * static strings and all have proc handlers.
77518 */
77519 - for (entry = *tablep; entry->mode; entry++) {
77520 - if (entry->child)
77521 - sd_free_ctl_entry(&entry->child);
77522 + for (entry = tablep; entry->mode; entry++) {
77523 + if (entry->child) {
77524 + sd_free_ctl_entry(entry->child);
77525 + pax_open_kernel();
77526 + entry->child = NULL;
77527 + pax_close_kernel();
77528 + }
77529 if (entry->proc_handler == NULL)
77530 kfree(entry->procname);
77531 }
77532
77533 - kfree(*tablep);
77534 - *tablep = NULL;
77535 + kfree(tablep);
77536 }
77537
77538 static int min_load_idx = 0;
77539 static int max_load_idx = CPU_LOAD_IDX_MAX;
77540
77541 static void
77542 -set_table_entry(struct ctl_table *entry,
77543 +set_table_entry(ctl_table_no_const *entry,
77544 const char *procname, void *data, int maxlen,
77545 umode_t mode, proc_handler *proc_handler,
77546 bool load_idx)
77547 @@ -4971,7 +4978,7 @@ set_table_entry(struct ctl_table *entry,
77548 static struct ctl_table *
77549 sd_alloc_ctl_domain_table(struct sched_domain *sd)
77550 {
77551 - struct ctl_table *table = sd_alloc_ctl_entry(13);
77552 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
77553
77554 if (table == NULL)
77555 return NULL;
77556 @@ -5006,9 +5013,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
77557 return table;
77558 }
77559
77560 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
77561 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
77562 {
77563 - struct ctl_table *entry, *table;
77564 + ctl_table_no_const *entry, *table;
77565 struct sched_domain *sd;
77566 int domain_num = 0, i;
77567 char buf[32];
77568 @@ -5035,11 +5042,13 @@ static struct ctl_table_header *sd_sysctl_header;
77569 static void register_sched_domain_sysctl(void)
77570 {
77571 int i, cpu_num = num_possible_cpus();
77572 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
77573 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
77574 char buf[32];
77575
77576 WARN_ON(sd_ctl_dir[0].child);
77577 + pax_open_kernel();
77578 sd_ctl_dir[0].child = entry;
77579 + pax_close_kernel();
77580
77581 if (entry == NULL)
77582 return;
77583 @@ -5062,8 +5071,12 @@ static void unregister_sched_domain_sysctl(void)
77584 if (sd_sysctl_header)
77585 unregister_sysctl_table(sd_sysctl_header);
77586 sd_sysctl_header = NULL;
77587 - if (sd_ctl_dir[0].child)
77588 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
77589 + if (sd_ctl_dir[0].child) {
77590 + sd_free_ctl_entry(sd_ctl_dir[0].child);
77591 + pax_open_kernel();
77592 + sd_ctl_dir[0].child = NULL;
77593 + pax_close_kernel();
77594 + }
77595 }
77596 #else
77597 static void register_sched_domain_sysctl(void)
77598 @@ -5162,7 +5175,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
77599 * happens before everything else. This has to be lower priority than
77600 * the notifier in the perf_event subsystem, though.
77601 */
77602 -static struct notifier_block __cpuinitdata migration_notifier = {
77603 +static struct notifier_block migration_notifier = {
77604 .notifier_call = migration_call,
77605 .priority = CPU_PRI_MIGRATION,
77606 };
77607 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
77608 index 81fa536..6ccf96a 100644
77609 --- a/kernel/sched/fair.c
77610 +++ b/kernel/sched/fair.c
77611 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
77612
77613 static void reset_ptenuma_scan(struct task_struct *p)
77614 {
77615 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
77616 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
77617 p->mm->numa_scan_offset = 0;
77618 }
77619
77620 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
77621 */
77622 static int select_idle_sibling(struct task_struct *p, int target)
77623 {
77624 - int cpu = smp_processor_id();
77625 - int prev_cpu = task_cpu(p);
77626 struct sched_domain *sd;
77627 struct sched_group *sg;
77628 - int i;
77629 + int i = task_cpu(p);
77630
77631 - /*
77632 - * If the task is going to be woken-up on this cpu and if it is
77633 - * already idle, then it is the right target.
77634 - */
77635 - if (target == cpu && idle_cpu(cpu))
77636 - return cpu;
77637 + if (idle_cpu(target))
77638 + return target;
77639
77640 /*
77641 - * If the task is going to be woken-up on the cpu where it previously
77642 - * ran and if it is currently idle, then it the right target.
77643 + * If the prevous cpu is cache affine and idle, don't be stupid.
77644 */
77645 - if (target == prev_cpu && idle_cpu(prev_cpu))
77646 - return prev_cpu;
77647 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
77648 + return i;
77649
77650 /*
77651 * Otherwise, iterate the domains and find an elegible idle cpu.
77652 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
77653 goto next;
77654
77655 for_each_cpu(i, sched_group_cpus(sg)) {
77656 - if (!idle_cpu(i))
77657 + if (i == target || !idle_cpu(i))
77658 goto next;
77659 }
77660
77661 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
77662 * run_rebalance_domains is triggered when needed from the scheduler tick.
77663 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
77664 */
77665 -static void run_rebalance_domains(struct softirq_action *h)
77666 +static void run_rebalance_domains(void)
77667 {
77668 int this_cpu = smp_processor_id();
77669 struct rq *this_rq = cpu_rq(this_cpu);
77670 diff --git a/kernel/signal.c b/kernel/signal.c
77671 index 7591ccc..8988390 100644
77672 --- a/kernel/signal.c
77673 +++ b/kernel/signal.c
77674 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
77675
77676 int print_fatal_signals __read_mostly;
77677
77678 -static void __user *sig_handler(struct task_struct *t, int sig)
77679 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
77680 {
77681 return t->sighand->action[sig - 1].sa.sa_handler;
77682 }
77683
77684 -static int sig_handler_ignored(void __user *handler, int sig)
77685 +static int sig_handler_ignored(__sighandler_t handler, int sig)
77686 {
77687 /* Is it explicitly or implicitly ignored? */
77688 return handler == SIG_IGN ||
77689 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
77690
77691 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
77692 {
77693 - void __user *handler;
77694 + __sighandler_t handler;
77695
77696 handler = sig_handler(t, sig);
77697
77698 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
77699 atomic_inc(&user->sigpending);
77700 rcu_read_unlock();
77701
77702 + if (!override_rlimit)
77703 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
77704 +
77705 if (override_rlimit ||
77706 atomic_read(&user->sigpending) <=
77707 task_rlimit(t, RLIMIT_SIGPENDING)) {
77708 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
77709
77710 int unhandled_signal(struct task_struct *tsk, int sig)
77711 {
77712 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
77713 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
77714 if (is_global_init(tsk))
77715 return 1;
77716 if (handler != SIG_IGN && handler != SIG_DFL)
77717 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
77718 }
77719 }
77720
77721 + /* allow glibc communication via tgkill to other threads in our
77722 + thread group */
77723 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
77724 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
77725 + && gr_handle_signal(t, sig))
77726 + return -EPERM;
77727 +
77728 return security_task_kill(t, info, sig, 0);
77729 }
77730
77731 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
77732 return send_signal(sig, info, p, 1);
77733 }
77734
77735 -static int
77736 +int
77737 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77738 {
77739 return send_signal(sig, info, t, 0);
77740 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77741 unsigned long int flags;
77742 int ret, blocked, ignored;
77743 struct k_sigaction *action;
77744 + int is_unhandled = 0;
77745
77746 spin_lock_irqsave(&t->sighand->siglock, flags);
77747 action = &t->sighand->action[sig-1];
77748 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77749 }
77750 if (action->sa.sa_handler == SIG_DFL)
77751 t->signal->flags &= ~SIGNAL_UNKILLABLE;
77752 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
77753 + is_unhandled = 1;
77754 ret = specific_send_sig_info(sig, info, t);
77755 spin_unlock_irqrestore(&t->sighand->siglock, flags);
77756
77757 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
77758 + normal operation */
77759 + if (is_unhandled) {
77760 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
77761 + gr_handle_crash(t, sig);
77762 + }
77763 +
77764 return ret;
77765 }
77766
77767 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
77768 ret = check_kill_permission(sig, info, p);
77769 rcu_read_unlock();
77770
77771 - if (!ret && sig)
77772 + if (!ret && sig) {
77773 ret = do_send_sig_info(sig, info, p, true);
77774 + if (!ret)
77775 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
77776 + }
77777
77778 return ret;
77779 }
77780 @@ -2855,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
77781 int error = -ESRCH;
77782
77783 rcu_read_lock();
77784 - p = find_task_by_vpid(pid);
77785 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
77786 + /* allow glibc communication via tgkill to other threads in our
77787 + thread group */
77788 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
77789 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
77790 + p = find_task_by_vpid_unrestricted(pid);
77791 + else
77792 +#endif
77793 + p = find_task_by_vpid(pid);
77794 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
77795 error = check_kill_permission(sig, info, p);
77796 /*
77797 @@ -3138,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
77798 }
77799 seg = get_fs();
77800 set_fs(KERNEL_DS);
77801 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
77802 - (stack_t __force __user *) &uoss,
77803 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
77804 + (stack_t __force_user *) &uoss,
77805 compat_user_stack_pointer());
77806 set_fs(seg);
77807 if (ret >= 0 && uoss_ptr) {
77808 diff --git a/kernel/smp.c b/kernel/smp.c
77809 index 69f38bd..77bbf12 100644
77810 --- a/kernel/smp.c
77811 +++ b/kernel/smp.c
77812 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
77813 return NOTIFY_OK;
77814 }
77815
77816 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
77817 +static struct notifier_block hotplug_cfd_notifier = {
77818 .notifier_call = hotplug_cfd,
77819 };
77820
77821 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
77822 index d6c5fc0..530560c 100644
77823 --- a/kernel/smpboot.c
77824 +++ b/kernel/smpboot.c
77825 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
77826 }
77827 smpboot_unpark_thread(plug_thread, cpu);
77828 }
77829 - list_add(&plug_thread->list, &hotplug_threads);
77830 + pax_list_add(&plug_thread->list, &hotplug_threads);
77831 out:
77832 mutex_unlock(&smpboot_threads_lock);
77833 return ret;
77834 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
77835 {
77836 get_online_cpus();
77837 mutex_lock(&smpboot_threads_lock);
77838 - list_del(&plug_thread->list);
77839 + pax_list_del(&plug_thread->list);
77840 smpboot_destroy_threads(plug_thread);
77841 mutex_unlock(&smpboot_threads_lock);
77842 put_online_cpus();
77843 diff --git a/kernel/softirq.c b/kernel/softirq.c
77844 index ed567ba..e71dabf 100644
77845 --- a/kernel/softirq.c
77846 +++ b/kernel/softirq.c
77847 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
77848 EXPORT_SYMBOL(irq_stat);
77849 #endif
77850
77851 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
77852 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
77853
77854 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
77855
77856 -char *softirq_to_name[NR_SOFTIRQS] = {
77857 +const char * const softirq_to_name[NR_SOFTIRQS] = {
77858 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
77859 "TASKLET", "SCHED", "HRTIMER", "RCU"
77860 };
77861 @@ -244,7 +244,7 @@ restart:
77862 kstat_incr_softirqs_this_cpu(vec_nr);
77863
77864 trace_softirq_entry(vec_nr);
77865 - h->action(h);
77866 + h->action();
77867 trace_softirq_exit(vec_nr);
77868 if (unlikely(prev_count != preempt_count())) {
77869 printk(KERN_ERR "huh, entered softirq %u %s %p"
77870 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
77871 or_softirq_pending(1UL << nr);
77872 }
77873
77874 -void open_softirq(int nr, void (*action)(struct softirq_action *))
77875 +void __init open_softirq(int nr, void (*action)(void))
77876 {
77877 softirq_vec[nr].action = action;
77878 }
77879 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
77880
77881 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
77882
77883 -static void tasklet_action(struct softirq_action *a)
77884 +static void tasklet_action(void)
77885 {
77886 struct tasklet_struct *list;
77887
77888 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
77889 }
77890 }
77891
77892 -static void tasklet_hi_action(struct softirq_action *a)
77893 +static void tasklet_hi_action(void)
77894 {
77895 struct tasklet_struct *list;
77896
77897 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
77898 return NOTIFY_OK;
77899 }
77900
77901 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
77902 +static struct notifier_block remote_softirq_cpu_notifier = {
77903 .notifier_call = remote_softirq_cpu_notify,
77904 };
77905
77906 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
77907 return NOTIFY_OK;
77908 }
77909
77910 -static struct notifier_block __cpuinitdata cpu_nfb = {
77911 +static struct notifier_block cpu_nfb = {
77912 .notifier_call = cpu_callback
77913 };
77914
77915 -static struct smp_hotplug_thread softirq_threads = {
77916 +static struct smp_hotplug_thread softirq_threads __read_only = {
77917 .store = &ksoftirqd,
77918 .thread_should_run = ksoftirqd_should_run,
77919 .thread_fn = run_ksoftirqd,
77920 diff --git a/kernel/srcu.c b/kernel/srcu.c
77921 index 2b85982..d52ab26 100644
77922 --- a/kernel/srcu.c
77923 +++ b/kernel/srcu.c
77924 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
77925 preempt_disable();
77926 idx = rcu_dereference_index_check(sp->completed,
77927 rcu_read_lock_sched_held()) & 0x1;
77928 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
77929 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
77930 smp_mb(); /* B */ /* Avoid leaking the critical section. */
77931 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
77932 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
77933 preempt_enable();
77934 return idx;
77935 }
77936 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
77937 {
77938 preempt_disable();
77939 smp_mb(); /* C */ /* Avoid leaking the critical section. */
77940 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
77941 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
77942 preempt_enable();
77943 }
77944 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
77945 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
77946 index 2f194e9..2c05ea9 100644
77947 --- a/kernel/stop_machine.c
77948 +++ b/kernel/stop_machine.c
77949 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
77950 * cpu notifiers. It currently shares the same priority as sched
77951 * migration_notifier.
77952 */
77953 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
77954 +static struct notifier_block cpu_stop_cpu_notifier = {
77955 .notifier_call = cpu_stop_cpu_callback,
77956 .priority = 10,
77957 };
77958 diff --git a/kernel/sys.c b/kernel/sys.c
77959 index 265b376..4e42ef5 100644
77960 --- a/kernel/sys.c
77961 +++ b/kernel/sys.c
77962 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
77963 error = -EACCES;
77964 goto out;
77965 }
77966 +
77967 + if (gr_handle_chroot_setpriority(p, niceval)) {
77968 + error = -EACCES;
77969 + goto out;
77970 + }
77971 +
77972 no_nice = security_task_setnice(p, niceval);
77973 if (no_nice) {
77974 error = no_nice;
77975 @@ -595,6 +601,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
77976 goto error;
77977 }
77978
77979 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
77980 + goto error;
77981 +
77982 if (rgid != (gid_t) -1 ||
77983 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
77984 new->sgid = new->egid;
77985 @@ -630,6 +639,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
77986 old = current_cred();
77987
77988 retval = -EPERM;
77989 +
77990 + if (gr_check_group_change(kgid, kgid, kgid))
77991 + goto error;
77992 +
77993 if (nsown_capable(CAP_SETGID))
77994 new->gid = new->egid = new->sgid = new->fsgid = kgid;
77995 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
77996 @@ -647,7 +660,7 @@ error:
77997 /*
77998 * change the user struct in a credentials set to match the new UID
77999 */
78000 -static int set_user(struct cred *new)
78001 +int set_user(struct cred *new)
78002 {
78003 struct user_struct *new_user;
78004
78005 @@ -727,6 +740,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78006 goto error;
78007 }
78008
78009 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78010 + goto error;
78011 +
78012 if (!uid_eq(new->uid, old->uid)) {
78013 retval = set_user(new);
78014 if (retval < 0)
78015 @@ -777,6 +793,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78016 old = current_cred();
78017
78018 retval = -EPERM;
78019 +
78020 + if (gr_check_crash_uid(kuid))
78021 + goto error;
78022 + if (gr_check_user_change(kuid, kuid, kuid))
78023 + goto error;
78024 +
78025 if (nsown_capable(CAP_SETUID)) {
78026 new->suid = new->uid = kuid;
78027 if (!uid_eq(kuid, old->uid)) {
78028 @@ -846,6 +868,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78029 goto error;
78030 }
78031
78032 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78033 + goto error;
78034 +
78035 if (ruid != (uid_t) -1) {
78036 new->uid = kruid;
78037 if (!uid_eq(kruid, old->uid)) {
78038 @@ -928,6 +953,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78039 goto error;
78040 }
78041
78042 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78043 + goto error;
78044 +
78045 if (rgid != (gid_t) -1)
78046 new->gid = krgid;
78047 if (egid != (gid_t) -1)
78048 @@ -981,6 +1009,9 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78049 if (!uid_valid(kuid))
78050 return old_fsuid;
78051
78052 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78053 + goto error;
78054 +
78055 new = prepare_creds();
78056 if (!new)
78057 return old_fsuid;
78058 @@ -995,6 +1026,7 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78059 }
78060 }
78061
78062 +error:
78063 abort_creds(new);
78064 return old_fsuid;
78065
78066 @@ -1027,12 +1059,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78067 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78068 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78069 nsown_capable(CAP_SETGID)) {
78070 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78071 + goto error;
78072 +
78073 if (!gid_eq(kgid, old->fsgid)) {
78074 new->fsgid = kgid;
78075 goto change_okay;
78076 }
78077 }
78078
78079 +error:
78080 abort_creds(new);
78081 return old_fsgid;
78082
78083 @@ -1340,19 +1376,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78084 return -EFAULT;
78085
78086 down_read(&uts_sem);
78087 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78088 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78089 __OLD_UTS_LEN);
78090 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78091 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78092 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78093 __OLD_UTS_LEN);
78094 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78095 - error |= __copy_to_user(&name->release, &utsname()->release,
78096 + error |= __copy_to_user(name->release, &utsname()->release,
78097 __OLD_UTS_LEN);
78098 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78099 - error |= __copy_to_user(&name->version, &utsname()->version,
78100 + error |= __copy_to_user(name->version, &utsname()->version,
78101 __OLD_UTS_LEN);
78102 error |= __put_user(0, name->version + __OLD_UTS_LEN);
78103 - error |= __copy_to_user(&name->machine, &utsname()->machine,
78104 + error |= __copy_to_user(name->machine, &utsname()->machine,
78105 __OLD_UTS_LEN);
78106 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
78107 up_read(&uts_sem);
78108 @@ -2026,7 +2062,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
78109 error = get_dumpable(me->mm);
78110 break;
78111 case PR_SET_DUMPABLE:
78112 - if (arg2 < 0 || arg2 > 1) {
78113 + if (arg2 > 1) {
78114 error = -EINVAL;
78115 break;
78116 }
78117 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
78118 index c88878d..e4fa5d1 100644
78119 --- a/kernel/sysctl.c
78120 +++ b/kernel/sysctl.c
78121 @@ -92,7 +92,6 @@
78122
78123
78124 #if defined(CONFIG_SYSCTL)
78125 -
78126 /* External variables not in a header file. */
78127 extern int sysctl_overcommit_memory;
78128 extern int sysctl_overcommit_ratio;
78129 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
78130 void __user *buffer, size_t *lenp, loff_t *ppos);
78131 #endif
78132
78133 -#ifdef CONFIG_PRINTK
78134 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78135 void __user *buffer, size_t *lenp, loff_t *ppos);
78136 -#endif
78137
78138 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
78139 void __user *buffer, size_t *lenp, loff_t *ppos);
78140 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
78141
78142 #endif
78143
78144 +extern struct ctl_table grsecurity_table[];
78145 +
78146 static struct ctl_table kern_table[];
78147 static struct ctl_table vm_table[];
78148 static struct ctl_table fs_table[];
78149 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
78150 int sysctl_legacy_va_layout;
78151 #endif
78152
78153 +#ifdef CONFIG_PAX_SOFTMODE
78154 +static ctl_table pax_table[] = {
78155 + {
78156 + .procname = "softmode",
78157 + .data = &pax_softmode,
78158 + .maxlen = sizeof(unsigned int),
78159 + .mode = 0600,
78160 + .proc_handler = &proc_dointvec,
78161 + },
78162 +
78163 + { }
78164 +};
78165 +#endif
78166 +
78167 /* The default sysctl tables: */
78168
78169 static struct ctl_table sysctl_base_table[] = {
78170 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
78171 #endif
78172
78173 static struct ctl_table kern_table[] = {
78174 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
78175 + {
78176 + .procname = "grsecurity",
78177 + .mode = 0500,
78178 + .child = grsecurity_table,
78179 + },
78180 +#endif
78181 +
78182 +#ifdef CONFIG_PAX_SOFTMODE
78183 + {
78184 + .procname = "pax",
78185 + .mode = 0500,
78186 + .child = pax_table,
78187 + },
78188 +#endif
78189 +
78190 {
78191 .procname = "sched_child_runs_first",
78192 .data = &sysctl_sched_child_runs_first,
78193 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
78194 .data = &modprobe_path,
78195 .maxlen = KMOD_PATH_LEN,
78196 .mode = 0644,
78197 - .proc_handler = proc_dostring,
78198 + .proc_handler = proc_dostring_modpriv,
78199 },
78200 {
78201 .procname = "modules_disabled",
78202 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
78203 .extra1 = &zero,
78204 .extra2 = &one,
78205 },
78206 +#endif
78207 {
78208 .procname = "kptr_restrict",
78209 .data = &kptr_restrict,
78210 .maxlen = sizeof(int),
78211 .mode = 0644,
78212 .proc_handler = proc_dointvec_minmax_sysadmin,
78213 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78214 + .extra1 = &two,
78215 +#else
78216 .extra1 = &zero,
78217 +#endif
78218 .extra2 = &two,
78219 },
78220 -#endif
78221 {
78222 .procname = "ngroups_max",
78223 .data = &ngroups_max,
78224 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
78225 .proc_handler = proc_dointvec_minmax,
78226 .extra1 = &zero,
78227 },
78228 + {
78229 + .procname = "heap_stack_gap",
78230 + .data = &sysctl_heap_stack_gap,
78231 + .maxlen = sizeof(sysctl_heap_stack_gap),
78232 + .mode = 0644,
78233 + .proc_handler = proc_doulongvec_minmax,
78234 + },
78235 #else
78236 {
78237 .procname = "nr_trim_pages",
78238 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
78239 buffer, lenp, ppos);
78240 }
78241
78242 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78243 + void __user *buffer, size_t *lenp, loff_t *ppos)
78244 +{
78245 + if (write && !capable(CAP_SYS_MODULE))
78246 + return -EPERM;
78247 +
78248 + return _proc_do_string(table->data, table->maxlen, write,
78249 + buffer, lenp, ppos);
78250 +}
78251 +
78252 static size_t proc_skip_spaces(char **buf)
78253 {
78254 size_t ret;
78255 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
78256 len = strlen(tmp);
78257 if (len > *size)
78258 len = *size;
78259 + if (len > sizeof(tmp))
78260 + len = sizeof(tmp);
78261 if (copy_to_user(*buf, tmp, len))
78262 return -EFAULT;
78263 *size -= len;
78264 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
78265 static int proc_taint(struct ctl_table *table, int write,
78266 void __user *buffer, size_t *lenp, loff_t *ppos)
78267 {
78268 - struct ctl_table t;
78269 + ctl_table_no_const t;
78270 unsigned long tmptaint = get_taint();
78271 int err;
78272
78273 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
78274 return err;
78275 }
78276
78277 -#ifdef CONFIG_PRINTK
78278 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78279 void __user *buffer, size_t *lenp, loff_t *ppos)
78280 {
78281 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78282
78283 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
78284 }
78285 -#endif
78286
78287 struct do_proc_dointvec_minmax_conv_param {
78288 int *min;
78289 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
78290 *i = val;
78291 } else {
78292 val = convdiv * (*i) / convmul;
78293 - if (!first)
78294 + if (!first) {
78295 err = proc_put_char(&buffer, &left, '\t');
78296 + if (err)
78297 + break;
78298 + }
78299 err = proc_put_long(&buffer, &left, val, false);
78300 if (err)
78301 break;
78302 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
78303 return -ENOSYS;
78304 }
78305
78306 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78307 + void __user *buffer, size_t *lenp, loff_t *ppos)
78308 +{
78309 + return -ENOSYS;
78310 +}
78311 +
78312 int proc_dointvec(struct ctl_table *table, int write,
78313 void __user *buffer, size_t *lenp, loff_t *ppos)
78314 {
78315 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
78316 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
78317 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
78318 EXPORT_SYMBOL(proc_dostring);
78319 +EXPORT_SYMBOL(proc_dostring_modpriv);
78320 EXPORT_SYMBOL(proc_doulongvec_minmax);
78321 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
78322 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
78323 index 0ddf3a0..a199f50 100644
78324 --- a/kernel/sysctl_binary.c
78325 +++ b/kernel/sysctl_binary.c
78326 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
78327 int i;
78328
78329 set_fs(KERNEL_DS);
78330 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
78331 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
78332 set_fs(old_fs);
78333 if (result < 0)
78334 goto out_kfree;
78335 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
78336 }
78337
78338 set_fs(KERNEL_DS);
78339 - result = vfs_write(file, buffer, str - buffer, &pos);
78340 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
78341 set_fs(old_fs);
78342 if (result < 0)
78343 goto out_kfree;
78344 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
78345 int i;
78346
78347 set_fs(KERNEL_DS);
78348 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
78349 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
78350 set_fs(old_fs);
78351 if (result < 0)
78352 goto out_kfree;
78353 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
78354 }
78355
78356 set_fs(KERNEL_DS);
78357 - result = vfs_write(file, buffer, str - buffer, &pos);
78358 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
78359 set_fs(old_fs);
78360 if (result < 0)
78361 goto out_kfree;
78362 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
78363 int i;
78364
78365 set_fs(KERNEL_DS);
78366 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
78367 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
78368 set_fs(old_fs);
78369 if (result < 0)
78370 goto out;
78371 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
78372 __le16 dnaddr;
78373
78374 set_fs(KERNEL_DS);
78375 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
78376 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
78377 set_fs(old_fs);
78378 if (result < 0)
78379 goto out;
78380 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
78381 le16_to_cpu(dnaddr) & 0x3ff);
78382
78383 set_fs(KERNEL_DS);
78384 - result = vfs_write(file, buf, len, &pos);
78385 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
78386 set_fs(old_fs);
78387 if (result < 0)
78388 goto out;
78389 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
78390 index 145bb4d..b2aa969 100644
78391 --- a/kernel/taskstats.c
78392 +++ b/kernel/taskstats.c
78393 @@ -28,9 +28,12 @@
78394 #include <linux/fs.h>
78395 #include <linux/file.h>
78396 #include <linux/pid_namespace.h>
78397 +#include <linux/grsecurity.h>
78398 #include <net/genetlink.h>
78399 #include <linux/atomic.h>
78400
78401 +extern int gr_is_taskstats_denied(int pid);
78402 +
78403 /*
78404 * Maximum length of a cpumask that can be specified in
78405 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
78406 @@ -570,6 +573,9 @@ err:
78407
78408 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
78409 {
78410 + if (gr_is_taskstats_denied(current->pid))
78411 + return -EACCES;
78412 +
78413 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
78414 return cmd_attr_register_cpumask(info);
78415 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
78416 diff --git a/kernel/time.c b/kernel/time.c
78417 index d226c6a..2f0d217 100644
78418 --- a/kernel/time.c
78419 +++ b/kernel/time.c
78420 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
78421 return error;
78422
78423 if (tz) {
78424 + /* we log in do_settimeofday called below, so don't log twice
78425 + */
78426 + if (!tv)
78427 + gr_log_timechange();
78428 +
78429 sys_tz = *tz;
78430 update_vsyscall_tz();
78431 if (firsttime) {
78432 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
78433 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
78434 * value to a scaled second value.
78435 */
78436 -unsigned long
78437 +unsigned long __intentional_overflow(-1)
78438 timespec_to_jiffies(const struct timespec *value)
78439 {
78440 unsigned long sec = value->tv_sec;
78441 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
78442 index f11d83b..d016d91 100644
78443 --- a/kernel/time/alarmtimer.c
78444 +++ b/kernel/time/alarmtimer.c
78445 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
78446 struct platform_device *pdev;
78447 int error = 0;
78448 int i;
78449 - struct k_clock alarm_clock = {
78450 + static struct k_clock alarm_clock = {
78451 .clock_getres = alarm_clock_getres,
78452 .clock_get = alarm_clock_get,
78453 .timer_create = alarm_timer_create,
78454 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
78455 index a13987a..36cd791 100644
78456 --- a/kernel/time/tick-broadcast.c
78457 +++ b/kernel/time/tick-broadcast.c
78458 @@ -116,7 +116,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
78459 * then clear the broadcast bit.
78460 */
78461 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
78462 - int cpu = smp_processor_id();
78463 + cpu = smp_processor_id();
78464
78465 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
78466 tick_broadcast_clear_oneshot(cpu);
78467 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
78468 index cbc6acb..3a77191 100644
78469 --- a/kernel/time/timekeeping.c
78470 +++ b/kernel/time/timekeeping.c
78471 @@ -15,6 +15,7 @@
78472 #include <linux/init.h>
78473 #include <linux/mm.h>
78474 #include <linux/sched.h>
78475 +#include <linux/grsecurity.h>
78476 #include <linux/syscore_ops.h>
78477 #include <linux/clocksource.h>
78478 #include <linux/jiffies.h>
78479 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
78480 if (!timespec_valid_strict(tv))
78481 return -EINVAL;
78482
78483 + gr_log_timechange();
78484 +
78485 write_seqlock_irqsave(&tk->lock, flags);
78486
78487 timekeeping_forward_now(tk);
78488 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
78489 index af5a7e9..715611a 100644
78490 --- a/kernel/time/timer_list.c
78491 +++ b/kernel/time/timer_list.c
78492 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
78493
78494 static void print_name_offset(struct seq_file *m, void *sym)
78495 {
78496 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78497 + SEQ_printf(m, "<%p>", NULL);
78498 +#else
78499 char symname[KSYM_NAME_LEN];
78500
78501 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
78502 SEQ_printf(m, "<%pK>", sym);
78503 else
78504 SEQ_printf(m, "%s", symname);
78505 +#endif
78506 }
78507
78508 static void
78509 @@ -112,7 +116,11 @@ next_one:
78510 static void
78511 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
78512 {
78513 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78514 + SEQ_printf(m, " .base: %p\n", NULL);
78515 +#else
78516 SEQ_printf(m, " .base: %pK\n", base);
78517 +#endif
78518 SEQ_printf(m, " .index: %d\n",
78519 base->index);
78520 SEQ_printf(m, " .resolution: %Lu nsecs\n",
78521 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
78522 {
78523 struct proc_dir_entry *pe;
78524
78525 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78526 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
78527 +#else
78528 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
78529 +#endif
78530 if (!pe)
78531 return -ENOMEM;
78532 return 0;
78533 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
78534 index 0b537f2..40d6c20 100644
78535 --- a/kernel/time/timer_stats.c
78536 +++ b/kernel/time/timer_stats.c
78537 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
78538 static unsigned long nr_entries;
78539 static struct entry entries[MAX_ENTRIES];
78540
78541 -static atomic_t overflow_count;
78542 +static atomic_unchecked_t overflow_count;
78543
78544 /*
78545 * The entries are in a hash-table, for fast lookup:
78546 @@ -140,7 +140,7 @@ static void reset_entries(void)
78547 nr_entries = 0;
78548 memset(entries, 0, sizeof(entries));
78549 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
78550 - atomic_set(&overflow_count, 0);
78551 + atomic_set_unchecked(&overflow_count, 0);
78552 }
78553
78554 static struct entry *alloc_entry(void)
78555 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78556 if (likely(entry))
78557 entry->count++;
78558 else
78559 - atomic_inc(&overflow_count);
78560 + atomic_inc_unchecked(&overflow_count);
78561
78562 out_unlock:
78563 raw_spin_unlock_irqrestore(lock, flags);
78564 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78565
78566 static void print_name_offset(struct seq_file *m, unsigned long addr)
78567 {
78568 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78569 + seq_printf(m, "<%p>", NULL);
78570 +#else
78571 char symname[KSYM_NAME_LEN];
78572
78573 if (lookup_symbol_name(addr, symname) < 0)
78574 - seq_printf(m, "<%p>", (void *)addr);
78575 + seq_printf(m, "<%pK>", (void *)addr);
78576 else
78577 seq_printf(m, "%s", symname);
78578 +#endif
78579 }
78580
78581 static int tstats_show(struct seq_file *m, void *v)
78582 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
78583
78584 seq_puts(m, "Timer Stats Version: v0.2\n");
78585 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
78586 - if (atomic_read(&overflow_count))
78587 + if (atomic_read_unchecked(&overflow_count))
78588 seq_printf(m, "Overflow: %d entries\n",
78589 - atomic_read(&overflow_count));
78590 + atomic_read_unchecked(&overflow_count));
78591
78592 for (i = 0; i < nr_entries; i++) {
78593 entry = entries + i;
78594 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
78595 {
78596 struct proc_dir_entry *pe;
78597
78598 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78599 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
78600 +#else
78601 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
78602 +#endif
78603 if (!pe)
78604 return -ENOMEM;
78605 return 0;
78606 diff --git a/kernel/timer.c b/kernel/timer.c
78607 index 367d008..5dee98f 100644
78608 --- a/kernel/timer.c
78609 +++ b/kernel/timer.c
78610 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
78611 /*
78612 * This function runs timers and the timer-tq in bottom half context.
78613 */
78614 -static void run_timer_softirq(struct softirq_action *h)
78615 +static void run_timer_softirq(void)
78616 {
78617 struct tvec_base *base = __this_cpu_read(tvec_bases);
78618
78619 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
78620 *
78621 * In all cases the return value is guaranteed to be non-negative.
78622 */
78623 -signed long __sched schedule_timeout(signed long timeout)
78624 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
78625 {
78626 struct timer_list timer;
78627 unsigned long expire;
78628 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
78629 return NOTIFY_OK;
78630 }
78631
78632 -static struct notifier_block __cpuinitdata timers_nb = {
78633 +static struct notifier_block timers_nb = {
78634 .notifier_call = timer_cpu_notify,
78635 };
78636
78637 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
78638 index c0bd030..62a1927 100644
78639 --- a/kernel/trace/blktrace.c
78640 +++ b/kernel/trace/blktrace.c
78641 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
78642 struct blk_trace *bt = filp->private_data;
78643 char buf[16];
78644
78645 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
78646 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
78647
78648 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
78649 }
78650 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
78651 return 1;
78652
78653 bt = buf->chan->private_data;
78654 - atomic_inc(&bt->dropped);
78655 + atomic_inc_unchecked(&bt->dropped);
78656 return 0;
78657 }
78658
78659 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
78660
78661 bt->dir = dir;
78662 bt->dev = dev;
78663 - atomic_set(&bt->dropped, 0);
78664 + atomic_set_unchecked(&bt->dropped, 0);
78665
78666 ret = -EIO;
78667 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
78668 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
78669 index b27052c..0e1af95 100644
78670 --- a/kernel/trace/ftrace.c
78671 +++ b/kernel/trace/ftrace.c
78672 @@ -1874,12 +1874,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
78673 if (unlikely(ftrace_disabled))
78674 return 0;
78675
78676 + ret = ftrace_arch_code_modify_prepare();
78677 + FTRACE_WARN_ON(ret);
78678 + if (ret)
78679 + return 0;
78680 +
78681 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
78682 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
78683 if (ret) {
78684 ftrace_bug(ret, ip);
78685 - return 0;
78686 }
78687 - return 1;
78688 + return ret ? 0 : 1;
78689 }
78690
78691 /*
78692 @@ -2965,7 +2970,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
78693
78694 int
78695 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
78696 - void *data)
78697 + void *data)
78698 {
78699 struct ftrace_func_probe *entry;
78700 struct ftrace_page *pg;
78701 @@ -3832,8 +3837,10 @@ static int ftrace_process_locs(struct module *mod,
78702 if (!count)
78703 return 0;
78704
78705 + pax_open_kernel();
78706 sort(start, count, sizeof(*start),
78707 ftrace_cmp_ips, ftrace_swap_ips);
78708 + pax_close_kernel();
78709
78710 start_pg = ftrace_allocate_pages(count);
78711 if (!start_pg)
78712 @@ -4559,8 +4566,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
78713 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
78714
78715 static int ftrace_graph_active;
78716 -static struct notifier_block ftrace_suspend_notifier;
78717 -
78718 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
78719 {
78720 return 0;
78721 @@ -4704,6 +4709,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
78722 return NOTIFY_DONE;
78723 }
78724
78725 +static struct notifier_block ftrace_suspend_notifier = {
78726 + .notifier_call = ftrace_suspend_notifier_call
78727 +};
78728 +
78729 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
78730 trace_func_graph_ent_t entryfunc)
78731 {
78732 @@ -4717,7 +4726,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
78733 goto out;
78734 }
78735
78736 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
78737 register_pm_notifier(&ftrace_suspend_notifier);
78738
78739 ftrace_graph_active++;
78740 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
78741 index ce8514f..8233573 100644
78742 --- a/kernel/trace/ring_buffer.c
78743 +++ b/kernel/trace/ring_buffer.c
78744 @@ -346,9 +346,9 @@ struct buffer_data_page {
78745 */
78746 struct buffer_page {
78747 struct list_head list; /* list of buffer pages */
78748 - local_t write; /* index for next write */
78749 + local_unchecked_t write; /* index for next write */
78750 unsigned read; /* index for next read */
78751 - local_t entries; /* entries on this page */
78752 + local_unchecked_t entries; /* entries on this page */
78753 unsigned long real_end; /* real end of data */
78754 struct buffer_data_page *page; /* Actual data page */
78755 };
78756 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
78757 unsigned long last_overrun;
78758 local_t entries_bytes;
78759 local_t entries;
78760 - local_t overrun;
78761 - local_t commit_overrun;
78762 + local_unchecked_t overrun;
78763 + local_unchecked_t commit_overrun;
78764 local_t dropped_events;
78765 local_t committing;
78766 local_t commits;
78767 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
78768 *
78769 * We add a counter to the write field to denote this.
78770 */
78771 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
78772 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
78773 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
78774 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
78775
78776 /*
78777 * Just make sure we have seen our old_write and synchronize
78778 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
78779 * cmpxchg to only update if an interrupt did not already
78780 * do it for us. If the cmpxchg fails, we don't care.
78781 */
78782 - (void)local_cmpxchg(&next_page->write, old_write, val);
78783 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
78784 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
78785 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
78786
78787 /*
78788 * No need to worry about races with clearing out the commit.
78789 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
78790
78791 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
78792 {
78793 - return local_read(&bpage->entries) & RB_WRITE_MASK;
78794 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
78795 }
78796
78797 static inline unsigned long rb_page_write(struct buffer_page *bpage)
78798 {
78799 - return local_read(&bpage->write) & RB_WRITE_MASK;
78800 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
78801 }
78802
78803 static int
78804 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
78805 * bytes consumed in ring buffer from here.
78806 * Increment overrun to account for the lost events.
78807 */
78808 - local_add(page_entries, &cpu_buffer->overrun);
78809 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
78810 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
78811 }
78812
78813 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
78814 * it is our responsibility to update
78815 * the counters.
78816 */
78817 - local_add(entries, &cpu_buffer->overrun);
78818 + local_add_unchecked(entries, &cpu_buffer->overrun);
78819 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
78820
78821 /*
78822 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78823 if (tail == BUF_PAGE_SIZE)
78824 tail_page->real_end = 0;
78825
78826 - local_sub(length, &tail_page->write);
78827 + local_sub_unchecked(length, &tail_page->write);
78828 return;
78829 }
78830
78831 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78832 rb_event_set_padding(event);
78833
78834 /* Set the write back to the previous setting */
78835 - local_sub(length, &tail_page->write);
78836 + local_sub_unchecked(length, &tail_page->write);
78837 return;
78838 }
78839
78840 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78841
78842 /* Set write to end of buffer */
78843 length = (tail + length) - BUF_PAGE_SIZE;
78844 - local_sub(length, &tail_page->write);
78845 + local_sub_unchecked(length, &tail_page->write);
78846 }
78847
78848 /*
78849 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
78850 * about it.
78851 */
78852 if (unlikely(next_page == commit_page)) {
78853 - local_inc(&cpu_buffer->commit_overrun);
78854 + local_inc_unchecked(&cpu_buffer->commit_overrun);
78855 goto out_reset;
78856 }
78857
78858 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
78859 cpu_buffer->tail_page) &&
78860 (cpu_buffer->commit_page ==
78861 cpu_buffer->reader_page))) {
78862 - local_inc(&cpu_buffer->commit_overrun);
78863 + local_inc_unchecked(&cpu_buffer->commit_overrun);
78864 goto out_reset;
78865 }
78866 }
78867 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
78868 length += RB_LEN_TIME_EXTEND;
78869
78870 tail_page = cpu_buffer->tail_page;
78871 - write = local_add_return(length, &tail_page->write);
78872 + write = local_add_return_unchecked(length, &tail_page->write);
78873
78874 /* set write to only the index of the write */
78875 write &= RB_WRITE_MASK;
78876 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
78877 kmemcheck_annotate_bitfield(event, bitfield);
78878 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
78879
78880 - local_inc(&tail_page->entries);
78881 + local_inc_unchecked(&tail_page->entries);
78882
78883 /*
78884 * If this is the first commit on the page, then update
78885 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
78886
78887 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
78888 unsigned long write_mask =
78889 - local_read(&bpage->write) & ~RB_WRITE_MASK;
78890 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
78891 unsigned long event_length = rb_event_length(event);
78892 /*
78893 * This is on the tail page. It is possible that
78894 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
78895 */
78896 old_index += write_mask;
78897 new_index += write_mask;
78898 - index = local_cmpxchg(&bpage->write, old_index, new_index);
78899 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
78900 if (index == old_index) {
78901 /* update counters */
78902 local_sub(event_length, &cpu_buffer->entries_bytes);
78903 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
78904
78905 /* Do the likely case first */
78906 if (likely(bpage->page == (void *)addr)) {
78907 - local_dec(&bpage->entries);
78908 + local_dec_unchecked(&bpage->entries);
78909 return;
78910 }
78911
78912 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
78913 start = bpage;
78914 do {
78915 if (bpage->page == (void *)addr) {
78916 - local_dec(&bpage->entries);
78917 + local_dec_unchecked(&bpage->entries);
78918 return;
78919 }
78920 rb_inc_page(cpu_buffer, &bpage);
78921 @@ -2926,7 +2926,7 @@ static inline unsigned long
78922 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
78923 {
78924 return local_read(&cpu_buffer->entries) -
78925 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
78926 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
78927 }
78928
78929 /**
78930 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
78931 return 0;
78932
78933 cpu_buffer = buffer->buffers[cpu];
78934 - ret = local_read(&cpu_buffer->overrun);
78935 + ret = local_read_unchecked(&cpu_buffer->overrun);
78936
78937 return ret;
78938 }
78939 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
78940 return 0;
78941
78942 cpu_buffer = buffer->buffers[cpu];
78943 - ret = local_read(&cpu_buffer->commit_overrun);
78944 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
78945
78946 return ret;
78947 }
78948 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
78949 /* if you care about this being correct, lock the buffer */
78950 for_each_buffer_cpu(buffer, cpu) {
78951 cpu_buffer = buffer->buffers[cpu];
78952 - overruns += local_read(&cpu_buffer->overrun);
78953 + overruns += local_read_unchecked(&cpu_buffer->overrun);
78954 }
78955
78956 return overruns;
78957 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
78958 /*
78959 * Reset the reader page to size zero.
78960 */
78961 - local_set(&cpu_buffer->reader_page->write, 0);
78962 - local_set(&cpu_buffer->reader_page->entries, 0);
78963 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
78964 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
78965 local_set(&cpu_buffer->reader_page->page->commit, 0);
78966 cpu_buffer->reader_page->real_end = 0;
78967
78968 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
78969 * want to compare with the last_overrun.
78970 */
78971 smp_mb();
78972 - overwrite = local_read(&(cpu_buffer->overrun));
78973 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
78974
78975 /*
78976 * Here's the tricky part.
78977 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
78978
78979 cpu_buffer->head_page
78980 = list_entry(cpu_buffer->pages, struct buffer_page, list);
78981 - local_set(&cpu_buffer->head_page->write, 0);
78982 - local_set(&cpu_buffer->head_page->entries, 0);
78983 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
78984 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
78985 local_set(&cpu_buffer->head_page->page->commit, 0);
78986
78987 cpu_buffer->head_page->read = 0;
78988 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
78989
78990 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
78991 INIT_LIST_HEAD(&cpu_buffer->new_pages);
78992 - local_set(&cpu_buffer->reader_page->write, 0);
78993 - local_set(&cpu_buffer->reader_page->entries, 0);
78994 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
78995 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
78996 local_set(&cpu_buffer->reader_page->page->commit, 0);
78997 cpu_buffer->reader_page->read = 0;
78998
78999 local_set(&cpu_buffer->entries_bytes, 0);
79000 - local_set(&cpu_buffer->overrun, 0);
79001 - local_set(&cpu_buffer->commit_overrun, 0);
79002 + local_set_unchecked(&cpu_buffer->overrun, 0);
79003 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79004 local_set(&cpu_buffer->dropped_events, 0);
79005 local_set(&cpu_buffer->entries, 0);
79006 local_set(&cpu_buffer->committing, 0);
79007 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79008 rb_init_page(bpage);
79009 bpage = reader->page;
79010 reader->page = *data_page;
79011 - local_set(&reader->write, 0);
79012 - local_set(&reader->entries, 0);
79013 + local_set_unchecked(&reader->write, 0);
79014 + local_set_unchecked(&reader->entries, 0);
79015 reader->read = 0;
79016 *data_page = bpage;
79017
79018 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79019 index 2ffbc24..76105a2 100644
79020 --- a/kernel/trace/trace.c
79021 +++ b/kernel/trace/trace.c
79022 @@ -4471,10 +4471,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79023 };
79024 #endif
79025
79026 -static struct dentry *d_tracer;
79027 -
79028 struct dentry *tracing_init_dentry(void)
79029 {
79030 + static struct dentry *d_tracer;
79031 static int once;
79032
79033 if (d_tracer)
79034 @@ -4494,10 +4493,9 @@ struct dentry *tracing_init_dentry(void)
79035 return d_tracer;
79036 }
79037
79038 -static struct dentry *d_percpu;
79039 -
79040 struct dentry *tracing_dentry_percpu(void)
79041 {
79042 + static struct dentry *d_percpu;
79043 static int once;
79044 struct dentry *d_tracer;
79045
79046 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79047 index 880073d..42db7c3 100644
79048 --- a/kernel/trace/trace_events.c
79049 +++ b/kernel/trace/trace_events.c
79050 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
79051 struct ftrace_module_file_ops {
79052 struct list_head list;
79053 struct module *mod;
79054 - struct file_operations id;
79055 - struct file_operations enable;
79056 - struct file_operations format;
79057 - struct file_operations filter;
79058 };
79059
79060 static struct ftrace_module_file_ops *
79061 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
79062
79063 file_ops->mod = mod;
79064
79065 - file_ops->id = ftrace_event_id_fops;
79066 - file_ops->id.owner = mod;
79067 -
79068 - file_ops->enable = ftrace_enable_fops;
79069 - file_ops->enable.owner = mod;
79070 -
79071 - file_ops->filter = ftrace_event_filter_fops;
79072 - file_ops->filter.owner = mod;
79073 -
79074 - file_ops->format = ftrace_event_format_fops;
79075 - file_ops->format.owner = mod;
79076 + pax_open_kernel();
79077 + mod->trace_id.owner = mod;
79078 + mod->trace_enable.owner = mod;
79079 + mod->trace_filter.owner = mod;
79080 + mod->trace_format.owner = mod;
79081 + pax_close_kernel();
79082
79083 list_add(&file_ops->list, &ftrace_module_file_list);
79084
79085 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
79086
79087 for_each_event(call, start, end) {
79088 __trace_add_event_call(*call, mod,
79089 - &file_ops->id, &file_ops->enable,
79090 - &file_ops->filter, &file_ops->format);
79091 + &mod->trace_id, &mod->trace_enable,
79092 + &mod->trace_filter, &mod->trace_format);
79093 }
79094 }
79095
79096 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
79097 index fd3c8aa..5f324a6 100644
79098 --- a/kernel/trace/trace_mmiotrace.c
79099 +++ b/kernel/trace/trace_mmiotrace.c
79100 @@ -24,7 +24,7 @@ struct header_iter {
79101 static struct trace_array *mmio_trace_array;
79102 static bool overrun_detected;
79103 static unsigned long prev_overruns;
79104 -static atomic_t dropped_count;
79105 +static atomic_unchecked_t dropped_count;
79106
79107 static void mmio_reset_data(struct trace_array *tr)
79108 {
79109 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
79110
79111 static unsigned long count_overruns(struct trace_iterator *iter)
79112 {
79113 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
79114 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
79115 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
79116
79117 if (over > prev_overruns)
79118 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
79119 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
79120 sizeof(*entry), 0, pc);
79121 if (!event) {
79122 - atomic_inc(&dropped_count);
79123 + atomic_inc_unchecked(&dropped_count);
79124 return;
79125 }
79126 entry = ring_buffer_event_data(event);
79127 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
79128 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
79129 sizeof(*entry), 0, pc);
79130 if (!event) {
79131 - atomic_inc(&dropped_count);
79132 + atomic_inc_unchecked(&dropped_count);
79133 return;
79134 }
79135 entry = ring_buffer_event_data(event);
79136 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
79137 index 194d796..76edb8f 100644
79138 --- a/kernel/trace/trace_output.c
79139 +++ b/kernel/trace/trace_output.c
79140 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
79141
79142 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
79143 if (!IS_ERR(p)) {
79144 - p = mangle_path(s->buffer + s->len, p, "\n");
79145 + p = mangle_path(s->buffer + s->len, p, "\n\\");
79146 if (p) {
79147 s->len = p - s->buffer;
79148 return 1;
79149 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
79150 goto out;
79151 }
79152
79153 + pax_open_kernel();
79154 if (event->funcs->trace == NULL)
79155 - event->funcs->trace = trace_nop_print;
79156 + *(void **)&event->funcs->trace = trace_nop_print;
79157 if (event->funcs->raw == NULL)
79158 - event->funcs->raw = trace_nop_print;
79159 + *(void **)&event->funcs->raw = trace_nop_print;
79160 if (event->funcs->hex == NULL)
79161 - event->funcs->hex = trace_nop_print;
79162 + *(void **)&event->funcs->hex = trace_nop_print;
79163 if (event->funcs->binary == NULL)
79164 - event->funcs->binary = trace_nop_print;
79165 + *(void **)&event->funcs->binary = trace_nop_print;
79166 + pax_close_kernel();
79167
79168 key = event->type & (EVENT_HASHSIZE - 1);
79169
79170 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
79171 index 42ca822..cdcacc6 100644
79172 --- a/kernel/trace/trace_stack.c
79173 +++ b/kernel/trace/trace_stack.c
79174 @@ -52,7 +52,7 @@ static inline void check_stack(void)
79175 return;
79176
79177 /* we do not handle interrupt stacks yet */
79178 - if (!object_is_on_stack(&this_size))
79179 + if (!object_starts_on_stack(&this_size))
79180 return;
79181
79182 local_irq_save(flags);
79183 diff --git a/kernel/user.c b/kernel/user.c
79184 index 33acb5e..57ebfd4 100644
79185 --- a/kernel/user.c
79186 +++ b/kernel/user.c
79187 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
79188 .count = 4294967295U,
79189 },
79190 },
79191 - .kref = {
79192 - .refcount = ATOMIC_INIT(3),
79193 - },
79194 + .count = ATOMIC_INIT(3),
79195 .owner = GLOBAL_ROOT_UID,
79196 .group = GLOBAL_ROOT_GID,
79197 .proc_inum = PROC_USER_INIT_INO,
79198 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
79199 index dbfe36a7..2a3c1df 100644
79200 --- a/kernel/user_namespace.c
79201 +++ b/kernel/user_namespace.c
79202 @@ -79,7 +79,7 @@ int create_user_ns(struct cred *new)
79203 return ret;
79204 }
79205
79206 - kref_init(&ns->kref);
79207 + atomic_set(&ns->count, 1);
79208 /* Leave the new->user_ns reference with the new user namespace. */
79209 ns->parent = parent_ns;
79210 ns->owner = owner;
79211 @@ -105,15 +105,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
79212 return create_user_ns(cred);
79213 }
79214
79215 -void free_user_ns(struct kref *kref)
79216 +void free_user_ns(struct user_namespace *ns)
79217 {
79218 - struct user_namespace *parent, *ns =
79219 - container_of(kref, struct user_namespace, kref);
79220 + struct user_namespace *parent;
79221
79222 - parent = ns->parent;
79223 - proc_free_inum(ns->proc_inum);
79224 - kmem_cache_free(user_ns_cachep, ns);
79225 - put_user_ns(parent);
79226 + do {
79227 + parent = ns->parent;
79228 + proc_free_inum(ns->proc_inum);
79229 + kmem_cache_free(user_ns_cachep, ns);
79230 + ns = parent;
79231 + } while (atomic_dec_and_test(&parent->count));
79232 }
79233 EXPORT_SYMBOL(free_user_ns);
79234
79235 @@ -804,7 +805,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
79236 if (atomic_read(&current->mm->mm_users) > 1)
79237 return -EINVAL;
79238
79239 - if (current->fs->users != 1)
79240 + if (atomic_read(&current->fs->users) != 1)
79241 return -EINVAL;
79242
79243 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
79244 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
79245 index 63da38c..639904e 100644
79246 --- a/kernel/utsname_sysctl.c
79247 +++ b/kernel/utsname_sysctl.c
79248 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
79249 static int proc_do_uts_string(ctl_table *table, int write,
79250 void __user *buffer, size_t *lenp, loff_t *ppos)
79251 {
79252 - struct ctl_table uts_table;
79253 + ctl_table_no_const uts_table;
79254 int r;
79255 memcpy(&uts_table, table, sizeof(uts_table));
79256 uts_table.data = get_uts(table, write);
79257 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
79258 index 75a2ab3..5961da7 100644
79259 --- a/kernel/watchdog.c
79260 +++ b/kernel/watchdog.c
79261 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
79262 }
79263 #endif /* CONFIG_SYSCTL */
79264
79265 -static struct smp_hotplug_thread watchdog_threads = {
79266 +static struct smp_hotplug_thread watchdog_threads __read_only = {
79267 .store = &softlockup_watchdog,
79268 .thread_should_run = watchdog_should_run,
79269 .thread_fn = watchdog,
79270 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
79271 index 67604e5..fe94fb1 100644
79272 --- a/lib/Kconfig.debug
79273 +++ b/lib/Kconfig.debug
79274 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
79275
79276 config DEBUG_LOCK_ALLOC
79277 bool "Lock debugging: detect incorrect freeing of live locks"
79278 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79279 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79280 select DEBUG_SPINLOCK
79281 select DEBUG_MUTEXES
79282 select LOCKDEP
79283 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
79284
79285 config PROVE_LOCKING
79286 bool "Lock debugging: prove locking correctness"
79287 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79288 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79289 select LOCKDEP
79290 select DEBUG_SPINLOCK
79291 select DEBUG_MUTEXES
79292 @@ -670,7 +670,7 @@ config LOCKDEP
79293
79294 config LOCK_STAT
79295 bool "Lock usage statistics"
79296 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79297 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79298 select LOCKDEP
79299 select DEBUG_SPINLOCK
79300 select DEBUG_MUTEXES
79301 @@ -1278,6 +1278,7 @@ config LATENCYTOP
79302 depends on DEBUG_KERNEL
79303 depends on STACKTRACE_SUPPORT
79304 depends on PROC_FS
79305 + depends on !GRKERNSEC_HIDESYM
79306 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
79307 select KALLSYMS
79308 select KALLSYMS_ALL
79309 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
79310
79311 config PROVIDE_OHCI1394_DMA_INIT
79312 bool "Remote debugging over FireWire early on boot"
79313 - depends on PCI && X86
79314 + depends on PCI && X86 && !GRKERNSEC
79315 help
79316 If you want to debug problems which hang or crash the kernel early
79317 on boot and the crashing machine has a FireWire port, you can use
79318 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
79319
79320 config FIREWIRE_OHCI_REMOTE_DMA
79321 bool "Remote debugging over FireWire with firewire-ohci"
79322 - depends on FIREWIRE_OHCI
79323 + depends on FIREWIRE_OHCI && !GRKERNSEC
79324 help
79325 This option lets you use the FireWire bus for remote debugging
79326 with help of the firewire-ohci driver. It enables unfiltered
79327 diff --git a/lib/Makefile b/lib/Makefile
79328 index 02ed6c0..bd243da 100644
79329 --- a/lib/Makefile
79330 +++ b/lib/Makefile
79331 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
79332
79333 obj-$(CONFIG_BTREE) += btree.o
79334 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
79335 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
79336 +obj-y += list_debug.o
79337 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
79338
79339 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
79340 diff --git a/lib/bitmap.c b/lib/bitmap.c
79341 index 06f7e4f..f3cf2b0 100644
79342 --- a/lib/bitmap.c
79343 +++ b/lib/bitmap.c
79344 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
79345 {
79346 int c, old_c, totaldigits, ndigits, nchunks, nbits;
79347 u32 chunk;
79348 - const char __user __force *ubuf = (const char __user __force *)buf;
79349 + const char __user *ubuf = (const char __force_user *)buf;
79350
79351 bitmap_zero(maskp, nmaskbits);
79352
79353 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
79354 {
79355 if (!access_ok(VERIFY_READ, ubuf, ulen))
79356 return -EFAULT;
79357 - return __bitmap_parse((const char __force *)ubuf,
79358 + return __bitmap_parse((const char __force_kernel *)ubuf,
79359 ulen, 1, maskp, nmaskbits);
79360
79361 }
79362 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
79363 {
79364 unsigned a, b;
79365 int c, old_c, totaldigits;
79366 - const char __user __force *ubuf = (const char __user __force *)buf;
79367 + const char __user *ubuf = (const char __force_user *)buf;
79368 int exp_digit, in_range;
79369
79370 totaldigits = c = 0;
79371 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
79372 {
79373 if (!access_ok(VERIFY_READ, ubuf, ulen))
79374 return -EFAULT;
79375 - return __bitmap_parselist((const char __force *)ubuf,
79376 + return __bitmap_parselist((const char __force_kernel *)ubuf,
79377 ulen, 1, maskp, nmaskbits);
79378 }
79379 EXPORT_SYMBOL(bitmap_parselist_user);
79380 diff --git a/lib/bug.c b/lib/bug.c
79381 index d0cdf14..4d07bd2 100644
79382 --- a/lib/bug.c
79383 +++ b/lib/bug.c
79384 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
79385 return BUG_TRAP_TYPE_NONE;
79386
79387 bug = find_bug(bugaddr);
79388 + if (!bug)
79389 + return BUG_TRAP_TYPE_NONE;
79390
79391 file = NULL;
79392 line = 0;
79393 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
79394 index d11808c..dc2d6f8 100644
79395 --- a/lib/debugobjects.c
79396 +++ b/lib/debugobjects.c
79397 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
79398 if (limit > 4)
79399 return;
79400
79401 - is_on_stack = object_is_on_stack(addr);
79402 + is_on_stack = object_starts_on_stack(addr);
79403 if (is_on_stack == onstack)
79404 return;
79405
79406 diff --git a/lib/devres.c b/lib/devres.c
79407 index 80b9c76..9e32279 100644
79408 --- a/lib/devres.c
79409 +++ b/lib/devres.c
79410 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
79411 void devm_iounmap(struct device *dev, void __iomem *addr)
79412 {
79413 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
79414 - (void *)addr));
79415 + (void __force *)addr));
79416 iounmap(addr);
79417 }
79418 EXPORT_SYMBOL(devm_iounmap);
79419 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
79420 {
79421 ioport_unmap(addr);
79422 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
79423 - devm_ioport_map_match, (void *)addr));
79424 + devm_ioport_map_match, (void __force *)addr));
79425 }
79426 EXPORT_SYMBOL(devm_ioport_unmap);
79427
79428 diff --git a/lib/div64.c b/lib/div64.c
79429 index a163b6c..9618fa5 100644
79430 --- a/lib/div64.c
79431 +++ b/lib/div64.c
79432 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
79433 EXPORT_SYMBOL(__div64_32);
79434
79435 #ifndef div_s64_rem
79436 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79437 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79438 {
79439 u64 quotient;
79440
79441 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
79442 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
79443 */
79444 #ifndef div64_u64
79445 -u64 div64_u64(u64 dividend, u64 divisor)
79446 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
79447 {
79448 u32 high = divisor >> 32;
79449 u64 quot;
79450 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
79451 index 5e396ac..58d5de1 100644
79452 --- a/lib/dma-debug.c
79453 +++ b/lib/dma-debug.c
79454 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
79455
79456 void dma_debug_add_bus(struct bus_type *bus)
79457 {
79458 - struct notifier_block *nb;
79459 + notifier_block_no_const *nb;
79460
79461 if (global_disable)
79462 return;
79463 @@ -942,7 +942,7 @@ out:
79464
79465 static void check_for_stack(struct device *dev, void *addr)
79466 {
79467 - if (object_is_on_stack(addr))
79468 + if (object_starts_on_stack(addr))
79469 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
79470 "stack [addr=%p]\n", addr);
79471 }
79472 diff --git a/lib/inflate.c b/lib/inflate.c
79473 index 013a761..c28f3fc 100644
79474 --- a/lib/inflate.c
79475 +++ b/lib/inflate.c
79476 @@ -269,7 +269,7 @@ static void free(void *where)
79477 malloc_ptr = free_mem_ptr;
79478 }
79479 #else
79480 -#define malloc(a) kmalloc(a, GFP_KERNEL)
79481 +#define malloc(a) kmalloc((a), GFP_KERNEL)
79482 #define free(a) kfree(a)
79483 #endif
79484
79485 diff --git a/lib/ioremap.c b/lib/ioremap.c
79486 index 0c9216c..863bd89 100644
79487 --- a/lib/ioremap.c
79488 +++ b/lib/ioremap.c
79489 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
79490 unsigned long next;
79491
79492 phys_addr -= addr;
79493 - pmd = pmd_alloc(&init_mm, pud, addr);
79494 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
79495 if (!pmd)
79496 return -ENOMEM;
79497 do {
79498 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
79499 unsigned long next;
79500
79501 phys_addr -= addr;
79502 - pud = pud_alloc(&init_mm, pgd, addr);
79503 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
79504 if (!pud)
79505 return -ENOMEM;
79506 do {
79507 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
79508 index bd2bea9..6b3c95e 100644
79509 --- a/lib/is_single_threaded.c
79510 +++ b/lib/is_single_threaded.c
79511 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
79512 struct task_struct *p, *t;
79513 bool ret;
79514
79515 + if (!mm)
79516 + return true;
79517 +
79518 if (atomic_read(&task->signal->live) != 1)
79519 return false;
79520
79521 diff --git a/lib/kobject.c b/lib/kobject.c
79522 index e07ee1f..998489d 100644
79523 --- a/lib/kobject.c
79524 +++ b/lib/kobject.c
79525 @@ -852,9 +852,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
79526
79527
79528 static DEFINE_SPINLOCK(kobj_ns_type_lock);
79529 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
79530 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
79531
79532 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79533 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79534 {
79535 enum kobj_ns_type type = ops->type;
79536 int error;
79537 diff --git a/lib/list_debug.c b/lib/list_debug.c
79538 index c24c2f7..06e070b 100644
79539 --- a/lib/list_debug.c
79540 +++ b/lib/list_debug.c
79541 @@ -11,7 +11,9 @@
79542 #include <linux/bug.h>
79543 #include <linux/kernel.h>
79544 #include <linux/rculist.h>
79545 +#include <linux/mm.h>
79546
79547 +#ifdef CONFIG_DEBUG_LIST
79548 /*
79549 * Insert a new entry between two known consecutive entries.
79550 *
79551 @@ -19,21 +21,32 @@
79552 * the prev/next entries already!
79553 */
79554
79555 -void __list_add(struct list_head *new,
79556 - struct list_head *prev,
79557 - struct list_head *next)
79558 +static bool __list_add_debug(struct list_head *new,
79559 + struct list_head *prev,
79560 + struct list_head *next)
79561 {
79562 - WARN(next->prev != prev,
79563 + if (WARN(next->prev != prev,
79564 "list_add corruption. next->prev should be "
79565 "prev (%p), but was %p. (next=%p).\n",
79566 - prev, next->prev, next);
79567 - WARN(prev->next != next,
79568 + prev, next->prev, next) ||
79569 + WARN(prev->next != next,
79570 "list_add corruption. prev->next should be "
79571 "next (%p), but was %p. (prev=%p).\n",
79572 - next, prev->next, prev);
79573 - WARN(new == prev || new == next,
79574 - "list_add double add: new=%p, prev=%p, next=%p.\n",
79575 - new, prev, next);
79576 + next, prev->next, prev) ||
79577 + WARN(new == prev || new == next,
79578 + "list_add double add: new=%p, prev=%p, next=%p.\n",
79579 + new, prev, next))
79580 + return false;
79581 + return true;
79582 +}
79583 +
79584 +void __list_add(struct list_head *new,
79585 + struct list_head *prev,
79586 + struct list_head *next)
79587 +{
79588 + if (!__list_add_debug(new, prev, next))
79589 + return;
79590 +
79591 next->prev = new;
79592 new->next = next;
79593 new->prev = prev;
79594 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
79595 }
79596 EXPORT_SYMBOL(__list_add);
79597
79598 -void __list_del_entry(struct list_head *entry)
79599 +static bool __list_del_entry_debug(struct list_head *entry)
79600 {
79601 struct list_head *prev, *next;
79602
79603 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
79604 WARN(next->prev != entry,
79605 "list_del corruption. next->prev should be %p, "
79606 "but was %p\n", entry, next->prev))
79607 + return false;
79608 + return true;
79609 +}
79610 +
79611 +void __list_del_entry(struct list_head *entry)
79612 +{
79613 + if (!__list_del_entry_debug(entry))
79614 return;
79615
79616 - __list_del(prev, next);
79617 + __list_del(entry->prev, entry->next);
79618 }
79619 EXPORT_SYMBOL(__list_del_entry);
79620
79621 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
79622 void __list_add_rcu(struct list_head *new,
79623 struct list_head *prev, struct list_head *next)
79624 {
79625 - WARN(next->prev != prev,
79626 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
79627 - prev, next->prev, next);
79628 - WARN(prev->next != next,
79629 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
79630 - next, prev->next, prev);
79631 + if (!__list_add_debug(new, prev, next))
79632 + return;
79633 +
79634 new->next = next;
79635 new->prev = prev;
79636 rcu_assign_pointer(list_next_rcu(prev), new);
79637 next->prev = new;
79638 }
79639 EXPORT_SYMBOL(__list_add_rcu);
79640 +#endif
79641 +
79642 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
79643 +{
79644 +#ifdef CONFIG_DEBUG_LIST
79645 + if (!__list_add_debug(new, prev, next))
79646 + return;
79647 +#endif
79648 +
79649 + pax_open_kernel();
79650 + next->prev = new;
79651 + new->next = next;
79652 + new->prev = prev;
79653 + prev->next = new;
79654 + pax_close_kernel();
79655 +}
79656 +EXPORT_SYMBOL(__pax_list_add);
79657 +
79658 +void pax_list_del(struct list_head *entry)
79659 +{
79660 +#ifdef CONFIG_DEBUG_LIST
79661 + if (!__list_del_entry_debug(entry))
79662 + return;
79663 +#endif
79664 +
79665 + pax_open_kernel();
79666 + __list_del(entry->prev, entry->next);
79667 + entry->next = LIST_POISON1;
79668 + entry->prev = LIST_POISON2;
79669 + pax_close_kernel();
79670 +}
79671 +EXPORT_SYMBOL(pax_list_del);
79672 +
79673 +void pax_list_del_init(struct list_head *entry)
79674 +{
79675 + pax_open_kernel();
79676 + __list_del(entry->prev, entry->next);
79677 + INIT_LIST_HEAD(entry);
79678 + pax_close_kernel();
79679 +}
79680 +EXPORT_SYMBOL(pax_list_del_init);
79681 +
79682 +void __pax_list_add_rcu(struct list_head *new,
79683 + struct list_head *prev, struct list_head *next)
79684 +{
79685 +#ifdef CONFIG_DEBUG_LIST
79686 + if (!__list_add_debug(new, prev, next))
79687 + return;
79688 +#endif
79689 +
79690 + pax_open_kernel();
79691 + new->next = next;
79692 + new->prev = prev;
79693 + rcu_assign_pointer(list_next_rcu(prev), new);
79694 + next->prev = new;
79695 + pax_close_kernel();
79696 +}
79697 +EXPORT_SYMBOL(__pax_list_add_rcu);
79698 +
79699 +void pax_list_del_rcu(struct list_head *entry)
79700 +{
79701 +#ifdef CONFIG_DEBUG_LIST
79702 + if (!__list_del_entry_debug(entry))
79703 + return;
79704 +#endif
79705 +
79706 + pax_open_kernel();
79707 + __list_del(entry->prev, entry->next);
79708 + entry->next = LIST_POISON1;
79709 + entry->prev = LIST_POISON2;
79710 + pax_close_kernel();
79711 +}
79712 +EXPORT_SYMBOL(pax_list_del_rcu);
79713 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
79714 index e796429..6e38f9f 100644
79715 --- a/lib/radix-tree.c
79716 +++ b/lib/radix-tree.c
79717 @@ -92,7 +92,7 @@ struct radix_tree_preload {
79718 int nr;
79719 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
79720 };
79721 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
79722 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
79723
79724 static inline void *ptr_to_indirect(void *ptr)
79725 {
79726 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
79727 index bb2b201..46abaf9 100644
79728 --- a/lib/strncpy_from_user.c
79729 +++ b/lib/strncpy_from_user.c
79730 @@ -21,7 +21,7 @@
79731 */
79732 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
79733 {
79734 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79735 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79736 long res = 0;
79737
79738 /*
79739 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
79740 index a28df52..3d55877 100644
79741 --- a/lib/strnlen_user.c
79742 +++ b/lib/strnlen_user.c
79743 @@ -26,7 +26,7 @@
79744 */
79745 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
79746 {
79747 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79748 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79749 long align, res = 0;
79750 unsigned long c;
79751
79752 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
79753 index 196b069..358f342 100644
79754 --- a/lib/swiotlb.c
79755 +++ b/lib/swiotlb.c
79756 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
79757
79758 void
79759 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
79760 - dma_addr_t dev_addr)
79761 + dma_addr_t dev_addr, struct dma_attrs *attrs)
79762 {
79763 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
79764
79765 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
79766 index fab33a9..3b5fe68 100644
79767 --- a/lib/vsprintf.c
79768 +++ b/lib/vsprintf.c
79769 @@ -16,6 +16,9 @@
79770 * - scnprintf and vscnprintf
79771 */
79772
79773 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79774 +#define __INCLUDED_BY_HIDESYM 1
79775 +#endif
79776 #include <stdarg.h>
79777 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
79778 #include <linux/types.h>
79779 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
79780 char sym[KSYM_SYMBOL_LEN];
79781 if (ext == 'B')
79782 sprint_backtrace(sym, value);
79783 - else if (ext != 'f' && ext != 's')
79784 + else if (ext != 'f' && ext != 's' && ext != 'a')
79785 sprint_symbol(sym, value);
79786 else
79787 sprint_symbol_no_offset(sym, value);
79788 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
79789 return number(buf, end, *(const netdev_features_t *)addr, spec);
79790 }
79791
79792 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79793 +int kptr_restrict __read_mostly = 2;
79794 +#else
79795 int kptr_restrict __read_mostly;
79796 +#endif
79797
79798 /*
79799 * Show a '%p' thing. A kernel extension is that the '%p' is followed
79800 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
79801 * - 'S' For symbolic direct pointers with offset
79802 * - 's' For symbolic direct pointers without offset
79803 * - 'B' For backtraced symbolic direct pointers with offset
79804 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
79805 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
79806 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
79807 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
79808 * - 'M' For a 6-byte MAC address, it prints the address in the
79809 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79810
79811 if (!ptr && *fmt != 'K') {
79812 /*
79813 - * Print (null) with the same width as a pointer so it makes
79814 + * Print (nil) with the same width as a pointer so it makes
79815 * tabular output look nice.
79816 */
79817 if (spec.field_width == -1)
79818 spec.field_width = default_width;
79819 - return string(buf, end, "(null)", spec);
79820 + return string(buf, end, "(nil)", spec);
79821 }
79822
79823 switch (*fmt) {
79824 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79825 /* Fallthrough */
79826 case 'S':
79827 case 's':
79828 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79829 + break;
79830 +#else
79831 + return symbol_string(buf, end, ptr, spec, *fmt);
79832 +#endif
79833 + case 'A':
79834 + case 'a':
79835 case 'B':
79836 return symbol_string(buf, end, ptr, spec, *fmt);
79837 case 'R':
79838 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79839 va_end(va);
79840 return buf;
79841 }
79842 + case 'P':
79843 + break;
79844 case 'K':
79845 /*
79846 * %pK cannot be used in IRQ context because its test
79847 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79848 }
79849 break;
79850 }
79851 +
79852 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79853 + /* 'P' = approved pointers to copy to userland,
79854 + as in the /proc/kallsyms case, as we make it display nothing
79855 + for non-root users, and the real contents for root users
79856 + Also ignore 'K' pointers, since we force their NULLing for non-root users
79857 + above
79858 + */
79859 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
79860 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
79861 + dump_stack();
79862 + ptr = NULL;
79863 + }
79864 +#endif
79865 +
79866 spec.flags |= SMALL;
79867 if (spec.field_width == -1) {
79868 spec.field_width = default_width;
79869 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
79870 typeof(type) value; \
79871 if (sizeof(type) == 8) { \
79872 args = PTR_ALIGN(args, sizeof(u32)); \
79873 - *(u32 *)&value = *(u32 *)args; \
79874 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
79875 + *(u32 *)&value = *(const u32 *)args; \
79876 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
79877 } else { \
79878 args = PTR_ALIGN(args, sizeof(type)); \
79879 - value = *(typeof(type) *)args; \
79880 + value = *(const typeof(type) *)args; \
79881 } \
79882 args += sizeof(type); \
79883 value; \
79884 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
79885 case FORMAT_TYPE_STR: {
79886 const char *str_arg = args;
79887 args += strlen(str_arg) + 1;
79888 - str = string(str, end, (char *)str_arg, spec);
79889 + str = string(str, end, str_arg, spec);
79890 break;
79891 }
79892
79893 diff --git a/localversion-grsec b/localversion-grsec
79894 new file mode 100644
79895 index 0000000..7cd6065
79896 --- /dev/null
79897 +++ b/localversion-grsec
79898 @@ -0,0 +1 @@
79899 +-grsec
79900 diff --git a/mm/Kconfig b/mm/Kconfig
79901 index 278e3ab..87c384d 100644
79902 --- a/mm/Kconfig
79903 +++ b/mm/Kconfig
79904 @@ -286,10 +286,10 @@ config KSM
79905 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
79906
79907 config DEFAULT_MMAP_MIN_ADDR
79908 - int "Low address space to protect from user allocation"
79909 + int "Low address space to protect from user allocation"
79910 depends on MMU
79911 - default 4096
79912 - help
79913 + default 65536
79914 + help
79915 This is the portion of low virtual memory which should be protected
79916 from userspace allocation. Keeping a user from writing to low pages
79917 can help reduce the impact of kernel NULL pointer bugs.
79918 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
79919
79920 config HWPOISON_INJECT
79921 tristate "HWPoison pages injector"
79922 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
79923 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
79924 select PROC_PAGE_MONITOR
79925
79926 config NOMMU_INITIAL_TRIM_EXCESS
79927 diff --git a/mm/filemap.c b/mm/filemap.c
79928 index 83efee7..3f99381 100644
79929 --- a/mm/filemap.c
79930 +++ b/mm/filemap.c
79931 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
79932 struct address_space *mapping = file->f_mapping;
79933
79934 if (!mapping->a_ops->readpage)
79935 - return -ENOEXEC;
79936 + return -ENODEV;
79937 file_accessed(file);
79938 vma->vm_ops = &generic_file_vm_ops;
79939 return 0;
79940 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
79941 *pos = i_size_read(inode);
79942
79943 if (limit != RLIM_INFINITY) {
79944 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
79945 if (*pos >= limit) {
79946 send_sig(SIGXFSZ, current, 0);
79947 return -EFBIG;
79948 diff --git a/mm/fremap.c b/mm/fremap.c
79949 index a0aaf0e..20325c3 100644
79950 --- a/mm/fremap.c
79951 +++ b/mm/fremap.c
79952 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
79953 retry:
79954 vma = find_vma(mm, start);
79955
79956 +#ifdef CONFIG_PAX_SEGMEXEC
79957 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
79958 + goto out;
79959 +#endif
79960 +
79961 /*
79962 * Make sure the vma is shared, that it supports prefaulting,
79963 * and that the remapped range is valid and fully within
79964 diff --git a/mm/highmem.c b/mm/highmem.c
79965 index b32b70c..e512eb0 100644
79966 --- a/mm/highmem.c
79967 +++ b/mm/highmem.c
79968 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
79969 * So no dangers, even with speculative execution.
79970 */
79971 page = pte_page(pkmap_page_table[i]);
79972 + pax_open_kernel();
79973 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
79974 -
79975 + pax_close_kernel();
79976 set_page_address(page, NULL);
79977 need_flush = 1;
79978 }
79979 @@ -198,9 +199,11 @@ start:
79980 }
79981 }
79982 vaddr = PKMAP_ADDR(last_pkmap_nr);
79983 +
79984 + pax_open_kernel();
79985 set_pte_at(&init_mm, vaddr,
79986 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
79987 -
79988 + pax_close_kernel();
79989 pkmap_count[last_pkmap_nr] = 1;
79990 set_page_address(page, (void *)vaddr);
79991
79992 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
79993 index d7cec92..b05cc33 100644
79994 --- a/mm/hugetlb.c
79995 +++ b/mm/hugetlb.c
79996 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
79997 struct hstate *h = &default_hstate;
79998 unsigned long tmp;
79999 int ret;
80000 + ctl_table_no_const hugetlb_table;
80001
80002 tmp = h->max_huge_pages;
80003
80004 if (write && h->order >= MAX_ORDER)
80005 return -EINVAL;
80006
80007 - table->data = &tmp;
80008 - table->maxlen = sizeof(unsigned long);
80009 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80010 + hugetlb_table = *table;
80011 + hugetlb_table.data = &tmp;
80012 + hugetlb_table.maxlen = sizeof(unsigned long);
80013 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80014 if (ret)
80015 goto out;
80016
80017 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80018 struct hstate *h = &default_hstate;
80019 unsigned long tmp;
80020 int ret;
80021 + ctl_table_no_const hugetlb_table;
80022
80023 tmp = h->nr_overcommit_huge_pages;
80024
80025 if (write && h->order >= MAX_ORDER)
80026 return -EINVAL;
80027
80028 - table->data = &tmp;
80029 - table->maxlen = sizeof(unsigned long);
80030 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80031 + hugetlb_table = *table;
80032 + hugetlb_table.data = &tmp;
80033 + hugetlb_table.maxlen = sizeof(unsigned long);
80034 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80035 if (ret)
80036 goto out;
80037
80038 @@ -2515,6 +2519,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80039 return 1;
80040 }
80041
80042 +#ifdef CONFIG_PAX_SEGMEXEC
80043 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80044 +{
80045 + struct mm_struct *mm = vma->vm_mm;
80046 + struct vm_area_struct *vma_m;
80047 + unsigned long address_m;
80048 + pte_t *ptep_m;
80049 +
80050 + vma_m = pax_find_mirror_vma(vma);
80051 + if (!vma_m)
80052 + return;
80053 +
80054 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80055 + address_m = address + SEGMEXEC_TASK_SIZE;
80056 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80057 + get_page(page_m);
80058 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80059 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80060 +}
80061 +#endif
80062 +
80063 /*
80064 * Hugetlb_cow() should be called with page lock of the original hugepage held.
80065 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
80066 @@ -2633,6 +2658,11 @@ retry_avoidcopy:
80067 make_huge_pte(vma, new_page, 1));
80068 page_remove_rmap(old_page);
80069 hugepage_add_new_anon_rmap(new_page, vma, address);
80070 +
80071 +#ifdef CONFIG_PAX_SEGMEXEC
80072 + pax_mirror_huge_pte(vma, address, new_page);
80073 +#endif
80074 +
80075 /* Make the old page be freed below */
80076 new_page = old_page;
80077 }
80078 @@ -2792,6 +2822,10 @@ retry:
80079 && (vma->vm_flags & VM_SHARED)));
80080 set_huge_pte_at(mm, address, ptep, new_pte);
80081
80082 +#ifdef CONFIG_PAX_SEGMEXEC
80083 + pax_mirror_huge_pte(vma, address, page);
80084 +#endif
80085 +
80086 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
80087 /* Optimization, do the COW without a second fault */
80088 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
80089 @@ -2821,6 +2855,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80090 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
80091 struct hstate *h = hstate_vma(vma);
80092
80093 +#ifdef CONFIG_PAX_SEGMEXEC
80094 + struct vm_area_struct *vma_m;
80095 +#endif
80096 +
80097 address &= huge_page_mask(h);
80098
80099 ptep = huge_pte_offset(mm, address);
80100 @@ -2834,6 +2872,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80101 VM_FAULT_SET_HINDEX(hstate_index(h));
80102 }
80103
80104 +#ifdef CONFIG_PAX_SEGMEXEC
80105 + vma_m = pax_find_mirror_vma(vma);
80106 + if (vma_m) {
80107 + unsigned long address_m;
80108 +
80109 + if (vma->vm_start > vma_m->vm_start) {
80110 + address_m = address;
80111 + address -= SEGMEXEC_TASK_SIZE;
80112 + vma = vma_m;
80113 + h = hstate_vma(vma);
80114 + } else
80115 + address_m = address + SEGMEXEC_TASK_SIZE;
80116 +
80117 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
80118 + return VM_FAULT_OOM;
80119 + address_m &= HPAGE_MASK;
80120 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
80121 + }
80122 +#endif
80123 +
80124 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
80125 if (!ptep)
80126 return VM_FAULT_OOM;
80127 diff --git a/mm/internal.h b/mm/internal.h
80128 index 9ba2110..eaf0674 100644
80129 --- a/mm/internal.h
80130 +++ b/mm/internal.h
80131 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
80132 * in mm/page_alloc.c
80133 */
80134 extern void __free_pages_bootmem(struct page *page, unsigned int order);
80135 +extern void free_compound_page(struct page *page);
80136 extern void prep_compound_page(struct page *page, unsigned long order);
80137 #ifdef CONFIG_MEMORY_FAILURE
80138 extern bool is_free_buddy_page(struct page *page);
80139 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
80140 index 752a705..6c3102e 100644
80141 --- a/mm/kmemleak.c
80142 +++ b/mm/kmemleak.c
80143 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
80144
80145 for (i = 0; i < object->trace_len; i++) {
80146 void *ptr = (void *)object->trace[i];
80147 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
80148 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
80149 }
80150 }
80151
80152 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
80153 return -ENOMEM;
80154 }
80155
80156 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
80157 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
80158 &kmemleak_fops);
80159 if (!dentry)
80160 pr_warning("Failed to create the debugfs kmemleak file\n");
80161 diff --git a/mm/maccess.c b/mm/maccess.c
80162 index d53adf9..03a24bf 100644
80163 --- a/mm/maccess.c
80164 +++ b/mm/maccess.c
80165 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
80166 set_fs(KERNEL_DS);
80167 pagefault_disable();
80168 ret = __copy_from_user_inatomic(dst,
80169 - (__force const void __user *)src, size);
80170 + (const void __force_user *)src, size);
80171 pagefault_enable();
80172 set_fs(old_fs);
80173
80174 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
80175
80176 set_fs(KERNEL_DS);
80177 pagefault_disable();
80178 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
80179 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
80180 pagefault_enable();
80181 set_fs(old_fs);
80182
80183 diff --git a/mm/madvise.c b/mm/madvise.c
80184 index 03dfa5c..b032917 100644
80185 --- a/mm/madvise.c
80186 +++ b/mm/madvise.c
80187 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
80188 pgoff_t pgoff;
80189 unsigned long new_flags = vma->vm_flags;
80190
80191 +#ifdef CONFIG_PAX_SEGMEXEC
80192 + struct vm_area_struct *vma_m;
80193 +#endif
80194 +
80195 switch (behavior) {
80196 case MADV_NORMAL:
80197 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
80198 @@ -123,6 +127,13 @@ success:
80199 /*
80200 * vm_flags is protected by the mmap_sem held in write mode.
80201 */
80202 +
80203 +#ifdef CONFIG_PAX_SEGMEXEC
80204 + vma_m = pax_find_mirror_vma(vma);
80205 + if (vma_m)
80206 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
80207 +#endif
80208 +
80209 vma->vm_flags = new_flags;
80210
80211 out:
80212 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80213 struct vm_area_struct ** prev,
80214 unsigned long start, unsigned long end)
80215 {
80216 +
80217 +#ifdef CONFIG_PAX_SEGMEXEC
80218 + struct vm_area_struct *vma_m;
80219 +#endif
80220 +
80221 *prev = vma;
80222 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
80223 return -EINVAL;
80224 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80225 zap_page_range(vma, start, end - start, &details);
80226 } else
80227 zap_page_range(vma, start, end - start, NULL);
80228 +
80229 +#ifdef CONFIG_PAX_SEGMEXEC
80230 + vma_m = pax_find_mirror_vma(vma);
80231 + if (vma_m) {
80232 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
80233 + struct zap_details details = {
80234 + .nonlinear_vma = vma_m,
80235 + .last_index = ULONG_MAX,
80236 + };
80237 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
80238 + } else
80239 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
80240 + }
80241 +#endif
80242 +
80243 return 0;
80244 }
80245
80246 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
80247 if (end < start)
80248 goto out;
80249
80250 +#ifdef CONFIG_PAX_SEGMEXEC
80251 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
80252 + if (end > SEGMEXEC_TASK_SIZE)
80253 + goto out;
80254 + } else
80255 +#endif
80256 +
80257 + if (end > TASK_SIZE)
80258 + goto out;
80259 +
80260 error = 0;
80261 if (end == start)
80262 goto out;
80263 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
80264 index c6e4dd3..1f41988 100644
80265 --- a/mm/memory-failure.c
80266 +++ b/mm/memory-failure.c
80267 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
80268
80269 int sysctl_memory_failure_recovery __read_mostly = 1;
80270
80271 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
80272 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
80273
80274 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
80275
80276 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
80277 pfn, t->comm, t->pid);
80278 si.si_signo = SIGBUS;
80279 si.si_errno = 0;
80280 - si.si_addr = (void *)addr;
80281 + si.si_addr = (void __user *)addr;
80282 #ifdef __ARCH_SI_TRAPNO
80283 si.si_trapno = trapno;
80284 #endif
80285 @@ -760,7 +760,7 @@ static struct page_state {
80286 unsigned long res;
80287 char *msg;
80288 int (*action)(struct page *p, unsigned long pfn);
80289 -} error_states[] = {
80290 +} __do_const error_states[] = {
80291 { reserved, reserved, "reserved kernel", me_kernel },
80292 /*
80293 * free pages are specially detected outside this table:
80294 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80295 }
80296
80297 nr_pages = 1 << compound_trans_order(hpage);
80298 - atomic_long_add(nr_pages, &mce_bad_pages);
80299 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
80300
80301 /*
80302 * We need/can do nothing about count=0 pages.
80303 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80304 if (!PageHWPoison(hpage)
80305 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
80306 || (p != hpage && TestSetPageHWPoison(hpage))) {
80307 - atomic_long_sub(nr_pages, &mce_bad_pages);
80308 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80309 return 0;
80310 }
80311 set_page_hwpoison_huge_page(hpage);
80312 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80313 }
80314 if (hwpoison_filter(p)) {
80315 if (TestClearPageHWPoison(p))
80316 - atomic_long_sub(nr_pages, &mce_bad_pages);
80317 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80318 unlock_page(hpage);
80319 put_page(hpage);
80320 return 0;
80321 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
80322 return 0;
80323 }
80324 if (TestClearPageHWPoison(p))
80325 - atomic_long_sub(nr_pages, &mce_bad_pages);
80326 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80327 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
80328 return 0;
80329 }
80330 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
80331 */
80332 if (TestClearPageHWPoison(page)) {
80333 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
80334 - atomic_long_sub(nr_pages, &mce_bad_pages);
80335 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
80336 freeit = 1;
80337 if (PageHuge(page))
80338 clear_page_hwpoison_huge_page(page);
80339 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
80340 }
80341 done:
80342 if (!PageHWPoison(hpage))
80343 - atomic_long_add(1 << compound_trans_order(hpage),
80344 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
80345 &mce_bad_pages);
80346 set_page_hwpoison_huge_page(hpage);
80347 dequeue_hwpoisoned_huge_page(hpage);
80348 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
80349 return ret;
80350
80351 done:
80352 - atomic_long_add(1, &mce_bad_pages);
80353 + atomic_long_add_unchecked(1, &mce_bad_pages);
80354 SetPageHWPoison(page);
80355 /* keep elevated page count for bad page */
80356 return ret;
80357 diff --git a/mm/memory.c b/mm/memory.c
80358 index bb1369f..efb96b5 100644
80359 --- a/mm/memory.c
80360 +++ b/mm/memory.c
80361 @@ -433,6 +433,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80362 free_pte_range(tlb, pmd, addr);
80363 } while (pmd++, addr = next, addr != end);
80364
80365 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
80366 start &= PUD_MASK;
80367 if (start < floor)
80368 return;
80369 @@ -447,6 +448,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
80370 pmd = pmd_offset(pud, start);
80371 pud_clear(pud);
80372 pmd_free_tlb(tlb, pmd, start);
80373 +#endif
80374 +
80375 }
80376
80377 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80378 @@ -466,6 +469,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80379 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
80380 } while (pud++, addr = next, addr != end);
80381
80382 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
80383 start &= PGDIR_MASK;
80384 if (start < floor)
80385 return;
80386 @@ -480,6 +484,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
80387 pud = pud_offset(pgd, start);
80388 pgd_clear(pgd);
80389 pud_free_tlb(tlb, pud, start);
80390 +#endif
80391 +
80392 }
80393
80394 /*
80395 @@ -1618,12 +1624,6 @@ no_page_table:
80396 return page;
80397 }
80398
80399 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
80400 -{
80401 - return stack_guard_page_start(vma, addr) ||
80402 - stack_guard_page_end(vma, addr+PAGE_SIZE);
80403 -}
80404 -
80405 /**
80406 * __get_user_pages() - pin user pages in memory
80407 * @tsk: task_struct of target task
80408 @@ -1709,10 +1709,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80409
80410 i = 0;
80411
80412 - do {
80413 + while (nr_pages) {
80414 struct vm_area_struct *vma;
80415
80416 - vma = find_extend_vma(mm, start);
80417 + vma = find_vma(mm, start);
80418 if (!vma && in_gate_area(mm, start)) {
80419 unsigned long pg = start & PAGE_MASK;
80420 pgd_t *pgd;
80421 @@ -1760,7 +1760,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80422 goto next_page;
80423 }
80424
80425 - if (!vma ||
80426 + if (!vma || start < vma->vm_start ||
80427 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
80428 !(vm_flags & vma->vm_flags))
80429 return i ? : -EFAULT;
80430 @@ -1787,11 +1787,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80431 int ret;
80432 unsigned int fault_flags = 0;
80433
80434 - /* For mlock, just skip the stack guard page. */
80435 - if (foll_flags & FOLL_MLOCK) {
80436 - if (stack_guard_page(vma, start))
80437 - goto next_page;
80438 - }
80439 if (foll_flags & FOLL_WRITE)
80440 fault_flags |= FAULT_FLAG_WRITE;
80441 if (nonblocking)
80442 @@ -1865,7 +1860,7 @@ next_page:
80443 start += PAGE_SIZE;
80444 nr_pages--;
80445 } while (nr_pages && start < vma->vm_end);
80446 - } while (nr_pages);
80447 + }
80448 return i;
80449 }
80450 EXPORT_SYMBOL(__get_user_pages);
80451 @@ -2072,6 +2067,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
80452 page_add_file_rmap(page);
80453 set_pte_at(mm, addr, pte, mk_pte(page, prot));
80454
80455 +#ifdef CONFIG_PAX_SEGMEXEC
80456 + pax_mirror_file_pte(vma, addr, page, ptl);
80457 +#endif
80458 +
80459 retval = 0;
80460 pte_unmap_unlock(pte, ptl);
80461 return retval;
80462 @@ -2116,9 +2115,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
80463 if (!page_count(page))
80464 return -EINVAL;
80465 if (!(vma->vm_flags & VM_MIXEDMAP)) {
80466 +
80467 +#ifdef CONFIG_PAX_SEGMEXEC
80468 + struct vm_area_struct *vma_m;
80469 +#endif
80470 +
80471 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
80472 BUG_ON(vma->vm_flags & VM_PFNMAP);
80473 vma->vm_flags |= VM_MIXEDMAP;
80474 +
80475 +#ifdef CONFIG_PAX_SEGMEXEC
80476 + vma_m = pax_find_mirror_vma(vma);
80477 + if (vma_m)
80478 + vma_m->vm_flags |= VM_MIXEDMAP;
80479 +#endif
80480 +
80481 }
80482 return insert_page(vma, addr, page, vma->vm_page_prot);
80483 }
80484 @@ -2201,6 +2212,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
80485 unsigned long pfn)
80486 {
80487 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
80488 + BUG_ON(vma->vm_mirror);
80489
80490 if (addr < vma->vm_start || addr >= vma->vm_end)
80491 return -EFAULT;
80492 @@ -2401,7 +2413,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
80493
80494 BUG_ON(pud_huge(*pud));
80495
80496 - pmd = pmd_alloc(mm, pud, addr);
80497 + pmd = (mm == &init_mm) ?
80498 + pmd_alloc_kernel(mm, pud, addr) :
80499 + pmd_alloc(mm, pud, addr);
80500 if (!pmd)
80501 return -ENOMEM;
80502 do {
80503 @@ -2421,7 +2435,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
80504 unsigned long next;
80505 int err;
80506
80507 - pud = pud_alloc(mm, pgd, addr);
80508 + pud = (mm == &init_mm) ?
80509 + pud_alloc_kernel(mm, pgd, addr) :
80510 + pud_alloc(mm, pgd, addr);
80511 if (!pud)
80512 return -ENOMEM;
80513 do {
80514 @@ -2509,6 +2525,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
80515 copy_user_highpage(dst, src, va, vma);
80516 }
80517
80518 +#ifdef CONFIG_PAX_SEGMEXEC
80519 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
80520 +{
80521 + struct mm_struct *mm = vma->vm_mm;
80522 + spinlock_t *ptl;
80523 + pte_t *pte, entry;
80524 +
80525 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
80526 + entry = *pte;
80527 + if (!pte_present(entry)) {
80528 + if (!pte_none(entry)) {
80529 + BUG_ON(pte_file(entry));
80530 + free_swap_and_cache(pte_to_swp_entry(entry));
80531 + pte_clear_not_present_full(mm, address, pte, 0);
80532 + }
80533 + } else {
80534 + struct page *page;
80535 +
80536 + flush_cache_page(vma, address, pte_pfn(entry));
80537 + entry = ptep_clear_flush(vma, address, pte);
80538 + BUG_ON(pte_dirty(entry));
80539 + page = vm_normal_page(vma, address, entry);
80540 + if (page) {
80541 + update_hiwater_rss(mm);
80542 + if (PageAnon(page))
80543 + dec_mm_counter_fast(mm, MM_ANONPAGES);
80544 + else
80545 + dec_mm_counter_fast(mm, MM_FILEPAGES);
80546 + page_remove_rmap(page);
80547 + page_cache_release(page);
80548 + }
80549 + }
80550 + pte_unmap_unlock(pte, ptl);
80551 +}
80552 +
80553 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
80554 + *
80555 + * the ptl of the lower mapped page is held on entry and is not released on exit
80556 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
80557 + */
80558 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80559 +{
80560 + struct mm_struct *mm = vma->vm_mm;
80561 + unsigned long address_m;
80562 + spinlock_t *ptl_m;
80563 + struct vm_area_struct *vma_m;
80564 + pmd_t *pmd_m;
80565 + pte_t *pte_m, entry_m;
80566 +
80567 + BUG_ON(!page_m || !PageAnon(page_m));
80568 +
80569 + vma_m = pax_find_mirror_vma(vma);
80570 + if (!vma_m)
80571 + return;
80572 +
80573 + BUG_ON(!PageLocked(page_m));
80574 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80575 + address_m = address + SEGMEXEC_TASK_SIZE;
80576 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80577 + pte_m = pte_offset_map(pmd_m, address_m);
80578 + ptl_m = pte_lockptr(mm, pmd_m);
80579 + if (ptl != ptl_m) {
80580 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80581 + if (!pte_none(*pte_m))
80582 + goto out;
80583 + }
80584 +
80585 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80586 + page_cache_get(page_m);
80587 + page_add_anon_rmap(page_m, vma_m, address_m);
80588 + inc_mm_counter_fast(mm, MM_ANONPAGES);
80589 + set_pte_at(mm, address_m, pte_m, entry_m);
80590 + update_mmu_cache(vma_m, address_m, entry_m);
80591 +out:
80592 + if (ptl != ptl_m)
80593 + spin_unlock(ptl_m);
80594 + pte_unmap(pte_m);
80595 + unlock_page(page_m);
80596 +}
80597 +
80598 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80599 +{
80600 + struct mm_struct *mm = vma->vm_mm;
80601 + unsigned long address_m;
80602 + spinlock_t *ptl_m;
80603 + struct vm_area_struct *vma_m;
80604 + pmd_t *pmd_m;
80605 + pte_t *pte_m, entry_m;
80606 +
80607 + BUG_ON(!page_m || PageAnon(page_m));
80608 +
80609 + vma_m = pax_find_mirror_vma(vma);
80610 + if (!vma_m)
80611 + return;
80612 +
80613 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80614 + address_m = address + SEGMEXEC_TASK_SIZE;
80615 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80616 + pte_m = pte_offset_map(pmd_m, address_m);
80617 + ptl_m = pte_lockptr(mm, pmd_m);
80618 + if (ptl != ptl_m) {
80619 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80620 + if (!pte_none(*pte_m))
80621 + goto out;
80622 + }
80623 +
80624 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80625 + page_cache_get(page_m);
80626 + page_add_file_rmap(page_m);
80627 + inc_mm_counter_fast(mm, MM_FILEPAGES);
80628 + set_pte_at(mm, address_m, pte_m, entry_m);
80629 + update_mmu_cache(vma_m, address_m, entry_m);
80630 +out:
80631 + if (ptl != ptl_m)
80632 + spin_unlock(ptl_m);
80633 + pte_unmap(pte_m);
80634 +}
80635 +
80636 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
80637 +{
80638 + struct mm_struct *mm = vma->vm_mm;
80639 + unsigned long address_m;
80640 + spinlock_t *ptl_m;
80641 + struct vm_area_struct *vma_m;
80642 + pmd_t *pmd_m;
80643 + pte_t *pte_m, entry_m;
80644 +
80645 + vma_m = pax_find_mirror_vma(vma);
80646 + if (!vma_m)
80647 + return;
80648 +
80649 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80650 + address_m = address + SEGMEXEC_TASK_SIZE;
80651 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80652 + pte_m = pte_offset_map(pmd_m, address_m);
80653 + ptl_m = pte_lockptr(mm, pmd_m);
80654 + if (ptl != ptl_m) {
80655 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80656 + if (!pte_none(*pte_m))
80657 + goto out;
80658 + }
80659 +
80660 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
80661 + set_pte_at(mm, address_m, pte_m, entry_m);
80662 +out:
80663 + if (ptl != ptl_m)
80664 + spin_unlock(ptl_m);
80665 + pte_unmap(pte_m);
80666 +}
80667 +
80668 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
80669 +{
80670 + struct page *page_m;
80671 + pte_t entry;
80672 +
80673 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
80674 + goto out;
80675 +
80676 + entry = *pte;
80677 + page_m = vm_normal_page(vma, address, entry);
80678 + if (!page_m)
80679 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
80680 + else if (PageAnon(page_m)) {
80681 + if (pax_find_mirror_vma(vma)) {
80682 + pte_unmap_unlock(pte, ptl);
80683 + lock_page(page_m);
80684 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
80685 + if (pte_same(entry, *pte))
80686 + pax_mirror_anon_pte(vma, address, page_m, ptl);
80687 + else
80688 + unlock_page(page_m);
80689 + }
80690 + } else
80691 + pax_mirror_file_pte(vma, address, page_m, ptl);
80692 +
80693 +out:
80694 + pte_unmap_unlock(pte, ptl);
80695 +}
80696 +#endif
80697 +
80698 /*
80699 * This routine handles present pages, when users try to write
80700 * to a shared page. It is done by copying the page to a new address
80701 @@ -2725,6 +2921,12 @@ gotten:
80702 */
80703 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
80704 if (likely(pte_same(*page_table, orig_pte))) {
80705 +
80706 +#ifdef CONFIG_PAX_SEGMEXEC
80707 + if (pax_find_mirror_vma(vma))
80708 + BUG_ON(!trylock_page(new_page));
80709 +#endif
80710 +
80711 if (old_page) {
80712 if (!PageAnon(old_page)) {
80713 dec_mm_counter_fast(mm, MM_FILEPAGES);
80714 @@ -2776,6 +2978,10 @@ gotten:
80715 page_remove_rmap(old_page);
80716 }
80717
80718 +#ifdef CONFIG_PAX_SEGMEXEC
80719 + pax_mirror_anon_pte(vma, address, new_page, ptl);
80720 +#endif
80721 +
80722 /* Free the old page.. */
80723 new_page = old_page;
80724 ret |= VM_FAULT_WRITE;
80725 @@ -3051,6 +3257,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
80726 swap_free(entry);
80727 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
80728 try_to_free_swap(page);
80729 +
80730 +#ifdef CONFIG_PAX_SEGMEXEC
80731 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
80732 +#endif
80733 +
80734 unlock_page(page);
80735 if (swapcache) {
80736 /*
80737 @@ -3074,6 +3285,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
80738
80739 /* No need to invalidate - it was non-present before */
80740 update_mmu_cache(vma, address, page_table);
80741 +
80742 +#ifdef CONFIG_PAX_SEGMEXEC
80743 + pax_mirror_anon_pte(vma, address, page, ptl);
80744 +#endif
80745 +
80746 unlock:
80747 pte_unmap_unlock(page_table, ptl);
80748 out:
80749 @@ -3093,40 +3309,6 @@ out_release:
80750 }
80751
80752 /*
80753 - * This is like a special single-page "expand_{down|up}wards()",
80754 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
80755 - * doesn't hit another vma.
80756 - */
80757 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
80758 -{
80759 - address &= PAGE_MASK;
80760 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
80761 - struct vm_area_struct *prev = vma->vm_prev;
80762 -
80763 - /*
80764 - * Is there a mapping abutting this one below?
80765 - *
80766 - * That's only ok if it's the same stack mapping
80767 - * that has gotten split..
80768 - */
80769 - if (prev && prev->vm_end == address)
80770 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
80771 -
80772 - expand_downwards(vma, address - PAGE_SIZE);
80773 - }
80774 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
80775 - struct vm_area_struct *next = vma->vm_next;
80776 -
80777 - /* As VM_GROWSDOWN but s/below/above/ */
80778 - if (next && next->vm_start == address + PAGE_SIZE)
80779 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
80780 -
80781 - expand_upwards(vma, address + PAGE_SIZE);
80782 - }
80783 - return 0;
80784 -}
80785 -
80786 -/*
80787 * We enter with non-exclusive mmap_sem (to exclude vma changes,
80788 * but allow concurrent faults), and pte mapped but not yet locked.
80789 * We return with mmap_sem still held, but pte unmapped and unlocked.
80790 @@ -3135,27 +3317,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
80791 unsigned long address, pte_t *page_table, pmd_t *pmd,
80792 unsigned int flags)
80793 {
80794 - struct page *page;
80795 + struct page *page = NULL;
80796 spinlock_t *ptl;
80797 pte_t entry;
80798
80799 - pte_unmap(page_table);
80800 -
80801 - /* Check if we need to add a guard page to the stack */
80802 - if (check_stack_guard_page(vma, address) < 0)
80803 - return VM_FAULT_SIGBUS;
80804 -
80805 - /* Use the zero-page for reads */
80806 if (!(flags & FAULT_FLAG_WRITE)) {
80807 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
80808 vma->vm_page_prot));
80809 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
80810 + ptl = pte_lockptr(mm, pmd);
80811 + spin_lock(ptl);
80812 if (!pte_none(*page_table))
80813 goto unlock;
80814 goto setpte;
80815 }
80816
80817 /* Allocate our own private page. */
80818 + pte_unmap(page_table);
80819 +
80820 if (unlikely(anon_vma_prepare(vma)))
80821 goto oom;
80822 page = alloc_zeroed_user_highpage_movable(vma, address);
80823 @@ -3174,6 +3352,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
80824 if (!pte_none(*page_table))
80825 goto release;
80826
80827 +#ifdef CONFIG_PAX_SEGMEXEC
80828 + if (pax_find_mirror_vma(vma))
80829 + BUG_ON(!trylock_page(page));
80830 +#endif
80831 +
80832 inc_mm_counter_fast(mm, MM_ANONPAGES);
80833 page_add_new_anon_rmap(page, vma, address);
80834 setpte:
80835 @@ -3181,6 +3364,12 @@ setpte:
80836
80837 /* No need to invalidate - it was non-present before */
80838 update_mmu_cache(vma, address, page_table);
80839 +
80840 +#ifdef CONFIG_PAX_SEGMEXEC
80841 + if (page)
80842 + pax_mirror_anon_pte(vma, address, page, ptl);
80843 +#endif
80844 +
80845 unlock:
80846 pte_unmap_unlock(page_table, ptl);
80847 return 0;
80848 @@ -3324,6 +3513,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80849 */
80850 /* Only go through if we didn't race with anybody else... */
80851 if (likely(pte_same(*page_table, orig_pte))) {
80852 +
80853 +#ifdef CONFIG_PAX_SEGMEXEC
80854 + if (anon && pax_find_mirror_vma(vma))
80855 + BUG_ON(!trylock_page(page));
80856 +#endif
80857 +
80858 flush_icache_page(vma, page);
80859 entry = mk_pte(page, vma->vm_page_prot);
80860 if (flags & FAULT_FLAG_WRITE)
80861 @@ -3343,6 +3538,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80862
80863 /* no need to invalidate: a not-present page won't be cached */
80864 update_mmu_cache(vma, address, page_table);
80865 +
80866 +#ifdef CONFIG_PAX_SEGMEXEC
80867 + if (anon)
80868 + pax_mirror_anon_pte(vma, address, page, ptl);
80869 + else
80870 + pax_mirror_file_pte(vma, address, page, ptl);
80871 +#endif
80872 +
80873 } else {
80874 if (cow_page)
80875 mem_cgroup_uncharge_page(cow_page);
80876 @@ -3664,6 +3867,12 @@ int handle_pte_fault(struct mm_struct *mm,
80877 if (flags & FAULT_FLAG_WRITE)
80878 flush_tlb_fix_spurious_fault(vma, address);
80879 }
80880 +
80881 +#ifdef CONFIG_PAX_SEGMEXEC
80882 + pax_mirror_pte(vma, address, pte, pmd, ptl);
80883 + return 0;
80884 +#endif
80885 +
80886 unlock:
80887 pte_unmap_unlock(pte, ptl);
80888 return 0;
80889 @@ -3680,6 +3889,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80890 pmd_t *pmd;
80891 pte_t *pte;
80892
80893 +#ifdef CONFIG_PAX_SEGMEXEC
80894 + struct vm_area_struct *vma_m;
80895 +#endif
80896 +
80897 __set_current_state(TASK_RUNNING);
80898
80899 count_vm_event(PGFAULT);
80900 @@ -3691,6 +3904,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80901 if (unlikely(is_vm_hugetlb_page(vma)))
80902 return hugetlb_fault(mm, vma, address, flags);
80903
80904 +#ifdef CONFIG_PAX_SEGMEXEC
80905 + vma_m = pax_find_mirror_vma(vma);
80906 + if (vma_m) {
80907 + unsigned long address_m;
80908 + pgd_t *pgd_m;
80909 + pud_t *pud_m;
80910 + pmd_t *pmd_m;
80911 +
80912 + if (vma->vm_start > vma_m->vm_start) {
80913 + address_m = address;
80914 + address -= SEGMEXEC_TASK_SIZE;
80915 + vma = vma_m;
80916 + } else
80917 + address_m = address + SEGMEXEC_TASK_SIZE;
80918 +
80919 + pgd_m = pgd_offset(mm, address_m);
80920 + pud_m = pud_alloc(mm, pgd_m, address_m);
80921 + if (!pud_m)
80922 + return VM_FAULT_OOM;
80923 + pmd_m = pmd_alloc(mm, pud_m, address_m);
80924 + if (!pmd_m)
80925 + return VM_FAULT_OOM;
80926 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
80927 + return VM_FAULT_OOM;
80928 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
80929 + }
80930 +#endif
80931 +
80932 retry:
80933 pgd = pgd_offset(mm, address);
80934 pud = pud_alloc(mm, pgd, address);
80935 @@ -3789,6 +4030,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
80936 spin_unlock(&mm->page_table_lock);
80937 return 0;
80938 }
80939 +
80940 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
80941 +{
80942 + pud_t *new = pud_alloc_one(mm, address);
80943 + if (!new)
80944 + return -ENOMEM;
80945 +
80946 + smp_wmb(); /* See comment in __pte_alloc */
80947 +
80948 + spin_lock(&mm->page_table_lock);
80949 + if (pgd_present(*pgd)) /* Another has populated it */
80950 + pud_free(mm, new);
80951 + else
80952 + pgd_populate_kernel(mm, pgd, new);
80953 + spin_unlock(&mm->page_table_lock);
80954 + return 0;
80955 +}
80956 #endif /* __PAGETABLE_PUD_FOLDED */
80957
80958 #ifndef __PAGETABLE_PMD_FOLDED
80959 @@ -3819,6 +4077,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
80960 spin_unlock(&mm->page_table_lock);
80961 return 0;
80962 }
80963 +
80964 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
80965 +{
80966 + pmd_t *new = pmd_alloc_one(mm, address);
80967 + if (!new)
80968 + return -ENOMEM;
80969 +
80970 + smp_wmb(); /* See comment in __pte_alloc */
80971 +
80972 + spin_lock(&mm->page_table_lock);
80973 +#ifndef __ARCH_HAS_4LEVEL_HACK
80974 + if (pud_present(*pud)) /* Another has populated it */
80975 + pmd_free(mm, new);
80976 + else
80977 + pud_populate_kernel(mm, pud, new);
80978 +#else
80979 + if (pgd_present(*pud)) /* Another has populated it */
80980 + pmd_free(mm, new);
80981 + else
80982 + pgd_populate_kernel(mm, pud, new);
80983 +#endif /* __ARCH_HAS_4LEVEL_HACK */
80984 + spin_unlock(&mm->page_table_lock);
80985 + return 0;
80986 +}
80987 #endif /* __PAGETABLE_PMD_FOLDED */
80988
80989 int make_pages_present(unsigned long addr, unsigned long end)
80990 @@ -3856,7 +4138,7 @@ static int __init gate_vma_init(void)
80991 gate_vma.vm_start = FIXADDR_USER_START;
80992 gate_vma.vm_end = FIXADDR_USER_END;
80993 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
80994 - gate_vma.vm_page_prot = __P101;
80995 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
80996
80997 return 0;
80998 }
80999 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81000 index 3df6d12..a11056a 100644
81001 --- a/mm/mempolicy.c
81002 +++ b/mm/mempolicy.c
81003 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81004 unsigned long vmstart;
81005 unsigned long vmend;
81006
81007 +#ifdef CONFIG_PAX_SEGMEXEC
81008 + struct vm_area_struct *vma_m;
81009 +#endif
81010 +
81011 vma = find_vma(mm, start);
81012 if (!vma || vma->vm_start > start)
81013 return -EFAULT;
81014 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81015 if (err)
81016 goto out;
81017 }
81018 +
81019 err = vma_replace_policy(vma, new_pol);
81020 if (err)
81021 goto out;
81022 +
81023 +#ifdef CONFIG_PAX_SEGMEXEC
81024 + vma_m = pax_find_mirror_vma(vma);
81025 + if (vma_m) {
81026 + err = vma_replace_policy(vma_m, new_pol);
81027 + if (err)
81028 + goto out;
81029 + }
81030 +#endif
81031 +
81032 }
81033
81034 out:
81035 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
81036
81037 if (end < start)
81038 return -EINVAL;
81039 +
81040 +#ifdef CONFIG_PAX_SEGMEXEC
81041 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81042 + if (end > SEGMEXEC_TASK_SIZE)
81043 + return -EINVAL;
81044 + } else
81045 +#endif
81046 +
81047 + if (end > TASK_SIZE)
81048 + return -EINVAL;
81049 +
81050 if (end == start)
81051 return 0;
81052
81053 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81054 */
81055 tcred = __task_cred(task);
81056 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81057 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81058 - !capable(CAP_SYS_NICE)) {
81059 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81060 rcu_read_unlock();
81061 err = -EPERM;
81062 goto out_put;
81063 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81064 goto out;
81065 }
81066
81067 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81068 + if (mm != current->mm &&
81069 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
81070 + mmput(mm);
81071 + err = -EPERM;
81072 + goto out;
81073 + }
81074 +#endif
81075 +
81076 err = do_migrate_pages(mm, old, new,
81077 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
81078
81079 diff --git a/mm/migrate.c b/mm/migrate.c
81080 index 2fd8b4a..d70358f 100644
81081 --- a/mm/migrate.c
81082 +++ b/mm/migrate.c
81083 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
81084 */
81085 tcred = __task_cred(task);
81086 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81087 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81088 - !capable(CAP_SYS_NICE)) {
81089 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81090 rcu_read_unlock();
81091 err = -EPERM;
81092 goto out;
81093 diff --git a/mm/mlock.c b/mm/mlock.c
81094 index c9bd528..da8d069 100644
81095 --- a/mm/mlock.c
81096 +++ b/mm/mlock.c
81097 @@ -13,6 +13,7 @@
81098 #include <linux/pagemap.h>
81099 #include <linux/mempolicy.h>
81100 #include <linux/syscalls.h>
81101 +#include <linux/security.h>
81102 #include <linux/sched.h>
81103 #include <linux/export.h>
81104 #include <linux/rmap.h>
81105 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
81106 {
81107 unsigned long nstart, end, tmp;
81108 struct vm_area_struct * vma, * prev;
81109 - int error;
81110 + int error = 0;
81111
81112 VM_BUG_ON(start & ~PAGE_MASK);
81113 VM_BUG_ON(len != PAGE_ALIGN(len));
81114 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
81115 return -EINVAL;
81116 if (end == start)
81117 return 0;
81118 + if (end > TASK_SIZE)
81119 + return -EINVAL;
81120 +
81121 vma = find_vma(current->mm, start);
81122 if (!vma || vma->vm_start > start)
81123 return -ENOMEM;
81124 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
81125 for (nstart = start ; ; ) {
81126 vm_flags_t newflags;
81127
81128 +#ifdef CONFIG_PAX_SEGMEXEC
81129 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81130 + break;
81131 +#endif
81132 +
81133 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
81134
81135 newflags = vma->vm_flags | VM_LOCKED;
81136 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
81137 lock_limit >>= PAGE_SHIFT;
81138
81139 /* check against resource limits */
81140 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
81141 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
81142 error = do_mlock(start, len, 1);
81143 up_write(&current->mm->mmap_sem);
81144 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
81145 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
81146 vm_flags_t newflags;
81147
81148 +#ifdef CONFIG_PAX_SEGMEXEC
81149 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81150 + break;
81151 +#endif
81152 +
81153 + BUG_ON(vma->vm_end > TASK_SIZE);
81154 newflags = vma->vm_flags | VM_LOCKED;
81155 if (!(flags & MCL_CURRENT))
81156 newflags &= ~VM_LOCKED;
81157 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
81158 lock_limit >>= PAGE_SHIFT;
81159
81160 ret = -ENOMEM;
81161 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
81162 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
81163 capable(CAP_IPC_LOCK))
81164 ret = do_mlockall(flags);
81165 diff --git a/mm/mmap.c b/mm/mmap.c
81166 index 8832b87..4bbb1b2 100644
81167 --- a/mm/mmap.c
81168 +++ b/mm/mmap.c
81169 @@ -32,6 +32,7 @@
81170 #include <linux/khugepaged.h>
81171 #include <linux/uprobes.h>
81172 #include <linux/rbtree_augmented.h>
81173 +#include <linux/random.h>
81174
81175 #include <asm/uaccess.h>
81176 #include <asm/cacheflush.h>
81177 @@ -48,6 +49,16 @@
81178 #define arch_rebalance_pgtables(addr, len) (addr)
81179 #endif
81180
81181 +static inline void verify_mm_writelocked(struct mm_struct *mm)
81182 +{
81183 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
81184 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
81185 + up_read(&mm->mmap_sem);
81186 + BUG();
81187 + }
81188 +#endif
81189 +}
81190 +
81191 static void unmap_region(struct mm_struct *mm,
81192 struct vm_area_struct *vma, struct vm_area_struct *prev,
81193 unsigned long start, unsigned long end);
81194 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
81195 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
81196 *
81197 */
81198 -pgprot_t protection_map[16] = {
81199 +pgprot_t protection_map[16] __read_only = {
81200 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
81201 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
81202 };
81203
81204 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
81205 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
81206 {
81207 - return __pgprot(pgprot_val(protection_map[vm_flags &
81208 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
81209 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
81210 pgprot_val(arch_vm_get_page_prot(vm_flags)));
81211 +
81212 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81213 + if (!(__supported_pte_mask & _PAGE_NX) &&
81214 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
81215 + (vm_flags & (VM_READ | VM_WRITE)))
81216 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
81217 +#endif
81218 +
81219 + return prot;
81220 }
81221 EXPORT_SYMBOL(vm_get_page_prot);
81222
81223 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
81224 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
81225 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
81226 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
81227 /*
81228 * Make sure vm_committed_as in one cacheline and not cacheline shared with
81229 * other variables. It can be updated by several CPUs frequently.
81230 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
81231 struct vm_area_struct *next = vma->vm_next;
81232
81233 might_sleep();
81234 + BUG_ON(vma->vm_mirror);
81235 if (vma->vm_ops && vma->vm_ops->close)
81236 vma->vm_ops->close(vma);
81237 if (vma->vm_file)
81238 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
81239 * not page aligned -Ram Gupta
81240 */
81241 rlim = rlimit(RLIMIT_DATA);
81242 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
81243 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
81244 (mm->end_data - mm->start_data) > rlim)
81245 goto out;
81246 @@ -888,6 +911,12 @@ static int
81247 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
81248 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81249 {
81250 +
81251 +#ifdef CONFIG_PAX_SEGMEXEC
81252 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
81253 + return 0;
81254 +#endif
81255 +
81256 if (is_mergeable_vma(vma, file, vm_flags) &&
81257 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81258 if (vma->vm_pgoff == vm_pgoff)
81259 @@ -907,6 +936,12 @@ static int
81260 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81261 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
81262 {
81263 +
81264 +#ifdef CONFIG_PAX_SEGMEXEC
81265 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
81266 + return 0;
81267 +#endif
81268 +
81269 if (is_mergeable_vma(vma, file, vm_flags) &&
81270 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
81271 pgoff_t vm_pglen;
81272 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
81273 struct vm_area_struct *vma_merge(struct mm_struct *mm,
81274 struct vm_area_struct *prev, unsigned long addr,
81275 unsigned long end, unsigned long vm_flags,
81276 - struct anon_vma *anon_vma, struct file *file,
81277 + struct anon_vma *anon_vma, struct file *file,
81278 pgoff_t pgoff, struct mempolicy *policy)
81279 {
81280 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
81281 struct vm_area_struct *area, *next;
81282 int err;
81283
81284 +#ifdef CONFIG_PAX_SEGMEXEC
81285 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
81286 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
81287 +
81288 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
81289 +#endif
81290 +
81291 /*
81292 * We later require that vma->vm_flags == vm_flags,
81293 * so this tests vma->vm_flags & VM_SPECIAL, too.
81294 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81295 if (next && next->vm_end == end) /* cases 6, 7, 8 */
81296 next = next->vm_next;
81297
81298 +#ifdef CONFIG_PAX_SEGMEXEC
81299 + if (prev)
81300 + prev_m = pax_find_mirror_vma(prev);
81301 + if (area)
81302 + area_m = pax_find_mirror_vma(area);
81303 + if (next)
81304 + next_m = pax_find_mirror_vma(next);
81305 +#endif
81306 +
81307 /*
81308 * Can it merge with the predecessor?
81309 */
81310 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81311 /* cases 1, 6 */
81312 err = vma_adjust(prev, prev->vm_start,
81313 next->vm_end, prev->vm_pgoff, NULL);
81314 - } else /* cases 2, 5, 7 */
81315 +
81316 +#ifdef CONFIG_PAX_SEGMEXEC
81317 + if (!err && prev_m)
81318 + err = vma_adjust(prev_m, prev_m->vm_start,
81319 + next_m->vm_end, prev_m->vm_pgoff, NULL);
81320 +#endif
81321 +
81322 + } else { /* cases 2, 5, 7 */
81323 err = vma_adjust(prev, prev->vm_start,
81324 end, prev->vm_pgoff, NULL);
81325 +
81326 +#ifdef CONFIG_PAX_SEGMEXEC
81327 + if (!err && prev_m)
81328 + err = vma_adjust(prev_m, prev_m->vm_start,
81329 + end_m, prev_m->vm_pgoff, NULL);
81330 +#endif
81331 +
81332 + }
81333 if (err)
81334 return NULL;
81335 khugepaged_enter_vma_merge(prev);
81336 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81337 mpol_equal(policy, vma_policy(next)) &&
81338 can_vma_merge_before(next, vm_flags,
81339 anon_vma, file, pgoff+pglen)) {
81340 - if (prev && addr < prev->vm_end) /* case 4 */
81341 + if (prev && addr < prev->vm_end) { /* case 4 */
81342 err = vma_adjust(prev, prev->vm_start,
81343 addr, prev->vm_pgoff, NULL);
81344 - else /* cases 3, 8 */
81345 +
81346 +#ifdef CONFIG_PAX_SEGMEXEC
81347 + if (!err && prev_m)
81348 + err = vma_adjust(prev_m, prev_m->vm_start,
81349 + addr_m, prev_m->vm_pgoff, NULL);
81350 +#endif
81351 +
81352 + } else { /* cases 3, 8 */
81353 err = vma_adjust(area, addr, next->vm_end,
81354 next->vm_pgoff - pglen, NULL);
81355 +
81356 +#ifdef CONFIG_PAX_SEGMEXEC
81357 + if (!err && area_m)
81358 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
81359 + next_m->vm_pgoff - pglen, NULL);
81360 +#endif
81361 +
81362 + }
81363 if (err)
81364 return NULL;
81365 khugepaged_enter_vma_merge(area);
81366 @@ -1120,8 +1201,10 @@ none:
81367 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81368 struct file *file, long pages)
81369 {
81370 - const unsigned long stack_flags
81371 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
81372 +
81373 +#ifdef CONFIG_PAX_RANDMMAP
81374 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81375 +#endif
81376
81377 mm->total_vm += pages;
81378
81379 @@ -1129,7 +1212,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81380 mm->shared_vm += pages;
81381 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
81382 mm->exec_vm += pages;
81383 - } else if (flags & stack_flags)
81384 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
81385 mm->stack_vm += pages;
81386 }
81387 #endif /* CONFIG_PROC_FS */
81388 @@ -1165,7 +1248,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81389 * (the exception is when the underlying filesystem is noexec
81390 * mounted, in which case we dont add PROT_EXEC.)
81391 */
81392 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
81393 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
81394 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
81395 prot |= PROT_EXEC;
81396
81397 @@ -1191,7 +1274,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81398 /* Obtain the address to map to. we verify (or select) it and ensure
81399 * that it represents a valid section of the address space.
81400 */
81401 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
81402 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
81403 if (addr & ~PAGE_MASK)
81404 return addr;
81405
81406 @@ -1202,6 +1285,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81407 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
81408 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
81409
81410 +#ifdef CONFIG_PAX_MPROTECT
81411 + if (mm->pax_flags & MF_PAX_MPROTECT) {
81412 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
81413 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
81414 + gr_log_rwxmmap(file);
81415 +
81416 +#ifdef CONFIG_PAX_EMUPLT
81417 + vm_flags &= ~VM_EXEC;
81418 +#else
81419 + return -EPERM;
81420 +#endif
81421 +
81422 + }
81423 +
81424 + if (!(vm_flags & VM_EXEC))
81425 + vm_flags &= ~VM_MAYEXEC;
81426 +#else
81427 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
81428 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
81429 +#endif
81430 + else
81431 + vm_flags &= ~VM_MAYWRITE;
81432 + }
81433 +#endif
81434 +
81435 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81436 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
81437 + vm_flags &= ~VM_PAGEEXEC;
81438 +#endif
81439 +
81440 if (flags & MAP_LOCKED)
81441 if (!can_do_mlock())
81442 return -EPERM;
81443 @@ -1213,6 +1326,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81444 locked += mm->locked_vm;
81445 lock_limit = rlimit(RLIMIT_MEMLOCK);
81446 lock_limit >>= PAGE_SHIFT;
81447 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81448 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
81449 return -EAGAIN;
81450 }
81451 @@ -1279,6 +1393,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81452 }
81453 }
81454
81455 + if (!gr_acl_handle_mmap(file, prot))
81456 + return -EACCES;
81457 +
81458 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
81459 }
81460
81461 @@ -1356,7 +1473,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
81462 vm_flags_t vm_flags = vma->vm_flags;
81463
81464 /* If it was private or non-writable, the write bit is already clear */
81465 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
81466 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
81467 return 0;
81468
81469 /* The backer wishes to know when pages are first written to? */
81470 @@ -1405,16 +1522,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
81471 unsigned long charged = 0;
81472 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
81473
81474 +#ifdef CONFIG_PAX_SEGMEXEC
81475 + struct vm_area_struct *vma_m = NULL;
81476 +#endif
81477 +
81478 + /*
81479 + * mm->mmap_sem is required to protect against another thread
81480 + * changing the mappings in case we sleep.
81481 + */
81482 + verify_mm_writelocked(mm);
81483 +
81484 /* Clear old maps */
81485 error = -ENOMEM;
81486 -munmap_back:
81487 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81488 if (do_munmap(mm, addr, len))
81489 return -ENOMEM;
81490 - goto munmap_back;
81491 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81492 }
81493
81494 /* Check against address space limit. */
81495 +
81496 +#ifdef CONFIG_PAX_RANDMMAP
81497 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81498 +#endif
81499 +
81500 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
81501 return -ENOMEM;
81502
81503 @@ -1460,6 +1591,16 @@ munmap_back:
81504 goto unacct_error;
81505 }
81506
81507 +#ifdef CONFIG_PAX_SEGMEXEC
81508 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
81509 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81510 + if (!vma_m) {
81511 + error = -ENOMEM;
81512 + goto free_vma;
81513 + }
81514 + }
81515 +#endif
81516 +
81517 vma->vm_mm = mm;
81518 vma->vm_start = addr;
81519 vma->vm_end = addr + len;
81520 @@ -1484,6 +1625,13 @@ munmap_back:
81521 if (error)
81522 goto unmap_and_free_vma;
81523
81524 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81525 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
81526 + vma->vm_flags |= VM_PAGEEXEC;
81527 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
81528 + }
81529 +#endif
81530 +
81531 /* Can addr have changed??
81532 *
81533 * Answer: Yes, several device drivers can do it in their
81534 @@ -1522,6 +1670,11 @@ munmap_back:
81535 vma_link(mm, vma, prev, rb_link, rb_parent);
81536 file = vma->vm_file;
81537
81538 +#ifdef CONFIG_PAX_SEGMEXEC
81539 + if (vma_m)
81540 + BUG_ON(pax_mirror_vma(vma_m, vma));
81541 +#endif
81542 +
81543 /* Once vma denies write, undo our temporary denial count */
81544 if (correct_wcount)
81545 atomic_inc(&inode->i_writecount);
81546 @@ -1529,6 +1682,7 @@ out:
81547 perf_event_mmap(vma);
81548
81549 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
81550 + track_exec_limit(mm, addr, addr + len, vm_flags);
81551 if (vm_flags & VM_LOCKED) {
81552 if (!mlock_vma_pages_range(vma, addr, addr + len))
81553 mm->locked_vm += (len >> PAGE_SHIFT);
81554 @@ -1550,6 +1704,12 @@ unmap_and_free_vma:
81555 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
81556 charged = 0;
81557 free_vma:
81558 +
81559 +#ifdef CONFIG_PAX_SEGMEXEC
81560 + if (vma_m)
81561 + kmem_cache_free(vm_area_cachep, vma_m);
81562 +#endif
81563 +
81564 kmem_cache_free(vm_area_cachep, vma);
81565 unacct_error:
81566 if (charged)
81567 @@ -1557,6 +1717,62 @@ unacct_error:
81568 return error;
81569 }
81570
81571 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
81572 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
81573 +{
81574 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
81575 + return (random32() & 0xFF) << PAGE_SHIFT;
81576 +
81577 + return 0;
81578 +}
81579 +#endif
81580 +
81581 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
81582 +{
81583 + if (!vma) {
81584 +#ifdef CONFIG_STACK_GROWSUP
81585 + if (addr > sysctl_heap_stack_gap)
81586 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
81587 + else
81588 + vma = find_vma(current->mm, 0);
81589 + if (vma && (vma->vm_flags & VM_GROWSUP))
81590 + return false;
81591 +#endif
81592 + return true;
81593 + }
81594 +
81595 + if (addr + len > vma->vm_start)
81596 + return false;
81597 +
81598 + if (vma->vm_flags & VM_GROWSDOWN)
81599 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
81600 +#ifdef CONFIG_STACK_GROWSUP
81601 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
81602 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
81603 +#endif
81604 + else if (offset)
81605 + return offset <= vma->vm_start - addr - len;
81606 +
81607 + return true;
81608 +}
81609 +
81610 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
81611 +{
81612 + if (vma->vm_start < len)
81613 + return -ENOMEM;
81614 +
81615 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
81616 + if (offset <= vma->vm_start - len)
81617 + return vma->vm_start - len - offset;
81618 + else
81619 + return -ENOMEM;
81620 + }
81621 +
81622 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
81623 + return vma->vm_start - len - sysctl_heap_stack_gap;
81624 + return -ENOMEM;
81625 +}
81626 +
81627 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
81628 {
81629 /*
81630 @@ -1776,6 +1992,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81631 struct mm_struct *mm = current->mm;
81632 struct vm_area_struct *vma;
81633 struct vm_unmapped_area_info info;
81634 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
81635
81636 if (len > TASK_SIZE)
81637 return -ENOMEM;
81638 @@ -1783,17 +2000,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81639 if (flags & MAP_FIXED)
81640 return addr;
81641
81642 +#ifdef CONFIG_PAX_RANDMMAP
81643 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
81644 +#endif
81645 +
81646 if (addr) {
81647 addr = PAGE_ALIGN(addr);
81648 vma = find_vma(mm, addr);
81649 - if (TASK_SIZE - len >= addr &&
81650 - (!vma || addr + len <= vma->vm_start))
81651 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
81652 return addr;
81653 }
81654
81655 info.flags = 0;
81656 info.length = len;
81657 info.low_limit = TASK_UNMAPPED_BASE;
81658 +
81659 +#ifdef CONFIG_PAX_RANDMMAP
81660 + if (mm->pax_flags & MF_PAX_RANDMMAP)
81661 + info.low_limit += mm->delta_mmap;
81662 +#endif
81663 +
81664 info.high_limit = TASK_SIZE;
81665 info.align_mask = 0;
81666 return vm_unmapped_area(&info);
81667 @@ -1802,10 +2028,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81668
81669 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
81670 {
81671 +
81672 +#ifdef CONFIG_PAX_SEGMEXEC
81673 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
81674 + return;
81675 +#endif
81676 +
81677 /*
81678 * Is this a new hole at the lowest possible address?
81679 */
81680 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
81681 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
81682 mm->free_area_cache = addr;
81683 }
81684
81685 @@ -1823,6 +2055,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81686 struct mm_struct *mm = current->mm;
81687 unsigned long addr = addr0;
81688 struct vm_unmapped_area_info info;
81689 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
81690
81691 /* requested length too big for entire address space */
81692 if (len > TASK_SIZE)
81693 @@ -1831,12 +2064,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81694 if (flags & MAP_FIXED)
81695 return addr;
81696
81697 +#ifdef CONFIG_PAX_RANDMMAP
81698 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
81699 +#endif
81700 +
81701 /* requesting a specific address */
81702 if (addr) {
81703 addr = PAGE_ALIGN(addr);
81704 vma = find_vma(mm, addr);
81705 - if (TASK_SIZE - len >= addr &&
81706 - (!vma || addr + len <= vma->vm_start))
81707 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
81708 return addr;
81709 }
81710
81711 @@ -1857,6 +2093,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81712 VM_BUG_ON(addr != -ENOMEM);
81713 info.flags = 0;
81714 info.low_limit = TASK_UNMAPPED_BASE;
81715 +
81716 +#ifdef CONFIG_PAX_RANDMMAP
81717 + if (mm->pax_flags & MF_PAX_RANDMMAP)
81718 + info.low_limit += mm->delta_mmap;
81719 +#endif
81720 +
81721 info.high_limit = TASK_SIZE;
81722 addr = vm_unmapped_area(&info);
81723 }
81724 @@ -1867,6 +2109,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81725
81726 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
81727 {
81728 +
81729 +#ifdef CONFIG_PAX_SEGMEXEC
81730 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
81731 + return;
81732 +#endif
81733 +
81734 /*
81735 * Is this a new hole at the highest possible address?
81736 */
81737 @@ -1874,8 +2122,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
81738 mm->free_area_cache = addr;
81739
81740 /* dont allow allocations above current base */
81741 - if (mm->free_area_cache > mm->mmap_base)
81742 + if (mm->free_area_cache > mm->mmap_base) {
81743 mm->free_area_cache = mm->mmap_base;
81744 + mm->cached_hole_size = ~0UL;
81745 + }
81746 }
81747
81748 unsigned long
81749 @@ -1974,6 +2224,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
81750 return vma;
81751 }
81752
81753 +#ifdef CONFIG_PAX_SEGMEXEC
81754 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
81755 +{
81756 + struct vm_area_struct *vma_m;
81757 +
81758 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
81759 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
81760 + BUG_ON(vma->vm_mirror);
81761 + return NULL;
81762 + }
81763 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
81764 + vma_m = vma->vm_mirror;
81765 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
81766 + BUG_ON(vma->vm_file != vma_m->vm_file);
81767 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
81768 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
81769 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
81770 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
81771 + return vma_m;
81772 +}
81773 +#endif
81774 +
81775 /*
81776 * Verify that the stack growth is acceptable and
81777 * update accounting. This is shared with both the
81778 @@ -1990,6 +2262,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81779 return -ENOMEM;
81780
81781 /* Stack limit test */
81782 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
81783 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
81784 return -ENOMEM;
81785
81786 @@ -2000,6 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81787 locked = mm->locked_vm + grow;
81788 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
81789 limit >>= PAGE_SHIFT;
81790 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81791 if (locked > limit && !capable(CAP_IPC_LOCK))
81792 return -ENOMEM;
81793 }
81794 @@ -2029,37 +2303,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81795 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
81796 * vma is the last one with address > vma->vm_end. Have to extend vma.
81797 */
81798 +#ifndef CONFIG_IA64
81799 +static
81800 +#endif
81801 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
81802 {
81803 int error;
81804 + bool locknext;
81805
81806 if (!(vma->vm_flags & VM_GROWSUP))
81807 return -EFAULT;
81808
81809 + /* Also guard against wrapping around to address 0. */
81810 + if (address < PAGE_ALIGN(address+1))
81811 + address = PAGE_ALIGN(address+1);
81812 + else
81813 + return -ENOMEM;
81814 +
81815 /*
81816 * We must make sure the anon_vma is allocated
81817 * so that the anon_vma locking is not a noop.
81818 */
81819 if (unlikely(anon_vma_prepare(vma)))
81820 return -ENOMEM;
81821 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
81822 + if (locknext && anon_vma_prepare(vma->vm_next))
81823 + return -ENOMEM;
81824 vma_lock_anon_vma(vma);
81825 + if (locknext)
81826 + vma_lock_anon_vma(vma->vm_next);
81827
81828 /*
81829 * vma->vm_start/vm_end cannot change under us because the caller
81830 * is required to hold the mmap_sem in read mode. We need the
81831 - * anon_vma lock to serialize against concurrent expand_stacks.
81832 - * Also guard against wrapping around to address 0.
81833 + * anon_vma locks to serialize against concurrent expand_stacks
81834 + * and expand_upwards.
81835 */
81836 - if (address < PAGE_ALIGN(address+4))
81837 - address = PAGE_ALIGN(address+4);
81838 - else {
81839 - vma_unlock_anon_vma(vma);
81840 - return -ENOMEM;
81841 - }
81842 error = 0;
81843
81844 /* Somebody else might have raced and expanded it already */
81845 - if (address > vma->vm_end) {
81846 + 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)
81847 + error = -ENOMEM;
81848 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
81849 unsigned long size, grow;
81850
81851 size = address - vma->vm_start;
81852 @@ -2094,6 +2379,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
81853 }
81854 }
81855 }
81856 + if (locknext)
81857 + vma_unlock_anon_vma(vma->vm_next);
81858 vma_unlock_anon_vma(vma);
81859 khugepaged_enter_vma_merge(vma);
81860 validate_mm(vma->vm_mm);
81861 @@ -2108,6 +2395,8 @@ int expand_downwards(struct vm_area_struct *vma,
81862 unsigned long address)
81863 {
81864 int error;
81865 + bool lockprev = false;
81866 + struct vm_area_struct *prev;
81867
81868 /*
81869 * We must make sure the anon_vma is allocated
81870 @@ -2121,6 +2410,15 @@ int expand_downwards(struct vm_area_struct *vma,
81871 if (error)
81872 return error;
81873
81874 + prev = vma->vm_prev;
81875 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
81876 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
81877 +#endif
81878 + if (lockprev && anon_vma_prepare(prev))
81879 + return -ENOMEM;
81880 + if (lockprev)
81881 + vma_lock_anon_vma(prev);
81882 +
81883 vma_lock_anon_vma(vma);
81884
81885 /*
81886 @@ -2130,9 +2428,17 @@ int expand_downwards(struct vm_area_struct *vma,
81887 */
81888
81889 /* Somebody else might have raced and expanded it already */
81890 - if (address < vma->vm_start) {
81891 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
81892 + error = -ENOMEM;
81893 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
81894 unsigned long size, grow;
81895
81896 +#ifdef CONFIG_PAX_SEGMEXEC
81897 + struct vm_area_struct *vma_m;
81898 +
81899 + vma_m = pax_find_mirror_vma(vma);
81900 +#endif
81901 +
81902 size = vma->vm_end - address;
81903 grow = (vma->vm_start - address) >> PAGE_SHIFT;
81904
81905 @@ -2157,6 +2463,18 @@ int expand_downwards(struct vm_area_struct *vma,
81906 vma->vm_pgoff -= grow;
81907 anon_vma_interval_tree_post_update_vma(vma);
81908 vma_gap_update(vma);
81909 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
81910 +
81911 +#ifdef CONFIG_PAX_SEGMEXEC
81912 + if (vma_m) {
81913 + anon_vma_interval_tree_pre_update_vma(vma_m);
81914 + vma_m->vm_start -= grow << PAGE_SHIFT;
81915 + vma_m->vm_pgoff -= grow;
81916 + anon_vma_interval_tree_post_update_vma(vma_m);
81917 + vma_gap_update(vma_m);
81918 + }
81919 +#endif
81920 +
81921 spin_unlock(&vma->vm_mm->page_table_lock);
81922
81923 perf_event_mmap(vma);
81924 @@ -2263,6 +2581,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
81925 do {
81926 long nrpages = vma_pages(vma);
81927
81928 +#ifdef CONFIG_PAX_SEGMEXEC
81929 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
81930 + vma = remove_vma(vma);
81931 + continue;
81932 + }
81933 +#endif
81934 +
81935 if (vma->vm_flags & VM_ACCOUNT)
81936 nr_accounted += nrpages;
81937 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
81938 @@ -2308,6 +2633,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
81939 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
81940 vma->vm_prev = NULL;
81941 do {
81942 +
81943 +#ifdef CONFIG_PAX_SEGMEXEC
81944 + if (vma->vm_mirror) {
81945 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
81946 + vma->vm_mirror->vm_mirror = NULL;
81947 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
81948 + vma->vm_mirror = NULL;
81949 + }
81950 +#endif
81951 +
81952 vma_rb_erase(vma, &mm->mm_rb);
81953 mm->map_count--;
81954 tail_vma = vma;
81955 @@ -2339,14 +2674,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81956 struct vm_area_struct *new;
81957 int err = -ENOMEM;
81958
81959 +#ifdef CONFIG_PAX_SEGMEXEC
81960 + struct vm_area_struct *vma_m, *new_m = NULL;
81961 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
81962 +#endif
81963 +
81964 if (is_vm_hugetlb_page(vma) && (addr &
81965 ~(huge_page_mask(hstate_vma(vma)))))
81966 return -EINVAL;
81967
81968 +#ifdef CONFIG_PAX_SEGMEXEC
81969 + vma_m = pax_find_mirror_vma(vma);
81970 +#endif
81971 +
81972 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81973 if (!new)
81974 goto out_err;
81975
81976 +#ifdef CONFIG_PAX_SEGMEXEC
81977 + if (vma_m) {
81978 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81979 + if (!new_m) {
81980 + kmem_cache_free(vm_area_cachep, new);
81981 + goto out_err;
81982 + }
81983 + }
81984 +#endif
81985 +
81986 /* most fields are the same, copy all, and then fixup */
81987 *new = *vma;
81988
81989 @@ -2359,6 +2713,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81990 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
81991 }
81992
81993 +#ifdef CONFIG_PAX_SEGMEXEC
81994 + if (vma_m) {
81995 + *new_m = *vma_m;
81996 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
81997 + new_m->vm_mirror = new;
81998 + new->vm_mirror = new_m;
81999 +
82000 + if (new_below)
82001 + new_m->vm_end = addr_m;
82002 + else {
82003 + new_m->vm_start = addr_m;
82004 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
82005 + }
82006 + }
82007 +#endif
82008 +
82009 pol = mpol_dup(vma_policy(vma));
82010 if (IS_ERR(pol)) {
82011 err = PTR_ERR(pol);
82012 @@ -2381,6 +2751,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82013 else
82014 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
82015
82016 +#ifdef CONFIG_PAX_SEGMEXEC
82017 + if (!err && vma_m) {
82018 + if (anon_vma_clone(new_m, vma_m))
82019 + goto out_free_mpol;
82020 +
82021 + mpol_get(pol);
82022 + vma_set_policy(new_m, pol);
82023 +
82024 + if (new_m->vm_file)
82025 + get_file(new_m->vm_file);
82026 +
82027 + if (new_m->vm_ops && new_m->vm_ops->open)
82028 + new_m->vm_ops->open(new_m);
82029 +
82030 + if (new_below)
82031 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
82032 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
82033 + else
82034 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
82035 +
82036 + if (err) {
82037 + if (new_m->vm_ops && new_m->vm_ops->close)
82038 + new_m->vm_ops->close(new_m);
82039 + if (new_m->vm_file)
82040 + fput(new_m->vm_file);
82041 + mpol_put(pol);
82042 + }
82043 + }
82044 +#endif
82045 +
82046 /* Success. */
82047 if (!err)
82048 return 0;
82049 @@ -2390,10 +2790,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82050 new->vm_ops->close(new);
82051 if (new->vm_file)
82052 fput(new->vm_file);
82053 - unlink_anon_vmas(new);
82054 out_free_mpol:
82055 mpol_put(pol);
82056 out_free_vma:
82057 +
82058 +#ifdef CONFIG_PAX_SEGMEXEC
82059 + if (new_m) {
82060 + unlink_anon_vmas(new_m);
82061 + kmem_cache_free(vm_area_cachep, new_m);
82062 + }
82063 +#endif
82064 +
82065 + unlink_anon_vmas(new);
82066 kmem_cache_free(vm_area_cachep, new);
82067 out_err:
82068 return err;
82069 @@ -2406,6 +2814,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82070 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82071 unsigned long addr, int new_below)
82072 {
82073 +
82074 +#ifdef CONFIG_PAX_SEGMEXEC
82075 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82076 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
82077 + if (mm->map_count >= sysctl_max_map_count-1)
82078 + return -ENOMEM;
82079 + } else
82080 +#endif
82081 +
82082 if (mm->map_count >= sysctl_max_map_count)
82083 return -ENOMEM;
82084
82085 @@ -2417,11 +2834,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82086 * work. This now handles partial unmappings.
82087 * Jeremy Fitzhardinge <jeremy@goop.org>
82088 */
82089 +#ifdef CONFIG_PAX_SEGMEXEC
82090 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82091 {
82092 + int ret = __do_munmap(mm, start, len);
82093 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
82094 + return ret;
82095 +
82096 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
82097 +}
82098 +
82099 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82100 +#else
82101 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82102 +#endif
82103 +{
82104 unsigned long end;
82105 struct vm_area_struct *vma, *prev, *last;
82106
82107 + /*
82108 + * mm->mmap_sem is required to protect against another thread
82109 + * changing the mappings in case we sleep.
82110 + */
82111 + verify_mm_writelocked(mm);
82112 +
82113 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
82114 return -EINVAL;
82115
82116 @@ -2496,6 +2932,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82117 /* Fix up all other VM information */
82118 remove_vma_list(mm, vma);
82119
82120 + track_exec_limit(mm, start, end, 0UL);
82121 +
82122 return 0;
82123 }
82124
82125 @@ -2504,6 +2942,13 @@ int vm_munmap(unsigned long start, size_t len)
82126 int ret;
82127 struct mm_struct *mm = current->mm;
82128
82129 +
82130 +#ifdef CONFIG_PAX_SEGMEXEC
82131 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
82132 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
82133 + return -EINVAL;
82134 +#endif
82135 +
82136 down_write(&mm->mmap_sem);
82137 ret = do_munmap(mm, start, len);
82138 up_write(&mm->mmap_sem);
82139 @@ -2517,16 +2962,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
82140 return vm_munmap(addr, len);
82141 }
82142
82143 -static inline void verify_mm_writelocked(struct mm_struct *mm)
82144 -{
82145 -#ifdef CONFIG_DEBUG_VM
82146 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82147 - WARN_ON(1);
82148 - up_read(&mm->mmap_sem);
82149 - }
82150 -#endif
82151 -}
82152 -
82153 /*
82154 * this is really a simplified "do_mmap". it only handles
82155 * anonymous maps. eventually we may be able to do some
82156 @@ -2540,6 +2975,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82157 struct rb_node ** rb_link, * rb_parent;
82158 pgoff_t pgoff = addr >> PAGE_SHIFT;
82159 int error;
82160 + unsigned long charged;
82161
82162 len = PAGE_ALIGN(len);
82163 if (!len)
82164 @@ -2547,16 +2983,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82165
82166 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
82167
82168 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
82169 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
82170 + flags &= ~VM_EXEC;
82171 +
82172 +#ifdef CONFIG_PAX_MPROTECT
82173 + if (mm->pax_flags & MF_PAX_MPROTECT)
82174 + flags &= ~VM_MAYEXEC;
82175 +#endif
82176 +
82177 + }
82178 +#endif
82179 +
82180 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
82181 if (error & ~PAGE_MASK)
82182 return error;
82183
82184 + charged = len >> PAGE_SHIFT;
82185 +
82186 /*
82187 * mlock MCL_FUTURE?
82188 */
82189 if (mm->def_flags & VM_LOCKED) {
82190 unsigned long locked, lock_limit;
82191 - locked = len >> PAGE_SHIFT;
82192 + locked = charged;
82193 locked += mm->locked_vm;
82194 lock_limit = rlimit(RLIMIT_MEMLOCK);
82195 lock_limit >>= PAGE_SHIFT;
82196 @@ -2573,21 +3023,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82197 /*
82198 * Clear old maps. this also does some error checking for us
82199 */
82200 - munmap_back:
82201 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82202 if (do_munmap(mm, addr, len))
82203 return -ENOMEM;
82204 - goto munmap_back;
82205 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82206 }
82207
82208 /* Check against address space limits *after* clearing old maps... */
82209 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82210 + if (!may_expand_vm(mm, charged))
82211 return -ENOMEM;
82212
82213 if (mm->map_count > sysctl_max_map_count)
82214 return -ENOMEM;
82215
82216 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
82217 + if (security_vm_enough_memory_mm(mm, charged))
82218 return -ENOMEM;
82219
82220 /* Can we just expand an old private anonymous mapping? */
82221 @@ -2601,7 +3050,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82222 */
82223 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82224 if (!vma) {
82225 - vm_unacct_memory(len >> PAGE_SHIFT);
82226 + vm_unacct_memory(charged);
82227 return -ENOMEM;
82228 }
82229
82230 @@ -2615,11 +3064,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82231 vma_link(mm, vma, prev, rb_link, rb_parent);
82232 out:
82233 perf_event_mmap(vma);
82234 - mm->total_vm += len >> PAGE_SHIFT;
82235 + mm->total_vm += charged;
82236 if (flags & VM_LOCKED) {
82237 if (!mlock_vma_pages_range(vma, addr, addr + len))
82238 - mm->locked_vm += (len >> PAGE_SHIFT);
82239 + mm->locked_vm += charged;
82240 }
82241 + track_exec_limit(mm, addr, addr + len, flags);
82242 return addr;
82243 }
82244
82245 @@ -2677,6 +3127,7 @@ void exit_mmap(struct mm_struct *mm)
82246 while (vma) {
82247 if (vma->vm_flags & VM_ACCOUNT)
82248 nr_accounted += vma_pages(vma);
82249 + vma->vm_mirror = NULL;
82250 vma = remove_vma(vma);
82251 }
82252 vm_unacct_memory(nr_accounted);
82253 @@ -2693,6 +3144,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82254 struct vm_area_struct *prev;
82255 struct rb_node **rb_link, *rb_parent;
82256
82257 +#ifdef CONFIG_PAX_SEGMEXEC
82258 + struct vm_area_struct *vma_m = NULL;
82259 +#endif
82260 +
82261 + if (security_mmap_addr(vma->vm_start))
82262 + return -EPERM;
82263 +
82264 /*
82265 * The vm_pgoff of a purely anonymous vma should be irrelevant
82266 * until its first write fault, when page's anon_vma and index
82267 @@ -2716,7 +3174,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
82268 security_vm_enough_memory_mm(mm, vma_pages(vma)))
82269 return -ENOMEM;
82270
82271 +#ifdef CONFIG_PAX_SEGMEXEC
82272 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
82273 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82274 + if (!vma_m)
82275 + return -ENOMEM;
82276 + }
82277 +#endif
82278 +
82279 vma_link(mm, vma, prev, rb_link, rb_parent);
82280 +
82281 +#ifdef CONFIG_PAX_SEGMEXEC
82282 + if (vma_m)
82283 + BUG_ON(pax_mirror_vma(vma_m, vma));
82284 +#endif
82285 +
82286 return 0;
82287 }
82288
82289 @@ -2736,6 +3208,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82290 struct mempolicy *pol;
82291 bool faulted_in_anon_vma = true;
82292
82293 + BUG_ON(vma->vm_mirror);
82294 +
82295 /*
82296 * If anonymous vma has not yet been faulted, update new pgoff
82297 * to match new location, to increase its chance of merging.
82298 @@ -2802,6 +3276,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
82299 return NULL;
82300 }
82301
82302 +#ifdef CONFIG_PAX_SEGMEXEC
82303 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
82304 +{
82305 + struct vm_area_struct *prev_m;
82306 + struct rb_node **rb_link_m, *rb_parent_m;
82307 + struct mempolicy *pol_m;
82308 +
82309 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
82310 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
82311 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
82312 + *vma_m = *vma;
82313 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
82314 + if (anon_vma_clone(vma_m, vma))
82315 + return -ENOMEM;
82316 + pol_m = vma_policy(vma_m);
82317 + mpol_get(pol_m);
82318 + vma_set_policy(vma_m, pol_m);
82319 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
82320 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
82321 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
82322 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
82323 + if (vma_m->vm_file)
82324 + get_file(vma_m->vm_file);
82325 + if (vma_m->vm_ops && vma_m->vm_ops->open)
82326 + vma_m->vm_ops->open(vma_m);
82327 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
82328 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
82329 + vma_m->vm_mirror = vma;
82330 + vma->vm_mirror = vma_m;
82331 + return 0;
82332 +}
82333 +#endif
82334 +
82335 /*
82336 * Return true if the calling process may expand its vm space by the passed
82337 * number of pages
82338 @@ -2813,6 +3320,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
82339
82340 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
82341
82342 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
82343 if (cur + npages > lim)
82344 return 0;
82345 return 1;
82346 @@ -2883,6 +3391,22 @@ int install_special_mapping(struct mm_struct *mm,
82347 vma->vm_start = addr;
82348 vma->vm_end = addr + len;
82349
82350 +#ifdef CONFIG_PAX_MPROTECT
82351 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82352 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82353 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
82354 + return -EPERM;
82355 + if (!(vm_flags & VM_EXEC))
82356 + vm_flags &= ~VM_MAYEXEC;
82357 +#else
82358 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82359 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82360 +#endif
82361 + else
82362 + vm_flags &= ~VM_MAYWRITE;
82363 + }
82364 +#endif
82365 +
82366 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
82367 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82368
82369 diff --git a/mm/mprotect.c b/mm/mprotect.c
82370 index 94722a4..9837984 100644
82371 --- a/mm/mprotect.c
82372 +++ b/mm/mprotect.c
82373 @@ -23,10 +23,17 @@
82374 #include <linux/mmu_notifier.h>
82375 #include <linux/migrate.h>
82376 #include <linux/perf_event.h>
82377 +
82378 +#ifdef CONFIG_PAX_MPROTECT
82379 +#include <linux/elf.h>
82380 +#include <linux/binfmts.h>
82381 +#endif
82382 +
82383 #include <asm/uaccess.h>
82384 #include <asm/pgtable.h>
82385 #include <asm/cacheflush.h>
82386 #include <asm/tlbflush.h>
82387 +#include <asm/mmu_context.h>
82388
82389 #ifndef pgprot_modify
82390 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
82391 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
82392 return pages;
82393 }
82394
82395 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82396 +/* called while holding the mmap semaphor for writing except stack expansion */
82397 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
82398 +{
82399 + unsigned long oldlimit, newlimit = 0UL;
82400 +
82401 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
82402 + return;
82403 +
82404 + spin_lock(&mm->page_table_lock);
82405 + oldlimit = mm->context.user_cs_limit;
82406 + if ((prot & VM_EXEC) && oldlimit < end)
82407 + /* USER_CS limit moved up */
82408 + newlimit = end;
82409 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
82410 + /* USER_CS limit moved down */
82411 + newlimit = start;
82412 +
82413 + if (newlimit) {
82414 + mm->context.user_cs_limit = newlimit;
82415 +
82416 +#ifdef CONFIG_SMP
82417 + wmb();
82418 + cpus_clear(mm->context.cpu_user_cs_mask);
82419 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
82420 +#endif
82421 +
82422 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
82423 + }
82424 + spin_unlock(&mm->page_table_lock);
82425 + if (newlimit == end) {
82426 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
82427 +
82428 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
82429 + if (is_vm_hugetlb_page(vma))
82430 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
82431 + else
82432 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
82433 + }
82434 +}
82435 +#endif
82436 +
82437 int
82438 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82439 unsigned long start, unsigned long end, unsigned long newflags)
82440 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82441 int error;
82442 int dirty_accountable = 0;
82443
82444 +#ifdef CONFIG_PAX_SEGMEXEC
82445 + struct vm_area_struct *vma_m = NULL;
82446 + unsigned long start_m, end_m;
82447 +
82448 + start_m = start + SEGMEXEC_TASK_SIZE;
82449 + end_m = end + SEGMEXEC_TASK_SIZE;
82450 +#endif
82451 +
82452 if (newflags == oldflags) {
82453 *pprev = vma;
82454 return 0;
82455 }
82456
82457 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
82458 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
82459 +
82460 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
82461 + return -ENOMEM;
82462 +
82463 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
82464 + return -ENOMEM;
82465 + }
82466 +
82467 /*
82468 * If we make a private mapping writable we increase our commit;
82469 * but (without finer accounting) cannot reduce our commit if we
82470 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82471 }
82472 }
82473
82474 +#ifdef CONFIG_PAX_SEGMEXEC
82475 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
82476 + if (start != vma->vm_start) {
82477 + error = split_vma(mm, vma, start, 1);
82478 + if (error)
82479 + goto fail;
82480 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
82481 + *pprev = (*pprev)->vm_next;
82482 + }
82483 +
82484 + if (end != vma->vm_end) {
82485 + error = split_vma(mm, vma, end, 0);
82486 + if (error)
82487 + goto fail;
82488 + }
82489 +
82490 + if (pax_find_mirror_vma(vma)) {
82491 + error = __do_munmap(mm, start_m, end_m - start_m);
82492 + if (error)
82493 + goto fail;
82494 + } else {
82495 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82496 + if (!vma_m) {
82497 + error = -ENOMEM;
82498 + goto fail;
82499 + }
82500 + vma->vm_flags = newflags;
82501 + error = pax_mirror_vma(vma_m, vma);
82502 + if (error) {
82503 + vma->vm_flags = oldflags;
82504 + goto fail;
82505 + }
82506 + }
82507 + }
82508 +#endif
82509 +
82510 /*
82511 * First try to merge with previous and/or next vma.
82512 */
82513 @@ -296,9 +399,21 @@ success:
82514 * vm_flags and vm_page_prot are protected by the mmap_sem
82515 * held in write mode.
82516 */
82517 +
82518 +#ifdef CONFIG_PAX_SEGMEXEC
82519 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
82520 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
82521 +#endif
82522 +
82523 vma->vm_flags = newflags;
82524 +
82525 +#ifdef CONFIG_PAX_MPROTECT
82526 + if (mm->binfmt && mm->binfmt->handle_mprotect)
82527 + mm->binfmt->handle_mprotect(vma, newflags);
82528 +#endif
82529 +
82530 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
82531 - vm_get_page_prot(newflags));
82532 + vm_get_page_prot(vma->vm_flags));
82533
82534 if (vma_wants_writenotify(vma)) {
82535 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
82536 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82537 end = start + len;
82538 if (end <= start)
82539 return -ENOMEM;
82540 +
82541 +#ifdef CONFIG_PAX_SEGMEXEC
82542 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
82543 + if (end > SEGMEXEC_TASK_SIZE)
82544 + return -EINVAL;
82545 + } else
82546 +#endif
82547 +
82548 + if (end > TASK_SIZE)
82549 + return -EINVAL;
82550 +
82551 if (!arch_validate_prot(prot))
82552 return -EINVAL;
82553
82554 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82555 /*
82556 * Does the application expect PROT_READ to imply PROT_EXEC:
82557 */
82558 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82559 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82560 prot |= PROT_EXEC;
82561
82562 vm_flags = calc_vm_prot_bits(prot);
82563 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82564 if (start > vma->vm_start)
82565 prev = vma;
82566
82567 +#ifdef CONFIG_PAX_MPROTECT
82568 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
82569 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
82570 +#endif
82571 +
82572 for (nstart = start ; ; ) {
82573 unsigned long newflags;
82574
82575 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82576
82577 /* newflags >> 4 shift VM_MAY% in place of VM_% */
82578 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
82579 + if (prot & (PROT_WRITE | PROT_EXEC))
82580 + gr_log_rwxmprotect(vma->vm_file);
82581 +
82582 + error = -EACCES;
82583 + goto out;
82584 + }
82585 +
82586 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
82587 error = -EACCES;
82588 goto out;
82589 }
82590 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82591 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
82592 if (error)
82593 goto out;
82594 +
82595 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
82596 +
82597 nstart = tmp;
82598
82599 if (nstart < prev->vm_end)
82600 diff --git a/mm/mremap.c b/mm/mremap.c
82601 index e1031e1..1f2a0a1 100644
82602 --- a/mm/mremap.c
82603 +++ b/mm/mremap.c
82604 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
82605 continue;
82606 pte = ptep_get_and_clear(mm, old_addr, old_pte);
82607 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
82608 +
82609 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82610 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
82611 + pte = pte_exprotect(pte);
82612 +#endif
82613 +
82614 set_pte_at(mm, new_addr, new_pte, pte);
82615 }
82616
82617 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
82618 if (is_vm_hugetlb_page(vma))
82619 goto Einval;
82620
82621 +#ifdef CONFIG_PAX_SEGMEXEC
82622 + if (pax_find_mirror_vma(vma))
82623 + goto Einval;
82624 +#endif
82625 +
82626 /* We can't remap across vm area boundaries */
82627 if (old_len > vma->vm_end - addr)
82628 goto Efault;
82629 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
82630 unsigned long ret = -EINVAL;
82631 unsigned long charged = 0;
82632 unsigned long map_flags;
82633 + unsigned long pax_task_size = TASK_SIZE;
82634
82635 if (new_addr & ~PAGE_MASK)
82636 goto out;
82637
82638 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
82639 +#ifdef CONFIG_PAX_SEGMEXEC
82640 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
82641 + pax_task_size = SEGMEXEC_TASK_SIZE;
82642 +#endif
82643 +
82644 + pax_task_size -= PAGE_SIZE;
82645 +
82646 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
82647 goto out;
82648
82649 /* Check if the location we're moving into overlaps the
82650 * old location at all, and fail if it does.
82651 */
82652 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
82653 - goto out;
82654 -
82655 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
82656 + if (addr + old_len > new_addr && new_addr + new_len > addr)
82657 goto out;
82658
82659 ret = do_munmap(mm, new_addr, new_len);
82660 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82661 struct vm_area_struct *vma;
82662 unsigned long ret = -EINVAL;
82663 unsigned long charged = 0;
82664 + unsigned long pax_task_size = TASK_SIZE;
82665
82666 down_write(&current->mm->mmap_sem);
82667
82668 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82669 if (!new_len)
82670 goto out;
82671
82672 +#ifdef CONFIG_PAX_SEGMEXEC
82673 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
82674 + pax_task_size = SEGMEXEC_TASK_SIZE;
82675 +#endif
82676 +
82677 + pax_task_size -= PAGE_SIZE;
82678 +
82679 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
82680 + old_len > pax_task_size || addr > pax_task_size-old_len)
82681 + goto out;
82682 +
82683 if (flags & MREMAP_FIXED) {
82684 if (flags & MREMAP_MAYMOVE)
82685 ret = mremap_to(addr, old_len, new_addr, new_len);
82686 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82687 addr + new_len);
82688 }
82689 ret = addr;
82690 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
82691 goto out;
82692 }
82693 }
82694 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82695 goto out;
82696 }
82697
82698 + map_flags = vma->vm_flags;
82699 ret = move_vma(vma, addr, old_len, new_len, new_addr);
82700 + if (!(ret & ~PAGE_MASK)) {
82701 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
82702 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
82703 + }
82704 }
82705 out:
82706 if (ret & ~PAGE_MASK)
82707 diff --git a/mm/nommu.c b/mm/nommu.c
82708 index 79c3cac..4d357e0 100644
82709 --- a/mm/nommu.c
82710 +++ b/mm/nommu.c
82711 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
82712 int sysctl_overcommit_ratio = 50; /* default is 50% */
82713 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
82714 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
82715 -int heap_stack_gap = 0;
82716
82717 atomic_long_t mmap_pages_allocated;
82718
82719 @@ -839,15 +838,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
82720 EXPORT_SYMBOL(find_vma);
82721
82722 /*
82723 - * find a VMA
82724 - * - we don't extend stack VMAs under NOMMU conditions
82725 - */
82726 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
82727 -{
82728 - return find_vma(mm, addr);
82729 -}
82730 -
82731 -/*
82732 * expand a stack to a given address
82733 * - not supported under NOMMU conditions
82734 */
82735 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82736
82737 /* most fields are the same, copy all, and then fixup */
82738 *new = *vma;
82739 + INIT_LIST_HEAD(&new->anon_vma_chain);
82740 *region = *vma->vm_region;
82741 new->vm_region = region;
82742
82743 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
82744 index 0713bfb..b95bb87 100644
82745 --- a/mm/page-writeback.c
82746 +++ b/mm/page-writeback.c
82747 @@ -655,7 +655,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
82748 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
82749 * - the bdi dirty thresh drops quickly due to change of JBOD workload
82750 */
82751 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
82752 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
82753 unsigned long thresh,
82754 unsigned long bg_thresh,
82755 unsigned long dirty,
82756 @@ -1630,7 +1630,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
82757 }
82758 }
82759
82760 -static struct notifier_block __cpuinitdata ratelimit_nb = {
82761 +static struct notifier_block ratelimit_nb = {
82762 .notifier_call = ratelimit_handler,
82763 .next = NULL,
82764 };
82765 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
82766 index 6a83cd3..3ab04ef 100644
82767 --- a/mm/page_alloc.c
82768 +++ b/mm/page_alloc.c
82769 @@ -58,6 +58,7 @@
82770 #include <linux/prefetch.h>
82771 #include <linux/migrate.h>
82772 #include <linux/page-debug-flags.h>
82773 +#include <linux/random.h>
82774
82775 #include <asm/tlbflush.h>
82776 #include <asm/div64.h>
82777 @@ -338,7 +339,7 @@ out:
82778 * This usage means that zero-order pages may not be compound.
82779 */
82780
82781 -static void free_compound_page(struct page *page)
82782 +void free_compound_page(struct page *page)
82783 {
82784 __free_pages_ok(page, compound_order(page));
82785 }
82786 @@ -693,6 +694,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
82787 int i;
82788 int bad = 0;
82789
82790 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82791 + unsigned long index = 1UL << order;
82792 +#endif
82793 +
82794 trace_mm_page_free(page, order);
82795 kmemcheck_free_shadow(page, order);
82796
82797 @@ -708,6 +713,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
82798 debug_check_no_obj_freed(page_address(page),
82799 PAGE_SIZE << order);
82800 }
82801 +
82802 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82803 + for (; index; --index)
82804 + sanitize_highpage(page + index - 1);
82805 +#endif
82806 +
82807 arch_free_page(page, order);
82808 kernel_map_pages(page, 1 << order, 0);
82809
82810 @@ -730,6 +741,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
82811 local_irq_restore(flags);
82812 }
82813
82814 +#ifdef CONFIG_PAX_LATENT_ENTROPY
82815 +bool __meminitdata extra_latent_entropy;
82816 +
82817 +static int __init setup_pax_extra_latent_entropy(char *str)
82818 +{
82819 + extra_latent_entropy = true;
82820 + return 0;
82821 +}
82822 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
82823 +
82824 +volatile u64 latent_entropy;
82825 +#endif
82826 +
82827 /*
82828 * Read access to zone->managed_pages is safe because it's unsigned long,
82829 * but we still need to serialize writers. Currently all callers of
82830 @@ -752,6 +776,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
82831 set_page_count(p, 0);
82832 }
82833
82834 +#ifdef CONFIG_PAX_LATENT_ENTROPY
82835 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
82836 + u64 hash = 0;
82837 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
82838 + const u64 *data = lowmem_page_address(page);
82839 +
82840 + for (index = 0; index < end; index++)
82841 + hash ^= hash + data[index];
82842 + latent_entropy ^= hash;
82843 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
82844 + }
82845 +#endif
82846 +
82847 page_zone(page)->managed_pages += 1 << order;
82848 set_page_refcounted(page);
82849 __free_pages(page, order);
82850 @@ -861,8 +898,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
82851 arch_alloc_page(page, order);
82852 kernel_map_pages(page, 1 << order, 1);
82853
82854 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
82855 if (gfp_flags & __GFP_ZERO)
82856 prep_zero_page(page, order, gfp_flags);
82857 +#endif
82858
82859 if (order && (gfp_flags & __GFP_COMP))
82860 prep_compound_page(page, order);
82861 @@ -3752,7 +3791,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
82862 unsigned long pfn;
82863
82864 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
82865 +#ifdef CONFIG_X86_32
82866 + /* boot failures in VMware 8 on 32bit vanilla since
82867 + this change */
82868 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
82869 +#else
82870 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
82871 +#endif
82872 return 1;
82873 }
82874 return 0;
82875 diff --git a/mm/percpu.c b/mm/percpu.c
82876 index 8c8e08f..73a5cda 100644
82877 --- a/mm/percpu.c
82878 +++ b/mm/percpu.c
82879 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
82880 static unsigned int pcpu_high_unit_cpu __read_mostly;
82881
82882 /* the address of the first chunk which starts with the kernel static area */
82883 -void *pcpu_base_addr __read_mostly;
82884 +void *pcpu_base_addr __read_only;
82885 EXPORT_SYMBOL_GPL(pcpu_base_addr);
82886
82887 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
82888 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
82889 index fd26d04..0cea1b0 100644
82890 --- a/mm/process_vm_access.c
82891 +++ b/mm/process_vm_access.c
82892 @@ -13,6 +13,7 @@
82893 #include <linux/uio.h>
82894 #include <linux/sched.h>
82895 #include <linux/highmem.h>
82896 +#include <linux/security.h>
82897 #include <linux/ptrace.h>
82898 #include <linux/slab.h>
82899 #include <linux/syscalls.h>
82900 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
82901 size_t iov_l_curr_offset = 0;
82902 ssize_t iov_len;
82903
82904 + return -ENOSYS; // PaX: until properly audited
82905 +
82906 /*
82907 * Work out how many pages of struct pages we're going to need
82908 * when eventually calling get_user_pages
82909 */
82910 for (i = 0; i < riovcnt; i++) {
82911 iov_len = rvec[i].iov_len;
82912 - if (iov_len > 0) {
82913 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
82914 - + iov_len)
82915 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
82916 - / PAGE_SIZE + 1;
82917 - nr_pages = max(nr_pages, nr_pages_iov);
82918 - }
82919 + if (iov_len <= 0)
82920 + continue;
82921 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
82922 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
82923 + nr_pages = max(nr_pages, nr_pages_iov);
82924 }
82925
82926 if (nr_pages == 0)
82927 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
82928 goto free_proc_pages;
82929 }
82930
82931 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
82932 + rc = -EPERM;
82933 + goto put_task_struct;
82934 + }
82935 +
82936 mm = mm_access(task, PTRACE_MODE_ATTACH);
82937 if (!mm || IS_ERR(mm)) {
82938 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
82939 diff --git a/mm/rmap.c b/mm/rmap.c
82940 index 2c78f8c..9e9c624 100644
82941 --- a/mm/rmap.c
82942 +++ b/mm/rmap.c
82943 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82944 struct anon_vma *anon_vma = vma->anon_vma;
82945 struct anon_vma_chain *avc;
82946
82947 +#ifdef CONFIG_PAX_SEGMEXEC
82948 + struct anon_vma_chain *avc_m = NULL;
82949 +#endif
82950 +
82951 might_sleep();
82952 if (unlikely(!anon_vma)) {
82953 struct mm_struct *mm = vma->vm_mm;
82954 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82955 if (!avc)
82956 goto out_enomem;
82957
82958 +#ifdef CONFIG_PAX_SEGMEXEC
82959 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
82960 + if (!avc_m)
82961 + goto out_enomem_free_avc;
82962 +#endif
82963 +
82964 anon_vma = find_mergeable_anon_vma(vma);
82965 allocated = NULL;
82966 if (!anon_vma) {
82967 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82968 /* page_table_lock to protect against threads */
82969 spin_lock(&mm->page_table_lock);
82970 if (likely(!vma->anon_vma)) {
82971 +
82972 +#ifdef CONFIG_PAX_SEGMEXEC
82973 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
82974 +
82975 + if (vma_m) {
82976 + BUG_ON(vma_m->anon_vma);
82977 + vma_m->anon_vma = anon_vma;
82978 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
82979 + avc_m = NULL;
82980 + }
82981 +#endif
82982 +
82983 vma->anon_vma = anon_vma;
82984 anon_vma_chain_link(vma, avc, anon_vma);
82985 allocated = NULL;
82986 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82987
82988 if (unlikely(allocated))
82989 put_anon_vma(allocated);
82990 +
82991 +#ifdef CONFIG_PAX_SEGMEXEC
82992 + if (unlikely(avc_m))
82993 + anon_vma_chain_free(avc_m);
82994 +#endif
82995 +
82996 if (unlikely(avc))
82997 anon_vma_chain_free(avc);
82998 }
82999 return 0;
83000
83001 out_enomem_free_avc:
83002 +
83003 +#ifdef CONFIG_PAX_SEGMEXEC
83004 + if (avc_m)
83005 + anon_vma_chain_free(avc_m);
83006 +#endif
83007 +
83008 anon_vma_chain_free(avc);
83009 out_enomem:
83010 return -ENOMEM;
83011 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
83012 * Attach the anon_vmas from src to dst.
83013 * Returns 0 on success, -ENOMEM on failure.
83014 */
83015 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83016 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
83017 {
83018 struct anon_vma_chain *avc, *pavc;
83019 struct anon_vma *root = NULL;
83020 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83021 * the corresponding VMA in the parent process is attached to.
83022 * Returns 0 on success, non-zero on failure.
83023 */
83024 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
83025 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
83026 {
83027 struct anon_vma_chain *avc;
83028 struct anon_vma *anon_vma;
83029 diff --git a/mm/shmem.c b/mm/shmem.c
83030 index efd0b3a..994b702 100644
83031 --- a/mm/shmem.c
83032 +++ b/mm/shmem.c
83033 @@ -31,7 +31,7 @@
83034 #include <linux/export.h>
83035 #include <linux/swap.h>
83036
83037 -static struct vfsmount *shm_mnt;
83038 +struct vfsmount *shm_mnt;
83039
83040 #ifdef CONFIG_SHMEM
83041 /*
83042 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
83043 #define BOGO_DIRENT_SIZE 20
83044
83045 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
83046 -#define SHORT_SYMLINK_LEN 128
83047 +#define SHORT_SYMLINK_LEN 64
83048
83049 /*
83050 * shmem_fallocate and shmem_writepage communicate via inode->i_private
83051 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
83052 static int shmem_xattr_validate(const char *name)
83053 {
83054 struct { const char *prefix; size_t len; } arr[] = {
83055 +
83056 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83057 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
83058 +#endif
83059 +
83060 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
83061 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
83062 };
83063 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
83064 if (err)
83065 return err;
83066
83067 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83068 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
83069 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
83070 + return -EOPNOTSUPP;
83071 + if (size > 8)
83072 + return -EINVAL;
83073 + }
83074 +#endif
83075 +
83076 return simple_xattr_set(&info->xattrs, name, value, size, flags);
83077 }
83078
83079 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
83080 int err = -ENOMEM;
83081
83082 /* Round up to L1_CACHE_BYTES to resist false sharing */
83083 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
83084 - L1_CACHE_BYTES), GFP_KERNEL);
83085 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
83086 if (!sbinfo)
83087 return -ENOMEM;
83088
83089 diff --git a/mm/slab.c b/mm/slab.c
83090 index e7667a3..a48e73b 100644
83091 --- a/mm/slab.c
83092 +++ b/mm/slab.c
83093 @@ -306,7 +306,7 @@ struct kmem_list3 {
83094 * Need this for bootstrapping a per node allocator.
83095 */
83096 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
83097 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
83098 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
83099 #define CACHE_CACHE 0
83100 #define SIZE_AC MAX_NUMNODES
83101 #define SIZE_L3 (2 * MAX_NUMNODES)
83102 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
83103 if ((x)->max_freeable < i) \
83104 (x)->max_freeable = i; \
83105 } while (0)
83106 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
83107 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
83108 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
83109 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
83110 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
83111 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
83112 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
83113 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
83114 #else
83115 #define STATS_INC_ACTIVE(x) do { } while (0)
83116 #define STATS_DEC_ACTIVE(x) do { } while (0)
83117 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
83118 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
83119 */
83120 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
83121 - const struct slab *slab, void *obj)
83122 + const struct slab *slab, const void *obj)
83123 {
83124 u32 offset = (obj - slab->s_mem);
83125 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
83126 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
83127 struct cache_names {
83128 char *name;
83129 char *name_dma;
83130 + char *name_usercopy;
83131 };
83132
83133 static struct cache_names __initdata cache_names[] = {
83134 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
83135 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
83136 #include <linux/kmalloc_sizes.h>
83137 - {NULL,}
83138 + {NULL}
83139 #undef CACHE
83140 };
83141
83142 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
83143 if (unlikely(gfpflags & GFP_DMA))
83144 return csizep->cs_dmacachep;
83145 #endif
83146 +
83147 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83148 + if (unlikely(gfpflags & GFP_USERCOPY))
83149 + return csizep->cs_usercopycachep;
83150 +#endif
83151 +
83152 return csizep->cs_cachep;
83153 }
83154
83155 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
83156 return notifier_from_errno(err);
83157 }
83158
83159 -static struct notifier_block __cpuinitdata cpucache_notifier = {
83160 +static struct notifier_block cpucache_notifier = {
83161 &cpuup_callback, NULL, 0
83162 };
83163
83164 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
83165 */
83166
83167 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
83168 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
83169 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83170
83171 if (INDEX_AC != INDEX_L3)
83172 sizes[INDEX_L3].cs_cachep =
83173 create_kmalloc_cache(names[INDEX_L3].name,
83174 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
83175 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83176
83177 slab_early_init = 0;
83178
83179 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
83180 */
83181 if (!sizes->cs_cachep)
83182 sizes->cs_cachep = create_kmalloc_cache(names->name,
83183 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
83184 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83185
83186 #ifdef CONFIG_ZONE_DMA
83187 sizes->cs_dmacachep = create_kmalloc_cache(
83188 names->name_dma, sizes->cs_size,
83189 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
83190 #endif
83191 +
83192 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83193 + sizes->cs_usercopycachep = create_kmalloc_cache(
83194 + names->name_usercopy, sizes->cs_size,
83195 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83196 +#endif
83197 +
83198 sizes++;
83199 names++;
83200 }
83201 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
83202
83203 if (unlikely(ZERO_OR_NULL_PTR(objp)))
83204 return;
83205 + VM_BUG_ON(!virt_addr_valid(objp));
83206 local_irq_save(flags);
83207 kfree_debugcheck(objp);
83208 c = virt_to_cache(objp);
83209 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
83210 }
83211 /* cpu stats */
83212 {
83213 - unsigned long allochit = atomic_read(&cachep->allochit);
83214 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
83215 - unsigned long freehit = atomic_read(&cachep->freehit);
83216 - unsigned long freemiss = atomic_read(&cachep->freemiss);
83217 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
83218 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
83219 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
83220 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
83221
83222 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
83223 allochit, allocmiss, freehit, freemiss);
83224 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
83225 static int __init slab_proc_init(void)
83226 {
83227 #ifdef CONFIG_DEBUG_SLAB_LEAK
83228 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
83229 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
83230 #endif
83231 return 0;
83232 }
83233 module_init(slab_proc_init);
83234 #endif
83235
83236 +bool is_usercopy_object(const void *ptr)
83237 +{
83238 + struct page *page;
83239 + struct kmem_cache *cachep;
83240 +
83241 + if (ZERO_OR_NULL_PTR(ptr))
83242 + return false;
83243 +
83244 + if (!slab_is_available())
83245 + return false;
83246 +
83247 + if (!virt_addr_valid(ptr))
83248 + return false;
83249 +
83250 + page = virt_to_head_page(ptr);
83251 +
83252 + if (!PageSlab(page))
83253 + return false;
83254 +
83255 + cachep = page->slab_cache;
83256 + return cachep->flags & SLAB_USERCOPY;
83257 +}
83258 +
83259 +#ifdef CONFIG_PAX_USERCOPY
83260 +const char *check_heap_object(const void *ptr, unsigned long n)
83261 +{
83262 + struct page *page;
83263 + struct kmem_cache *cachep;
83264 + struct slab *slabp;
83265 + unsigned int objnr;
83266 + unsigned long offset;
83267 +
83268 + if (ZERO_OR_NULL_PTR(ptr))
83269 + return "<null>";
83270 +
83271 + if (!virt_addr_valid(ptr))
83272 + return NULL;
83273 +
83274 + page = virt_to_head_page(ptr);
83275 +
83276 + if (!PageSlab(page))
83277 + return NULL;
83278 +
83279 + cachep = page->slab_cache;
83280 + if (!(cachep->flags & SLAB_USERCOPY))
83281 + return cachep->name;
83282 +
83283 + slabp = page->slab_page;
83284 + objnr = obj_to_index(cachep, slabp, ptr);
83285 + BUG_ON(objnr >= cachep->num);
83286 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
83287 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
83288 + return NULL;
83289 +
83290 + return cachep->name;
83291 +}
83292 +#endif
83293 +
83294 /**
83295 * ksize - get the actual amount of memory allocated for a given object
83296 * @objp: Pointer to the object
83297 diff --git a/mm/slab.h b/mm/slab.h
83298 index 34a98d6..73633d1 100644
83299 --- a/mm/slab.h
83300 +++ b/mm/slab.h
83301 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83302
83303 /* Legal flag mask for kmem_cache_create(), for various configurations */
83304 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
83305 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
83306 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
83307
83308 #if defined(CONFIG_DEBUG_SLAB)
83309 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
83310 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
83311 return s;
83312
83313 page = virt_to_head_page(x);
83314 +
83315 + BUG_ON(!PageSlab(page));
83316 +
83317 cachep = page->slab_cache;
83318 if (slab_equal_or_root(cachep, s))
83319 return cachep;
83320 diff --git a/mm/slab_common.c b/mm/slab_common.c
83321 index 3f3cd97..93b0236 100644
83322 --- a/mm/slab_common.c
83323 +++ b/mm/slab_common.c
83324 @@ -22,7 +22,7 @@
83325
83326 #include "slab.h"
83327
83328 -enum slab_state slab_state;
83329 +enum slab_state slab_state __read_only;
83330 LIST_HEAD(slab_caches);
83331 DEFINE_MUTEX(slab_mutex);
83332 struct kmem_cache *kmem_cache;
83333 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
83334
83335 err = __kmem_cache_create(s, flags);
83336 if (!err) {
83337 - s->refcount = 1;
83338 + atomic_set(&s->refcount, 1);
83339 list_add(&s->list, &slab_caches);
83340 memcg_cache_list_add(memcg, s);
83341 } else {
83342 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
83343
83344 get_online_cpus();
83345 mutex_lock(&slab_mutex);
83346 - s->refcount--;
83347 - if (!s->refcount) {
83348 + if (atomic_dec_and_test(&s->refcount)) {
83349 list_del(&s->list);
83350
83351 if (!__kmem_cache_shutdown(s)) {
83352 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
83353 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
83354 name, size, err);
83355
83356 - s->refcount = -1; /* Exempt from merging for now */
83357 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
83358 }
83359
83360 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83361 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83362
83363 create_boot_cache(s, name, size, flags);
83364 list_add(&s->list, &slab_caches);
83365 - s->refcount = 1;
83366 + atomic_set(&s->refcount, 1);
83367 return s;
83368 }
83369
83370 diff --git a/mm/slob.c b/mm/slob.c
83371 index a99fdf7..6ee34ec 100644
83372 --- a/mm/slob.c
83373 +++ b/mm/slob.c
83374 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
83375 /*
83376 * Return the size of a slob block.
83377 */
83378 -static slobidx_t slob_units(slob_t *s)
83379 +static slobidx_t slob_units(const slob_t *s)
83380 {
83381 if (s->units > 0)
83382 return s->units;
83383 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
83384 /*
83385 * Return the next free slob block pointer after this one.
83386 */
83387 -static slob_t *slob_next(slob_t *s)
83388 +static slob_t *slob_next(const slob_t *s)
83389 {
83390 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
83391 slobidx_t next;
83392 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
83393 /*
83394 * Returns true if s is the last free block in its page.
83395 */
83396 -static int slob_last(slob_t *s)
83397 +static int slob_last(const slob_t *s)
83398 {
83399 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
83400 }
83401
83402 -static void *slob_new_pages(gfp_t gfp, int order, int node)
83403 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
83404 {
83405 - void *page;
83406 + struct page *page;
83407
83408 #ifdef CONFIG_NUMA
83409 if (node != NUMA_NO_NODE)
83410 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
83411 if (!page)
83412 return NULL;
83413
83414 - return page_address(page);
83415 + __SetPageSlab(page);
83416 + return page;
83417 }
83418
83419 -static void slob_free_pages(void *b, int order)
83420 +static void slob_free_pages(struct page *sp, int order)
83421 {
83422 if (current->reclaim_state)
83423 current->reclaim_state->reclaimed_slab += 1 << order;
83424 - free_pages((unsigned long)b, order);
83425 + __ClearPageSlab(sp);
83426 + reset_page_mapcount(sp);
83427 + sp->private = 0;
83428 + __free_pages(sp, order);
83429 }
83430
83431 /*
83432 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
83433
83434 /* Not enough space: must allocate a new page */
83435 if (!b) {
83436 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83437 - if (!b)
83438 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83439 + if (!sp)
83440 return NULL;
83441 - sp = virt_to_page(b);
83442 - __SetPageSlab(sp);
83443 + b = page_address(sp);
83444
83445 spin_lock_irqsave(&slob_lock, flags);
83446 sp->units = SLOB_UNITS(PAGE_SIZE);
83447 sp->freelist = b;
83448 + sp->private = 0;
83449 INIT_LIST_HEAD(&sp->list);
83450 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
83451 set_slob_page_free(sp, slob_list);
83452 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
83453 if (slob_page_free(sp))
83454 clear_slob_page_free(sp);
83455 spin_unlock_irqrestore(&slob_lock, flags);
83456 - __ClearPageSlab(sp);
83457 - reset_page_mapcount(sp);
83458 - slob_free_pages(b, 0);
83459 + slob_free_pages(sp, 0);
83460 return;
83461 }
83462
83463 @@ -424,11 +426,10 @@ out:
83464 */
83465
83466 static __always_inline void *
83467 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83468 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
83469 {
83470 - unsigned int *m;
83471 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83472 - void *ret;
83473 + slob_t *m;
83474 + void *ret = NULL;
83475
83476 gfp &= gfp_allowed_mask;
83477
83478 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83479
83480 if (!m)
83481 return NULL;
83482 - *m = size;
83483 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
83484 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
83485 + m[0].units = size;
83486 + m[1].units = align;
83487 ret = (void *)m + align;
83488
83489 trace_kmalloc_node(caller, ret,
83490 size, size + align, gfp, node);
83491 } else {
83492 unsigned int order = get_order(size);
83493 + struct page *page;
83494
83495 if (likely(order))
83496 gfp |= __GFP_COMP;
83497 - ret = slob_new_pages(gfp, order, node);
83498 + page = slob_new_pages(gfp, order, node);
83499 + if (page) {
83500 + ret = page_address(page);
83501 + page->private = size;
83502 + }
83503
83504 trace_kmalloc_node(caller, ret,
83505 size, PAGE_SIZE << order, gfp, node);
83506 }
83507
83508 - kmemleak_alloc(ret, size, 1, gfp);
83509 + return ret;
83510 +}
83511 +
83512 +static __always_inline void *
83513 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83514 +{
83515 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83516 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
83517 +
83518 + if (!ZERO_OR_NULL_PTR(ret))
83519 + kmemleak_alloc(ret, size, 1, gfp);
83520 return ret;
83521 }
83522
83523 @@ -493,34 +512,112 @@ void kfree(const void *block)
83524 return;
83525 kmemleak_free(block);
83526
83527 + VM_BUG_ON(!virt_addr_valid(block));
83528 sp = virt_to_page(block);
83529 - if (PageSlab(sp)) {
83530 + VM_BUG_ON(!PageSlab(sp));
83531 + if (!sp->private) {
83532 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83533 - unsigned int *m = (unsigned int *)(block - align);
83534 - slob_free(m, *m + align);
83535 - } else
83536 + slob_t *m = (slob_t *)(block - align);
83537 + slob_free(m, m[0].units + align);
83538 + } else {
83539 + __ClearPageSlab(sp);
83540 + reset_page_mapcount(sp);
83541 + sp->private = 0;
83542 __free_pages(sp, compound_order(sp));
83543 + }
83544 }
83545 EXPORT_SYMBOL(kfree);
83546
83547 +bool is_usercopy_object(const void *ptr)
83548 +{
83549 + if (!slab_is_available())
83550 + return false;
83551 +
83552 + // PAX: TODO
83553 +
83554 + return false;
83555 +}
83556 +
83557 +#ifdef CONFIG_PAX_USERCOPY
83558 +const char *check_heap_object(const void *ptr, unsigned long n)
83559 +{
83560 + struct page *page;
83561 + const slob_t *free;
83562 + const void *base;
83563 + unsigned long flags;
83564 +
83565 + if (ZERO_OR_NULL_PTR(ptr))
83566 + return "<null>";
83567 +
83568 + if (!virt_addr_valid(ptr))
83569 + return NULL;
83570 +
83571 + page = virt_to_head_page(ptr);
83572 + if (!PageSlab(page))
83573 + return NULL;
83574 +
83575 + if (page->private) {
83576 + base = page;
83577 + if (base <= ptr && n <= page->private - (ptr - base))
83578 + return NULL;
83579 + return "<slob>";
83580 + }
83581 +
83582 + /* some tricky double walking to find the chunk */
83583 + spin_lock_irqsave(&slob_lock, flags);
83584 + base = (void *)((unsigned long)ptr & PAGE_MASK);
83585 + free = page->freelist;
83586 +
83587 + while (!slob_last(free) && (void *)free <= ptr) {
83588 + base = free + slob_units(free);
83589 + free = slob_next(free);
83590 + }
83591 +
83592 + while (base < (void *)free) {
83593 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
83594 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
83595 + int offset;
83596 +
83597 + if (ptr < base + align)
83598 + break;
83599 +
83600 + offset = ptr - base - align;
83601 + if (offset >= m) {
83602 + base += size;
83603 + continue;
83604 + }
83605 +
83606 + if (n > m - offset)
83607 + break;
83608 +
83609 + spin_unlock_irqrestore(&slob_lock, flags);
83610 + return NULL;
83611 + }
83612 +
83613 + spin_unlock_irqrestore(&slob_lock, flags);
83614 + return "<slob>";
83615 +}
83616 +#endif
83617 +
83618 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
83619 size_t ksize(const void *block)
83620 {
83621 struct page *sp;
83622 int align;
83623 - unsigned int *m;
83624 + slob_t *m;
83625
83626 BUG_ON(!block);
83627 if (unlikely(block == ZERO_SIZE_PTR))
83628 return 0;
83629
83630 sp = virt_to_page(block);
83631 - if (unlikely(!PageSlab(sp)))
83632 - return PAGE_SIZE << compound_order(sp);
83633 + VM_BUG_ON(!PageSlab(sp));
83634 + if (sp->private)
83635 + return sp->private;
83636
83637 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83638 - m = (unsigned int *)(block - align);
83639 - return SLOB_UNITS(*m) * SLOB_UNIT;
83640 + m = (slob_t *)(block - align);
83641 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
83642 }
83643 EXPORT_SYMBOL(ksize);
83644
83645 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
83646
83647 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
83648 {
83649 - void *b;
83650 + void *b = NULL;
83651
83652 flags &= gfp_allowed_mask;
83653
83654 lockdep_trace_alloc(flags);
83655
83656 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83657 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
83658 +#else
83659 if (c->size < PAGE_SIZE) {
83660 b = slob_alloc(c->size, flags, c->align, node);
83661 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
83662 SLOB_UNITS(c->size) * SLOB_UNIT,
83663 flags, node);
83664 } else {
83665 - b = slob_new_pages(flags, get_order(c->size), node);
83666 + struct page *sp;
83667 +
83668 + sp = slob_new_pages(flags, get_order(c->size), node);
83669 + if (sp) {
83670 + b = page_address(sp);
83671 + sp->private = c->size;
83672 + }
83673 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
83674 PAGE_SIZE << get_order(c->size),
83675 flags, node);
83676 }
83677 +#endif
83678
83679 if (c->ctor)
83680 c->ctor(b);
83681 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
83682
83683 static void __kmem_cache_free(void *b, int size)
83684 {
83685 - if (size < PAGE_SIZE)
83686 + struct page *sp;
83687 +
83688 + sp = virt_to_page(b);
83689 + BUG_ON(!PageSlab(sp));
83690 + if (!sp->private)
83691 slob_free(b, size);
83692 else
83693 - slob_free_pages(b, get_order(size));
83694 + slob_free_pages(sp, get_order(size));
83695 }
83696
83697 static void kmem_rcu_free(struct rcu_head *head)
83698 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
83699
83700 void kmem_cache_free(struct kmem_cache *c, void *b)
83701 {
83702 + int size = c->size;
83703 +
83704 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83705 + if (size + c->align < PAGE_SIZE) {
83706 + size += c->align;
83707 + b -= c->align;
83708 + }
83709 +#endif
83710 +
83711 kmemleak_free_recursive(b, c->flags);
83712 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
83713 struct slob_rcu *slob_rcu;
83714 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
83715 - slob_rcu->size = c->size;
83716 + slob_rcu = b + (size - sizeof(struct slob_rcu));
83717 + slob_rcu->size = size;
83718 call_rcu(&slob_rcu->head, kmem_rcu_free);
83719 } else {
83720 - __kmem_cache_free(b, c->size);
83721 + __kmem_cache_free(b, size);
83722 }
83723
83724 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83725 + trace_kfree(_RET_IP_, b);
83726 +#else
83727 trace_kmem_cache_free(_RET_IP_, b);
83728 +#endif
83729 +
83730 }
83731 EXPORT_SYMBOL(kmem_cache_free);
83732
83733 diff --git a/mm/slub.c b/mm/slub.c
83734 index ba2ca53..991c4f7 100644
83735 --- a/mm/slub.c
83736 +++ b/mm/slub.c
83737 @@ -197,7 +197,7 @@ struct track {
83738
83739 enum track_item { TRACK_ALLOC, TRACK_FREE };
83740
83741 -#ifdef CONFIG_SYSFS
83742 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83743 static int sysfs_slab_add(struct kmem_cache *);
83744 static int sysfs_slab_alias(struct kmem_cache *, const char *);
83745 static void sysfs_slab_remove(struct kmem_cache *);
83746 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
83747 if (!t->addr)
83748 return;
83749
83750 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
83751 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
83752 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
83753 #ifdef CONFIG_STACKTRACE
83754 {
83755 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
83756 * Merge control. If this is set then no merging of slab caches will occur.
83757 * (Could be removed. This was introduced to pacify the merge skeptics.)
83758 */
83759 -static int slub_nomerge;
83760 +static int slub_nomerge = 1;
83761
83762 /*
83763 * Calculate the order of allocation given an slab object size.
83764 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
83765 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
83766 #endif
83767
83768 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83769 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
83770 +#endif
83771 +
83772 static int __init setup_slub_min_order(char *str)
83773 {
83774 get_option(&str, &slub_min_order);
83775 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
83776 return kmalloc_dma_caches[index];
83777
83778 #endif
83779 +
83780 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83781 + if (flags & SLAB_USERCOPY)
83782 + return kmalloc_usercopy_caches[index];
83783 +
83784 +#endif
83785 +
83786 return kmalloc_caches[index];
83787 }
83788
83789 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
83790 EXPORT_SYMBOL(__kmalloc_node);
83791 #endif
83792
83793 +bool is_usercopy_object(const void *ptr)
83794 +{
83795 + struct page *page;
83796 + struct kmem_cache *s;
83797 +
83798 + if (ZERO_OR_NULL_PTR(ptr))
83799 + return false;
83800 +
83801 + if (!slab_is_available())
83802 + return false;
83803 +
83804 + if (!virt_addr_valid(ptr))
83805 + return false;
83806 +
83807 + page = virt_to_head_page(ptr);
83808 +
83809 + if (!PageSlab(page))
83810 + return false;
83811 +
83812 + s = page->slab_cache;
83813 + return s->flags & SLAB_USERCOPY;
83814 +}
83815 +
83816 +#ifdef CONFIG_PAX_USERCOPY
83817 +const char *check_heap_object(const void *ptr, unsigned long n)
83818 +{
83819 + struct page *page;
83820 + struct kmem_cache *s;
83821 + unsigned long offset;
83822 +
83823 + if (ZERO_OR_NULL_PTR(ptr))
83824 + return "<null>";
83825 +
83826 + if (!virt_addr_valid(ptr))
83827 + return NULL;
83828 +
83829 + page = virt_to_head_page(ptr);
83830 +
83831 + if (!PageSlab(page))
83832 + return NULL;
83833 +
83834 + s = page->slab_cache;
83835 + if (!(s->flags & SLAB_USERCOPY))
83836 + return s->name;
83837 +
83838 + offset = (ptr - page_address(page)) % s->size;
83839 + if (offset <= s->object_size && n <= s->object_size - offset)
83840 + return NULL;
83841 +
83842 + return s->name;
83843 +}
83844 +#endif
83845 +
83846 size_t ksize(const void *object)
83847 {
83848 struct page *page;
83849 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
83850 if (unlikely(ZERO_OR_NULL_PTR(x)))
83851 return;
83852
83853 + VM_BUG_ON(!virt_addr_valid(x));
83854 page = virt_to_head_page(x);
83855 if (unlikely(!PageSlab(page))) {
83856 BUG_ON(!PageCompound(page));
83857 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
83858
83859 /* Caches that are not of the two-to-the-power-of size */
83860 if (KMALLOC_MIN_SIZE <= 32) {
83861 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
83862 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
83863 caches++;
83864 }
83865
83866 if (KMALLOC_MIN_SIZE <= 64) {
83867 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
83868 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
83869 caches++;
83870 }
83871
83872 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
83873 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
83874 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
83875 caches++;
83876 }
83877
83878 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
83879 }
83880 }
83881 #endif
83882 +
83883 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83884 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
83885 + struct kmem_cache *s = kmalloc_caches[i];
83886 +
83887 + if (s && s->size) {
83888 + char *name = kasprintf(GFP_NOWAIT,
83889 + "usercopy-kmalloc-%d", s->object_size);
83890 +
83891 + BUG_ON(!name);
83892 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
83893 + s->object_size, SLAB_USERCOPY);
83894 + }
83895 + }
83896 +#endif
83897 +
83898 printk(KERN_INFO
83899 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
83900 " CPUs=%d, Nodes=%d\n",
83901 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
83902 /*
83903 * We may have set a slab to be unmergeable during bootstrap.
83904 */
83905 - if (s->refcount < 0)
83906 + if (atomic_read(&s->refcount) < 0)
83907 return 1;
83908
83909 return 0;
83910 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83911
83912 s = find_mergeable(memcg, size, align, flags, name, ctor);
83913 if (s) {
83914 - s->refcount++;
83915 + atomic_inc(&s->refcount);
83916 /*
83917 * Adjust the object sizes so that we clear
83918 * the complete object on kzalloc.
83919 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83920 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
83921
83922 if (sysfs_slab_alias(s, name)) {
83923 - s->refcount--;
83924 + atomic_dec(&s->refcount);
83925 s = NULL;
83926 }
83927 }
83928 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
83929 return NOTIFY_OK;
83930 }
83931
83932 -static struct notifier_block __cpuinitdata slab_notifier = {
83933 +static struct notifier_block slab_notifier = {
83934 .notifier_call = slab_cpuup_callback
83935 };
83936
83937 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
83938 }
83939 #endif
83940
83941 -#ifdef CONFIG_SYSFS
83942 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83943 static int count_inuse(struct page *page)
83944 {
83945 return page->inuse;
83946 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
83947 validate_slab_cache(kmalloc_caches[9]);
83948 }
83949 #else
83950 -#ifdef CONFIG_SYSFS
83951 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83952 static void resiliency_test(void) {};
83953 #endif
83954 #endif
83955
83956 -#ifdef CONFIG_SYSFS
83957 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83958 enum slab_stat_type {
83959 SL_ALL, /* All slabs */
83960 SL_PARTIAL, /* Only partially allocated slabs */
83961 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
83962
83963 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
83964 {
83965 - return sprintf(buf, "%d\n", s->refcount - 1);
83966 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
83967 }
83968 SLAB_ATTR_RO(aliases);
83969
83970 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
83971 return name;
83972 }
83973
83974 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83975 static int sysfs_slab_add(struct kmem_cache *s)
83976 {
83977 int err;
83978 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
83979 kobject_del(&s->kobj);
83980 kobject_put(&s->kobj);
83981 }
83982 +#endif
83983
83984 /*
83985 * Need to buffer aliases during bootup until sysfs becomes
83986 @@ -5336,6 +5419,7 @@ struct saved_alias {
83987
83988 static struct saved_alias *alias_list;
83989
83990 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83991 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
83992 {
83993 struct saved_alias *al;
83994 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
83995 alias_list = al;
83996 return 0;
83997 }
83998 +#endif
83999
84000 static int __init slab_sysfs_init(void)
84001 {
84002 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
84003 index 1b7e22a..3fcd4f3 100644
84004 --- a/mm/sparse-vmemmap.c
84005 +++ b/mm/sparse-vmemmap.c
84006 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
84007 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84008 if (!p)
84009 return NULL;
84010 - pud_populate(&init_mm, pud, p);
84011 + pud_populate_kernel(&init_mm, pud, p);
84012 }
84013 return pud;
84014 }
84015 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
84016 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84017 if (!p)
84018 return NULL;
84019 - pgd_populate(&init_mm, pgd, p);
84020 + pgd_populate_kernel(&init_mm, pgd, p);
84021 }
84022 return pgd;
84023 }
84024 diff --git a/mm/sparse.c b/mm/sparse.c
84025 index 6b5fb76..db0c190 100644
84026 --- a/mm/sparse.c
84027 +++ b/mm/sparse.c
84028 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
84029
84030 for (i = 0; i < PAGES_PER_SECTION; i++) {
84031 if (PageHWPoison(&memmap[i])) {
84032 - atomic_long_sub(1, &mce_bad_pages);
84033 + atomic_long_sub_unchecked(1, &mce_bad_pages);
84034 ClearPageHWPoison(&memmap[i]);
84035 }
84036 }
84037 diff --git a/mm/swap.c b/mm/swap.c
84038 index 6310dc2..3662b3f 100644
84039 --- a/mm/swap.c
84040 +++ b/mm/swap.c
84041 @@ -30,6 +30,7 @@
84042 #include <linux/backing-dev.h>
84043 #include <linux/memcontrol.h>
84044 #include <linux/gfp.h>
84045 +#include <linux/hugetlb.h>
84046
84047 #include "internal.h"
84048
84049 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
84050
84051 __page_cache_release(page);
84052 dtor = get_compound_page_dtor(page);
84053 + if (!PageHuge(page))
84054 + BUG_ON(dtor != free_compound_page);
84055 (*dtor)(page);
84056 }
84057
84058 diff --git a/mm/swapfile.c b/mm/swapfile.c
84059 index e97a0e5..b50e796 100644
84060 --- a/mm/swapfile.c
84061 +++ b/mm/swapfile.c
84062 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
84063
84064 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
84065 /* Activity counter to indicate that a swapon or swapoff has occurred */
84066 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
84067 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
84068
84069 static inline unsigned char swap_count(unsigned char ent)
84070 {
84071 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
84072 }
84073 filp_close(swap_file, NULL);
84074 err = 0;
84075 - atomic_inc(&proc_poll_event);
84076 + atomic_inc_unchecked(&proc_poll_event);
84077 wake_up_interruptible(&proc_poll_wait);
84078
84079 out_dput:
84080 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
84081
84082 poll_wait(file, &proc_poll_wait, wait);
84083
84084 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
84085 - seq->poll_event = atomic_read(&proc_poll_event);
84086 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
84087 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84088 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
84089 }
84090
84091 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
84092 return ret;
84093
84094 seq = file->private_data;
84095 - seq->poll_event = atomic_read(&proc_poll_event);
84096 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84097 return 0;
84098 }
84099
84100 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
84101 (frontswap_map) ? "FS" : "");
84102
84103 mutex_unlock(&swapon_mutex);
84104 - atomic_inc(&proc_poll_event);
84105 + atomic_inc_unchecked(&proc_poll_event);
84106 wake_up_interruptible(&proc_poll_wait);
84107
84108 if (S_ISREG(inode->i_mode))
84109 diff --git a/mm/util.c b/mm/util.c
84110 index c55e26b..3f913a9 100644
84111 --- a/mm/util.c
84112 +++ b/mm/util.c
84113 @@ -292,6 +292,12 @@ done:
84114 void arch_pick_mmap_layout(struct mm_struct *mm)
84115 {
84116 mm->mmap_base = TASK_UNMAPPED_BASE;
84117 +
84118 +#ifdef CONFIG_PAX_RANDMMAP
84119 + if (mm->pax_flags & MF_PAX_RANDMMAP)
84120 + mm->mmap_base += mm->delta_mmap;
84121 +#endif
84122 +
84123 mm->get_unmapped_area = arch_get_unmapped_area;
84124 mm->unmap_area = arch_unmap_area;
84125 }
84126 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
84127 index 5123a16..f234a48 100644
84128 --- a/mm/vmalloc.c
84129 +++ b/mm/vmalloc.c
84130 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
84131
84132 pte = pte_offset_kernel(pmd, addr);
84133 do {
84134 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84135 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84136 +
84137 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84138 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
84139 + BUG_ON(!pte_exec(*pte));
84140 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
84141 + continue;
84142 + }
84143 +#endif
84144 +
84145 + {
84146 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84147 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84148 + }
84149 } while (pte++, addr += PAGE_SIZE, addr != end);
84150 }
84151
84152 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
84153 pte = pte_alloc_kernel(pmd, addr);
84154 if (!pte)
84155 return -ENOMEM;
84156 +
84157 + pax_open_kernel();
84158 do {
84159 struct page *page = pages[*nr];
84160
84161 - if (WARN_ON(!pte_none(*pte)))
84162 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84163 + if (pgprot_val(prot) & _PAGE_NX)
84164 +#endif
84165 +
84166 + if (!pte_none(*pte)) {
84167 + pax_close_kernel();
84168 + WARN_ON(1);
84169 return -EBUSY;
84170 - if (WARN_ON(!page))
84171 + }
84172 + if (!page) {
84173 + pax_close_kernel();
84174 + WARN_ON(1);
84175 return -ENOMEM;
84176 + }
84177 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
84178 (*nr)++;
84179 } while (pte++, addr += PAGE_SIZE, addr != end);
84180 + pax_close_kernel();
84181 return 0;
84182 }
84183
84184 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
84185 pmd_t *pmd;
84186 unsigned long next;
84187
84188 - pmd = pmd_alloc(&init_mm, pud, addr);
84189 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
84190 if (!pmd)
84191 return -ENOMEM;
84192 do {
84193 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
84194 pud_t *pud;
84195 unsigned long next;
84196
84197 - pud = pud_alloc(&init_mm, pgd, addr);
84198 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
84199 if (!pud)
84200 return -ENOMEM;
84201 do {
84202 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
84203 * and fall back on vmalloc() if that fails. Others
84204 * just put it in the vmalloc space.
84205 */
84206 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
84207 +#ifdef CONFIG_MODULES
84208 +#ifdef MODULES_VADDR
84209 unsigned long addr = (unsigned long)x;
84210 if (addr >= MODULES_VADDR && addr < MODULES_END)
84211 return 1;
84212 #endif
84213 +
84214 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84215 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
84216 + return 1;
84217 +#endif
84218 +
84219 +#endif
84220 +
84221 return is_vmalloc_addr(x);
84222 }
84223
84224 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
84225
84226 if (!pgd_none(*pgd)) {
84227 pud_t *pud = pud_offset(pgd, addr);
84228 +#ifdef CONFIG_X86
84229 + if (!pud_large(*pud))
84230 +#endif
84231 if (!pud_none(*pud)) {
84232 pmd_t *pmd = pmd_offset(pud, addr);
84233 +#ifdef CONFIG_X86
84234 + if (!pmd_large(*pmd))
84235 +#endif
84236 if (!pmd_none(*pmd)) {
84237 pte_t *ptep, pte;
84238
84239 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
84240 * Allocate a region of KVA of the specified size and alignment, within the
84241 * vstart and vend.
84242 */
84243 -static struct vmap_area *alloc_vmap_area(unsigned long size,
84244 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
84245 unsigned long align,
84246 unsigned long vstart, unsigned long vend,
84247 int node, gfp_t gfp_mask)
84248 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
84249 struct vm_struct *area;
84250
84251 BUG_ON(in_interrupt());
84252 +
84253 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84254 + if (flags & VM_KERNEXEC) {
84255 + if (start != VMALLOC_START || end != VMALLOC_END)
84256 + return NULL;
84257 + start = (unsigned long)MODULES_EXEC_VADDR;
84258 + end = (unsigned long)MODULES_EXEC_END;
84259 + }
84260 +#endif
84261 +
84262 if (flags & VM_IOREMAP) {
84263 int bit = fls(size);
84264
84265 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
84266 if (count > totalram_pages)
84267 return NULL;
84268
84269 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84270 + if (!(pgprot_val(prot) & _PAGE_NX))
84271 + flags |= VM_KERNEXEC;
84272 +#endif
84273 +
84274 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
84275 __builtin_return_address(0));
84276 if (!area)
84277 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
84278 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
84279 goto fail;
84280
84281 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
84282 + if (!(pgprot_val(prot) & _PAGE_NX))
84283 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
84284 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
84285 + else
84286 +#endif
84287 +
84288 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
84289 start, end, node, gfp_mask, caller);
84290 if (!area)
84291 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
84292 * For tight control over page level allocator and protection flags
84293 * use __vmalloc() instead.
84294 */
84295 -
84296 void *vmalloc_exec(unsigned long size)
84297 {
84298 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
84299 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
84300 -1, __builtin_return_address(0));
84301 }
84302
84303 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
84304 unsigned long uaddr = vma->vm_start;
84305 unsigned long usize = vma->vm_end - vma->vm_start;
84306
84307 + BUG_ON(vma->vm_mirror);
84308 +
84309 if ((PAGE_SIZE-1) & (unsigned long)addr)
84310 return -EINVAL;
84311
84312 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
84313 v->addr, v->addr + v->size, v->size);
84314
84315 if (v->caller)
84316 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84317 + seq_printf(m, " %pK", v->caller);
84318 +#else
84319 seq_printf(m, " %pS", v->caller);
84320 +#endif
84321
84322 if (v->nr_pages)
84323 seq_printf(m, " pages=%d", v->nr_pages);
84324 diff --git a/mm/vmstat.c b/mm/vmstat.c
84325 index 9800306..76b4b27 100644
84326 --- a/mm/vmstat.c
84327 +++ b/mm/vmstat.c
84328 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
84329 *
84330 * vm_stat contains the global counters
84331 */
84332 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84333 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84334 EXPORT_SYMBOL(vm_stat);
84335
84336 #ifdef CONFIG_SMP
84337 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
84338 v = p->vm_stat_diff[i];
84339 p->vm_stat_diff[i] = 0;
84340 local_irq_restore(flags);
84341 - atomic_long_add(v, &zone->vm_stat[i]);
84342 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84343 global_diff[i] += v;
84344 #ifdef CONFIG_NUMA
84345 /* 3 seconds idle till flush */
84346 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
84347
84348 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
84349 if (global_diff[i])
84350 - atomic_long_add(global_diff[i], &vm_stat[i]);
84351 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
84352 }
84353
84354 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84355 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84356 if (pset->vm_stat_diff[i]) {
84357 int v = pset->vm_stat_diff[i];
84358 pset->vm_stat_diff[i] = 0;
84359 - atomic_long_add(v, &zone->vm_stat[i]);
84360 - atomic_long_add(v, &vm_stat[i]);
84361 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84362 + atomic_long_add_unchecked(v, &vm_stat[i]);
84363 }
84364 }
84365 #endif
84366 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
84367 return NOTIFY_OK;
84368 }
84369
84370 -static struct notifier_block __cpuinitdata vmstat_notifier =
84371 +static struct notifier_block vmstat_notifier =
84372 { &vmstat_cpuup_callback, NULL, 0 };
84373 #endif
84374
84375 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
84376 start_cpu_timer(cpu);
84377 #endif
84378 #ifdef CONFIG_PROC_FS
84379 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
84380 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
84381 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
84382 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
84383 + {
84384 + mode_t gr_mode = S_IRUGO;
84385 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84386 + gr_mode = S_IRUSR;
84387 +#endif
84388 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
84389 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
84390 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
84391 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
84392 +#else
84393 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
84394 +#endif
84395 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
84396 + }
84397 #endif
84398 return 0;
84399 }
84400 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
84401 index a292e80..785ee68 100644
84402 --- a/net/8021q/vlan.c
84403 +++ b/net/8021q/vlan.c
84404 @@ -485,7 +485,7 @@ out:
84405 return NOTIFY_DONE;
84406 }
84407
84408 -static struct notifier_block vlan_notifier_block __read_mostly = {
84409 +static struct notifier_block vlan_notifier_block = {
84410 .notifier_call = vlan_device_event,
84411 };
84412
84413 @@ -560,8 +560,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
84414 err = -EPERM;
84415 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
84416 break;
84417 - if ((args.u.name_type >= 0) &&
84418 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
84419 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
84420 struct vlan_net *vn;
84421
84422 vn = net_generic(net, vlan_net_id);
84423 diff --git a/net/9p/mod.c b/net/9p/mod.c
84424 index 6ab36ae..6f1841b 100644
84425 --- a/net/9p/mod.c
84426 +++ b/net/9p/mod.c
84427 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
84428 void v9fs_register_trans(struct p9_trans_module *m)
84429 {
84430 spin_lock(&v9fs_trans_lock);
84431 - list_add_tail(&m->list, &v9fs_trans_list);
84432 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
84433 spin_unlock(&v9fs_trans_lock);
84434 }
84435 EXPORT_SYMBOL(v9fs_register_trans);
84436 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
84437 void v9fs_unregister_trans(struct p9_trans_module *m)
84438 {
84439 spin_lock(&v9fs_trans_lock);
84440 - list_del_init(&m->list);
84441 + pax_list_del_init((struct list_head *)&m->list);
84442 spin_unlock(&v9fs_trans_lock);
84443 }
84444 EXPORT_SYMBOL(v9fs_unregister_trans);
84445 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
84446 index 02efb25..41541a9 100644
84447 --- a/net/9p/trans_fd.c
84448 +++ b/net/9p/trans_fd.c
84449 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
84450 oldfs = get_fs();
84451 set_fs(get_ds());
84452 /* The cast to a user pointer is valid due to the set_fs() */
84453 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
84454 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
84455 set_fs(oldfs);
84456
84457 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
84458 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
84459 index 876fbe8..8bbea9f 100644
84460 --- a/net/atm/atm_misc.c
84461 +++ b/net/atm/atm_misc.c
84462 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
84463 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
84464 return 1;
84465 atm_return(vcc, truesize);
84466 - atomic_inc(&vcc->stats->rx_drop);
84467 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84468 return 0;
84469 }
84470 EXPORT_SYMBOL(atm_charge);
84471 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
84472 }
84473 }
84474 atm_return(vcc, guess);
84475 - atomic_inc(&vcc->stats->rx_drop);
84476 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84477 return NULL;
84478 }
84479 EXPORT_SYMBOL(atm_alloc_charge);
84480 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
84481
84482 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84483 {
84484 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
84485 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
84486 __SONET_ITEMS
84487 #undef __HANDLE_ITEM
84488 }
84489 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
84490
84491 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84492 {
84493 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
84494 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
84495 __SONET_ITEMS
84496 #undef __HANDLE_ITEM
84497 }
84498 diff --git a/net/atm/lec.h b/net/atm/lec.h
84499 index a86aff9..3a0d6f6 100644
84500 --- a/net/atm/lec.h
84501 +++ b/net/atm/lec.h
84502 @@ -48,7 +48,7 @@ struct lane2_ops {
84503 const u8 *tlvs, u32 sizeoftlvs);
84504 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
84505 const u8 *tlvs, u32 sizeoftlvs);
84506 -};
84507 +} __no_const;
84508
84509 /*
84510 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
84511 diff --git a/net/atm/proc.c b/net/atm/proc.c
84512 index 0d020de..011c7bb 100644
84513 --- a/net/atm/proc.c
84514 +++ b/net/atm/proc.c
84515 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
84516 const struct k_atm_aal_stats *stats)
84517 {
84518 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
84519 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
84520 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
84521 - atomic_read(&stats->rx_drop));
84522 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
84523 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
84524 + atomic_read_unchecked(&stats->rx_drop));
84525 }
84526
84527 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
84528 diff --git a/net/atm/resources.c b/net/atm/resources.c
84529 index 0447d5d..3cf4728 100644
84530 --- a/net/atm/resources.c
84531 +++ b/net/atm/resources.c
84532 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
84533 static void copy_aal_stats(struct k_atm_aal_stats *from,
84534 struct atm_aal_stats *to)
84535 {
84536 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
84537 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
84538 __AAL_STAT_ITEMS
84539 #undef __HANDLE_ITEM
84540 }
84541 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
84542 static void subtract_aal_stats(struct k_atm_aal_stats *from,
84543 struct atm_aal_stats *to)
84544 {
84545 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
84546 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
84547 __AAL_STAT_ITEMS
84548 #undef __HANDLE_ITEM
84549 }
84550 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
84551 index d5744b7..506bae3 100644
84552 --- a/net/ax25/sysctl_net_ax25.c
84553 +++ b/net/ax25/sysctl_net_ax25.c
84554 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
84555 {
84556 char path[sizeof("net/ax25/") + IFNAMSIZ];
84557 int k;
84558 - struct ctl_table *table;
84559 + ctl_table_no_const *table;
84560
84561 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
84562 if (!table)
84563 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
84564 index 1ee94d0..14beea2 100644
84565 --- a/net/batman-adv/bat_iv_ogm.c
84566 +++ b/net/batman-adv/bat_iv_ogm.c
84567 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
84568
84569 /* randomize initial seqno to avoid collision */
84570 get_random_bytes(&random_seqno, sizeof(random_seqno));
84571 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
84572 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
84573
84574 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
84575 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
84576 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
84577 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
84578
84579 /* change sequence number to network order */
84580 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
84581 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
84582 batadv_ogm_packet->seqno = htonl(seqno);
84583 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
84584 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
84585
84586 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
84587 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
84588 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
84589 return;
84590
84591 /* could be changed by schedule_own_packet() */
84592 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
84593 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
84594
84595 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
84596 has_directlink_flag = 1;
84597 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
84598 index f1d37cd..4190879 100644
84599 --- a/net/batman-adv/hard-interface.c
84600 +++ b/net/batman-adv/hard-interface.c
84601 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
84602 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
84603 dev_add_pack(&hard_iface->batman_adv_ptype);
84604
84605 - atomic_set(&hard_iface->frag_seqno, 1);
84606 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
84607 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
84608 hard_iface->net_dev->name);
84609
84610 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
84611 /* This can't be called via a bat_priv callback because
84612 * we have no bat_priv yet.
84613 */
84614 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
84615 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
84616 hard_iface->bat_iv.ogm_buff = NULL;
84617
84618 return hard_iface;
84619 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
84620 index 6b548fd..fc32c8d 100644
84621 --- a/net/batman-adv/soft-interface.c
84622 +++ b/net/batman-adv/soft-interface.c
84623 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
84624 primary_if->net_dev->dev_addr, ETH_ALEN);
84625
84626 /* set broadcast sequence number */
84627 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
84628 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
84629 bcast_packet->seqno = htonl(seqno);
84630
84631 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
84632 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
84633 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
84634
84635 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
84636 - atomic_set(&bat_priv->bcast_seqno, 1);
84637 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
84638 atomic_set(&bat_priv->tt.vn, 0);
84639 atomic_set(&bat_priv->tt.local_changes, 0);
84640 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
84641 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
84642 index ae9ac9a..11e0fe7 100644
84643 --- a/net/batman-adv/types.h
84644 +++ b/net/batman-adv/types.h
84645 @@ -48,7 +48,7 @@
84646 struct batadv_hard_iface_bat_iv {
84647 unsigned char *ogm_buff;
84648 int ogm_buff_len;
84649 - atomic_t ogm_seqno;
84650 + atomic_unchecked_t ogm_seqno;
84651 };
84652
84653 struct batadv_hard_iface {
84654 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
84655 int16_t if_num;
84656 char if_status;
84657 struct net_device *net_dev;
84658 - atomic_t frag_seqno;
84659 + atomic_unchecked_t frag_seqno;
84660 struct kobject *hardif_obj;
84661 atomic_t refcount;
84662 struct packet_type batman_adv_ptype;
84663 @@ -284,7 +284,7 @@ struct batadv_priv {
84664 atomic_t orig_interval; /* uint */
84665 atomic_t hop_penalty; /* uint */
84666 atomic_t log_level; /* uint */
84667 - atomic_t bcast_seqno;
84668 + atomic_unchecked_t bcast_seqno;
84669 atomic_t bcast_queue_left;
84670 atomic_t batman_queue_left;
84671 char num_ifaces;
84672 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
84673 index 10aff49..ea8e021 100644
84674 --- a/net/batman-adv/unicast.c
84675 +++ b/net/batman-adv/unicast.c
84676 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
84677 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
84678 frag2->flags = large_tail;
84679
84680 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
84681 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
84682 frag1->seqno = htons(seqno - 1);
84683 frag2->seqno = htons(seqno);
84684
84685 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
84686 index 07f0739..3c42e34 100644
84687 --- a/net/bluetooth/hci_sock.c
84688 +++ b/net/bluetooth/hci_sock.c
84689 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
84690 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
84691 }
84692
84693 - len = min_t(unsigned int, len, sizeof(uf));
84694 + len = min((size_t)len, sizeof(uf));
84695 if (copy_from_user(&uf, optval, len)) {
84696 err = -EFAULT;
84697 break;
84698 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
84699 index 22e6583..426e2f3 100644
84700 --- a/net/bluetooth/l2cap_core.c
84701 +++ b/net/bluetooth/l2cap_core.c
84702 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
84703 break;
84704
84705 case L2CAP_CONF_RFC:
84706 - if (olen == sizeof(rfc))
84707 - memcpy(&rfc, (void *)val, olen);
84708 + if (olen != sizeof(rfc))
84709 + break;
84710 +
84711 + memcpy(&rfc, (void *)val, olen);
84712
84713 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
84714 rfc.mode != chan->mode)
84715 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
84716 index 1bcfb84..dad9f98 100644
84717 --- a/net/bluetooth/l2cap_sock.c
84718 +++ b/net/bluetooth/l2cap_sock.c
84719 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
84720 struct sock *sk = sock->sk;
84721 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
84722 struct l2cap_options opts;
84723 - int len, err = 0;
84724 + int err = 0;
84725 + size_t len = optlen;
84726 u32 opt;
84727
84728 BT_DBG("sk %p", sk);
84729 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
84730 opts.max_tx = chan->max_tx;
84731 opts.txwin_size = chan->tx_win;
84732
84733 - len = min_t(unsigned int, sizeof(opts), optlen);
84734 + len = min(sizeof(opts), len);
84735 if (copy_from_user((char *) &opts, optval, len)) {
84736 err = -EFAULT;
84737 break;
84738 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84739 struct bt_security sec;
84740 struct bt_power pwr;
84741 struct l2cap_conn *conn;
84742 - int len, err = 0;
84743 + int err = 0;
84744 + size_t len = optlen;
84745 u32 opt;
84746
84747 BT_DBG("sk %p", sk);
84748 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84749
84750 sec.level = BT_SECURITY_LOW;
84751
84752 - len = min_t(unsigned int, sizeof(sec), optlen);
84753 + len = min(sizeof(sec), len);
84754 if (copy_from_user((char *) &sec, optval, len)) {
84755 err = -EFAULT;
84756 break;
84757 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84758
84759 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
84760
84761 - len = min_t(unsigned int, sizeof(pwr), optlen);
84762 + len = min(sizeof(pwr), len);
84763 if (copy_from_user((char *) &pwr, optval, len)) {
84764 err = -EFAULT;
84765 break;
84766 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
84767 index ce3f665..2c7d08f 100644
84768 --- a/net/bluetooth/rfcomm/sock.c
84769 +++ b/net/bluetooth/rfcomm/sock.c
84770 @@ -667,7 +667,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
84771 struct sock *sk = sock->sk;
84772 struct bt_security sec;
84773 int err = 0;
84774 - size_t len;
84775 + size_t len = optlen;
84776 u32 opt;
84777
84778 BT_DBG("sk %p", sk);
84779 @@ -689,7 +689,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
84780
84781 sec.level = BT_SECURITY_LOW;
84782
84783 - len = min_t(unsigned int, sizeof(sec), optlen);
84784 + len = min(sizeof(sec), len);
84785 if (copy_from_user((char *) &sec, optval, len)) {
84786 err = -EFAULT;
84787 break;
84788 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
84789 index bd6fd0f..6492cba 100644
84790 --- a/net/bluetooth/rfcomm/tty.c
84791 +++ b/net/bluetooth/rfcomm/tty.c
84792 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
84793 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
84794
84795 spin_lock_irqsave(&dev->port.lock, flags);
84796 - if (dev->port.count > 0) {
84797 + if (atomic_read(&dev->port.count) > 0) {
84798 spin_unlock_irqrestore(&dev->port.lock, flags);
84799 return;
84800 }
84801 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
84802 return -ENODEV;
84803
84804 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
84805 - dev->channel, dev->port.count);
84806 + dev->channel, atomic_read(&dev->port.count));
84807
84808 spin_lock_irqsave(&dev->port.lock, flags);
84809 - if (++dev->port.count > 1) {
84810 + if (atomic_inc_return(&dev->port.count) > 1) {
84811 spin_unlock_irqrestore(&dev->port.lock, flags);
84812 return 0;
84813 }
84814 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
84815 return;
84816
84817 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
84818 - dev->port.count);
84819 + atomic_read(&dev->port.count));
84820
84821 spin_lock_irqsave(&dev->port.lock, flags);
84822 - if (!--dev->port.count) {
84823 + if (!atomic_dec_return(&dev->port.count)) {
84824 spin_unlock_irqrestore(&dev->port.lock, flags);
84825 if (dev->tty_dev->parent)
84826 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
84827 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
84828 index 5fe2ff3..121d696 100644
84829 --- a/net/bridge/netfilter/ebtables.c
84830 +++ b/net/bridge/netfilter/ebtables.c
84831 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
84832 tmp.valid_hooks = t->table->valid_hooks;
84833 }
84834 mutex_unlock(&ebt_mutex);
84835 - if (copy_to_user(user, &tmp, *len) != 0){
84836 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
84837 BUGPRINT("c2u Didn't work\n");
84838 ret = -EFAULT;
84839 break;
84840 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
84841 goto out;
84842 tmp.valid_hooks = t->valid_hooks;
84843
84844 - if (copy_to_user(user, &tmp, *len) != 0) {
84845 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
84846 ret = -EFAULT;
84847 break;
84848 }
84849 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
84850 tmp.entries_size = t->table->entries_size;
84851 tmp.valid_hooks = t->table->valid_hooks;
84852
84853 - if (copy_to_user(user, &tmp, *len) != 0) {
84854 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
84855 ret = -EFAULT;
84856 break;
84857 }
84858 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
84859 index a376ec1..1fbd6be 100644
84860 --- a/net/caif/cfctrl.c
84861 +++ b/net/caif/cfctrl.c
84862 @@ -10,6 +10,7 @@
84863 #include <linux/spinlock.h>
84864 #include <linux/slab.h>
84865 #include <linux/pkt_sched.h>
84866 +#include <linux/sched.h>
84867 #include <net/caif/caif_layer.h>
84868 #include <net/caif/cfpkt.h>
84869 #include <net/caif/cfctrl.h>
84870 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
84871 memset(&dev_info, 0, sizeof(dev_info));
84872 dev_info.id = 0xff;
84873 cfsrvl_init(&this->serv, 0, &dev_info, false);
84874 - atomic_set(&this->req_seq_no, 1);
84875 - atomic_set(&this->rsp_seq_no, 1);
84876 + atomic_set_unchecked(&this->req_seq_no, 1);
84877 + atomic_set_unchecked(&this->rsp_seq_no, 1);
84878 this->serv.layer.receive = cfctrl_recv;
84879 sprintf(this->serv.layer.name, "ctrl");
84880 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
84881 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
84882 struct cfctrl_request_info *req)
84883 {
84884 spin_lock_bh(&ctrl->info_list_lock);
84885 - atomic_inc(&ctrl->req_seq_no);
84886 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
84887 + atomic_inc_unchecked(&ctrl->req_seq_no);
84888 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
84889 list_add_tail(&req->list, &ctrl->list);
84890 spin_unlock_bh(&ctrl->info_list_lock);
84891 }
84892 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
84893 if (p != first)
84894 pr_warn("Requests are not received in order\n");
84895
84896 - atomic_set(&ctrl->rsp_seq_no,
84897 + atomic_set_unchecked(&ctrl->rsp_seq_no,
84898 p->sequence_no);
84899 list_del(&p->list);
84900 goto out;
84901 diff --git a/net/can/af_can.c b/net/can/af_can.c
84902 index ddac1ee..3ee0a78 100644
84903 --- a/net/can/af_can.c
84904 +++ b/net/can/af_can.c
84905 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
84906 };
84907
84908 /* notifier block for netdevice event */
84909 -static struct notifier_block can_netdev_notifier __read_mostly = {
84910 +static struct notifier_block can_netdev_notifier = {
84911 .notifier_call = can_notifier,
84912 };
84913
84914 diff --git a/net/can/gw.c b/net/can/gw.c
84915 index 574dda78e..3d2b3da 100644
84916 --- a/net/can/gw.c
84917 +++ b/net/can/gw.c
84918 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
84919 MODULE_ALIAS("can-gw");
84920
84921 static HLIST_HEAD(cgw_list);
84922 -static struct notifier_block notifier;
84923
84924 static struct kmem_cache *cgw_cache __read_mostly;
84925
84926 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
84927 return err;
84928 }
84929
84930 +static struct notifier_block notifier = {
84931 + .notifier_call = cgw_notifier
84932 +};
84933 +
84934 static __init int cgw_module_init(void)
84935 {
84936 printk(banner);
84937 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
84938 return -ENOMEM;
84939
84940 /* set notifier */
84941 - notifier.notifier_call = cgw_notifier;
84942 register_netdevice_notifier(&notifier);
84943
84944 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
84945 diff --git a/net/compat.c b/net/compat.c
84946 index 79ae884..17c5c09 100644
84947 --- a/net/compat.c
84948 +++ b/net/compat.c
84949 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
84950 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
84951 __get_user(kmsg->msg_flags, &umsg->msg_flags))
84952 return -EFAULT;
84953 - kmsg->msg_name = compat_ptr(tmp1);
84954 - kmsg->msg_iov = compat_ptr(tmp2);
84955 - kmsg->msg_control = compat_ptr(tmp3);
84956 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
84957 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
84958 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
84959 return 0;
84960 }
84961
84962 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84963
84964 if (kern_msg->msg_namelen) {
84965 if (mode == VERIFY_READ) {
84966 - int err = move_addr_to_kernel(kern_msg->msg_name,
84967 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
84968 kern_msg->msg_namelen,
84969 kern_address);
84970 if (err < 0)
84971 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84972 kern_msg->msg_name = NULL;
84973
84974 tot_len = iov_from_user_compat_to_kern(kern_iov,
84975 - (struct compat_iovec __user *)kern_msg->msg_iov,
84976 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
84977 kern_msg->msg_iovlen);
84978 if (tot_len >= 0)
84979 kern_msg->msg_iov = kern_iov;
84980 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84981
84982 #define CMSG_COMPAT_FIRSTHDR(msg) \
84983 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
84984 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
84985 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
84986 (struct compat_cmsghdr __user *)NULL)
84987
84988 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
84989 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
84990 (ucmlen) <= (unsigned long) \
84991 ((mhdr)->msg_controllen - \
84992 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
84993 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
84994
84995 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
84996 struct compat_cmsghdr __user *cmsg, int cmsg_len)
84997 {
84998 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
84999 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
85000 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
85001 msg->msg_controllen)
85002 return NULL;
85003 return (struct compat_cmsghdr __user *)ptr;
85004 @@ -219,7 +219,7 @@ Efault:
85005
85006 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
85007 {
85008 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85009 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85010 struct compat_cmsghdr cmhdr;
85011 struct compat_timeval ctv;
85012 struct compat_timespec cts[3];
85013 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
85014
85015 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
85016 {
85017 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85018 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85019 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
85020 int fdnum = scm->fp->count;
85021 struct file **fp = scm->fp->fp;
85022 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
85023 return -EFAULT;
85024 old_fs = get_fs();
85025 set_fs(KERNEL_DS);
85026 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
85027 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
85028 set_fs(old_fs);
85029
85030 return err;
85031 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
85032 len = sizeof(ktime);
85033 old_fs = get_fs();
85034 set_fs(KERNEL_DS);
85035 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
85036 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
85037 set_fs(old_fs);
85038
85039 if (!err) {
85040 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85041 case MCAST_JOIN_GROUP:
85042 case MCAST_LEAVE_GROUP:
85043 {
85044 - struct compat_group_req __user *gr32 = (void *)optval;
85045 + struct compat_group_req __user *gr32 = (void __user *)optval;
85046 struct group_req __user *kgr =
85047 compat_alloc_user_space(sizeof(struct group_req));
85048 u32 interface;
85049 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85050 case MCAST_BLOCK_SOURCE:
85051 case MCAST_UNBLOCK_SOURCE:
85052 {
85053 - struct compat_group_source_req __user *gsr32 = (void *)optval;
85054 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
85055 struct group_source_req __user *kgsr = compat_alloc_user_space(
85056 sizeof(struct group_source_req));
85057 u32 interface;
85058 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85059 }
85060 case MCAST_MSFILTER:
85061 {
85062 - struct compat_group_filter __user *gf32 = (void *)optval;
85063 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85064 struct group_filter __user *kgf;
85065 u32 interface, fmode, numsrc;
85066
85067 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
85068 char __user *optval, int __user *optlen,
85069 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
85070 {
85071 - struct compat_group_filter __user *gf32 = (void *)optval;
85072 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85073 struct group_filter __user *kgf;
85074 int __user *koptlen;
85075 u32 interface, fmode, numsrc;
85076 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
85077
85078 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
85079 return -EINVAL;
85080 - if (copy_from_user(a, args, nas[call]))
85081 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
85082 return -EFAULT;
85083 a0 = a[0];
85084 a1 = a[1];
85085 diff --git a/net/core/datagram.c b/net/core/datagram.c
85086 index 368f9c3..f82d4a3 100644
85087 --- a/net/core/datagram.c
85088 +++ b/net/core/datagram.c
85089 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
85090 }
85091
85092 kfree_skb(skb);
85093 - atomic_inc(&sk->sk_drops);
85094 + atomic_inc_unchecked(&sk->sk_drops);
85095 sk_mem_reclaim_partial(sk);
85096
85097 return err;
85098 diff --git a/net/core/dev.c b/net/core/dev.c
85099 index 1339f77..6fd27dc 100644
85100 --- a/net/core/dev.c
85101 +++ b/net/core/dev.c
85102 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
85103 if (no_module && capable(CAP_NET_ADMIN))
85104 no_module = request_module("netdev-%s", name);
85105 if (no_module && capable(CAP_SYS_MODULE)) {
85106 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
85107 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
85108 +#else
85109 if (!request_module("%s", name))
85110 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
85111 name);
85112 +#endif
85113 }
85114 }
85115 EXPORT_SYMBOL(dev_load);
85116 @@ -1715,7 +1719,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85117 {
85118 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
85119 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
85120 - atomic_long_inc(&dev->rx_dropped);
85121 + atomic_long_inc_unchecked(&dev->rx_dropped);
85122 kfree_skb(skb);
85123 return NET_RX_DROP;
85124 }
85125 @@ -1725,7 +1729,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85126 nf_reset(skb);
85127
85128 if (unlikely(!is_skb_forwardable(dev, skb))) {
85129 - atomic_long_inc(&dev->rx_dropped);
85130 + atomic_long_inc_unchecked(&dev->rx_dropped);
85131 kfree_skb(skb);
85132 return NET_RX_DROP;
85133 }
85134 @@ -2180,7 +2184,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
85135
85136 struct dev_gso_cb {
85137 void (*destructor)(struct sk_buff *skb);
85138 -};
85139 +} __no_const;
85140
85141 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
85142
85143 @@ -3053,7 +3057,7 @@ enqueue:
85144
85145 local_irq_restore(flags);
85146
85147 - atomic_long_inc(&skb->dev->rx_dropped);
85148 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85149 kfree_skb(skb);
85150 return NET_RX_DROP;
85151 }
85152 @@ -3125,7 +3129,7 @@ int netif_rx_ni(struct sk_buff *skb)
85153 }
85154 EXPORT_SYMBOL(netif_rx_ni);
85155
85156 -static void net_tx_action(struct softirq_action *h)
85157 +static void net_tx_action(void)
85158 {
85159 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85160
85161 @@ -3457,7 +3461,7 @@ ncls:
85162 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
85163 } else {
85164 drop:
85165 - atomic_long_inc(&skb->dev->rx_dropped);
85166 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85167 kfree_skb(skb);
85168 /* Jamal, now you will not able to escape explaining
85169 * me how you were going to use this. :-)
85170 @@ -4040,7 +4044,7 @@ void netif_napi_del(struct napi_struct *napi)
85171 }
85172 EXPORT_SYMBOL(netif_napi_del);
85173
85174 -static void net_rx_action(struct softirq_action *h)
85175 +static void net_rx_action(void)
85176 {
85177 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85178 unsigned long time_limit = jiffies + 2;
85179 @@ -4524,8 +4528,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
85180 else
85181 seq_printf(seq, "%04x", ntohs(pt->type));
85182
85183 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85184 + seq_printf(seq, " %-8s %p\n",
85185 + pt->dev ? pt->dev->name : "", NULL);
85186 +#else
85187 seq_printf(seq, " %-8s %pF\n",
85188 pt->dev ? pt->dev->name : "", pt->func);
85189 +#endif
85190 }
85191
85192 return 0;
85193 @@ -6097,7 +6106,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
85194 } else {
85195 netdev_stats_to_stats64(storage, &dev->stats);
85196 }
85197 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
85198 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
85199 return storage;
85200 }
85201 EXPORT_SYMBOL(dev_get_stats);
85202 diff --git a/net/core/flow.c b/net/core/flow.c
85203 index b0901ee..7d3c2ca 100644
85204 --- a/net/core/flow.c
85205 +++ b/net/core/flow.c
85206 @@ -61,7 +61,7 @@ struct flow_cache {
85207 struct timer_list rnd_timer;
85208 };
85209
85210 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
85211 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
85212 EXPORT_SYMBOL(flow_cache_genid);
85213 static struct flow_cache flow_cache_global;
85214 static struct kmem_cache *flow_cachep __read_mostly;
85215 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
85216
85217 static int flow_entry_valid(struct flow_cache_entry *fle)
85218 {
85219 - if (atomic_read(&flow_cache_genid) != fle->genid)
85220 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
85221 return 0;
85222 if (fle->object && !fle->object->ops->check(fle->object))
85223 return 0;
85224 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
85225 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
85226 fcp->hash_count++;
85227 }
85228 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
85229 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
85230 flo = fle->object;
85231 if (!flo)
85232 goto ret_object;
85233 @@ -280,7 +280,7 @@ nocache:
85234 }
85235 flo = resolver(net, key, family, dir, flo, ctx);
85236 if (fle) {
85237 - fle->genid = atomic_read(&flow_cache_genid);
85238 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
85239 if (!IS_ERR(flo))
85240 fle->object = flo;
85241 else
85242 diff --git a/net/core/iovec.c b/net/core/iovec.c
85243 index 7e7aeb0..2a998cb 100644
85244 --- a/net/core/iovec.c
85245 +++ b/net/core/iovec.c
85246 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85247 if (m->msg_namelen) {
85248 if (mode == VERIFY_READ) {
85249 void __user *namep;
85250 - namep = (void __user __force *) m->msg_name;
85251 + namep = (void __force_user *) m->msg_name;
85252 err = move_addr_to_kernel(namep, m->msg_namelen,
85253 address);
85254 if (err < 0)
85255 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
85256 }
85257
85258 size = m->msg_iovlen * sizeof(struct iovec);
85259 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
85260 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
85261 return -EFAULT;
85262
85263 m->msg_iov = iov;
85264 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
85265 index c815f28..e6403f2 100644
85266 --- a/net/core/neighbour.c
85267 +++ b/net/core/neighbour.c
85268 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
85269 size_t *lenp, loff_t *ppos)
85270 {
85271 int size, ret;
85272 - ctl_table tmp = *ctl;
85273 + ctl_table_no_const tmp = *ctl;
85274
85275 tmp.extra1 = &zero;
85276 tmp.extra2 = &unres_qlen_max;
85277 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
85278 index 28c5f5a..7edf2e2 100644
85279 --- a/net/core/net-sysfs.c
85280 +++ b/net/core/net-sysfs.c
85281 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
85282 }
85283 EXPORT_SYMBOL(netdev_class_remove_file);
85284
85285 -int netdev_kobject_init(void)
85286 +int __init netdev_kobject_init(void)
85287 {
85288 kobj_ns_type_register(&net_ns_type_operations);
85289 return class_register(&net_class);
85290 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
85291 index 8acce01..2e306bb 100644
85292 --- a/net/core/net_namespace.c
85293 +++ b/net/core/net_namespace.c
85294 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
85295 int error;
85296 LIST_HEAD(net_exit_list);
85297
85298 - list_add_tail(&ops->list, list);
85299 + pax_list_add_tail((struct list_head *)&ops->list, list);
85300 if (ops->init || (ops->id && ops->size)) {
85301 for_each_net(net) {
85302 error = ops_init(ops, net);
85303 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
85304
85305 out_undo:
85306 /* If I have an error cleanup all namespaces I initialized */
85307 - list_del(&ops->list);
85308 + pax_list_del((struct list_head *)&ops->list);
85309 ops_exit_list(ops, &net_exit_list);
85310 ops_free_list(ops, &net_exit_list);
85311 return error;
85312 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
85313 struct net *net;
85314 LIST_HEAD(net_exit_list);
85315
85316 - list_del(&ops->list);
85317 + pax_list_del((struct list_head *)&ops->list);
85318 for_each_net(net)
85319 list_add_tail(&net->exit_list, &net_exit_list);
85320 ops_exit_list(ops, &net_exit_list);
85321 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
85322 mutex_lock(&net_mutex);
85323 error = register_pernet_operations(&pernet_list, ops);
85324 if (!error && (first_device == &pernet_list))
85325 - first_device = &ops->list;
85326 + first_device = (struct list_head *)&ops->list;
85327 mutex_unlock(&net_mutex);
85328 return error;
85329 }
85330 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
85331 index 6212ec9..dd4ad3b 100644
85332 --- a/net/core/rtnetlink.c
85333 +++ b/net/core/rtnetlink.c
85334 @@ -58,7 +58,7 @@ struct rtnl_link {
85335 rtnl_doit_func doit;
85336 rtnl_dumpit_func dumpit;
85337 rtnl_calcit_func calcit;
85338 -};
85339 +} __no_const;
85340
85341 static DEFINE_MUTEX(rtnl_mutex);
85342
85343 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
85344 if (rtnl_link_ops_get(ops->kind))
85345 return -EEXIST;
85346
85347 - if (!ops->dellink)
85348 - ops->dellink = unregister_netdevice_queue;
85349 + if (!ops->dellink) {
85350 + pax_open_kernel();
85351 + *(void **)&ops->dellink = unregister_netdevice_queue;
85352 + pax_close_kernel();
85353 + }
85354
85355 - list_add_tail(&ops->list, &link_ops);
85356 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
85357 return 0;
85358 }
85359 EXPORT_SYMBOL_GPL(__rtnl_link_register);
85360 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
85361 for_each_net(net) {
85362 __rtnl_kill_links(net, ops);
85363 }
85364 - list_del(&ops->list);
85365 + pax_list_del((struct list_head *)&ops->list);
85366 }
85367 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
85368
85369 diff --git a/net/core/scm.c b/net/core/scm.c
85370 index 905dcc6..14ee2d6 100644
85371 --- a/net/core/scm.c
85372 +++ b/net/core/scm.c
85373 @@ -224,7 +224,7 @@ EXPORT_SYMBOL(__scm_send);
85374 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85375 {
85376 struct cmsghdr __user *cm
85377 - = (__force struct cmsghdr __user *)msg->msg_control;
85378 + = (struct cmsghdr __force_user *)msg->msg_control;
85379 struct cmsghdr cmhdr;
85380 int cmlen = CMSG_LEN(len);
85381 int err;
85382 @@ -247,7 +247,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85383 err = -EFAULT;
85384 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
85385 goto out;
85386 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
85387 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
85388 goto out;
85389 cmlen = CMSG_SPACE(len);
85390 if (msg->msg_controllen < cmlen)
85391 @@ -263,7 +263,7 @@ EXPORT_SYMBOL(put_cmsg);
85392 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85393 {
85394 struct cmsghdr __user *cm
85395 - = (__force struct cmsghdr __user*)msg->msg_control;
85396 + = (struct cmsghdr __force_user *)msg->msg_control;
85397
85398 int fdmax = 0;
85399 int fdnum = scm->fp->count;
85400 @@ -283,7 +283,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85401 if (fdnum < fdmax)
85402 fdmax = fdnum;
85403
85404 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
85405 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
85406 i++, cmfptr++)
85407 {
85408 struct socket *sock;
85409 diff --git a/net/core/sock.c b/net/core/sock.c
85410 index bc131d4..029e378 100644
85411 --- a/net/core/sock.c
85412 +++ b/net/core/sock.c
85413 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85414 struct sk_buff_head *list = &sk->sk_receive_queue;
85415
85416 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
85417 - atomic_inc(&sk->sk_drops);
85418 + atomic_inc_unchecked(&sk->sk_drops);
85419 trace_sock_rcvqueue_full(sk, skb);
85420 return -ENOMEM;
85421 }
85422 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85423 return err;
85424
85425 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
85426 - atomic_inc(&sk->sk_drops);
85427 + atomic_inc_unchecked(&sk->sk_drops);
85428 return -ENOBUFS;
85429 }
85430
85431 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85432 skb_dst_force(skb);
85433
85434 spin_lock_irqsave(&list->lock, flags);
85435 - skb->dropcount = atomic_read(&sk->sk_drops);
85436 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
85437 __skb_queue_tail(list, skb);
85438 spin_unlock_irqrestore(&list->lock, flags);
85439
85440 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85441 skb->dev = NULL;
85442
85443 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
85444 - atomic_inc(&sk->sk_drops);
85445 + atomic_inc_unchecked(&sk->sk_drops);
85446 goto discard_and_relse;
85447 }
85448 if (nested)
85449 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85450 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
85451 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
85452 bh_unlock_sock(sk);
85453 - atomic_inc(&sk->sk_drops);
85454 + atomic_inc_unchecked(&sk->sk_drops);
85455 goto discard_and_relse;
85456 }
85457
85458 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85459 struct timeval tm;
85460 } v;
85461
85462 - int lv = sizeof(int);
85463 - int len;
85464 + unsigned int lv = sizeof(int);
85465 + unsigned int len;
85466
85467 if (get_user(len, optlen))
85468 return -EFAULT;
85469 - if (len < 0)
85470 + if (len > INT_MAX)
85471 return -EINVAL;
85472
85473 memset(&v, 0, sizeof(v));
85474 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85475
85476 case SO_PEERNAME:
85477 {
85478 - char address[128];
85479 + char address[_K_SS_MAXSIZE];
85480
85481 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
85482 return -ENOTCONN;
85483 - if (lv < len)
85484 + if (lv < len || sizeof address < len)
85485 return -EINVAL;
85486 if (copy_to_user(optval, address, len))
85487 return -EFAULT;
85488 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85489
85490 if (len > lv)
85491 len = lv;
85492 - if (copy_to_user(optval, &v, len))
85493 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
85494 return -EFAULT;
85495 lenout:
85496 if (put_user(len, optlen))
85497 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
85498 */
85499 smp_wmb();
85500 atomic_set(&sk->sk_refcnt, 1);
85501 - atomic_set(&sk->sk_drops, 0);
85502 + atomic_set_unchecked(&sk->sk_drops, 0);
85503 }
85504 EXPORT_SYMBOL(sock_init_data);
85505
85506 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
85507 index 750f44f..922399c 100644
85508 --- a/net/core/sock_diag.c
85509 +++ b/net/core/sock_diag.c
85510 @@ -9,26 +9,33 @@
85511 #include <linux/inet_diag.h>
85512 #include <linux/sock_diag.h>
85513
85514 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
85515 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
85516 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
85517 static DEFINE_MUTEX(sock_diag_table_mutex);
85518
85519 int sock_diag_check_cookie(void *sk, __u32 *cookie)
85520 {
85521 +#ifndef CONFIG_GRKERNSEC_HIDESYM
85522 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
85523 cookie[1] != INET_DIAG_NOCOOKIE) &&
85524 ((u32)(unsigned long)sk != cookie[0] ||
85525 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
85526 return -ESTALE;
85527 else
85528 +#endif
85529 return 0;
85530 }
85531 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
85532
85533 void sock_diag_save_cookie(void *sk, __u32 *cookie)
85534 {
85535 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85536 + cookie[0] = 0;
85537 + cookie[1] = 0;
85538 +#else
85539 cookie[0] = (u32)(unsigned long)sk;
85540 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
85541 +#endif
85542 }
85543 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
85544
85545 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
85546 mutex_lock(&sock_diag_table_mutex);
85547 if (sock_diag_handlers[hndl->family])
85548 err = -EBUSY;
85549 - else
85550 + else {
85551 + pax_open_kernel();
85552 sock_diag_handlers[hndl->family] = hndl;
85553 + pax_close_kernel();
85554 + }
85555 mutex_unlock(&sock_diag_table_mutex);
85556
85557 return err;
85558 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
85559
85560 mutex_lock(&sock_diag_table_mutex);
85561 BUG_ON(sock_diag_handlers[family] != hnld);
85562 + pax_open_kernel();
85563 sock_diag_handlers[family] = NULL;
85564 + pax_close_kernel();
85565 mutex_unlock(&sock_diag_table_mutex);
85566 }
85567 EXPORT_SYMBOL_GPL(sock_diag_unregister);
85568
85569 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
85570 -{
85571 - if (sock_diag_handlers[family] == NULL)
85572 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
85573 - NETLINK_SOCK_DIAG, family);
85574 -
85575 - mutex_lock(&sock_diag_table_mutex);
85576 - return sock_diag_handlers[family];
85577 -}
85578 -
85579 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
85580 -{
85581 - mutex_unlock(&sock_diag_table_mutex);
85582 -}
85583 -
85584 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
85585 {
85586 int err;
85587 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
85588 if (req->sdiag_family >= AF_MAX)
85589 return -EINVAL;
85590
85591 - hndl = sock_diag_lock_handler(req->sdiag_family);
85592 + if (sock_diag_handlers[req->sdiag_family] == NULL)
85593 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
85594 + NETLINK_SOCK_DIAG, req->sdiag_family);
85595 +
85596 + mutex_lock(&sock_diag_table_mutex);
85597 + hndl = sock_diag_handlers[req->sdiag_family];
85598 if (hndl == NULL)
85599 err = -ENOENT;
85600 else
85601 err = hndl->dump(skb, nlh);
85602 - sock_diag_unlock_handler(hndl);
85603 + mutex_unlock(&sock_diag_table_mutex);
85604
85605 return err;
85606 }
85607 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
85608 index d1b0804..98cf5f7 100644
85609 --- a/net/core/sysctl_net_core.c
85610 +++ b/net/core/sysctl_net_core.c
85611 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
85612 {
85613 unsigned int orig_size, size;
85614 int ret, i;
85615 - ctl_table tmp = {
85616 + ctl_table_no_const tmp = {
85617 .data = &size,
85618 .maxlen = sizeof(size),
85619 .mode = table->mode
85620 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
85621
85622 static __net_init int sysctl_core_net_init(struct net *net)
85623 {
85624 - struct ctl_table *tbl;
85625 + ctl_table_no_const *tbl = NULL;
85626
85627 net->core.sysctl_somaxconn = SOMAXCONN;
85628
85629 - tbl = netns_core_table;
85630 if (!net_eq(net, &init_net)) {
85631 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
85632 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
85633 if (tbl == NULL)
85634 goto err_dup;
85635
85636 @@ -221,17 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
85637 if (net->user_ns != &init_user_ns) {
85638 tbl[0].procname = NULL;
85639 }
85640 - }
85641 -
85642 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
85643 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
85644 + } else
85645 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
85646 if (net->core.sysctl_hdr == NULL)
85647 goto err_reg;
85648
85649 return 0;
85650
85651 err_reg:
85652 - if (tbl != netns_core_table)
85653 - kfree(tbl);
85654 + kfree(tbl);
85655 err_dup:
85656 return -ENOMEM;
85657 }
85658 @@ -246,7 +244,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
85659 kfree(tbl);
85660 }
85661
85662 -static __net_initdata struct pernet_operations sysctl_core_ops = {
85663 +static __net_initconst struct pernet_operations sysctl_core_ops = {
85664 .init = sysctl_core_net_init,
85665 .exit = sysctl_core_net_exit,
85666 };
85667 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
85668 index 307c322..78a4c6f 100644
85669 --- a/net/decnet/af_decnet.c
85670 +++ b/net/decnet/af_decnet.c
85671 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
85672 .sysctl_rmem = sysctl_decnet_rmem,
85673 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
85674 .obj_size = sizeof(struct dn_sock),
85675 + .slab_flags = SLAB_USERCOPY,
85676 };
85677
85678 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
85679 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
85680 index a55eecc..dd8428c 100644
85681 --- a/net/decnet/sysctl_net_decnet.c
85682 +++ b/net/decnet/sysctl_net_decnet.c
85683 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
85684
85685 if (len > *lenp) len = *lenp;
85686
85687 - if (copy_to_user(buffer, addr, len))
85688 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
85689 return -EFAULT;
85690
85691 *lenp = len;
85692 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
85693
85694 if (len > *lenp) len = *lenp;
85695
85696 - if (copy_to_user(buffer, devname, len))
85697 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
85698 return -EFAULT;
85699
85700 *lenp = len;
85701 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
85702 index fcf104e..95552d4 100644
85703 --- a/net/ipv4/af_inet.c
85704 +++ b/net/ipv4/af_inet.c
85705 @@ -1717,13 +1717,9 @@ static int __init inet_init(void)
85706
85707 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
85708
85709 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
85710 - if (!sysctl_local_reserved_ports)
85711 - goto out;
85712 -
85713 rc = proto_register(&tcp_prot, 1);
85714 if (rc)
85715 - goto out_free_reserved_ports;
85716 + goto out;
85717
85718 rc = proto_register(&udp_prot, 1);
85719 if (rc)
85720 @@ -1832,8 +1828,6 @@ out_unregister_udp_proto:
85721 proto_unregister(&udp_prot);
85722 out_unregister_tcp_proto:
85723 proto_unregister(&tcp_prot);
85724 -out_free_reserved_ports:
85725 - kfree(sysctl_local_reserved_ports);
85726 goto out;
85727 }
85728
85729 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
85730 index a69b4e4..dbccba5 100644
85731 --- a/net/ipv4/ah4.c
85732 +++ b/net/ipv4/ah4.c
85733 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
85734 return;
85735
85736 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85737 - atomic_inc(&flow_cache_genid);
85738 + atomic_inc_unchecked(&flow_cache_genid);
85739 rt_genid_bump(net);
85740
85741 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
85742 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
85743 index a8e4f26..25e5f40 100644
85744 --- a/net/ipv4/devinet.c
85745 +++ b/net/ipv4/devinet.c
85746 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
85747 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
85748 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
85749
85750 -static struct devinet_sysctl_table {
85751 +static const struct devinet_sysctl_table {
85752 struct ctl_table_header *sysctl_header;
85753 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
85754 } devinet_sysctl = {
85755 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
85756 int err;
85757 struct ipv4_devconf *all, *dflt;
85758 #ifdef CONFIG_SYSCTL
85759 - struct ctl_table *tbl = ctl_forward_entry;
85760 + ctl_table_no_const *tbl = NULL;
85761 struct ctl_table_header *forw_hdr;
85762 #endif
85763
85764 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
85765 goto err_alloc_dflt;
85766
85767 #ifdef CONFIG_SYSCTL
85768 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
85769 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
85770 if (tbl == NULL)
85771 goto err_alloc_ctl;
85772
85773 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
85774 goto err_reg_dflt;
85775
85776 err = -ENOMEM;
85777 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
85778 + if (!net_eq(net, &init_net))
85779 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
85780 + else
85781 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
85782 if (forw_hdr == NULL)
85783 goto err_reg_ctl;
85784 net->ipv4.forw_hdr = forw_hdr;
85785 @@ -1935,8 +1938,7 @@ err_reg_ctl:
85786 err_reg_dflt:
85787 __devinet_sysctl_unregister(all);
85788 err_reg_all:
85789 - if (tbl != ctl_forward_entry)
85790 - kfree(tbl);
85791 + kfree(tbl);
85792 err_alloc_ctl:
85793 #endif
85794 if (dflt != &ipv4_devconf_dflt)
85795 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
85796 index 3b4f0cd..8cb864c 100644
85797 --- a/net/ipv4/esp4.c
85798 +++ b/net/ipv4/esp4.c
85799 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
85800 return;
85801
85802 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85803 - atomic_inc(&flow_cache_genid);
85804 + atomic_inc_unchecked(&flow_cache_genid);
85805 rt_genid_bump(net);
85806
85807 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
85808 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
85809 index 5cd75e2..f57ef39 100644
85810 --- a/net/ipv4/fib_frontend.c
85811 +++ b/net/ipv4/fib_frontend.c
85812 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
85813 #ifdef CONFIG_IP_ROUTE_MULTIPATH
85814 fib_sync_up(dev);
85815 #endif
85816 - atomic_inc(&net->ipv4.dev_addr_genid);
85817 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85818 rt_cache_flush(dev_net(dev));
85819 break;
85820 case NETDEV_DOWN:
85821 fib_del_ifaddr(ifa, NULL);
85822 - atomic_inc(&net->ipv4.dev_addr_genid);
85823 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85824 if (ifa->ifa_dev->ifa_list == NULL) {
85825 /* Last address was deleted from this interface.
85826 * Disable IP.
85827 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
85828 #ifdef CONFIG_IP_ROUTE_MULTIPATH
85829 fib_sync_up(dev);
85830 #endif
85831 - atomic_inc(&net->ipv4.dev_addr_genid);
85832 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85833 rt_cache_flush(net);
85834 break;
85835 case NETDEV_DOWN:
85836 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
85837 index 4797a80..2bd54e9 100644
85838 --- a/net/ipv4/fib_semantics.c
85839 +++ b/net/ipv4/fib_semantics.c
85840 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
85841 nh->nh_saddr = inet_select_addr(nh->nh_dev,
85842 nh->nh_gw,
85843 nh->nh_parent->fib_scope);
85844 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
85845 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
85846
85847 return nh->nh_saddr;
85848 }
85849 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
85850 index d0670f0..744ac80 100644
85851 --- a/net/ipv4/inet_connection_sock.c
85852 +++ b/net/ipv4/inet_connection_sock.c
85853 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
85854 .range = { 32768, 61000 },
85855 };
85856
85857 -unsigned long *sysctl_local_reserved_ports;
85858 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
85859 EXPORT_SYMBOL(sysctl_local_reserved_ports);
85860
85861 void inet_get_local_port_range(int *low, int *high)
85862 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
85863 index fa3ae81..0dbe6b8 100644
85864 --- a/net/ipv4/inet_hashtables.c
85865 +++ b/net/ipv4/inet_hashtables.c
85866 @@ -18,12 +18,15 @@
85867 #include <linux/sched.h>
85868 #include <linux/slab.h>
85869 #include <linux/wait.h>
85870 +#include <linux/security.h>
85871
85872 #include <net/inet_connection_sock.h>
85873 #include <net/inet_hashtables.h>
85874 #include <net/secure_seq.h>
85875 #include <net/ip.h>
85876
85877 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
85878 +
85879 /*
85880 * Allocate and initialize a new local port bind bucket.
85881 * The bindhash mutex for snum's hash chain must be held here.
85882 @@ -540,6 +543,8 @@ ok:
85883 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
85884 spin_unlock(&head->lock);
85885
85886 + gr_update_task_in_ip_table(current, inet_sk(sk));
85887 +
85888 if (tw) {
85889 inet_twsk_deschedule(tw, death_row);
85890 while (twrefcnt) {
85891 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
85892 index 000e3d2..5472da3 100644
85893 --- a/net/ipv4/inetpeer.c
85894 +++ b/net/ipv4/inetpeer.c
85895 @@ -503,8 +503,8 @@ relookup:
85896 if (p) {
85897 p->daddr = *daddr;
85898 atomic_set(&p->refcnt, 1);
85899 - atomic_set(&p->rid, 0);
85900 - atomic_set(&p->ip_id_count,
85901 + atomic_set_unchecked(&p->rid, 0);
85902 + atomic_set_unchecked(&p->ip_id_count,
85903 (daddr->family == AF_INET) ?
85904 secure_ip_id(daddr->addr.a4) :
85905 secure_ipv6_id(daddr->addr.a6));
85906 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
85907 index a8fc332..4ca4ca65 100644
85908 --- a/net/ipv4/ip_fragment.c
85909 +++ b/net/ipv4/ip_fragment.c
85910 @@ -319,7 +319,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
85911 return 0;
85912
85913 start = qp->rid;
85914 - end = atomic_inc_return(&peer->rid);
85915 + end = atomic_inc_return_unchecked(&peer->rid);
85916 qp->rid = end;
85917
85918 rc = qp->q.fragments && (end - start) > max;
85919 @@ -786,12 +786,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
85920
85921 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85922 {
85923 - struct ctl_table *table;
85924 + ctl_table_no_const *table = NULL;
85925 struct ctl_table_header *hdr;
85926
85927 - table = ip4_frags_ns_ctl_table;
85928 if (!net_eq(net, &init_net)) {
85929 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
85930 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
85931 if (table == NULL)
85932 goto err_alloc;
85933
85934 @@ -802,9 +801,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85935 /* Don't export sysctls to unprivileged users */
85936 if (net->user_ns != &init_user_ns)
85937 table[0].procname = NULL;
85938 - }
85939 + hdr = register_net_sysctl(net, "net/ipv4", table);
85940 + } else
85941 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
85942
85943 - hdr = register_net_sysctl(net, "net/ipv4", table);
85944 if (hdr == NULL)
85945 goto err_reg;
85946
85947 @@ -812,8 +812,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85948 return 0;
85949
85950 err_reg:
85951 - if (!net_eq(net, &init_net))
85952 - kfree(table);
85953 + kfree(table);
85954 err_alloc:
85955 return -ENOMEM;
85956 }
85957 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
85958 index a85062b..2958a9b 100644
85959 --- a/net/ipv4/ip_gre.c
85960 +++ b/net/ipv4/ip_gre.c
85961 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
85962 module_param(log_ecn_error, bool, 0644);
85963 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
85964
85965 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
85966 +static struct rtnl_link_ops ipgre_link_ops;
85967 static int ipgre_tunnel_init(struct net_device *dev);
85968 static void ipgre_tunnel_setup(struct net_device *dev);
85969 static int ipgre_tunnel_bind_dev(struct net_device *dev);
85970 @@ -1753,7 +1753,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
85971 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
85972 };
85973
85974 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
85975 +static struct rtnl_link_ops ipgre_link_ops = {
85976 .kind = "gre",
85977 .maxtype = IFLA_GRE_MAX,
85978 .policy = ipgre_policy,
85979 @@ -1766,7 +1766,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
85980 .fill_info = ipgre_fill_info,
85981 };
85982
85983 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
85984 +static struct rtnl_link_ops ipgre_tap_ops = {
85985 .kind = "gretap",
85986 .maxtype = IFLA_GRE_MAX,
85987 .policy = ipgre_policy,
85988 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
85989 index d9c4f11..02b82db 100644
85990 --- a/net/ipv4/ip_sockglue.c
85991 +++ b/net/ipv4/ip_sockglue.c
85992 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
85993 len = min_t(unsigned int, len, opt->optlen);
85994 if (put_user(len, optlen))
85995 return -EFAULT;
85996 - if (copy_to_user(optval, opt->__data, len))
85997 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
85998 + copy_to_user(optval, opt->__data, len))
85999 return -EFAULT;
86000 return 0;
86001 }
86002 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86003 if (sk->sk_type != SOCK_STREAM)
86004 return -ENOPROTOOPT;
86005
86006 - msg.msg_control = optval;
86007 + msg.msg_control = (void __force_kernel *)optval;
86008 msg.msg_controllen = len;
86009 msg.msg_flags = flags;
86010
86011 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
86012 index c3a4233..1412161 100644
86013 --- a/net/ipv4/ip_vti.c
86014 +++ b/net/ipv4/ip_vti.c
86015 @@ -47,7 +47,7 @@
86016 #define HASH_SIZE 16
86017 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
86018
86019 -static struct rtnl_link_ops vti_link_ops __read_mostly;
86020 +static struct rtnl_link_ops vti_link_ops;
86021
86022 static int vti_net_id __read_mostly;
86023 struct vti_net {
86024 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
86025 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
86026 };
86027
86028 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
86029 +static struct rtnl_link_ops vti_link_ops = {
86030 .kind = "vti",
86031 .maxtype = IFLA_VTI_MAX,
86032 .policy = vti_policy,
86033 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
86034 index 9a46dae..5f793a0 100644
86035 --- a/net/ipv4/ipcomp.c
86036 +++ b/net/ipv4/ipcomp.c
86037 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
86038 return;
86039
86040 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86041 - atomic_inc(&flow_cache_genid);
86042 + atomic_inc_unchecked(&flow_cache_genid);
86043 rt_genid_bump(net);
86044
86045 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
86046 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
86047 index a2e50ae..e152b7c 100644
86048 --- a/net/ipv4/ipconfig.c
86049 +++ b/net/ipv4/ipconfig.c
86050 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
86051
86052 mm_segment_t oldfs = get_fs();
86053 set_fs(get_ds());
86054 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86055 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86056 set_fs(oldfs);
86057 return res;
86058 }
86059 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
86060
86061 mm_segment_t oldfs = get_fs();
86062 set_fs(get_ds());
86063 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86064 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86065 set_fs(oldfs);
86066 return res;
86067 }
86068 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
86069
86070 mm_segment_t oldfs = get_fs();
86071 set_fs(get_ds());
86072 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
86073 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
86074 set_fs(oldfs);
86075 return res;
86076 }
86077 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
86078 index 191fc24..1b3b804 100644
86079 --- a/net/ipv4/ipip.c
86080 +++ b/net/ipv4/ipip.c
86081 @@ -138,7 +138,7 @@ struct ipip_net {
86082 static int ipip_tunnel_init(struct net_device *dev);
86083 static void ipip_tunnel_setup(struct net_device *dev);
86084 static void ipip_dev_free(struct net_device *dev);
86085 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
86086 +static struct rtnl_link_ops ipip_link_ops;
86087
86088 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
86089 struct rtnl_link_stats64 *tot)
86090 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
86091 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
86092 };
86093
86094 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
86095 +static struct rtnl_link_ops ipip_link_ops = {
86096 .kind = "ipip",
86097 .maxtype = IFLA_IPTUN_MAX,
86098 .policy = ipip_policy,
86099 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
86100 index 3ea4127..849297b 100644
86101 --- a/net/ipv4/netfilter/arp_tables.c
86102 +++ b/net/ipv4/netfilter/arp_tables.c
86103 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
86104 #endif
86105
86106 static int get_info(struct net *net, void __user *user,
86107 - const int *len, int compat)
86108 + int len, int compat)
86109 {
86110 char name[XT_TABLE_MAXNAMELEN];
86111 struct xt_table *t;
86112 int ret;
86113
86114 - if (*len != sizeof(struct arpt_getinfo)) {
86115 - duprintf("length %u != %Zu\n", *len,
86116 + if (len != sizeof(struct arpt_getinfo)) {
86117 + duprintf("length %u != %Zu\n", len,
86118 sizeof(struct arpt_getinfo));
86119 return -EINVAL;
86120 }
86121 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
86122 info.size = private->size;
86123 strcpy(info.name, name);
86124
86125 - if (copy_to_user(user, &info, *len) != 0)
86126 + if (copy_to_user(user, &info, len) != 0)
86127 ret = -EFAULT;
86128 else
86129 ret = 0;
86130 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
86131
86132 switch (cmd) {
86133 case ARPT_SO_GET_INFO:
86134 - ret = get_info(sock_net(sk), user, len, 1);
86135 + ret = get_info(sock_net(sk), user, *len, 1);
86136 break;
86137 case ARPT_SO_GET_ENTRIES:
86138 ret = compat_get_entries(sock_net(sk), user, len);
86139 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
86140
86141 switch (cmd) {
86142 case ARPT_SO_GET_INFO:
86143 - ret = get_info(sock_net(sk), user, len, 0);
86144 + ret = get_info(sock_net(sk), user, *len, 0);
86145 break;
86146
86147 case ARPT_SO_GET_ENTRIES:
86148 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
86149 index 17c5e06..1b91206 100644
86150 --- a/net/ipv4/netfilter/ip_tables.c
86151 +++ b/net/ipv4/netfilter/ip_tables.c
86152 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
86153 #endif
86154
86155 static int get_info(struct net *net, void __user *user,
86156 - const int *len, int compat)
86157 + int len, int compat)
86158 {
86159 char name[XT_TABLE_MAXNAMELEN];
86160 struct xt_table *t;
86161 int ret;
86162
86163 - if (*len != sizeof(struct ipt_getinfo)) {
86164 - duprintf("length %u != %zu\n", *len,
86165 + if (len != sizeof(struct ipt_getinfo)) {
86166 + duprintf("length %u != %zu\n", len,
86167 sizeof(struct ipt_getinfo));
86168 return -EINVAL;
86169 }
86170 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
86171 info.size = private->size;
86172 strcpy(info.name, name);
86173
86174 - if (copy_to_user(user, &info, *len) != 0)
86175 + if (copy_to_user(user, &info, len) != 0)
86176 ret = -EFAULT;
86177 else
86178 ret = 0;
86179 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86180
86181 switch (cmd) {
86182 case IPT_SO_GET_INFO:
86183 - ret = get_info(sock_net(sk), user, len, 1);
86184 + ret = get_info(sock_net(sk), user, *len, 1);
86185 break;
86186 case IPT_SO_GET_ENTRIES:
86187 ret = compat_get_entries(sock_net(sk), user, len);
86188 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86189
86190 switch (cmd) {
86191 case IPT_SO_GET_INFO:
86192 - ret = get_info(sock_net(sk), user, len, 0);
86193 + ret = get_info(sock_net(sk), user, *len, 0);
86194 break;
86195
86196 case IPT_SO_GET_ENTRIES:
86197 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
86198 index dc454cc..5bb917f 100644
86199 --- a/net/ipv4/ping.c
86200 +++ b/net/ipv4/ping.c
86201 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
86202 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86203 0, sock_i_ino(sp),
86204 atomic_read(&sp->sk_refcnt), sp,
86205 - atomic_read(&sp->sk_drops), len);
86206 + atomic_read_unchecked(&sp->sk_drops), len);
86207 }
86208
86209 static int ping_seq_show(struct seq_file *seq, void *v)
86210 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
86211 index 6f08991..55867ad 100644
86212 --- a/net/ipv4/raw.c
86213 +++ b/net/ipv4/raw.c
86214 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
86215 int raw_rcv(struct sock *sk, struct sk_buff *skb)
86216 {
86217 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
86218 - atomic_inc(&sk->sk_drops);
86219 + atomic_inc_unchecked(&sk->sk_drops);
86220 kfree_skb(skb);
86221 return NET_RX_DROP;
86222 }
86223 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
86224
86225 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
86226 {
86227 + struct icmp_filter filter;
86228 +
86229 if (optlen > sizeof(struct icmp_filter))
86230 optlen = sizeof(struct icmp_filter);
86231 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
86232 + if (copy_from_user(&filter, optval, optlen))
86233 return -EFAULT;
86234 + raw_sk(sk)->filter = filter;
86235 return 0;
86236 }
86237
86238 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
86239 {
86240 int len, ret = -EFAULT;
86241 + struct icmp_filter filter;
86242
86243 if (get_user(len, optlen))
86244 goto out;
86245 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
86246 if (len > sizeof(struct icmp_filter))
86247 len = sizeof(struct icmp_filter);
86248 ret = -EFAULT;
86249 - if (put_user(len, optlen) ||
86250 - copy_to_user(optval, &raw_sk(sk)->filter, len))
86251 + filter = raw_sk(sk)->filter;
86252 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
86253 goto out;
86254 ret = 0;
86255 out: return ret;
86256 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
86257 0, 0L, 0,
86258 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
86259 0, sock_i_ino(sp),
86260 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
86261 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
86262 }
86263
86264 static int raw_seq_show(struct seq_file *seq, void *v)
86265 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
86266 index a0fcc47..32e2c89 100644
86267 --- a/net/ipv4/route.c
86268 +++ b/net/ipv4/route.c
86269 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
86270 .maxlen = sizeof(int),
86271 .mode = 0200,
86272 .proc_handler = ipv4_sysctl_rtcache_flush,
86273 + .extra1 = &init_net,
86274 },
86275 { },
86276 };
86277
86278 static __net_init int sysctl_route_net_init(struct net *net)
86279 {
86280 - struct ctl_table *tbl;
86281 + ctl_table_no_const *tbl = NULL;
86282
86283 - tbl = ipv4_route_flush_table;
86284 if (!net_eq(net, &init_net)) {
86285 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86286 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
86287 if (tbl == NULL)
86288 goto err_dup;
86289
86290 /* Don't export sysctls to unprivileged users */
86291 if (net->user_ns != &init_user_ns)
86292 tbl[0].procname = NULL;
86293 - }
86294 - tbl[0].extra1 = net;
86295 + tbl[0].extra1 = net;
86296 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86297 + } else
86298 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
86299
86300 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86301 if (net->ipv4.route_hdr == NULL)
86302 goto err_reg;
86303 return 0;
86304
86305 err_reg:
86306 - if (tbl != ipv4_route_flush_table)
86307 - kfree(tbl);
86308 + kfree(tbl);
86309 err_dup:
86310 return -ENOMEM;
86311 }
86312 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
86313
86314 static __net_init int rt_genid_init(struct net *net)
86315 {
86316 - atomic_set(&net->rt_genid, 0);
86317 + atomic_set_unchecked(&net->rt_genid, 0);
86318 get_random_bytes(&net->ipv4.dev_addr_genid,
86319 sizeof(net->ipv4.dev_addr_genid));
86320 return 0;
86321 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
86322 index d84400b..62e066e 100644
86323 --- a/net/ipv4/sysctl_net_ipv4.c
86324 +++ b/net/ipv4/sysctl_net_ipv4.c
86325 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
86326 {
86327 int ret;
86328 int range[2];
86329 - ctl_table tmp = {
86330 + ctl_table_no_const tmp = {
86331 .data = &range,
86332 .maxlen = sizeof(range),
86333 .mode = table->mode,
86334 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
86335 int ret;
86336 gid_t urange[2];
86337 kgid_t low, high;
86338 - ctl_table tmp = {
86339 + ctl_table_no_const tmp = {
86340 .data = &urange,
86341 .maxlen = sizeof(urange),
86342 .mode = table->mode,
86343 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
86344 void __user *buffer, size_t *lenp, loff_t *ppos)
86345 {
86346 char val[TCP_CA_NAME_MAX];
86347 - ctl_table tbl = {
86348 + ctl_table_no_const tbl = {
86349 .data = val,
86350 .maxlen = TCP_CA_NAME_MAX,
86351 };
86352 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
86353 void __user *buffer, size_t *lenp,
86354 loff_t *ppos)
86355 {
86356 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
86357 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
86358 int ret;
86359
86360 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86361 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
86362 void __user *buffer, size_t *lenp,
86363 loff_t *ppos)
86364 {
86365 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
86366 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
86367 int ret;
86368
86369 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86370 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86371 struct mem_cgroup *memcg;
86372 #endif
86373
86374 - ctl_table tmp = {
86375 + ctl_table_no_const tmp = {
86376 .data = &vec,
86377 .maxlen = sizeof(vec),
86378 .mode = ctl->mode,
86379 };
86380
86381 if (!write) {
86382 - ctl->data = &net->ipv4.sysctl_tcp_mem;
86383 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
86384 + ctl_table_no_const tcp_mem = *ctl;
86385 +
86386 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
86387 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
86388 }
86389
86390 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
86391 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86392 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
86393 size_t *lenp, loff_t *ppos)
86394 {
86395 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86396 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86397 struct tcp_fastopen_context *ctxt;
86398 int ret;
86399 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
86400 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
86401 },
86402 {
86403 .procname = "ip_local_reserved_ports",
86404 - .data = NULL, /* initialized in sysctl_ipv4_init */
86405 + .data = sysctl_local_reserved_ports,
86406 .maxlen = 65536,
86407 .mode = 0644,
86408 .proc_handler = proc_do_large_bitmap,
86409 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
86410
86411 static __net_init int ipv4_sysctl_init_net(struct net *net)
86412 {
86413 - struct ctl_table *table;
86414 + ctl_table_no_const *table = NULL;
86415
86416 - table = ipv4_net_table;
86417 if (!net_eq(net, &init_net)) {
86418 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
86419 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
86420 if (table == NULL)
86421 goto err_alloc;
86422
86423 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
86424
86425 tcp_init_mem(net);
86426
86427 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86428 + if (!net_eq(net, &init_net))
86429 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86430 + else
86431 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
86432 if (net->ipv4.ipv4_hdr == NULL)
86433 goto err_reg;
86434
86435 return 0;
86436
86437 err_reg:
86438 - if (!net_eq(net, &init_net))
86439 - kfree(table);
86440 + kfree(table);
86441 err_alloc:
86442 return -ENOMEM;
86443 }
86444 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
86445 static __init int sysctl_ipv4_init(void)
86446 {
86447 struct ctl_table_header *hdr;
86448 - struct ctl_table *i;
86449 -
86450 - for (i = ipv4_table; i->procname; i++) {
86451 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
86452 - i->data = sysctl_local_reserved_ports;
86453 - break;
86454 - }
86455 - }
86456 - if (!i->procname)
86457 - return -EINVAL;
86458
86459 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
86460 if (hdr == NULL)
86461 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
86462 index 66702d3..31ff8f9 100644
86463 --- a/net/ipv4/tcp_input.c
86464 +++ b/net/ipv4/tcp_input.c
86465 @@ -4733,7 +4733,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
86466 * simplifies code)
86467 */
86468 static void
86469 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86470 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86471 struct sk_buff *head, struct sk_buff *tail,
86472 u32 start, u32 end)
86473 {
86474 @@ -5850,6 +5850,7 @@ discard:
86475 tcp_paws_reject(&tp->rx_opt, 0))
86476 goto discard_and_undo;
86477
86478 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
86479 if (th->syn) {
86480 /* We see SYN without ACK. It is attempt of
86481 * simultaneous connect with crossed SYNs.
86482 @@ -5900,6 +5901,7 @@ discard:
86483 goto discard;
86484 #endif
86485 }
86486 +#endif
86487 /* "fifth, if neither of the SYN or RST bits is set then
86488 * drop the segment and return."
86489 */
86490 @@ -5944,7 +5946,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
86491 goto discard;
86492
86493 if (th->syn) {
86494 - if (th->fin)
86495 + if (th->fin || th->urg || th->psh)
86496 goto discard;
86497 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
86498 return 1;
86499 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
86500 index d9130a9..00328ff 100644
86501 --- a/net/ipv4/tcp_ipv4.c
86502 +++ b/net/ipv4/tcp_ipv4.c
86503 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
86504 EXPORT_SYMBOL(sysctl_tcp_low_latency);
86505
86506
86507 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86508 +extern int grsec_enable_blackhole;
86509 +#endif
86510 +
86511 #ifdef CONFIG_TCP_MD5SIG
86512 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
86513 __be32 daddr, __be32 saddr, const struct tcphdr *th);
86514 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
86515 return 0;
86516
86517 reset:
86518 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86519 + if (!grsec_enable_blackhole)
86520 +#endif
86521 tcp_v4_send_reset(rsk, skb);
86522 discard:
86523 kfree_skb(skb);
86524 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
86525 TCP_SKB_CB(skb)->sacked = 0;
86526
86527 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
86528 - if (!sk)
86529 + if (!sk) {
86530 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86531 + ret = 1;
86532 +#endif
86533 goto no_tcp_socket;
86534 -
86535 + }
86536 process:
86537 - if (sk->sk_state == TCP_TIME_WAIT)
86538 + if (sk->sk_state == TCP_TIME_WAIT) {
86539 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86540 + ret = 2;
86541 +#endif
86542 goto do_time_wait;
86543 + }
86544
86545 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
86546 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
86547 @@ -2050,6 +2064,10 @@ no_tcp_socket:
86548 bad_packet:
86549 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
86550 } else {
86551 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86552 + if (!grsec_enable_blackhole || (ret == 1 &&
86553 + (skb->dev->flags & IFF_LOOPBACK)))
86554 +#endif
86555 tcp_v4_send_reset(NULL, skb);
86556 }
86557
86558 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
86559 index f35f2df..ccb5ca6 100644
86560 --- a/net/ipv4/tcp_minisocks.c
86561 +++ b/net/ipv4/tcp_minisocks.c
86562 @@ -27,6 +27,10 @@
86563 #include <net/inet_common.h>
86564 #include <net/xfrm.h>
86565
86566 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86567 +extern int grsec_enable_blackhole;
86568 +#endif
86569 +
86570 int sysctl_tcp_syncookies __read_mostly = 1;
86571 EXPORT_SYMBOL(sysctl_tcp_syncookies);
86572
86573 @@ -742,7 +746,10 @@ embryonic_reset:
86574 * avoid becoming vulnerable to outside attack aiming at
86575 * resetting legit local connections.
86576 */
86577 - req->rsk_ops->send_reset(sk, skb);
86578 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86579 + if (!grsec_enable_blackhole)
86580 +#endif
86581 + req->rsk_ops->send_reset(sk, skb);
86582 } else if (fastopen) { /* received a valid RST pkt */
86583 reqsk_fastopen_remove(sk, req, true);
86584 tcp_reset(sk);
86585 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
86586 index 4526fe6..1a34e43 100644
86587 --- a/net/ipv4/tcp_probe.c
86588 +++ b/net/ipv4/tcp_probe.c
86589 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
86590 if (cnt + width >= len)
86591 break;
86592
86593 - if (copy_to_user(buf + cnt, tbuf, width))
86594 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
86595 return -EFAULT;
86596 cnt += width;
86597 }
86598 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
86599 index b78aac3..e18230b 100644
86600 --- a/net/ipv4/tcp_timer.c
86601 +++ b/net/ipv4/tcp_timer.c
86602 @@ -22,6 +22,10 @@
86603 #include <linux/gfp.h>
86604 #include <net/tcp.h>
86605
86606 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86607 +extern int grsec_lastack_retries;
86608 +#endif
86609 +
86610 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
86611 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
86612 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
86613 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
86614 }
86615 }
86616
86617 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86618 + if ((sk->sk_state == TCP_LAST_ACK) &&
86619 + (grsec_lastack_retries > 0) &&
86620 + (grsec_lastack_retries < retry_until))
86621 + retry_until = grsec_lastack_retries;
86622 +#endif
86623 +
86624 if (retransmits_timed_out(sk, retry_until,
86625 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
86626 /* Has it gone just too far? */
86627 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
86628 index 1f4d405..3524677 100644
86629 --- a/net/ipv4/udp.c
86630 +++ b/net/ipv4/udp.c
86631 @@ -87,6 +87,7 @@
86632 #include <linux/types.h>
86633 #include <linux/fcntl.h>
86634 #include <linux/module.h>
86635 +#include <linux/security.h>
86636 #include <linux/socket.h>
86637 #include <linux/sockios.h>
86638 #include <linux/igmp.h>
86639 @@ -111,6 +112,10 @@
86640 #include <trace/events/skb.h>
86641 #include "udp_impl.h"
86642
86643 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86644 +extern int grsec_enable_blackhole;
86645 +#endif
86646 +
86647 struct udp_table udp_table __read_mostly;
86648 EXPORT_SYMBOL(udp_table);
86649
86650 @@ -569,6 +574,9 @@ found:
86651 return s;
86652 }
86653
86654 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
86655 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
86656 +
86657 /*
86658 * This routine is called by the ICMP module when it gets some
86659 * sort of error condition. If err < 0 then the socket should
86660 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
86661 dport = usin->sin_port;
86662 if (dport == 0)
86663 return -EINVAL;
86664 +
86665 + err = gr_search_udp_sendmsg(sk, usin);
86666 + if (err)
86667 + return err;
86668 } else {
86669 if (sk->sk_state != TCP_ESTABLISHED)
86670 return -EDESTADDRREQ;
86671 +
86672 + err = gr_search_udp_sendmsg(sk, NULL);
86673 + if (err)
86674 + return err;
86675 +
86676 daddr = inet->inet_daddr;
86677 dport = inet->inet_dport;
86678 /* Open fast path for connected socket.
86679 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
86680 udp_lib_checksum_complete(skb)) {
86681 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
86682 IS_UDPLITE(sk));
86683 - atomic_inc(&sk->sk_drops);
86684 + atomic_inc_unchecked(&sk->sk_drops);
86685 __skb_unlink(skb, rcvq);
86686 __skb_queue_tail(&list_kill, skb);
86687 }
86688 @@ -1194,6 +1211,10 @@ try_again:
86689 if (!skb)
86690 goto out;
86691
86692 + err = gr_search_udp_recvmsg(sk, skb);
86693 + if (err)
86694 + goto out_free;
86695 +
86696 ulen = skb->len - sizeof(struct udphdr);
86697 copied = len;
86698 if (copied > ulen)
86699 @@ -1227,7 +1248,7 @@ try_again:
86700 if (unlikely(err)) {
86701 trace_kfree_skb(skb, udp_recvmsg);
86702 if (!peeked) {
86703 - atomic_inc(&sk->sk_drops);
86704 + atomic_inc_unchecked(&sk->sk_drops);
86705 UDP_INC_STATS_USER(sock_net(sk),
86706 UDP_MIB_INERRORS, is_udplite);
86707 }
86708 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86709
86710 drop:
86711 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
86712 - atomic_inc(&sk->sk_drops);
86713 + atomic_inc_unchecked(&sk->sk_drops);
86714 kfree_skb(skb);
86715 return -1;
86716 }
86717 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
86718 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
86719
86720 if (!skb1) {
86721 - atomic_inc(&sk->sk_drops);
86722 + atomic_inc_unchecked(&sk->sk_drops);
86723 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
86724 IS_UDPLITE(sk));
86725 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
86726 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
86727 goto csum_error;
86728
86729 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
86730 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86731 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
86732 +#endif
86733 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
86734
86735 /*
86736 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
86737 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86738 0, sock_i_ino(sp),
86739 atomic_read(&sp->sk_refcnt), sp,
86740 - atomic_read(&sp->sk_drops), len);
86741 + atomic_read_unchecked(&sp->sk_drops), len);
86742 }
86743
86744 int udp4_seq_show(struct seq_file *seq, void *v)
86745 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
86746 index 1b5d8cb..ffb0833 100644
86747 --- a/net/ipv6/addrconf.c
86748 +++ b/net/ipv6/addrconf.c
86749 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
86750 p.iph.ihl = 5;
86751 p.iph.protocol = IPPROTO_IPV6;
86752 p.iph.ttl = 64;
86753 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
86754 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
86755
86756 if (ops->ndo_do_ioctl) {
86757 mm_segment_t oldfs = get_fs();
86758 @@ -4388,7 +4388,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
86759 int *valp = ctl->data;
86760 int val = *valp;
86761 loff_t pos = *ppos;
86762 - ctl_table lctl;
86763 + ctl_table_no_const lctl;
86764 int ret;
86765
86766 /*
86767 @@ -4470,7 +4470,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
86768 int *valp = ctl->data;
86769 int val = *valp;
86770 loff_t pos = *ppos;
86771 - ctl_table lctl;
86772 + ctl_table_no_const lctl;
86773 int ret;
86774
86775 /*
86776 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
86777 index fff5bdd..15194fb 100644
86778 --- a/net/ipv6/icmp.c
86779 +++ b/net/ipv6/icmp.c
86780 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
86781
86782 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
86783 {
86784 - struct ctl_table *table;
86785 + ctl_table_no_const *table;
86786
86787 table = kmemdup(ipv6_icmp_table_template,
86788 sizeof(ipv6_icmp_table_template),
86789 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
86790 index 131dd09..f7ed64f 100644
86791 --- a/net/ipv6/ip6_gre.c
86792 +++ b/net/ipv6/ip6_gre.c
86793 @@ -73,7 +73,7 @@ struct ip6gre_net {
86794 struct net_device *fb_tunnel_dev;
86795 };
86796
86797 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
86798 +static struct rtnl_link_ops ip6gre_link_ops;
86799 static int ip6gre_tunnel_init(struct net_device *dev);
86800 static void ip6gre_tunnel_setup(struct net_device *dev);
86801 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
86802 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
86803 }
86804
86805
86806 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
86807 +static struct inet6_protocol ip6gre_protocol = {
86808 .handler = ip6gre_rcv,
86809 .err_handler = ip6gre_err,
86810 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
86811 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
86812 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
86813 };
86814
86815 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
86816 +static struct rtnl_link_ops ip6gre_link_ops = {
86817 .kind = "ip6gre",
86818 .maxtype = IFLA_GRE_MAX,
86819 .policy = ip6gre_policy,
86820 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
86821 .fill_info = ip6gre_fill_info,
86822 };
86823
86824 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
86825 +static struct rtnl_link_ops ip6gre_tap_ops = {
86826 .kind = "ip6gretap",
86827 .maxtype = IFLA_GRE_MAX,
86828 .policy = ip6gre_policy,
86829 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
86830 index a14f28b..b4b8956 100644
86831 --- a/net/ipv6/ip6_tunnel.c
86832 +++ b/net/ipv6/ip6_tunnel.c
86833 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
86834
86835 static int ip6_tnl_dev_init(struct net_device *dev);
86836 static void ip6_tnl_dev_setup(struct net_device *dev);
86837 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
86838 +static struct rtnl_link_ops ip6_link_ops;
86839
86840 static int ip6_tnl_net_id __read_mostly;
86841 struct ip6_tnl_net {
86842 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
86843 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
86844 };
86845
86846 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
86847 +static struct rtnl_link_ops ip6_link_ops = {
86848 .kind = "ip6tnl",
86849 .maxtype = IFLA_IPTUN_MAX,
86850 .policy = ip6_tnl_policy,
86851 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
86852 index d1e2e8e..51c19ae 100644
86853 --- a/net/ipv6/ipv6_sockglue.c
86854 +++ b/net/ipv6/ipv6_sockglue.c
86855 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
86856 if (sk->sk_type != SOCK_STREAM)
86857 return -ENOPROTOOPT;
86858
86859 - msg.msg_control = optval;
86860 + msg.msg_control = (void __force_kernel *)optval;
86861 msg.msg_controllen = len;
86862 msg.msg_flags = flags;
86863
86864 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
86865 index 125a90d..2a11f36 100644
86866 --- a/net/ipv6/netfilter/ip6_tables.c
86867 +++ b/net/ipv6/netfilter/ip6_tables.c
86868 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
86869 #endif
86870
86871 static int get_info(struct net *net, void __user *user,
86872 - const int *len, int compat)
86873 + int len, int compat)
86874 {
86875 char name[XT_TABLE_MAXNAMELEN];
86876 struct xt_table *t;
86877 int ret;
86878
86879 - if (*len != sizeof(struct ip6t_getinfo)) {
86880 - duprintf("length %u != %zu\n", *len,
86881 + if (len != sizeof(struct ip6t_getinfo)) {
86882 + duprintf("length %u != %zu\n", len,
86883 sizeof(struct ip6t_getinfo));
86884 return -EINVAL;
86885 }
86886 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
86887 info.size = private->size;
86888 strcpy(info.name, name);
86889
86890 - if (copy_to_user(user, &info, *len) != 0)
86891 + if (copy_to_user(user, &info, len) != 0)
86892 ret = -EFAULT;
86893 else
86894 ret = 0;
86895 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86896
86897 switch (cmd) {
86898 case IP6T_SO_GET_INFO:
86899 - ret = get_info(sock_net(sk), user, len, 1);
86900 + ret = get_info(sock_net(sk), user, *len, 1);
86901 break;
86902 case IP6T_SO_GET_ENTRIES:
86903 ret = compat_get_entries(sock_net(sk), user, len);
86904 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86905
86906 switch (cmd) {
86907 case IP6T_SO_GET_INFO:
86908 - ret = get_info(sock_net(sk), user, len, 0);
86909 + ret = get_info(sock_net(sk), user, *len, 0);
86910 break;
86911
86912 case IP6T_SO_GET_ENTRIES:
86913 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
86914 index 2f3a018..8bca195 100644
86915 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
86916 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
86917 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
86918
86919 static int nf_ct_frag6_sysctl_register(struct net *net)
86920 {
86921 - struct ctl_table *table;
86922 + ctl_table_no_const *table = NULL;
86923 struct ctl_table_header *hdr;
86924
86925 - table = nf_ct_frag6_sysctl_table;
86926 if (!net_eq(net, &init_net)) {
86927 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
86928 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
86929 GFP_KERNEL);
86930 if (table == NULL)
86931 goto err_alloc;
86932 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
86933 table[0].data = &net->ipv6.frags.high_thresh;
86934 table[1].data = &net->ipv6.frags.low_thresh;
86935 table[2].data = &net->ipv6.frags.timeout;
86936 - }
86937 -
86938 - hdr = register_net_sysctl(net, "net/netfilter", table);
86939 + hdr = register_net_sysctl(net, "net/netfilter", table);
86940 + } else
86941 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
86942 if (hdr == NULL)
86943 goto err_reg;
86944
86945 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
86946 return 0;
86947
86948 err_reg:
86949 - if (!net_eq(net, &init_net))
86950 - kfree(table);
86951 + kfree(table);
86952 err_alloc:
86953 return -ENOMEM;
86954 }
86955 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
86956 index 70fa814..d70c28c 100644
86957 --- a/net/ipv6/raw.c
86958 +++ b/net/ipv6/raw.c
86959 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
86960 {
86961 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
86962 skb_checksum_complete(skb)) {
86963 - atomic_inc(&sk->sk_drops);
86964 + atomic_inc_unchecked(&sk->sk_drops);
86965 kfree_skb(skb);
86966 return NET_RX_DROP;
86967 }
86968 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
86969 struct raw6_sock *rp = raw6_sk(sk);
86970
86971 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
86972 - atomic_inc(&sk->sk_drops);
86973 + atomic_inc_unchecked(&sk->sk_drops);
86974 kfree_skb(skb);
86975 return NET_RX_DROP;
86976 }
86977 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
86978
86979 if (inet->hdrincl) {
86980 if (skb_checksum_complete(skb)) {
86981 - atomic_inc(&sk->sk_drops);
86982 + atomic_inc_unchecked(&sk->sk_drops);
86983 kfree_skb(skb);
86984 return NET_RX_DROP;
86985 }
86986 @@ -604,7 +604,7 @@ out:
86987 return err;
86988 }
86989
86990 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
86991 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
86992 struct flowi6 *fl6, struct dst_entry **dstp,
86993 unsigned int flags)
86994 {
86995 @@ -916,12 +916,15 @@ do_confirm:
86996 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
86997 char __user *optval, int optlen)
86998 {
86999 + struct icmp6_filter filter;
87000 +
87001 switch (optname) {
87002 case ICMPV6_FILTER:
87003 if (optlen > sizeof(struct icmp6_filter))
87004 optlen = sizeof(struct icmp6_filter);
87005 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
87006 + if (copy_from_user(&filter, optval, optlen))
87007 return -EFAULT;
87008 + raw6_sk(sk)->filter = filter;
87009 return 0;
87010 default:
87011 return -ENOPROTOOPT;
87012 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87013 char __user *optval, int __user *optlen)
87014 {
87015 int len;
87016 + struct icmp6_filter filter;
87017
87018 switch (optname) {
87019 case ICMPV6_FILTER:
87020 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87021 len = sizeof(struct icmp6_filter);
87022 if (put_user(len, optlen))
87023 return -EFAULT;
87024 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
87025 + filter = raw6_sk(sk)->filter;
87026 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
87027 return -EFAULT;
87028 return 0;
87029 default:
87030 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87031 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87032 0,
87033 sock_i_ino(sp),
87034 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87035 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87036 }
87037
87038 static int raw6_seq_show(struct seq_file *seq, void *v)
87039 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
87040 index d9ba8a2..f3f9e14 100644
87041 --- a/net/ipv6/reassembly.c
87042 +++ b/net/ipv6/reassembly.c
87043 @@ -608,12 +608,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
87044
87045 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87046 {
87047 - struct ctl_table *table;
87048 + ctl_table_no_const *table = NULL;
87049 struct ctl_table_header *hdr;
87050
87051 - table = ip6_frags_ns_ctl_table;
87052 if (!net_eq(net, &init_net)) {
87053 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87054 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87055 if (table == NULL)
87056 goto err_alloc;
87057
87058 @@ -624,9 +623,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87059 /* Don't export sysctls to unprivileged users */
87060 if (net->user_ns != &init_user_ns)
87061 table[0].procname = NULL;
87062 - }
87063 + hdr = register_net_sysctl(net, "net/ipv6", table);
87064 + } else
87065 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
87066
87067 - hdr = register_net_sysctl(net, "net/ipv6", table);
87068 if (hdr == NULL)
87069 goto err_reg;
87070
87071 @@ -634,8 +634,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87072 return 0;
87073
87074 err_reg:
87075 - if (!net_eq(net, &init_net))
87076 - kfree(table);
87077 + kfree(table);
87078 err_alloc:
87079 return -ENOMEM;
87080 }
87081 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
87082 index 5845613..3af8fc7 100644
87083 --- a/net/ipv6/route.c
87084 +++ b/net/ipv6/route.c
87085 @@ -2966,7 +2966,7 @@ ctl_table ipv6_route_table_template[] = {
87086
87087 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
87088 {
87089 - struct ctl_table *table;
87090 + ctl_table_no_const *table;
87091
87092 table = kmemdup(ipv6_route_table_template,
87093 sizeof(ipv6_route_table_template),
87094 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
87095 index cfba99b..20ca511 100644
87096 --- a/net/ipv6/sit.c
87097 +++ b/net/ipv6/sit.c
87098 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87099 static int ipip6_tunnel_init(struct net_device *dev);
87100 static void ipip6_tunnel_setup(struct net_device *dev);
87101 static void ipip6_dev_free(struct net_device *dev);
87102 -static struct rtnl_link_ops sit_link_ops __read_mostly;
87103 +static struct rtnl_link_ops sit_link_ops;
87104
87105 static int sit_net_id __read_mostly;
87106 struct sit_net {
87107 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
87108 #endif
87109 };
87110
87111 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
87112 +static struct rtnl_link_ops sit_link_ops = {
87113 .kind = "sit",
87114 .maxtype = IFLA_IPTUN_MAX,
87115 .policy = ipip6_policy,
87116 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
87117 index e85c48b..b8268d3 100644
87118 --- a/net/ipv6/sysctl_net_ipv6.c
87119 +++ b/net/ipv6/sysctl_net_ipv6.c
87120 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
87121
87122 static int __net_init ipv6_sysctl_net_init(struct net *net)
87123 {
87124 - struct ctl_table *ipv6_table;
87125 + ctl_table_no_const *ipv6_table;
87126 struct ctl_table *ipv6_route_table;
87127 struct ctl_table *ipv6_icmp_table;
87128 int err;
87129 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
87130 index 8d19346..e47216f 100644
87131 --- a/net/ipv6/tcp_ipv6.c
87132 +++ b/net/ipv6/tcp_ipv6.c
87133 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
87134 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
87135 }
87136
87137 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87138 +extern int grsec_enable_blackhole;
87139 +#endif
87140 +
87141 static void tcp_v6_hash(struct sock *sk)
87142 {
87143 if (sk->sk_state != TCP_CLOSE) {
87144 @@ -1440,6 +1444,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
87145 return 0;
87146
87147 reset:
87148 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87149 + if (!grsec_enable_blackhole)
87150 +#endif
87151 tcp_v6_send_reset(sk, skb);
87152 discard:
87153 if (opt_skb)
87154 @@ -1521,12 +1528,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
87155 TCP_SKB_CB(skb)->sacked = 0;
87156
87157 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87158 - if (!sk)
87159 + if (!sk) {
87160 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87161 + ret = 1;
87162 +#endif
87163 goto no_tcp_socket;
87164 + }
87165
87166 process:
87167 - if (sk->sk_state == TCP_TIME_WAIT)
87168 + if (sk->sk_state == TCP_TIME_WAIT) {
87169 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87170 + ret = 2;
87171 +#endif
87172 goto do_time_wait;
87173 + }
87174
87175 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
87176 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87177 @@ -1575,6 +1590,10 @@ no_tcp_socket:
87178 bad_packet:
87179 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87180 } else {
87181 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87182 + if (!grsec_enable_blackhole || (ret == 1 &&
87183 + (skb->dev->flags & IFF_LOOPBACK)))
87184 +#endif
87185 tcp_v6_send_reset(NULL, skb);
87186 }
87187
87188 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
87189 index fb08329..2d6919e 100644
87190 --- a/net/ipv6/udp.c
87191 +++ b/net/ipv6/udp.c
87192 @@ -51,6 +51,10 @@
87193 #include <trace/events/skb.h>
87194 #include "udp_impl.h"
87195
87196 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87197 +extern int grsec_enable_blackhole;
87198 +#endif
87199 +
87200 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
87201 {
87202 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
87203 @@ -395,7 +399,7 @@ try_again:
87204 if (unlikely(err)) {
87205 trace_kfree_skb(skb, udpv6_recvmsg);
87206 if (!peeked) {
87207 - atomic_inc(&sk->sk_drops);
87208 + atomic_inc_unchecked(&sk->sk_drops);
87209 if (is_udp4)
87210 UDP_INC_STATS_USER(sock_net(sk),
87211 UDP_MIB_INERRORS,
87212 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87213 return rc;
87214 drop:
87215 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87216 - atomic_inc(&sk->sk_drops);
87217 + atomic_inc_unchecked(&sk->sk_drops);
87218 kfree_skb(skb);
87219 return -1;
87220 }
87221 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87222 if (likely(skb1 == NULL))
87223 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87224 if (!skb1) {
87225 - atomic_inc(&sk->sk_drops);
87226 + atomic_inc_unchecked(&sk->sk_drops);
87227 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87228 IS_UDPLITE(sk));
87229 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87230 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87231 goto discard;
87232
87233 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87234 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87235 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87236 +#endif
87237 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
87238
87239 kfree_skb(skb);
87240 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
87241 0,
87242 sock_i_ino(sp),
87243 atomic_read(&sp->sk_refcnt), sp,
87244 - atomic_read(&sp->sk_drops));
87245 + atomic_read_unchecked(&sp->sk_drops));
87246 }
87247
87248 int udp6_seq_show(struct seq_file *seq, void *v)
87249 diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
87250 index b833677..4d04105 100644
87251 --- a/net/irda/af_irda.c
87252 +++ b/net/irda/af_irda.c
87253 @@ -2584,8 +2584,10 @@ bed:
87254 NULL, NULL, NULL);
87255
87256 /* Check if the we got some results */
87257 - if (!self->cachedaddr)
87258 - return -EAGAIN; /* Didn't find any devices */
87259 + if (!self->cachedaddr) {
87260 + err = -EAGAIN; /* Didn't find any devices */
87261 + goto out;
87262 + }
87263 daddr = self->cachedaddr;
87264 /* Cleanup */
87265 self->cachedaddr = 0;
87266 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
87267 index a68c88c..d55b0c5 100644
87268 --- a/net/irda/ircomm/ircomm_tty.c
87269 +++ b/net/irda/ircomm/ircomm_tty.c
87270 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87271 add_wait_queue(&port->open_wait, &wait);
87272
87273 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
87274 - __FILE__, __LINE__, tty->driver->name, port->count);
87275 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87276
87277 spin_lock_irqsave(&port->lock, flags);
87278 if (!tty_hung_up_p(filp)) {
87279 extra_count = 1;
87280 - port->count--;
87281 + atomic_dec(&port->count);
87282 }
87283 spin_unlock_irqrestore(&port->lock, flags);
87284 port->blocked_open++;
87285 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87286 }
87287
87288 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
87289 - __FILE__, __LINE__, tty->driver->name, port->count);
87290 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87291
87292 schedule();
87293 }
87294 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87295 if (extra_count) {
87296 /* ++ is not atomic, so this should be protected - Jean II */
87297 spin_lock_irqsave(&port->lock, flags);
87298 - port->count++;
87299 + atomic_inc(&port->count);
87300 spin_unlock_irqrestore(&port->lock, flags);
87301 }
87302 port->blocked_open--;
87303
87304 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
87305 - __FILE__, __LINE__, tty->driver->name, port->count);
87306 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87307
87308 if (!retval)
87309 port->flags |= ASYNC_NORMAL_ACTIVE;
87310 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
87311
87312 /* ++ is not atomic, so this should be protected - Jean II */
87313 spin_lock_irqsave(&self->port.lock, flags);
87314 - self->port.count++;
87315 + atomic_inc(&self->port.count);
87316 spin_unlock_irqrestore(&self->port.lock, flags);
87317 tty_port_tty_set(&self->port, tty);
87318
87319 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
87320 - self->line, self->port.count);
87321 + self->line, atomic_read(&self->port.count));
87322
87323 /* Not really used by us, but lets do it anyway */
87324 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
87325 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
87326 tty_kref_put(port->tty);
87327 }
87328 port->tty = NULL;
87329 - port->count = 0;
87330 + atomic_set(&port->count, 0);
87331 spin_unlock_irqrestore(&port->lock, flags);
87332
87333 wake_up_interruptible(&port->open_wait);
87334 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
87335 seq_putc(m, '\n');
87336
87337 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
87338 - seq_printf(m, "Open count: %d\n", self->port.count);
87339 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
87340 seq_printf(m, "Max data size: %d\n", self->max_data_size);
87341 seq_printf(m, "Max header size: %d\n", self->max_header_size);
87342
87343 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
87344 index e71e85b..29340a9 100644
87345 --- a/net/irda/iriap.c
87346 +++ b/net/irda/iriap.c
87347 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
87348 /* case CS_ISO_8859_9: */
87349 /* case CS_UNICODE: */
87350 default:
87351 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
87352 - __func__, ias_charset_types[charset]);
87353 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
87354 + __func__, charset,
87355 + charset < ARRAY_SIZE(ias_charset_types) ?
87356 + ias_charset_types[charset] :
87357 + "(unknown)");
87358
87359 /* Aborting, close connection! */
87360 iriap_disconnect_request(self);
87361 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
87362 index cd6f7a9..e63fe89 100644
87363 --- a/net/iucv/af_iucv.c
87364 +++ b/net/iucv/af_iucv.c
87365 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
87366
87367 write_lock_bh(&iucv_sk_list.lock);
87368
87369 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
87370 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87371 while (__iucv_get_sock_by_name(name)) {
87372 sprintf(name, "%08x",
87373 - atomic_inc_return(&iucv_sk_list.autobind_name));
87374 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87375 }
87376
87377 write_unlock_bh(&iucv_sk_list.lock);
87378 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
87379 index df08250..02021fe 100644
87380 --- a/net/iucv/iucv.c
87381 +++ b/net/iucv/iucv.c
87382 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
87383 return NOTIFY_OK;
87384 }
87385
87386 -static struct notifier_block __refdata iucv_cpu_notifier = {
87387 +static struct notifier_block iucv_cpu_notifier = {
87388 .notifier_call = iucv_cpu_notify,
87389 };
87390
87391 diff --git a/net/key/af_key.c b/net/key/af_key.c
87392 index 5b426a6..970032b 100644
87393 --- a/net/key/af_key.c
87394 +++ b/net/key/af_key.c
87395 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
87396 static u32 get_acqseq(void)
87397 {
87398 u32 res;
87399 - static atomic_t acqseq;
87400 + static atomic_unchecked_t acqseq;
87401
87402 do {
87403 - res = atomic_inc_return(&acqseq);
87404 + res = atomic_inc_return_unchecked(&acqseq);
87405 } while (!res);
87406 return res;
87407 }
87408 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
87409 index 0479c64..d031db6 100644
87410 --- a/net/mac80211/cfg.c
87411 +++ b/net/mac80211/cfg.c
87412 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
87413 ret = ieee80211_vif_use_channel(sdata, chandef,
87414 IEEE80211_CHANCTX_EXCLUSIVE);
87415 }
87416 - } else if (local->open_count == local->monitors) {
87417 + } else if (local_read(&local->open_count) == local->monitors) {
87418 local->_oper_channel = chandef->chan;
87419 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
87420 ieee80211_hw_config(local, 0);
87421 @@ -2716,7 +2716,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
87422 else
87423 local->probe_req_reg--;
87424
87425 - if (!local->open_count)
87426 + if (!local_read(&local->open_count))
87427 break;
87428
87429 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
87430 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
87431 index 2ed065c..948177f 100644
87432 --- a/net/mac80211/ieee80211_i.h
87433 +++ b/net/mac80211/ieee80211_i.h
87434 @@ -28,6 +28,7 @@
87435 #include <net/ieee80211_radiotap.h>
87436 #include <net/cfg80211.h>
87437 #include <net/mac80211.h>
87438 +#include <asm/local.h>
87439 #include "key.h"
87440 #include "sta_info.h"
87441 #include "debug.h"
87442 @@ -909,7 +910,7 @@ struct ieee80211_local {
87443 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
87444 spinlock_t queue_stop_reason_lock;
87445
87446 - int open_count;
87447 + local_t open_count;
87448 int monitors, cooked_mntrs;
87449 /* number of interfaces with corresponding FIF_ flags */
87450 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
87451 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
87452 index 8be854e..ad72a69 100644
87453 --- a/net/mac80211/iface.c
87454 +++ b/net/mac80211/iface.c
87455 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87456 break;
87457 }
87458
87459 - if (local->open_count == 0) {
87460 + if (local_read(&local->open_count) == 0) {
87461 res = drv_start(local);
87462 if (res)
87463 goto err_del_bss;
87464 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87465 break;
87466 }
87467
87468 - if (local->monitors == 0 && local->open_count == 0) {
87469 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
87470 res = ieee80211_add_virtual_monitor(local);
87471 if (res)
87472 goto err_stop;
87473 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87474 mutex_unlock(&local->mtx);
87475
87476 if (coming_up)
87477 - local->open_count++;
87478 + local_inc(&local->open_count);
87479
87480 if (hw_reconf_flags)
87481 ieee80211_hw_config(local, hw_reconf_flags);
87482 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87483 err_del_interface:
87484 drv_remove_interface(local, sdata);
87485 err_stop:
87486 - if (!local->open_count)
87487 + if (!local_read(&local->open_count))
87488 drv_stop(local);
87489 err_del_bss:
87490 sdata->bss = NULL;
87491 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87492 }
87493
87494 if (going_down)
87495 - local->open_count--;
87496 + local_dec(&local->open_count);
87497
87498 switch (sdata->vif.type) {
87499 case NL80211_IFTYPE_AP_VLAN:
87500 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87501
87502 ieee80211_recalc_ps(local, -1);
87503
87504 - if (local->open_count == 0) {
87505 + if (local_read(&local->open_count) == 0) {
87506 if (local->ops->napi_poll)
87507 napi_disable(&local->napi);
87508 ieee80211_clear_tx_pending(local);
87509 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87510 }
87511 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
87512
87513 - if (local->monitors == local->open_count && local->monitors > 0)
87514 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
87515 ieee80211_add_virtual_monitor(local);
87516 }
87517
87518 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
87519 index 1b087ff..bf600e9 100644
87520 --- a/net/mac80211/main.c
87521 +++ b/net/mac80211/main.c
87522 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
87523 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
87524 IEEE80211_CONF_CHANGE_POWER);
87525
87526 - if (changed && local->open_count) {
87527 + if (changed && local_read(&local->open_count)) {
87528 ret = drv_config(local, changed);
87529 /*
87530 * Goal:
87531 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
87532 index 79a48f3..5e185c9 100644
87533 --- a/net/mac80211/pm.c
87534 +++ b/net/mac80211/pm.c
87535 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87536 struct sta_info *sta;
87537 struct ieee80211_chanctx *ctx;
87538
87539 - if (!local->open_count)
87540 + if (!local_read(&local->open_count))
87541 goto suspend;
87542
87543 ieee80211_scan_cancel(local);
87544 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87545 cancel_work_sync(&local->dynamic_ps_enable_work);
87546 del_timer_sync(&local->dynamic_ps_timer);
87547
87548 - local->wowlan = wowlan && local->open_count;
87549 + local->wowlan = wowlan && local_read(&local->open_count);
87550 if (local->wowlan) {
87551 int err = drv_suspend(local, wowlan);
87552 if (err < 0) {
87553 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87554 mutex_unlock(&local->chanctx_mtx);
87555
87556 /* stop hardware - this must stop RX */
87557 - if (local->open_count)
87558 + if (local_read(&local->open_count))
87559 ieee80211_stop_device(local);
87560
87561 suspend:
87562 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
87563 index dd88381..eef4dd6 100644
87564 --- a/net/mac80211/rate.c
87565 +++ b/net/mac80211/rate.c
87566 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
87567
87568 ASSERT_RTNL();
87569
87570 - if (local->open_count)
87571 + if (local_read(&local->open_count))
87572 return -EBUSY;
87573
87574 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
87575 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
87576 index c97a065..ff61928 100644
87577 --- a/net/mac80211/rc80211_pid_debugfs.c
87578 +++ b/net/mac80211/rc80211_pid_debugfs.c
87579 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
87580
87581 spin_unlock_irqrestore(&events->lock, status);
87582
87583 - if (copy_to_user(buf, pb, p))
87584 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
87585 return -EFAULT;
87586
87587 return p;
87588 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
87589 index f11e8c5..08d0013 100644
87590 --- a/net/mac80211/util.c
87591 +++ b/net/mac80211/util.c
87592 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
87593 }
87594 #endif
87595 /* everything else happens only if HW was up & running */
87596 - if (!local->open_count)
87597 + if (!local_read(&local->open_count))
87598 goto wake_up;
87599
87600 /*
87601 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
87602 index 49e96df..63a51c3 100644
87603 --- a/net/netfilter/Kconfig
87604 +++ b/net/netfilter/Kconfig
87605 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
87606
87607 To compile it as a module, choose M here. If unsure, say N.
87608
87609 +config NETFILTER_XT_MATCH_GRADM
87610 + tristate '"gradm" match support'
87611 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
87612 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
87613 + ---help---
87614 + The gradm match allows to match on grsecurity RBAC being enabled.
87615 + It is useful when iptables rules are applied early on bootup to
87616 + prevent connections to the machine (except from a trusted host)
87617 + while the RBAC system is disabled.
87618 +
87619 config NETFILTER_XT_MATCH_HASHLIMIT
87620 tristate '"hashlimit" match support'
87621 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
87622 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
87623 index 3259697..54d5393 100644
87624 --- a/net/netfilter/Makefile
87625 +++ b/net/netfilter/Makefile
87626 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
87627 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
87628 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
87629 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
87630 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
87631 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
87632 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
87633 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
87634 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
87635 index 6d6d8f2..a676749 100644
87636 --- a/net/netfilter/ipset/ip_set_core.c
87637 +++ b/net/netfilter/ipset/ip_set_core.c
87638 @@ -1800,7 +1800,7 @@ done:
87639 return ret;
87640 }
87641
87642 -static struct nf_sockopt_ops so_set __read_mostly = {
87643 +static struct nf_sockopt_ops so_set = {
87644 .pf = PF_INET,
87645 .get_optmin = SO_IP_SET,
87646 .get_optmax = SO_IP_SET + 1,
87647 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
87648 index 30e764a..c3b6a9d 100644
87649 --- a/net/netfilter/ipvs/ip_vs_conn.c
87650 +++ b/net/netfilter/ipvs/ip_vs_conn.c
87651 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
87652 /* Increase the refcnt counter of the dest */
87653 atomic_inc(&dest->refcnt);
87654
87655 - conn_flags = atomic_read(&dest->conn_flags);
87656 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
87657 if (cp->protocol != IPPROTO_UDP)
87658 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
87659 flags = cp->flags;
87660 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
87661 atomic_set(&cp->refcnt, 1);
87662
87663 atomic_set(&cp->n_control, 0);
87664 - atomic_set(&cp->in_pkts, 0);
87665 + atomic_set_unchecked(&cp->in_pkts, 0);
87666
87667 atomic_inc(&ipvs->conn_count);
87668 if (flags & IP_VS_CONN_F_NO_CPORT)
87669 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
87670
87671 /* Don't drop the entry if its number of incoming packets is not
87672 located in [0, 8] */
87673 - i = atomic_read(&cp->in_pkts);
87674 + i = atomic_read_unchecked(&cp->in_pkts);
87675 if (i > 8 || i < 0) return 0;
87676
87677 if (!todrop_rate[i]) return 0;
87678 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
87679 index 47edf5a..235b07d 100644
87680 --- a/net/netfilter/ipvs/ip_vs_core.c
87681 +++ b/net/netfilter/ipvs/ip_vs_core.c
87682 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
87683 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
87684 /* do not touch skb anymore */
87685
87686 - atomic_inc(&cp->in_pkts);
87687 + atomic_inc_unchecked(&cp->in_pkts);
87688 ip_vs_conn_put(cp);
87689 return ret;
87690 }
87691 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
87692 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
87693 pkts = sysctl_sync_threshold(ipvs);
87694 else
87695 - pkts = atomic_add_return(1, &cp->in_pkts);
87696 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87697
87698 if (ipvs->sync_state & IP_VS_STATE_MASTER)
87699 ip_vs_sync_conn(net, cp, pkts);
87700 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
87701 index ec664cb..7f34a77 100644
87702 --- a/net/netfilter/ipvs/ip_vs_ctl.c
87703 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
87704 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
87705 ip_vs_rs_hash(ipvs, dest);
87706 write_unlock_bh(&ipvs->rs_lock);
87707 }
87708 - atomic_set(&dest->conn_flags, conn_flags);
87709 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
87710
87711 /* bind the service */
87712 if (!dest->svc) {
87713 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
87714 * align with netns init in ip_vs_control_net_init()
87715 */
87716
87717 -static struct ctl_table vs_vars[] = {
87718 +static ctl_table_no_const vs_vars[] __read_only = {
87719 {
87720 .procname = "amemthresh",
87721 .maxlen = sizeof(int),
87722 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
87723 " %-7s %-6d %-10d %-10d\n",
87724 &dest->addr.in6,
87725 ntohs(dest->port),
87726 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
87727 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
87728 atomic_read(&dest->weight),
87729 atomic_read(&dest->activeconns),
87730 atomic_read(&dest->inactconns));
87731 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
87732 "%-7s %-6d %-10d %-10d\n",
87733 ntohl(dest->addr.ip),
87734 ntohs(dest->port),
87735 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
87736 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
87737 atomic_read(&dest->weight),
87738 atomic_read(&dest->activeconns),
87739 atomic_read(&dest->inactconns));
87740 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
87741
87742 entry.addr = dest->addr.ip;
87743 entry.port = dest->port;
87744 - entry.conn_flags = atomic_read(&dest->conn_flags);
87745 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
87746 entry.weight = atomic_read(&dest->weight);
87747 entry.u_threshold = dest->u_threshold;
87748 entry.l_threshold = dest->l_threshold;
87749 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
87750 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
87751 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
87752 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
87753 - (atomic_read(&dest->conn_flags) &
87754 + (atomic_read_unchecked(&dest->conn_flags) &
87755 IP_VS_CONN_F_FWD_MASK)) ||
87756 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
87757 atomic_read(&dest->weight)) ||
87758 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
87759 {
87760 int idx;
87761 struct netns_ipvs *ipvs = net_ipvs(net);
87762 - struct ctl_table *tbl;
87763 + ctl_table_no_const *tbl;
87764
87765 atomic_set(&ipvs->dropentry, 0);
87766 spin_lock_init(&ipvs->dropentry_lock);
87767 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
87768 index fdd89b9..bd96aa9 100644
87769 --- a/net/netfilter/ipvs/ip_vs_lblc.c
87770 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
87771 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
87772 * IPVS LBLC sysctl table
87773 */
87774 #ifdef CONFIG_SYSCTL
87775 -static ctl_table vs_vars_table[] = {
87776 +static ctl_table_no_const vs_vars_table[] __read_only = {
87777 {
87778 .procname = "lblc_expiration",
87779 .data = NULL,
87780 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
87781 index c03b6a3..8ce3681 100644
87782 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
87783 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
87784 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
87785 * IPVS LBLCR sysctl table
87786 */
87787
87788 -static ctl_table vs_vars_table[] = {
87789 +static ctl_table_no_const vs_vars_table[] __read_only = {
87790 {
87791 .procname = "lblcr_expiration",
87792 .data = NULL,
87793 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
87794 index 44fd10c..2a163b3 100644
87795 --- a/net/netfilter/ipvs/ip_vs_sync.c
87796 +++ b/net/netfilter/ipvs/ip_vs_sync.c
87797 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
87798 cp = cp->control;
87799 if (cp) {
87800 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
87801 - pkts = atomic_add_return(1, &cp->in_pkts);
87802 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87803 else
87804 pkts = sysctl_sync_threshold(ipvs);
87805 ip_vs_sync_conn(net, cp->control, pkts);
87806 @@ -758,7 +758,7 @@ control:
87807 if (!cp)
87808 return;
87809 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
87810 - pkts = atomic_add_return(1, &cp->in_pkts);
87811 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87812 else
87813 pkts = sysctl_sync_threshold(ipvs);
87814 goto sloop;
87815 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
87816
87817 if (opt)
87818 memcpy(&cp->in_seq, opt, sizeof(*opt));
87819 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
87820 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
87821 cp->state = state;
87822 cp->old_state = cp->state;
87823 /*
87824 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
87825 index ee6b7a9..f9a89f6 100644
87826 --- a/net/netfilter/ipvs/ip_vs_xmit.c
87827 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
87828 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
87829 else
87830 rc = NF_ACCEPT;
87831 /* do not touch skb anymore */
87832 - atomic_inc(&cp->in_pkts);
87833 + atomic_inc_unchecked(&cp->in_pkts);
87834 goto out;
87835 }
87836
87837 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
87838 else
87839 rc = NF_ACCEPT;
87840 /* do not touch skb anymore */
87841 - atomic_inc(&cp->in_pkts);
87842 + atomic_inc_unchecked(&cp->in_pkts);
87843 goto out;
87844 }
87845
87846 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
87847 index 7df424e..a527b02 100644
87848 --- a/net/netfilter/nf_conntrack_acct.c
87849 +++ b/net/netfilter/nf_conntrack_acct.c
87850 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
87851 #ifdef CONFIG_SYSCTL
87852 static int nf_conntrack_acct_init_sysctl(struct net *net)
87853 {
87854 - struct ctl_table *table;
87855 + ctl_table_no_const *table;
87856
87857 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
87858 GFP_KERNEL);
87859 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
87860 index e4a0c4f..c263f28 100644
87861 --- a/net/netfilter/nf_conntrack_core.c
87862 +++ b/net/netfilter/nf_conntrack_core.c
87863 @@ -1529,6 +1529,10 @@ err_extend:
87864 #define DYING_NULLS_VAL ((1<<30)+1)
87865 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
87866
87867 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87868 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
87869 +#endif
87870 +
87871 static int nf_conntrack_init_net(struct net *net)
87872 {
87873 int ret;
87874 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
87875 goto err_stat;
87876 }
87877
87878 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87879 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
87880 +#else
87881 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
87882 +#endif
87883 if (!net->ct.slabname) {
87884 ret = -ENOMEM;
87885 goto err_slabname;
87886 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
87887 index faa978f..1afb18f 100644
87888 --- a/net/netfilter/nf_conntrack_ecache.c
87889 +++ b/net/netfilter/nf_conntrack_ecache.c
87890 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
87891 #ifdef CONFIG_SYSCTL
87892 static int nf_conntrack_event_init_sysctl(struct net *net)
87893 {
87894 - struct ctl_table *table;
87895 + ctl_table_no_const *table;
87896
87897 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
87898 GFP_KERNEL);
87899 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
87900 index 884f2b3..d53b33a 100644
87901 --- a/net/netfilter/nf_conntrack_helper.c
87902 +++ b/net/netfilter/nf_conntrack_helper.c
87903 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
87904
87905 static int nf_conntrack_helper_init_sysctl(struct net *net)
87906 {
87907 - struct ctl_table *table;
87908 + ctl_table_no_const *table;
87909
87910 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
87911 GFP_KERNEL);
87912 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
87913 index 51e928d..72a413a 100644
87914 --- a/net/netfilter/nf_conntrack_proto.c
87915 +++ b/net/netfilter/nf_conntrack_proto.c
87916 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
87917
87918 static void
87919 nf_ct_unregister_sysctl(struct ctl_table_header **header,
87920 - struct ctl_table **table,
87921 + ctl_table_no_const **table,
87922 unsigned int users)
87923 {
87924 if (users > 0)
87925 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
87926 index e7185c6..4ad6c9c 100644
87927 --- a/net/netfilter/nf_conntrack_standalone.c
87928 +++ b/net/netfilter/nf_conntrack_standalone.c
87929 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
87930
87931 static int nf_conntrack_standalone_init_sysctl(struct net *net)
87932 {
87933 - struct ctl_table *table;
87934 + ctl_table_no_const *table;
87935
87936 if (net_eq(net, &init_net)) {
87937 nf_ct_netfilter_header =
87938 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
87939 index 7ea8026..bc9512d 100644
87940 --- a/net/netfilter/nf_conntrack_timestamp.c
87941 +++ b/net/netfilter/nf_conntrack_timestamp.c
87942 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
87943 #ifdef CONFIG_SYSCTL
87944 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
87945 {
87946 - struct ctl_table *table;
87947 + ctl_table_no_const *table;
87948
87949 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
87950 GFP_KERNEL);
87951 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
87952 index 9e31269..bc4c1b7 100644
87953 --- a/net/netfilter/nf_log.c
87954 +++ b/net/netfilter/nf_log.c
87955 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
87956
87957 #ifdef CONFIG_SYSCTL
87958 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
87959 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
87960 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
87961 static struct ctl_table_header *nf_log_dir_header;
87962
87963 static int nf_log_proc_dostring(ctl_table *table, int write,
87964 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
87965 rcu_assign_pointer(nf_loggers[tindex], logger);
87966 mutex_unlock(&nf_log_mutex);
87967 } else {
87968 + ctl_table_no_const nf_log_table = *table;
87969 +
87970 mutex_lock(&nf_log_mutex);
87971 logger = rcu_dereference_protected(nf_loggers[tindex],
87972 lockdep_is_held(&nf_log_mutex));
87973 if (!logger)
87974 - table->data = "NONE";
87975 + nf_log_table.data = "NONE";
87976 else
87977 - table->data = logger->name;
87978 - r = proc_dostring(table, write, buffer, lenp, ppos);
87979 + nf_log_table.data = logger->name;
87980 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
87981 mutex_unlock(&nf_log_mutex);
87982 }
87983
87984 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
87985 index f042ae5..30ea486 100644
87986 --- a/net/netfilter/nf_sockopt.c
87987 +++ b/net/netfilter/nf_sockopt.c
87988 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
87989 }
87990 }
87991
87992 - list_add(&reg->list, &nf_sockopts);
87993 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
87994 out:
87995 mutex_unlock(&nf_sockopt_mutex);
87996 return ret;
87997 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
87998 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
87999 {
88000 mutex_lock(&nf_sockopt_mutex);
88001 - list_del(&reg->list);
88002 + pax_list_del((struct list_head *)&reg->list);
88003 mutex_unlock(&nf_sockopt_mutex);
88004 }
88005 EXPORT_SYMBOL(nf_unregister_sockopt);
88006 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
88007 index 92fd8ec..3f6ea4b 100644
88008 --- a/net/netfilter/nfnetlink_log.c
88009 +++ b/net/netfilter/nfnetlink_log.c
88010 @@ -72,7 +72,7 @@ struct nfulnl_instance {
88011 };
88012
88013 static DEFINE_SPINLOCK(instances_lock);
88014 -static atomic_t global_seq;
88015 +static atomic_unchecked_t global_seq;
88016
88017 #define INSTANCE_BUCKETS 16
88018 static struct hlist_head instance_table[INSTANCE_BUCKETS];
88019 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
88020 /* global sequence number */
88021 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
88022 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
88023 - htonl(atomic_inc_return(&global_seq))))
88024 + htonl(atomic_inc_return_unchecked(&global_seq))))
88025 goto nla_put_failure;
88026
88027 if (data_len) {
88028 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
88029 new file mode 100644
88030 index 0000000..c566332
88031 --- /dev/null
88032 +++ b/net/netfilter/xt_gradm.c
88033 @@ -0,0 +1,51 @@
88034 +/*
88035 + * gradm match for netfilter
88036 + * Copyright © Zbigniew Krzystolik, 2010
88037 + *
88038 + * This program is free software; you can redistribute it and/or modify
88039 + * it under the terms of the GNU General Public License; either version
88040 + * 2 or 3 as published by the Free Software Foundation.
88041 + */
88042 +#include <linux/module.h>
88043 +#include <linux/moduleparam.h>
88044 +#include <linux/skbuff.h>
88045 +#include <linux/netfilter/x_tables.h>
88046 +#include <linux/grsecurity.h>
88047 +#include <linux/netfilter/xt_gradm.h>
88048 +
88049 +static bool
88050 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
88051 +{
88052 + const struct xt_gradm_mtinfo *info = par->matchinfo;
88053 + bool retval = false;
88054 + if (gr_acl_is_enabled())
88055 + retval = true;
88056 + return retval ^ info->invflags;
88057 +}
88058 +
88059 +static struct xt_match gradm_mt_reg __read_mostly = {
88060 + .name = "gradm",
88061 + .revision = 0,
88062 + .family = NFPROTO_UNSPEC,
88063 + .match = gradm_mt,
88064 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
88065 + .me = THIS_MODULE,
88066 +};
88067 +
88068 +static int __init gradm_mt_init(void)
88069 +{
88070 + return xt_register_match(&gradm_mt_reg);
88071 +}
88072 +
88073 +static void __exit gradm_mt_exit(void)
88074 +{
88075 + xt_unregister_match(&gradm_mt_reg);
88076 +}
88077 +
88078 +module_init(gradm_mt_init);
88079 +module_exit(gradm_mt_exit);
88080 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
88081 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
88082 +MODULE_LICENSE("GPL");
88083 +MODULE_ALIAS("ipt_gradm");
88084 +MODULE_ALIAS("ip6t_gradm");
88085 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
88086 index 4fe4fb4..87a89e5 100644
88087 --- a/net/netfilter/xt_statistic.c
88088 +++ b/net/netfilter/xt_statistic.c
88089 @@ -19,7 +19,7 @@
88090 #include <linux/module.h>
88091
88092 struct xt_statistic_priv {
88093 - atomic_t count;
88094 + atomic_unchecked_t count;
88095 } ____cacheline_aligned_in_smp;
88096
88097 MODULE_LICENSE("GPL");
88098 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
88099 break;
88100 case XT_STATISTIC_MODE_NTH:
88101 do {
88102 - oval = atomic_read(&info->master->count);
88103 + oval = atomic_read_unchecked(&info->master->count);
88104 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
88105 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
88106 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
88107 if (nval == 0)
88108 ret = !ret;
88109 break;
88110 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
88111 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
88112 if (info->master == NULL)
88113 return -ENOMEM;
88114 - atomic_set(&info->master->count, info->u.nth.count);
88115 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
88116
88117 return 0;
88118 }
88119 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
88120 index c0353d5..fcb0270 100644
88121 --- a/net/netlink/af_netlink.c
88122 +++ b/net/netlink/af_netlink.c
88123 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
88124 sk->sk_error_report(sk);
88125 }
88126 }
88127 - atomic_inc(&sk->sk_drops);
88128 + atomic_inc_unchecked(&sk->sk_drops);
88129 }
88130
88131 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
88132 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
88133 sk_wmem_alloc_get(s),
88134 nlk->cb,
88135 atomic_read(&s->sk_refcnt),
88136 - atomic_read(&s->sk_drops),
88137 + atomic_read_unchecked(&s->sk_drops),
88138 sock_i_ino(s)
88139 );
88140
88141 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
88142 index f2aabb6..2e5e66e 100644
88143 --- a/net/netlink/genetlink.c
88144 +++ b/net/netlink/genetlink.c
88145 @@ -295,18 +295,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
88146 goto errout;
88147 }
88148
88149 + pax_open_kernel();
88150 if (ops->dumpit)
88151 - ops->flags |= GENL_CMD_CAP_DUMP;
88152 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
88153 if (ops->doit)
88154 - ops->flags |= GENL_CMD_CAP_DO;
88155 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
88156 if (ops->policy)
88157 - ops->flags |= GENL_CMD_CAP_HASPOL;
88158 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
88159 + pax_close_kernel();
88160
88161 genl_lock();
88162 - list_add_tail(&ops->ops_list, &family->ops_list);
88163 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
88164 genl_unlock();
88165
88166 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
88167 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
88168 err = 0;
88169 errout:
88170 return err;
88171 @@ -336,9 +338,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
88172 genl_lock();
88173 list_for_each_entry(rc, &family->ops_list, ops_list) {
88174 if (rc == ops) {
88175 - list_del(&ops->ops_list);
88176 + pax_list_del((struct list_head *)&ops->ops_list);
88177 genl_unlock();
88178 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
88179 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
88180 return 0;
88181 }
88182 }
88183 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
88184 index 7261eb8..44e8ac6 100644
88185 --- a/net/netrom/af_netrom.c
88186 +++ b/net/netrom/af_netrom.c
88187 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88188 struct sock *sk = sock->sk;
88189 struct nr_sock *nr = nr_sk(sk);
88190
88191 + memset(sax, 0, sizeof(*sax));
88192 lock_sock(sk);
88193 if (peer != 0) {
88194 if (sk->sk_state != TCP_ESTABLISHED) {
88195 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
88196 *uaddr_len = sizeof(struct full_sockaddr_ax25);
88197 } else {
88198 sax->fsa_ax25.sax25_family = AF_NETROM;
88199 - sax->fsa_ax25.sax25_ndigis = 0;
88200 sax->fsa_ax25.sax25_call = nr->source_addr;
88201 *uaddr_len = sizeof(struct sockaddr_ax25);
88202 }
88203 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
88204 index c111bd0..7788ff7 100644
88205 --- a/net/packet/af_packet.c
88206 +++ b/net/packet/af_packet.c
88207 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88208
88209 spin_lock(&sk->sk_receive_queue.lock);
88210 po->stats.tp_packets++;
88211 - skb->dropcount = atomic_read(&sk->sk_drops);
88212 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
88213 __skb_queue_tail(&sk->sk_receive_queue, skb);
88214 spin_unlock(&sk->sk_receive_queue.lock);
88215 sk->sk_data_ready(sk, skb->len);
88216 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
88217 drop_n_acct:
88218 spin_lock(&sk->sk_receive_queue.lock);
88219 po->stats.tp_drops++;
88220 - atomic_inc(&sk->sk_drops);
88221 + atomic_inc_unchecked(&sk->sk_drops);
88222 spin_unlock(&sk->sk_receive_queue.lock);
88223
88224 drop_n_restore:
88225 @@ -2565,6 +2565,7 @@ out:
88226
88227 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88228 {
88229 + struct sock_extended_err ee;
88230 struct sock_exterr_skb *serr;
88231 struct sk_buff *skb, *skb2;
88232 int copied, err;
88233 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
88234 sock_recv_timestamp(msg, sk, skb);
88235
88236 serr = SKB_EXT_ERR(skb);
88237 + ee = serr->ee;
88238 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
88239 - sizeof(serr->ee), &serr->ee);
88240 + sizeof ee, &ee);
88241
88242 msg->msg_flags |= MSG_ERRQUEUE;
88243 err = copied;
88244 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88245 case PACKET_HDRLEN:
88246 if (len > sizeof(int))
88247 len = sizeof(int);
88248 - if (copy_from_user(&val, optval, len))
88249 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
88250 return -EFAULT;
88251 switch (val) {
88252 case TPACKET_V1:
88253 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88254 len = lv;
88255 if (put_user(len, optlen))
88256 return -EFAULT;
88257 - if (copy_to_user(optval, data, len))
88258 + if (len > sizeof(st) || copy_to_user(optval, data, len))
88259 return -EFAULT;
88260 return 0;
88261 }
88262 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
88263 index 5a940db..f0b9c12 100644
88264 --- a/net/phonet/af_phonet.c
88265 +++ b/net/phonet/af_phonet.c
88266 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
88267 {
88268 struct phonet_protocol *pp;
88269
88270 - if (protocol >= PHONET_NPROTO)
88271 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88272 return NULL;
88273
88274 rcu_read_lock();
88275 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
88276 {
88277 int err = 0;
88278
88279 - if (protocol >= PHONET_NPROTO)
88280 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88281 return -EINVAL;
88282
88283 err = proto_register(pp->prot, 1);
88284 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
88285 index 576f22c..bc7a71b 100644
88286 --- a/net/phonet/pep.c
88287 +++ b/net/phonet/pep.c
88288 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88289
88290 case PNS_PEP_CTRL_REQ:
88291 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
88292 - atomic_inc(&sk->sk_drops);
88293 + atomic_inc_unchecked(&sk->sk_drops);
88294 break;
88295 }
88296 __skb_pull(skb, 4);
88297 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88298 }
88299
88300 if (pn->rx_credits == 0) {
88301 - atomic_inc(&sk->sk_drops);
88302 + atomic_inc_unchecked(&sk->sk_drops);
88303 err = -ENOBUFS;
88304 break;
88305 }
88306 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
88307 }
88308
88309 if (pn->rx_credits == 0) {
88310 - atomic_inc(&sk->sk_drops);
88311 + atomic_inc_unchecked(&sk->sk_drops);
88312 err = NET_RX_DROP;
88313 break;
88314 }
88315 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
88316 index b7e9827..c264c85 100644
88317 --- a/net/phonet/socket.c
88318 +++ b/net/phonet/socket.c
88319 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
88320 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
88321 sock_i_ino(sk),
88322 atomic_read(&sk->sk_refcnt), sk,
88323 - atomic_read(&sk->sk_drops), &len);
88324 + atomic_read_unchecked(&sk->sk_drops), &len);
88325 }
88326 seq_printf(seq, "%*s\n", 127 - len, "");
88327 return 0;
88328 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
88329 index d6bbbbd..61561e4 100644
88330 --- a/net/phonet/sysctl.c
88331 +++ b/net/phonet/sysctl.c
88332 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
88333 {
88334 int ret;
88335 int range[2] = {local_port_range[0], local_port_range[1]};
88336 - ctl_table tmp = {
88337 + ctl_table_no_const tmp = {
88338 .data = &range,
88339 .maxlen = sizeof(range),
88340 .mode = table->mode,
88341 diff --git a/net/rds/cong.c b/net/rds/cong.c
88342 index e5b65ac..f3b6fb7 100644
88343 --- a/net/rds/cong.c
88344 +++ b/net/rds/cong.c
88345 @@ -78,7 +78,7 @@
88346 * finds that the saved generation number is smaller than the global generation
88347 * number, it wakes up the process.
88348 */
88349 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
88350 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
88351
88352 /*
88353 * Congestion monitoring
88354 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
88355 rdsdebug("waking map %p for %pI4\n",
88356 map, &map->m_addr);
88357 rds_stats_inc(s_cong_update_received);
88358 - atomic_inc(&rds_cong_generation);
88359 + atomic_inc_unchecked(&rds_cong_generation);
88360 if (waitqueue_active(&map->m_waitq))
88361 wake_up(&map->m_waitq);
88362 if (waitqueue_active(&rds_poll_waitq))
88363 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
88364
88365 int rds_cong_updated_since(unsigned long *recent)
88366 {
88367 - unsigned long gen = atomic_read(&rds_cong_generation);
88368 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
88369
88370 if (likely(*recent == gen))
88371 return 0;
88372 diff --git a/net/rds/ib.h b/net/rds/ib.h
88373 index 7280ab8..e04f4ea 100644
88374 --- a/net/rds/ib.h
88375 +++ b/net/rds/ib.h
88376 @@ -128,7 +128,7 @@ struct rds_ib_connection {
88377 /* sending acks */
88378 unsigned long i_ack_flags;
88379 #ifdef KERNEL_HAS_ATOMIC64
88380 - atomic64_t i_ack_next; /* next ACK to send */
88381 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
88382 #else
88383 spinlock_t i_ack_lock; /* protect i_ack_next */
88384 u64 i_ack_next; /* next ACK to send */
88385 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
88386 index 31b74f5..dc1fbfa 100644
88387 --- a/net/rds/ib_cm.c
88388 +++ b/net/rds/ib_cm.c
88389 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
88390 /* Clear the ACK state */
88391 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
88392 #ifdef KERNEL_HAS_ATOMIC64
88393 - atomic64_set(&ic->i_ack_next, 0);
88394 + atomic64_set_unchecked(&ic->i_ack_next, 0);
88395 #else
88396 ic->i_ack_next = 0;
88397 #endif
88398 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
88399 index 8eb9501..0c386ff 100644
88400 --- a/net/rds/ib_recv.c
88401 +++ b/net/rds/ib_recv.c
88402 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
88403 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
88404 int ack_required)
88405 {
88406 - atomic64_set(&ic->i_ack_next, seq);
88407 + atomic64_set_unchecked(&ic->i_ack_next, seq);
88408 if (ack_required) {
88409 smp_mb__before_clear_bit();
88410 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88411 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
88412 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88413 smp_mb__after_clear_bit();
88414
88415 - return atomic64_read(&ic->i_ack_next);
88416 + return atomic64_read_unchecked(&ic->i_ack_next);
88417 }
88418 #endif
88419
88420 diff --git a/net/rds/iw.h b/net/rds/iw.h
88421 index 04ce3b1..48119a6 100644
88422 --- a/net/rds/iw.h
88423 +++ b/net/rds/iw.h
88424 @@ -134,7 +134,7 @@ struct rds_iw_connection {
88425 /* sending acks */
88426 unsigned long i_ack_flags;
88427 #ifdef KERNEL_HAS_ATOMIC64
88428 - atomic64_t i_ack_next; /* next ACK to send */
88429 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
88430 #else
88431 spinlock_t i_ack_lock; /* protect i_ack_next */
88432 u64 i_ack_next; /* next ACK to send */
88433 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
88434 index a91e1db..cf3053f 100644
88435 --- a/net/rds/iw_cm.c
88436 +++ b/net/rds/iw_cm.c
88437 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
88438 /* Clear the ACK state */
88439 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
88440 #ifdef KERNEL_HAS_ATOMIC64
88441 - atomic64_set(&ic->i_ack_next, 0);
88442 + atomic64_set_unchecked(&ic->i_ack_next, 0);
88443 #else
88444 ic->i_ack_next = 0;
88445 #endif
88446 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
88447 index 4503335..db566b4 100644
88448 --- a/net/rds/iw_recv.c
88449 +++ b/net/rds/iw_recv.c
88450 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
88451 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
88452 int ack_required)
88453 {
88454 - atomic64_set(&ic->i_ack_next, seq);
88455 + atomic64_set_unchecked(&ic->i_ack_next, seq);
88456 if (ack_required) {
88457 smp_mb__before_clear_bit();
88458 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88459 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
88460 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88461 smp_mb__after_clear_bit();
88462
88463 - return atomic64_read(&ic->i_ack_next);
88464 + return atomic64_read_unchecked(&ic->i_ack_next);
88465 }
88466 #endif
88467
88468 diff --git a/net/rds/rds.h b/net/rds/rds.h
88469 index ec1d731..90a3a8d 100644
88470 --- a/net/rds/rds.h
88471 +++ b/net/rds/rds.h
88472 @@ -449,7 +449,7 @@ struct rds_transport {
88473 void (*sync_mr)(void *trans_private, int direction);
88474 void (*free_mr)(void *trans_private, int invalidate);
88475 void (*flush_mrs)(void);
88476 -};
88477 +} __do_const;
88478
88479 struct rds_sock {
88480 struct sock rs_sk;
88481 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
88482 index edac9ef..16bcb98 100644
88483 --- a/net/rds/tcp.c
88484 +++ b/net/rds/tcp.c
88485 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
88486 int val = 1;
88487
88488 set_fs(KERNEL_DS);
88489 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
88490 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
88491 sizeof(val));
88492 set_fs(oldfs);
88493 }
88494 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
88495 index 81cf5a4..b5826ff 100644
88496 --- a/net/rds/tcp_send.c
88497 +++ b/net/rds/tcp_send.c
88498 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
88499
88500 oldfs = get_fs();
88501 set_fs(KERNEL_DS);
88502 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
88503 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
88504 sizeof(val));
88505 set_fs(oldfs);
88506 }
88507 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
88508 index 05996d0..5a1dfe0 100644
88509 --- a/net/rxrpc/af_rxrpc.c
88510 +++ b/net/rxrpc/af_rxrpc.c
88511 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
88512 __be32 rxrpc_epoch;
88513
88514 /* current debugging ID */
88515 -atomic_t rxrpc_debug_id;
88516 +atomic_unchecked_t rxrpc_debug_id;
88517
88518 /* count of skbs currently in use */
88519 atomic_t rxrpc_n_skbs;
88520 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
88521 index e4d9cbc..b229649 100644
88522 --- a/net/rxrpc/ar-ack.c
88523 +++ b/net/rxrpc/ar-ack.c
88524 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
88525
88526 _enter("{%d,%d,%d,%d},",
88527 call->acks_hard, call->acks_unacked,
88528 - atomic_read(&call->sequence),
88529 + atomic_read_unchecked(&call->sequence),
88530 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
88531
88532 stop = 0;
88533 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
88534
88535 /* each Tx packet has a new serial number */
88536 sp->hdr.serial =
88537 - htonl(atomic_inc_return(&call->conn->serial));
88538 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
88539
88540 hdr = (struct rxrpc_header *) txb->head;
88541 hdr->serial = sp->hdr.serial;
88542 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
88543 */
88544 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
88545 {
88546 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
88547 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
88548 }
88549
88550 /*
88551 @@ -629,7 +629,7 @@ process_further:
88552
88553 latest = ntohl(sp->hdr.serial);
88554 hard = ntohl(ack.firstPacket);
88555 - tx = atomic_read(&call->sequence);
88556 + tx = atomic_read_unchecked(&call->sequence);
88557
88558 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
88559 latest,
88560 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
88561 goto maybe_reschedule;
88562
88563 send_ACK_with_skew:
88564 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
88565 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
88566 ntohl(ack.serial));
88567 send_ACK:
88568 mtu = call->conn->trans->peer->if_mtu;
88569 @@ -1173,7 +1173,7 @@ send_ACK:
88570 ackinfo.rxMTU = htonl(5692);
88571 ackinfo.jumbo_max = htonl(4);
88572
88573 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
88574 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
88575 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
88576 ntohl(hdr.serial),
88577 ntohs(ack.maxSkew),
88578 @@ -1191,7 +1191,7 @@ send_ACK:
88579 send_message:
88580 _debug("send message");
88581
88582 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
88583 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
88584 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
88585 send_message_2:
88586
88587 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
88588 index a3bbb36..3341fb9 100644
88589 --- a/net/rxrpc/ar-call.c
88590 +++ b/net/rxrpc/ar-call.c
88591 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
88592 spin_lock_init(&call->lock);
88593 rwlock_init(&call->state_lock);
88594 atomic_set(&call->usage, 1);
88595 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
88596 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88597 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
88598
88599 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
88600 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
88601 index 4106ca9..a338d7a 100644
88602 --- a/net/rxrpc/ar-connection.c
88603 +++ b/net/rxrpc/ar-connection.c
88604 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
88605 rwlock_init(&conn->lock);
88606 spin_lock_init(&conn->state_lock);
88607 atomic_set(&conn->usage, 1);
88608 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
88609 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88610 conn->avail_calls = RXRPC_MAXCALLS;
88611 conn->size_align = 4;
88612 conn->header_size = sizeof(struct rxrpc_header);
88613 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
88614 index e7ed43a..6afa140 100644
88615 --- a/net/rxrpc/ar-connevent.c
88616 +++ b/net/rxrpc/ar-connevent.c
88617 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
88618
88619 len = iov[0].iov_len + iov[1].iov_len;
88620
88621 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
88622 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88623 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
88624
88625 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
88626 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
88627 index 529572f..c758ca7 100644
88628 --- a/net/rxrpc/ar-input.c
88629 +++ b/net/rxrpc/ar-input.c
88630 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
88631 /* track the latest serial number on this connection for ACK packet
88632 * information */
88633 serial = ntohl(sp->hdr.serial);
88634 - hi_serial = atomic_read(&call->conn->hi_serial);
88635 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
88636 while (serial > hi_serial)
88637 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
88638 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
88639 serial);
88640
88641 /* request ACK generation for any ACK or DATA packet that requests
88642 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
88643 index a693aca..81e7293 100644
88644 --- a/net/rxrpc/ar-internal.h
88645 +++ b/net/rxrpc/ar-internal.h
88646 @@ -272,8 +272,8 @@ struct rxrpc_connection {
88647 int error; /* error code for local abort */
88648 int debug_id; /* debug ID for printks */
88649 unsigned int call_counter; /* call ID counter */
88650 - atomic_t serial; /* packet serial number counter */
88651 - atomic_t hi_serial; /* highest serial number received */
88652 + atomic_unchecked_t serial; /* packet serial number counter */
88653 + atomic_unchecked_t hi_serial; /* highest serial number received */
88654 u8 avail_calls; /* number of calls available */
88655 u8 size_align; /* data size alignment (for security) */
88656 u8 header_size; /* rxrpc + security header size */
88657 @@ -346,7 +346,7 @@ struct rxrpc_call {
88658 spinlock_t lock;
88659 rwlock_t state_lock; /* lock for state transition */
88660 atomic_t usage;
88661 - atomic_t sequence; /* Tx data packet sequence counter */
88662 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
88663 u32 abort_code; /* local/remote abort code */
88664 enum { /* current state of call */
88665 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
88666 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
88667 */
88668 extern atomic_t rxrpc_n_skbs;
88669 extern __be32 rxrpc_epoch;
88670 -extern atomic_t rxrpc_debug_id;
88671 +extern atomic_unchecked_t rxrpc_debug_id;
88672 extern struct workqueue_struct *rxrpc_workqueue;
88673
88674 /*
88675 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
88676 index 87f7135..74d3703 100644
88677 --- a/net/rxrpc/ar-local.c
88678 +++ b/net/rxrpc/ar-local.c
88679 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
88680 spin_lock_init(&local->lock);
88681 rwlock_init(&local->services_lock);
88682 atomic_set(&local->usage, 1);
88683 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
88684 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88685 memcpy(&local->srx, srx, sizeof(*srx));
88686 }
88687
88688 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
88689 index e1ac183..b43e10e 100644
88690 --- a/net/rxrpc/ar-output.c
88691 +++ b/net/rxrpc/ar-output.c
88692 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
88693 sp->hdr.cid = call->cid;
88694 sp->hdr.callNumber = call->call_id;
88695 sp->hdr.seq =
88696 - htonl(atomic_inc_return(&call->sequence));
88697 + htonl(atomic_inc_return_unchecked(&call->sequence));
88698 sp->hdr.serial =
88699 - htonl(atomic_inc_return(&conn->serial));
88700 + htonl(atomic_inc_return_unchecked(&conn->serial));
88701 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
88702 sp->hdr.userStatus = 0;
88703 sp->hdr.securityIndex = conn->security_ix;
88704 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
88705 index bebaa43..2644591 100644
88706 --- a/net/rxrpc/ar-peer.c
88707 +++ b/net/rxrpc/ar-peer.c
88708 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
88709 INIT_LIST_HEAD(&peer->error_targets);
88710 spin_lock_init(&peer->lock);
88711 atomic_set(&peer->usage, 1);
88712 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
88713 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88714 memcpy(&peer->srx, srx, sizeof(*srx));
88715
88716 rxrpc_assess_MTU_size(peer);
88717 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
88718 index 38047f7..9f48511 100644
88719 --- a/net/rxrpc/ar-proc.c
88720 +++ b/net/rxrpc/ar-proc.c
88721 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
88722 atomic_read(&conn->usage),
88723 rxrpc_conn_states[conn->state],
88724 key_serial(conn->key),
88725 - atomic_read(&conn->serial),
88726 - atomic_read(&conn->hi_serial));
88727 + atomic_read_unchecked(&conn->serial),
88728 + atomic_read_unchecked(&conn->hi_serial));
88729
88730 return 0;
88731 }
88732 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
88733 index 92df566..87ec1bf 100644
88734 --- a/net/rxrpc/ar-transport.c
88735 +++ b/net/rxrpc/ar-transport.c
88736 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
88737 spin_lock_init(&trans->client_lock);
88738 rwlock_init(&trans->conn_lock);
88739 atomic_set(&trans->usage, 1);
88740 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
88741 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88742
88743 if (peer->srx.transport.family == AF_INET) {
88744 switch (peer->srx.transport_type) {
88745 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
88746 index f226709..0e735a8 100644
88747 --- a/net/rxrpc/rxkad.c
88748 +++ b/net/rxrpc/rxkad.c
88749 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
88750
88751 len = iov[0].iov_len + iov[1].iov_len;
88752
88753 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
88754 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88755 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
88756
88757 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
88758 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
88759
88760 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
88761
88762 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
88763 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88764 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
88765
88766 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
88767 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
88768 index 391a245..296b3d7 100644
88769 --- a/net/sctp/ipv6.c
88770 +++ b/net/sctp/ipv6.c
88771 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
88772 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
88773 };
88774
88775 -static struct sctp_af sctp_af_inet6 = {
88776 +static struct sctp_af sctp_af_inet6 __read_only = {
88777 .sa_family = AF_INET6,
88778 .sctp_xmit = sctp_v6_xmit,
88779 .setsockopt = ipv6_setsockopt,
88780 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
88781 #endif
88782 };
88783
88784 -static struct sctp_pf sctp_pf_inet6 = {
88785 +static struct sctp_pf sctp_pf_inet6 __read_only = {
88786 .event_msgname = sctp_inet6_event_msgname,
88787 .skb_msgname = sctp_inet6_skb_msgname,
88788 .af_supported = sctp_inet6_af_supported,
88789 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
88790
88791 void sctp_v6_pf_exit(void)
88792 {
88793 - list_del(&sctp_af_inet6.list);
88794 + pax_list_del(&sctp_af_inet6.list);
88795 }
88796
88797 /* Initialize IPv6 support and register with socket layer. */
88798 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
88799 index 8c19e97..16264b8 100644
88800 --- a/net/sctp/proc.c
88801 +++ b/net/sctp/proc.c
88802 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
88803 seq_printf(seq,
88804 "%8pK %8pK %-3d %-3d %-2d %-4d "
88805 "%4d %8d %8d %7d %5lu %-5d %5d ",
88806 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
88807 + assoc, sk,
88808 + sctp_sk(sk)->type, sk->sk_state,
88809 assoc->state, hash,
88810 assoc->assoc_id,
88811 assoc->sndbuf_used,
88812 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
88813 index f898b1c..a2d0fe8 100644
88814 --- a/net/sctp/protocol.c
88815 +++ b/net/sctp/protocol.c
88816 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
88817 return 0;
88818 }
88819
88820 + pax_open_kernel();
88821 INIT_LIST_HEAD(&af->list);
88822 - list_add_tail(&af->list, &sctp_address_families);
88823 + pax_close_kernel();
88824 + pax_list_add_tail(&af->list, &sctp_address_families);
88825 return 1;
88826 }
88827
88828 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
88829
88830 static struct sctp_af sctp_af_inet;
88831
88832 -static struct sctp_pf sctp_pf_inet = {
88833 +static struct sctp_pf sctp_pf_inet __read_only = {
88834 .event_msgname = sctp_inet_event_msgname,
88835 .skb_msgname = sctp_inet_skb_msgname,
88836 .af_supported = sctp_inet_af_supported,
88837 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
88838 };
88839
88840 /* IPv4 address related functions. */
88841 -static struct sctp_af sctp_af_inet = {
88842 +static struct sctp_af sctp_af_inet __read_only = {
88843 .sa_family = AF_INET,
88844 .sctp_xmit = sctp_v4_xmit,
88845 .setsockopt = ip_setsockopt,
88846 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
88847
88848 static void sctp_v4_pf_exit(void)
88849 {
88850 - list_del(&sctp_af_inet.list);
88851 + pax_list_del(&sctp_af_inet.list);
88852 }
88853
88854 static int sctp_v4_protosw_init(void)
88855 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
88856 index c957775..6d4593a 100644
88857 --- a/net/sctp/sm_sideeffect.c
88858 +++ b/net/sctp/sm_sideeffect.c
88859 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
88860 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
88861 }
88862
88863 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
88864 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
88865 NULL,
88866 sctp_generate_t1_cookie_event,
88867 sctp_generate_t1_init_event,
88868 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
88869 index 9ef5c73..1e9a9a9 100644
88870 --- a/net/sctp/socket.c
88871 +++ b/net/sctp/socket.c
88872 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
88873 {
88874 struct sctp_association *asoc;
88875 struct sctp_ulpevent *event;
88876 + struct sctp_event_subscribe subscribe;
88877
88878 if (optlen > sizeof(struct sctp_event_subscribe))
88879 return -EINVAL;
88880 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
88881 + if (copy_from_user(&subscribe, optval, optlen))
88882 return -EFAULT;
88883 + sctp_sk(sk)->subscribe = subscribe;
88884
88885 /*
88886 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
88887 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
88888 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
88889 int __user *optlen)
88890 {
88891 + struct sctp_event_subscribe subscribe;
88892 +
88893 if (len <= 0)
88894 return -EINVAL;
88895 if (len > sizeof(struct sctp_event_subscribe))
88896 len = sizeof(struct sctp_event_subscribe);
88897 if (put_user(len, optlen))
88898 return -EFAULT;
88899 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
88900 + subscribe = sctp_sk(sk)->subscribe;
88901 + if (copy_to_user(optval, &subscribe, len))
88902 return -EFAULT;
88903 return 0;
88904 }
88905 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
88906 */
88907 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
88908 {
88909 + __u32 autoclose;
88910 +
88911 /* Applicable to UDP-style socket only */
88912 if (sctp_style(sk, TCP))
88913 return -EOPNOTSUPP;
88914 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
88915 len = sizeof(int);
88916 if (put_user(len, optlen))
88917 return -EFAULT;
88918 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
88919 + autoclose = sctp_sk(sk)->autoclose;
88920 + if (copy_to_user(optval, &autoclose, sizeof(int)))
88921 return -EFAULT;
88922 return 0;
88923 }
88924 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
88925 */
88926 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
88927 {
88928 + struct sctp_initmsg initmsg;
88929 +
88930 if (len < sizeof(struct sctp_initmsg))
88931 return -EINVAL;
88932 len = sizeof(struct sctp_initmsg);
88933 if (put_user(len, optlen))
88934 return -EFAULT;
88935 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
88936 + initmsg = sctp_sk(sk)->initmsg;
88937 + if (copy_to_user(optval, &initmsg, len))
88938 return -EFAULT;
88939 return 0;
88940 }
88941 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
88942 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
88943 if (space_left < addrlen)
88944 return -ENOMEM;
88945 + if (addrlen > sizeof(temp) || addrlen < 0)
88946 + return -EFAULT;
88947 if (copy_to_user(to, &temp, addrlen))
88948 return -EFAULT;
88949 to += addrlen;
88950 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
88951 index 442ad4e..825ea94 100644
88952 --- a/net/sctp/ssnmap.c
88953 +++ b/net/sctp/ssnmap.c
88954 @@ -41,8 +41,6 @@
88955 #include <net/sctp/sctp.h>
88956 #include <net/sctp/sm.h>
88957
88958 -#define MAX_KMALLOC_SIZE 131072
88959 -
88960 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
88961 __u16 out);
88962
88963 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
88964 int size;
88965
88966 size = sctp_ssnmap_size(in, out);
88967 - if (size <= MAX_KMALLOC_SIZE)
88968 + if (size <= KMALLOC_MAX_SIZE)
88969 retval = kmalloc(size, gfp);
88970 else
88971 retval = (struct sctp_ssnmap *)
88972 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
88973 return retval;
88974
88975 fail_map:
88976 - if (size <= MAX_KMALLOC_SIZE)
88977 + if (size <= KMALLOC_MAX_SIZE)
88978 kfree(retval);
88979 else
88980 free_pages((unsigned long)retval, get_order(size));
88981 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
88982 int size;
88983
88984 size = sctp_ssnmap_size(map->in.len, map->out.len);
88985 - if (size <= MAX_KMALLOC_SIZE)
88986 + if (size <= KMALLOC_MAX_SIZE)
88987 kfree(map);
88988 else
88989 free_pages((unsigned long)map, get_order(size));
88990 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
88991 index bf3c6e8..376d8d0 100644
88992 --- a/net/sctp/sysctl.c
88993 +++ b/net/sctp/sysctl.c
88994 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
88995 {
88996 struct net *net = current->nsproxy->net_ns;
88997 char tmp[8];
88998 - ctl_table tbl;
88999 + ctl_table_no_const tbl;
89000 int ret;
89001 int changed = 0;
89002 char *none = "none";
89003 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89004
89005 int sctp_sysctl_net_register(struct net *net)
89006 {
89007 - struct ctl_table *table;
89008 + ctl_table_no_const *table;
89009 int i;
89010
89011 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
89012 diff --git a/net/socket.c b/net/socket.c
89013 index 2ca51c7..9a9c83e 100644
89014 --- a/net/socket.c
89015 +++ b/net/socket.c
89016 @@ -89,6 +89,7 @@
89017 #include <linux/magic.h>
89018 #include <linux/slab.h>
89019 #include <linux/xattr.h>
89020 +#include <linux/in.h>
89021
89022 #include <asm/uaccess.h>
89023 #include <asm/unistd.h>
89024 @@ -106,6 +107,8 @@
89025 #include <linux/sockios.h>
89026 #include <linux/atalk.h>
89027
89028 +#include <linux/grsock.h>
89029 +
89030 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
89031 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
89032 unsigned long nr_segs, loff_t pos);
89033 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
89034 &sockfs_dentry_operations, SOCKFS_MAGIC);
89035 }
89036
89037 -static struct vfsmount *sock_mnt __read_mostly;
89038 +struct vfsmount *sock_mnt __read_mostly;
89039
89040 static struct file_system_type sock_fs_type = {
89041 .name = "sockfs",
89042 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
89043 return -EAFNOSUPPORT;
89044 if (type < 0 || type >= SOCK_MAX)
89045 return -EINVAL;
89046 + if (protocol < 0)
89047 + return -EINVAL;
89048
89049 /* Compatibility.
89050
89051 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
89052 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
89053 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
89054
89055 + if(!gr_search_socket(family, type, protocol)) {
89056 + retval = -EACCES;
89057 + goto out;
89058 + }
89059 +
89060 + if (gr_handle_sock_all(family, type, protocol)) {
89061 + retval = -EACCES;
89062 + goto out;
89063 + }
89064 +
89065 retval = sock_create(family, type, protocol, &sock);
89066 if (retval < 0)
89067 goto out;
89068 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89069 if (sock) {
89070 err = move_addr_to_kernel(umyaddr, addrlen, &address);
89071 if (err >= 0) {
89072 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
89073 + err = -EACCES;
89074 + goto error;
89075 + }
89076 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
89077 + if (err)
89078 + goto error;
89079 +
89080 err = security_socket_bind(sock,
89081 (struct sockaddr *)&address,
89082 addrlen);
89083 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89084 (struct sockaddr *)
89085 &address, addrlen);
89086 }
89087 +error:
89088 fput_light(sock->file, fput_needed);
89089 }
89090 return err;
89091 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
89092 if ((unsigned int)backlog > somaxconn)
89093 backlog = somaxconn;
89094
89095 + if (gr_handle_sock_server_other(sock->sk)) {
89096 + err = -EPERM;
89097 + goto error;
89098 + }
89099 +
89100 + err = gr_search_listen(sock);
89101 + if (err)
89102 + goto error;
89103 +
89104 err = security_socket_listen(sock, backlog);
89105 if (!err)
89106 err = sock->ops->listen(sock, backlog);
89107
89108 +error:
89109 fput_light(sock->file, fput_needed);
89110 }
89111 return err;
89112 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89113 newsock->type = sock->type;
89114 newsock->ops = sock->ops;
89115
89116 + if (gr_handle_sock_server_other(sock->sk)) {
89117 + err = -EPERM;
89118 + sock_release(newsock);
89119 + goto out_put;
89120 + }
89121 +
89122 + err = gr_search_accept(sock);
89123 + if (err) {
89124 + sock_release(newsock);
89125 + goto out_put;
89126 + }
89127 +
89128 /*
89129 * We don't need try_module_get here, as the listening socket (sock)
89130 * has the protocol module (sock->ops->owner) held.
89131 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
89132 fd_install(newfd, newfile);
89133 err = newfd;
89134
89135 + gr_attach_curr_ip(newsock->sk);
89136 +
89137 out_put:
89138 fput_light(sock->file, fput_needed);
89139 out:
89140 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89141 int, addrlen)
89142 {
89143 struct socket *sock;
89144 + struct sockaddr *sck;
89145 struct sockaddr_storage address;
89146 int err, fput_needed;
89147
89148 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
89149 if (err < 0)
89150 goto out_put;
89151
89152 + sck = (struct sockaddr *)&address;
89153 +
89154 + if (gr_handle_sock_client(sck)) {
89155 + err = -EACCES;
89156 + goto out_put;
89157 + }
89158 +
89159 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
89160 + if (err)
89161 + goto out_put;
89162 +
89163 err =
89164 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
89165 if (err)
89166 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
89167 * the protocol.
89168 */
89169
89170 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
89171 +
89172 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
89173 unsigned int, flags, struct sockaddr __user *, addr,
89174 int, addr_len)
89175 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
89176 * checking falls down on this.
89177 */
89178 if (copy_from_user(ctl_buf,
89179 - (void __user __force *)msg_sys->msg_control,
89180 + (void __force_user *)msg_sys->msg_control,
89181 ctl_len))
89182 goto out_freectl;
89183 msg_sys->msg_control = ctl_buf;
89184 @@ -2187,7 +2249,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89185 int err, total_len, len;
89186
89187 /* kernel mode address */
89188 - struct sockaddr_storage addr;
89189 + struct sockaddr_storage addr = { };
89190
89191 /* user mode address pointers */
89192 struct sockaddr __user *uaddr;
89193 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
89194 * kernel msghdr to use the kernel address space)
89195 */
89196
89197 - uaddr = (__force void __user *)msg_sys->msg_name;
89198 + uaddr = (void __force_user *)msg_sys->msg_name;
89199 uaddr_len = COMPAT_NAMELEN(msg);
89200 if (MSG_CMSG_COMPAT & flags) {
89201 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
89202 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
89203 }
89204
89205 ifr = compat_alloc_user_space(buf_size);
89206 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
89207 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
89208
89209 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
89210 return -EFAULT;
89211 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
89212 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
89213
89214 if (copy_in_user(rxnfc, compat_rxnfc,
89215 - (void *)(&rxnfc->fs.m_ext + 1) -
89216 - (void *)rxnfc) ||
89217 + (void __user *)(&rxnfc->fs.m_ext + 1) -
89218 + (void __user *)rxnfc) ||
89219 copy_in_user(&rxnfc->fs.ring_cookie,
89220 &compat_rxnfc->fs.ring_cookie,
89221 - (void *)(&rxnfc->fs.location + 1) -
89222 - (void *)&rxnfc->fs.ring_cookie) ||
89223 + (void __user *)(&rxnfc->fs.location + 1) -
89224 + (void __user *)&rxnfc->fs.ring_cookie) ||
89225 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
89226 sizeof(rxnfc->rule_cnt)))
89227 return -EFAULT;
89228 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
89229
89230 if (convert_out) {
89231 if (copy_in_user(compat_rxnfc, rxnfc,
89232 - (const void *)(&rxnfc->fs.m_ext + 1) -
89233 - (const void *)rxnfc) ||
89234 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
89235 + (const void __user *)rxnfc) ||
89236 copy_in_user(&compat_rxnfc->fs.ring_cookie,
89237 &rxnfc->fs.ring_cookie,
89238 - (const void *)(&rxnfc->fs.location + 1) -
89239 - (const void *)&rxnfc->fs.ring_cookie) ||
89240 + (const void __user *)(&rxnfc->fs.location + 1) -
89241 + (const void __user *)&rxnfc->fs.ring_cookie) ||
89242 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
89243 sizeof(rxnfc->rule_cnt)))
89244 return -EFAULT;
89245 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
89246 old_fs = get_fs();
89247 set_fs(KERNEL_DS);
89248 err = dev_ioctl(net, cmd,
89249 - (struct ifreq __user __force *) &kifr);
89250 + (struct ifreq __force_user *) &kifr);
89251 set_fs(old_fs);
89252
89253 return err;
89254 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
89255
89256 old_fs = get_fs();
89257 set_fs(KERNEL_DS);
89258 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
89259 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
89260 set_fs(old_fs);
89261
89262 if (cmd == SIOCGIFMAP && !err) {
89263 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
89264 ret |= __get_user(rtdev, &(ur4->rt_dev));
89265 if (rtdev) {
89266 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
89267 - r4.rt_dev = (char __user __force *)devname;
89268 + r4.rt_dev = (char __force_user *)devname;
89269 devname[15] = 0;
89270 } else
89271 r4.rt_dev = NULL;
89272 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
89273 int __user *uoptlen;
89274 int err;
89275
89276 - uoptval = (char __user __force *) optval;
89277 - uoptlen = (int __user __force *) optlen;
89278 + uoptval = (char __force_user *) optval;
89279 + uoptlen = (int __force_user *) optlen;
89280
89281 set_fs(KERNEL_DS);
89282 if (level == SOL_SOCKET)
89283 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
89284 char __user *uoptval;
89285 int err;
89286
89287 - uoptval = (char __user __force *) optval;
89288 + uoptval = (char __force_user *) optval;
89289
89290 set_fs(KERNEL_DS);
89291 if (level == SOL_SOCKET)
89292 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
89293 index 507b5e8..049e64a 100644
89294 --- a/net/sunrpc/clnt.c
89295 +++ b/net/sunrpc/clnt.c
89296 @@ -1272,7 +1272,9 @@ call_start(struct rpc_task *task)
89297 (RPC_IS_ASYNC(task) ? "async" : "sync"));
89298
89299 /* Increment call count */
89300 - task->tk_msg.rpc_proc->p_count++;
89301 + pax_open_kernel();
89302 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
89303 + pax_close_kernel();
89304 clnt->cl_stats->rpccnt++;
89305 task->tk_action = call_reserve;
89306 }
89307 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
89308 index fb20f25..e3ba316 100644
89309 --- a/net/sunrpc/sched.c
89310 +++ b/net/sunrpc/sched.c
89311 @@ -259,9 +259,9 @@ static int rpc_wait_bit_killable(void *word)
89312 #ifdef RPC_DEBUG
89313 static void rpc_task_set_debuginfo(struct rpc_task *task)
89314 {
89315 - static atomic_t rpc_pid;
89316 + static atomic_unchecked_t rpc_pid;
89317
89318 - task->tk_pid = atomic_inc_return(&rpc_pid);
89319 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
89320 }
89321 #else
89322 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
89323 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
89324 index 2d34b6b..e2d584d 100644
89325 --- a/net/sunrpc/svc.c
89326 +++ b/net/sunrpc/svc.c
89327 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
89328 svc_putnl(resv, RPC_SUCCESS);
89329
89330 /* Bump per-procedure stats counter */
89331 - procp->pc_count++;
89332 + pax_open_kernel();
89333 + (*(unsigned int *)&procp->pc_count)++;
89334 + pax_close_kernel();
89335
89336 /* Initialize storage for argp and resp */
89337 memset(rqstp->rq_argp, 0, procp->pc_argsize);
89338 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
89339 index 8343737..677025e 100644
89340 --- a/net/sunrpc/xprtrdma/svc_rdma.c
89341 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
89342 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
89343 static unsigned int min_max_inline = 4096;
89344 static unsigned int max_max_inline = 65536;
89345
89346 -atomic_t rdma_stat_recv;
89347 -atomic_t rdma_stat_read;
89348 -atomic_t rdma_stat_write;
89349 -atomic_t rdma_stat_sq_starve;
89350 -atomic_t rdma_stat_rq_starve;
89351 -atomic_t rdma_stat_rq_poll;
89352 -atomic_t rdma_stat_rq_prod;
89353 -atomic_t rdma_stat_sq_poll;
89354 -atomic_t rdma_stat_sq_prod;
89355 +atomic_unchecked_t rdma_stat_recv;
89356 +atomic_unchecked_t rdma_stat_read;
89357 +atomic_unchecked_t rdma_stat_write;
89358 +atomic_unchecked_t rdma_stat_sq_starve;
89359 +atomic_unchecked_t rdma_stat_rq_starve;
89360 +atomic_unchecked_t rdma_stat_rq_poll;
89361 +atomic_unchecked_t rdma_stat_rq_prod;
89362 +atomic_unchecked_t rdma_stat_sq_poll;
89363 +atomic_unchecked_t rdma_stat_sq_prod;
89364
89365 /* Temporary NFS request map and context caches */
89366 struct kmem_cache *svc_rdma_map_cachep;
89367 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
89368 len -= *ppos;
89369 if (len > *lenp)
89370 len = *lenp;
89371 - if (len && copy_to_user(buffer, str_buf, len))
89372 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
89373 return -EFAULT;
89374 *lenp = len;
89375 *ppos += len;
89376 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
89377 {
89378 .procname = "rdma_stat_read",
89379 .data = &rdma_stat_read,
89380 - .maxlen = sizeof(atomic_t),
89381 + .maxlen = sizeof(atomic_unchecked_t),
89382 .mode = 0644,
89383 .proc_handler = read_reset_stat,
89384 },
89385 {
89386 .procname = "rdma_stat_recv",
89387 .data = &rdma_stat_recv,
89388 - .maxlen = sizeof(atomic_t),
89389 + .maxlen = sizeof(atomic_unchecked_t),
89390 .mode = 0644,
89391 .proc_handler = read_reset_stat,
89392 },
89393 {
89394 .procname = "rdma_stat_write",
89395 .data = &rdma_stat_write,
89396 - .maxlen = sizeof(atomic_t),
89397 + .maxlen = sizeof(atomic_unchecked_t),
89398 .mode = 0644,
89399 .proc_handler = read_reset_stat,
89400 },
89401 {
89402 .procname = "rdma_stat_sq_starve",
89403 .data = &rdma_stat_sq_starve,
89404 - .maxlen = sizeof(atomic_t),
89405 + .maxlen = sizeof(atomic_unchecked_t),
89406 .mode = 0644,
89407 .proc_handler = read_reset_stat,
89408 },
89409 {
89410 .procname = "rdma_stat_rq_starve",
89411 .data = &rdma_stat_rq_starve,
89412 - .maxlen = sizeof(atomic_t),
89413 + .maxlen = sizeof(atomic_unchecked_t),
89414 .mode = 0644,
89415 .proc_handler = read_reset_stat,
89416 },
89417 {
89418 .procname = "rdma_stat_rq_poll",
89419 .data = &rdma_stat_rq_poll,
89420 - .maxlen = sizeof(atomic_t),
89421 + .maxlen = sizeof(atomic_unchecked_t),
89422 .mode = 0644,
89423 .proc_handler = read_reset_stat,
89424 },
89425 {
89426 .procname = "rdma_stat_rq_prod",
89427 .data = &rdma_stat_rq_prod,
89428 - .maxlen = sizeof(atomic_t),
89429 + .maxlen = sizeof(atomic_unchecked_t),
89430 .mode = 0644,
89431 .proc_handler = read_reset_stat,
89432 },
89433 {
89434 .procname = "rdma_stat_sq_poll",
89435 .data = &rdma_stat_sq_poll,
89436 - .maxlen = sizeof(atomic_t),
89437 + .maxlen = sizeof(atomic_unchecked_t),
89438 .mode = 0644,
89439 .proc_handler = read_reset_stat,
89440 },
89441 {
89442 .procname = "rdma_stat_sq_prod",
89443 .data = &rdma_stat_sq_prod,
89444 - .maxlen = sizeof(atomic_t),
89445 + .maxlen = sizeof(atomic_unchecked_t),
89446 .mode = 0644,
89447 .proc_handler = read_reset_stat,
89448 },
89449 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89450 index 0ce7552..d074459 100644
89451 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89452 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89453 @@ -501,7 +501,7 @@ next_sge:
89454 svc_rdma_put_context(ctxt, 0);
89455 goto out;
89456 }
89457 - atomic_inc(&rdma_stat_read);
89458 + atomic_inc_unchecked(&rdma_stat_read);
89459
89460 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
89461 chl_map->ch[ch_no].count -= read_wr.num_sge;
89462 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
89463 dto_q);
89464 list_del_init(&ctxt->dto_q);
89465 } else {
89466 - atomic_inc(&rdma_stat_rq_starve);
89467 + atomic_inc_unchecked(&rdma_stat_rq_starve);
89468 clear_bit(XPT_DATA, &xprt->xpt_flags);
89469 ctxt = NULL;
89470 }
89471 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
89472 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
89473 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
89474 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
89475 - atomic_inc(&rdma_stat_recv);
89476 + atomic_inc_unchecked(&rdma_stat_recv);
89477
89478 /* Build up the XDR from the receive buffers. */
89479 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
89480 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89481 index c1d124d..acfc59e 100644
89482 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89483 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89484 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
89485 write_wr.wr.rdma.remote_addr = to;
89486
89487 /* Post It */
89488 - atomic_inc(&rdma_stat_write);
89489 + atomic_inc_unchecked(&rdma_stat_write);
89490 if (svc_rdma_send(xprt, &write_wr))
89491 goto err;
89492 return 0;
89493 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
89494 index 62e4f9b..dd3f2d7 100644
89495 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
89496 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
89497 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
89498 return;
89499
89500 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
89501 - atomic_inc(&rdma_stat_rq_poll);
89502 + atomic_inc_unchecked(&rdma_stat_rq_poll);
89503
89504 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
89505 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
89506 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
89507 }
89508
89509 if (ctxt)
89510 - atomic_inc(&rdma_stat_rq_prod);
89511 + atomic_inc_unchecked(&rdma_stat_rq_prod);
89512
89513 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
89514 /*
89515 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
89516 return;
89517
89518 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
89519 - atomic_inc(&rdma_stat_sq_poll);
89520 + atomic_inc_unchecked(&rdma_stat_sq_poll);
89521 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
89522 if (wc.status != IB_WC_SUCCESS)
89523 /* Close the transport */
89524 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
89525 }
89526
89527 if (ctxt)
89528 - atomic_inc(&rdma_stat_sq_prod);
89529 + atomic_inc_unchecked(&rdma_stat_sq_prod);
89530 }
89531
89532 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
89533 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
89534 spin_lock_bh(&xprt->sc_lock);
89535 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
89536 spin_unlock_bh(&xprt->sc_lock);
89537 - atomic_inc(&rdma_stat_sq_starve);
89538 + atomic_inc_unchecked(&rdma_stat_sq_starve);
89539
89540 /* See if we can opportunistically reap SQ WR to make room */
89541 sq_cq_reap(xprt);
89542 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
89543 index 9bc6db0..47ac8c0 100644
89544 --- a/net/sysctl_net.c
89545 +++ b/net/sysctl_net.c
89546 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
89547 kgid_t root_gid = make_kgid(net->user_ns, 0);
89548
89549 /* Allow network administrator to have same access as root. */
89550 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
89551 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
89552 uid_eq(root_uid, current_uid())) {
89553 int mode = (table->mode >> 6) & 7;
89554 return (mode << 6) | (mode << 3) | mode;
89555 diff --git a/net/tipc/link.c b/net/tipc/link.c
89556 index daa6080..02d357f 100644
89557 --- a/net/tipc/link.c
89558 +++ b/net/tipc/link.c
89559 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
89560 struct tipc_msg fragm_hdr;
89561 struct sk_buff *buf, *buf_chain, *prev;
89562 u32 fragm_crs, fragm_rest, hsz, sect_rest;
89563 - const unchar *sect_crs;
89564 + const unchar __user *sect_crs;
89565 int curr_sect;
89566 u32 fragm_no;
89567
89568 @@ -1242,7 +1242,7 @@ again:
89569
89570 if (!sect_rest) {
89571 sect_rest = msg_sect[++curr_sect].iov_len;
89572 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
89573 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
89574 }
89575
89576 if (sect_rest < fragm_rest)
89577 @@ -1261,7 +1261,7 @@ error:
89578 }
89579 } else
89580 skb_copy_to_linear_data_offset(buf, fragm_crs,
89581 - sect_crs, sz);
89582 + (const void __force_kernel *)sect_crs, sz);
89583 sect_crs += sz;
89584 sect_rest -= sz;
89585 fragm_crs += sz;
89586 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
89587 index f2db8a8..9245aa4 100644
89588 --- a/net/tipc/msg.c
89589 +++ b/net/tipc/msg.c
89590 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
89591 msg_sect[cnt].iov_len);
89592 else
89593 skb_copy_to_linear_data_offset(*buf, pos,
89594 - msg_sect[cnt].iov_base,
89595 + (const void __force_kernel *)msg_sect[cnt].iov_base,
89596 msg_sect[cnt].iov_len);
89597 pos += msg_sect[cnt].iov_len;
89598 }
89599 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
89600 index 6b42d47..2ac24d5 100644
89601 --- a/net/tipc/subscr.c
89602 +++ b/net/tipc/subscr.c
89603 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
89604 {
89605 struct iovec msg_sect;
89606
89607 - msg_sect.iov_base = (void *)&sub->evt;
89608 + msg_sect.iov_base = (void __force_user *)&sub->evt;
89609 msg_sect.iov_len = sizeof(struct tipc_event);
89610
89611 sub->evt.event = htohl(event, sub->swap);
89612 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
89613 index 5b5c876..6713b81 100644
89614 --- a/net/unix/af_unix.c
89615 +++ b/net/unix/af_unix.c
89616 @@ -786,6 +786,12 @@ static struct sock *unix_find_other(struct net *net,
89617 err = -ECONNREFUSED;
89618 if (!S_ISSOCK(inode->i_mode))
89619 goto put_fail;
89620 +
89621 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
89622 + err = -EACCES;
89623 + goto put_fail;
89624 + }
89625 +
89626 u = unix_find_socket_byinode(inode);
89627 if (!u)
89628 goto put_fail;
89629 @@ -806,6 +812,13 @@ static struct sock *unix_find_other(struct net *net,
89630 if (u) {
89631 struct dentry *dentry;
89632 dentry = unix_sk(u)->path.dentry;
89633 +
89634 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
89635 + err = -EPERM;
89636 + sock_put(u);
89637 + goto fail;
89638 + }
89639 +
89640 if (dentry)
89641 touch_atime(&unix_sk(u)->path);
89642 } else
89643 @@ -839,12 +852,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
89644 */
89645 err = security_path_mknod(&path, dentry, mode, 0);
89646 if (!err) {
89647 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
89648 + err = -EACCES;
89649 + goto out;
89650 + }
89651 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
89652 if (!err) {
89653 res->mnt = mntget(path.mnt);
89654 res->dentry = dget(dentry);
89655 + gr_handle_create(dentry, path.mnt);
89656 }
89657 }
89658 +out:
89659 done_path_create(&path, dentry);
89660 return err;
89661 }
89662 @@ -2326,9 +2345,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
89663 seq_puts(seq, "Num RefCount Protocol Flags Type St "
89664 "Inode Path\n");
89665 else {
89666 - struct sock *s = v;
89667 + struct sock *s = v, *peer;
89668 struct unix_sock *u = unix_sk(s);
89669 unix_state_lock(s);
89670 + peer = unix_peer(s);
89671 + unix_state_unlock(s);
89672 +
89673 + unix_state_double_lock(s, peer);
89674
89675 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
89676 s,
89677 @@ -2355,8 +2378,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
89678 }
89679 for ( ; i < len; i++)
89680 seq_putc(seq, u->addr->name->sun_path[i]);
89681 - }
89682 - unix_state_unlock(s);
89683 + } else if (peer)
89684 + seq_printf(seq, " P%lu", sock_i_ino(peer));
89685 +
89686 + unix_state_double_unlock(s, peer);
89687 seq_putc(seq, '\n');
89688 }
89689
89690 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
89691 index 8800604..0526440 100644
89692 --- a/net/unix/sysctl_net_unix.c
89693 +++ b/net/unix/sysctl_net_unix.c
89694 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
89695
89696 int __net_init unix_sysctl_register(struct net *net)
89697 {
89698 - struct ctl_table *table;
89699 + ctl_table_no_const *table;
89700
89701 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
89702 if (table == NULL)
89703 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
89704 index c8717c1..08539f5 100644
89705 --- a/net/wireless/wext-core.c
89706 +++ b/net/wireless/wext-core.c
89707 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
89708 */
89709
89710 /* Support for very large requests */
89711 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
89712 - (user_length > descr->max_tokens)) {
89713 + if (user_length > descr->max_tokens) {
89714 /* Allow userspace to GET more than max so
89715 * we can support any size GET requests.
89716 * There is still a limit : -ENOMEM.
89717 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
89718 }
89719 }
89720
89721 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
89722 - /*
89723 - * If this is a GET, but not NOMAX, it means that the extra
89724 - * data is not bounded by userspace, but by max_tokens. Thus
89725 - * set the length to max_tokens. This matches the extra data
89726 - * allocation.
89727 - * The driver should fill it with the number of tokens it
89728 - * provided, and it may check iwp->length rather than having
89729 - * knowledge of max_tokens. If the driver doesn't change the
89730 - * iwp->length, this ioctl just copies back max_token tokens
89731 - * filled with zeroes. Hopefully the driver isn't claiming
89732 - * them to be valid data.
89733 - */
89734 - iwp->length = descr->max_tokens;
89735 - }
89736 -
89737 err = handler(dev, info, (union iwreq_data *) iwp, extra);
89738
89739 iwp->length += essid_compat;
89740 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
89741 index 07c5857..fde4018 100644
89742 --- a/net/xfrm/xfrm_policy.c
89743 +++ b/net/xfrm/xfrm_policy.c
89744 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
89745 {
89746 policy->walk.dead = 1;
89747
89748 - atomic_inc(&policy->genid);
89749 + atomic_inc_unchecked(&policy->genid);
89750
89751 if (del_timer(&policy->timer))
89752 xfrm_pol_put(policy);
89753 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
89754 hlist_add_head(&policy->bydst, chain);
89755 xfrm_pol_hold(policy);
89756 net->xfrm.policy_count[dir]++;
89757 - atomic_inc(&flow_cache_genid);
89758 + atomic_inc_unchecked(&flow_cache_genid);
89759 rt_genid_bump(net);
89760 if (delpol)
89761 __xfrm_policy_unlink(delpol, dir);
89762 @@ -1550,7 +1550,7 @@ free_dst:
89763 goto out;
89764 }
89765
89766 -static int inline
89767 +static inline int
89768 xfrm_dst_alloc_copy(void **target, const void *src, int size)
89769 {
89770 if (!*target) {
89771 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
89772 return 0;
89773 }
89774
89775 -static int inline
89776 +static inline int
89777 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
89778 {
89779 #ifdef CONFIG_XFRM_SUB_POLICY
89780 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
89781 #endif
89782 }
89783
89784 -static int inline
89785 +static inline int
89786 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
89787 {
89788 #ifdef CONFIG_XFRM_SUB_POLICY
89789 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
89790
89791 xdst->num_pols = num_pols;
89792 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
89793 - xdst->policy_genid = atomic_read(&pols[0]->genid);
89794 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
89795
89796 return xdst;
89797 }
89798 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
89799 if (xdst->xfrm_genid != dst->xfrm->genid)
89800 return 0;
89801 if (xdst->num_pols > 0 &&
89802 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
89803 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
89804 return 0;
89805
89806 mtu = dst_mtu(dst->child);
89807 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
89808 dst_ops->link_failure = xfrm_link_failure;
89809 if (likely(dst_ops->neigh_lookup == NULL))
89810 dst_ops->neigh_lookup = xfrm_neigh_lookup;
89811 - if (likely(afinfo->garbage_collect == NULL))
89812 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
89813 + if (likely(afinfo->garbage_collect == NULL)) {
89814 + pax_open_kernel();
89815 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
89816 + pax_close_kernel();
89817 + }
89818 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
89819 }
89820 spin_unlock(&xfrm_policy_afinfo_lock);
89821 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
89822 dst_ops->check = NULL;
89823 dst_ops->negative_advice = NULL;
89824 dst_ops->link_failure = NULL;
89825 - afinfo->garbage_collect = NULL;
89826 + pax_open_kernel();
89827 + *(void **)&afinfo->garbage_collect = NULL;
89828 + pax_close_kernel();
89829 }
89830 return err;
89831 }
89832 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
89833 sizeof(pol->xfrm_vec[i].saddr));
89834 pol->xfrm_vec[i].encap_family = mp->new_family;
89835 /* flush bundles */
89836 - atomic_inc(&pol->genid);
89837 + atomic_inc_unchecked(&pol->genid);
89838 }
89839 }
89840
89841 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
89842 index 3459692..e7cdb1a 100644
89843 --- a/net/xfrm/xfrm_state.c
89844 +++ b/net/xfrm/xfrm_state.c
89845 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
89846
89847 if (unlikely(afinfo == NULL))
89848 return -EAFNOSUPPORT;
89849 - typemap = afinfo->type_map;
89850 + typemap = (const struct xfrm_type **)afinfo->type_map;
89851
89852 - if (likely(typemap[type->proto] == NULL))
89853 + if (likely(typemap[type->proto] == NULL)) {
89854 + pax_open_kernel();
89855 typemap[type->proto] = type;
89856 - else
89857 + pax_close_kernel();
89858 + } else
89859 err = -EEXIST;
89860 xfrm_state_unlock_afinfo(afinfo);
89861 return err;
89862 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
89863
89864 if (unlikely(afinfo == NULL))
89865 return -EAFNOSUPPORT;
89866 - typemap = afinfo->type_map;
89867 + typemap = (const struct xfrm_type **)afinfo->type_map;
89868
89869 if (unlikely(typemap[type->proto] != type))
89870 err = -ENOENT;
89871 - else
89872 + else {
89873 + pax_open_kernel();
89874 typemap[type->proto] = NULL;
89875 + pax_close_kernel();
89876 + }
89877 xfrm_state_unlock_afinfo(afinfo);
89878 return err;
89879 }
89880 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
89881 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
89882 {
89883 struct xfrm_state_afinfo *afinfo;
89884 - const struct xfrm_type **typemap;
89885 const struct xfrm_type *type;
89886 int modload_attempted = 0;
89887
89888 @@ -235,9 +239,8 @@ retry:
89889 afinfo = xfrm_state_get_afinfo(family);
89890 if (unlikely(afinfo == NULL))
89891 return NULL;
89892 - typemap = afinfo->type_map;
89893
89894 - type = typemap[proto];
89895 + type = afinfo->type_map[proto];
89896 if (unlikely(type && !try_module_get(type->owner)))
89897 type = NULL;
89898 if (!type && !modload_attempted) {
89899 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
89900 return -EAFNOSUPPORT;
89901
89902 err = -EEXIST;
89903 - modemap = afinfo->mode_map;
89904 + modemap = (struct xfrm_mode **)afinfo->mode_map;
89905 if (modemap[mode->encap])
89906 goto out;
89907
89908 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
89909 if (!try_module_get(afinfo->owner))
89910 goto out;
89911
89912 - mode->afinfo = afinfo;
89913 + pax_open_kernel();
89914 + *(const void **)&mode->afinfo = afinfo;
89915 modemap[mode->encap] = mode;
89916 + pax_close_kernel();
89917 err = 0;
89918
89919 out:
89920 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
89921 return -EAFNOSUPPORT;
89922
89923 err = -ENOENT;
89924 - modemap = afinfo->mode_map;
89925 + modemap = (struct xfrm_mode **)afinfo->mode_map;
89926 if (likely(modemap[mode->encap] == mode)) {
89927 + pax_open_kernel();
89928 modemap[mode->encap] = NULL;
89929 + pax_close_kernel();
89930 module_put(mode->afinfo->owner);
89931 err = 0;
89932 }
89933 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
89934 index 05a6e3d..6716ec9 100644
89935 --- a/net/xfrm/xfrm_sysctl.c
89936 +++ b/net/xfrm/xfrm_sysctl.c
89937 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
89938
89939 int __net_init xfrm_sysctl_init(struct net *net)
89940 {
89941 - struct ctl_table *table;
89942 + ctl_table_no_const *table;
89943
89944 __xfrm_sysctl_init(net);
89945
89946 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
89947 index 0e801c3..5c8ad3b 100644
89948 --- a/scripts/Makefile.build
89949 +++ b/scripts/Makefile.build
89950 @@ -111,7 +111,7 @@ endif
89951 endif
89952
89953 # Do not include host rules unless needed
89954 -ifneq ($(hostprogs-y)$(hostprogs-m),)
89955 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
89956 include scripts/Makefile.host
89957 endif
89958
89959 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
89960 index 686cb0d..9d653bf 100644
89961 --- a/scripts/Makefile.clean
89962 +++ b/scripts/Makefile.clean
89963 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
89964 __clean-files := $(extra-y) $(always) \
89965 $(targets) $(clean-files) \
89966 $(host-progs) \
89967 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
89968 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
89969 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
89970
89971 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
89972
89973 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
89974 index 1ac414f..38575f7 100644
89975 --- a/scripts/Makefile.host
89976 +++ b/scripts/Makefile.host
89977 @@ -31,6 +31,8 @@
89978 # Note: Shared libraries consisting of C++ files are not supported
89979
89980 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
89981 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
89982 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
89983
89984 # C code
89985 # Executables compiled from a single .c file
89986 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
89987 # Shared libaries (only .c supported)
89988 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
89989 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
89990 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
89991 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
89992 # Remove .so files from "xxx-objs"
89993 host-cobjs := $(filter-out %.so,$(host-cobjs))
89994 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
89995
89996 -#Object (.o) files used by the shared libaries
89997 +# Object (.o) files used by the shared libaries
89998 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
89999 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
90000
90001 # output directory for programs/.o files
90002 # hostprogs-y := tools/build may have been specified. Retrieve directory
90003 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
90004 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
90005 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
90006 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
90007 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
90008 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
90009 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
90010 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
90011
90012 obj-dirs += $(host-objdirs)
90013 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
90014 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
90015 $(call if_changed_dep,host-cshobjs)
90016
90017 +# Compile .c file, create position independent .o file
90018 +# host-cxxshobjs -> .o
90019 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
90020 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
90021 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
90022 + $(call if_changed_dep,host-cxxshobjs)
90023 +
90024 # Link a shared library, based on position independent .o files
90025 # *.o -> .so shared library (host-cshlib)
90026 quiet_cmd_host-cshlib = HOSTLLD -shared $@
90027 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
90028 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
90029 $(call if_changed,host-cshlib)
90030
90031 +# Link a shared library, based on position independent .o files
90032 +# *.o -> .so shared library (host-cxxshlib)
90033 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
90034 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
90035 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
90036 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
90037 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
90038 + $(call if_changed,host-cxxshlib)
90039 +
90040 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
90041 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
90042 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
90043
90044 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
90045 index cb1f50c..cef2a7c 100644
90046 --- a/scripts/basic/fixdep.c
90047 +++ b/scripts/basic/fixdep.c
90048 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
90049 /*
90050 * Lookup a value in the configuration string.
90051 */
90052 -static int is_defined_config(const char *name, int len, unsigned int hash)
90053 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
90054 {
90055 struct item *aux;
90056
90057 @@ -211,10 +211,10 @@ static void clear_config(void)
90058 /*
90059 * Record the use of a CONFIG_* word.
90060 */
90061 -static void use_config(const char *m, int slen)
90062 +static void use_config(const char *m, unsigned int slen)
90063 {
90064 unsigned int hash = strhash(m, slen);
90065 - int c, i;
90066 + unsigned int c, i;
90067
90068 if (is_defined_config(m, slen, hash))
90069 return;
90070 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
90071
90072 static void parse_config_file(const char *map, size_t len)
90073 {
90074 - const int *end = (const int *) (map + len);
90075 + const unsigned int *end = (const unsigned int *) (map + len);
90076 /* start at +1, so that p can never be < map */
90077 - const int *m = (const int *) map + 1;
90078 + const unsigned int *m = (const unsigned int *) map + 1;
90079 const char *p, *q;
90080
90081 for (; m < end; m++) {
90082 @@ -406,7 +406,7 @@ static void print_deps(void)
90083 static void traps(void)
90084 {
90085 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
90086 - int *p = (int *)test;
90087 + unsigned int *p = (unsigned int *)test;
90088
90089 if (*p != INT_CONF) {
90090 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
90091 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
90092 new file mode 100644
90093 index 0000000..5e0222d
90094 --- /dev/null
90095 +++ b/scripts/gcc-plugin.sh
90096 @@ -0,0 +1,17 @@
90097 +#!/bin/bash
90098 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
90099 +#include "gcc-plugin.h"
90100 +#include "tree.h"
90101 +#include "tm.h"
90102 +#include "rtl.h"
90103 +#ifdef ENABLE_BUILD_WITH_CXX
90104 +#warning $2
90105 +#else
90106 +#warning $1
90107 +#endif
90108 +EOF`
90109 +if [ $? -eq 0 ]
90110 +then
90111 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
90112 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
90113 +fi
90114 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
90115 index b3d907e..a4782ab 100644
90116 --- a/scripts/link-vmlinux.sh
90117 +++ b/scripts/link-vmlinux.sh
90118 @@ -152,7 +152,7 @@ else
90119 fi;
90120
90121 # final build of init/
90122 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
90123 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
90124
90125 kallsymso=""
90126 kallsyms_vmlinux=""
90127 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
90128 index df4fc23..0ea719d 100644
90129 --- a/scripts/mod/file2alias.c
90130 +++ b/scripts/mod/file2alias.c
90131 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
90132 unsigned long size, unsigned long id_size,
90133 void *symval)
90134 {
90135 - int i;
90136 + unsigned int i;
90137
90138 if (size % id_size || size < id_size) {
90139 if (cross_build != 0)
90140 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
90141 /* USB is special because the bcdDevice can be matched against a numeric range */
90142 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
90143 static void do_usb_entry(struct usb_device_id *id,
90144 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
90145 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
90146 unsigned char range_lo, unsigned char range_hi,
90147 unsigned char max, struct module *mod)
90148 {
90149 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
90150 {
90151 unsigned int devlo, devhi;
90152 unsigned char chi, clo, max;
90153 - int ndigits;
90154 + unsigned int ndigits;
90155
90156 id->match_flags = TO_NATIVE(id->match_flags);
90157 id->idVendor = TO_NATIVE(id->idVendor);
90158 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
90159 for (i = 0; i < count; i++) {
90160 const char *id = (char *)devs[i].id;
90161 char acpi_id[sizeof(devs[0].id)];
90162 - int j;
90163 + unsigned int j;
90164
90165 buf_printf(&mod->dev_table_buf,
90166 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
90167 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90168
90169 for (j = 0; j < PNP_MAX_DEVICES; j++) {
90170 const char *id = (char *)card->devs[j].id;
90171 - int i2, j2;
90172 + unsigned int i2, j2;
90173 int dup = 0;
90174
90175 if (!id[0])
90176 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
90177 /* add an individual alias for every device entry */
90178 if (!dup) {
90179 char acpi_id[sizeof(card->devs[0].id)];
90180 - int k;
90181 + unsigned int k;
90182
90183 buf_printf(&mod->dev_table_buf,
90184 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
90185 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
90186 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
90187 char *alias)
90188 {
90189 - int i, j;
90190 + unsigned int i, j;
90191
90192 sprintf(alias, "dmi*");
90193
90194 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
90195 index ff36c50..7ab4fa9 100644
90196 --- a/scripts/mod/modpost.c
90197 +++ b/scripts/mod/modpost.c
90198 @@ -929,6 +929,7 @@ enum mismatch {
90199 ANY_INIT_TO_ANY_EXIT,
90200 ANY_EXIT_TO_ANY_INIT,
90201 EXPORT_TO_INIT_EXIT,
90202 + DATA_TO_TEXT
90203 };
90204
90205 struct sectioncheck {
90206 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
90207 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
90208 .mismatch = EXPORT_TO_INIT_EXIT,
90209 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
90210 +},
90211 +/* Do not reference code from writable data */
90212 +{
90213 + .fromsec = { DATA_SECTIONS, NULL },
90214 + .tosec = { TEXT_SECTIONS, NULL },
90215 + .mismatch = DATA_TO_TEXT
90216 }
90217 };
90218
90219 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
90220 continue;
90221 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
90222 continue;
90223 - if (sym->st_value == addr)
90224 - return sym;
90225 /* Find a symbol nearby - addr are maybe negative */
90226 d = sym->st_value - addr;
90227 + if (d == 0)
90228 + return sym;
90229 if (d < 0)
90230 d = addr - sym->st_value;
90231 if (d < distance) {
90232 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
90233 tosym, prl_to, prl_to, tosym);
90234 free(prl_to);
90235 break;
90236 + case DATA_TO_TEXT:
90237 +#if 0
90238 + fprintf(stderr,
90239 + "The %s %s:%s references\n"
90240 + "the %s %s:%s%s\n",
90241 + from, fromsec, fromsym, to, tosec, tosym, to_p);
90242 +#endif
90243 + break;
90244 }
90245 fprintf(stderr, "\n");
90246 }
90247 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
90248 static void check_sec_ref(struct module *mod, const char *modname,
90249 struct elf_info *elf)
90250 {
90251 - int i;
90252 + unsigned int i;
90253 Elf_Shdr *sechdrs = elf->sechdrs;
90254
90255 /* Walk through all sections */
90256 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
90257 va_end(ap);
90258 }
90259
90260 -void buf_write(struct buffer *buf, const char *s, int len)
90261 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
90262 {
90263 if (buf->size - buf->pos < len) {
90264 buf->size += len + SZ;
90265 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
90266 if (fstat(fileno(file), &st) < 0)
90267 goto close_write;
90268
90269 - if (st.st_size != b->pos)
90270 + if (st.st_size != (off_t)b->pos)
90271 goto close_write;
90272
90273 tmp = NOFAIL(malloc(b->pos));
90274 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
90275 index 51207e4..f7d603d 100644
90276 --- a/scripts/mod/modpost.h
90277 +++ b/scripts/mod/modpost.h
90278 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
90279
90280 struct buffer {
90281 char *p;
90282 - int pos;
90283 - int size;
90284 + unsigned int pos;
90285 + unsigned int size;
90286 };
90287
90288 void __attribute__((format(printf, 2, 3)))
90289 buf_printf(struct buffer *buf, const char *fmt, ...);
90290
90291 void
90292 -buf_write(struct buffer *buf, const char *s, int len);
90293 +buf_write(struct buffer *buf, const char *s, unsigned int len);
90294
90295 struct module {
90296 struct module *next;
90297 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
90298 index 9dfcd6d..099068e 100644
90299 --- a/scripts/mod/sumversion.c
90300 +++ b/scripts/mod/sumversion.c
90301 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
90302 goto out;
90303 }
90304
90305 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
90306 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
90307 warn("writing sum in %s failed: %s\n",
90308 filename, strerror(errno));
90309 goto out;
90310 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
90311 index acb8650..b8c5f02 100644
90312 --- a/scripts/package/builddeb
90313 +++ b/scripts/package/builddeb
90314 @@ -246,6 +246,7 @@ fi
90315 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
90316 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
90317 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
90318 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
90319 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
90320 mkdir -p "$destdir"
90321 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
90322 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
90323 index 68bb4ef..2f419e1 100644
90324 --- a/scripts/pnmtologo.c
90325 +++ b/scripts/pnmtologo.c
90326 @@ -244,14 +244,14 @@ static void write_header(void)
90327 fprintf(out, " * Linux logo %s\n", logoname);
90328 fputs(" */\n\n", out);
90329 fputs("#include <linux/linux_logo.h>\n\n", out);
90330 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
90331 + fprintf(out, "static unsigned char %s_data[] = {\n",
90332 logoname);
90333 }
90334
90335 static void write_footer(void)
90336 {
90337 fputs("\n};\n\n", out);
90338 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
90339 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
90340 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
90341 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
90342 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
90343 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
90344 fputs("\n};\n\n", out);
90345
90346 /* write logo clut */
90347 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
90348 + fprintf(out, "static unsigned char %s_clut[] = {\n",
90349 logoname);
90350 write_hex_cnt = 0;
90351 for (i = 0; i < logo_clutsize; i++) {
90352 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
90353 index e4fd45b..2eeb5c4 100644
90354 --- a/scripts/sortextable.h
90355 +++ b/scripts/sortextable.h
90356 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
90357 const char *secstrtab;
90358 const char *strtab;
90359 char *extab_image;
90360 - int extab_index = 0;
90361 - int i;
90362 - int idx;
90363 + unsigned int extab_index = 0;
90364 + unsigned int i;
90365 + unsigned int idx;
90366
90367 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
90368 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
90369 diff --git a/security/Kconfig b/security/Kconfig
90370 index e9c6ac7..20df9f1 100644
90371 --- a/security/Kconfig
90372 +++ b/security/Kconfig
90373 @@ -4,6 +4,944 @@
90374
90375 menu "Security options"
90376
90377 +menu "Grsecurity"
90378 +
90379 + config ARCH_TRACK_EXEC_LIMIT
90380 + bool
90381 +
90382 + config PAX_KERNEXEC_PLUGIN
90383 + bool
90384 +
90385 + config PAX_PER_CPU_PGD
90386 + bool
90387 +
90388 + config TASK_SIZE_MAX_SHIFT
90389 + int
90390 + depends on X86_64
90391 + default 47 if !PAX_PER_CPU_PGD
90392 + default 42 if PAX_PER_CPU_PGD
90393 +
90394 + config PAX_ENABLE_PAE
90395 + bool
90396 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
90397 +
90398 + config PAX_USERCOPY_SLABS
90399 + bool
90400 +
90401 +config GRKERNSEC
90402 + bool "Grsecurity"
90403 + select CRYPTO
90404 + select CRYPTO_SHA256
90405 + select PROC_FS
90406 + select STOP_MACHINE
90407 + help
90408 + If you say Y here, you will be able to configure many features
90409 + that will enhance the security of your system. It is highly
90410 + recommended that you say Y here and read through the help
90411 + for each option so that you fully understand the features and
90412 + can evaluate their usefulness for your machine.
90413 +
90414 +choice
90415 + prompt "Configuration Method"
90416 + depends on GRKERNSEC
90417 + default GRKERNSEC_CONFIG_CUSTOM
90418 + help
90419 +
90420 +config GRKERNSEC_CONFIG_AUTO
90421 + bool "Automatic"
90422 + help
90423 + If you choose this configuration method, you'll be able to answer a small
90424 + number of simple questions about how you plan to use this kernel.
90425 + The settings of grsecurity and PaX will be automatically configured for
90426 + the highest commonly-used settings within the provided constraints.
90427 +
90428 + If you require additional configuration, custom changes can still be made
90429 + from the "custom configuration" menu.
90430 +
90431 +config GRKERNSEC_CONFIG_CUSTOM
90432 + bool "Custom"
90433 + help
90434 + If you choose this configuration method, you'll be able to configure all
90435 + grsecurity and PaX settings manually. Via this method, no options are
90436 + automatically enabled.
90437 +
90438 +endchoice
90439 +
90440 +choice
90441 + prompt "Usage Type"
90442 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90443 + default GRKERNSEC_CONFIG_SERVER
90444 + help
90445 +
90446 +config GRKERNSEC_CONFIG_SERVER
90447 + bool "Server"
90448 + help
90449 + Choose this option if you plan to use this kernel on a server.
90450 +
90451 +config GRKERNSEC_CONFIG_DESKTOP
90452 + bool "Desktop"
90453 + help
90454 + Choose this option if you plan to use this kernel on a desktop.
90455 +
90456 +endchoice
90457 +
90458 +choice
90459 + prompt "Virtualization Type"
90460 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
90461 + default GRKERNSEC_CONFIG_VIRT_NONE
90462 + help
90463 +
90464 +config GRKERNSEC_CONFIG_VIRT_NONE
90465 + bool "None"
90466 + help
90467 + Choose this option if this kernel will be run on bare metal.
90468 +
90469 +config GRKERNSEC_CONFIG_VIRT_GUEST
90470 + bool "Guest"
90471 + help
90472 + Choose this option if this kernel will be run as a VM guest.
90473 +
90474 +config GRKERNSEC_CONFIG_VIRT_HOST
90475 + bool "Host"
90476 + help
90477 + Choose this option if this kernel will be run as a VM host.
90478 +
90479 +endchoice
90480 +
90481 +choice
90482 + prompt "Virtualization Hardware"
90483 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
90484 + help
90485 +
90486 +config GRKERNSEC_CONFIG_VIRT_EPT
90487 + bool "EPT/RVI Processor Support"
90488 + depends on X86
90489 + help
90490 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
90491 + hardware virtualization. This allows for additional kernel hardening protections
90492 + to operate without additional performance impact.
90493 +
90494 + To see if your Intel processor supports EPT, see:
90495 + http://ark.intel.com/Products/VirtualizationTechnology
90496 + (Most Core i3/5/7 support EPT)
90497 +
90498 + To see if your AMD processor supports RVI, see:
90499 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
90500 +
90501 +config GRKERNSEC_CONFIG_VIRT_SOFT
90502 + bool "First-gen/No Hardware Virtualization"
90503 + help
90504 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
90505 + support hardware virtualization or doesn't support the EPT/RVI extensions.
90506 +
90507 +endchoice
90508 +
90509 +choice
90510 + prompt "Virtualization Software"
90511 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
90512 + help
90513 +
90514 +config GRKERNSEC_CONFIG_VIRT_XEN
90515 + bool "Xen"
90516 + help
90517 + Choose this option if this kernel is running as a Xen guest or host.
90518 +
90519 +config GRKERNSEC_CONFIG_VIRT_VMWARE
90520 + bool "VMWare"
90521 + help
90522 + Choose this option if this kernel is running as a VMWare guest or host.
90523 +
90524 +config GRKERNSEC_CONFIG_VIRT_KVM
90525 + bool "KVM"
90526 + help
90527 + Choose this option if this kernel is running as a KVM guest or host.
90528 +
90529 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
90530 + bool "VirtualBox"
90531 + help
90532 + Choose this option if this kernel is running as a VirtualBox guest or host.
90533 +
90534 +endchoice
90535 +
90536 +choice
90537 + prompt "Required Priorities"
90538 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90539 + default GRKERNSEC_CONFIG_PRIORITY_PERF
90540 + help
90541 +
90542 +config GRKERNSEC_CONFIG_PRIORITY_PERF
90543 + bool "Performance"
90544 + help
90545 + Choose this option if performance is of highest priority for this deployment
90546 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
90547 + clearing of structures intended for userland, and freed memory sanitizing will
90548 + be disabled.
90549 +
90550 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
90551 + bool "Security"
90552 + help
90553 + Choose this option if security is of highest priority for this deployment of
90554 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
90555 + for userland, and freed memory sanitizing will be enabled for this kernel.
90556 + In a worst-case scenario, these features can introduce a 20% performance hit
90557 + (UDEREF on x64 contributing half of this hit).
90558 +
90559 +endchoice
90560 +
90561 +menu "Default Special Groups"
90562 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90563 +
90564 +config GRKERNSEC_PROC_GID
90565 + int "GID exempted from /proc restrictions"
90566 + default 1001
90567 + help
90568 + Setting this GID determines which group will be exempted from
90569 + grsecurity's /proc restrictions, allowing users of the specified
90570 + group to view network statistics and the existence of other users'
90571 + processes on the system. This GID may also be chosen at boot time
90572 + via "grsec_proc_gid=" on the kernel commandline.
90573 +
90574 +config GRKERNSEC_TPE_UNTRUSTED_GID
90575 + int "GID for TPE-untrusted users"
90576 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
90577 + default 1005
90578 + help
90579 + Setting this GID determines which group untrusted users should
90580 + be added to. These users will be placed under grsecurity's Trusted Path
90581 + Execution mechanism, preventing them from executing their own binaries.
90582 + The users will only be able to execute binaries in directories owned and
90583 + writable only by the root user. If the sysctl option is enabled, a sysctl
90584 + option with name "tpe_gid" is created.
90585 +
90586 +config GRKERNSEC_TPE_TRUSTED_GID
90587 + int "GID for TPE-trusted users"
90588 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
90589 + default 1005
90590 + help
90591 + Setting this GID determines what group TPE restrictions will be
90592 + *disabled* for. If the sysctl option is enabled, a sysctl option
90593 + with name "tpe_gid" is created.
90594 +
90595 +config GRKERNSEC_SYMLINKOWN_GID
90596 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
90597 + depends on GRKERNSEC_CONFIG_SERVER
90598 + default 1006
90599 + help
90600 + Setting this GID determines what group kernel-enforced
90601 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
90602 + is enabled, a sysctl option with name "symlinkown_gid" is created.
90603 +
90604 +
90605 +endmenu
90606 +
90607 +menu "Customize Configuration"
90608 +depends on GRKERNSEC
90609 +
90610 +menu "PaX"
90611 +
90612 +config PAX
90613 + bool "Enable various PaX features"
90614 + default y if GRKERNSEC_CONFIG_AUTO
90615 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
90616 + help
90617 + This allows you to enable various PaX features. PaX adds
90618 + intrusion prevention mechanisms to the kernel that reduce
90619 + the risks posed by exploitable memory corruption bugs.
90620 +
90621 +menu "PaX Control"
90622 + depends on PAX
90623 +
90624 +config PAX_SOFTMODE
90625 + bool 'Support soft mode'
90626 + help
90627 + Enabling this option will allow you to run PaX in soft mode, that
90628 + is, PaX features will not be enforced by default, only on executables
90629 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
90630 + support as they are the only way to mark executables for soft mode use.
90631 +
90632 + Soft mode can be activated by using the "pax_softmode=1" kernel command
90633 + line option on boot. Furthermore you can control various PaX features
90634 + at runtime via the entries in /proc/sys/kernel/pax.
90635 +
90636 +config PAX_EI_PAX
90637 + bool 'Use legacy ELF header marking'
90638 + default y if GRKERNSEC_CONFIG_AUTO
90639 + help
90640 + Enabling this option will allow you to control PaX features on
90641 + a per executable basis via the 'chpax' utility available at
90642 + http://pax.grsecurity.net/. The control flags will be read from
90643 + an otherwise reserved part of the ELF header. This marking has
90644 + numerous drawbacks (no support for soft-mode, toolchain does not
90645 + know about the non-standard use of the ELF header) therefore it
90646 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
90647 + support.
90648 +
90649 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
90650 + support as well, they will override the legacy EI_PAX marks.
90651 +
90652 + If you enable none of the marking options then all applications
90653 + will run with PaX enabled on them by default.
90654 +
90655 +config PAX_PT_PAX_FLAGS
90656 + bool 'Use ELF program header marking'
90657 + default y if GRKERNSEC_CONFIG_AUTO
90658 + help
90659 + Enabling this option will allow you to control PaX features on
90660 + a per executable basis via the 'paxctl' utility available at
90661 + http://pax.grsecurity.net/. The control flags will be read from
90662 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
90663 + has the benefits of supporting both soft mode and being fully
90664 + integrated into the toolchain (the binutils patch is available
90665 + from http://pax.grsecurity.net).
90666 +
90667 + Note that if you enable the legacy EI_PAX marking support as well,
90668 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
90669 +
90670 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
90671 + must make sure that the marks are the same if a binary has both marks.
90672 +
90673 + If you enable none of the marking options then all applications
90674 + will run with PaX enabled on them by default.
90675 +
90676 +config PAX_XATTR_PAX_FLAGS
90677 + bool 'Use filesystem extended attributes marking'
90678 + default y if GRKERNSEC_CONFIG_AUTO
90679 + select CIFS_XATTR if CIFS
90680 + select EXT2_FS_XATTR if EXT2_FS
90681 + select EXT3_FS_XATTR if EXT3_FS
90682 + select EXT4_FS_XATTR if EXT4_FS
90683 + select JFFS2_FS_XATTR if JFFS2_FS
90684 + select REISERFS_FS_XATTR if REISERFS_FS
90685 + select SQUASHFS_XATTR if SQUASHFS
90686 + select TMPFS_XATTR if TMPFS
90687 + select UBIFS_FS_XATTR if UBIFS_FS
90688 + help
90689 + Enabling this option will allow you to control PaX features on
90690 + a per executable basis via the 'setfattr' utility. The control
90691 + flags will be read from the user.pax.flags extended attribute of
90692 + the file. This marking has the benefit of supporting binary-only
90693 + applications that self-check themselves (e.g., skype) and would
90694 + not tolerate chpax/paxctl changes. The main drawback is that
90695 + extended attributes are not supported by some filesystems (e.g.,
90696 + isofs, udf, vfat) so copying files through such filesystems will
90697 + lose the extended attributes and these PaX markings.
90698 +
90699 + Note that if you enable the legacy EI_PAX marking support as well,
90700 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
90701 +
90702 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
90703 + must make sure that the marks are the same if a binary has both marks.
90704 +
90705 + If you enable none of the marking options then all applications
90706 + will run with PaX enabled on them by default.
90707 +
90708 +choice
90709 + prompt 'MAC system integration'
90710 + default PAX_HAVE_ACL_FLAGS
90711 + help
90712 + Mandatory Access Control systems have the option of controlling
90713 + PaX flags on a per executable basis, choose the method supported
90714 + by your particular system.
90715 +
90716 + - "none": if your MAC system does not interact with PaX,
90717 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
90718 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
90719 +
90720 + NOTE: this option is for developers/integrators only.
90721 +
90722 + config PAX_NO_ACL_FLAGS
90723 + bool 'none'
90724 +
90725 + config PAX_HAVE_ACL_FLAGS
90726 + bool 'direct'
90727 +
90728 + config PAX_HOOK_ACL_FLAGS
90729 + bool 'hook'
90730 +endchoice
90731 +
90732 +endmenu
90733 +
90734 +menu "Non-executable pages"
90735 + depends on PAX
90736 +
90737 +config PAX_NOEXEC
90738 + bool "Enforce non-executable pages"
90739 + default y if GRKERNSEC_CONFIG_AUTO
90740 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
90741 + help
90742 + By design some architectures do not allow for protecting memory
90743 + pages against execution or even if they do, Linux does not make
90744 + use of this feature. In practice this means that if a page is
90745 + readable (such as the stack or heap) it is also executable.
90746 +
90747 + There is a well known exploit technique that makes use of this
90748 + fact and a common programming mistake where an attacker can
90749 + introduce code of his choice somewhere in the attacked program's
90750 + memory (typically the stack or the heap) and then execute it.
90751 +
90752 + If the attacked program was running with different (typically
90753 + higher) privileges than that of the attacker, then he can elevate
90754 + his own privilege level (e.g. get a root shell, write to files for
90755 + which he does not have write access to, etc).
90756 +
90757 + Enabling this option will let you choose from various features
90758 + that prevent the injection and execution of 'foreign' code in
90759 + a program.
90760 +
90761 + This will also break programs that rely on the old behaviour and
90762 + expect that dynamically allocated memory via the malloc() family
90763 + of functions is executable (which it is not). Notable examples
90764 + are the XFree86 4.x server, the java runtime and wine.
90765 +
90766 +config PAX_PAGEEXEC
90767 + bool "Paging based non-executable pages"
90768 + default y if GRKERNSEC_CONFIG_AUTO
90769 + 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)
90770 + select S390_SWITCH_AMODE if S390
90771 + select S390_EXEC_PROTECT if S390
90772 + select ARCH_TRACK_EXEC_LIMIT if X86_32
90773 + help
90774 + This implementation is based on the paging feature of the CPU.
90775 + On i386 without hardware non-executable bit support there is a
90776 + variable but usually low performance impact, however on Intel's
90777 + P4 core based CPUs it is very high so you should not enable this
90778 + for kernels meant to be used on such CPUs.
90779 +
90780 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
90781 + with hardware non-executable bit support there is no performance
90782 + impact, on ppc the impact is negligible.
90783 +
90784 + Note that several architectures require various emulations due to
90785 + badly designed userland ABIs, this will cause a performance impact
90786 + but will disappear as soon as userland is fixed. For example, ppc
90787 + userland MUST have been built with secure-plt by a recent toolchain.
90788 +
90789 +config PAX_SEGMEXEC
90790 + bool "Segmentation based non-executable pages"
90791 + default y if GRKERNSEC_CONFIG_AUTO
90792 + depends on PAX_NOEXEC && X86_32
90793 + help
90794 + This implementation is based on the segmentation feature of the
90795 + CPU and has a very small performance impact, however applications
90796 + will be limited to a 1.5 GB address space instead of the normal
90797 + 3 GB.
90798 +
90799 +config PAX_EMUTRAMP
90800 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
90801 + default y if PARISC
90802 + help
90803 + There are some programs and libraries that for one reason or
90804 + another attempt to execute special small code snippets from
90805 + non-executable memory pages. Most notable examples are the
90806 + signal handler return code generated by the kernel itself and
90807 + the GCC trampolines.
90808 +
90809 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
90810 + such programs will no longer work under your kernel.
90811 +
90812 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
90813 + utilities to enable trampoline emulation for the affected programs
90814 + yet still have the protection provided by the non-executable pages.
90815 +
90816 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
90817 + your system will not even boot.
90818 +
90819 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
90820 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
90821 + for the affected files.
90822 +
90823 + NOTE: enabling this feature *may* open up a loophole in the
90824 + protection provided by non-executable pages that an attacker
90825 + could abuse. Therefore the best solution is to not have any
90826 + files on your system that would require this option. This can
90827 + be achieved by not using libc5 (which relies on the kernel
90828 + signal handler return code) and not using or rewriting programs
90829 + that make use of the nested function implementation of GCC.
90830 + Skilled users can just fix GCC itself so that it implements
90831 + nested function calls in a way that does not interfere with PaX.
90832 +
90833 +config PAX_EMUSIGRT
90834 + bool "Automatically emulate sigreturn trampolines"
90835 + depends on PAX_EMUTRAMP && PARISC
90836 + default y
90837 + help
90838 + Enabling this option will have the kernel automatically detect
90839 + and emulate signal return trampolines executing on the stack
90840 + that would otherwise lead to task termination.
90841 +
90842 + This solution is intended as a temporary one for users with
90843 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
90844 + Modula-3 runtime, etc) or executables linked to such, basically
90845 + everything that does not specify its own SA_RESTORER function in
90846 + normal executable memory like glibc 2.1+ does.
90847 +
90848 + On parisc you MUST enable this option, otherwise your system will
90849 + not even boot.
90850 +
90851 + NOTE: this feature cannot be disabled on a per executable basis
90852 + and since it *does* open up a loophole in the protection provided
90853 + by non-executable pages, the best solution is to not have any
90854 + files on your system that would require this option.
90855 +
90856 +config PAX_MPROTECT
90857 + bool "Restrict mprotect()"
90858 + default y if GRKERNSEC_CONFIG_AUTO
90859 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
90860 + help
90861 + Enabling this option will prevent programs from
90862 + - changing the executable status of memory pages that were
90863 + not originally created as executable,
90864 + - making read-only executable pages writable again,
90865 + - creating executable pages from anonymous memory,
90866 + - making read-only-after-relocations (RELRO) data pages writable again.
90867 +
90868 + You should say Y here to complete the protection provided by
90869 + the enforcement of non-executable pages.
90870 +
90871 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
90872 + this feature on a per file basis.
90873 +
90874 +config PAX_MPROTECT_COMPAT
90875 + bool "Use legacy/compat protection demoting (read help)"
90876 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
90877 + depends on PAX_MPROTECT
90878 + help
90879 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
90880 + by sending the proper error code to the application. For some broken
90881 + userland, this can cause problems with Python or other applications. The
90882 + current implementation however allows for applications like clamav to
90883 + detect if JIT compilation/execution is allowed and to fall back gracefully
90884 + to an interpreter-based mode if it does not. While we encourage everyone
90885 + to use the current implementation as-is and push upstream to fix broken
90886 + userland (note that the RWX logging option can assist with this), in some
90887 + environments this may not be possible. Having to disable MPROTECT
90888 + completely on certain binaries reduces the security benefit of PaX,
90889 + so this option is provided for those environments to revert to the old
90890 + behavior.
90891 +
90892 +config PAX_ELFRELOCS
90893 + bool "Allow ELF text relocations (read help)"
90894 + depends on PAX_MPROTECT
90895 + default n
90896 + help
90897 + Non-executable pages and mprotect() restrictions are effective
90898 + in preventing the introduction of new executable code into an
90899 + attacked task's address space. There remain only two venues
90900 + for this kind of attack: if the attacker can execute already
90901 + existing code in the attacked task then he can either have it
90902 + create and mmap() a file containing his code or have it mmap()
90903 + an already existing ELF library that does not have position
90904 + independent code in it and use mprotect() on it to make it
90905 + writable and copy his code there. While protecting against
90906 + the former approach is beyond PaX, the latter can be prevented
90907 + by having only PIC ELF libraries on one's system (which do not
90908 + need to relocate their code). If you are sure this is your case,
90909 + as is the case with all modern Linux distributions, then leave
90910 + this option disabled. You should say 'n' here.
90911 +
90912 +config PAX_ETEXECRELOCS
90913 + bool "Allow ELF ET_EXEC text relocations"
90914 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
90915 + select PAX_ELFRELOCS
90916 + default y
90917 + help
90918 + On some architectures there are incorrectly created applications
90919 + that require text relocations and would not work without enabling
90920 + this option. If you are an alpha, ia64 or parisc user, you should
90921 + enable this option and disable it once you have made sure that
90922 + none of your applications need it.
90923 +
90924 +config PAX_EMUPLT
90925 + bool "Automatically emulate ELF PLT"
90926 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
90927 + default y
90928 + help
90929 + Enabling this option will have the kernel automatically detect
90930 + and emulate the Procedure Linkage Table entries in ELF files.
90931 + On some architectures such entries are in writable memory, and
90932 + become non-executable leading to task termination. Therefore
90933 + it is mandatory that you enable this option on alpha, parisc,
90934 + sparc and sparc64, otherwise your system would not even boot.
90935 +
90936 + NOTE: this feature *does* open up a loophole in the protection
90937 + provided by the non-executable pages, therefore the proper
90938 + solution is to modify the toolchain to produce a PLT that does
90939 + not need to be writable.
90940 +
90941 +config PAX_DLRESOLVE
90942 + bool 'Emulate old glibc resolver stub'
90943 + depends on PAX_EMUPLT && SPARC
90944 + default n
90945 + help
90946 + This option is needed if userland has an old glibc (before 2.4)
90947 + that puts a 'save' instruction into the runtime generated resolver
90948 + stub that needs special emulation.
90949 +
90950 +config PAX_KERNEXEC
90951 + bool "Enforce non-executable kernel pages"
90952 + 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))
90953 + depends on ((X86 && (!X86_32 || X86_WP_WORKS_OK)) || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
90954 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
90955 + select PAX_KERNEXEC_PLUGIN if X86_64
90956 + help
90957 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
90958 + that is, enabling this option will make it harder to inject
90959 + and execute 'foreign' code in kernel memory itself.
90960 +
90961 +choice
90962 + prompt "Return Address Instrumentation Method"
90963 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
90964 + depends on PAX_KERNEXEC_PLUGIN
90965 + help
90966 + Select the method used to instrument function pointer dereferences.
90967 + Note that binary modules cannot be instrumented by this approach.
90968 +
90969 + Note that the implementation requires a gcc with plugin support,
90970 + i.e., gcc 4.5 or newer. You may need to install the supporting
90971 + headers explicitly in addition to the normal gcc package.
90972 +
90973 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
90974 + bool "bts"
90975 + help
90976 + This method is compatible with binary only modules but has
90977 + a higher runtime overhead.
90978 +
90979 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
90980 + bool "or"
90981 + depends on !PARAVIRT
90982 + help
90983 + This method is incompatible with binary only modules but has
90984 + a lower runtime overhead.
90985 +endchoice
90986 +
90987 +config PAX_KERNEXEC_PLUGIN_METHOD
90988 + string
90989 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
90990 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
90991 + default ""
90992 +
90993 +config PAX_KERNEXEC_MODULE_TEXT
90994 + int "Minimum amount of memory reserved for module code"
90995 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
90996 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
90997 + depends on PAX_KERNEXEC && X86_32 && MODULES
90998 + help
90999 + Due to implementation details the kernel must reserve a fixed
91000 + amount of memory for module code at compile time that cannot be
91001 + changed at runtime. Here you can specify the minimum amount
91002 + in MB that will be reserved. Due to the same implementation
91003 + details this size will always be rounded up to the next 2/4 MB
91004 + boundary (depends on PAE) so the actually available memory for
91005 + module code will usually be more than this minimum.
91006 +
91007 + The default 4 MB should be enough for most users but if you have
91008 + an excessive number of modules (e.g., most distribution configs
91009 + compile many drivers as modules) or use huge modules such as
91010 + nvidia's kernel driver, you will need to adjust this amount.
91011 + A good rule of thumb is to look at your currently loaded kernel
91012 + modules and add up their sizes.
91013 +
91014 +endmenu
91015 +
91016 +menu "Address Space Layout Randomization"
91017 + depends on PAX
91018 +
91019 +config PAX_ASLR
91020 + bool "Address Space Layout Randomization"
91021 + default y if GRKERNSEC_CONFIG_AUTO
91022 + help
91023 + Many if not most exploit techniques rely on the knowledge of
91024 + certain addresses in the attacked program. The following options
91025 + will allow the kernel to apply a certain amount of randomization
91026 + to specific parts of the program thereby forcing an attacker to
91027 + guess them in most cases. Any failed guess will most likely crash
91028 + the attacked program which allows the kernel to detect such attempts
91029 + and react on them. PaX itself provides no reaction mechanisms,
91030 + instead it is strongly encouraged that you make use of Nergal's
91031 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
91032 + (http://www.grsecurity.net/) built-in crash detection features or
91033 + develop one yourself.
91034 +
91035 + By saying Y here you can choose to randomize the following areas:
91036 + - top of the task's kernel stack
91037 + - top of the task's userland stack
91038 + - base address for mmap() requests that do not specify one
91039 + (this includes all libraries)
91040 + - base address of the main executable
91041 +
91042 + It is strongly recommended to say Y here as address space layout
91043 + randomization has negligible impact on performance yet it provides
91044 + a very effective protection.
91045 +
91046 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91047 + this feature on a per file basis.
91048 +
91049 +config PAX_RANDKSTACK
91050 + bool "Randomize kernel stack base"
91051 + default y if GRKERNSEC_CONFIG_AUTO
91052 + depends on X86_TSC && X86
91053 + help
91054 + By saying Y here the kernel will randomize every task's kernel
91055 + stack on every system call. This will not only force an attacker
91056 + to guess it but also prevent him from making use of possible
91057 + leaked information about it.
91058 +
91059 + Since the kernel stack is a rather scarce resource, randomization
91060 + may cause unexpected stack overflows, therefore you should very
91061 + carefully test your system. Note that once enabled in the kernel
91062 + configuration, this feature cannot be disabled on a per file basis.
91063 +
91064 +config PAX_RANDUSTACK
91065 + bool "Randomize user stack base"
91066 + default y if GRKERNSEC_CONFIG_AUTO
91067 + depends on PAX_ASLR
91068 + help
91069 + By saying Y here the kernel will randomize every task's userland
91070 + stack. The randomization is done in two steps where the second
91071 + one may apply a big amount of shift to the top of the stack and
91072 + cause problems for programs that want to use lots of memory (more
91073 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
91074 + For this reason the second step can be controlled by 'chpax' or
91075 + 'paxctl' on a per file basis.
91076 +
91077 +config PAX_RANDMMAP
91078 + bool "Randomize mmap() base"
91079 + default y if GRKERNSEC_CONFIG_AUTO
91080 + depends on PAX_ASLR
91081 + help
91082 + By saying Y here the kernel will use a randomized base address for
91083 + mmap() requests that do not specify one themselves. As a result
91084 + all dynamically loaded libraries will appear at random addresses
91085 + and therefore be harder to exploit by a technique where an attacker
91086 + attempts to execute library code for his purposes (e.g. spawn a
91087 + shell from an exploited program that is running at an elevated
91088 + privilege level).
91089 +
91090 + Furthermore, if a program is relinked as a dynamic ELF file, its
91091 + base address will be randomized as well, completing the full
91092 + randomization of the address space layout. Attacking such programs
91093 + becomes a guess game. You can find an example of doing this at
91094 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
91095 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
91096 +
91097 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
91098 + feature on a per file basis.
91099 +
91100 +endmenu
91101 +
91102 +menu "Miscellaneous hardening features"
91103 +
91104 +config PAX_MEMORY_SANITIZE
91105 + bool "Sanitize all freed memory"
91106 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91107 + depends on !HIBERNATION
91108 + help
91109 + By saying Y here the kernel will erase memory pages as soon as they
91110 + are freed. This in turn reduces the lifetime of data stored in the
91111 + pages, making it less likely that sensitive information such as
91112 + passwords, cryptographic secrets, etc stay in memory for too long.
91113 +
91114 + This is especially useful for programs whose runtime is short, long
91115 + lived processes and the kernel itself benefit from this as long as
91116 + they operate on whole memory pages and ensure timely freeing of pages
91117 + that may hold sensitive information.
91118 +
91119 + The tradeoff is performance impact, on a single CPU system kernel
91120 + compilation sees a 3% slowdown, other systems and workloads may vary
91121 + and you are advised to test this feature on your expected workload
91122 + before deploying it.
91123 +
91124 + Note that this feature does not protect data stored in live pages,
91125 + e.g., process memory swapped to disk may stay there for a long time.
91126 +
91127 +config PAX_MEMORY_STACKLEAK
91128 + bool "Sanitize kernel stack"
91129 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91130 + depends on X86
91131 + help
91132 + By saying Y here the kernel will erase the kernel stack before it
91133 + returns from a system call. This in turn reduces the information
91134 + that a kernel stack leak bug can reveal.
91135 +
91136 + Note that such a bug can still leak information that was put on
91137 + the stack by the current system call (the one eventually triggering
91138 + the bug) but traces of earlier system calls on the kernel stack
91139 + cannot leak anymore.
91140 +
91141 + The tradeoff is performance impact: on a single CPU system kernel
91142 + compilation sees a 1% slowdown, other systems and workloads may vary
91143 + and you are advised to test this feature on your expected workload
91144 + before deploying it.
91145 +
91146 + Note that the full feature requires a gcc with plugin support,
91147 + i.e., gcc 4.5 or newer. You may need to install the supporting
91148 + headers explicitly in addition to the normal gcc package. Using
91149 + older gcc versions means that functions with large enough stack
91150 + frames may leave uninitialized memory behind that may be exposed
91151 + to a later syscall leaking the stack.
91152 +
91153 +config PAX_MEMORY_STRUCTLEAK
91154 + bool "Forcibly initialize local variables copied to userland"
91155 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
91156 + help
91157 + By saying Y here the kernel will zero initialize some local
91158 + variables that are going to be copied to userland. This in
91159 + turn prevents unintended information leakage from the kernel
91160 + stack should later code forget to explicitly set all parts of
91161 + the copied variable.
91162 +
91163 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
91164 + at a much smaller coverage.
91165 +
91166 + Note that the implementation requires a gcc with plugin support,
91167 + i.e., gcc 4.5 or newer. You may need to install the supporting
91168 + headers explicitly in addition to the normal gcc package.
91169 +
91170 +config PAX_MEMORY_UDEREF
91171 + bool "Prevent invalid userland pointer dereference"
91172 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
91173 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
91174 + select PAX_PER_CPU_PGD if X86_64
91175 + help
91176 + By saying Y here the kernel will be prevented from dereferencing
91177 + userland pointers in contexts where the kernel expects only kernel
91178 + pointers. This is both a useful runtime debugging feature and a
91179 + security measure that prevents exploiting a class of kernel bugs.
91180 +
91181 + The tradeoff is that some virtualization solutions may experience
91182 + a huge slowdown and therefore you should not enable this feature
91183 + for kernels meant to run in such environments. Whether a given VM
91184 + solution is affected or not is best determined by simply trying it
91185 + out, the performance impact will be obvious right on boot as this
91186 + mechanism engages from very early on. A good rule of thumb is that
91187 + VMs running on CPUs without hardware virtualization support (i.e.,
91188 + the majority of IA-32 CPUs) will likely experience the slowdown.
91189 +
91190 +config PAX_REFCOUNT
91191 + bool "Prevent various kernel object reference counter overflows"
91192 + default y if GRKERNSEC_CONFIG_AUTO
91193 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
91194 + help
91195 + By saying Y here the kernel will detect and prevent overflowing
91196 + various (but not all) kinds of object reference counters. Such
91197 + overflows can normally occur due to bugs only and are often, if
91198 + not always, exploitable.
91199 +
91200 + The tradeoff is that data structures protected by an overflowed
91201 + refcount will never be freed and therefore will leak memory. Note
91202 + that this leak also happens even without this protection but in
91203 + that case the overflow can eventually trigger the freeing of the
91204 + data structure while it is still being used elsewhere, resulting
91205 + in the exploitable situation that this feature prevents.
91206 +
91207 + Since this has a negligible performance impact, you should enable
91208 + this feature.
91209 +
91210 +config PAX_CONSTIFY_PLUGIN
91211 + bool "Automatically constify eligible structures"
91212 + default y
91213 + depends on !UML
91214 + help
91215 + By saying Y here the compiler will automatically constify a class
91216 + of types that contain only function pointers. This reduces the
91217 + kernel's attack surface and also produces a better memory layout.
91218 +
91219 + Note that the implementation requires a gcc with plugin support,
91220 + i.e., gcc 4.5 or newer. You may need to install the supporting
91221 + headers explicitly in addition to the normal gcc package.
91222 +
91223 + Note that if some code really has to modify constified variables
91224 + then the source code will have to be patched to allow it. Examples
91225 + can be found in PaX itself (the no_const attribute) and for some
91226 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
91227 +
91228 +config PAX_USERCOPY
91229 + bool "Harden heap object copies between kernel and userland"
91230 + default y if GRKERNSEC_CONFIG_AUTO
91231 + depends on ARM || IA64 || PPC || SPARC || X86
91232 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
91233 + select PAX_USERCOPY_SLABS
91234 + help
91235 + By saying Y here the kernel will enforce the size of heap objects
91236 + when they are copied in either direction between the kernel and
91237 + userland, even if only a part of the heap object is copied.
91238 +
91239 + Specifically, this checking prevents information leaking from the
91240 + kernel heap during kernel to userland copies (if the kernel heap
91241 + object is otherwise fully initialized) and prevents kernel heap
91242 + overflows during userland to kernel copies.
91243 +
91244 + Note that the current implementation provides the strictest bounds
91245 + checks for the SLUB allocator.
91246 +
91247 + Enabling this option also enables per-slab cache protection against
91248 + data in a given cache being copied into/out of via userland
91249 + accessors. Though the whitelist of regions will be reduced over
91250 + time, it notably protects important data structures like task structs.
91251 +
91252 + If frame pointers are enabled on x86, this option will also restrict
91253 + copies into and out of the kernel stack to local variables within a
91254 + single frame.
91255 +
91256 + Since this has a negligible performance impact, you should enable
91257 + this feature.
91258 +
91259 +
91260 +config PAX_USERCOPY_DEBUG
91261 + bool
91262 + depends on X86 && PAX_USERCOPY
91263 + default n
91264 +
91265 +config PAX_SIZE_OVERFLOW
91266 + bool "Prevent various integer overflows in function size parameters"
91267 + default y if GRKERNSEC_CONFIG_AUTO
91268 + depends on X86
91269 + help
91270 + By saying Y here the kernel recomputes expressions of function
91271 + arguments marked by a size_overflow attribute with double integer
91272 + precision (DImode/TImode for 32/64 bit integer types).
91273 +
91274 + The recomputed argument is checked against TYPE_MAX and an event
91275 + is logged on overflow and the triggering process is killed.
91276 +
91277 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
91278 +
91279 + Note that the implementation requires a gcc with plugin support,
91280 + i.e., gcc 4.5 or newer. You may need to install the supporting
91281 + headers explicitly in addition to the normal gcc package.
91282 +
91283 +config PAX_LATENT_ENTROPY
91284 + bool "Generate some entropy during boot"
91285 + default y if GRKERNSEC_CONFIG_AUTO
91286 + help
91287 + By saying Y here the kernel will instrument early boot code to
91288 + extract some entropy from both original and artificially created
91289 + program state. This will help especially embedded systems where
91290 + there is little 'natural' source of entropy normally. The cost
91291 + is some slowdown of the boot process.
91292 +
91293 + When pax_extra_latent_entropy is passed on the kernel command line,
91294 + entropy will be extracted from up to the first 4GB of RAM while the
91295 + runtime memory allocator is being initialized. This costs even more
91296 + slowdown of the boot process.
91297 +
91298 + Note that the implementation requires a gcc with plugin support,
91299 + i.e., gcc 4.5 or newer. You may need to install the supporting
91300 + headers explicitly in addition to the normal gcc package.
91301 +
91302 + Note that entropy extracted this way is not cryptographically
91303 + secure!
91304 +
91305 +endmenu
91306 +
91307 +endmenu
91308 +
91309 +source grsecurity/Kconfig
91310 +
91311 +endmenu
91312 +
91313 +endmenu
91314 +
91315 source security/keys/Kconfig
91316
91317 config SECURITY_DMESG_RESTRICT
91318 @@ -103,7 +1041,7 @@ config INTEL_TXT
91319 config LSM_MMAP_MIN_ADDR
91320 int "Low address space for LSM to protect from user allocation"
91321 depends on SECURITY && SECURITY_SELINUX
91322 - default 32768 if ARM
91323 + default 32768 if ALPHA || ARM || PARISC || SPARC32
91324 default 65536
91325 help
91326 This is the portion of low virtual memory which should be protected
91327 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
91328 index 8c2a7f6..b133ac9 100644
91329 --- a/security/apparmor/lsm.c
91330 +++ b/security/apparmor/lsm.c
91331 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
91332 return error;
91333 }
91334
91335 -static struct security_operations apparmor_ops = {
91336 +static struct security_operations apparmor_ops __read_only = {
91337 .name = "apparmor",
91338
91339 .ptrace_access_check = apparmor_ptrace_access_check,
91340 diff --git a/security/commoncap.c b/security/commoncap.c
91341 index 7ee08c7..8d1a9d6 100644
91342 --- a/security/commoncap.c
91343 +++ b/security/commoncap.c
91344 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
91345 return 0;
91346 }
91347
91348 +/* returns:
91349 + 1 for suid privilege
91350 + 2 for sgid privilege
91351 + 3 for fscap privilege
91352 +*/
91353 +int is_privileged_binary(const struct dentry *dentry)
91354 +{
91355 + struct cpu_vfs_cap_data capdata;
91356 + struct inode *inode = dentry->d_inode;
91357 +
91358 + if (!inode || S_ISDIR(inode->i_mode))
91359 + return 0;
91360 +
91361 + if (inode->i_mode & S_ISUID)
91362 + return 1;
91363 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
91364 + return 2;
91365 +
91366 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
91367 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
91368 + return 3;
91369 + }
91370 +
91371 + return 0;
91372 +}
91373 +
91374 /*
91375 * Attempt to get the on-exec apply capability sets for an executable file from
91376 * its xattrs and, if present, apply them to the proposed credentials being
91377 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
91378 const struct cred *cred = current_cred();
91379 kuid_t root_uid = make_kuid(cred->user_ns, 0);
91380
91381 + if (gr_acl_enable_at_secure())
91382 + return 1;
91383 +
91384 if (!uid_eq(cred->uid, root_uid)) {
91385 if (bprm->cap_effective)
91386 return 1;
91387 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
91388 index 079a85d..12e93f8 100644
91389 --- a/security/integrity/ima/ima.h
91390 +++ b/security/integrity/ima/ima.h
91391 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
91392 extern spinlock_t ima_queue_lock;
91393
91394 struct ima_h_table {
91395 - atomic_long_t len; /* number of stored measurements in the list */
91396 - atomic_long_t violations;
91397 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
91398 + atomic_long_unchecked_t violations;
91399 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
91400 };
91401 extern struct ima_h_table ima_htable;
91402 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
91403 index 0cea3db..2f0ef77 100644
91404 --- a/security/integrity/ima/ima_api.c
91405 +++ b/security/integrity/ima/ima_api.c
91406 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
91407 int result;
91408
91409 /* can overflow, only indicator */
91410 - atomic_long_inc(&ima_htable.violations);
91411 + atomic_long_inc_unchecked(&ima_htable.violations);
91412
91413 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
91414 if (!entry) {
91415 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
91416 index 38477c9..87a60c7 100644
91417 --- a/security/integrity/ima/ima_fs.c
91418 +++ b/security/integrity/ima/ima_fs.c
91419 @@ -28,12 +28,12 @@
91420 static int valid_policy = 1;
91421 #define TMPBUFLEN 12
91422 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
91423 - loff_t *ppos, atomic_long_t *val)
91424 + loff_t *ppos, atomic_long_unchecked_t *val)
91425 {
91426 char tmpbuf[TMPBUFLEN];
91427 ssize_t len;
91428
91429 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
91430 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
91431 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
91432 }
91433
91434 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
91435 index 55a6271..ad829c3 100644
91436 --- a/security/integrity/ima/ima_queue.c
91437 +++ b/security/integrity/ima/ima_queue.c
91438 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
91439 INIT_LIST_HEAD(&qe->later);
91440 list_add_tail_rcu(&qe->later, &ima_measurements);
91441
91442 - atomic_long_inc(&ima_htable.len);
91443 + atomic_long_inc_unchecked(&ima_htable.len);
91444 key = ima_hash_key(entry->digest);
91445 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
91446 return 0;
91447 diff --git a/security/keys/compat.c b/security/keys/compat.c
91448 index d65fa7f..cbfe366 100644
91449 --- a/security/keys/compat.c
91450 +++ b/security/keys/compat.c
91451 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
91452 if (ret == 0)
91453 goto no_payload_free;
91454
91455 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
91456 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
91457 err:
91458 if (iov != iovstack)
91459 kfree(iov);
91460 diff --git a/security/keys/key.c b/security/keys/key.c
91461 index 8fb7c7b..ba3610d 100644
91462 --- a/security/keys/key.c
91463 +++ b/security/keys/key.c
91464 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
91465
91466 atomic_set(&key->usage, 1);
91467 init_rwsem(&key->sem);
91468 - lockdep_set_class(&key->sem, &type->lock_class);
91469 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
91470 key->type = type;
91471 key->user = user;
91472 key->quotalen = quotalen;
91473 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
91474 struct key_type *p;
91475 int ret;
91476
91477 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
91478 + pax_open_kernel();
91479 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
91480 + pax_close_kernel();
91481
91482 ret = -EEXIST;
91483 down_write(&key_types_sem);
91484 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
91485 }
91486
91487 /* store the type */
91488 - list_add(&ktype->link, &key_types_list);
91489 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
91490
91491 pr_notice("Key type %s registered\n", ktype->name);
91492 ret = 0;
91493 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
91494 void unregister_key_type(struct key_type *ktype)
91495 {
91496 down_write(&key_types_sem);
91497 - list_del_init(&ktype->link);
91498 + pax_list_del_init((struct list_head *)&ktype->link);
91499 downgrade_write(&key_types_sem);
91500 key_gc_keytype(ktype);
91501 pr_notice("Key type %s unregistered\n", ktype->name);
91502 @@ -1084,10 +1086,10 @@ void __init key_init(void)
91503 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
91504
91505 /* add the special key types */
91506 - list_add_tail(&key_type_keyring.link, &key_types_list);
91507 - list_add_tail(&key_type_dead.link, &key_types_list);
91508 - list_add_tail(&key_type_user.link, &key_types_list);
91509 - list_add_tail(&key_type_logon.link, &key_types_list);
91510 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
91511 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
91512 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
91513 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
91514
91515 /* record the root user tracking */
91516 rb_link_node(&root_key_user.node,
91517 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
91518 index 4b5c948..2054dc1 100644
91519 --- a/security/keys/keyctl.c
91520 +++ b/security/keys/keyctl.c
91521 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
91522 /*
91523 * Copy the iovec data from userspace
91524 */
91525 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
91526 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
91527 unsigned ioc)
91528 {
91529 for (; ioc > 0; ioc--) {
91530 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
91531 * If successful, 0 will be returned.
91532 */
91533 long keyctl_instantiate_key_common(key_serial_t id,
91534 - const struct iovec *payload_iov,
91535 + const struct iovec __user *payload_iov,
91536 unsigned ioc,
91537 size_t plen,
91538 key_serial_t ringid)
91539 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
91540 [0].iov_len = plen
91541 };
91542
91543 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
91544 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
91545 }
91546
91547 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
91548 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
91549 if (ret == 0)
91550 goto no_payload_free;
91551
91552 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
91553 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
91554 err:
91555 if (iov != iovstack)
91556 kfree(iov);
91557 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
91558 index 6ece7f2..ecdb55c 100644
91559 --- a/security/keys/keyring.c
91560 +++ b/security/keys/keyring.c
91561 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
91562 ret = -EFAULT;
91563
91564 for (loop = 0; loop < klist->nkeys; loop++) {
91565 + key_serial_t serial;
91566 key = rcu_deref_link_locked(klist, loop,
91567 keyring);
91568 + serial = key->serial;
91569
91570 tmp = sizeof(key_serial_t);
91571 if (tmp > buflen)
91572 tmp = buflen;
91573
91574 - if (copy_to_user(buffer,
91575 - &key->serial,
91576 - tmp) != 0)
91577 + if (copy_to_user(buffer, &serial, tmp))
91578 goto error;
91579
91580 buflen -= tmp;
91581 diff --git a/security/min_addr.c b/security/min_addr.c
91582 index f728728..6457a0c 100644
91583 --- a/security/min_addr.c
91584 +++ b/security/min_addr.c
91585 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
91586 */
91587 static void update_mmap_min_addr(void)
91588 {
91589 +#ifndef SPARC
91590 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
91591 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
91592 mmap_min_addr = dac_mmap_min_addr;
91593 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
91594 #else
91595 mmap_min_addr = dac_mmap_min_addr;
91596 #endif
91597 +#endif
91598 }
91599
91600 /*
91601 diff --git a/security/security.c b/security/security.c
91602 index 7b88c6a..1e3ea8f 100644
91603 --- a/security/security.c
91604 +++ b/security/security.c
91605 @@ -20,6 +20,7 @@
91606 #include <linux/ima.h>
91607 #include <linux/evm.h>
91608 #include <linux/fsnotify.h>
91609 +#include <linux/mm.h>
91610 #include <linux/mman.h>
91611 #include <linux/mount.h>
91612 #include <linux/personality.h>
91613 @@ -32,8 +33,8 @@
91614 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
91615 CONFIG_DEFAULT_SECURITY;
91616
91617 -static struct security_operations *security_ops;
91618 -static struct security_operations default_security_ops = {
91619 +static struct security_operations *security_ops __read_only;
91620 +static struct security_operations default_security_ops __read_only = {
91621 .name = "default",
91622 };
91623
91624 @@ -74,7 +75,9 @@ int __init security_init(void)
91625
91626 void reset_security_ops(void)
91627 {
91628 + pax_open_kernel();
91629 security_ops = &default_security_ops;
91630 + pax_close_kernel();
91631 }
91632
91633 /* Save user chosen LSM */
91634 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
91635 index ef26e96..642fb78 100644
91636 --- a/security/selinux/hooks.c
91637 +++ b/security/selinux/hooks.c
91638 @@ -95,8 +95,6 @@
91639
91640 #define NUM_SEL_MNT_OPTS 5
91641
91642 -extern struct security_operations *security_ops;
91643 -
91644 /* SECMARK reference count */
91645 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
91646
91647 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
91648
91649 #endif
91650
91651 -static struct security_operations selinux_ops = {
91652 +static struct security_operations selinux_ops __read_only = {
91653 .name = "selinux",
91654
91655 .ptrace_access_check = selinux_ptrace_access_check,
91656 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
91657 index 65f67cb..3f141ef 100644
91658 --- a/security/selinux/include/xfrm.h
91659 +++ b/security/selinux/include/xfrm.h
91660 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
91661
91662 static inline void selinux_xfrm_notify_policyload(void)
91663 {
91664 - atomic_inc(&flow_cache_genid);
91665 + atomic_inc_unchecked(&flow_cache_genid);
91666 rt_genid_bump(&init_net);
91667 }
91668 #else
91669 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
91670 index 38be92c..21f49ee 100644
91671 --- a/security/smack/smack_lsm.c
91672 +++ b/security/smack/smack_lsm.c
91673 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
91674 return 0;
91675 }
91676
91677 -struct security_operations smack_ops = {
91678 +struct security_operations smack_ops __read_only = {
91679 .name = "smack",
91680
91681 .ptrace_access_check = smack_ptrace_access_check,
91682 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
91683 index 390c646..f2f8db3 100644
91684 --- a/security/tomoyo/mount.c
91685 +++ b/security/tomoyo/mount.c
91686 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
91687 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
91688 need_dev = -1; /* dev_name is a directory */
91689 } else {
91690 + if (!capable(CAP_SYS_ADMIN)) {
91691 + error = -EPERM;
91692 + goto out;
91693 + }
91694 fstype = get_fs_type(type);
91695 if (!fstype) {
91696 error = -ENODEV;
91697 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
91698 index a2ee362..5754f34 100644
91699 --- a/security/tomoyo/tomoyo.c
91700 +++ b/security/tomoyo/tomoyo.c
91701 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
91702 * tomoyo_security_ops is a "struct security_operations" which is used for
91703 * registering TOMOYO.
91704 */
91705 -static struct security_operations tomoyo_security_ops = {
91706 +static struct security_operations tomoyo_security_ops __read_only = {
91707 .name = "tomoyo",
91708 .cred_alloc_blank = tomoyo_cred_alloc_blank,
91709 .cred_prepare = tomoyo_cred_prepare,
91710 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
91711 index 20ef514..4182bed 100644
91712 --- a/security/yama/Kconfig
91713 +++ b/security/yama/Kconfig
91714 @@ -1,6 +1,6 @@
91715 config SECURITY_YAMA
91716 bool "Yama support"
91717 - depends on SECURITY
91718 + depends on SECURITY && !GRKERNSEC
91719 select SECURITYFS
91720 select SECURITY_PATH
91721 default n
91722 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
91723 index 23414b9..b92b314 100644
91724 --- a/security/yama/yama_lsm.c
91725 +++ b/security/yama/yama_lsm.c
91726 @@ -367,7 +367,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
91727 }
91728
91729 #ifndef CONFIG_SECURITY_YAMA_STACKED
91730 -static struct security_operations yama_ops = {
91731 +static struct security_operations yama_ops __read_only = {
91732 .name = "yama",
91733
91734 .ptrace_access_check = yama_ptrace_access_check,
91735 @@ -378,28 +378,24 @@ static struct security_operations yama_ops = {
91736 #endif
91737
91738 #ifdef CONFIG_SYSCTL
91739 +static int zero __read_only;
91740 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
91741 +
91742 static int yama_dointvec_minmax(struct ctl_table *table, int write,
91743 void __user *buffer, size_t *lenp, loff_t *ppos)
91744 {
91745 - int rc;
91746 + ctl_table_no_const yama_table;
91747
91748 if (write && !capable(CAP_SYS_PTRACE))
91749 return -EPERM;
91750
91751 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
91752 - if (rc)
91753 - return rc;
91754 -
91755 + yama_table = *table;
91756 /* Lock the max value if it ever gets set. */
91757 - if (write && *(int *)table->data == *(int *)table->extra2)
91758 - table->extra1 = table->extra2;
91759 -
91760 - return rc;
91761 + if (ptrace_scope == max_scope)
91762 + yama_table.extra1 = &max_scope;
91763 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
91764 }
91765
91766 -static int zero;
91767 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
91768 -
91769 struct ctl_path yama_sysctl_path[] = {
91770 { .procname = "kernel", },
91771 { .procname = "yama", },
91772 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
91773 index 4cedc69..e59d8a3 100644
91774 --- a/sound/aoa/codecs/onyx.c
91775 +++ b/sound/aoa/codecs/onyx.c
91776 @@ -54,7 +54,7 @@ struct onyx {
91777 spdif_locked:1,
91778 analog_locked:1,
91779 original_mute:2;
91780 - int open_count;
91781 + local_t open_count;
91782 struct codec_info *codec_info;
91783
91784 /* mutex serializes concurrent access to the device
91785 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
91786 struct onyx *onyx = cii->codec_data;
91787
91788 mutex_lock(&onyx->mutex);
91789 - onyx->open_count++;
91790 + local_inc(&onyx->open_count);
91791 mutex_unlock(&onyx->mutex);
91792
91793 return 0;
91794 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
91795 struct onyx *onyx = cii->codec_data;
91796
91797 mutex_lock(&onyx->mutex);
91798 - onyx->open_count--;
91799 - if (!onyx->open_count)
91800 + if (local_dec_and_test(&onyx->open_count))
91801 onyx->spdif_locked = onyx->analog_locked = 0;
91802 mutex_unlock(&onyx->mutex);
91803
91804 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
91805 index ffd2025..df062c9 100644
91806 --- a/sound/aoa/codecs/onyx.h
91807 +++ b/sound/aoa/codecs/onyx.h
91808 @@ -11,6 +11,7 @@
91809 #include <linux/i2c.h>
91810 #include <asm/pmac_low_i2c.h>
91811 #include <asm/prom.h>
91812 +#include <asm/local.h>
91813
91814 /* PCM3052 register definitions */
91815
91816 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
91817 index 4c1cc51..16040040 100644
91818 --- a/sound/core/oss/pcm_oss.c
91819 +++ b/sound/core/oss/pcm_oss.c
91820 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
91821 if (in_kernel) {
91822 mm_segment_t fs;
91823 fs = snd_enter_user();
91824 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
91825 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
91826 snd_leave_user(fs);
91827 } else {
91828 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
91829 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
91830 }
91831 if (ret != -EPIPE && ret != -ESTRPIPE)
91832 break;
91833 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
91834 if (in_kernel) {
91835 mm_segment_t fs;
91836 fs = snd_enter_user();
91837 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
91838 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
91839 snd_leave_user(fs);
91840 } else {
91841 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
91842 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
91843 }
91844 if (ret == -EPIPE) {
91845 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
91846 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
91847 struct snd_pcm_plugin_channel *channels;
91848 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
91849 if (!in_kernel) {
91850 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
91851 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
91852 return -EFAULT;
91853 buf = runtime->oss.buffer;
91854 }
91855 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
91856 }
91857 } else {
91858 tmp = snd_pcm_oss_write2(substream,
91859 - (const char __force *)buf,
91860 + (const char __force_kernel *)buf,
91861 runtime->oss.period_bytes, 0);
91862 if (tmp <= 0)
91863 goto err;
91864 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
91865 struct snd_pcm_runtime *runtime = substream->runtime;
91866 snd_pcm_sframes_t frames, frames1;
91867 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
91868 - char __user *final_dst = (char __force __user *)buf;
91869 + char __user *final_dst = (char __force_user *)buf;
91870 if (runtime->oss.plugin_first) {
91871 struct snd_pcm_plugin_channel *channels;
91872 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
91873 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
91874 xfer += tmp;
91875 runtime->oss.buffer_used -= tmp;
91876 } else {
91877 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
91878 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
91879 runtime->oss.period_bytes, 0);
91880 if (tmp <= 0)
91881 goto err;
91882 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
91883 size1);
91884 size1 /= runtime->channels; /* frames */
91885 fs = snd_enter_user();
91886 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
91887 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
91888 snd_leave_user(fs);
91889 }
91890 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
91891 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
91892 index af49721..e85058e 100644
91893 --- a/sound/core/pcm_compat.c
91894 +++ b/sound/core/pcm_compat.c
91895 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
91896 int err;
91897
91898 fs = snd_enter_user();
91899 - err = snd_pcm_delay(substream, &delay);
91900 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
91901 snd_leave_user(fs);
91902 if (err < 0)
91903 return err;
91904 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
91905 index 09b4286..8620fac 100644
91906 --- a/sound/core/pcm_native.c
91907 +++ b/sound/core/pcm_native.c
91908 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
91909 switch (substream->stream) {
91910 case SNDRV_PCM_STREAM_PLAYBACK:
91911 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
91912 - (void __user *)arg);
91913 + (void __force_user *)arg);
91914 break;
91915 case SNDRV_PCM_STREAM_CAPTURE:
91916 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
91917 - (void __user *)arg);
91918 + (void __force_user *)arg);
91919 break;
91920 default:
91921 result = -EINVAL;
91922 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
91923 index 040c60e..989a19a 100644
91924 --- a/sound/core/seq/seq_device.c
91925 +++ b/sound/core/seq/seq_device.c
91926 @@ -64,7 +64,7 @@ struct ops_list {
91927 int argsize; /* argument size */
91928
91929 /* operators */
91930 - struct snd_seq_dev_ops ops;
91931 + struct snd_seq_dev_ops *ops;
91932
91933 /* registered devices */
91934 struct list_head dev_list; /* list of devices */
91935 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
91936
91937 mutex_lock(&ops->reg_mutex);
91938 /* copy driver operators */
91939 - ops->ops = *entry;
91940 + ops->ops = entry;
91941 ops->driver |= DRIVER_LOADED;
91942 ops->argsize = argsize;
91943
91944 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
91945 dev->name, ops->id, ops->argsize, dev->argsize);
91946 return -EINVAL;
91947 }
91948 - if (ops->ops.init_device(dev) >= 0) {
91949 + if (ops->ops->init_device(dev) >= 0) {
91950 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
91951 ops->num_init_devices++;
91952 } else {
91953 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
91954 dev->name, ops->id, ops->argsize, dev->argsize);
91955 return -EINVAL;
91956 }
91957 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
91958 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
91959 dev->status = SNDRV_SEQ_DEVICE_FREE;
91960 dev->driver_data = NULL;
91961 ops->num_init_devices--;
91962 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
91963 index 4e0dd22..7a1f32c 100644
91964 --- a/sound/drivers/mts64.c
91965 +++ b/sound/drivers/mts64.c
91966 @@ -29,6 +29,7 @@
91967 #include <sound/initval.h>
91968 #include <sound/rawmidi.h>
91969 #include <sound/control.h>
91970 +#include <asm/local.h>
91971
91972 #define CARD_NAME "Miditerminal 4140"
91973 #define DRIVER_NAME "MTS64"
91974 @@ -67,7 +68,7 @@ struct mts64 {
91975 struct pardevice *pardev;
91976 int pardev_claimed;
91977
91978 - int open_count;
91979 + local_t open_count;
91980 int current_midi_output_port;
91981 int current_midi_input_port;
91982 u8 mode[MTS64_NUM_INPUT_PORTS];
91983 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
91984 {
91985 struct mts64 *mts = substream->rmidi->private_data;
91986
91987 - if (mts->open_count == 0) {
91988 + if (local_read(&mts->open_count) == 0) {
91989 /* We don't need a spinlock here, because this is just called
91990 if the device has not been opened before.
91991 So there aren't any IRQs from the device */
91992 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
91993
91994 msleep(50);
91995 }
91996 - ++(mts->open_count);
91997 + local_inc(&mts->open_count);
91998
91999 return 0;
92000 }
92001 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92002 struct mts64 *mts = substream->rmidi->private_data;
92003 unsigned long flags;
92004
92005 - --(mts->open_count);
92006 - if (mts->open_count == 0) {
92007 + if (local_dec_return(&mts->open_count) == 0) {
92008 /* We need the spinlock_irqsave here because we can still
92009 have IRQs at this point */
92010 spin_lock_irqsave(&mts->lock, flags);
92011 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92012
92013 msleep(500);
92014
92015 - } else if (mts->open_count < 0)
92016 - mts->open_count = 0;
92017 + } else if (local_read(&mts->open_count) < 0)
92018 + local_set(&mts->open_count, 0);
92019
92020 return 0;
92021 }
92022 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
92023 index b953fb4..1999c01 100644
92024 --- a/sound/drivers/opl4/opl4_lib.c
92025 +++ b/sound/drivers/opl4/opl4_lib.c
92026 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
92027 MODULE_DESCRIPTION("OPL4 driver");
92028 MODULE_LICENSE("GPL");
92029
92030 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
92031 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
92032 {
92033 int timeout = 10;
92034 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
92035 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
92036 index 991018d..8984740 100644
92037 --- a/sound/drivers/portman2x4.c
92038 +++ b/sound/drivers/portman2x4.c
92039 @@ -48,6 +48,7 @@
92040 #include <sound/initval.h>
92041 #include <sound/rawmidi.h>
92042 #include <sound/control.h>
92043 +#include <asm/local.h>
92044
92045 #define CARD_NAME "Portman 2x4"
92046 #define DRIVER_NAME "portman"
92047 @@ -85,7 +86,7 @@ struct portman {
92048 struct pardevice *pardev;
92049 int pardev_claimed;
92050
92051 - int open_count;
92052 + local_t open_count;
92053 int mode[PORTMAN_NUM_INPUT_PORTS];
92054 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
92055 };
92056 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
92057 index ea995af..f1bfa37 100644
92058 --- a/sound/firewire/amdtp.c
92059 +++ b/sound/firewire/amdtp.c
92060 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
92061 ptr = s->pcm_buffer_pointer + data_blocks;
92062 if (ptr >= pcm->runtime->buffer_size)
92063 ptr -= pcm->runtime->buffer_size;
92064 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
92065 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
92066
92067 s->pcm_period_pointer += data_blocks;
92068 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
92069 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
92070 */
92071 void amdtp_out_stream_update(struct amdtp_out_stream *s)
92072 {
92073 - ACCESS_ONCE(s->source_node_id_field) =
92074 + ACCESS_ONCE_RW(s->source_node_id_field) =
92075 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
92076 }
92077 EXPORT_SYMBOL(amdtp_out_stream_update);
92078 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
92079 index b680c5e..061b7a0 100644
92080 --- a/sound/firewire/amdtp.h
92081 +++ b/sound/firewire/amdtp.h
92082 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
92083 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
92084 struct snd_pcm_substream *pcm)
92085 {
92086 - ACCESS_ONCE(s->pcm) = pcm;
92087 + ACCESS_ONCE_RW(s->pcm) = pcm;
92088 }
92089
92090 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
92091 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
92092 index d428ffe..751ef78 100644
92093 --- a/sound/firewire/isight.c
92094 +++ b/sound/firewire/isight.c
92095 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
92096 ptr += count;
92097 if (ptr >= runtime->buffer_size)
92098 ptr -= runtime->buffer_size;
92099 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
92100 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
92101
92102 isight->period_counter += count;
92103 if (isight->period_counter >= runtime->period_size) {
92104 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
92105 if (err < 0)
92106 return err;
92107
92108 - ACCESS_ONCE(isight->pcm_active) = true;
92109 + ACCESS_ONCE_RW(isight->pcm_active) = true;
92110
92111 return 0;
92112 }
92113 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
92114 {
92115 struct isight *isight = substream->private_data;
92116
92117 - ACCESS_ONCE(isight->pcm_active) = false;
92118 + ACCESS_ONCE_RW(isight->pcm_active) = false;
92119
92120 mutex_lock(&isight->mutex);
92121 isight_stop_streaming(isight);
92122 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
92123
92124 switch (cmd) {
92125 case SNDRV_PCM_TRIGGER_START:
92126 - ACCESS_ONCE(isight->pcm_running) = true;
92127 + ACCESS_ONCE_RW(isight->pcm_running) = true;
92128 break;
92129 case SNDRV_PCM_TRIGGER_STOP:
92130 - ACCESS_ONCE(isight->pcm_running) = false;
92131 + ACCESS_ONCE_RW(isight->pcm_running) = false;
92132 break;
92133 default:
92134 return -EINVAL;
92135 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
92136 index 844a555..985ab83 100644
92137 --- a/sound/firewire/scs1x.c
92138 +++ b/sound/firewire/scs1x.c
92139 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
92140 {
92141 struct scs *scs = stream->rmidi->private_data;
92142
92143 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
92144 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
92145 if (up) {
92146 scs->output_idle = false;
92147 tasklet_schedule(&scs->tasklet);
92148 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
92149 {
92150 struct scs *scs = stream->rmidi->private_data;
92151
92152 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
92153 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
92154 }
92155
92156 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
92157 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
92158
92159 snd_card_disconnect(scs->card);
92160
92161 - ACCESS_ONCE(scs->output) = NULL;
92162 - ACCESS_ONCE(scs->input) = NULL;
92163 + ACCESS_ONCE_RW(scs->output) = NULL;
92164 + ACCESS_ONCE_RW(scs->input) = NULL;
92165
92166 wait_event(scs->idle_wait, scs->output_idle);
92167
92168 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
92169 index 048439a..3be9f6f 100644
92170 --- a/sound/oss/sb_audio.c
92171 +++ b/sound/oss/sb_audio.c
92172 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
92173 buf16 = (signed short *)(localbuf + localoffs);
92174 while (c)
92175 {
92176 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92177 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
92178 if (copy_from_user(lbuf8,
92179 userbuf+useroffs + p,
92180 locallen))
92181 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
92182 index 7d8803a..559f8d0 100644
92183 --- a/sound/oss/swarm_cs4297a.c
92184 +++ b/sound/oss/swarm_cs4297a.c
92185 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
92186 {
92187 struct cs4297a_state *s;
92188 u32 pwr, id;
92189 - mm_segment_t fs;
92190 int rval;
92191 #ifndef CONFIG_BCM_CS4297A_CSWARM
92192 u64 cfg;
92193 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
92194 if (!rval) {
92195 char *sb1250_duart_present;
92196
92197 +#if 0
92198 + mm_segment_t fs;
92199 fs = get_fs();
92200 set_fs(KERNEL_DS);
92201 -#if 0
92202 val = SOUND_MASK_LINE;
92203 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
92204 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
92205 val = initvol[i].vol;
92206 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
92207 }
92208 + set_fs(fs);
92209 // cs4297a_write_ac97(s, 0x18, 0x0808);
92210 #else
92211 // cs4297a_write_ac97(s, 0x5e, 0x180);
92212 cs4297a_write_ac97(s, 0x02, 0x0808);
92213 cs4297a_write_ac97(s, 0x18, 0x0808);
92214 #endif
92215 - set_fs(fs);
92216
92217 list_add(&s->list, &cs4297a_devs);
92218
92219 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
92220 index 4631a23..001ae57 100644
92221 --- a/sound/pci/ymfpci/ymfpci.h
92222 +++ b/sound/pci/ymfpci/ymfpci.h
92223 @@ -358,7 +358,7 @@ struct snd_ymfpci {
92224 spinlock_t reg_lock;
92225 spinlock_t voice_lock;
92226 wait_queue_head_t interrupt_sleep;
92227 - atomic_t interrupt_sleep_count;
92228 + atomic_unchecked_t interrupt_sleep_count;
92229 struct snd_info_entry *proc_entry;
92230 const struct firmware *dsp_microcode;
92231 const struct firmware *controller_microcode;
92232 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
92233 index 22056c5..25d3244 100644
92234 --- a/sound/pci/ymfpci/ymfpci_main.c
92235 +++ b/sound/pci/ymfpci/ymfpci_main.c
92236 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
92237 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
92238 break;
92239 }
92240 - if (atomic_read(&chip->interrupt_sleep_count)) {
92241 - atomic_set(&chip->interrupt_sleep_count, 0);
92242 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92243 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92244 wake_up(&chip->interrupt_sleep);
92245 }
92246 __end:
92247 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
92248 continue;
92249 init_waitqueue_entry(&wait, current);
92250 add_wait_queue(&chip->interrupt_sleep, &wait);
92251 - atomic_inc(&chip->interrupt_sleep_count);
92252 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
92253 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
92254 remove_wait_queue(&chip->interrupt_sleep, &wait);
92255 }
92256 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
92257 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
92258 spin_unlock(&chip->reg_lock);
92259
92260 - if (atomic_read(&chip->interrupt_sleep_count)) {
92261 - atomic_set(&chip->interrupt_sleep_count, 0);
92262 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92263 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92264 wake_up(&chip->interrupt_sleep);
92265 }
92266 }
92267 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
92268 spin_lock_init(&chip->reg_lock);
92269 spin_lock_init(&chip->voice_lock);
92270 init_waitqueue_head(&chip->interrupt_sleep);
92271 - atomic_set(&chip->interrupt_sleep_count, 0);
92272 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92273 chip->card = card;
92274 chip->pci = pci;
92275 chip->irq = -1;
92276 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
92277 new file mode 100644
92278 index 0000000..50f2f2f
92279 --- /dev/null
92280 +++ b/tools/gcc/.gitignore
92281 @@ -0,0 +1 @@
92282 +size_overflow_hash.h
92283 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
92284 new file mode 100644
92285 index 0000000..144dbee
92286 --- /dev/null
92287 +++ b/tools/gcc/Makefile
92288 @@ -0,0 +1,45 @@
92289 +#CC := gcc
92290 +#PLUGIN_SOURCE_FILES := pax_plugin.c
92291 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
92292 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
92293 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
92294 +
92295 +ifeq ($(PLUGINCC),$(HOSTCC))
92296 +HOSTLIBS := hostlibs
92297 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
92298 +else
92299 +HOSTLIBS := hostcxxlibs
92300 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
92301 +endif
92302 +
92303 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
92304 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
92305 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
92306 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
92307 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
92308 +$(HOSTLIBS)-y += colorize_plugin.so
92309 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
92310 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
92311 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
92312 +
92313 +always := $($(HOSTLIBS)-y)
92314 +
92315 +constify_plugin-objs := constify_plugin.o
92316 +stackleak_plugin-objs := stackleak_plugin.o
92317 +kallocstat_plugin-objs := kallocstat_plugin.o
92318 +kernexec_plugin-objs := kernexec_plugin.o
92319 +checker_plugin-objs := checker_plugin.o
92320 +colorize_plugin-objs := colorize_plugin.o
92321 +size_overflow_plugin-objs := size_overflow_plugin.o
92322 +latent_entropy_plugin-objs := latent_entropy_plugin.o
92323 +structleak_plugin-objs := structleak_plugin.o
92324 +
92325 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
92326 +
92327 +quiet_cmd_build_size_overflow_hash = GENHASH $@
92328 + cmd_build_size_overflow_hash = \
92329 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
92330 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
92331 + $(call if_changed,build_size_overflow_hash)
92332 +
92333 +targets += size_overflow_hash.h
92334 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
92335 new file mode 100644
92336 index 0000000..d41b5af
92337 --- /dev/null
92338 +++ b/tools/gcc/checker_plugin.c
92339 @@ -0,0 +1,171 @@
92340 +/*
92341 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
92342 + * Licensed under the GPL v2
92343 + *
92344 + * Note: the choice of the license means that the compilation process is
92345 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92346 + * but for the kernel it doesn't matter since it doesn't link against
92347 + * any of the gcc libraries
92348 + *
92349 + * gcc plugin to implement various sparse (source code checker) features
92350 + *
92351 + * TODO:
92352 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
92353 + *
92354 + * BUGS:
92355 + * - none known
92356 + */
92357 +#include "gcc-plugin.h"
92358 +#include "config.h"
92359 +#include "system.h"
92360 +#include "coretypes.h"
92361 +#include "tree.h"
92362 +#include "tree-pass.h"
92363 +#include "flags.h"
92364 +#include "intl.h"
92365 +#include "toplev.h"
92366 +#include "plugin.h"
92367 +//#include "expr.h" where are you...
92368 +#include "diagnostic.h"
92369 +#include "plugin-version.h"
92370 +#include "tm.h"
92371 +#include "function.h"
92372 +#include "basic-block.h"
92373 +#include "gimple.h"
92374 +#include "rtl.h"
92375 +#include "emit-rtl.h"
92376 +#include "tree-flow.h"
92377 +#include "target.h"
92378 +
92379 +extern void c_register_addr_space (const char *str, addr_space_t as);
92380 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
92381 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
92382 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
92383 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
92384 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
92385 +
92386 +extern void print_gimple_stmt(FILE *, gimple, int, int);
92387 +extern rtx emit_move_insn(rtx x, rtx y);
92388 +
92389 +int plugin_is_GPL_compatible;
92390 +
92391 +static struct plugin_info checker_plugin_info = {
92392 + .version = "201111150100",
92393 +};
92394 +
92395 +#define ADDR_SPACE_KERNEL 0
92396 +#define ADDR_SPACE_FORCE_KERNEL 1
92397 +#define ADDR_SPACE_USER 2
92398 +#define ADDR_SPACE_FORCE_USER 3
92399 +#define ADDR_SPACE_IOMEM 0
92400 +#define ADDR_SPACE_FORCE_IOMEM 0
92401 +#define ADDR_SPACE_PERCPU 0
92402 +#define ADDR_SPACE_FORCE_PERCPU 0
92403 +#define ADDR_SPACE_RCU 0
92404 +#define ADDR_SPACE_FORCE_RCU 0
92405 +
92406 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
92407 +{
92408 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
92409 +}
92410 +
92411 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
92412 +{
92413 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
92414 +}
92415 +
92416 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
92417 +{
92418 + return default_addr_space_valid_pointer_mode(mode, as);
92419 +}
92420 +
92421 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
92422 +{
92423 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
92424 +}
92425 +
92426 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
92427 +{
92428 + return default_addr_space_legitimize_address(x, oldx, mode, as);
92429 +}
92430 +
92431 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
92432 +{
92433 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
92434 + return true;
92435 +
92436 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
92437 + return true;
92438 +
92439 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
92440 + return true;
92441 +
92442 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
92443 + return true;
92444 +
92445 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
92446 + return true;
92447 +
92448 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
92449 + return true;
92450 +
92451 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
92452 + return true;
92453 +
92454 + return subset == superset;
92455 +}
92456 +
92457 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
92458 +{
92459 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
92460 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
92461 +
92462 + return op;
92463 +}
92464 +
92465 +static void register_checker_address_spaces(void *event_data, void *data)
92466 +{
92467 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
92468 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
92469 + c_register_addr_space("__user", ADDR_SPACE_USER);
92470 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
92471 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
92472 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
92473 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
92474 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
92475 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
92476 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
92477 +
92478 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
92479 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
92480 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
92481 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
92482 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
92483 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
92484 + targetm.addr_space.convert = checker_addr_space_convert;
92485 +}
92486 +
92487 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92488 +{
92489 + const char * const plugin_name = plugin_info->base_name;
92490 + const int argc = plugin_info->argc;
92491 + const struct plugin_argument * const argv = plugin_info->argv;
92492 + int i;
92493 +
92494 + if (!plugin_default_version_check(version, &gcc_version)) {
92495 + error(G_("incompatible gcc/plugin versions"));
92496 + return 1;
92497 + }
92498 +
92499 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
92500 +
92501 + for (i = 0; i < argc; ++i)
92502 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
92503 +
92504 + if (TARGET_64BIT == 0)
92505 + return 0;
92506 +
92507 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
92508 +
92509 + return 0;
92510 +}
92511 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
92512 new file mode 100644
92513 index 0000000..414fe5e
92514 --- /dev/null
92515 +++ b/tools/gcc/colorize_plugin.c
92516 @@ -0,0 +1,151 @@
92517 +/*
92518 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
92519 + * Licensed under the GPL v2
92520 + *
92521 + * Note: the choice of the license means that the compilation process is
92522 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92523 + * but for the kernel it doesn't matter since it doesn't link against
92524 + * any of the gcc libraries
92525 + *
92526 + * gcc plugin to colorize diagnostic output
92527 + *
92528 + */
92529 +
92530 +#include "gcc-plugin.h"
92531 +#include "config.h"
92532 +#include "system.h"
92533 +#include "coretypes.h"
92534 +#include "tree.h"
92535 +#include "tree-pass.h"
92536 +#include "flags.h"
92537 +#include "intl.h"
92538 +#include "toplev.h"
92539 +#include "plugin.h"
92540 +#include "diagnostic.h"
92541 +#include "plugin-version.h"
92542 +#include "tm.h"
92543 +
92544 +int plugin_is_GPL_compatible;
92545 +
92546 +static struct plugin_info colorize_plugin_info = {
92547 + .version = "201302112000",
92548 + .help = NULL,
92549 +};
92550 +
92551 +#define GREEN "\033[32m\033[2m"
92552 +#define LIGHTGREEN "\033[32m\033[1m"
92553 +#define YELLOW "\033[33m\033[2m"
92554 +#define LIGHTYELLOW "\033[33m\033[1m"
92555 +#define RED "\033[31m\033[2m"
92556 +#define LIGHTRED "\033[31m\033[1m"
92557 +#define BLUE "\033[34m\033[2m"
92558 +#define LIGHTBLUE "\033[34m\033[1m"
92559 +#define BRIGHT "\033[m\033[1m"
92560 +#define NORMAL "\033[m"
92561 +
92562 +static diagnostic_starter_fn old_starter;
92563 +static diagnostic_finalizer_fn old_finalizer;
92564 +
92565 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
92566 +{
92567 + const char *color;
92568 + char *newprefix;
92569 +
92570 + switch (diagnostic->kind) {
92571 + case DK_NOTE:
92572 + color = LIGHTBLUE;
92573 + break;
92574 +
92575 + case DK_PEDWARN:
92576 + case DK_WARNING:
92577 + color = LIGHTYELLOW;
92578 + break;
92579 +
92580 + case DK_ERROR:
92581 + case DK_FATAL:
92582 + case DK_ICE:
92583 + case DK_PERMERROR:
92584 + case DK_SORRY:
92585 + color = LIGHTRED;
92586 + break;
92587 +
92588 + default:
92589 + color = NORMAL;
92590 + }
92591 +
92592 + old_starter(context, diagnostic);
92593 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
92594 + return;
92595 + pp_destroy_prefix(context->printer);
92596 + pp_set_prefix(context->printer, newprefix);
92597 +}
92598 +
92599 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
92600 +{
92601 + old_finalizer(context, diagnostic);
92602 +}
92603 +
92604 +static void colorize_arm(void)
92605 +{
92606 + old_starter = diagnostic_starter(global_dc);
92607 + old_finalizer = diagnostic_finalizer(global_dc);
92608 +
92609 + diagnostic_starter(global_dc) = start_colorize;
92610 + diagnostic_finalizer(global_dc) = finalize_colorize;
92611 +}
92612 +
92613 +static unsigned int execute_colorize_rearm(void)
92614 +{
92615 + if (diagnostic_starter(global_dc) == start_colorize)
92616 + return 0;
92617 +
92618 + colorize_arm();
92619 + return 0;
92620 +}
92621 +
92622 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
92623 + .pass = {
92624 + .type = SIMPLE_IPA_PASS,
92625 + .name = "colorize_rearm",
92626 +#if BUILDING_GCC_VERSION >= 4008
92627 + .optinfo_flags = OPTGROUP_NONE,
92628 +#endif
92629 + .gate = NULL,
92630 + .execute = execute_colorize_rearm,
92631 + .sub = NULL,
92632 + .next = NULL,
92633 + .static_pass_number = 0,
92634 + .tv_id = TV_NONE,
92635 + .properties_required = 0,
92636 + .properties_provided = 0,
92637 + .properties_destroyed = 0,
92638 + .todo_flags_start = 0,
92639 + .todo_flags_finish = 0
92640 + }
92641 +};
92642 +
92643 +static void colorize_start_unit(void *gcc_data, void *user_data)
92644 +{
92645 + colorize_arm();
92646 +}
92647 +
92648 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92649 +{
92650 + const char * const plugin_name = plugin_info->base_name;
92651 + struct register_pass_info colorize_rearm_pass_info = {
92652 + .pass = &pass_ipa_colorize_rearm.pass,
92653 + .reference_pass_name = "*free_lang_data",
92654 + .ref_pass_instance_number = 1,
92655 + .pos_op = PASS_POS_INSERT_AFTER
92656 + };
92657 +
92658 + if (!plugin_default_version_check(version, &gcc_version)) {
92659 + error(G_("incompatible gcc/plugin versions"));
92660 + return 1;
92661 + }
92662 +
92663 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
92664 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
92665 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
92666 + return 0;
92667 +}
92668 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
92669 new file mode 100644
92670 index 0000000..bee0acb
92671 --- /dev/null
92672 +++ b/tools/gcc/constify_plugin.c
92673 @@ -0,0 +1,518 @@
92674 +/*
92675 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
92676 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
92677 + * Licensed under the GPL v2, or (at your option) v3
92678 + *
92679 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
92680 + *
92681 + * Homepage:
92682 + * http://www.grsecurity.net/~ephox/const_plugin/
92683 + *
92684 + * Usage:
92685 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
92686 + * $ gcc -fplugin=constify_plugin.so test.c -O2
92687 + */
92688 +
92689 +#include "gcc-plugin.h"
92690 +#include "config.h"
92691 +#include "system.h"
92692 +#include "coretypes.h"
92693 +#include "tree.h"
92694 +#include "tree-pass.h"
92695 +#include "flags.h"
92696 +#include "intl.h"
92697 +#include "toplev.h"
92698 +#include "plugin.h"
92699 +#include "diagnostic.h"
92700 +#include "plugin-version.h"
92701 +#include "tm.h"
92702 +#include "function.h"
92703 +#include "basic-block.h"
92704 +#include "gimple.h"
92705 +#include "rtl.h"
92706 +#include "emit-rtl.h"
92707 +#include "tree-flow.h"
92708 +#include "target.h"
92709 +#include "langhooks.h"
92710 +
92711 +// should come from c-tree.h if only it were installed for gcc 4.5...
92712 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
92713 +
92714 +// unused type flag in all versions 4.5-4.8
92715 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
92716 +
92717 +int plugin_is_GPL_compatible;
92718 +
92719 +static struct plugin_info const_plugin_info = {
92720 + .version = "201303270300",
92721 + .help = "no-constify\tturn off constification\n",
92722 +};
92723 +
92724 +typedef struct {
92725 + bool has_fptr_field;
92726 + bool has_writable_field;
92727 + bool has_do_const_field;
92728 + bool has_no_const_field;
92729 +} constify_info;
92730 +
92731 +static const_tree get_field_type(const_tree field)
92732 +{
92733 + return strip_array_types(TREE_TYPE(field));
92734 +}
92735 +
92736 +static bool is_fptr(const_tree field)
92737 +{
92738 + const_tree ptr = get_field_type(field);
92739 +
92740 + if (TREE_CODE(ptr) != POINTER_TYPE)
92741 + return false;
92742 +
92743 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
92744 +}
92745 +
92746 +/*
92747 + * determine whether the given structure type meets the requirements for automatic constification,
92748 + * including the constification attributes on nested structure types
92749 + */
92750 +static void constifiable(const_tree node, constify_info *cinfo)
92751 +{
92752 + const_tree field;
92753 +
92754 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
92755 +
92756 + // e.g., pointer to structure fields while still constructing the structure type
92757 + if (TYPE_FIELDS(node) == NULL_TREE)
92758 + return;
92759 +
92760 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
92761 + const_tree type = get_field_type(field);
92762 + enum tree_code code = TREE_CODE(type);
92763 +
92764 + if (node == type)
92765 + continue;
92766 +
92767 + if (is_fptr(field))
92768 + cinfo->has_fptr_field = true;
92769 + else if (!TREE_READONLY(field))
92770 + cinfo->has_writable_field = true;
92771 +
92772 + if (code == RECORD_TYPE || code == UNION_TYPE) {
92773 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92774 + cinfo->has_do_const_field = true;
92775 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
92776 + cinfo->has_no_const_field = true;
92777 + else
92778 + constifiable(type, cinfo);
92779 + }
92780 + }
92781 +}
92782 +
92783 +static bool constified(const_tree node)
92784 +{
92785 + constify_info cinfo = {
92786 + .has_fptr_field = false,
92787 + .has_writable_field = false,
92788 + .has_do_const_field = false,
92789 + .has_no_const_field = false
92790 + };
92791 +
92792 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
92793 +
92794 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
92795 + gcc_assert(!TYPE_READONLY(node));
92796 + return false;
92797 + }
92798 +
92799 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
92800 + gcc_assert(TYPE_READONLY(node));
92801 + return true;
92802 + }
92803 +
92804 + constifiable(node, &cinfo);
92805 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
92806 + return false;
92807 +
92808 + return TYPE_READONLY(node);
92809 +}
92810 +
92811 +static void deconstify_tree(tree node);
92812 +
92813 +static void deconstify_type(tree type)
92814 +{
92815 + tree field;
92816 +
92817 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
92818 +
92819 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
92820 + const_tree fieldtype = get_field_type(field);
92821 +
92822 + // special case handling of simple ptr-to-same-array-type members
92823 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
92824 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
92825 +
92826 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
92827 + continue;
92828 + if (TREE_TYPE(TREE_TYPE(field)) == type)
92829 + continue;
92830 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
92831 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
92832 + TREE_TYPE(TREE_TYPE(field)) = type;
92833 + }
92834 + continue;
92835 + }
92836 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
92837 + continue;
92838 + if (!constified(fieldtype))
92839 + continue;
92840 +
92841 + deconstify_tree(field);
92842 + TREE_READONLY(field) = 0;
92843 + }
92844 + TYPE_READONLY(type) = 0;
92845 + C_TYPE_FIELDS_READONLY(type) = 0;
92846 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92847 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
92848 +}
92849 +
92850 +static void deconstify_tree(tree node)
92851 +{
92852 + tree old_type, new_type, field;
92853 +
92854 + old_type = TREE_TYPE(node);
92855 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
92856 + node = TREE_TYPE(node) = copy_node(old_type);
92857 + old_type = TREE_TYPE(old_type);
92858 + }
92859 +
92860 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
92861 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
92862 +
92863 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
92864 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
92865 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
92866 + DECL_FIELD_CONTEXT(field) = new_type;
92867 +
92868 + deconstify_type(new_type);
92869 +
92870 + TREE_TYPE(node) = new_type;
92871 +}
92872 +
92873 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
92874 +{
92875 + tree type;
92876 + constify_info cinfo = {
92877 + .has_fptr_field = false,
92878 + .has_writable_field = false,
92879 + .has_do_const_field = false,
92880 + .has_no_const_field = false
92881 + };
92882 +
92883 + *no_add_attrs = true;
92884 + if (TREE_CODE(*node) == FUNCTION_DECL) {
92885 + error("%qE attribute does not apply to functions", name);
92886 + return NULL_TREE;
92887 + }
92888 +
92889 + if (TREE_CODE(*node) == PARM_DECL) {
92890 + error("%qE attribute does not apply to function parameters", name);
92891 + return NULL_TREE;
92892 + }
92893 +
92894 + if (TREE_CODE(*node) == VAR_DECL) {
92895 + error("%qE attribute does not apply to variables", name);
92896 + return NULL_TREE;
92897 + }
92898 +
92899 + if (TYPE_P(*node)) {
92900 + *no_add_attrs = false;
92901 + type = *node;
92902 + } else {
92903 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
92904 + type = TREE_TYPE(*node);
92905 + }
92906 +
92907 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
92908 + error("%qE attribute applies to struct and union types only", name);
92909 + return NULL_TREE;
92910 + }
92911 +
92912 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
92913 + error("%qE attribute is already applied to the type", name);
92914 + return NULL_TREE;
92915 + }
92916 +
92917 + if (TYPE_P(*node)) {
92918 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92919 + error("%qE attribute is incompatible with 'do_const'", name);
92920 + return NULL_TREE;
92921 + }
92922 +
92923 + constifiable(type, &cinfo);
92924 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
92925 + deconstify_tree(*node);
92926 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
92927 + return NULL_TREE;
92928 + }
92929 +
92930 + error("%qE attribute used on type that is not constified", name);
92931 + return NULL_TREE;
92932 +}
92933 +
92934 +static void constify_type(tree type)
92935 +{
92936 + TYPE_READONLY(type) = 1;
92937 + C_TYPE_FIELDS_READONLY(type) = 1;
92938 + TYPE_CONSTIFY_VISITED(type) = 1;
92939 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
92940 +}
92941 +
92942 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
92943 +{
92944 + *no_add_attrs = true;
92945 + if (!TYPE_P(*node)) {
92946 + error("%qE attribute applies to types only", name);
92947 + return NULL_TREE;
92948 + }
92949 +
92950 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
92951 + error("%qE attribute applies to struct and union types only", name);
92952 + return NULL_TREE;
92953 + }
92954 +
92955 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
92956 + error("%qE attribute is already applied to the type", name);
92957 + return NULL_TREE;
92958 + }
92959 +
92960 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
92961 + error("%qE attribute is incompatible with 'no_const'", name);
92962 + return NULL_TREE;
92963 + }
92964 +
92965 + *no_add_attrs = false;
92966 + return NULL_TREE;
92967 +}
92968 +
92969 +static struct attribute_spec no_const_attr = {
92970 + .name = "no_const",
92971 + .min_length = 0,
92972 + .max_length = 0,
92973 + .decl_required = false,
92974 + .type_required = false,
92975 + .function_type_required = false,
92976 + .handler = handle_no_const_attribute,
92977 +#if BUILDING_GCC_VERSION >= 4007
92978 + .affects_type_identity = true
92979 +#endif
92980 +};
92981 +
92982 +static struct attribute_spec do_const_attr = {
92983 + .name = "do_const",
92984 + .min_length = 0,
92985 + .max_length = 0,
92986 + .decl_required = false,
92987 + .type_required = false,
92988 + .function_type_required = false,
92989 + .handler = handle_do_const_attribute,
92990 +#if BUILDING_GCC_VERSION >= 4007
92991 + .affects_type_identity = true
92992 +#endif
92993 +};
92994 +
92995 +static void register_attributes(void *event_data, void *data)
92996 +{
92997 + register_attribute(&no_const_attr);
92998 + register_attribute(&do_const_attr);
92999 +}
93000 +
93001 +static void finish_type(void *event_data, void *data)
93002 +{
93003 + tree type = (tree)event_data;
93004 + constify_info cinfo = {
93005 + .has_fptr_field = false,
93006 + .has_writable_field = false,
93007 + .has_do_const_field = false,
93008 + .has_no_const_field = false
93009 + };
93010 +
93011 + if (type == NULL_TREE || type == error_mark_node)
93012 + return;
93013 +
93014 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
93015 + return;
93016 +
93017 + constifiable(type, &cinfo);
93018 +
93019 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
93020 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93021 + return;
93022 + if (cinfo.has_writable_field)
93023 + return;
93024 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
93025 + return;
93026 + }
93027 +
93028 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
93029 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
93030 + deconstify_type(type);
93031 + TYPE_CONSTIFY_VISITED(type) = 1;
93032 + } else
93033 + error("'no_const' attribute used on type that is not constified");
93034 + return;
93035 + }
93036 +
93037 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93038 + constify_type(type);
93039 + return;
93040 + }
93041 +
93042 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
93043 + constify_type(type);
93044 + return;
93045 + }
93046 +
93047 + deconstify_type(type);
93048 + TYPE_CONSTIFY_VISITED(type) = 1;
93049 +}
93050 +
93051 +static unsigned int check_local_variables(void)
93052 +{
93053 + unsigned int ret = 0;
93054 + tree var;
93055 +
93056 +#if BUILDING_GCC_VERSION == 4005
93057 + tree vars;
93058 +#else
93059 + unsigned int i;
93060 +#endif
93061 +
93062 +#if BUILDING_GCC_VERSION == 4005
93063 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
93064 + var = TREE_VALUE(vars);
93065 +#else
93066 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
93067 +#endif
93068 + tree type = TREE_TYPE(var);
93069 +
93070 + gcc_assert(DECL_P(var));
93071 + if (is_global_var(var))
93072 + continue;
93073 +
93074 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
93075 + continue;
93076 +
93077 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
93078 + continue;
93079 +
93080 + if (!TYPE_CONSTIFY_VISITED(type))
93081 + continue;
93082 +
93083 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
93084 + ret = 1;
93085 + }
93086 + return ret;
93087 +}
93088 +
93089 +static struct gimple_opt_pass pass_local_variable = {
93090 + {
93091 + .type = GIMPLE_PASS,
93092 + .name = "check_local_variables",
93093 +#if BUILDING_GCC_VERSION >= 4008
93094 + .optinfo_flags = OPTGROUP_NONE,
93095 +#endif
93096 + .gate = NULL,
93097 + .execute = check_local_variables,
93098 + .sub = NULL,
93099 + .next = NULL,
93100 + .static_pass_number = 0,
93101 + .tv_id = TV_NONE,
93102 + .properties_required = 0,
93103 + .properties_provided = 0,
93104 + .properties_destroyed = 0,
93105 + .todo_flags_start = 0,
93106 + .todo_flags_finish = 0
93107 + }
93108 +};
93109 +
93110 +static struct {
93111 + const char *name;
93112 + const char *asm_op;
93113 +} sections[] = {
93114 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
93115 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
93116 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
93117 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
93118 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
93119 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
93120 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
93121 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
93122 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
93123 +};
93124 +
93125 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
93126 +
93127 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
93128 +{
93129 + size_t i;
93130 +
93131 + for (i = 0; i < ARRAY_SIZE(sections); i++)
93132 + if (!strcmp(sections[i].name, name))
93133 + return 0;
93134 + return old_section_type_flags(decl, name, reloc);
93135 +}
93136 +
93137 +static void constify_start_unit(void *gcc_data, void *user_data)
93138 +{
93139 +// size_t i;
93140 +
93141 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
93142 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
93143 +// sections[i].section = get_section(sections[i].name, 0, NULL);
93144 +
93145 + old_section_type_flags = targetm.section_type_flags;
93146 + targetm.section_type_flags = constify_section_type_flags;
93147 +}
93148 +
93149 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93150 +{
93151 + const char * const plugin_name = plugin_info->base_name;
93152 + const int argc = plugin_info->argc;
93153 + const struct plugin_argument * const argv = plugin_info->argv;
93154 + int i;
93155 + bool constify = true;
93156 +
93157 + struct register_pass_info local_variable_pass_info = {
93158 + .pass = &pass_local_variable.pass,
93159 + .reference_pass_name = "ssa",
93160 + .ref_pass_instance_number = 1,
93161 + .pos_op = PASS_POS_INSERT_BEFORE
93162 + };
93163 +
93164 + if (!plugin_default_version_check(version, &gcc_version)) {
93165 + error(G_("incompatible gcc/plugin versions"));
93166 + return 1;
93167 + }
93168 +
93169 + for (i = 0; i < argc; ++i) {
93170 + if (!(strcmp(argv[i].key, "no-constify"))) {
93171 + constify = false;
93172 + continue;
93173 + }
93174 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93175 + }
93176 +
93177 + if (strcmp(lang_hooks.name, "GNU C")) {
93178 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
93179 + constify = false;
93180 + }
93181 +
93182 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
93183 + if (constify) {
93184 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
93185 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
93186 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
93187 + }
93188 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
93189 +
93190 + return 0;
93191 +}
93192 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
93193 new file mode 100644
93194 index 0000000..e518932
93195 --- /dev/null
93196 +++ b/tools/gcc/generate_size_overflow_hash.sh
93197 @@ -0,0 +1,94 @@
93198 +#!/bin/bash
93199 +
93200 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
93201 +
93202 +header1="size_overflow_hash.h"
93203 +database="size_overflow_hash.data"
93204 +n=65536
93205 +
93206 +usage() {
93207 +cat <<EOF
93208 +usage: $0 options
93209 +OPTIONS:
93210 + -h|--help help
93211 + -o header file
93212 + -d database file
93213 + -n hash array size
93214 +EOF
93215 + return 0
93216 +}
93217 +
93218 +while true
93219 +do
93220 + case "$1" in
93221 + -h|--help) usage && exit 0;;
93222 + -n) n=$2; shift 2;;
93223 + -o) header1="$2"; shift 2;;
93224 + -d) database="$2"; shift 2;;
93225 + --) shift 1; break ;;
93226 + *) break ;;
93227 + esac
93228 +done
93229 +
93230 +create_defines() {
93231 + for i in `seq 0 31`
93232 + do
93233 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
93234 + done
93235 + echo >> "$header1"
93236 +}
93237 +
93238 +create_structs() {
93239 + rm -f "$header1"
93240 +
93241 + create_defines
93242 +
93243 + cat "$database" | while read data
93244 + do
93245 + data_array=($data)
93246 + struct_hash_name="${data_array[0]}"
93247 + funcn="${data_array[1]}"
93248 + params="${data_array[2]}"
93249 + next="${data_array[4]}"
93250 +
93251 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
93252 +
93253 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
93254 + echo -en "\t.param\t= " >> "$header1"
93255 + line=
93256 + for param_num in ${params//-/ };
93257 + do
93258 + line="${line}PARAM"$param_num"|"
93259 + done
93260 +
93261 + echo -e "${line%?},\n};\n" >> "$header1"
93262 + done
93263 +}
93264 +
93265 +create_headers() {
93266 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
93267 +}
93268 +
93269 +create_array_elements() {
93270 + index=0
93271 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
93272 + do
93273 + data_array=($data)
93274 + i="${data_array[3]}"
93275 + hash="${data_array[0]}"
93276 + while [[ $index -lt $i ]]
93277 + do
93278 + echo -e "\t["$index"]\t= NULL," >> "$header1"
93279 + index=$(($index + 1))
93280 + done
93281 + index=$(($index + 1))
93282 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
93283 + done
93284 + echo '};' >> $header1
93285 +}
93286 +
93287 +create_structs
93288 +create_headers
93289 +create_array_elements
93290 +
93291 +exit 0
93292 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
93293 new file mode 100644
93294 index 0000000..568b360
93295 --- /dev/null
93296 +++ b/tools/gcc/kallocstat_plugin.c
93297 @@ -0,0 +1,170 @@
93298 +/*
93299 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
93300 + * Licensed under the GPL v2
93301 + *
93302 + * Note: the choice of the license means that the compilation process is
93303 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93304 + * but for the kernel it doesn't matter since it doesn't link against
93305 + * any of the gcc libraries
93306 + *
93307 + * gcc plugin to find the distribution of k*alloc sizes
93308 + *
93309 + * TODO:
93310 + *
93311 + * BUGS:
93312 + * - none known
93313 + */
93314 +#include "gcc-plugin.h"
93315 +#include "config.h"
93316 +#include "system.h"
93317 +#include "coretypes.h"
93318 +#include "tree.h"
93319 +#include "tree-pass.h"
93320 +#include "flags.h"
93321 +#include "intl.h"
93322 +#include "toplev.h"
93323 +#include "plugin.h"
93324 +//#include "expr.h" where are you...
93325 +#include "diagnostic.h"
93326 +#include "plugin-version.h"
93327 +#include "tm.h"
93328 +#include "function.h"
93329 +#include "basic-block.h"
93330 +#include "gimple.h"
93331 +#include "rtl.h"
93332 +#include "emit-rtl.h"
93333 +
93334 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93335 +
93336 +int plugin_is_GPL_compatible;
93337 +
93338 +static const char * const kalloc_functions[] = {
93339 + "__kmalloc",
93340 + "kmalloc",
93341 + "kmalloc_large",
93342 + "kmalloc_node",
93343 + "kmalloc_order",
93344 + "kmalloc_order_trace",
93345 + "kmalloc_slab",
93346 + "kzalloc",
93347 + "kzalloc_node",
93348 +};
93349 +
93350 +static struct plugin_info kallocstat_plugin_info = {
93351 + .version = "201302112000",
93352 +};
93353 +
93354 +static unsigned int execute_kallocstat(void);
93355 +
93356 +static struct gimple_opt_pass kallocstat_pass = {
93357 + .pass = {
93358 + .type = GIMPLE_PASS,
93359 + .name = "kallocstat",
93360 +#if BUILDING_GCC_VERSION >= 4008
93361 + .optinfo_flags = OPTGROUP_NONE,
93362 +#endif
93363 + .gate = NULL,
93364 + .execute = execute_kallocstat,
93365 + .sub = NULL,
93366 + .next = NULL,
93367 + .static_pass_number = 0,
93368 + .tv_id = TV_NONE,
93369 + .properties_required = 0,
93370 + .properties_provided = 0,
93371 + .properties_destroyed = 0,
93372 + .todo_flags_start = 0,
93373 + .todo_flags_finish = 0
93374 + }
93375 +};
93376 +
93377 +static bool is_kalloc(const char *fnname)
93378 +{
93379 + size_t i;
93380 +
93381 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
93382 + if (!strcmp(fnname, kalloc_functions[i]))
93383 + return true;
93384 + return false;
93385 +}
93386 +
93387 +static unsigned int execute_kallocstat(void)
93388 +{
93389 + basic_block bb;
93390 +
93391 + // 1. loop through BBs and GIMPLE statements
93392 + FOR_EACH_BB(bb) {
93393 + gimple_stmt_iterator gsi;
93394 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93395 + // gimple match:
93396 + tree fndecl, size;
93397 + gimple call_stmt;
93398 + const char *fnname;
93399 +
93400 + // is it a call
93401 + call_stmt = gsi_stmt(gsi);
93402 + if (!is_gimple_call(call_stmt))
93403 + continue;
93404 + fndecl = gimple_call_fndecl(call_stmt);
93405 + if (fndecl == NULL_TREE)
93406 + continue;
93407 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
93408 + continue;
93409 +
93410 + // is it a call to k*alloc
93411 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
93412 + if (!is_kalloc(fnname))
93413 + continue;
93414 +
93415 + // is the size arg the result of a simple const assignment
93416 + size = gimple_call_arg(call_stmt, 0);
93417 + while (true) {
93418 + gimple def_stmt;
93419 + expanded_location xloc;
93420 + size_t size_val;
93421 +
93422 + if (TREE_CODE(size) != SSA_NAME)
93423 + break;
93424 + def_stmt = SSA_NAME_DEF_STMT(size);
93425 + if (!def_stmt || !is_gimple_assign(def_stmt))
93426 + break;
93427 + if (gimple_num_ops(def_stmt) != 2)
93428 + break;
93429 + size = gimple_assign_rhs1(def_stmt);
93430 + if (!TREE_CONSTANT(size))
93431 + continue;
93432 + xloc = expand_location(gimple_location(def_stmt));
93433 + if (!xloc.file)
93434 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
93435 + size_val = TREE_INT_CST_LOW(size);
93436 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
93437 + break;
93438 + }
93439 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
93440 +//debug_tree(gimple_call_fn(call_stmt));
93441 +//print_node(stderr, "pax", fndecl, 4);
93442 + }
93443 + }
93444 +
93445 + return 0;
93446 +}
93447 +
93448 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93449 +{
93450 + const char * const plugin_name = plugin_info->base_name;
93451 + struct register_pass_info kallocstat_pass_info = {
93452 + .pass = &kallocstat_pass.pass,
93453 + .reference_pass_name = "ssa",
93454 + .ref_pass_instance_number = 1,
93455 + .pos_op = PASS_POS_INSERT_AFTER
93456 + };
93457 +
93458 + if (!plugin_default_version_check(version, &gcc_version)) {
93459 + error(G_("incompatible gcc/plugin versions"));
93460 + return 1;
93461 + }
93462 +
93463 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
93464 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
93465 +
93466 + return 0;
93467 +}
93468 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
93469 new file mode 100644
93470 index 0000000..0408e06
93471 --- /dev/null
93472 +++ b/tools/gcc/kernexec_plugin.c
93473 @@ -0,0 +1,465 @@
93474 +/*
93475 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
93476 + * Licensed under the GPL v2
93477 + *
93478 + * Note: the choice of the license means that the compilation process is
93479 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93480 + * but for the kernel it doesn't matter since it doesn't link against
93481 + * any of the gcc libraries
93482 + *
93483 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
93484 + *
93485 + * TODO:
93486 + *
93487 + * BUGS:
93488 + * - none known
93489 + */
93490 +#include "gcc-plugin.h"
93491 +#include "config.h"
93492 +#include "system.h"
93493 +#include "coretypes.h"
93494 +#include "tree.h"
93495 +#include "tree-pass.h"
93496 +#include "flags.h"
93497 +#include "intl.h"
93498 +#include "toplev.h"
93499 +#include "plugin.h"
93500 +//#include "expr.h" where are you...
93501 +#include "diagnostic.h"
93502 +#include "plugin-version.h"
93503 +#include "tm.h"
93504 +#include "function.h"
93505 +#include "basic-block.h"
93506 +#include "gimple.h"
93507 +#include "rtl.h"
93508 +#include "emit-rtl.h"
93509 +#include "tree-flow.h"
93510 +
93511 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93512 +extern rtx emit_move_insn(rtx x, rtx y);
93513 +
93514 +#if BUILDING_GCC_VERSION <= 4006
93515 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
93516 +#endif
93517 +
93518 +#if BUILDING_GCC_VERSION >= 4008
93519 +#define TODO_dump_func 0
93520 +#endif
93521 +
93522 +int plugin_is_GPL_compatible;
93523 +
93524 +static struct plugin_info kernexec_plugin_info = {
93525 + .version = "201302112000",
93526 + .help = "method=[bts|or]\tinstrumentation method\n"
93527 +};
93528 +
93529 +static unsigned int execute_kernexec_reload(void);
93530 +static unsigned int execute_kernexec_fptr(void);
93531 +static unsigned int execute_kernexec_retaddr(void);
93532 +static bool kernexec_cmodel_check(void);
93533 +
93534 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
93535 +static void (*kernexec_instrument_retaddr)(rtx);
93536 +
93537 +static struct gimple_opt_pass kernexec_reload_pass = {
93538 + .pass = {
93539 + .type = GIMPLE_PASS,
93540 + .name = "kernexec_reload",
93541 +#if BUILDING_GCC_VERSION >= 4008
93542 + .optinfo_flags = OPTGROUP_NONE,
93543 +#endif
93544 + .gate = kernexec_cmodel_check,
93545 + .execute = execute_kernexec_reload,
93546 + .sub = NULL,
93547 + .next = NULL,
93548 + .static_pass_number = 0,
93549 + .tv_id = TV_NONE,
93550 + .properties_required = 0,
93551 + .properties_provided = 0,
93552 + .properties_destroyed = 0,
93553 + .todo_flags_start = 0,
93554 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
93555 + }
93556 +};
93557 +
93558 +static struct gimple_opt_pass kernexec_fptr_pass = {
93559 + .pass = {
93560 + .type = GIMPLE_PASS,
93561 + .name = "kernexec_fptr",
93562 +#if BUILDING_GCC_VERSION >= 4008
93563 + .optinfo_flags = OPTGROUP_NONE,
93564 +#endif
93565 + .gate = kernexec_cmodel_check,
93566 + .execute = execute_kernexec_fptr,
93567 + .sub = NULL,
93568 + .next = NULL,
93569 + .static_pass_number = 0,
93570 + .tv_id = TV_NONE,
93571 + .properties_required = 0,
93572 + .properties_provided = 0,
93573 + .properties_destroyed = 0,
93574 + .todo_flags_start = 0,
93575 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
93576 + }
93577 +};
93578 +
93579 +static struct rtl_opt_pass kernexec_retaddr_pass = {
93580 + .pass = {
93581 + .type = RTL_PASS,
93582 + .name = "kernexec_retaddr",
93583 +#if BUILDING_GCC_VERSION >= 4008
93584 + .optinfo_flags = OPTGROUP_NONE,
93585 +#endif
93586 + .gate = kernexec_cmodel_check,
93587 + .execute = execute_kernexec_retaddr,
93588 + .sub = NULL,
93589 + .next = NULL,
93590 + .static_pass_number = 0,
93591 + .tv_id = TV_NONE,
93592 + .properties_required = 0,
93593 + .properties_provided = 0,
93594 + .properties_destroyed = 0,
93595 + .todo_flags_start = 0,
93596 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
93597 + }
93598 +};
93599 +
93600 +static bool kernexec_cmodel_check(void)
93601 +{
93602 + tree section;
93603 +
93604 + if (ix86_cmodel != CM_KERNEL)
93605 + return false;
93606 +
93607 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
93608 + if (!section || !TREE_VALUE(section))
93609 + return true;
93610 +
93611 + section = TREE_VALUE(TREE_VALUE(section));
93612 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
93613 + return true;
93614 +
93615 + return false;
93616 +}
93617 +
93618 +/*
93619 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
93620 + */
93621 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
93622 +{
93623 + gimple asm_movabs_stmt;
93624 +
93625 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
93626 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
93627 + gimple_asm_set_volatile(asm_movabs_stmt, true);
93628 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
93629 + update_stmt(asm_movabs_stmt);
93630 +}
93631 +
93632 +/*
93633 + * find all asm() stmts that clobber r10 and add a reload of r10
93634 + */
93635 +static unsigned int execute_kernexec_reload(void)
93636 +{
93637 + basic_block bb;
93638 +
93639 + // 1. loop through BBs and GIMPLE statements
93640 + FOR_EACH_BB(bb) {
93641 + gimple_stmt_iterator gsi;
93642 +
93643 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93644 + // gimple match: __asm__ ("" : : : "r10");
93645 + gimple asm_stmt;
93646 + size_t nclobbers;
93647 +
93648 + // is it an asm ...
93649 + asm_stmt = gsi_stmt(gsi);
93650 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
93651 + continue;
93652 +
93653 + // ... clobbering r10
93654 + nclobbers = gimple_asm_nclobbers(asm_stmt);
93655 + while (nclobbers--) {
93656 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
93657 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
93658 + continue;
93659 + kernexec_reload_fptr_mask(&gsi);
93660 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
93661 + break;
93662 + }
93663 + }
93664 + }
93665 +
93666 + return 0;
93667 +}
93668 +
93669 +/*
93670 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
93671 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
93672 + */
93673 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
93674 +{
93675 + gimple assign_intptr, assign_new_fptr, call_stmt;
93676 + tree intptr, old_fptr, new_fptr, kernexec_mask;
93677 +
93678 + call_stmt = gsi_stmt(*gsi);
93679 + old_fptr = gimple_call_fn(call_stmt);
93680 +
93681 + // create temporary unsigned long variable used for bitops and cast fptr to it
93682 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
93683 +#if BUILDING_GCC_VERSION <= 4007
93684 + add_referenced_var(intptr);
93685 + mark_sym_for_renaming(intptr);
93686 +#endif
93687 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
93688 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
93689 + update_stmt(assign_intptr);
93690 +
93691 + // apply logical or to temporary unsigned long and bitmask
93692 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
93693 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
93694 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
93695 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
93696 + update_stmt(assign_intptr);
93697 +
93698 + // cast temporary unsigned long back to a temporary fptr variable
93699 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
93700 +#if BUILDING_GCC_VERSION <= 4007
93701 + add_referenced_var(new_fptr);
93702 + mark_sym_for_renaming(new_fptr);
93703 +#endif
93704 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
93705 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
93706 + update_stmt(assign_new_fptr);
93707 +
93708 + // replace call stmt fn with the new fptr
93709 + gimple_call_set_fn(call_stmt, new_fptr);
93710 + update_stmt(call_stmt);
93711 +}
93712 +
93713 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
93714 +{
93715 + gimple asm_or_stmt, call_stmt;
93716 + tree old_fptr, new_fptr, input, output;
93717 +#if BUILDING_GCC_VERSION <= 4007
93718 + VEC(tree, gc) *inputs = NULL;
93719 + VEC(tree, gc) *outputs = NULL;
93720 +#else
93721 + vec<tree, va_gc> *inputs = NULL;
93722 + vec<tree, va_gc> *outputs = NULL;
93723 +#endif
93724 +
93725 + call_stmt = gsi_stmt(*gsi);
93726 + old_fptr = gimple_call_fn(call_stmt);
93727 +
93728 + // create temporary fptr variable
93729 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
93730 +#if BUILDING_GCC_VERSION <= 4007
93731 + add_referenced_var(new_fptr);
93732 + mark_sym_for_renaming(new_fptr);
93733 +#endif
93734 +
93735 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
93736 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
93737 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
93738 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
93739 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
93740 +#if BUILDING_GCC_VERSION <= 4007
93741 + VEC_safe_push(tree, gc, inputs, input);
93742 + VEC_safe_push(tree, gc, outputs, output);
93743 +#else
93744 + vec_safe_push(inputs, input);
93745 + vec_safe_push(outputs, output);
93746 +#endif
93747 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
93748 + gimple_asm_set_volatile(asm_or_stmt, true);
93749 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
93750 + update_stmt(asm_or_stmt);
93751 +
93752 + // replace call stmt fn with the new fptr
93753 + gimple_call_set_fn(call_stmt, new_fptr);
93754 + update_stmt(call_stmt);
93755 +}
93756 +
93757 +/*
93758 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
93759 + */
93760 +static unsigned int execute_kernexec_fptr(void)
93761 +{
93762 + basic_block bb;
93763 +
93764 + // 1. loop through BBs and GIMPLE statements
93765 + FOR_EACH_BB(bb) {
93766 + gimple_stmt_iterator gsi;
93767 +
93768 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93769 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
93770 + tree fn;
93771 + gimple call_stmt;
93772 +
93773 + // is it a call ...
93774 + call_stmt = gsi_stmt(gsi);
93775 + if (!is_gimple_call(call_stmt))
93776 + continue;
93777 + fn = gimple_call_fn(call_stmt);
93778 + if (TREE_CODE(fn) == ADDR_EXPR)
93779 + continue;
93780 + if (TREE_CODE(fn) != SSA_NAME)
93781 + gcc_unreachable();
93782 +
93783 + // ... through a function pointer
93784 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
93785 + fn = SSA_NAME_VAR(fn);
93786 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
93787 + debug_tree(fn);
93788 + gcc_unreachable();
93789 + }
93790 + }
93791 + fn = TREE_TYPE(fn);
93792 + if (TREE_CODE(fn) != POINTER_TYPE)
93793 + continue;
93794 + fn = TREE_TYPE(fn);
93795 + if (TREE_CODE(fn) != FUNCTION_TYPE)
93796 + continue;
93797 +
93798 + kernexec_instrument_fptr(&gsi);
93799 +
93800 +//debug_tree(gimple_call_fn(call_stmt));
93801 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
93802 + }
93803 + }
93804 +
93805 + return 0;
93806 +}
93807 +
93808 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
93809 +static void kernexec_instrument_retaddr_bts(rtx insn)
93810 +{
93811 + rtx btsq;
93812 + rtvec argvec, constraintvec, labelvec;
93813 + int line;
93814 +
93815 + // create asm volatile("btsq $63,(%%rsp)":::)
93816 + argvec = rtvec_alloc(0);
93817 + constraintvec = rtvec_alloc(0);
93818 + labelvec = rtvec_alloc(0);
93819 + line = expand_location(RTL_LOCATION(insn)).line;
93820 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
93821 + MEM_VOLATILE_P(btsq) = 1;
93822 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
93823 + emit_insn_before(btsq, insn);
93824 +}
93825 +
93826 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
93827 +static void kernexec_instrument_retaddr_or(rtx insn)
93828 +{
93829 + rtx orq;
93830 + rtvec argvec, constraintvec, labelvec;
93831 + int line;
93832 +
93833 + // create asm volatile("orq %%r10,(%%rsp)":::)
93834 + argvec = rtvec_alloc(0);
93835 + constraintvec = rtvec_alloc(0);
93836 + labelvec = rtvec_alloc(0);
93837 + line = expand_location(RTL_LOCATION(insn)).line;
93838 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
93839 + MEM_VOLATILE_P(orq) = 1;
93840 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
93841 + emit_insn_before(orq, insn);
93842 +}
93843 +
93844 +/*
93845 + * find all asm level function returns and forcibly set the highest bit of the return address
93846 + */
93847 +static unsigned int execute_kernexec_retaddr(void)
93848 +{
93849 + rtx insn;
93850 +
93851 + // 1. find function returns
93852 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
93853 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
93854 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
93855 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
93856 + rtx body;
93857 +
93858 + // is it a retn
93859 + if (!JUMP_P(insn))
93860 + continue;
93861 + body = PATTERN(insn);
93862 + if (GET_CODE(body) == PARALLEL)
93863 + body = XVECEXP(body, 0, 0);
93864 + if (!ANY_RETURN_P(body))
93865 + continue;
93866 + kernexec_instrument_retaddr(insn);
93867 + }
93868 +
93869 +// print_simple_rtl(stderr, get_insns());
93870 +// print_rtl(stderr, get_insns());
93871 +
93872 + return 0;
93873 +}
93874 +
93875 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93876 +{
93877 + const char * const plugin_name = plugin_info->base_name;
93878 + const int argc = plugin_info->argc;
93879 + const struct plugin_argument * const argv = plugin_info->argv;
93880 + int i;
93881 + struct register_pass_info kernexec_reload_pass_info = {
93882 + .pass = &kernexec_reload_pass.pass,
93883 + .reference_pass_name = "ssa",
93884 + .ref_pass_instance_number = 1,
93885 + .pos_op = PASS_POS_INSERT_AFTER
93886 + };
93887 + struct register_pass_info kernexec_fptr_pass_info = {
93888 + .pass = &kernexec_fptr_pass.pass,
93889 + .reference_pass_name = "ssa",
93890 + .ref_pass_instance_number = 1,
93891 + .pos_op = PASS_POS_INSERT_AFTER
93892 + };
93893 + struct register_pass_info kernexec_retaddr_pass_info = {
93894 + .pass = &kernexec_retaddr_pass.pass,
93895 + .reference_pass_name = "pro_and_epilogue",
93896 + .ref_pass_instance_number = 1,
93897 + .pos_op = PASS_POS_INSERT_AFTER
93898 + };
93899 +
93900 + if (!plugin_default_version_check(version, &gcc_version)) {
93901 + error(G_("incompatible gcc/plugin versions"));
93902 + return 1;
93903 + }
93904 +
93905 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
93906 +
93907 + if (TARGET_64BIT == 0)
93908 + return 0;
93909 +
93910 + for (i = 0; i < argc; ++i) {
93911 + if (!strcmp(argv[i].key, "method")) {
93912 + if (!argv[i].value) {
93913 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93914 + continue;
93915 + }
93916 + if (!strcmp(argv[i].value, "bts")) {
93917 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
93918 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
93919 + } else if (!strcmp(argv[i].value, "or")) {
93920 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
93921 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
93922 + fix_register("r10", 1, 1);
93923 + } else
93924 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
93925 + continue;
93926 + }
93927 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93928 + }
93929 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
93930 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
93931 +
93932 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
93933 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
93934 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
93935 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
93936 +
93937 + return 0;
93938 +}
93939 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
93940 new file mode 100644
93941 index 0000000..b5395ba
93942 --- /dev/null
93943 +++ b/tools/gcc/latent_entropy_plugin.c
93944 @@ -0,0 +1,327 @@
93945 +/*
93946 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
93947 + * Licensed under the GPL v2
93948 + *
93949 + * Note: the choice of the license means that the compilation process is
93950 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93951 + * but for the kernel it doesn't matter since it doesn't link against
93952 + * any of the gcc libraries
93953 + *
93954 + * gcc plugin to help generate a little bit of entropy from program state,
93955 + * used during boot in the kernel
93956 + *
93957 + * TODO:
93958 + * - add ipa pass to identify not explicitly marked candidate functions
93959 + * - mix in more program state (function arguments/return values, loop variables, etc)
93960 + * - more instrumentation control via attribute parameters
93961 + *
93962 + * BUGS:
93963 + * - LTO needs -flto-partition=none for now
93964 + */
93965 +#include "gcc-plugin.h"
93966 +#include "config.h"
93967 +#include "system.h"
93968 +#include "coretypes.h"
93969 +#include "tree.h"
93970 +#include "tree-pass.h"
93971 +#include "flags.h"
93972 +#include "intl.h"
93973 +#include "toplev.h"
93974 +#include "plugin.h"
93975 +//#include "expr.h" where are you...
93976 +#include "diagnostic.h"
93977 +#include "plugin-version.h"
93978 +#include "tm.h"
93979 +#include "function.h"
93980 +#include "basic-block.h"
93981 +#include "gimple.h"
93982 +#include "rtl.h"
93983 +#include "emit-rtl.h"
93984 +#include "tree-flow.h"
93985 +#include "langhooks.h"
93986 +
93987 +#if BUILDING_GCC_VERSION >= 4008
93988 +#define TODO_dump_func 0
93989 +#endif
93990 +
93991 +int plugin_is_GPL_compatible;
93992 +
93993 +static tree latent_entropy_decl;
93994 +
93995 +static struct plugin_info latent_entropy_plugin_info = {
93996 + .version = "201303102320",
93997 + .help = NULL
93998 +};
93999 +
94000 +static unsigned int execute_latent_entropy(void);
94001 +static bool gate_latent_entropy(void);
94002 +
94003 +static struct gimple_opt_pass latent_entropy_pass = {
94004 + .pass = {
94005 + .type = GIMPLE_PASS,
94006 + .name = "latent_entropy",
94007 +#if BUILDING_GCC_VERSION >= 4008
94008 + .optinfo_flags = OPTGROUP_NONE,
94009 +#endif
94010 + .gate = gate_latent_entropy,
94011 + .execute = execute_latent_entropy,
94012 + .sub = NULL,
94013 + .next = NULL,
94014 + .static_pass_number = 0,
94015 + .tv_id = TV_NONE,
94016 + .properties_required = PROP_gimple_leh | PROP_cfg,
94017 + .properties_provided = 0,
94018 + .properties_destroyed = 0,
94019 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
94020 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
94021 + }
94022 +};
94023 +
94024 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94025 +{
94026 + if (TREE_CODE(*node) != FUNCTION_DECL) {
94027 + *no_add_attrs = true;
94028 + error("%qE attribute only applies to functions", name);
94029 + }
94030 + return NULL_TREE;
94031 +}
94032 +
94033 +static struct attribute_spec latent_entropy_attr = {
94034 + .name = "latent_entropy",
94035 + .min_length = 0,
94036 + .max_length = 0,
94037 + .decl_required = true,
94038 + .type_required = false,
94039 + .function_type_required = false,
94040 + .handler = handle_latent_entropy_attribute,
94041 +#if BUILDING_GCC_VERSION >= 4007
94042 + .affects_type_identity = false
94043 +#endif
94044 +};
94045 +
94046 +static void register_attributes(void *event_data, void *data)
94047 +{
94048 + register_attribute(&latent_entropy_attr);
94049 +}
94050 +
94051 +static bool gate_latent_entropy(void)
94052 +{
94053 + tree latent_entropy_attr;
94054 +
94055 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
94056 + return latent_entropy_attr != NULL_TREE;
94057 +}
94058 +
94059 +static unsigned HOST_WIDE_INT seed;
94060 +static unsigned HOST_WIDE_INT get_random_const(void)
94061 +{
94062 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
94063 + return seed;
94064 +}
94065 +
94066 +static enum tree_code get_op(tree *rhs)
94067 +{
94068 + static enum tree_code op;
94069 + unsigned HOST_WIDE_INT random_const;
94070 +
94071 + random_const = get_random_const();
94072 +
94073 + switch (op) {
94074 + case BIT_XOR_EXPR:
94075 + op = PLUS_EXPR;
94076 + break;
94077 +
94078 + case PLUS_EXPR:
94079 + if (rhs) {
94080 + op = LROTATE_EXPR;
94081 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
94082 + break;
94083 + }
94084 +
94085 + case LROTATE_EXPR:
94086 + default:
94087 + op = BIT_XOR_EXPR;
94088 + break;
94089 + }
94090 + if (rhs)
94091 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
94092 + return op;
94093 +}
94094 +
94095 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
94096 +{
94097 + gimple_stmt_iterator gsi;
94098 + gimple assign;
94099 + tree addxorrol, rhs;
94100 + enum tree_code op;
94101 +
94102 + op = get_op(&rhs);
94103 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
94104 + assign = gimple_build_assign(local_entropy, addxorrol);
94105 +#if BUILDING_GCC_VERSION <= 4007
94106 + find_referenced_vars_in(assign);
94107 +#endif
94108 +//debug_bb(bb);
94109 + gsi = gsi_after_labels(bb);
94110 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
94111 + update_stmt(assign);
94112 +}
94113 +
94114 +static void perturb_latent_entropy(basic_block bb, tree rhs)
94115 +{
94116 + gimple_stmt_iterator gsi;
94117 + gimple assign;
94118 + tree addxorrol, temp;
94119 +
94120 + // 1. create temporary copy of latent_entropy
94121 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
94122 +#if BUILDING_GCC_VERSION <= 4007
94123 + add_referenced_var(temp);
94124 + mark_sym_for_renaming(temp);
94125 +#endif
94126 +
94127 + // 2. read...
94128 + assign = gimple_build_assign(temp, latent_entropy_decl);
94129 +#if BUILDING_GCC_VERSION <= 4007
94130 + find_referenced_vars_in(assign);
94131 +#endif
94132 + gsi = gsi_after_labels(bb);
94133 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94134 + update_stmt(assign);
94135 +
94136 + // 3. ...modify...
94137 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
94138 + assign = gimple_build_assign(temp, addxorrol);
94139 +#if BUILDING_GCC_VERSION <= 4007
94140 + find_referenced_vars_in(assign);
94141 +#endif
94142 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94143 + update_stmt(assign);
94144 +
94145 + // 4. ...write latent_entropy
94146 + assign = gimple_build_assign(latent_entropy_decl, temp);
94147 +#if BUILDING_GCC_VERSION <= 4007
94148 + find_referenced_vars_in(assign);
94149 +#endif
94150 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94151 + update_stmt(assign);
94152 +}
94153 +
94154 +static unsigned int execute_latent_entropy(void)
94155 +{
94156 + basic_block bb;
94157 + gimple assign;
94158 + gimple_stmt_iterator gsi;
94159 + tree local_entropy;
94160 +
94161 + if (!latent_entropy_decl) {
94162 + struct varpool_node *node;
94163 +
94164 +#if BUILDING_GCC_VERSION <= 4007
94165 + for (node = varpool_nodes; node; node = node->next) {
94166 + tree var = node->decl;
94167 +#else
94168 + FOR_EACH_VARIABLE(node) {
94169 + tree var = node->symbol.decl;
94170 +#endif
94171 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
94172 + continue;
94173 + latent_entropy_decl = var;
94174 +// debug_tree(var);
94175 + break;
94176 + }
94177 + if (!latent_entropy_decl) {
94178 +// debug_tree(current_function_decl);
94179 + return 0;
94180 + }
94181 + }
94182 +
94183 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
94184 +
94185 + // 1. create local entropy variable
94186 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
94187 +#if BUILDING_GCC_VERSION <= 4007
94188 + add_referenced_var(local_entropy);
94189 + mark_sym_for_renaming(local_entropy);
94190 +#endif
94191 +
94192 + // 2. initialize local entropy variable
94193 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
94194 + if (dom_info_available_p(CDI_DOMINATORS))
94195 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
94196 + gsi = gsi_start_bb(bb);
94197 +
94198 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
94199 +// gimple_set_location(assign, loc);
94200 +#if BUILDING_GCC_VERSION <= 4007
94201 + find_referenced_vars_in(assign);
94202 +#endif
94203 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
94204 + update_stmt(assign);
94205 + bb = bb->next_bb;
94206 +
94207 + // 3. instrument each BB with an operation on the local entropy variable
94208 + while (bb != EXIT_BLOCK_PTR) {
94209 + perturb_local_entropy(bb, local_entropy);
94210 + bb = bb->next_bb;
94211 + };
94212 +
94213 + // 4. mix local entropy into the global entropy variable
94214 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
94215 + return 0;
94216 +}
94217 +
94218 +static void start_unit_callback(void *gcc_data, void *user_data)
94219 +{
94220 + tree latent_entropy_type;
94221 +
94222 +#if BUILDING_GCC_VERSION >= 4007
94223 + seed = get_random_seed(false);
94224 +#else
94225 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
94226 + seed *= seed;
94227 +#endif
94228 +
94229 + if (in_lto_p)
94230 + return;
94231 +
94232 + // extern volatile u64 latent_entropy
94233 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
94234 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
94235 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
94236 +
94237 + TREE_STATIC(latent_entropy_decl) = 1;
94238 + TREE_PUBLIC(latent_entropy_decl) = 1;
94239 + TREE_USED(latent_entropy_decl) = 1;
94240 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
94241 + DECL_EXTERNAL(latent_entropy_decl) = 1;
94242 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
94243 + DECL_INITIAL(latent_entropy_decl) = NULL;
94244 + lang_hooks.decls.pushdecl(latent_entropy_decl);
94245 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
94246 +// varpool_finalize_decl(latent_entropy_decl);
94247 +// varpool_mark_needed_node(latent_entropy_decl);
94248 +}
94249 +
94250 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94251 +{
94252 + const char * const plugin_name = plugin_info->base_name;
94253 + struct register_pass_info latent_entropy_pass_info = {
94254 + .pass = &latent_entropy_pass.pass,
94255 + .reference_pass_name = "optimized",
94256 + .ref_pass_instance_number = 1,
94257 + .pos_op = PASS_POS_INSERT_BEFORE
94258 + };
94259 +
94260 + if (!plugin_default_version_check(version, &gcc_version)) {
94261 + error(G_("incompatible gcc/plugin versions"));
94262 + return 1;
94263 + }
94264 +
94265 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
94266 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
94267 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
94268 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94269 +
94270 + return 0;
94271 +}
94272 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
94273 new file mode 100644
94274 index 0000000..ddd5b2e
94275 --- /dev/null
94276 +++ b/tools/gcc/size_overflow_hash.data
94277 @@ -0,0 +1,5876 @@
94278 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
94279 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
94280 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
94281 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
94282 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
94283 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
94284 +padzero_55 padzero 1 55 &sel_read_policyvers_55
94285 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
94286 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
94287 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
94288 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
94289 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
94290 +load_msg_95 load_msg 2 95 NULL
94291 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
94292 +init_q_132 init_q 4 132 NULL
94293 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
94294 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
94295 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
94296 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
94297 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
94298 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
94299 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
94300 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
94301 +br_port_info_size_268 br_port_info_size 0 268 NULL
94302 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
94303 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
94304 +syslog_print_307 syslog_print 2 307 NULL
94305 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
94306 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
94307 +next_node_allowed_318 next_node_allowed 1 318 NULL
94308 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
94309 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
94310 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
94311 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
94312 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
94313 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
94314 +pidlist_resize_496 pidlist_resize 2 496 NULL
94315 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
94316 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
94317 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
94318 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
94319 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
94320 +dle_count_543 dle_count 0 543 NULL
94321 +devres_alloc_551 devres_alloc 2 551 NULL
94322 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
94323 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
94324 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
94325 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
94326 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
94327 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
94328 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
94329 +isp1760_register_628 isp1760_register 1-2 628 NULL
94330 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
94331 +unlink_queued_645 unlink_queued 3-4 645 NULL
94332 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
94333 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
94334 +div_u64_rem_672 div_u64_rem 0 672 NULL
94335 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
94336 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
94337 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
94338 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
94339 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
94340 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
94341 +dvb_video_write_754 dvb_video_write 3 754 NULL
94342 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
94343 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
94344 +if_writecmd_815 if_writecmd 2 815 NULL
94345 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
94346 +read_fifo_826 read_fifo 3 826 NULL
94347 +read_tree_block_841 read_tree_block 3 841 NULL
94348 +um_idi_read_850 um_idi_read 3 850 NULL
94349 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
94350 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
94351 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
94352 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
94353 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
94354 +readw_931 readw 0 931 NULL
94355 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
94356 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
94357 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
94358 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
94359 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
94360 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
94361 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
94362 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
94363 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
94364 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
94365 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
94366 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
94367 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
94368 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
94369 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
94370 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
94371 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
94372 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
94373 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
94374 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
94375 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
94376 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
94377 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
94378 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
94379 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
94380 +thin_status_1239 thin_status 5 1239 NULL
94381 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
94382 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
94383 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
94384 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
94385 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
94386 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
94387 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
94388 +ffs_1322 ffs 0 1322 NULL
94389 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
94390 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
94391 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
94392 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
94393 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
94394 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
94395 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
94396 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
94397 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
94398 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
94399 +zone_page_state_1393 zone_page_state 0 1393 NULL
94400 +file_read_actor_1401 file_read_actor 4 1401 NULL
94401 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
94402 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
94403 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
94404 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
94405 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
94406 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
94407 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
94408 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
94409 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
94410 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
94411 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
94412 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
94413 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
94414 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
94415 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
94416 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
94417 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
94418 +rmap_add_1677 rmap_add 3 1677 NULL
94419 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
94420 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
94421 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
94422 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
94423 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
94424 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
94425 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
94426 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
94427 +cosa_write_1774 cosa_write 3 1774 NULL
94428 +update_macheader_1775 update_macheader 7 1775 NULL
94429 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
94430 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
94431 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
94432 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
94433 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
94434 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
94435 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
94436 +read_swap_header_1957 read_swap_header 0 1957 NULL
94437 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
94438 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
94439 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
94440 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
94441 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
94442 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
94443 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
94444 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
94445 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
94446 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
94447 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
94448 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
94449 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
94450 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
94451 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
94452 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
94453 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
94454 +audit_expand_2098 audit_expand 2 2098 NULL
94455 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
94456 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
94457 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
94458 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
94459 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
94460 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
94461 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
94462 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
94463 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
94464 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
94465 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
94466 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
94467 +u32_array_read_2219 u32_array_read 3 2219 NULL
94468 +vhci_write_2224 vhci_write 3 2224 NULL
94469 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
94470 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
94471 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
94472 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
94473 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
94474 +do_update_counters_2259 do_update_counters 4 2259 NULL
94475 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
94476 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
94477 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
94478 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
94479 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
94480 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
94481 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
94482 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
94483 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
94484 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
94485 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
94486 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
94487 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
94488 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
94489 +raid1_size_2419 raid1_size 0-2 2419 NULL
94490 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
94491 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
94492 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
94493 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
94494 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
94495 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
94496 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
94497 +update_pmkid_2481 update_pmkid 4 2481 NULL
94498 +wiphy_new_2482 wiphy_new 2 2482 NULL
94499 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
94500 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
94501 +dm_write_2513 dm_write 3 2513 NULL
94502 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
94503 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
94504 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
94505 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
94506 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
94507 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
94508 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
94509 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
94510 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
94511 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
94512 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
94513 +__next_cpu_2782 __next_cpu 1 2782 NULL
94514 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
94515 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
94516 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
94517 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
94518 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
94519 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
94520 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
94521 +__swab64p_2875 __swab64p 0 2875 NULL
94522 +nla_padlen_2883 nla_padlen 1 2883 NULL
94523 +cmm_write_2896 cmm_write 3 2896 NULL
94524 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
94525 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
94526 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
94527 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
94528 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
94529 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
94530 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
94531 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
94532 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
94533 +depth_write_3021 depth_write 3 3021 NULL
94534 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
94535 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
94536 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
94537 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
94538 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
94539 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
94540 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
94541 +free_coherent_3082 free_coherent 4-2 3082 NULL
94542 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
94543 +rb_alloc_3102 rb_alloc 1 3102 NULL
94544 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
94545 +print_time_3132 print_time 0 3132 NULL
94546 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
94547 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
94548 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
94549 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
94550 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
94551 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
94552 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
94553 +alloc_context_3194 alloc_context 1 3194 NULL
94554 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
94555 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
94556 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
94557 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
94558 +key_key_read_3241 key_key_read 3 3241 NULL
94559 +number_3243 number 0 3243 NULL
94560 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
94561 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
94562 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
94563 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
94564 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
94565 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
94566 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
94567 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
94568 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
94569 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
94570 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
94571 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
94572 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
94573 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
94574 +send_stream_3397 send_stream 4 3397 NULL
94575 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
94576 +msix_map_region_3411 msix_map_region 3 3411 NULL
94577 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
94578 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
94579 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
94580 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
94581 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
94582 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
94583 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
94584 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
94585 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
94586 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
94587 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
94588 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
94589 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
94590 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
94591 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
94592 +evtchn_read_3569 evtchn_read 3 3569 NULL
94593 +vc_resize_3585 vc_resize 2-3 3585 NULL
94594 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
94595 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
94596 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
94597 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
94598 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
94599 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
94600 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
94601 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
94602 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
94603 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
94604 +create_irq_3703 create_irq 0 3703 NULL nohasharray
94605 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
94606 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
94607 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
94608 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
94609 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
94610 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
94611 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
94612 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
94613 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
94614 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
94615 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
94616 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
94617 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
94618 +get_fd_set_3866 get_fd_set 1 3866 NULL
94619 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
94620 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
94621 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
94622 +nvram_write_3894 nvram_write 3 3894 NULL
94623 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
94624 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
94625 +vcs_write_3910 vcs_write 3 3910 NULL
94626 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
94627 +do_add_counters_3992 do_add_counters 3 3992 NULL
94628 +userspace_status_4004 userspace_status 4 4004 NULL
94629 +mei_write_4005 mei_write 3 4005 NULL nohasharray
94630 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
94631 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
94632 +blk_end_request_4024 blk_end_request 3 4024 NULL
94633 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
94634 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
94635 +read_file_queues_4078 read_file_queues 3 4078 NULL
94636 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
94637 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
94638 +tm6000_read_4151 tm6000_read 3 4151 NULL
94639 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
94640 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
94641 +get_alua_req_4166 get_alua_req 3 4166 NULL
94642 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
94643 +read_file_bool_4180 read_file_bool 3 4180 NULL
94644 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
94645 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
94646 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
94647 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
94648 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
94649 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
94650 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
94651 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
94652 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
94653 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
94654 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
94655 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
94656 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
94657 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
94658 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
94659 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
94660 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
94661 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
94662 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
94663 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
94664 +set_link_security_4502 set_link_security 4 4502 NULL
94665 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
94666 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
94667 +tty_register_device_4544 tty_register_device 2 4544 NULL
94668 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
94669 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
94670 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
94671 +bch_alloc_4593 bch_alloc 1 4593 NULL
94672 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
94673 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
94674 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
94675 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
94676 +kone_receive_4690 kone_receive 4 4690 NULL
94677 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
94678 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
94679 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
94680 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
94681 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
94682 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
94683 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
94684 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
94685 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
94686 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
94687 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
94688 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
94689 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
94690 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
94691 +sys_ipc_4889 sys_ipc 3 4889 NULL
94692 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
94693 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
94694 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
94695 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
94696 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
94697 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
94698 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
94699 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
94700 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
94701 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
94702 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
94703 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
94704 +do_mincore_5018 do_mincore 0-1 5018 NULL
94705 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
94706 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
94707 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
94708 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
94709 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
94710 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
94711 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
94712 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
94713 +sound_write_5102 sound_write 3 5102 NULL
94714 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
94715 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
94716 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
94717 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
94718 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
94719 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
94720 +skb_network_header_5203 skb_network_header 0 5203 NULL
94721 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
94722 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
94723 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
94724 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
94725 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
94726 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
94727 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
94728 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
94729 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
94730 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
94731 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
94732 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
94733 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
94734 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
94735 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
94736 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
94737 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
94738 +tty_write_5494 tty_write 3 5494 NULL
94739 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
94740 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
94741 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
94742 +spidev_message_5518 spidev_message 3 5518 NULL
94743 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
94744 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
94745 +le_readq_5557 le_readq 0 5557 NULL
94746 +inw_5558 inw 0 5558 NULL
94747 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
94748 +fir16_create_5574 fir16_create 3 5574 NULL
94749 +bioset_create_5580 bioset_create 1 5580 NULL
94750 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
94751 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
94752 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
94753 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
94754 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
94755 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
94756 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
94757 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
94758 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
94759 +get_arg_5694 get_arg 3 5694 NULL
94760 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
94761 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
94762 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
94763 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
94764 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
94765 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
94766 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
94767 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
94768 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
94769 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
94770 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
94771 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
94772 +setup_req_5848 setup_req 3 5848 NULL
94773 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
94774 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
94775 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
94776 +port_show_regs_5904 port_show_regs 3 5904 NULL
94777 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
94778 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
94779 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
94780 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
94781 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
94782 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
94783 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
94784 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
94785 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
94786 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
94787 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
94788 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
94789 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
94790 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
94791 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
94792 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
94793 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
94794 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
94795 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
94796 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
94797 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
94798 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
94799 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
94800 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
94801 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
94802 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
94803 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
94804 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
94805 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
94806 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
94807 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
94808 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
94809 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
94810 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
94811 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
94812 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
94813 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
94814 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
94815 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
94816 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
94817 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
94818 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
94819 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
94820 +mei_read_6507 mei_read 3 6507 NULL
94821 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
94822 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
94823 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
94824 +wdm_read_6549 wdm_read 3 6549 NULL
94825 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
94826 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
94827 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
94828 +usemap_size_6601 usemap_size 0-1 6601 NULL
94829 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
94830 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
94831 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
94832 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
94833 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
94834 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
94835 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
94836 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
94837 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
94838 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
94839 +mpeg_read_6708 mpeg_read 3 6708 NULL
94840 +video_proc_write_6724 video_proc_write 3 6724 NULL
94841 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
94842 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
94843 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
94844 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
94845 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
94846 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
94847 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
94848 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
94849 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
94850 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
94851 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
94852 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
94853 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
94854 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
94855 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
94856 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
94857 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
94858 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
94859 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
94860 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
94861 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
94862 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
94863 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
94864 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
94865 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
94866 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
94867 +request_key_async_6990 request_key_async 4 6990 NULL
94868 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
94869 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
94870 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
94871 +wimax_msg_7030 wimax_msg 4 7030 NULL
94872 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
94873 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
94874 +event_enable_read_7074 event_enable_read 3 7074 NULL
94875 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
94876 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
94877 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
94878 +check_header_7108 check_header 0 7108 NULL
94879 +utf16_strsize_7203 utf16_strsize 0 7203 NULL nohasharray
94880 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 &utf16_strsize_7203
94881 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
94882 +get_param_h_7247 get_param_h 0 7247 NULL
94883 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
94884 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
94885 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
94886 +mgmt_control_7349 mgmt_control 3 7349 NULL
94887 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
94888 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
94889 +hweight_long_7388 hweight_long 0-1 7388 NULL
94890 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
94891 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
94892 +readb_7401 readb 0 7401 NULL
94893 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
94894 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
94895 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
94896 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
94897 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
94898 +garp_request_join_7471 garp_request_join 4 7471 NULL
94899 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
94900 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
94901 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
94902 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
94903 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
94904 +setup_usemap_7524 setup_usemap 3 7524 NULL
94905 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
94906 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
94907 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
94908 +groups_alloc_7614 groups_alloc 1 7614 NULL
94909 +sg_virt_7616 sg_virt 0 7616 NULL
94910 +cpumask_first_7648 cpumask_first 0 7648 NULL
94911 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
94912 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
94913 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
94914 +dev_write_7708 dev_write 3 7708 NULL
94915 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
94916 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
94917 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
94918 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
94919 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
94920 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
94921 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
94922 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
94923 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
94924 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
94925 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
94926 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
94927 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
94928 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
94929 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
94930 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
94931 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
94932 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
94933 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
94934 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
94935 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
94936 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
94937 +sys_mbind_7990 sys_mbind 5 7990 NULL
94938 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
94939 +vcs_read_8017 vcs_read 3 8017 NULL
94940 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
94941 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
94942 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
94943 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
94944 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
94945 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
94946 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
94947 +venus_lookup_8121 venus_lookup 4 8121 NULL
94948 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
94949 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
94950 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
94951 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
94952 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
94953 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
94954 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
94955 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
94956 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
94957 +play_iframe_8219 play_iframe 3 8219 NULL
94958 +create_log_8225 create_log 2 8225 NULL nohasharray
94959 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
94960 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
94961 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
94962 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
94963 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
94964 +init_cdev_8274 init_cdev 1 8274 NULL
94965 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
94966 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
94967 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
94968 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
94969 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
94970 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
94971 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
94972 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
94973 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
94974 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
94975 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
94976 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
94977 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
94978 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
94979 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
94980 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
94981 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
94982 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
94983 +dev_config_8506 dev_config 3 8506 NULL
94984 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
94985 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
94986 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
94987 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
94988 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
94989 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
94990 +profile_remove_8556 profile_remove 3 8556 NULL
94991 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
94992 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
94993 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
94994 +tower_write_8580 tower_write 3 8580 NULL
94995 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
94996 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
94997 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
94998 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
94999 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
95000 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
95001 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
95002 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
95003 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
95004 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
95005 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
95006 +arcfb_write_8702 arcfb_write 3 8702 NULL
95007 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
95008 +init_header_8703 init_header 0 8703 &i_size_read_8703
95009 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
95010 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
95011 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
95012 +f_dupfd_8730 f_dupfd 1 8730 NULL
95013 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
95014 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
95015 +sys_prctl_8766 sys_prctl 4 8766 NULL
95016 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
95017 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
95018 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
95019 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
95020 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
95021 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
95022 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
95023 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
95024 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
95025 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
95026 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
95027 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
95028 +send_pages_8872 send_pages 3 8872 NULL
95029 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
95030 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
95031 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
95032 +layout_commit_8926 layout_commit 3 8926 NULL
95033 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
95034 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
95035 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
95036 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
95037 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
95038 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
95039 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
95040 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
95041 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
95042 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
95043 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
95044 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
95045 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
95046 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
95047 +nla_put_9042 nla_put 3 9042 NULL
95048 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
95049 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
95050 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
95051 +string_9080 string 0 9080 NULL
95052 +create_queues_9088 create_queues 2-3 9088 NULL
95053 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
95054 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
95055 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
95056 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
95057 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
95058 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
95059 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
95060 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
95061 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
95062 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
95063 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
95064 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
95065 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
95066 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
95067 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
95068 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
95069 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
95070 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
95071 +flakey_status_9274 flakey_status 5 9274 NULL
95072 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
95073 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
95074 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
95075 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
95076 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
95077 +read_9397 read 3 9397 NULL
95078 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
95079 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
95080 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
95081 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
95082 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
95083 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
95084 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
95085 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
95086 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
95087 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
95088 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
95089 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
95090 +lp_write_9511 lp_write 3 9511 NULL
95091 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
95092 +lm3533_update_9529 lm3533_update 2 9529 NULL
95093 +read_file_dma_9530 read_file_dma 3 9530 NULL
95094 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
95095 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
95096 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
95097 +readl_9557 readl 0 9557 NULL
95098 +fw_node_create_9559 fw_node_create 2 9559 NULL
95099 +kobj_map_9566 kobj_map 2-3 9566 NULL
95100 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
95101 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
95102 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
95103 +do_sync_9604 do_sync 1 9604 NULL
95104 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
95105 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
95106 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
95107 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
95108 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
95109 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
95110 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
95111 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
95112 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
95113 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
95114 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
95115 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 NULL nohasharray
95116 +is_hole_9694 is_hole 2 9694 &x25_asy_compat_ioctl_9694
95117 +fnb_9703 fnb 2-3 9703 NULL
95118 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
95119 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
95120 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
95121 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
95122 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
95123 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
95124 +do_sigpending_9766 do_sigpending 2 9766 NULL
95125 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
95126 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
95127 +_regmap_write_9803 _regmap_write 2 9803 NULL
95128 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
95129 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
95130 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
95131 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
95132 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
95133 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
95134 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
95135 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
95136 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
95137 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
95138 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
95139 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
95140 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
95141 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
95142 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
95143 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
95144 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
95145 +read_file_misc_9948 read_file_misc 3 9948 NULL
95146 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
95147 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
95148 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
95149 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
95150 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
95151 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
95152 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
95153 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
95154 +handle_request_10024 handle_request 9 10024 NULL
95155 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
95156 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
95157 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
95158 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
95159 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
95160 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
95161 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
95162 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
95163 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
95164 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
95165 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
95166 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
95167 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
95168 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
95169 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
95170 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
95171 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
95172 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
95173 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
95174 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
95175 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
95176 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
95177 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
95178 +read_emulate_10310 read_emulate 2-4 10310 NULL
95179 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
95180 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
95181 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
95182 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
95183 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
95184 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
95185 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
95186 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
95187 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
95188 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
95189 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
95190 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
95191 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
95192 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
95193 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
95194 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
95195 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
95196 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
95197 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
95198 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
95199 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
95200 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
95201 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
95202 +otp_read_10594 otp_read 2-4-5 10594 NULL
95203 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
95204 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
95205 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
95206 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
95207 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
95208 +parport_write_10669 parport_write 0 10669 NULL
95209 +inl_10708 inl 0 10708 NULL nohasharray
95210 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
95211 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
95212 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
95213 +spi_sync_10731 spi_sync 0 10731 NULL
95214 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
95215 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
95216 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
95217 +sys_syslog_10746 sys_syslog 3 10746 NULL
95218 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
95219 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
95220 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
95221 +sys_bind_10799 sys_bind 3 10799 NULL
95222 +compat_put_int_10828 compat_put_int 1 10828 NULL
95223 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
95224 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
95225 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
95226 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
95227 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
95228 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
95229 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
95230 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
95231 +get_scq_10897 get_scq 2 10897 NULL
95232 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
95233 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
95234 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
95235 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
95236 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
95237 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
95238 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
95239 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
95240 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
95241 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
95242 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
95243 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
95244 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
95245 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
95246 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
95247 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
95248 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
95249 +count_argc_11083 count_argc 0 11083 NULL
95250 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
95251 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
95252 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
95253 +page_offset_11120 page_offset 0 11120 NULL
95254 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
95255 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
95256 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
95257 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
95258 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
95259 +__swab16p_11220 __swab16p 0 11220 NULL
95260 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
95261 +of_irq_count_11253 of_irq_count 0 11253 NULL
95262 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
95263 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
95264 +cru_detect_11272 cru_detect 1 11272 NULL
95265 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
95266 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
95267 +construct_key_11329 construct_key 3 11329 NULL nohasharray
95268 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
95269 +next_segment_11330 next_segment 0-2-1 11330 NULL
95270 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
95271 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
95272 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
95273 +sel_write_create_11353 sel_write_create 3 11353 NULL
95274 +handle_unit_11355 handle_unit 0-1 11355 NULL
95275 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
95276 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
95277 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
95278 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
95279 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
95280 +str_to_user_11411 str_to_user 2 11411 NULL
95281 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
95282 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
95283 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
95284 +trace_options_read_11419 trace_options_read 3 11419 NULL
95285 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
95286 +prepare_image_11424 prepare_image 0 11424 NULL
95287 +vring_size_11426 vring_size 0-1-2 11426 NULL
95288 +bttv_read_11432 bttv_read 3 11432 NULL
95289 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
95290 +swp_offset_11475 swp_offset 0 11475 NULL
95291 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
95292 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
95293 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
95294 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
95295 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
95296 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
95297 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
95298 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
95299 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
95300 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
95301 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
95302 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
95303 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
95304 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
95305 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
95306 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
95307 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
95308 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
95309 +split_11691 split 2 11691 NULL
95310 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
95311 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
95312 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
95313 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
95314 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
95315 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
95316 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
95317 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
95318 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
95319 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
95320 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
95321 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
95322 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
95323 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
95324 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
95325 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
95326 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
95327 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
95328 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
95329 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
95330 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
95331 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
95332 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
95333 +atmel_read16_11981 atmel_read16 0 11981 NULL
95334 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
95335 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
95336 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
95337 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
95338 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
95339 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
95340 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
95341 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
95342 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
95343 +set_powered_12129 set_powered 4 12129 NULL
95344 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
95345 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
95346 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
95347 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
95348 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
95349 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
95350 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
95351 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
95352 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
95353 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
95354 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
95355 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
95356 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
95357 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
95358 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
95359 +receive_copy_12216 receive_copy 3 12216 NULL
95360 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
95361 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
95362 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
95363 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
95364 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
95365 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
95366 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
95367 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
95368 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
95369 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
95370 +split_bvec_12312 split_bvec 6 12312 NULL
95371 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
95372 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
95373 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
95374 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
95375 +receive_packet_12367 receive_packet 2 12367 NULL
95376 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
95377 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
95378 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
95379 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
95380 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
95381 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
95382 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
95383 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
95384 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
95385 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
95386 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
95387 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
95388 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
95389 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
95390 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
95391 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
95392 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
95393 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
95394 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
95395 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
95396 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
95397 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
95398 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
95399 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
95400 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
95401 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
95402 +ivtv_write_12721 ivtv_write 3 12721 NULL
95403 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
95404 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
95405 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
95406 +listxattr_12769 listxattr 3 12769 NULL
95407 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
95408 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
95409 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
95410 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
95411 +readq_12825 readq 0 12825 NULL
95412 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
95413 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 NULL nohasharray
95414 +spidev_sync_12842 spidev_sync 0 12842 &ath6kl_wmi_add_wow_pattern_cmd_12842
95415 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
95416 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
95417 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
95418 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
95419 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
95420 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
95421 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
95422 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
95423 +bm_status_write_12964 bm_status_write 3 12964 NULL
95424 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
95425 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
95426 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
95427 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
95428 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
95429 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
95430 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
95431 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
95432 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
95433 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
95434 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
95435 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
95436 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
95437 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
95438 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
95439 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
95440 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
95441 +blk_update_request_13146 blk_update_request 3 13146 NULL
95442 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
95443 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
95444 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
95445 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
95446 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
95447 +comedi_read_13199 comedi_read 3 13199 NULL
95448 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
95449 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
95450 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
95451 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
95452 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
95453 +fw_download_code_13249 fw_download_code 3 13249 NULL
95454 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
95455 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
95456 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
95457 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
95458 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
95459 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
95460 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
95461 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
95462 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
95463 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
95464 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
95465 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
95466 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
95467 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
95468 +sky2_receive_13407 sky2_receive 2 13407 NULL
95469 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
95470 +keyring_read_13438 keyring_read 3 13438 NULL
95471 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
95472 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
95473 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
95474 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
95475 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
95476 +core_status_13515 core_status 4 13515 NULL
95477 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
95478 +bm_init_13529 bm_init 2 13529 NULL
95479 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
95480 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
95481 +alloc_tio_13564 alloc_tio 3 13564 NULL
95482 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
95483 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
95484 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
95485 +cache_write_13589 cache_write 3 13589 NULL
95486 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
95487 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
95488 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
95489 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
95490 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
95491 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
95492 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
95493 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
95494 +packet_snd_13634 packet_snd 3 13634 NULL
95495 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
95496 +cache_downcall_13666 cache_downcall 3 13666 NULL
95497 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
95498 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
95499 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
95500 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
95501 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
95502 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
95503 +random_read_13815 random_read 3 13815 NULL
95504 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
95505 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
95506 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
95507 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
95508 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
95509 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
95510 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
95511 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
95512 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
95513 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
95514 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
95515 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
95516 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
95517 +com90xx_found_13974 com90xx_found 3 13974 NULL
95518 +qcam_read_13977 qcam_read 3 13977 NULL
95519 +dsp_read_13980 dsp_read 2 13980 NULL
95520 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
95521 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
95522 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
95523 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
95524 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
95525 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
95526 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
95527 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
95528 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
95529 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
95530 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
95531 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
95532 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
95533 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
95534 +em_canid_change_14150 em_canid_change 3 14150 NULL
95535 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
95536 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
95537 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
95538 +alloc_async_14208 alloc_async 1 14208 NULL
95539 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
95540 +pool_status_14230 pool_status 5 14230 NULL
95541 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
95542 +inode_to_path_14235 inode_to_path 2 14235 NULL
95543 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
95544 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
95545 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
95546 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
95547 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
95548 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
95549 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
95550 +rr_status_14293 rr_status 5 14293 NULL
95551 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
95552 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
95553 +oo_objects_14319 oo_objects 0 14319 NULL
95554 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
95555 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
95556 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
95557 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
95558 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
95559 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
95560 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
95561 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
95562 +block_size_14443 block_size 0 14443 NULL
95563 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
95564 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
95565 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
95566 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
95567 +stripe_status_14506 stripe_status 5 14506 NULL
95568 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
95569 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
95570 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
95571 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
95572 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
95573 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
95574 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
95575 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
95576 +dbJoin_14644 dbJoin 0 14644 NULL
95577 +profile_replace_14652 profile_replace 3 14652 NULL
95578 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
95579 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
95580 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
95581 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
95582 +vfd_write_14717 vfd_write 3 14717 NULL
95583 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
95584 +raid1_resize_14740 raid1_resize 2 14740 NULL
95585 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
95586 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
95587 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
95588 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
95589 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
95590 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
95591 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
95592 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
95593 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
95594 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
95595 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
95596 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
95597 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
95598 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
95599 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
95600 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
95601 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
95602 +unifi_read_14899 unifi_read 3 14899 NULL
95603 +krealloc_14908 krealloc 2 14908 NULL
95604 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
95605 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
95606 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
95607 +queue_cnt_14951 queue_cnt 0 14951 NULL
95608 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
95609 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
95610 +setkey_14987 setkey 3 14987 NULL nohasharray
95611 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
95612 +vmap_15025 vmap 2 15025 NULL
95613 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
95614 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
95615 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
95616 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
95617 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
95618 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
95619 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
95620 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
95621 +start_port_15124 start_port 0 15124 NULL
95622 +memchr_15126 memchr 0 15126 NULL
95623 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
95624 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
95625 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
95626 +reserve_resources_15194 reserve_resources 3 15194 NULL
95627 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
95628 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
95629 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
95630 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
95631 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
95632 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
95633 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
95634 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
95635 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
95636 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
95637 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
95638 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
95639 +ioread16_15342 ioread16 0 15342 NULL
95640 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
95641 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
95642 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
95643 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
95644 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
95645 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
95646 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
95647 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
95648 +get_modalias_15406 get_modalias 2 15406 NULL
95649 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
95650 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
95651 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
95652 +memweight_15450 memweight 2 15450 NULL
95653 +vmalloc_15464 vmalloc 1 15464 NULL
95654 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
95655 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
95656 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
95657 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
95658 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
95659 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
95660 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
95661 +persistent_status_15574 persistent_status 4 15574 NULL
95662 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
95663 +vme_user_write_15587 vme_user_write 3 15587 NULL
95664 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
95665 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
95666 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
95667 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
95668 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
95669 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
95670 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
95671 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
95672 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
95673 +fs_path_add_15648 fs_path_add 3 15648 NULL
95674 +xsd_read_15653 xsd_read 3 15653 NULL
95675 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
95676 +unix_bind_15668 unix_bind 3 15668 NULL
95677 +dm_read_15674 dm_read 3 15674 NULL
95678 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
95679 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
95680 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
95681 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
95682 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
95683 +do_test_15766 do_test 1 15766 NULL
95684 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
95685 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
95686 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
95687 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
95688 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
95689 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
95690 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
95691 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
95692 +table_size_15851 table_size 0-1-2 15851 NULL
95693 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
95694 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
95695 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
95696 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
95697 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
95698 +native_read_msr_15905 native_read_msr 0 15905 NULL
95699 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
95700 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
95701 +power_read_15939 power_read 3 15939 NULL
95702 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
95703 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
95704 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
95705 +set_spte_15977 set_spte 7-6 15977 NULL
95706 +frame_alloc_15981 frame_alloc 4 15981 NULL
95707 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
95708 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
95709 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
95710 +got_frame_16028 got_frame 2 16028 NULL
95711 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
95712 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
95713 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
95714 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
95715 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
95716 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
95717 +fsm_init_16134 fsm_init 2 16134 NULL
95718 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
95719 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
95720 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
95721 +mapping_level_16188 mapping_level 2 16188 NULL
95722 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
95723 +create_table_16213 create_table 2 16213 NULL
95724 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
95725 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
95726 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
95727 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
95728 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
95729 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
95730 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
95731 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
95732 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
95733 +account_16283 account 0-2-4 16283 NULL nohasharray
95734 +mirror_status_16283 mirror_status 5 16283 &account_16283
95735 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
95736 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
95737 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
95738 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
95739 +tps80031_update_16360 tps80031_update 3 16360 NULL
95740 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
95741 +rbd_add_16366 rbd_add 3 16366 NULL
95742 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
95743 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
95744 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
95745 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
95746 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
95747 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
95748 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
95749 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
95750 +raid10_resize_16537 raid10_resize 2 16537 NULL
95751 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
95752 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
95753 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
95754 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
95755 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
95756 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
95757 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
95758 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
95759 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
95760 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
95761 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
95762 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
95763 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
95764 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
95765 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
95766 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
95767 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
95768 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
95769 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
95770 +st_write_16874 st_write 3 16874 NULL
95771 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
95772 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
95773 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
95774 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
95775 +random32_16937 random32 0 16937 NULL
95776 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
95777 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
95778 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
95779 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
95780 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
95781 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
95782 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
95783 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
95784 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
95785 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
95786 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
95787 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
95788 +mac_address_string_17091 mac_address_string 0 17091 NULL
95789 +entry_length_17093 entry_length 0 17093 NULL
95790 +sys_preadv_17100 sys_preadv 3 17100 NULL
95791 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
95792 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
95793 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
95794 +sep_read_17161 sep_read 3 17161 NULL
95795 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
95796 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
95797 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
95798 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
95799 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
95800 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
95801 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
95802 +ms_rw_17220 ms_rw 3-4 17220 NULL
95803 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
95804 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
95805 +alloc_ep_17269 alloc_ep 1 17269 NULL
95806 +pg_read_17276 pg_read 3 17276 NULL
95807 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
95808 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
95809 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
95810 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
95811 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
95812 +skb_pad_17302 skb_pad 2 17302 NULL
95813 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
95814 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
95815 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
95816 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
95817 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
95818 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
95819 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
95820 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
95821 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
95822 +compat_cmd_17465 compat_cmd 2 17465 NULL
95823 +probe_bios_17467 probe_bios 1 17467 NULL
95824 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
95825 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
95826 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
95827 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
95828 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
95829 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
95830 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
95831 +copy_from_user_17559 copy_from_user 3 17559 NULL
95832 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
95833 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
95834 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
95835 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
95836 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
95837 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
95838 +osst_execute_17607 osst_execute 7-6 17607 NULL
95839 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
95840 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
95841 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
95842 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
95843 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
95844 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
95845 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
95846 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
95847 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
95848 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
95849 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
95850 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
95851 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
95852 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
95853 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
95854 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
95855 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
95856 +count_leafs_17842 count_leafs 0 17842 NULL
95857 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
95858 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
95859 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
95860 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
95861 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
95862 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
95863 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
95864 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
95865 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
95866 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
95867 +recover_head_17904 recover_head 3 17904 NULL
95868 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
95869 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
95870 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
95871 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
95872 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
95873 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
95874 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
95875 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
95876 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
95877 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
95878 +prandom32_18007 prandom32 0 18007 NULL
95879 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
95880 +fill_read_18019 fill_read 0 18019 NULL
95881 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
95882 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
95883 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
95884 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
95885 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
95886 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
95887 +packet_came_18072 packet_came 3 18072 NULL
95888 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
95889 +get_vm_area_18080 get_vm_area 1 18080 NULL
95890 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
95891 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
95892 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
95893 +svc_getnl_18120 svc_getnl 0 18120 NULL
95894 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
95895 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
95896 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
95897 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
95898 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
95899 +_has_tag_18169 _has_tag 2 18169 NULL
95900 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
95901 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
95902 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
95903 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
95904 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
95905 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
95906 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
95907 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
95908 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
95909 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
95910 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
95911 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
95912 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
95913 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
95914 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
95915 +um_idi_write_18293 um_idi_write 3 18293 NULL
95916 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
95917 +vga_r_18310 vga_r 0 18310 NULL
95918 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
95919 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
95920 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
95921 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
95922 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
95923 +ep_io_18367 ep_io 0 18367 NULL
95924 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
95925 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
95926 +__video_register_device_18399 __video_register_device 3 18399 NULL
95927 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
95928 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
95929 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
95930 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
95931 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
95932 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
95933 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
95934 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
95935 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
95936 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
95937 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
95938 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
95939 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
95940 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
95941 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
95942 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
95943 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
95944 +debug_output_18575 debug_output 3 18575 NULL
95945 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
95946 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
95947 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
95948 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
95949 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
95950 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
95951 +from_buffer_18625 from_buffer 3 18625 NULL
95952 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
95953 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
95954 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
95955 +unmap_page_18665 unmap_page 2-3 18665 NULL
95956 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
95957 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
95958 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
95959 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
95960 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
95961 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
95962 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
95963 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
95964 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
95965 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
95966 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
95967 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
95968 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
95969 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
95970 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
95971 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
95972 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
95973 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
95974 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
95975 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
95976 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
95977 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
95978 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
95979 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
95980 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
95981 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
95982 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
95983 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
95984 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
95985 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
95986 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
95987 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
95988 +huge_page_size_19008 huge_page_size 0 19008 NULL
95989 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
95990 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
95991 +revalidate_19043 revalidate 2 19043 NULL
95992 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
95993 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
95994 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
95995 +copy_and_check_19089 copy_and_check 3 19089 NULL
95996 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
95997 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
95998 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
95999 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
96000 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
96001 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
96002 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
96003 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
96004 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
96005 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
96006 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
96007 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
96008 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
96009 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
96010 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
96011 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
96012 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
96013 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
96014 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
96015 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
96016 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
96017 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
96018 +qc_capture_19298 qc_capture 3 19298 NULL
96019 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
96020 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
96021 +debug_read_19322 debug_read 3 19322 NULL
96022 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
96023 +read_zero_19366 read_zero 3 19366 NULL
96024 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
96025 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
96026 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
96027 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
96028 +__phys_addr_19434 __phys_addr 0 19434 NULL
96029 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
96030 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
96031 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
96032 +sky2_read16_19475 sky2_read16 0 19475 NULL
96033 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
96034 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
96035 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
96036 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
96037 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
96038 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
96039 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
96040 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
96041 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
96042 +nfsd_read_19568 nfsd_read 5 19568 NULL
96043 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
96044 +bm_status_read_19583 bm_status_read 3 19583 NULL
96045 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
96046 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
96047 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
96048 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
96049 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
96050 +read_reg_19723 read_reg 0 19723 NULL
96051 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
96052 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
96053 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
96054 +p9_client_read_19750 p9_client_read 5 19750 NULL
96055 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
96056 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
96057 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
96058 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
96059 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
96060 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
96061 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
96062 +vip_read_19832 vip_read 3 19832 NULL nohasharray
96063 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
96064 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
96065 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
96066 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
96067 +__nla_put_19857 __nla_put 3 19857 NULL
96068 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
96069 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
96070 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
96071 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
96072 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
96073 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
96074 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
96075 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
96076 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
96077 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
96078 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
96079 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
96080 +team_options_register_20091 team_options_register 3 20091 NULL
96081 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
96082 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
96083 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
96084 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
96085 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
96086 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
96087 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
96088 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
96089 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
96090 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
96091 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
96092 +resource_size_20256 resource_size 0 20256 NULL
96093 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
96094 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
96095 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
96096 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
96097 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
96098 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
96099 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
96100 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
96101 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
96102 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
96103 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
96104 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
96105 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
96106 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
96107 +read_buf_20469 read_buf 2 20469 NULL
96108 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
96109 +fast_user_write_20494 fast_user_write 5 20494 NULL
96110 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
96111 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
96112 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
96113 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
96114 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
96115 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
96116 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
96117 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
96118 +venus_create_20555 venus_create 4 20555 NULL
96119 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
96120 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
96121 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
96122 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
96123 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
96124 +lirc_write_20604 lirc_write 3 20604 NULL
96125 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
96126 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
96127 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
96128 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
96129 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
96130 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
96131 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
96132 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
96133 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
96134 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
96135 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
96136 +cpumask_size_20683 cpumask_size 0 20683 NULL
96137 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
96138 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
96139 +__maestro_read_20700 __maestro_read 0 20700 NULL
96140 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
96141 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
96142 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
96143 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
96144 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
96145 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
96146 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
96147 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
96148 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
96149 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
96150 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
96151 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
96152 +sys_sendto_20809 sys_sendto 6 20809 NULL
96153 +strndup_user_20819 strndup_user 2 20819 NULL
96154 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
96155 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
96156 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
96157 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
96158 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
96159 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
96160 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
96161 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
96162 +htable_bits_20933 htable_bits 0 20933 NULL
96163 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
96164 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
96165 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
96166 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
96167 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
96168 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
96169 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
96170 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
96171 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
96172 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
96173 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
96174 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
96175 +multipath_status_21094 multipath_status 5 21094 NULL
96176 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
96177 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
96178 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
96179 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
96180 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
96181 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
96182 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
96183 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
96184 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
96185 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
96186 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
96187 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
96188 +input_ff_create_21240 input_ff_create 2 21240 NULL
96189 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
96190 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
96191 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
96192 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
96193 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
96194 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
96195 +add_res_range_21310 add_res_range 4 21310 NULL
96196 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
96197 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
96198 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
96199 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
96200 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
96201 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
96202 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
96203 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
96204 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
96205 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
96206 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
96207 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
96208 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
96209 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
96210 +concat_writev_21451 concat_writev 3 21451 NULL
96211 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
96212 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
96213 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
96214 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
96215 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
96216 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
96217 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
96218 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
96219 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
96220 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
96221 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
96222 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
96223 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
96224 +validate_nnode_21638 validate_nnode 0 21638 NULL
96225 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
96226 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
96227 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
96228 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
96229 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
96230 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
96231 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
96232 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
96233 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
96234 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
96235 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
96236 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
96237 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
96238 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
96239 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
96240 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
96241 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
96242 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
96243 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
96244 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
96245 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
96246 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
96247 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
96248 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
96249 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
96250 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
96251 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
96252 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
96253 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
96254 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
96255 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
96256 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
96257 +ti_recv_22027 ti_recv 4 22027 NULL
96258 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
96259 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
96260 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
96261 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
96262 +mem_rw_22085 mem_rw 3 22085 NULL
96263 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
96264 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
96265 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
96266 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
96267 +compat_insn_22142 compat_insn 2 22142 NULL
96268 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
96269 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
96270 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
96271 +fls_22210 fls 0 22210 NULL
96272 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
96273 +mem_write_22232 mem_write 3 22232 NULL
96274 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
96275 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
96276 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
96277 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
96278 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
96279 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
96280 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
96281 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
96282 +get_segment_base_22324 get_segment_base 0 22324 NULL
96283 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
96284 +atomic_read_22342 atomic_read 0 22342 NULL
96285 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
96286 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
96287 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
96288 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
96289 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
96290 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
96291 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
96292 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
96293 +zoran_write_22404 zoran_write 3 22404 NULL
96294 +queue_reply_22416 queue_reply 3 22416 NULL
96295 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
96296 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
96297 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
96298 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
96299 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
96300 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
96301 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
96302 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
96303 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
96304 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
96305 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
96306 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
96307 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
96308 +snapshot_read_22601 snapshot_read 3 22601 NULL
96309 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
96310 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
96311 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
96312 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
96313 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
96314 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
96315 +fill_gap_22681 fill_gap 0 22681 NULL
96316 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
96317 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
96318 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
96319 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
96320 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
96321 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
96322 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
96323 +print_frame_22769 print_frame 0 22769 NULL
96324 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
96325 +retu_write_22800 retu_write 2 22800 NULL
96326 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
96327 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
96328 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
96329 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
96330 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
96331 +create_attr_set_22861 create_attr_set 1 22861 NULL
96332 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
96333 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
96334 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
96335 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
96336 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
96337 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
96338 +vme_get_size_22964 vme_get_size 0 22964 NULL
96339 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
96340 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
96341 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
96342 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
96343 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
96344 +st_status_23032 st_status 5 23032 NULL
96345 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
96346 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
96347 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
96348 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
96349 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
96350 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
96351 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
96352 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
96353 +fls_long_23096 fls_long 0 23096 NULL
96354 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
96355 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
96356 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
96357 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
96358 +__clear_user_23118 __clear_user 0 23118 NULL
96359 +dm_write_async_23120 dm_write_async 3 23120 NULL
96360 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
96361 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
96362 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
96363 +read_file_ani_23161 read_file_ani 3 23161 NULL
96364 +ioremap_23172 ioremap 1-2 23172 NULL
96365 +usblp_write_23178 usblp_write 3 23178 NULL
96366 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
96367 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
96368 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
96369 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
96370 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
96371 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
96372 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
96373 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
96374 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
96375 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
96376 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
96377 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
96378 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
96379 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
96380 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
96381 +doc_probe_23285 doc_probe 1 23285 NULL
96382 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
96383 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
96384 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
96385 +page_readlink_23346 page_readlink 3 23346 NULL
96386 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
96387 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
96388 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
96389 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
96390 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
96391 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
96392 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
96393 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
96394 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
96395 +event_filter_read_23494 event_filter_read 3 23494 NULL
96396 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
96397 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
96398 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
96399 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
96400 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
96401 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
96402 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
96403 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
96404 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
96405 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
96406 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
96407 +sInW_23663 sInW 0 23663 NULL
96408 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
96409 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
96410 +cx18_read_23699 cx18_read 3 23699 NULL
96411 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
96412 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
96413 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
96414 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
96415 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
96416 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
96417 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
96418 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
96419 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
96420 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
96421 +p54_init_common_23850 p54_init_common 1 23850 NULL
96422 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
96423 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
96424 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
96425 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
96426 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
96427 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
96428 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
96429 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
96430 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
96431 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
96432 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
96433 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
96434 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
96435 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
96436 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
96437 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
96438 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
96439 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
96440 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
96441 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
96442 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
96443 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
96444 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
96445 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
96446 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
96447 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
96448 +mpu401_read_24126 mpu401_read 3 24126 NULL
96449 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
96450 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
96451 +adu_read_24177 adu_read 3 24177 NULL
96452 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
96453 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
96454 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
96455 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
96456 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
96457 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
96458 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
96459 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
96460 +thin_status_24278 thin_status 5 24278 NULL
96461 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
96462 +msg_size_24288 msg_size 0 24288 NULL
96463 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
96464 +map_page_24298 map_page 3-4 24298 NULL
96465 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
96466 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
96467 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
96468 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
96469 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
96470 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
96471 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
96472 +igetword_24373 igetword 0 24373 NULL
96473 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
96474 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
96475 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
96476 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
96477 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
96478 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
96479 +smk_user_access_24440 smk_user_access 3 24440 NULL
96480 +page_address_24444 page_address 0 24444 NULL
96481 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
96482 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
96483 +pd_video_read_24510 pd_video_read 3 24510 NULL
96484 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
96485 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
96486 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
96487 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
96488 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
96489 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
96490 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
96491 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
96492 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
96493 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
96494 +context_alloc_24645 context_alloc 3 24645 NULL
96495 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
96496 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
96497 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
96498 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
96499 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
96500 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
96501 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
96502 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
96503 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
96504 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
96505 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
96506 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
96507 +cache_read_24790 cache_read 3 24790 NULL
96508 +unpack_str_24798 unpack_str 0 24798 NULL
96509 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
96510 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
96511 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
96512 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
96513 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
96514 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
96515 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
96516 +queues_read_24877 queues_read 3 24877 NULL
96517 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
96518 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
96519 +next_token_24929 next_token 0 24929 NULL
96520 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
96521 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
96522 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
96523 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
96524 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
96525 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
96526 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
96527 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
96528 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
96529 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
96530 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
96531 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
96532 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
96533 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
96534 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
96535 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
96536 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
96537 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
96538 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
96539 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
96540 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
96541 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
96542 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
96543 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
96544 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
96545 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
96546 +stripe_status_25259 stripe_status 5 25259 NULL
96547 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
96548 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
96549 +vfs_writev_25278 vfs_writev 3 25278 NULL
96550 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
96551 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
96552 +help_25316 help 5 25316 NULL nohasharray
96553 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
96554 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
96555 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
96556 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
96557 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
96558 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
96559 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
96560 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
96561 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
96562 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
96563 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
96564 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
96565 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
96566 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
96567 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
96568 +sb_permission_25523 sb_permission 0 25523 NULL
96569 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
96570 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
96571 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
96572 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
96573 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
96574 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
96575 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
96576 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
96577 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
96578 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
96579 +__direct_map_25647 __direct_map 5-6 25647 NULL
96580 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
96581 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
96582 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
96583 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
96584 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
96585 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
96586 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
96587 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
96588 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
96589 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
96590 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
96591 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
96592 +sg_read_25799 sg_read 3 25799 NULL
96593 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
96594 +system_enable_read_25815 system_enable_read 3 25815 NULL
96595 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
96596 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
96597 +parport_read_25855 parport_read 0 25855 NULL
96598 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
96599 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
96600 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
96601 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
96602 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
96603 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
96604 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
96605 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
96606 +rcname_read_25919 rcname_read 3 25919 NULL
96607 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
96608 +key_flags_read_25931 key_flags_read 3 25931 NULL
96609 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
96610 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
96611 +flush_25957 flush 2 25957 NULL
96612 +video_register_device_25971 video_register_device 3 25971 NULL
96613 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
96614 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
96615 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
96616 +mirror_status_26010 mirror_status 5 26010 NULL
96617 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
96618 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
96619 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
96620 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
96621 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
96622 +tun_do_read_26047 tun_do_read 5 26047 NULL
96623 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
96624 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
96625 +cpumask_next_26096 cpumask_next 1 26096 NULL
96626 +skb_cow_26138 skb_cow 2 26138 NULL
96627 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
96628 +__fswab64_26155 __fswab64 0 26155 NULL
96629 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
96630 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
96631 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
96632 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
96633 +disk_devt_26180 disk_devt 0 26180 NULL
96634 +get_registers_26187 get_registers 3 26187 NULL
96635 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
96636 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
96637 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
96638 +mce_write_26201 mce_write 3 26201 NULL
96639 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
96640 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
96641 +bio_split_26235 bio_split 2 26235 NULL
96642 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
96643 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
96644 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
96645 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
96646 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
96647 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
96648 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
96649 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
96650 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
96651 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
96652 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
96653 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
96654 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
96655 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
96656 +read_vmcore_26501 read_vmcore 3 26501 NULL
96657 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
96658 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
96659 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
96660 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
96661 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
96662 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
96663 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
96664 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
96665 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
96666 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
96667 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
96668 +mmap_region_26649 mmap_region 0-2 26649 NULL
96669 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
96670 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
96671 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
96672 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
96673 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
96674 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
96675 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
96676 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
96677 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
96678 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
96679 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
96680 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
96681 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
96682 +smk_write_load_26829 smk_write_load 3 26829 NULL
96683 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
96684 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
96685 +scnprint_id_26842 scnprint_id 3 26842 NULL
96686 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
96687 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
96688 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
96689 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
96690 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
96691 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
96692 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
96693 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
96694 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
96695 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
96696 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
96697 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
96698 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
96699 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
96700 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
96701 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
96702 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
96703 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
96704 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
96705 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
96706 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
96707 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
96708 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
96709 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
96710 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
96711 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
96712 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
96713 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
96714 +pms_capture_27142 pms_capture 4 27142 NULL
96715 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
96716 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
96717 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
96718 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
96719 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
96720 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
96721 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
96722 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
96723 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
96724 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
96725 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
96726 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
96727 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
96728 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
96729 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
96730 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
96731 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
96732 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
96733 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
96734 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
96735 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
96736 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
96737 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
96738 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
96739 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
96740 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
96741 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
96742 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
96743 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
96744 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
96745 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
96746 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
96747 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
96748 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
96749 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
96750 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
96751 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
96752 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
96753 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
96754 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
96755 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
96756 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
96757 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
96758 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
96759 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
96760 +qword_get_27670 qword_get 0 27670 NULL
96761 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
96762 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
96763 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
96764 +evm_write_key_27715 evm_write_key 3 27715 NULL
96765 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
96766 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
96767 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
96768 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
96769 +kcalloc_27770 kcalloc 1-2 27770 NULL
96770 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
96771 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
96772 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
96773 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
96774 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
96775 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
96776 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
96777 +read_profile_27859 read_profile 3 27859 NULL
96778 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
96779 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
96780 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
96781 +gluebi_write_27905 gluebi_write 3 27905 NULL
96782 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
96783 +bm_find_next_27929 bm_find_next 2 27929 NULL
96784 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
96785 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
96786 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
96787 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
96788 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
96789 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
96790 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
96791 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
96792 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
96793 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
96794 +pool_status_28055 pool_status 5 28055 NULL
96795 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
96796 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
96797 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
96798 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
96799 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
96800 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
96801 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
96802 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
96803 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
96804 +video_read_28148 video_read 3 28148 NULL
96805 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
96806 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
96807 +vread_28173 vread 0 28173 NULL
96808 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
96809 +d_path_28198 d_path 0 28198 NULL
96810 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
96811 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
96812 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
96813 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
96814 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
96815 +usemap_size_28281 usemap_size 0 28281 NULL
96816 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
96817 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
96818 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
96819 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
96820 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
96821 +snapshot_write_28351 snapshot_write 3 28351 NULL
96822 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
96823 +sys_writev_28384 sys_writev 3 28384 NULL
96824 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
96825 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
96826 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
96827 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
96828 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
96829 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
96830 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
96831 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
96832 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
96833 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
96834 +max_response_pages_28492 max_response_pages 0 28492 NULL
96835 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
96836 +__next_node_28521 __next_node 1 28521 NULL
96837 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
96838 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
96839 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
96840 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
96841 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
96842 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
96843 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
96844 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
96845 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
96846 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
96847 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
96848 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
96849 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
96850 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
96851 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
96852 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
96853 +_set_range_28627 _set_range 3 28627 NULL
96854 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
96855 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
96856 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
96857 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
96858 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
96859 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
96860 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
96861 +spi_execute_28736 spi_execute 5 28736 NULL
96862 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
96863 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
96864 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
96865 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
96866 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
96867 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
96868 +sel_write_member_28800 sel_write_member 3 28800 NULL
96869 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
96870 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
96871 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
96872 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
96873 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
96874 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
96875 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
96876 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
96877 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
96878 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
96879 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
96880 +push_rx_28939 push_rx 3 28939 NULL
96881 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
96882 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
96883 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
96884 +bin_uuid_28999 bin_uuid 3 28999 NULL
96885 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
96886 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
96887 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
96888 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
96889 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
96890 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
96891 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
96892 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
96893 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
96894 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
96895 +snprintf_29125 snprintf 0 29125 NULL
96896 +iov_shorten_29130 iov_shorten 0 29130 NULL
96897 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
96898 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
96899 +reshape_ring_29147 reshape_ring 2 29147 NULL
96900 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
96901 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
96902 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
96903 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
96904 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
96905 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
96906 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
96907 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
96908 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
96909 +recover_peb_29238 recover_peb 6-7 29238 NULL
96910 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
96911 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
96912 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
96913 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
96914 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
96915 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
96916 +tun_put_user_29337 tun_put_user 5 29337 NULL
96917 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
96918 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
96919 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
96920 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
96921 +mempool_create_29437 mempool_create 1 29437 NULL
96922 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
96923 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
96924 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
96925 +do_register_entry_29478 do_register_entry 4 29478 NULL
96926 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
96927 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
96928 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
96929 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
96930 +ftrace_write_29551 ftrace_write 3 29551 NULL
96931 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
96932 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
96933 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
96934 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
96935 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
96936 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
96937 +slots_per_page_29601 slots_per_page 0 29601 NULL
96938 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
96939 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
96940 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
96941 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
96942 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
96943 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
96944 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
96945 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
96946 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
96947 +probes_write_29711 probes_write 3 29711 NULL
96948 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
96949 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
96950 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
96951 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
96952 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
96953 +dbAlloc_29794 dbAlloc 0 29794 NULL
96954 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
96955 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
96956 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
96957 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
96958 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
96959 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
96960 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
96961 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
96962 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
96963 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
96964 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
96965 +check586_29914 check586 2 29914 NULL
96966 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
96967 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
96968 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
96969 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
96970 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
96971 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
96972 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
96973 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
96974 +drp_wmove_30043 drp_wmove 4 30043 NULL
96975 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
96976 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
96977 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
96978 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
96979 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
96980 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
96981 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
96982 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
96983 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
96984 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
96985 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
96986 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
96987 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
96988 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
96989 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
96990 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
96991 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
96992 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
96993 +compat_readv_30273 compat_readv 3 30273 NULL
96994 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
96995 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
96996 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
96997 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
96998 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
96999 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
97000 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
97001 +resource_from_user_30341 resource_from_user 3 30341 NULL
97002 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
97003 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
97004 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
97005 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
97006 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
97007 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
97008 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
97009 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
97010 +enable_write_30456 enable_write 3 30456 NULL
97011 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
97012 +urandom_read_30462 urandom_read 3 30462 NULL
97013 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
97014 +write_head_30481 write_head 4 30481 NULL
97015 +adu_write_30487 adu_write 3 30487 NULL
97016 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
97017 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
97018 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
97019 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
97020 +set_le_30581 set_le 4 30581 NULL
97021 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
97022 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
97023 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
97024 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
97025 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
97026 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
97027 +agp_remap_30665 agp_remap 2 30665 NULL
97028 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
97029 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
97030 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
97031 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
97032 +snapshot_status_30744 snapshot_status 5 30744 NULL
97033 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
97034 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
97035 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
97036 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
97037 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
97038 +create_subvol_30836 create_subvol 4 30836 NULL
97039 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
97040 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
97041 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
97042 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
97043 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
97044 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
97045 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
97046 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
97047 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
97048 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
97049 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
97050 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
97051 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
97052 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
97053 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
97054 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
97055 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
97056 +sys_mincore_31079 sys_mincore 1 31079 NULL
97057 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
97058 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
97059 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
97060 +depth_read_31112 depth_read 3 31112 NULL
97061 +ssb_read16_31139 ssb_read16 0 31139 NULL
97062 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
97063 +size_inside_page_31141 size_inside_page 0 31141 NULL
97064 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
97065 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
97066 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
97067 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
97068 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
97069 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
97070 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
97071 +__read_reg_31216 __read_reg 0 31216 NULL
97072 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
97073 +cyy_readb_31240 cyy_readb 0 31240 NULL
97074 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
97075 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
97076 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
97077 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
97078 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
97079 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
97080 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
97081 +command_file_write_31318 command_file_write 3 31318 NULL
97082 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
97083 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
97084 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
97085 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
97086 +inb_31388 inb 0 31388 NULL
97087 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
97088 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
97089 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
97090 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
97091 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
97092 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
97093 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
97094 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
97095 +do_fcntl_31468 do_fcntl 3 31468 NULL
97096 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
97097 +alg_setkey_31485 alg_setkey 3 31485 NULL
97098 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
97099 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
97100 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
97101 +hidraw_write_31536 hidraw_write 3 31536 NULL
97102 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
97103 +usbvision_read_31555 usbvision_read 3 31555 NULL
97104 +normalize_31566 normalize 0-1-2 31566 NULL
97105 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
97106 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
97107 +osst_write_31581 osst_write 3 31581 NULL
97108 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
97109 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
97110 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
97111 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
97112 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
97113 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
97114 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
97115 +__lgread_31668 __lgread 4 31668 NULL
97116 +symbol_string_31670 symbol_string 0 31670 NULL
97117 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
97118 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
97119 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
97120 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
97121 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
97122 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
97123 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
97124 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
97125 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
97126 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
97127 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
97128 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
97129 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
97130 +get_count_order_31800 get_count_order 0 31800 NULL
97131 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
97132 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
97133 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
97134 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
97135 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
97136 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
97137 +xattr_permission_31907 xattr_permission 0 31907 NULL
97138 +new_dir_31919 new_dir 3 31919 NULL
97139 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
97140 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
97141 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
97142 +vb2_write_31948 vb2_write 3 31948 NULL
97143 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
97144 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
97145 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
97146 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
97147 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
97148 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
97149 +calc_hmac_32010 calc_hmac 3 32010 NULL
97150 +aead_len_32021 aead_len 0 32021 NULL
97151 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
97152 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
97153 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
97154 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
97155 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
97156 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
97157 +bio_alloc_32095 bio_alloc 2 32095 NULL
97158 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
97159 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
97160 +disk_status_32120 disk_status 4 32120 NULL
97161 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
97162 +venus_link_32165 venus_link 5 32165 NULL
97163 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
97164 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
97165 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
97166 +load_header_32183 load_header 0 32183 NULL
97167 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
97168 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
97169 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
97170 +lm3533_write_32236 lm3533_write 2 32236 NULL
97171 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
97172 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
97173 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
97174 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
97175 +hex_string_32310 hex_string 0 32310 NULL
97176 +flakey_status_32315 flakey_status 5 32315 NULL
97177 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
97178 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
97179 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
97180 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
97181 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
97182 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
97183 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
97184 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
97185 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
97186 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
97187 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
97188 +log_text_32428 log_text 0 32428 NULL
97189 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
97190 +hid_input_report_32458 hid_input_report 4 32458 NULL
97191 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
97192 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
97193 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
97194 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
97195 +disconnect_32521 disconnect 4 32521 NULL
97196 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
97197 +ilo_read_32531 ilo_read 3 32531 NULL
97198 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
97199 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
97200 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
97201 +__first_node_32558 __first_node 0 32558 NULL
97202 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
97203 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
97204 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
97205 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
97206 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
97207 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
97208 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
97209 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
97210 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
97211 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
97212 +kvmalloc_32646 kvmalloc 1 32646 NULL
97213 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
97214 +generic_readlink_32654 generic_readlink 3 32654 NULL
97215 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
97216 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
97217 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
97218 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
97219 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
97220 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
97221 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
97222 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
97223 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
97224 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
97225 +vga_rseq_32848 vga_rseq 0 32848 NULL
97226 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
97227 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
97228 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
97229 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
97230 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
97231 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
97232 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
97233 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
97234 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
97235 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
97236 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
97237 +compat_filldir_32999 compat_filldir 3 32999 NULL
97238 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
97239 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
97240 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
97241 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
97242 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
97243 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
97244 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
97245 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
97246 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
97247 +write_node_33121 write_node 4 33121 NULL
97248 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
97249 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
97250 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
97251 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
97252 +pp_read_33210 pp_read 3 33210 NULL
97253 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
97254 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
97255 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
97256 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
97257 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
97258 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
97259 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
97260 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
97261 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
97262 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
97263 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
97264 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
97265 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
97266 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
97267 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
97268 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
97269 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
97270 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
97271 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
97272 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
97273 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
97274 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
97275 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
97276 +create_entry_33479 create_entry 2 33479 NULL
97277 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
97278 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
97279 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
97280 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
97281 +res_counter_read_33499 res_counter_read 4 33499 NULL
97282 +fb_read_33506 fb_read 3 33506 NULL
97283 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
97284 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
97285 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
97286 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
97287 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
97288 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
97289 +dup_array_33551 dup_array 3 33551 NULL
97290 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
97291 +count_subheaders_33591 count_subheaders 0 33591 NULL
97292 +scsi_execute_33596 scsi_execute 5 33596 NULL
97293 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
97294 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
97295 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
97296 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
97297 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
97298 +inw_p_33668 inw_p 0 33668 NULL
97299 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
97300 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
97301 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
97302 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
97303 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
97304 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
97305 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
97306 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
97307 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
97308 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
97309 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
97310 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
97311 +Read_hfc_33755 Read_hfc 0 33755 NULL
97312 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
97313 +hashtab_create_33769 hashtab_create 3 33769 NULL
97314 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
97315 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
97316 +find_next_offset_33804 find_next_offset 3 33804 NULL
97317 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
97318 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
97319 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
97320 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
97321 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
97322 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
97323 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
97324 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
97325 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
97326 +config_proc_write_33878 config_proc_write 3 33878 NULL
97327 +get_user_pages_33908 get_user_pages 0 33908 NULL
97328 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
97329 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
97330 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
97331 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
97332 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
97333 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
97334 +ppp_write_34034 ppp_write 3 34034 NULL
97335 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
97336 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
97337 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
97338 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
97339 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
97340 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
97341 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
97342 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
97343 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
97344 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
97345 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
97346 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
97347 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
97348 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
97349 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
97350 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
97351 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
97352 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
97353 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
97354 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
97355 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
97356 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
97357 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
97358 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
97359 +ea_read_34378 ea_read 0 34378 NULL
97360 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
97361 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
97362 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
97363 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
97364 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
97365 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
97366 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
97367 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
97368 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
97369 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
97370 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
97371 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
97372 +alloc_buf_34532 alloc_buf 1 34532 NULL
97373 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
97374 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
97375 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
97376 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
97377 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
97378 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
97379 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
97380 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
97381 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
97382 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
97383 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
97384 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
97385 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
97386 +port_print_34704 port_print 3 34704 NULL
97387 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
97388 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
97389 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
97390 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
97391 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
97392 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
97393 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
97394 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
97395 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
97396 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
97397 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
97398 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
97399 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
97400 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
97401 +msg_print_text_34889 msg_print_text 0 34889 NULL
97402 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
97403 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
97404 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
97405 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
97406 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
97407 +Realloc_34961 Realloc 2 34961 NULL
97408 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
97409 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
97410 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
97411 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
97412 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
97413 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
97414 +store_ifalias_35088 store_ifalias 4 35088 NULL
97415 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
97416 +capi_write_35104 capi_write 3 35104 NULL nohasharray
97417 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
97418 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
97419 +pointer_35138 pointer 0 35138 NULL
97420 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
97421 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
97422 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
97423 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
97424 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
97425 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
97426 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
97427 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
97428 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
97429 +set_fd_set_35249 set_fd_set 1 35249 NULL
97430 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
97431 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
97432 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
97433 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
97434 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
97435 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
97436 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
97437 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
97438 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
97439 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
97440 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
97441 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
97442 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
97443 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
97444 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
97445 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
97446 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
97447 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
97448 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
97449 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
97450 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
97451 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
97452 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
97453 +async_setkey_35521 async_setkey 3 35521 NULL
97454 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
97455 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
97456 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
97457 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
97458 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
97459 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
97460 +ReadZReg_35604 ReadZReg 0 35604 NULL
97461 +kernel_readv_35617 kernel_readv 3 35617 NULL
97462 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
97463 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
97464 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
97465 +store_debug_level_35652 store_debug_level 3 35652 NULL
97466 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
97467 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
97468 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
97469 +dm_table_create_35687 dm_table_create 3 35687 NULL
97470 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
97471 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
97472 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
97473 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
97474 +read_file_stations_35795 read_file_stations 3 35795 NULL
97475 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
97476 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
97477 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
97478 +fls64_35862 fls64 0 35862 NULL
97479 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
97480 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
97481 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
97482 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
97483 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
97484 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
97485 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
97486 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
97487 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
97488 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
97489 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
97490 +acl_alloc_35979 acl_alloc 1 35979 NULL
97491 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
97492 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
97493 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
97494 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
97495 +sys_init_module_36047 sys_init_module 2 36047 NULL
97496 +account_shadowed_36048 account_shadowed 2 36048 NULL
97497 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
97498 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
97499 +write_emulate_36065 write_emulate 2-4 36065 NULL
97500 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
97501 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
97502 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
97503 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
97504 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
97505 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
97506 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
97507 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
97508 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
97509 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
97510 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
97511 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
97512 +twl_set_36154 twl_set 2 36154 NULL
97513 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
97514 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
97515 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
97516 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
97517 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
97518 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
97519 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
97520 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
97521 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
97522 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
97523 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
97524 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
97525 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
97526 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
97527 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
97528 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
97529 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
97530 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
97531 +lc_create_36332 lc_create 4 36332 NULL
97532 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
97533 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
97534 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
97535 +to_sector_36361 to_sector 0-1 36361 NULL
97536 +tunables_read_36385 tunables_read 3 36385 NULL
97537 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
97538 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
97539 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
97540 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
97541 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
97542 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
97543 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
97544 +get_param_l_36518 get_param_l 0 36518 NULL
97545 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
97546 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
97547 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
97548 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
97549 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
97550 +get_entry_len_36549 get_entry_len 0 36549 NULL
97551 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
97552 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
97553 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
97554 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
97555 +__erst_read_36579 __erst_read 0 36579 NULL
97556 +put_cmsg_36589 put_cmsg 4 36589 NULL
97557 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
97558 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
97559 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
97560 +format_decode_36638 format_decode 0 36638 NULL
97561 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
97562 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
97563 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
97564 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
97565 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
97566 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
97567 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
97568 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
97569 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
97570 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
97571 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
97572 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
97573 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
97574 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
97575 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
97576 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
97577 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
97578 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
97579 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
97580 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
97581 +cm_write_36858 cm_write 3 36858 NULL
97582 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
97583 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
97584 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
97585 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
97586 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
97587 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
97588 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
97589 +div_u64_36951 div_u64 0 36951 NULL
97590 +write_leb_36957 write_leb 5 36957 NULL
97591 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
97592 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
97593 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
97594 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
97595 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
97596 +setxattr_37006 setxattr 4 37006 NULL
97597 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
97598 +parse_command_37079 parse_command 2 37079 NULL
97599 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
97600 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
97601 +tun_get_user_37094 tun_get_user 5 37094 NULL
97602 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
97603 +msg_word_37164 msg_word 0 37164 NULL
97604 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
97605 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
97606 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
97607 +__do_replace_37227 __do_replace 5 37227 NULL
97608 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
97609 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
97610 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
97611 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
97612 +c101_run_37279 c101_run 2 37279 NULL
97613 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
97614 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
97615 +send_msg_37323 send_msg 4 37323 NULL
97616 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
97617 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
97618 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
97619 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
97620 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
97621 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
97622 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
97623 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
97624 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
97625 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
97626 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
97627 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
97628 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
97629 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
97630 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
97631 +get_est_timing_37484 get_est_timing 0 37484 NULL
97632 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
97633 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
97634 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
97635 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
97636 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
97637 +hdr_size_37536 hdr_size 0 37536 NULL
97638 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
97639 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
97640 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
97641 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
97642 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
97643 +alloc_fd_37637 alloc_fd 1 37637 NULL
97644 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
97645 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
97646 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
97647 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
97648 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
97649 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
97650 +nametbl_header_37698 nametbl_header 2 37698 NULL
97651 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
97652 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
97653 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
97654 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
97655 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
97656 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
97657 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
97658 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
97659 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
97660 +deny_write_access_37813 deny_write_access 0 37813 NULL
97661 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
97662 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
97663 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
97664 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
97665 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
97666 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
97667 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
97668 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
97669 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
97670 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
97671 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
97672 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
97673 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
97674 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
97675 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
97676 +vfs_readv_38011 vfs_readv 3 38011 NULL
97677 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
97678 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
97679 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
97680 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
97681 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
97682 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
97683 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
97684 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
97685 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
97686 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
97687 +ep0_read_38095 ep0_read 3 38095 NULL
97688 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
97689 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
97690 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
97691 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
97692 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
97693 +cdev_add_38176 cdev_add 2-3 38176 NULL
97694 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
97695 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
97696 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
97697 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
97698 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
97699 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
97700 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
97701 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
97702 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
97703 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
97704 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
97705 +verity_status_38273 verity_status 5 38273 NULL
97706 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
97707 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
97708 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
97709 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
97710 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
97711 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
97712 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
97713 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
97714 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
97715 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
97716 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
97717 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
97718 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
97719 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
97720 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
97721 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
97722 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
97723 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
97724 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
97725 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
97726 +dev_names_read_38509 dev_names_read 3 38509 NULL
97727 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
97728 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
97729 +set_queue_count_38519 set_queue_count 0 38519 NULL
97730 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
97731 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
97732 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
97733 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
97734 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
97735 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
97736 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
97737 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
97738 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
97739 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
97740 +delay_status_38606 delay_status 5 38606 NULL
97741 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
97742 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
97743 +cma_create_area_38642 cma_create_area 2 38642 NULL
97744 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
97745 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
97746 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
97747 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
97748 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
97749 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
97750 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
97751 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
97752 +udf_readpages_38761 udf_readpages 4 38761 NULL
97753 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
97754 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
97755 +err_decode_38804 err_decode 2 38804 NULL
97756 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
97757 +sys_select_38827 sys_select 1 38827 NULL
97758 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
97759 +direct_entry_38836 direct_entry 3 38836 NULL
97760 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
97761 +interfaces_38859 interfaces 2 38859 NULL
97762 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
97763 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
97764 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
97765 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
97766 +__fswab16_38898 __fswab16 0 38898 NULL
97767 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
97768 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
97769 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
97770 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
97771 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
97772 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
97773 +udf_new_block_38999 udf_new_block 4 38999 NULL
97774 +get_nodes_39012 get_nodes 3 39012 NULL
97775 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
97776 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
97777 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
97778 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
97779 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
97780 +tun_get_user_39099 tun_get_user 4 39099 NULL
97781 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
97782 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
97783 +ea_foreach_39133 ea_foreach 0 39133 NULL
97784 +generic_permission_39150 generic_permission 0 39150 NULL
97785 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
97786 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
97787 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
97788 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
97789 +init_list_set_39188 init_list_set 2-3 39188 NULL
97790 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
97791 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
97792 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
97793 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
97794 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
97795 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
97796 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
97797 +drm_order_39244 drm_order 0 39244 NULL
97798 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
97799 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
97800 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
97801 +__skb_cow_39254 __skb_cow 2 39254 NULL
97802 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
97803 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
97804 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
97805 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
97806 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
97807 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
97808 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
97809 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
97810 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
97811 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
97812 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
97813 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
97814 +__send_to_port_39386 __send_to_port 3 39386 NULL
97815 +user_power_read_39414 user_power_read 3 39414 NULL
97816 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
97817 +sys_semop_39457 sys_semop 3 39457 NULL
97818 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
97819 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
97820 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
97821 +int_proc_write_39542 int_proc_write 3 39542 NULL
97822 +pp_write_39554 pp_write 3 39554 NULL
97823 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
97824 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
97825 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
97826 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
97827 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
97828 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
97829 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
97830 +ext_depth_39607 ext_depth 0 39607 NULL
97831 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
97832 +sdio_readb_39618 sdio_readb 0 39618 NULL
97833 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
97834 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
97835 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
97836 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
97837 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
97838 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
97839 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
97840 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
97841 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
97842 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
97843 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
97844 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
97845 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
97846 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
97847 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
97848 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
97849 +pkt_add_39897 pkt_add 3 39897 NULL
97850 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
97851 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
97852 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
97853 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
97854 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
97855 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
97856 +__spi_async_39932 __spi_async 0 39932 NULL
97857 +__get_order_39935 __get_order 0 39935 NULL
97858 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
97859 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
97860 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
97861 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
97862 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
97863 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
97864 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
97865 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
97866 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
97867 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
97868 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
97869 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
97870 +add_tty_40055 add_tty 1 40055 NULL nohasharray
97871 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
97872 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
97873 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
97874 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
97875 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
97876 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
97877 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
97878 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
97879 +pt_write_40159 pt_write 3 40159 NULL
97880 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
97881 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
97882 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
97883 +allocate_probes_40204 allocate_probes 1 40204 NULL
97884 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
97885 +compat_put_long_40214 compat_put_long 1 40214 NULL
97886 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
97887 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
97888 +osst_read_40237 osst_read 3 40237 NULL
97889 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
97890 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
97891 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
97892 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
97893 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
97894 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
97895 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
97896 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
97897 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
97898 +mmio_read_40348 mmio_read 4 40348 NULL
97899 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
97900 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
97901 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
97902 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
97903 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
97904 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
97905 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
97906 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
97907 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
97908 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
97909 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
97910 +tty_write_room_40495 tty_write_room 0 40495 NULL
97911 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
97912 +sg_phys_40507 sg_phys 0 40507 NULL
97913 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
97914 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
97915 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
97916 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
97917 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
97918 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
97919 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
97920 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
97921 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
97922 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
97923 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
97924 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
97925 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
97926 +fops_read_40672 fops_read 3 40672 NULL
97927 +tps80031_write_40678 tps80031_write 3 40678 NULL
97928 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
97929 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
97930 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
97931 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
97932 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
97933 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
97934 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
97935 +card_send_command_40757 card_send_command 3 40757 NULL
97936 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
97937 +pg_write_40766 pg_write 3 40766 NULL
97938 +show_list_40775 show_list 3 40775 NULL
97939 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
97940 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
97941 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
97942 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
97943 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
97944 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
97945 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
97946 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
97947 +read_file_queue_40895 read_file_queue 3 40895 NULL
97948 +waiters_read_40902 waiters_read 3 40902 NULL
97949 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
97950 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
97951 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
97952 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
97953 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
97954 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
97955 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
97956 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
97957 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
97958 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
97959 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
97960 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
97961 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
97962 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
97963 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
97964 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
97965 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
97966 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
97967 +dma_attach_41094 dma_attach 5-6 41094 NULL
97968 +provide_user_output_41105 provide_user_output 3 41105 NULL
97969 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
97970 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
97971 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
97972 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
97973 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
97974 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
97975 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
97976 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
97977 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
97978 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
97979 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
97980 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
97981 +erst_read_41260 erst_read 0 41260 NULL
97982 +__fprog_create_41263 __fprog_create 2 41263 NULL
97983 +alloc_context_41283 alloc_context 1 41283 NULL
97984 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
97985 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
97986 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
97987 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
97988 +kmp_init_41373 kmp_init 2 41373 NULL
97989 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
97990 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
97991 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
97992 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
97993 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
97994 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
97995 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
97996 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
97997 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
97998 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
97999 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
98000 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
98001 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
98002 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
98003 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
98004 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
98005 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
98006 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
98007 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
98008 +gserial_setup_41558 gserial_setup 2 41558 NULL
98009 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
98010 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
98011 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
98012 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
98013 +vga_io_r_41609 vga_io_r 0 41609 NULL
98014 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
98015 +a2mp_send_41615 a2mp_send 4 41615 NULL
98016 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
98017 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
98018 +get_std_timing_41654 get_std_timing 0 41654 NULL
98019 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
98020 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
98021 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
98022 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
98023 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
98024 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
98025 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
98026 +fillonedir_41746 fillonedir 3 41746 NULL
98027 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
98028 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
98029 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
98030 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
98031 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
98032 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
98033 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
98034 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
98035 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
98036 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
98037 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
98038 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
98039 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
98040 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
98041 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
98042 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
98043 +portnames_read_41958 portnames_read 3 41958 NULL
98044 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
98045 +dst_mtu_41969 dst_mtu 0 41969 NULL
98046 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
98047 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
98048 +lguest_map_42008 lguest_map 1-2 42008 NULL
98049 +pool_allocate_42012 pool_allocate 3 42012 NULL
98050 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
98051 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
98052 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
98053 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
98054 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
98055 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
98056 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
98057 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
98058 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
98059 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
98060 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
98061 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
98062 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
98063 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
98064 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
98065 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
98066 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
98067 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
98068 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
98069 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
98070 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
98071 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
98072 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
98073 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
98074 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
98075 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
98076 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
98077 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
98078 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
98079 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
98080 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
98081 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
98082 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
98083 +krng_get_random_42420 krng_get_random 3 42420 NULL
98084 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
98085 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
98086 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
98087 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
98088 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
98089 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
98090 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
98091 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
98092 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
98093 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
98094 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
98095 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
98096 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
98097 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
98098 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
98099 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
98100 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
98101 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
98102 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
98103 +map_state_42602 map_state 1 42602 NULL nohasharray
98104 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
98105 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
98106 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
98107 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
98108 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
98109 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
98110 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
98111 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
98112 +vb2_read_42703 vb2_read 3 42703 NULL
98113 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
98114 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
98115 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
98116 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
98117 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
98118 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
98119 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
98120 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
98121 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
98122 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
98123 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
98124 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
98125 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
98126 +set_arg_42824 set_arg 3 42824 NULL
98127 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
98128 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
98129 +prandom_u32_42853 prandom_u32 0 42853 NULL
98130 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
98131 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
98132 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
98133 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
98134 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
98135 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
98136 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
98137 +hd_end_request_42904 hd_end_request 2 42904 NULL
98138 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
98139 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
98140 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
98141 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
98142 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
98143 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
98144 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
98145 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
98146 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
98147 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
98148 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
98149 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
98150 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
98151 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
98152 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
98153 +uuid_string_43154 uuid_string 0 43154 NULL
98154 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
98155 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
98156 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
98157 +process_measurement_43190 process_measurement 0 43190 NULL
98158 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
98159 +uio_write_43202 uio_write 3 43202 NULL
98160 +iso_callback_43208 iso_callback 3 43208 NULL
98161 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
98162 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
98163 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
98164 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
98165 +fixup_leb_43256 fixup_leb 3 43256 NULL
98166 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
98167 +evtchn_write_43278 evtchn_write 3 43278 NULL
98168 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
98169 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
98170 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
98171 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
98172 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
98173 +xenfb_write_43412 xenfb_write 3 43412 NULL
98174 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 NULL nohasharray
98175 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 &gdm_wimax_netif_rx_43423
98176 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
98177 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
98178 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
98179 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
98180 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
98181 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
98182 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
98183 +do_readlink_43518 do_readlink 2 43518 NULL
98184 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
98185 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
98186 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
98187 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
98188 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
98189 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
98190 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
98191 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
98192 +proc_read_43614 proc_read 3 43614 NULL
98193 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
98194 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
98195 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
98196 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
98197 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
98198 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
98199 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
98200 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
98201 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
98202 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
98203 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
98204 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
98205 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
98206 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
98207 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
98208 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
98209 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
98210 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
98211 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
98212 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
98213 +read_flush_43851 read_flush 3 43851 NULL
98214 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
98215 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
98216 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
98217 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
98218 +SendString_43928 SendString 3 43928 NULL
98219 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
98220 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
98221 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
98222 +nla_reserve_43984 nla_reserve 3 43984 NULL
98223 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
98224 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
98225 +emit_flags_44006 emit_flags 4-3 44006 NULL
98226 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
98227 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
98228 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
98229 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
98230 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
98231 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
98232 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
98233 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
98234 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
98235 +__set_free_44211 __set_free 2 44211 NULL
98236 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
98237 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
98238 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
98239 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
98240 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
98241 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
98242 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
98243 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
98244 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
98245 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
98246 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
98247 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
98248 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
98249 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
98250 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
98251 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
98252 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
98253 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
98254 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
98255 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
98256 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
98257 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
98258 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
98259 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
98260 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
98261 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
98262 +spidev_write_44510 spidev_write 3 44510 NULL
98263 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
98264 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
98265 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
98266 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
98267 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
98268 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
98269 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
98270 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
98271 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
98272 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
98273 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
98274 +mpi_resize_44674 mpi_resize 2 44674 NULL
98275 +ts_read_44687 ts_read 3 44687 NULL
98276 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
98277 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
98278 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
98279 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
98280 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
98281 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
98282 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
98283 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
98284 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
98285 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
98286 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
98287 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
98288 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
98289 +sisusb_write_44834 sisusb_write 3 44834 NULL
98290 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
98291 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
98292 +skb_availroom_44883 skb_availroom 0 44883 NULL
98293 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
98294 +do_tty_write_44896 do_tty_write 5 44896 NULL
98295 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
98296 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
98297 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
98298 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
98299 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
98300 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
98301 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
98302 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
98303 +sel_write_user_45060 sel_write_user 3 45060 NULL
98304 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
98305 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
98306 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
98307 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
98308 +usbdev_read_45114 usbdev_read 3 45114 NULL
98309 +send_to_tty_45141 send_to_tty 3 45141 NULL
98310 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
98311 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
98312 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
98313 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
98314 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
98315 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
98316 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
98317 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
98318 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
98319 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
98320 +add_child_45201 add_child 4 45201 NULL
98321 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
98322 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
98323 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
98324 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
98325 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
98326 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
98327 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
98328 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
98329 +keymap_store_45406 keymap_store 4 45406 NULL
98330 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
98331 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
98332 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
98333 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
98334 +__node_remap_45458 __node_remap 4 45458 NULL
98335 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
98336 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
98337 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
98338 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
98339 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
98340 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
98341 +clone_bio_45516 clone_bio 6 45516 NULL
98342 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
98343 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
98344 +copy_macs_45534 copy_macs 4 45534 NULL
98345 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
98346 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
98347 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
98348 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
98349 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
98350 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
98351 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
98352 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
98353 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
98354 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
98355 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
98356 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
98357 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
98358 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
98359 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
98360 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
98361 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
98362 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
98363 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
98364 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
98365 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
98366 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
98367 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
98368 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
98369 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
98370 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
98371 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
98372 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
98373 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
98374 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
98375 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
98376 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
98377 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
98378 +amthi_read_45831 amthi_read 4 45831 NULL
98379 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
98380 +isdn_write_45863 isdn_write 3 45863 NULL
98381 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
98382 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
98383 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
98384 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
98385 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
98386 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
98387 +alloc_mr_45935 alloc_mr 1 45935 NULL
98388 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
98389 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
98390 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
98391 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
98392 +get_free_entries_46030 get_free_entries 1 46030 NULL
98393 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
98394 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
98395 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
98396 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
98397 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
98398 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
98399 +slhc_toss_46066 slhc_toss 0 46066 NULL
98400 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
98401 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
98402 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
98403 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
98404 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
98405 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
98406 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
98407 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
98408 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
98409 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
98410 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
98411 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
98412 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
98413 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
98414 +dsp_write_46218 dsp_write 2 46218 NULL
98415 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
98416 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
98417 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
98418 +ReadReg_46277 ReadReg 0 46277 NULL
98419 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
98420 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
98421 +twl6040_write_46351 twl6040_write 2 46351 NULL
98422 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
98423 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
98424 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
98425 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
98426 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
98427 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
98428 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
98429 +filldir64_46469 filldir64 3 46469 NULL
98430 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
98431 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
98432 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
98433 +kmsg_read_46514 kmsg_read 3 46514 NULL
98434 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
98435 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
98436 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
98437 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
98438 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
98439 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
98440 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
98441 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
98442 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
98443 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
98444 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
98445 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
98446 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
98447 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
98448 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
98449 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
98450 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
98451 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
98452 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
98453 +prepare_copy_46725 prepare_copy 2 46725 NULL
98454 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
98455 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
98456 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
98457 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
98458 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
98459 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
98460 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
98461 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
98462 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
98463 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
98464 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
98465 +spi_async_46857 spi_async 0 46857 NULL
98466 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
98467 +vsnprintf_46863 vsnprintf 0 46863 NULL
98468 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
98469 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
98470 +rvmalloc_46873 rvmalloc 1 46873 NULL
98471 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
98472 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
98473 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
98474 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
98475 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
98476 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
98477 +fb_write_46924 fb_write 3 46924 NULL
98478 +raid_status_46930 raid_status 5 46930 NULL
98479 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
98480 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
98481 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
98482 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
98483 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
98484 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
98485 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
98486 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
98487 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
98488 +__map_single_47020 __map_single 3-4-7 47020 NULL
98489 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
98490 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
98491 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
98492 +fs_path_len_47060 fs_path_len 0 47060 NULL
98493 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
98494 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
98495 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
98496 +mousedev_read_47123 mousedev_read 3 47123 NULL
98497 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
98498 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
98499 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
98500 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
98501 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
98502 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
98503 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
98504 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
98505 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
98506 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
98507 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
98508 +l2headersize_47238 l2headersize 0 47238 NULL
98509 +options_write_47243 options_write 3 47243 NULL
98510 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
98511 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
98512 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
98513 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
98514 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
98515 +vsnprintf_47291 vsnprintf 0 47291 NULL
98516 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
98517 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
98518 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
98519 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
98520 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
98521 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
98522 +nametbl_list_47391 nametbl_list 2 47391 NULL
98523 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
98524 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
98525 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
98526 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
98527 +vzalloc_47421 vzalloc 1 47421 NULL
98528 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
98529 +newpart_47485 newpart 6 47485 NULL
98530 +core_sys_select_47494 core_sys_select 1 47494 NULL
98531 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
98532 +unlink_simple_47506 unlink_simple 3 47506 NULL
98533 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
98534 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
98535 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
98536 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
98537 +oz_events_read_47535 oz_events_read 3 47535 NULL
98538 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
98539 +cycx_setup_47562 cycx_setup 4 47562 NULL
98540 +read_ldt_47570 read_ldt 2 47570 NULL
98541 +pci_iomap_47575 pci_iomap 3 47575 NULL
98542 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
98543 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
98544 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
98545 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
98546 +uea_request_47613 uea_request 4 47613 NULL
98547 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
98548 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
98549 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
98550 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
98551 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
98552 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
98553 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
98554 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
98555 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
98556 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
98557 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
98558 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
98559 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
98560 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
98561 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
98562 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
98563 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
98564 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
98565 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
98566 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
98567 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
98568 +vhci_read_47878 vhci_read 3 47878 NULL
98569 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
98570 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
98571 +timeout_read_47915 timeout_read 3 47915 NULL
98572 +comedi_write_47926 comedi_write 3 47926 NULL
98573 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
98574 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
98575 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
98576 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
98577 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
98578 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
98579 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
98580 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
98581 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
98582 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
98583 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
98584 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
98585 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
98586 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
98587 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
98588 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
98589 +set_discoverable_48141 set_discoverable 4 48141 NULL
98590 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
98591 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
98592 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
98593 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
98594 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
98595 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
98596 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
98597 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
98598 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
98599 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
98600 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
98601 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
98602 +read_file_recv_48232 read_file_recv 3 48232 NULL
98603 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
98604 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
98605 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
98606 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
98607 +send_set_info_48288 send_set_info 7 48288 NULL
98608 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
98609 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
98610 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
98611 +hash_setkey_48310 hash_setkey 3 48310 NULL
98612 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
98613 +skb_add_data_48363 skb_add_data 3 48363 NULL
98614 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
98615 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
98616 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
98617 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
98618 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
98619 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
98620 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
98621 +send_control_msg_48498 send_control_msg 6 48498 NULL
98622 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
98623 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
98624 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
98625 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
98626 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
98627 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
98628 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
98629 +named_distribute_48544 named_distribute 4 48544 NULL
98630 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
98631 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
98632 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
98633 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
98634 +mtd_read_48655 mtd_read 0 48655 NULL
98635 +lc_create_48662 lc_create 3 48662 NULL
98636 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
98637 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
98638 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
98639 +altera_drscan_48698 altera_drscan 2 48698 NULL
98640 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
98641 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
98642 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
98643 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
98644 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
98645 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
98646 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
98647 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
98648 +azx_get_position_48841 azx_get_position 0 48841 NULL
98649 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
98650 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
98651 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
98652 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
98653 +get_num_ops_48886 get_num_ops 0 48886 NULL
98654 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
98655 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
98656 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
98657 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
98658 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
98659 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
98660 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
98661 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
98662 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
98663 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
98664 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
98665 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
98666 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
98667 +xd_rw_49020 xd_rw 3-4 49020 NULL
98668 +transient_status_49027 transient_status 4 49027 NULL
98669 +ubi_read_49061 ubi_read 0 49061 NULL
98670 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
98671 +calc_layout_49074 calc_layout 4 49074 NULL
98672 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
98673 +scsi_register_49094 scsi_register 2 49094 NULL
98674 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
98675 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
98676 +pt_read_49136 pt_read 3 49136 NULL
98677 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
98678 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
98679 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
98680 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
98681 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
98682 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
98683 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
98684 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
98685 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
98686 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
98687 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
98688 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
98689 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
98690 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
98691 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
98692 +uio_read_49300 uio_read 3 49300 NULL
98693 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
98694 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
98695 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
98696 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
98697 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
98698 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
98699 +px_raw_event_49371 px_raw_event 4 49371 NULL
98700 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
98701 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
98702 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
98703 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
98704 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
98705 +md_domain_init_49432 md_domain_init 2 49432 NULL
98706 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
98707 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
98708 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
98709 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
98710 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
98711 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
98712 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
98713 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
98714 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
98715 +smk_write_access_49561 smk_write_access 3 49561 NULL
98716 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
98717 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
98718 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
98719 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
98720 +heap_init_49617 heap_init 2 49617 NULL
98721 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
98722 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
98723 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
98724 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
98725 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
98726 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
98727 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
98728 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
98729 +check_frame_49741 check_frame 0 49741 NULL
98730 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
98731 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
98732 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
98733 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
98734 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
98735 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
98736 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
98737 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
98738 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
98739 +add_uuid_49831 add_uuid 4 49831 NULL
98740 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
98741 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
98742 +twl4030_write_49846 twl4030_write 2 49846 NULL
98743 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
98744 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
98745 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
98746 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
98747 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
98748 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
98749 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
98750 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
98751 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
98752 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
98753 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
98754 +__module_alloc_50004 __module_alloc 1 50004 NULL
98755 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
98756 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
98757 +isdn_read_50021 isdn_read 3 50021 NULL
98758 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
98759 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
98760 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
98761 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
98762 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
98763 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
98764 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
98765 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
98766 +read_file_slot_50111 read_file_slot 3 50111 NULL
98767 +copy_items_50140 copy_items 6 50140 NULL
98768 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
98769 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
98770 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
98771 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
98772 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
98773 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
98774 +odev_update_50169 odev_update 2 50169 NULL
98775 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
98776 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
98777 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
98778 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
98779 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
98780 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
98781 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
98782 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
98783 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
98784 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
98785 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
98786 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
98787 +do_launder_page_50329 do_launder_page 0 50329 NULL
98788 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
98789 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
98790 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
98791 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
98792 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
98793 +tpm_read_50344 tpm_read 3 50344 NULL
98794 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
98795 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
98796 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
98797 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
98798 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
98799 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
98800 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
98801 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
98802 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
98803 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
98804 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
98805 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
98806 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
98807 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
98808 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
98809 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
98810 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
98811 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
98812 +fat_readpages_50582 fat_readpages 4 50582 NULL
98813 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
98814 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
98815 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
98816 +__ffs_50625 __ffs 0 50625 NULL
98817 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
98818 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
98819 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
98820 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
98821 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
98822 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
98823 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
98824 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
98825 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
98826 +skb_padto_50759 skb_padto 2 50759 NULL
98827 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
98828 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
98829 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
98830 +tpm_write_50798 tpm_write 3 50798 NULL
98831 +tun_do_read_50800 tun_do_read 4 50800 NULL
98832 +write_flush_50803 write_flush 3 50803 NULL
98833 +dvb_play_50814 dvb_play 3 50814 NULL
98834 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
98835 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
98836 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
98837 +dma_attach_50831 dma_attach 6-7 50831 NULL
98838 +SetArea_50835 SetArea 4 50835 NULL nohasharray
98839 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
98840 +self_check_write_50856 self_check_write 5 50856 NULL
98841 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
98842 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
98843 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
98844 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
98845 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
98846 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
98847 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
98848 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
98849 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
98850 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
98851 +timeout_write_50991 timeout_write 3 50991 NULL
98852 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
98853 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
98854 +proc_write_51003 proc_write 3 51003 NULL
98855 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
98856 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
98857 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
98858 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
98859 +dump_midi_51040 dump_midi 3 51040 NULL
98860 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
98861 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
98862 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
98863 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
98864 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
98865 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
98866 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
98867 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
98868 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
98869 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
98870 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
98871 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
98872 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
98873 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
98874 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
98875 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
98876 +tipc_send_51238 tipc_send 4 51238 NULL
98877 +drm_property_create_51239 drm_property_create 4 51239 NULL
98878 +st_read_51251 st_read 3 51251 NULL
98879 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
98880 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
98881 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
98882 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
98883 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
98884 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
98885 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
98886 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
98887 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
98888 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
98889 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
98890 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
98891 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
98892 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
98893 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
98894 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
98895 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
98896 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
98897 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
98898 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
98899 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
98900 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
98901 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
98902 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
98903 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
98904 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
98905 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
98906 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
98907 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
98908 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
98909 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
98910 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
98911 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
98912 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
98913 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
98914 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
98915 +sel_write_access_51704 sel_write_access 3 51704 NULL
98916 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
98917 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
98918 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
98919 +msg_set_51725 msg_set 3 51725 NULL
98920 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
98921 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
98922 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
98923 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
98924 +if_write_51756 if_write 3 51756 NULL
98925 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
98926 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
98927 +__fswab32_51781 __fswab32 0 51781 NULL
98928 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
98929 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
98930 +wm2000_write_51834 wm2000_write 2 51834 NULL
98931 +ioread32_51847 ioread32 0 51847 NULL nohasharray
98932 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
98933 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
98934 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
98935 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
98936 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
98937 +user_read_51881 user_read 3 51881 NULL
98938 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
98939 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
98940 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
98941 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
98942 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
98943 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
98944 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
98945 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
98946 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
98947 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
98948 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
98949 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
98950 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
98951 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
98952 +rdmalt_52022 rdmalt 0 52022 NULL
98953 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
98954 +override_release_52032 override_release 2 52032 NULL
98955 +end_port_52042 end_port 0 52042 NULL
98956 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
98957 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
98958 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
98959 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
98960 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
98961 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
98962 +retry_count_read_52129 retry_count_read 3 52129 NULL
98963 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
98964 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
98965 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
98966 +htable_size_52148 htable_size 0-1 52148 NULL
98967 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
98968 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
98969 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
98970 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
98971 +print_prefix_52176 print_prefix 0 52176 NULL
98972 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
98973 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
98974 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
98975 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
98976 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
98977 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
98978 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
98979 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
98980 +read_file_reset_52310 read_file_reset 3 52310 NULL
98981 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
98982 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
98983 +hwflags_read_52318 hwflags_read 3 52318 NULL
98984 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
98985 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
98986 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
98987 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
98988 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
98989 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
98990 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
98991 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
98992 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
98993 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
98994 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
98995 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
98996 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
98997 +delay_status_52431 delay_status 5 52431 NULL
98998 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
98999 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
99000 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
99001 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
99002 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
99003 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
99004 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
99005 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
99006 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
99007 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
99008 +emit_code_52583 emit_code 0-3 52583 NULL
99009 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
99010 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
99011 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
99012 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
99013 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
99014 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
99015 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
99016 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
99017 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
99018 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
99019 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
99020 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
99021 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
99022 +twlreg_write_52880 twlreg_write 3 52880 NULL
99023 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
99024 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
99025 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
99026 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
99027 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
99028 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
99029 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
99030 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
99031 +send_packet_52960 send_packet 4 52960 NULL
99032 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
99033 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
99034 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
99035 +num_node_state_52989 num_node_state 0 52989 NULL
99036 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
99037 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
99038 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
99039 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
99040 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
99041 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
99042 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
99043 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
99044 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
99045 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
99046 +verity_status_53120 verity_status 5 53120 NULL
99047 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
99048 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
99049 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
99050 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
99051 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
99052 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
99053 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
99054 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
99055 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
99056 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
99057 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
99058 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
99059 +vm_mmap_53339 vm_mmap 0 53339 NULL
99060 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
99061 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
99062 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
99063 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
99064 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
99065 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
99066 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
99067 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
99068 +n2_run_53459 n2_run 3 53459 NULL
99069 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
99070 +wm831x_write_53469 wm831x_write 2 53469 NULL
99071 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
99072 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
99073 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
99074 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
99075 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
99076 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
99077 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
99078 +check_acl_53512 check_acl 0 53512 NULL
99079 +set_registers_53582 set_registers 3 53582 NULL
99080 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
99081 +__readw_53594 __readw 0 53594 NULL
99082 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
99083 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
99084 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
99085 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
99086 +_preload_range_53676 _preload_range 2-3 53676 NULL
99087 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
99088 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
99089 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 NULL nohasharray
99090 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
99091 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
99092 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
99093 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
99094 +wdm_write_53735 wdm_write 3 53735 NULL
99095 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
99096 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
99097 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
99098 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
99099 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
99100 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
99101 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
99102 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
99103 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
99104 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
99105 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
99106 +pms_read_53873 pms_read 3 53873 NULL
99107 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
99108 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
99109 +proc_file_read_53905 proc_file_read 3 53905 NULL
99110 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
99111 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
99112 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
99113 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
99114 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
99115 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
99116 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
99117 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
99118 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
99119 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
99120 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
99121 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
99122 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
99123 +_malloc_54077 _malloc 1 54077 NULL
99124 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
99125 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
99126 +create_xattr_54106 create_xattr 5 54106 NULL
99127 +strn_len_54122 strn_len 0 54122 NULL
99128 +isku_receive_54130 isku_receive 4 54130 NULL
99129 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
99130 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
99131 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
99132 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
99133 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
99134 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
99135 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
99136 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
99137 +reada_add_block_54247 reada_add_block 2 54247 NULL
99138 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
99139 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
99140 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
99141 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
99142 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
99143 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
99144 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
99145 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
99146 +sprintf_54306 sprintf 0 54306 NULL
99147 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
99148 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
99149 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
99150 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
99151 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
99152 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
99153 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
99154 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
99155 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
99156 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
99157 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
99158 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
99159 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
99160 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
99161 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
99162 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
99163 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
99164 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
99165 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
99166 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
99167 +viacam_read_54526 viacam_read 3 54526 NULL
99168 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
99169 +setsockopt_54539 setsockopt 5 54539 NULL
99170 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
99171 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
99172 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
99173 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
99174 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
99175 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
99176 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
99177 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
99178 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
99179 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
99180 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
99181 +evm_read_key_54674 evm_read_key 3 54674 NULL
99182 +resource_string_54699 resource_string 0 54699 NULL
99183 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
99184 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
99185 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
99186 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
99187 +kzalloc_54740 kzalloc 1 54740 NULL
99188 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
99189 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
99190 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
99191 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
99192 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
99193 +domain_init_54797 domain_init 2 54797 NULL
99194 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
99195 +nfsd_write_54809 nfsd_write 6 54809 NULL
99196 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
99197 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
99198 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
99199 +write_rio_54837 write_rio 3 54837 NULL
99200 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
99201 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
99202 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
99203 +printer_read_54851 printer_read 3 54851 NULL
99204 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
99205 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
99206 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
99207 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
99208 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
99209 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
99210 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
99211 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
99212 +add_port_54941 add_port 2 54941 NULL
99213 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
99214 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
99215 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
99216 +c4_add_card_54968 c4_add_card 3 54968 NULL
99217 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
99218 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
99219 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
99220 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
99221 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
99222 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
99223 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
99224 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
99225 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
99226 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
99227 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
99228 +corrupt_data_55120 corrupt_data 0 55120 NULL
99229 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
99230 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
99231 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
99232 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
99233 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
99234 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
99235 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
99236 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
99237 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
99238 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
99239 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
99240 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
99241 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
99242 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
99243 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
99244 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
99245 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
99246 +ptrace_request_55288 ptrace_request 3 55288 NULL
99247 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
99248 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
99249 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
99250 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
99251 +vme_user_read_55338 vme_user_read 3 55338 NULL
99252 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
99253 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
99254 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
99255 +__send_to_port_55383 __send_to_port 3 55383 NULL
99256 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
99257 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
99258 +alloc_skb_55439 alloc_skb 1 55439 NULL
99259 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
99260 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
99261 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
99262 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
99263 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
99264 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
99265 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
99266 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
99267 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
99268 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
99269 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
99270 +ea_get_55522 ea_get 0 55522 NULL
99271 +buffer_size_55534 buffer_size 0 55534 NULL
99272 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
99273 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
99274 +add_partition_55588 add_partition 2 55588 NULL
99275 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
99276 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
99277 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
99278 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
99279 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
99280 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
99281 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
99282 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
99283 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
99284 +read_oldmem_55658 read_oldmem 3 55658 NULL
99285 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
99286 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
99287 +get_info_55681 get_info 3 55681 NULL
99288 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
99289 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
99290 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
99291 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
99292 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
99293 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
99294 +set_local_name_55757 set_local_name 4 55757 NULL
99295 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
99296 +strlen_55778 strlen 0 55778 NULL nohasharray
99297 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
99298 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
99299 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
99300 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
99301 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
99302 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
99303 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
99304 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
99305 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
99306 +hsc_write_55875 hsc_write 3 55875 NULL
99307 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
99308 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
99309 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
99310 +handle_response_55951 handle_response 5 55951 NULL
99311 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
99312 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
99313 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
99314 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
99315 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
99316 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
99317 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
99318 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
99319 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
99320 +map_addr_56144 map_addr 7 56144 NULL
99321 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
99322 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
99323 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
99324 +skb_headroom_56200 skb_headroom 0 56200 NULL
99325 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
99326 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
99327 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
99328 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
99329 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
99330 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
99331 +fd_copyin_56247 fd_copyin 3 56247 NULL
99332 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
99333 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
99334 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
99335 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
99336 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
99337 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
99338 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
99339 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
99340 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
99341 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
99342 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
99343 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
99344 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
99345 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
99346 +dev_read_56369 dev_read 3 56369 NULL
99347 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
99348 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
99349 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
99350 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
99351 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
99352 +store_msg_56417 store_msg 3 56417 NULL
99353 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
99354 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
99355 +fl_create_56435 fl_create 5 56435 NULL
99356 +gnttab_map_56439 gnttab_map 2 56439 NULL
99357 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
99358 +set_connectable_56458 set_connectable 4 56458 NULL
99359 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
99360 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
99361 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
99362 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
99363 +ip_options_get_56538 ip_options_get 4 56538 NULL
99364 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
99365 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
99366 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
99367 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
99368 +event_filter_write_56609 event_filter_write 3 56609 NULL
99369 +gather_array_56641 gather_array 3 56641 NULL
99370 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
99371 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
99372 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
99373 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
99374 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
99375 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
99376 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
99377 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
99378 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
99379 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
99380 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
99381 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
99382 +do_syslog_56807 do_syslog 3 56807 NULL
99383 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
99384 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
99385 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
99386 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
99387 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
99388 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
99389 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
99390 +strcspn_56913 strcspn 0 56913 NULL
99391 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
99392 +check_header_56930 check_header 2 56930 NULL
99393 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
99394 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
99395 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
99396 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
99397 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
99398 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
99399 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
99400 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
99401 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
99402 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
99403 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
99404 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
99405 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
99406 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
99407 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
99408 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
99409 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
99410 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
99411 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
99412 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
99413 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
99414 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
99415 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
99416 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
99417 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
99418 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
99419 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
99420 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
99421 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
99422 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
99423 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
99424 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
99425 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
99426 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
99427 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
99428 +fw_file_size_57307 fw_file_size 0 57307 NULL
99429 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
99430 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
99431 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
99432 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
99433 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
99434 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
99435 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
99436 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
99437 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
99438 +read_file_blob_57406 read_file_blob 3 57406 NULL
99439 +enclosure_register_57412 enclosure_register 3 57412 NULL
99440 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
99441 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
99442 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
99443 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
99444 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
99445 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
99446 +ReadReg_57453 ReadReg 0 57453 NULL
99447 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
99448 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
99449 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
99450 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
99451 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
99452 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
99453 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
99454 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
99455 +skb_headlen_57501 skb_headlen 0 57501 NULL
99456 +copy_in_user_57502 copy_in_user 3 57502 NULL
99457 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
99458 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
99459 +init_tag_map_57515 init_tag_map 3 57515 NULL
99460 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
99461 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
99462 +inode_permission_57531 inode_permission 0 57531 NULL
99463 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
99464 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
99465 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
99466 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
99467 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
99468 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
99469 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
99470 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
99471 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
99472 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
99473 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
99474 +mem_read_57631 mem_read 3 57631 NULL
99475 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
99476 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
99477 +r3964_write_57662 r3964_write 4 57662 NULL
99478 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
99479 +__lgwrite_57669 __lgwrite 4 57669 NULL
99480 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
99481 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
99482 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
99483 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
99484 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
99485 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
99486 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
99487 +ld2_57794 ld2 0 57794 NULL
99488 +ivtv_read_57796 ivtv_read 3 57796 NULL
99489 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
99490 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
99491 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
99492 +copy_to_user_57835 copy_to_user 3 57835 NULL
99493 +flash_read_57843 flash_read 3 57843 NULL
99494 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
99495 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
99496 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
99497 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
99498 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
99499 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
99500 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
99501 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
99502 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
99503 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
99504 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
99505 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
99506 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
99507 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
99508 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
99509 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
99510 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
99511 +mc13783_write_58033 mc13783_write 2 58033 NULL
99512 +mce_async_out_58056 mce_async_out 3 58056 NULL
99513 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
99514 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
99515 +cm4040_write_58079 cm4040_write 3 58079 NULL
99516 +udi_log_event_58105 udi_log_event 3 58105 NULL
99517 +savemem_58129 savemem 3 58129 NULL
99518 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
99519 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
99520 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
99521 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
99522 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
99523 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
99524 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
99525 +read_file_debug_58256 read_file_debug 3 58256 NULL
99526 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
99527 +profile_load_58267 profile_load 3 58267 NULL
99528 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
99529 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
99530 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
99531 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
99532 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
99533 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
99534 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
99535 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
99536 +next_pidmap_58347 next_pidmap 2 58347 NULL
99537 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
99538 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
99539 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
99540 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
99541 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
99542 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
99543 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
99544 +capabilities_read_58457 capabilities_read 3 58457 NULL
99545 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
99546 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
99547 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
99548 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
99549 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
99550 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
99551 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
99552 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
99553 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
99554 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
99555 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
99556 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
99557 +xip_file_read_58592 xip_file_read 3 58592 NULL
99558 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
99559 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
99560 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
99561 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
99562 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
99563 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
99564 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
99565 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
99566 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
99567 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
99568 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
99569 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
99570 +acpi_map_58725 acpi_map 1-2 58725 NULL
99571 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
99572 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
99573 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
99574 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
99575 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
99576 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
99577 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
99578 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
99579 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
99580 +ep_read_58813 ep_read 3 58813 NULL
99581 +command_write_58841 command_write 3 58841 NULL
99582 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
99583 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
99584 +hw_write_58881 hw_write 2 58881 NULL
99585 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
99586 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
99587 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
99588 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
99589 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
99590 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
99591 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
99592 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
99593 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
99594 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
99595 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
99596 +ep_write_59008 ep_write 3 59008 NULL
99597 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
99598 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
99599 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
99600 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
99601 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
99602 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
99603 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
99604 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
99605 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
99606 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
99607 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
99608 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
99609 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
99610 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
99611 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
99612 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
99613 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
99614 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
99615 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
99616 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
99617 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
99618 +dt3155_read_59226 dt3155_read 3 59226 NULL
99619 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
99620 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
99621 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
99622 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
99623 +nla_len_59258 nla_len 0 59258 NULL
99624 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
99625 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
99626 +fd_copyout_59323 fd_copyout 3 59323 NULL
99627 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
99628 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
99629 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
99630 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
99631 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
99632 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
99633 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
99634 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
99635 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
99636 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
99637 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
99638 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
99639 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
99640 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
99641 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
99642 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
99643 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
99644 +tunables_write_59563 tunables_write 3 59563 NULL
99645 +memdup_user_59590 memdup_user 2 59590 NULL
99646 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
99647 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
99648 +mtrr_write_59622 mtrr_write 3 59622 NULL
99649 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
99650 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
99651 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
99652 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
99653 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
99654 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
99655 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
99656 +wm8400_write_59675 wm8400_write 2 59675 NULL
99657 +sriov_enable_59689 sriov_enable 2 59689 NULL
99658 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
99659 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
99660 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
99661 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
99662 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
99663 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
99664 +strnlen_59746 strnlen 0 59746 NULL
99665 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
99666 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
99667 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
99668 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
99669 +venus_remove_59781 venus_remove 4 59781 NULL
99670 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
99671 +ipw_write_59807 ipw_write 3 59807 NULL
99672 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
99673 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
99674 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
99675 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
99676 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
99677 +tun_put_user_59849 tun_put_user 4 59849 NULL
99678 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
99679 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
99680 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
99681 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
99682 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
99683 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 NULL nohasharray
99684 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 &compat_ipmi_ioctl_59956
99685 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
99686 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
99687 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
99688 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
99689 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
99690 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
99691 +register_device_60015 register_device 2-3 60015 NULL
99692 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
99693 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
99694 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
99695 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
99696 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
99697 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
99698 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
99699 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
99700 +load_module_60056 load_module 2 60056 NULL nohasharray
99701 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
99702 +compat_writev_60063 compat_writev 3 60063 NULL
99703 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
99704 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
99705 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
99706 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
99707 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
99708 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
99709 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
99710 +init_state_60165 init_state 2 60165 NULL
99711 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
99712 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
99713 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
99714 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
99715 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
99716 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
99717 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
99718 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
99719 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
99720 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
99721 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
99722 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
99723 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
99724 +printer_write_60276 printer_write 3 60276 NULL
99725 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
99726 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
99727 +getDataLength_60301 getDataLength 0 60301 NULL
99728 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
99729 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
99730 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
99731 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
99732 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
99733 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
99734 +driver_names_read_60399 driver_names_read 3 60399 NULL
99735 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
99736 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
99737 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
99738 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
99739 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
99740 +rx_data_60442 rx_data 4 60442 NULL
99741 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
99742 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
99743 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
99744 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
99745 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
99746 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
99747 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
99748 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
99749 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
99750 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
99751 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
99752 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
99753 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
99754 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
99755 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
99756 +init_data_container_60709 init_data_container 1 60709 NULL
99757 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
99758 +raid_status_60755 raid_status 5 60755 NULL
99759 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
99760 +opticon_write_60775 opticon_write 4 60775 NULL
99761 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
99762 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
99763 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
99764 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
99765 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
99766 +generic_writepages_60871 generic_writepages 0 60871 NULL
99767 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
99768 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
99769 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
99770 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
99771 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
99772 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
99773 +pti_char_write_60960 pti_char_write 3 60960 NULL
99774 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
99775 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
99776 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
99777 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
99778 +symtab_init_61050 symtab_init 2 61050 NULL
99779 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
99780 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
99781 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
99782 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
99783 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
99784 +get_derived_key_61100 get_derived_key 4 61100 NULL
99785 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
99786 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
99787 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
99788 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
99789 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
99790 +__vmalloc_61168 __vmalloc 1 61168 NULL
99791 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
99792 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
99793 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
99794 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
99795 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
99796 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
99797 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
99798 +sys_add_key_61288 sys_add_key 4 61288 NULL
99799 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
99800 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
99801 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
99802 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
99803 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
99804 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
99805 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
99806 +change_xattr_61390 change_xattr 5 61390 NULL
99807 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
99808 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
99809 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
99810 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
99811 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
99812 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
99813 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
99814 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
99815 +erst_errno_61526 erst_errno 0 61526 NULL
99816 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
99817 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
99818 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
99819 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
99820 +seq_open_private_61589 seq_open_private 3 61589 NULL
99821 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
99822 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
99823 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
99824 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
99825 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
99826 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
99827 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
99828 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
99829 +resize_stripes_61650 resize_stripes 2 61650 NULL
99830 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
99831 +insert_one_name_61668 insert_one_name 7 61668 NULL
99832 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
99833 +lock_loop_61681 lock_loop 1 61681 NULL
99834 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
99835 +filter_read_61692 filter_read 3 61692 NULL
99836 +iov_length_61716 iov_length 0 61716 NULL
99837 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
99838 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
99839 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
99840 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
99841 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
99842 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
99843 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
99844 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
99845 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
99846 +get_fw_name_61874 get_fw_name 3 61874 NULL
99847 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
99848 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
99849 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
99850 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
99851 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
99852 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
99853 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
99854 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
99855 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
99856 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
99857 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
99858 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
99859 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
99860 +cow_file_range_61979 cow_file_range 3 61979 NULL
99861 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
99862 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
99863 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
99864 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
99865 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
99866 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
99867 +do_pselect_62061 do_pselect 1 62061 NULL
99868 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
99869 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
99870 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
99871 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
99872 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
99873 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
99874 +ql_status_62135 ql_status 5 62135 NULL
99875 +video_usercopy_62151 video_usercopy 2 62151 NULL
99876 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
99877 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
99878 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
99879 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
99880 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
99881 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
99882 +allocate_partition_62245 allocate_partition 4 62245 NULL
99883 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
99884 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
99885 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
99886 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
99887 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
99888 +subseq_list_62332 subseq_list 3-0 62332 NULL
99889 +flash_write_62354 flash_write 3 62354 NULL
99890 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
99891 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
99892 +altera_irscan_62396 altera_irscan 2 62396 NULL
99893 +set_ssp_62411 set_ssp 4 62411 NULL
99894 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
99895 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
99896 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
99897 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
99898 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
99899 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
99900 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
99901 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
99902 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
99903 +debugfs_read_62535 debugfs_read 3 62535 NULL
99904 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
99905 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
99906 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
99907 +get_subdir_62581 get_subdir 3 62581 NULL
99908 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
99909 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
99910 +get_desc_base_62617 get_desc_base 0 62617 NULL
99911 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
99912 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
99913 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
99914 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
99915 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
99916 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
99917 +write_62671 write 3 62671 NULL
99918 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
99919 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
99920 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
99921 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
99922 +rdm_62719 rdm 0 62719 NULL
99923 +key_replays_read_62746 key_replays_read 3 62746 NULL
99924 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
99925 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
99926 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
99927 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
99928 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
99929 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
99930 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
99931 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
99932 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
99933 +aoechr_write_62883 aoechr_write 3 62883 NULL nohasharray
99934 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 &aoechr_write_62883
99935 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
99936 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
99937 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
99938 +getdqbuf_62908 getdqbuf 1 62908 NULL
99939 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
99940 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
99941 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
99942 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
99943 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
99944 +unlink1_63059 unlink1 3 63059 NULL
99945 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
99946 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
99947 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
99948 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
99949 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
99950 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
99951 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
99952 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
99953 +vme_master_read_63221 vme_master_read 0 63221 NULL
99954 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
99955 +ptp_read_63251 ptp_read 4 63251 NULL
99956 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
99957 +raid5_resize_63306 raid5_resize 2 63306 NULL
99958 +proc_info_read_63344 proc_info_read 3 63344 NULL
99959 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
99960 +idmouse_read_63374 idmouse_read 3 63374 NULL
99961 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
99962 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
99963 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
99964 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
99965 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
99966 +kone_send_63435 kone_send 4 63435 NULL
99967 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
99968 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
99969 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
99970 +read_kcore_63488 read_kcore 3 63488 NULL
99971 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
99972 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
99973 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
99974 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
99975 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
99976 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
99977 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
99978 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
99979 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
99980 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
99981 +module_alloc_63630 module_alloc 1 63630 NULL
99982 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
99983 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
99984 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
99985 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
99986 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
99987 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
99988 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
99989 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
99990 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
99991 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
99992 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
99993 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
99994 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
99995 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
99996 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
99997 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
99998 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
99999 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
100000 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
100001 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
100002 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
100003 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
100004 +sel_write_load_63830 sel_write_load 3 63830 NULL
100005 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
100006 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
100007 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
100008 +divas_write_63901 divas_write 3 63901 NULL
100009 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
100010 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
100011 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
100012 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
100013 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
100014 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
100015 +__team_options_register_63941 __team_options_register 3 63941 NULL
100016 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
100017 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
100018 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
100019 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
100020 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
100021 +kmemdup_64015 kmemdup 2 64015 NULL
100022 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
100023 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
100024 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
100025 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
100026 +get_u8_64076 get_u8 0 64076 NULL
100027 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
100028 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
100029 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
100030 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
100031 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
100032 +init_bch_64130 init_bch 1-2 64130 NULL
100033 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
100034 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
100035 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
100036 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
100037 +read_pulse_64227 read_pulse 0-3 64227 NULL
100038 +header_len_64232 header_len 0 64232 NULL
100039 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
100040 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
100041 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
100042 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
100043 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
100044 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
100045 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
100046 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
100047 +ffz_64324 ffz 0 64324 NULL
100048 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
100049 +ts_write_64336 ts_write 3 64336 NULL
100050 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
100051 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
100052 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
100053 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
100054 +ilo_write_64378 ilo_write 3 64378 NULL
100055 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
100056 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
100057 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
100058 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
100059 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
100060 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
100061 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
100062 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
100063 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
100064 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
100065 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
100066 +cap_capable_64462 cap_capable 0 64462 NULL
100067 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
100068 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
100069 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
100070 +remove_uuid_64505 remove_uuid 4 64505 NULL
100071 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
100072 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
100073 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
100074 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
100075 +__spi_sync_64561 __spi_sync 0 64561 NULL
100076 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
100077 +fanotify_write_64623 fanotify_write 3 64623 NULL
100078 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
100079 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
100080 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
100081 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
100082 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
100083 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
100084 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
100085 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
100086 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
100087 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
100088 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
100089 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
100090 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
100091 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
100092 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
100093 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
100094 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
100095 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
100096 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
100097 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
100098 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
100099 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
100100 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
100101 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
100102 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
100103 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
100104 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
100105 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
100106 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
100107 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
100108 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
100109 +pskb_pull_65005 pskb_pull 2 65005 NULL
100110 +unifi_write_65012 unifi_write 3 65012 NULL
100111 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
100112 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
100113 +insert_dent_65034 insert_dent 7 65034 NULL
100114 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
100115 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
100116 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
100117 +make_idx_node_65068 make_idx_node 0 65068 NULL
100118 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
100119 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
100120 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
100121 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
100122 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
100123 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
100124 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
100125 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
100126 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
100127 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
100128 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
100129 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
100130 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
100131 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
100132 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
100133 +get_var_len_65304 get_var_len 0 65304 NULL
100134 +unpack_array_65318 unpack_array 0 65318 NULL
100135 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
100136 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
100137 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
100138 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
100139 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
100140 +strchr_65372 strchr 0 65372 NULL
100141 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
100142 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
100143 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
100144 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
100145 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
100146 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
100147 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
100148 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
100149 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
100150 +regmap_write_65478 regmap_write 2 65478 NULL
100151 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
100152 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
100153 +alloc_dr_65495 alloc_dr 2 65495 NULL
100154 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
100155 new file mode 100644
100156 index 0000000..63c46e5
100157 --- /dev/null
100158 +++ b/tools/gcc/size_overflow_plugin.c
100159 @@ -0,0 +1,2050 @@
100160 +/*
100161 + * Copyright 2011, 2012 by Emese Revfy <re.emese@gmail.com>
100162 + * Licensed under the GPL v2, or (at your option) v3
100163 + *
100164 + * Homepage:
100165 + * http://www.grsecurity.net/~ephox/overflow_plugin/
100166 + *
100167 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
100168 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
100169 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
100170 + *
100171 + * Usage:
100172 + * $ 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
100173 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
100174 + */
100175 +
100176 +#include "gcc-plugin.h"
100177 +#include "config.h"
100178 +#include "system.h"
100179 +#include "coretypes.h"
100180 +#include "tree.h"
100181 +#include "tree-pass.h"
100182 +#include "intl.h"
100183 +#include "plugin-version.h"
100184 +#include "tm.h"
100185 +#include "toplev.h"
100186 +#include "function.h"
100187 +#include "tree-flow.h"
100188 +#include "plugin.h"
100189 +#include "gimple.h"
100190 +#include "diagnostic.h"
100191 +#include "cfgloop.h"
100192 +
100193 +#if BUILDING_GCC_VERSION >= 4008
100194 +#define TODO_dump_func 0
100195 +#endif
100196 +
100197 +struct size_overflow_hash {
100198 + const struct size_overflow_hash * const next;
100199 + const char * const name;
100200 + const unsigned int param;
100201 +};
100202 +
100203 +#include "size_overflow_hash.h"
100204 +
100205 +enum mark {
100206 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
100207 +};
100208 +
100209 +enum err_code_conditions {
100210 + CAST_ONLY, FROM_CONST
100211 +};
100212 +
100213 +static unsigned int call_count = 0;
100214 +
100215 +#define __unused __attribute__((__unused__))
100216 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
100217 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
100218 +#define BEFORE_STMT true
100219 +#define AFTER_STMT false
100220 +#define CREATE_NEW_VAR NULL_TREE
100221 +#define CODES_LIMIT 32
100222 +#define MAX_PARAM 31
100223 +#define MY_STMT GF_PLF_1
100224 +#define NO_CAST_CHECK GF_PLF_2
100225 +#define FROM_ARG true
100226 +#define FROM_RET false
100227 +
100228 +#if BUILDING_GCC_VERSION == 4005
100229 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
100230 +#endif
100231 +
100232 +int plugin_is_GPL_compatible;
100233 +void debug_gimple_stmt(gimple gs);
100234 +
100235 +static tree expand(struct pointer_set_t *visited, tree lhs);
100236 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
100237 +static tree report_size_overflow_decl;
100238 +static const_tree const_char_ptr_type_node;
100239 +static unsigned int handle_function(void);
100240 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
100241 +static tree get_size_overflow_type(gimple stmt, const_tree node);
100242 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
100243 +static void print_missing_msg(tree func, unsigned int argnum);
100244 +
100245 +static struct plugin_info size_overflow_plugin_info = {
100246 + .version = "20130316beta",
100247 + .help = "no-size-overflow\tturn off size overflow checking\n",
100248 +};
100249 +
100250 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
100251 +{
100252 + unsigned int arg_count;
100253 + enum tree_code code = TREE_CODE(*node);
100254 +
100255 + switch (code) {
100256 + case FUNCTION_DECL:
100257 + arg_count = type_num_arguments(TREE_TYPE(*node));
100258 + break;
100259 + case FUNCTION_TYPE:
100260 + case METHOD_TYPE:
100261 + arg_count = type_num_arguments(*node);
100262 + break;
100263 + default:
100264 + *no_add_attrs = true;
100265 + error("%s: %qE attribute only applies to functions", __func__, name);
100266 + return NULL_TREE;
100267 + }
100268 +
100269 + for (; args; args = TREE_CHAIN(args)) {
100270 + tree position = TREE_VALUE(args);
100271 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
100272 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
100273 + *no_add_attrs = true;
100274 + }
100275 + }
100276 + return NULL_TREE;
100277 +}
100278 +
100279 +static const char* get_asm_name(tree node)
100280 +{
100281 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
100282 +}
100283 +
100284 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
100285 +{
100286 + unsigned int arg_count, arg_num;
100287 + enum tree_code code = TREE_CODE(*node);
100288 +
100289 + switch (code) {
100290 + case FUNCTION_DECL:
100291 + arg_count = type_num_arguments(TREE_TYPE(*node));
100292 + break;
100293 + case FUNCTION_TYPE:
100294 + case METHOD_TYPE:
100295 + arg_count = type_num_arguments(*node);
100296 + break;
100297 + case FIELD_DECL:
100298 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
100299 + if (arg_num != 0) {
100300 + *no_add_attrs = true;
100301 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
100302 + }
100303 + return NULL_TREE;
100304 + default:
100305 + *no_add_attrs = true;
100306 + error("%qE attribute only applies to functions", name);
100307 + return NULL_TREE;
100308 + }
100309 +
100310 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
100311 + return NULL_TREE;
100312 +
100313 + for (; args; args = TREE_CHAIN(args)) {
100314 + tree position = TREE_VALUE(args);
100315 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
100316 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
100317 + *no_add_attrs = true;
100318 + }
100319 + }
100320 + return NULL_TREE;
100321 +}
100322 +
100323 +static struct attribute_spec size_overflow_attr = {
100324 + .name = "size_overflow",
100325 + .min_length = 1,
100326 + .max_length = -1,
100327 + .decl_required = true,
100328 + .type_required = false,
100329 + .function_type_required = false,
100330 + .handler = handle_size_overflow_attribute,
100331 +#if BUILDING_GCC_VERSION >= 4007
100332 + .affects_type_identity = false
100333 +#endif
100334 +};
100335 +
100336 +static struct attribute_spec intentional_overflow_attr = {
100337 + .name = "intentional_overflow",
100338 + .min_length = 1,
100339 + .max_length = -1,
100340 + .decl_required = true,
100341 + .type_required = false,
100342 + .function_type_required = false,
100343 + .handler = handle_intentional_overflow_attribute,
100344 +#if BUILDING_GCC_VERSION >= 4007
100345 + .affects_type_identity = false
100346 +#endif
100347 +};
100348 +
100349 +static void register_attributes(void __unused *event_data, void __unused *data)
100350 +{
100351 + register_attribute(&size_overflow_attr);
100352 + register_attribute(&intentional_overflow_attr);
100353 +}
100354 +
100355 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
100356 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
100357 +{
100358 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
100359 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
100360 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
100361 +
100362 + unsigned int m = 0x57559429;
100363 + unsigned int n = 0x5052acdb;
100364 + const unsigned int *key4 = (const unsigned int *)key;
100365 + unsigned int h = len;
100366 + unsigned int k = len + seed + n;
100367 + unsigned long long p;
100368 +
100369 + while (len >= 8) {
100370 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
100371 + len -= 8;
100372 + }
100373 + if (len >= 4) {
100374 + cwmixb(key4[0]) key4 += 1;
100375 + len -= 4;
100376 + }
100377 + if (len)
100378 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
100379 + cwmixb(h ^ (k + n));
100380 + return k ^ h;
100381 +
100382 +#undef cwfold
100383 +#undef cwmixa
100384 +#undef cwmixb
100385 +}
100386 +
100387 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
100388 +{
100389 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
100390 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
100391 + return fn ^ codes;
100392 +}
100393 +
100394 +static inline tree get_original_function_decl(tree fndecl)
100395 +{
100396 + if (DECL_ABSTRACT_ORIGIN(fndecl))
100397 + return DECL_ABSTRACT_ORIGIN(fndecl);
100398 + return fndecl;
100399 +}
100400 +
100401 +static inline gimple get_def_stmt(const_tree node)
100402 +{
100403 + gcc_assert(node != NULL_TREE);
100404 + if (TREE_CODE(node) != SSA_NAME)
100405 + return NULL;
100406 + return SSA_NAME_DEF_STMT(node);
100407 +}
100408 +
100409 +static unsigned char get_tree_code(const_tree type)
100410 +{
100411 + switch (TREE_CODE(type)) {
100412 + case ARRAY_TYPE:
100413 + return 0;
100414 + case BOOLEAN_TYPE:
100415 + return 1;
100416 + case ENUMERAL_TYPE:
100417 + return 2;
100418 + case FUNCTION_TYPE:
100419 + return 3;
100420 + case INTEGER_TYPE:
100421 + return 4;
100422 + case POINTER_TYPE:
100423 + return 5;
100424 + case RECORD_TYPE:
100425 + return 6;
100426 + case UNION_TYPE:
100427 + return 7;
100428 + case VOID_TYPE:
100429 + return 8;
100430 + case REAL_TYPE:
100431 + return 9;
100432 + case VECTOR_TYPE:
100433 + return 10;
100434 + case REFERENCE_TYPE:
100435 + return 11;
100436 + case OFFSET_TYPE:
100437 + return 12;
100438 + case COMPLEX_TYPE:
100439 + return 13;
100440 + default:
100441 + debug_tree((tree)type);
100442 + gcc_unreachable();
100443 + }
100444 +}
100445 +
100446 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
100447 +{
100448 + gcc_assert(type != NULL_TREE);
100449 +
100450 + while (type && len < CODES_LIMIT) {
100451 + tree_codes[len] = get_tree_code(type);
100452 + len++;
100453 + type = TREE_TYPE(type);
100454 + }
100455 + return len;
100456 +}
100457 +
100458 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
100459 +{
100460 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
100461 + enum tree_code code = TREE_CODE(type);
100462 + size_t len = 0;
100463 +
100464 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
100465 +
100466 + arg = TYPE_ARG_TYPES(type);
100467 + // skip builtins __builtin_constant_p
100468 + if (!arg && DECL_BUILT_IN(fndecl))
100469 + return 0;
100470 +
100471 + if (TREE_CODE_CLASS(code) == tcc_type)
100472 + result = type;
100473 + else
100474 + result = DECL_RESULT(fndecl);
100475 +
100476 + gcc_assert(result != NULL_TREE);
100477 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
100478 +
100479 + if (arg == NULL_TREE) {
100480 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
100481 + arg_field = DECL_ARGUMENT_FLD(fndecl);
100482 + if (arg_field == NULL_TREE)
100483 + return 0;
100484 + arg = TREE_TYPE(arg_field);
100485 + len = add_type_codes(arg, tree_codes, len);
100486 + gcc_assert(len != 0);
100487 + return len;
100488 + }
100489 +
100490 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
100491 + while (arg && len < CODES_LIMIT) {
100492 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
100493 + arg = TREE_CHAIN(arg);
100494 + }
100495 +
100496 + gcc_assert(len != 0);
100497 + return len;
100498 +}
100499 +
100500 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
100501 +{
100502 + unsigned int hash;
100503 + const struct size_overflow_hash *entry;
100504 + unsigned char tree_codes[CODES_LIMIT];
100505 + size_t len;
100506 + const char *func_name;
100507 +
100508 + fndecl = get_original_function_decl(fndecl);
100509 + len = get_function_decl(fndecl, tree_codes);
100510 + if (len == 0)
100511 + return NULL;
100512 +
100513 + func_name = get_asm_name(fndecl);
100514 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
100515 +
100516 + entry = size_overflow_hash[hash];
100517 + while (entry) {
100518 + if (!strcmp(entry->name, func_name))
100519 + return entry;
100520 + entry = entry->next;
100521 + }
100522 +
100523 + return NULL;
100524 +}
100525 +
100526 +static bool is_bool(const_tree node)
100527 +{
100528 + const_tree type;
100529 +
100530 + if (node == NULL_TREE)
100531 + return false;
100532 +
100533 + type = TREE_TYPE(node);
100534 + if (!INTEGRAL_TYPE_P(type))
100535 + return false;
100536 + if (TREE_CODE(type) == BOOLEAN_TYPE)
100537 + return true;
100538 + if (TYPE_PRECISION(type) == 1)
100539 + return true;
100540 + return false;
100541 +}
100542 +
100543 +static bool skip_types(const_tree var)
100544 +{
100545 + tree type;
100546 +
100547 + if (is_gimple_constant(var))
100548 + return true;
100549 +
100550 + switch (TREE_CODE(var)) {
100551 + case ADDR_EXPR:
100552 +#if BUILDING_GCC_VERSION >= 4006
100553 + case MEM_REF:
100554 +#endif
100555 + case ARRAY_REF:
100556 + case BIT_FIELD_REF:
100557 + case INDIRECT_REF:
100558 + case TARGET_MEM_REF:
100559 + return true;
100560 + case PARM_DECL:
100561 + case VAR_DECL:
100562 + case COMPONENT_REF:
100563 + return false;
100564 + default:
100565 + break;
100566 + }
100567 +
100568 + gcc_assert(TREE_CODE(var) == SSA_NAME);
100569 +
100570 + type = TREE_TYPE(var);
100571 + switch (TREE_CODE(type)) {
100572 + case INTEGER_TYPE:
100573 + case ENUMERAL_TYPE:
100574 + return false;
100575 + case BOOLEAN_TYPE:
100576 + return is_bool(var);
100577 + default:
100578 + break;
100579 + }
100580 +
100581 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
100582 +
100583 + type = TREE_TYPE(type);
100584 + gcc_assert(type != NULL_TREE);
100585 + switch (TREE_CODE(type)) {
100586 + case RECORD_TYPE:
100587 + case POINTER_TYPE:
100588 + case ARRAY_TYPE:
100589 + return true;
100590 + case VOID_TYPE:
100591 + case INTEGER_TYPE:
100592 + case UNION_TYPE:
100593 + return false;
100594 + default:
100595 + break;
100596 + }
100597 +
100598 + debug_tree((tree)var);
100599 + gcc_unreachable();
100600 +}
100601 +
100602 +static unsigned int find_arg_number(const_tree arg, tree func)
100603 +{
100604 + tree var;
100605 + unsigned int argnum = 1;
100606 +
100607 + if (TREE_CODE(arg) == SSA_NAME)
100608 + arg = SSA_NAME_VAR(arg);
100609 +
100610 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
100611 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
100612 + continue;
100613 + if (!skip_types(var))
100614 + return argnum;
100615 + }
100616 +
100617 + return 0;
100618 +}
100619 +
100620 +static tree create_new_var(tree type)
100621 +{
100622 + tree new_var = create_tmp_var(type, "cicus");
100623 +
100624 +#if BUILDING_GCC_VERSION <= 4007
100625 + add_referenced_var(new_var);
100626 + mark_sym_for_renaming(new_var);
100627 +#endif
100628 + return new_var;
100629 +}
100630 +
100631 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
100632 +{
100633 + gimple assign;
100634 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
100635 + tree type = TREE_TYPE(rhs1);
100636 + tree lhs = create_new_var(type);
100637 +
100638 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
100639 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
100640 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
100641 +
100642 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
100643 + update_stmt(assign);
100644 + gimple_set_plf(assign, MY_STMT, true);
100645 + return assign;
100646 +}
100647 +
100648 +static tree cast_a_tree(tree type, tree var)
100649 +{
100650 + gcc_assert(type != NULL_TREE);
100651 + gcc_assert(var != NULL_TREE);
100652 + gcc_assert(fold_convertible_p(type, var));
100653 +
100654 + return fold_convert(type, var);
100655 +}
100656 +
100657 +static tree get_lhs(const_gimple stmt)
100658 +{
100659 + switch (gimple_code(stmt)) {
100660 + case GIMPLE_ASSIGN:
100661 + return gimple_get_lhs(stmt);
100662 + case GIMPLE_PHI:
100663 + return gimple_phi_result(stmt);
100664 + case GIMPLE_CALL:
100665 + return gimple_call_lhs(stmt);
100666 + default:
100667 + return NULL_TREE;
100668 + }
100669 +}
100670 +
100671 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
100672 +{
100673 + const_gimple def_stmt = get_def_stmt(rhs);
100674 +
100675 + if (force)
100676 + return false;
100677 +
100678 + if (is_gimple_constant(rhs))
100679 + return false;
100680 +
100681 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
100682 + return false;
100683 +
100684 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
100685 + return false;
100686 +
100687 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
100688 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
100689 + return false;
100690 +
100691 + return true;
100692 +}
100693 +
100694 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
100695 +{
100696 + gimple assign, def_stmt;
100697 +
100698 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
100699 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
100700 + gcc_unreachable();
100701 +
100702 + def_stmt = get_def_stmt(rhs);
100703 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
100704 + return def_stmt;
100705 +
100706 + if (lhs == CREATE_NEW_VAR)
100707 + lhs = create_new_var(dst_type);
100708 +
100709 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
100710 +
100711 + if (!gsi_end_p(*gsi)) {
100712 + location_t loc = gimple_location(gsi_stmt(*gsi));
100713 + gimple_set_location(assign, loc);
100714 + }
100715 +
100716 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
100717 +
100718 + if (before)
100719 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
100720 + else
100721 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
100722 + update_stmt(assign);
100723 + gimple_set_plf(assign, MY_STMT, true);
100724 +
100725 + return assign;
100726 +}
100727 +
100728 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
100729 +{
100730 + gimple_stmt_iterator gsi;
100731 + tree lhs;
100732 + const_gimple new_stmt;
100733 +
100734 + if (rhs == NULL_TREE)
100735 + return NULL_TREE;
100736 +
100737 + gsi = gsi_for_stmt(stmt);
100738 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
100739 +
100740 + lhs = get_lhs(new_stmt);
100741 + gcc_assert(lhs != NULL_TREE);
100742 + return lhs;
100743 +}
100744 +
100745 +static tree cast_to_TI_type(gimple stmt, tree node)
100746 +{
100747 + gimple_stmt_iterator gsi;
100748 + gimple cast_stmt;
100749 + tree type = TREE_TYPE(node);
100750 +
100751 + if (types_compatible_p(type, intTI_type_node))
100752 + return node;
100753 +
100754 + gsi = gsi_for_stmt(stmt);
100755 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
100756 + return gimple_get_lhs(cast_stmt);
100757 +}
100758 +
100759 +static void check_function_hash(const_gimple stmt)
100760 +{
100761 + tree func;
100762 + const struct size_overflow_hash *hash;
100763 +
100764 + if (gimple_code(stmt) != GIMPLE_CALL)
100765 + return;
100766 +
100767 + func = gimple_call_fndecl(stmt);
100768 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
100769 + if (func == NULL_TREE)
100770 + return;
100771 +
100772 + hash = get_function_hash(func);
100773 + if (!hash)
100774 + print_missing_msg(func, 0);
100775 +}
100776 +
100777 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
100778 +{
100779 + tree lhs, new_lhs;
100780 + gimple_stmt_iterator gsi;
100781 +
100782 + if (rhs1 == NULL_TREE) {
100783 + debug_gimple_stmt(oldstmt);
100784 + error("%s: rhs1 is NULL_TREE", __func__);
100785 + gcc_unreachable();
100786 + }
100787 +
100788 + switch (gimple_code(oldstmt)) {
100789 + case GIMPLE_ASM:
100790 + lhs = rhs1;
100791 + break;
100792 + case GIMPLE_CALL:
100793 + lhs = gimple_call_lhs(oldstmt);
100794 + break;
100795 + case GIMPLE_ASSIGN:
100796 + lhs = gimple_get_lhs(oldstmt);
100797 + break;
100798 + default:
100799 + debug_gimple_stmt(oldstmt);
100800 + gcc_unreachable();
100801 + }
100802 +
100803 + gsi = gsi_for_stmt(oldstmt);
100804 + pointer_set_insert(visited, oldstmt);
100805 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
100806 + basic_block next_bb, cur_bb;
100807 + const_edge e;
100808 +
100809 + gcc_assert(before == false);
100810 + gcc_assert(stmt_can_throw_internal(oldstmt));
100811 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
100812 + gcc_assert(!gsi_end_p(gsi));
100813 +
100814 + cur_bb = gimple_bb(oldstmt);
100815 + next_bb = cur_bb->next_bb;
100816 + e = find_edge(cur_bb, next_bb);
100817 + gcc_assert(e != NULL);
100818 + gcc_assert(e->flags & EDGE_FALLTHRU);
100819 +
100820 + gsi = gsi_after_labels(next_bb);
100821 + gcc_assert(!gsi_end_p(gsi));
100822 +
100823 + before = true;
100824 + oldstmt = gsi_stmt(gsi);
100825 + }
100826 +
100827 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
100828 + return new_lhs;
100829 +}
100830 +
100831 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
100832 +{
100833 + gimple stmt;
100834 + gimple_stmt_iterator gsi;
100835 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
100836 +
100837 + if (gimple_plf(oldstmt, MY_STMT))
100838 + return lhs;
100839 +
100840 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
100841 + rhs1 = gimple_assign_rhs1(oldstmt);
100842 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
100843 + }
100844 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
100845 + rhs2 = gimple_assign_rhs2(oldstmt);
100846 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
100847 + }
100848 +
100849 + stmt = gimple_copy(oldstmt);
100850 + gimple_set_location(stmt, gimple_location(oldstmt));
100851 + gimple_set_plf(stmt, MY_STMT, true);
100852 +
100853 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
100854 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
100855 +
100856 + size_overflow_type = get_size_overflow_type(oldstmt, node);
100857 +
100858 + new_var = create_new_var(size_overflow_type);
100859 + new_var = make_ssa_name(new_var, stmt);
100860 + gimple_set_lhs(stmt, new_var);
100861 +
100862 + if (rhs1 != NULL_TREE)
100863 + gimple_assign_set_rhs1(stmt, rhs1);
100864 +
100865 + if (rhs2 != NULL_TREE)
100866 + gimple_assign_set_rhs2(stmt, rhs2);
100867 +#if BUILDING_GCC_VERSION >= 4007
100868 + if (rhs3 != NULL_TREE)
100869 + gimple_assign_set_rhs3(stmt, rhs3);
100870 +#endif
100871 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
100872 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
100873 +
100874 + gsi = gsi_for_stmt(oldstmt);
100875 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
100876 + update_stmt(stmt);
100877 + pointer_set_insert(visited, oldstmt);
100878 + return gimple_get_lhs(stmt);
100879 +}
100880 +
100881 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
100882 +{
100883 + basic_block first_bb;
100884 + gimple assign;
100885 + gimple_stmt_iterator gsi;
100886 +
100887 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
100888 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
100889 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
100890 +
100891 + gsi = gsi_start_bb(first_bb);
100892 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
100893 + return gimple_get_lhs(assign);
100894 +}
100895 +
100896 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
100897 +{
100898 + gimple_stmt_iterator gsi;
100899 + const_gimple assign;
100900 + gimple def_stmt = get_def_stmt(new_arg);
100901 +
100902 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
100903 + gsi = gsi_after_labels(gimple_bb(def_stmt));
100904 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
100905 + } else {
100906 + gsi = gsi_for_stmt(def_stmt);
100907 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
100908 + }
100909 +
100910 + return gimple_get_lhs(assign);
100911 +}
100912 +
100913 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
100914 +{
100915 + basic_block bb;
100916 + gimple_stmt_iterator gsi;
100917 + const_gimple assign, def_stmt;
100918 +
100919 + def_stmt = get_def_stmt(arg);
100920 + bb = gimple_bb(def_stmt);
100921 + gcc_assert(bb->index != 0);
100922 + gsi = gsi_after_labels(bb);
100923 +
100924 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
100925 + return gimple_get_lhs(assign);
100926 +}
100927 +
100928 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
100929 +{
100930 + tree size_overflow_type;
100931 + const_gimple def_stmt = get_def_stmt(arg);
100932 +
100933 + if (phi_ssa_name != NULL_TREE)
100934 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
100935 +
100936 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
100937 +
100938 + if (new_arg != NULL_TREE) {
100939 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
100940 + return use_phi_ssa_name(phi_ssa_name, new_arg);
100941 + }
100942 +
100943 + switch(gimple_code(def_stmt)) {
100944 + case GIMPLE_PHI:
100945 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
100946 + case GIMPLE_NOP:
100947 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
100948 + default:
100949 + debug_gimple_stmt((gimple)def_stmt);
100950 + gcc_unreachable();
100951 + }
100952 +}
100953 +
100954 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
100955 +{
100956 + basic_block bb;
100957 + gimple phi;
100958 + gimple_seq seq;
100959 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
100960 +
100961 + bb = gsi_bb(gsi);
100962 +
100963 + phi = create_phi_node(result, bb);
100964 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
100965 + seq = phi_nodes(bb);
100966 + gsi = gsi_last(seq);
100967 + gsi_remove(&gsi, false);
100968 +
100969 + gsi = gsi_for_stmt(oldstmt);
100970 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
100971 + gimple_set_bb(phi, bb);
100972 + gimple_set_plf(phi, MY_STMT, true);
100973 + return phi;
100974 +}
100975 +
100976 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
100977 +{
100978 + gimple new_phi = NULL;
100979 + gimple oldstmt = get_def_stmt(orig_result);
100980 + tree phi_ssa_name = NULL_TREE;
100981 + unsigned int i;
100982 +
100983 + pointer_set_insert(visited, oldstmt);
100984 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
100985 + tree arg, new_arg;
100986 +
100987 + arg = gimple_phi_arg_def(oldstmt, i);
100988 +
100989 + new_arg = expand(visited, arg);
100990 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
100991 + if (i == 0) {
100992 + phi_ssa_name = new_arg;
100993 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
100994 + }
100995 +
100996 + gcc_assert(new_phi != NULL);
100997 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
100998 + }
100999 +
101000 + gcc_assert(new_phi != NULL);
101001 + update_stmt(new_phi);
101002 + return gimple_phi_result(new_phi);
101003 +}
101004 +
101005 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
101006 +{
101007 + const_gimple assign;
101008 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101009 + tree origtype = TREE_TYPE(orig_rhs);
101010 +
101011 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
101012 +
101013 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101014 + return gimple_get_lhs(assign);
101015 +}
101016 +
101017 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
101018 +{
101019 + const_tree rhs1, lhs, rhs1_type, lhs_type;
101020 + enum machine_mode lhs_mode, rhs_mode;
101021 + gimple def_stmt = get_def_stmt(no_const_rhs);
101022 +
101023 + if (!gimple_assign_cast_p(def_stmt))
101024 + return false;
101025 +
101026 + rhs1 = gimple_assign_rhs1(def_stmt);
101027 + lhs = gimple_get_lhs(def_stmt);
101028 + rhs1_type = TREE_TYPE(rhs1);
101029 + lhs_type = TREE_TYPE(lhs);
101030 + rhs_mode = TYPE_MODE(rhs1_type);
101031 + lhs_mode = TYPE_MODE(lhs_type);
101032 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
101033 + return false;
101034 +
101035 + return true;
101036 +}
101037 +
101038 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
101039 +{
101040 + tree rhs1 = gimple_assign_rhs1(stmt);
101041 + tree lhs = gimple_get_lhs(stmt);
101042 + const_tree rhs1_type = TREE_TYPE(rhs1);
101043 + const_tree lhs_type = TREE_TYPE(lhs);
101044 +
101045 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
101046 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101047 +
101048 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
101049 +}
101050 +
101051 +static bool skip_lhs_cast_check(const_gimple stmt)
101052 +{
101053 + const_tree rhs = gimple_assign_rhs1(stmt);
101054 + const_gimple def_stmt = get_def_stmt(rhs);
101055 +
101056 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
101057 + if (gimple_code(def_stmt) == GIMPLE_ASM)
101058 + return true;
101059 +
101060 + return false;
101061 +}
101062 +
101063 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
101064 +{
101065 + bool cast_lhs, cast_rhs;
101066 + tree lhs = gimple_get_lhs(stmt);
101067 + tree rhs = gimple_assign_rhs1(stmt);
101068 + const_tree lhs_type = TREE_TYPE(lhs);
101069 + const_tree rhs_type = TREE_TYPE(rhs);
101070 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
101071 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
101072 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
101073 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
101074 +
101075 + static bool check_lhs[3][4] = {
101076 + // ss su us uu
101077 + { false, true, true, false }, // lhs > rhs
101078 + { false, false, false, false }, // lhs = rhs
101079 + { true, true, true, true }, // lhs < rhs
101080 + };
101081 +
101082 + static bool check_rhs[3][4] = {
101083 + // ss su us uu
101084 + { true, false, true, true }, // lhs > rhs
101085 + { true, false, true, true }, // lhs = rhs
101086 + { true, false, true, true }, // lhs < rhs
101087 + };
101088 +
101089 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
101090 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
101091 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101092 +
101093 + if (lhs_size > rhs_size) {
101094 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101095 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101096 + } else if (lhs_size == rhs_size) {
101097 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101098 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101099 + } else {
101100 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101101 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
101102 + }
101103 +
101104 + if (!cast_lhs && !cast_rhs)
101105 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101106 +
101107 + if (cast_lhs && !skip_lhs_cast_check(stmt))
101108 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
101109 +
101110 + if (cast_rhs)
101111 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
101112 +
101113 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101114 +}
101115 +
101116 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
101117 +{
101118 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
101119 +
101120 + if (gimple_plf(stmt, MY_STMT))
101121 + return lhs;
101122 +
101123 + rhs1 = gimple_assign_rhs1(stmt);
101124 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
101125 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101126 +
101127 + new_rhs1 = expand(visited, rhs1);
101128 +
101129 + if (new_rhs1 == NULL_TREE)
101130 + return create_cast_assign(visited, stmt);
101131 +
101132 + if (gimple_plf(stmt, NO_CAST_CHECK))
101133 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101134 +
101135 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
101136 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
101137 +
101138 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
101139 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
101140 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101141 + }
101142 +
101143 + if (!gimple_assign_cast_p(stmt))
101144 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
101145 +
101146 + return create_cast_overflow_check(visited, new_rhs1, stmt);
101147 +}
101148 +
101149 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
101150 +{
101151 + tree rhs1, lhs = gimple_get_lhs(stmt);
101152 + gimple def_stmt = get_def_stmt(lhs);
101153 +
101154 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
101155 + rhs1 = gimple_assign_rhs1(def_stmt);
101156 +
101157 + if (is_gimple_constant(rhs1))
101158 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101159 +
101160 + switch (TREE_CODE(rhs1)) {
101161 + case SSA_NAME:
101162 + return handle_unary_rhs(visited, def_stmt);
101163 + case ARRAY_REF:
101164 + case BIT_FIELD_REF:
101165 + case ADDR_EXPR:
101166 + case COMPONENT_REF:
101167 + case INDIRECT_REF:
101168 +#if BUILDING_GCC_VERSION >= 4006
101169 + case MEM_REF:
101170 +#endif
101171 + case TARGET_MEM_REF:
101172 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101173 + case PARM_DECL:
101174 + case VAR_DECL:
101175 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101176 +
101177 + default:
101178 + debug_gimple_stmt(def_stmt);
101179 + debug_tree(rhs1);
101180 + gcc_unreachable();
101181 + }
101182 +}
101183 +
101184 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
101185 +{
101186 + gimple cond_stmt;
101187 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
101188 +
101189 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
101190 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
101191 + update_stmt(cond_stmt);
101192 +}
101193 +
101194 +static tree create_string_param(tree string)
101195 +{
101196 + tree i_type, a_type;
101197 + const int length = TREE_STRING_LENGTH(string);
101198 +
101199 + gcc_assert(length > 0);
101200 +
101201 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
101202 + a_type = build_array_type(char_type_node, i_type);
101203 +
101204 + TREE_TYPE(string) = a_type;
101205 + TREE_CONSTANT(string) = 1;
101206 + TREE_READONLY(string) = 1;
101207 +
101208 + return build1(ADDR_EXPR, ptr_type_node, string);
101209 +}
101210 +
101211 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
101212 +{
101213 + gimple func_stmt;
101214 + const_gimple def_stmt;
101215 + const_tree loc_line;
101216 + tree loc_file, ssa_name, current_func;
101217 + expanded_location xloc;
101218 + char *ssa_name_buf;
101219 + int len;
101220 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
101221 +
101222 + def_stmt = get_def_stmt(arg);
101223 + xloc = expand_location(gimple_location(def_stmt));
101224 +
101225 + if (!gimple_has_location(def_stmt)) {
101226 + xloc = expand_location(gimple_location(stmt));
101227 + if (!gimple_has_location(stmt))
101228 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101229 + }
101230 +
101231 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
101232 +
101233 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
101234 + loc_file = create_string_param(loc_file);
101235 +
101236 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
101237 + current_func = create_string_param(current_func);
101238 +
101239 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
101240 + call_count++;
101241 + 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);
101242 + gcc_assert(len > 0);
101243 + ssa_name = build_string(len + 1, ssa_name_buf);
101244 + free(ssa_name_buf);
101245 + ssa_name = create_string_param(ssa_name);
101246 +
101247 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
101248 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
101249 +
101250 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
101251 +}
101252 +
101253 +static void __unused print_the_code_insertions(const_gimple stmt)
101254 +{
101255 + location_t loc = gimple_location(stmt);
101256 +
101257 + inform(loc, "Integer size_overflow check applied here.");
101258 +}
101259 +
101260 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
101261 +{
101262 + basic_block cond_bb, join_bb, bb_true;
101263 + edge e;
101264 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101265 +
101266 + cond_bb = gimple_bb(stmt);
101267 + if (before)
101268 + gsi_prev(&gsi);
101269 + if (gsi_end_p(gsi))
101270 + e = split_block_after_labels(cond_bb);
101271 + else
101272 + e = split_block(cond_bb, gsi_stmt(gsi));
101273 + cond_bb = e->src;
101274 + join_bb = e->dest;
101275 + e->flags = EDGE_FALSE_VALUE;
101276 + e->probability = REG_BR_PROB_BASE;
101277 +
101278 + bb_true = create_empty_bb(cond_bb);
101279 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
101280 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
101281 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
101282 +
101283 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101284 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
101285 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
101286 +
101287 + if (current_loops != NULL) {
101288 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
101289 + add_bb_to_loop(bb_true, cond_bb->loop_father);
101290 + }
101291 +
101292 + insert_cond(cond_bb, arg, cond_code, type_value);
101293 + insert_cond_result(bb_true, stmt, arg, min);
101294 +
101295 +// print_the_code_insertions(stmt);
101296 +}
101297 +
101298 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
101299 +{
101300 + const_tree rhs_type = TREE_TYPE(rhs);
101301 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
101302 +
101303 + gcc_assert(rhs_type != NULL_TREE);
101304 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
101305 + return;
101306 +
101307 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
101308 +
101309 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
101310 + // typemax (-1) < typemin (0)
101311 + if (TREE_OVERFLOW(type_max))
101312 + return;
101313 +
101314 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
101315 +
101316 + cast_rhs_type = TREE_TYPE(cast_rhs);
101317 + type_max_type = TREE_TYPE(type_max);
101318 + type_min_type = TREE_TYPE(type_min);
101319 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
101320 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
101321 +
101322 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
101323 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
101324 +}
101325 +
101326 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
101327 +{
101328 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
101329 + return false;
101330 + if (!is_gimple_constant(rhs))
101331 + return false;
101332 + return true;
101333 +}
101334 +
101335 +static tree get_def_stmt_rhs(const_tree var)
101336 +{
101337 + tree rhs1, def_stmt_rhs1;
101338 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
101339 +
101340 + def_stmt = get_def_stmt(var);
101341 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
101342 +
101343 + rhs1 = gimple_assign_rhs1(def_stmt);
101344 + rhs1_def_stmt = get_def_stmt(rhs1);
101345 + if (!gimple_assign_cast_p(rhs1_def_stmt))
101346 + return rhs1;
101347 +
101348 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
101349 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
101350 +
101351 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
101352 + case GIMPLE_CALL:
101353 + case GIMPLE_NOP:
101354 + case GIMPLE_ASM:
101355 + case GIMPLE_PHI:
101356 + return def_stmt_rhs1;
101357 + case GIMPLE_ASSIGN:
101358 + return rhs1;
101359 + default:
101360 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
101361 + gcc_unreachable();
101362 + }
101363 +}
101364 +
101365 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
101366 +{
101367 + tree new_rhs, orig_rhs;
101368 + void (*gimple_assign_set_rhs)(gimple, tree);
101369 + tree rhs1 = gimple_assign_rhs1(stmt);
101370 + tree rhs2 = gimple_assign_rhs2(stmt);
101371 + tree lhs = gimple_get_lhs(stmt);
101372 +
101373 + if (!check_overflow)
101374 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101375 +
101376 + if (change_rhs == NULL_TREE)
101377 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101378 +
101379 + if (new_rhs2 == NULL_TREE) {
101380 + orig_rhs = rhs1;
101381 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
101382 + } else {
101383 + orig_rhs = rhs2;
101384 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
101385 + }
101386 +
101387 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
101388 +
101389 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
101390 + gimple_assign_set_rhs(stmt, new_rhs);
101391 + update_stmt(stmt);
101392 +
101393 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101394 +}
101395 +
101396 +static bool is_subtraction_special(const_gimple stmt)
101397 +{
101398 + gimple rhs1_def_stmt, rhs2_def_stmt;
101399 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
101400 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
101401 + const_tree rhs1 = gimple_assign_rhs1(stmt);
101402 + const_tree rhs2 = gimple_assign_rhs2(stmt);
101403 +
101404 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
101405 + return false;
101406 +
101407 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
101408 +
101409 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
101410 + return false;
101411 +
101412 + rhs1_def_stmt = get_def_stmt(rhs1);
101413 + rhs2_def_stmt = get_def_stmt(rhs2);
101414 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
101415 + return false;
101416 +
101417 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
101418 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
101419 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
101420 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
101421 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
101422 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
101423 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
101424 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
101425 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
101426 + return false;
101427 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
101428 + return false;
101429 +
101430 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
101431 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
101432 + return true;
101433 +}
101434 +
101435 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
101436 +{
101437 + tree new_rhs1, new_rhs2;
101438 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
101439 + gimple assign, stmt = get_def_stmt(lhs);
101440 + tree rhs1 = gimple_assign_rhs1(stmt);
101441 + tree rhs2 = gimple_assign_rhs2(stmt);
101442 +
101443 + if (!is_subtraction_special(stmt))
101444 + return NULL_TREE;
101445 +
101446 + new_rhs1 = expand(visited, rhs1);
101447 + new_rhs2 = expand(visited, rhs2);
101448 +
101449 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
101450 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
101451 +
101452 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
101453 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
101454 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
101455 + }
101456 +
101457 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
101458 + new_lhs = gimple_get_lhs(assign);
101459 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
101460 +
101461 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
101462 +}
101463 +
101464 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
101465 +{
101466 + const_gimple def_stmt;
101467 +
101468 + if (TREE_CODE(rhs) != SSA_NAME)
101469 + return false;
101470 +
101471 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
101472 + return false;
101473 +
101474 + def_stmt = get_def_stmt(rhs);
101475 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
101476 + return false;
101477 +
101478 + return true;
101479 +}
101480 +
101481 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
101482 +{
101483 + tree rhs1, rhs2, new_lhs;
101484 + gimple def_stmt = get_def_stmt(lhs);
101485 + tree new_rhs1 = NULL_TREE;
101486 + tree new_rhs2 = NULL_TREE;
101487 +
101488 + rhs1 = gimple_assign_rhs1(def_stmt);
101489 + rhs2 = gimple_assign_rhs2(def_stmt);
101490 +
101491 + /* no DImode/TImode division in the 32/64 bit kernel */
101492 + switch (gimple_assign_rhs_code(def_stmt)) {
101493 + case RDIV_EXPR:
101494 + case TRUNC_DIV_EXPR:
101495 + case CEIL_DIV_EXPR:
101496 + case FLOOR_DIV_EXPR:
101497 + case ROUND_DIV_EXPR:
101498 + case TRUNC_MOD_EXPR:
101499 + case CEIL_MOD_EXPR:
101500 + case FLOOR_MOD_EXPR:
101501 + case ROUND_MOD_EXPR:
101502 + case EXACT_DIV_EXPR:
101503 + case POINTER_PLUS_EXPR:
101504 + case BIT_AND_EXPR:
101505 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101506 + default:
101507 + break;
101508 + }
101509 +
101510 + new_lhs = handle_integer_truncation(visited, lhs);
101511 + if (new_lhs != NULL_TREE)
101512 + return new_lhs;
101513 +
101514 + if (TREE_CODE(rhs1) == SSA_NAME)
101515 + new_rhs1 = expand(visited, rhs1);
101516 + if (TREE_CODE(rhs2) == SSA_NAME)
101517 + new_rhs2 = expand(visited, rhs2);
101518 +
101519 + if (is_a_neg_overflow(def_stmt, rhs2))
101520 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
101521 + if (is_a_neg_overflow(def_stmt, rhs1))
101522 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
101523 +
101524 +
101525 + if (is_a_constant_overflow(def_stmt, rhs2))
101526 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
101527 + if (is_a_constant_overflow(def_stmt, rhs1))
101528 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
101529 +
101530 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
101531 +}
101532 +
101533 +#if BUILDING_GCC_VERSION >= 4007
101534 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
101535 +{
101536 + if (is_gimple_constant(rhs))
101537 + return cast_a_tree(size_overflow_type, rhs);
101538 + if (TREE_CODE(rhs) != SSA_NAME)
101539 + return NULL_TREE;
101540 + return expand(visited, rhs);
101541 +}
101542 +
101543 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
101544 +{
101545 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
101546 + gimple def_stmt = get_def_stmt(lhs);
101547 +
101548 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
101549 +
101550 + rhs1 = gimple_assign_rhs1(def_stmt);
101551 + rhs2 = gimple_assign_rhs2(def_stmt);
101552 + rhs3 = gimple_assign_rhs3(def_stmt);
101553 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
101554 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
101555 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
101556 +
101557 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
101558 +}
101559 +#endif
101560 +
101561 +static tree get_size_overflow_type(gimple stmt, const_tree node)
101562 +{
101563 + const_tree type;
101564 + tree new_type;
101565 +
101566 + gcc_assert(node != NULL_TREE);
101567 +
101568 + type = TREE_TYPE(node);
101569 +
101570 + if (gimple_plf(stmt, MY_STMT))
101571 + return TREE_TYPE(node);
101572 +
101573 + switch (TYPE_MODE(type)) {
101574 + case QImode:
101575 + new_type = intHI_type_node;
101576 + break;
101577 + case HImode:
101578 + new_type = intSI_type_node;
101579 + break;
101580 + case SImode:
101581 + new_type = intDI_type_node;
101582 + break;
101583 + case DImode:
101584 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101585 + new_type = intDI_type_node;
101586 + else
101587 + new_type = intTI_type_node;
101588 + break;
101589 + default:
101590 + debug_tree((tree)node);
101591 + error("%s: unsupported gcc configuration.", __func__);
101592 + gcc_unreachable();
101593 + }
101594 +
101595 + if (TYPE_QUALS(type) != 0)
101596 + return build_qualified_type(new_type, TYPE_QUALS(type));
101597 + return new_type;
101598 +}
101599 +
101600 +static tree expand_visited(gimple def_stmt)
101601 +{
101602 + const_gimple next_stmt;
101603 + gimple_stmt_iterator gsi;
101604 + enum gimple_code code = gimple_code(def_stmt);
101605 +
101606 + if (code == GIMPLE_ASM)
101607 + return NULL_TREE;
101608 +
101609 + gsi = gsi_for_stmt(def_stmt);
101610 + gsi_next(&gsi);
101611 +
101612 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
101613 + return NULL_TREE;
101614 + gcc_assert(!gsi_end_p(gsi));
101615 + next_stmt = gsi_stmt(gsi);
101616 +
101617 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
101618 + return NULL_TREE;
101619 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
101620 +
101621 + return get_lhs(next_stmt);
101622 +}
101623 +
101624 +static tree expand(struct pointer_set_t *visited, tree lhs)
101625 +{
101626 + gimple def_stmt;
101627 +
101628 + if (skip_types(lhs))
101629 + return NULL_TREE;
101630 +
101631 + def_stmt = get_def_stmt(lhs);
101632 +
101633 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101634 + return NULL_TREE;
101635 +
101636 + if (gimple_plf(def_stmt, MY_STMT))
101637 + return lhs;
101638 +
101639 + if (pointer_set_contains(visited, def_stmt))
101640 + return expand_visited(def_stmt);
101641 +
101642 + switch (gimple_code(def_stmt)) {
101643 + case GIMPLE_PHI:
101644 + return handle_phi(visited, lhs);
101645 + case GIMPLE_CALL:
101646 + case GIMPLE_ASM:
101647 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101648 + case GIMPLE_ASSIGN:
101649 + switch (gimple_num_ops(def_stmt)) {
101650 + case 2:
101651 + return handle_unary_ops(visited, def_stmt);
101652 + case 3:
101653 + return handle_binary_ops(visited, lhs);
101654 +#if BUILDING_GCC_VERSION >= 4007
101655 + case 4:
101656 + return handle_ternary_ops(visited, lhs);
101657 +#endif
101658 + }
101659 + default:
101660 + debug_gimple_stmt(def_stmt);
101661 + error("%s: unknown gimple code", __func__);
101662 + gcc_unreachable();
101663 + }
101664 +}
101665 +
101666 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
101667 +{
101668 + const_gimple assign;
101669 + tree orig_type = TREE_TYPE(orig_node);
101670 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101671 +
101672 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101673 + return gimple_get_lhs(assign);
101674 +}
101675 +
101676 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
101677 +{
101678 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
101679 + update_stmt(stmt);
101680 +}
101681 +
101682 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
101683 +{
101684 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
101685 + update_stmt(stmt);
101686 +}
101687 +
101688 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
101689 +{
101690 + tree arg;
101691 + const_tree origarg;
101692 +
101693 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
101694 + return true;
101695 +
101696 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
101697 + while (origarg && *argnum) {
101698 + (*argnum)--;
101699 + origarg = TREE_CHAIN(origarg);
101700 + }
101701 +
101702 + gcc_assert(*argnum == 0);
101703 +
101704 + gcc_assert(origarg != NULL_TREE);
101705 + *argnum = 0;
101706 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
101707 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
101708 + return true;
101709 + return false;
101710 +}
101711 +
101712 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
101713 +{
101714 + gimple phi = get_def_stmt(result);
101715 + unsigned int i, n = gimple_phi_num_args(phi);
101716 +
101717 + if (!phi)
101718 + return MARK_NO;
101719 +
101720 + pointer_set_insert(visited, phi);
101721 + for (i = 0; i < n; i++) {
101722 + enum mark marked;
101723 + const_tree arg = gimple_phi_arg_def(phi, i);
101724 + marked = pre_expand(visited, search_err_code, arg);
101725 + if (marked != MARK_NO)
101726 + return marked;
101727 + }
101728 + return MARK_NO;
101729 +}
101730 +
101731 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101732 +{
101733 + gimple def_stmt = get_def_stmt(lhs);
101734 + const_tree rhs;
101735 +
101736 + if (!def_stmt)
101737 + return MARK_NO;
101738 +
101739 + rhs = gimple_assign_rhs1(def_stmt);
101740 +
101741 + def_stmt = get_def_stmt(rhs);
101742 + if (is_gimple_constant(rhs))
101743 + search_err_code[FROM_CONST] = true;
101744 +
101745 + return pre_expand(visited, search_err_code, rhs);
101746 +}
101747 +
101748 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101749 +{
101750 + gimple def_stmt = get_def_stmt(lhs);
101751 + const_tree rhs1, rhs2;
101752 + enum mark marked;
101753 +
101754 + if (!def_stmt)
101755 + return MARK_NO;
101756 +
101757 + search_err_code[CAST_ONLY] = false;
101758 +
101759 + rhs1 = gimple_assign_rhs1(def_stmt);
101760 + rhs2 = gimple_assign_rhs2(def_stmt);
101761 + marked = pre_expand(visited, search_err_code, rhs1);
101762 + if (marked != MARK_NO)
101763 + return marked;
101764 + return pre_expand(visited, search_err_code, rhs2);
101765 +}
101766 +
101767 +static const_tree search_field_decl(const_tree comp_ref)
101768 +{
101769 + const_tree field = NULL_TREE;
101770 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
101771 +
101772 + for (i = 0; i < len; i++) {
101773 + field = TREE_OPERAND(comp_ref, i);
101774 + if (TREE_CODE(field) == FIELD_DECL)
101775 + break;
101776 + }
101777 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
101778 + return field;
101779 +}
101780 +
101781 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
101782 +{
101783 + const_tree attr, p;
101784 +
101785 + // 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);
101786 + if (fndecl == NULL_TREE)
101787 + return MARK_NO;
101788 +
101789 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
101790 + if (!attr || !TREE_VALUE(attr))
101791 + return MARK_NO;
101792 +
101793 + p = TREE_VALUE(attr);
101794 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
101795 + return MARK_TURN_OFF;
101796 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
101797 + return MARK_NOT_INTENTIONAL;
101798 + if (argnum == 0) {
101799 + gcc_assert(current_function_decl == fndecl);
101800 + return MARK_NO;
101801 + }
101802 +
101803 + do {
101804 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
101805 + return MARK_YES;
101806 + p = TREE_CHAIN(p);
101807 + } while (p);
101808 +
101809 + return MARK_NO;
101810 +}
101811 +
101812 +static void print_missing_msg(tree func, unsigned int argnum)
101813 +{
101814 + unsigned int new_hash;
101815 + size_t len;
101816 + unsigned char tree_codes[CODES_LIMIT];
101817 + location_t loc;
101818 + const char *curfunc;
101819 +
101820 + func = get_original_function_decl(func);
101821 + loc = DECL_SOURCE_LOCATION(func);
101822 + curfunc = get_asm_name(func);
101823 +
101824 + len = get_function_decl(func, tree_codes);
101825 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
101826 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
101827 +}
101828 +
101829 +static unsigned int search_missing_attribute(const_tree arg)
101830 +{
101831 + unsigned int argnum;
101832 + const struct size_overflow_hash *hash;
101833 + const_tree type = TREE_TYPE(arg);
101834 + tree func = get_original_function_decl(current_function_decl);
101835 +
101836 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
101837 +
101838 + if (TREE_CODE(type) == POINTER_TYPE)
101839 + return 0;
101840 +
101841 + argnum = find_arg_number(arg, func);
101842 + if (argnum == 0)
101843 + return 0;
101844 +
101845 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
101846 + return argnum;
101847 +
101848 + hash = get_function_hash(func);
101849 + if (!hash || !(hash->param & (1U << argnum))) {
101850 + print_missing_msg(func, argnum);
101851 + return 0;
101852 + }
101853 + return argnum;
101854 +}
101855 +
101856 +static enum mark is_already_marked(const_tree lhs)
101857 +{
101858 + unsigned int argnum;
101859 + const_tree fndecl;
101860 +
101861 + argnum = search_missing_attribute(lhs);
101862 + fndecl = get_original_function_decl(current_function_decl);
101863 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
101864 + return MARK_YES;
101865 + return MARK_NO;
101866 +}
101867 +
101868 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101869 +{
101870 + const_gimple def_stmt;
101871 +
101872 + if (skip_types(lhs))
101873 + return MARK_NO;
101874 +
101875 + if (TREE_CODE(lhs) == PARM_DECL)
101876 + return is_already_marked(lhs);
101877 +
101878 + if (TREE_CODE(lhs) == COMPONENT_REF) {
101879 + const_tree field, attr;
101880 +
101881 + field = search_field_decl(lhs);
101882 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
101883 + if (!attr || !TREE_VALUE(attr))
101884 + return MARK_NO;
101885 + return MARK_YES;
101886 + }
101887 +
101888 + def_stmt = get_def_stmt(lhs);
101889 +
101890 + if (!def_stmt)
101891 + return MARK_NO;
101892 +
101893 + if (pointer_set_contains(visited, def_stmt))
101894 + return MARK_NO;
101895 +
101896 + switch (gimple_code(def_stmt)) {
101897 + case GIMPLE_NOP:
101898 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
101899 + return is_already_marked(lhs);
101900 + return MARK_NO;
101901 + case GIMPLE_PHI:
101902 + return walk_phi(visited, search_err_code, lhs);
101903 + case GIMPLE_CALL:
101904 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
101905 + return MARK_TURN_OFF;
101906 + check_function_hash(def_stmt);
101907 + return MARK_NO;
101908 + case GIMPLE_ASM:
101909 + search_err_code[CAST_ONLY] = false;
101910 + return MARK_NO;
101911 + case GIMPLE_ASSIGN:
101912 + switch (gimple_num_ops(def_stmt)) {
101913 + case 2:
101914 + return walk_unary_ops(visited, search_err_code, lhs);
101915 + case 3:
101916 + return walk_binary_ops(visited, search_err_code, lhs);
101917 + }
101918 + default:
101919 + debug_gimple_stmt((gimple)def_stmt);
101920 + error("%s: unknown gimple code", __func__);
101921 + gcc_unreachable();
101922 + }
101923 +}
101924 +
101925 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
101926 +static bool skip_asm(const_tree arg)
101927 +{
101928 + gimple def_stmt = get_def_stmt(arg);
101929 +
101930 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
101931 + return false;
101932 +
101933 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
101934 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
101935 +}
101936 +
101937 +/*
101938 +0</MARK_YES: no dup, search attributes (so, int)
101939 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
101940 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
101941 +*/
101942 +
101943 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
101944 +{
101945 + struct pointer_set_t *visited;
101946 + enum mark is_marked, is_found;
101947 + location_t loc;
101948 + bool search_err_code[2] = {true, false};
101949 +
101950 + is_marked = mark_status(current_function_decl, 0);
101951 + if (is_marked == MARK_TURN_OFF)
101952 + return true;
101953 +
101954 + is_marked = mark_status(fndecl, argnum + 1);
101955 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
101956 + return true;
101957 +
101958 + visited = pointer_set_create();
101959 + is_found = pre_expand(visited, search_err_code, arg);
101960 + pointer_set_destroy(visited);
101961 +
101962 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
101963 + return true;
101964 +
101965 + if (where == FROM_ARG && skip_asm(arg))
101966 + return true;
101967 +
101968 + if (is_found == MARK_TURN_OFF)
101969 + return true;
101970 +
101971 + if ((is_found == MARK_YES && is_marked == MARK_YES))
101972 + return true;
101973 +
101974 + if (is_found == MARK_YES) {
101975 + loc = DECL_SOURCE_LOCATION(fndecl);
101976 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
101977 + return true;
101978 + }
101979 + return false;
101980 +}
101981 +
101982 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
101983 +{
101984 + struct pointer_set_t *visited;
101985 + tree arg, new_arg;
101986 + bool match;
101987 +
101988 + if (argnum == 0)
101989 + return;
101990 +
101991 + argnum--;
101992 +
101993 + match = get_function_arg(&argnum, fndecl);
101994 + if (!match)
101995 + return;
101996 + gcc_assert(gimple_call_num_args(stmt) > argnum);
101997 + arg = gimple_call_arg(stmt, argnum);
101998 + if (arg == NULL_TREE)
101999 + return;
102000 +
102001 + if (skip_types(arg))
102002 + return;
102003 +
102004 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
102005 + return;
102006 +
102007 + visited = pointer_set_create();
102008 + new_arg = expand(visited, arg);
102009 + pointer_set_destroy(visited);
102010 +
102011 + if (new_arg == NULL_TREE)
102012 + return;
102013 +
102014 + change_function_arg(stmt, arg, argnum, new_arg);
102015 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
102016 +}
102017 +
102018 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
102019 +{
102020 + tree p = TREE_VALUE(attr);
102021 + do {
102022 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
102023 + p = TREE_CHAIN(p);
102024 + } while (p);
102025 +}
102026 +
102027 +static void handle_function_by_hash(gimple stmt, tree fndecl)
102028 +{
102029 + unsigned int num;
102030 + const struct size_overflow_hash *hash;
102031 +
102032 + hash = get_function_hash(fndecl);
102033 + if (!hash)
102034 + return;
102035 +
102036 + for (num = 0; num <= MAX_PARAM; num++)
102037 + if (hash->param & (1U << num))
102038 + handle_function_arg(stmt, fndecl, num);
102039 +}
102040 +
102041 +static bool check_return_value(void)
102042 +{
102043 + const struct size_overflow_hash *hash;
102044 +
102045 + hash = get_function_hash(current_function_decl);
102046 + if (!hash || !(hash->param & 1U << 0))
102047 + return false;
102048 +
102049 + return true;
102050 +}
102051 +
102052 +static void handle_return_value(gimple ret_stmt)
102053 +{
102054 + struct pointer_set_t *visited;
102055 + tree ret, new_ret;
102056 +
102057 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
102058 + return;
102059 +
102060 + ret = gimple_return_retval(ret_stmt);
102061 +
102062 + if (skip_types(ret))
102063 + return;
102064 +
102065 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
102066 + return;
102067 +
102068 + visited = pointer_set_create();
102069 + new_ret = expand(visited, ret);
102070 + pointer_set_destroy(visited);
102071 +
102072 + change_function_return(ret_stmt, ret, new_ret);
102073 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
102074 +}
102075 +
102076 +static void set_plf_false(void)
102077 +{
102078 + basic_block bb;
102079 +
102080 + FOR_ALL_BB(bb) {
102081 + gimple_stmt_iterator si;
102082 +
102083 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
102084 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102085 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
102086 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
102087 + }
102088 +}
102089 +
102090 +static unsigned int handle_function(void)
102091 +{
102092 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
102093 + bool check_ret;
102094 +
102095 + set_plf_false();
102096 +
102097 + check_ret = check_return_value();
102098 +
102099 + do {
102100 + gimple_stmt_iterator gsi;
102101 + next = bb->next_bb;
102102 +
102103 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102104 + tree fndecl, attr;
102105 + gimple stmt = gsi_stmt(gsi);
102106 +
102107 + if (check_ret)
102108 + handle_return_value(stmt);
102109 +
102110 + if (!(is_gimple_call(stmt)))
102111 + continue;
102112 + fndecl = gimple_call_fndecl(stmt);
102113 + if (fndecl == NULL_TREE)
102114 + continue;
102115 + if (gimple_call_num_args(stmt) == 0)
102116 + continue;
102117 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
102118 + if (!attr || !TREE_VALUE(attr))
102119 + handle_function_by_hash(stmt, fndecl);
102120 + else
102121 + handle_function_by_attribute(stmt, attr, fndecl);
102122 + gsi = gsi_for_stmt(stmt);
102123 + next = gimple_bb(stmt)->next_bb;
102124 + }
102125 + bb = next;
102126 + } while (bb);
102127 + return 0;
102128 +}
102129 +
102130 +static struct gimple_opt_pass size_overflow_pass = {
102131 + .pass = {
102132 + .type = GIMPLE_PASS,
102133 + .name = "size_overflow",
102134 +#if BUILDING_GCC_VERSION >= 4008
102135 + .optinfo_flags = OPTGROUP_NONE,
102136 +#endif
102137 + .gate = NULL,
102138 + .execute = handle_function,
102139 + .sub = NULL,
102140 + .next = NULL,
102141 + .static_pass_number = 0,
102142 + .tv_id = TV_NONE,
102143 + .properties_required = PROP_cfg,
102144 + .properties_provided = 0,
102145 + .properties_destroyed = 0,
102146 + .todo_flags_start = 0,
102147 + .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
102148 + }
102149 +};
102150 +
102151 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
102152 +{
102153 + tree fntype;
102154 +
102155 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
102156 +
102157 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
102158 + fntype = build_function_type_list(void_type_node,
102159 + const_char_ptr_type_node,
102160 + unsigned_type_node,
102161 + const_char_ptr_type_node,
102162 + const_char_ptr_type_node,
102163 + NULL_TREE);
102164 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
102165 +
102166 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
102167 + TREE_PUBLIC(report_size_overflow_decl) = 1;
102168 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
102169 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
102170 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
102171 +}
102172 +
102173 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102174 +{
102175 + int i;
102176 + const char * const plugin_name = plugin_info->base_name;
102177 + const int argc = plugin_info->argc;
102178 + const struct plugin_argument * const argv = plugin_info->argv;
102179 + bool enable = true;
102180 +
102181 + struct register_pass_info size_overflow_pass_info = {
102182 + .pass = &size_overflow_pass.pass,
102183 + .reference_pass_name = "ssa",
102184 + .ref_pass_instance_number = 1,
102185 + .pos_op = PASS_POS_INSERT_AFTER
102186 + };
102187 +
102188 + if (!plugin_default_version_check(version, &gcc_version)) {
102189 + error(G_("incompatible gcc/plugin versions"));
102190 + return 1;
102191 + }
102192 +
102193 + for (i = 0; i < argc; ++i) {
102194 + if (!strcmp(argv[i].key, "no-size-overflow")) {
102195 + enable = false;
102196 + continue;
102197 + }
102198 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102199 + }
102200 +
102201 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
102202 + if (enable) {
102203 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102204 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
102205 + }
102206 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102207 +
102208 + return 0;
102209 +}
102210 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
102211 new file mode 100644
102212 index 0000000..ac2901e
102213 --- /dev/null
102214 +++ b/tools/gcc/stackleak_plugin.c
102215 @@ -0,0 +1,327 @@
102216 +/*
102217 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102218 + * Licensed under the GPL v2
102219 + *
102220 + * Note: the choice of the license means that the compilation process is
102221 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102222 + * but for the kernel it doesn't matter since it doesn't link against
102223 + * any of the gcc libraries
102224 + *
102225 + * gcc plugin to help implement various PaX features
102226 + *
102227 + * - track lowest stack pointer
102228 + *
102229 + * TODO:
102230 + * - initialize all local variables
102231 + *
102232 + * BUGS:
102233 + * - none known
102234 + */
102235 +#include "gcc-plugin.h"
102236 +#include "config.h"
102237 +#include "system.h"
102238 +#include "coretypes.h"
102239 +#include "tree.h"
102240 +#include "tree-pass.h"
102241 +#include "flags.h"
102242 +#include "intl.h"
102243 +#include "toplev.h"
102244 +#include "plugin.h"
102245 +//#include "expr.h" where are you...
102246 +#include "diagnostic.h"
102247 +#include "plugin-version.h"
102248 +#include "tm.h"
102249 +#include "function.h"
102250 +#include "basic-block.h"
102251 +#include "gimple.h"
102252 +#include "rtl.h"
102253 +#include "emit-rtl.h"
102254 +
102255 +#if BUILDING_GCC_VERSION >= 4008
102256 +#define TODO_dump_func 0
102257 +#endif
102258 +
102259 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102260 +
102261 +int plugin_is_GPL_compatible;
102262 +
102263 +static int track_frame_size = -1;
102264 +static const char track_function[] = "pax_track_stack";
102265 +static const char check_function[] = "pax_check_alloca";
102266 +static bool init_locals;
102267 +
102268 +static struct plugin_info stackleak_plugin_info = {
102269 + .version = "201302112000",
102270 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
102271 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
102272 +};
102273 +
102274 +static bool gate_stackleak_track_stack(void);
102275 +static unsigned int execute_stackleak_tree_instrument(void);
102276 +static unsigned int execute_stackleak_final(void);
102277 +
102278 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
102279 + .pass = {
102280 + .type = GIMPLE_PASS,
102281 + .name = "stackleak_tree_instrument",
102282 +#if BUILDING_GCC_VERSION >= 4008
102283 + .optinfo_flags = OPTGROUP_NONE,
102284 +#endif
102285 + .gate = gate_stackleak_track_stack,
102286 + .execute = execute_stackleak_tree_instrument,
102287 + .sub = NULL,
102288 + .next = NULL,
102289 + .static_pass_number = 0,
102290 + .tv_id = TV_NONE,
102291 + .properties_required = PROP_gimple_leh | PROP_cfg,
102292 + .properties_provided = 0,
102293 + .properties_destroyed = 0,
102294 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
102295 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
102296 + }
102297 +};
102298 +
102299 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
102300 + .pass = {
102301 + .type = RTL_PASS,
102302 + .name = "stackleak_final",
102303 +#if BUILDING_GCC_VERSION >= 4008
102304 + .optinfo_flags = OPTGROUP_NONE,
102305 +#endif
102306 + .gate = gate_stackleak_track_stack,
102307 + .execute = execute_stackleak_final,
102308 + .sub = NULL,
102309 + .next = NULL,
102310 + .static_pass_number = 0,
102311 + .tv_id = TV_NONE,
102312 + .properties_required = 0,
102313 + .properties_provided = 0,
102314 + .properties_destroyed = 0,
102315 + .todo_flags_start = 0,
102316 + .todo_flags_finish = TODO_dump_func
102317 + }
102318 +};
102319 +
102320 +static bool gate_stackleak_track_stack(void)
102321 +{
102322 + return track_frame_size >= 0;
102323 +}
102324 +
102325 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
102326 +{
102327 + gimple check_alloca;
102328 + tree fntype, fndecl, alloca_size;
102329 +
102330 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
102331 + fndecl = build_fn_decl(check_function, fntype);
102332 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
102333 +
102334 + // insert call to void pax_check_alloca(unsigned long size)
102335 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
102336 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
102337 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
102338 +}
102339 +
102340 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
102341 +{
102342 + gimple track_stack;
102343 + tree fntype, fndecl;
102344 +
102345 + fntype = build_function_type_list(void_type_node, NULL_TREE);
102346 + fndecl = build_fn_decl(track_function, fntype);
102347 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
102348 +
102349 + // insert call to void pax_track_stack(void)
102350 + track_stack = gimple_build_call(fndecl, 0);
102351 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
102352 +}
102353 +
102354 +#if BUILDING_GCC_VERSION == 4005
102355 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
102356 +{
102357 + tree fndecl;
102358 +
102359 + if (!is_gimple_call(stmt))
102360 + return false;
102361 + fndecl = gimple_call_fndecl(stmt);
102362 + if (!fndecl)
102363 + return false;
102364 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
102365 + return false;
102366 +// print_node(stderr, "pax", fndecl, 4);
102367 + return DECL_FUNCTION_CODE(fndecl) == code;
102368 +}
102369 +#endif
102370 +
102371 +static bool is_alloca(gimple stmt)
102372 +{
102373 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
102374 + return true;
102375 +
102376 +#if BUILDING_GCC_VERSION >= 4007
102377 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
102378 + return true;
102379 +#endif
102380 +
102381 + return false;
102382 +}
102383 +
102384 +static unsigned int execute_stackleak_tree_instrument(void)
102385 +{
102386 + basic_block bb, entry_bb;
102387 + bool prologue_instrumented = false, is_leaf = true;
102388 +
102389 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
102390 +
102391 + // 1. loop through BBs and GIMPLE statements
102392 + FOR_EACH_BB(bb) {
102393 + gimple_stmt_iterator gsi;
102394 +
102395 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102396 + gimple stmt;
102397 +
102398 + stmt = gsi_stmt(gsi);
102399 +
102400 + if (is_gimple_call(stmt))
102401 + is_leaf = false;
102402 +
102403 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
102404 + if (!is_alloca(stmt))
102405 + continue;
102406 +
102407 + // 2. insert stack overflow check before each __builtin_alloca call
102408 + stackleak_check_alloca(&gsi);
102409 +
102410 + // 3. insert track call after each __builtin_alloca call
102411 + stackleak_add_instrumentation(&gsi);
102412 + if (bb == entry_bb)
102413 + prologue_instrumented = true;
102414 + }
102415 + }
102416 +
102417 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
102418 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
102419 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
102420 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
102421 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
102422 + return 0;
102423 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
102424 + return 0;
102425 +
102426 + // 4. insert track call at the beginning
102427 + if (!prologue_instrumented) {
102428 + gimple_stmt_iterator gsi;
102429 +
102430 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102431 + if (dom_info_available_p(CDI_DOMINATORS))
102432 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102433 + gsi = gsi_start_bb(bb);
102434 + stackleak_add_instrumentation(&gsi);
102435 + }
102436 +
102437 + return 0;
102438 +}
102439 +
102440 +static unsigned int execute_stackleak_final(void)
102441 +{
102442 + rtx insn, next;
102443 +
102444 + if (cfun->calls_alloca)
102445 + return 0;
102446 +
102447 + // keep calls only if function frame is big enough
102448 + if (get_frame_size() >= track_frame_size)
102449 + return 0;
102450 +
102451 + // 1. find pax_track_stack calls
102452 + for (insn = get_insns(); insn; insn = next) {
102453 + // 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))
102454 + rtx body;
102455 +
102456 + next = NEXT_INSN(insn);
102457 + if (!CALL_P(insn))
102458 + continue;
102459 + body = PATTERN(insn);
102460 + if (GET_CODE(body) != CALL)
102461 + continue;
102462 + body = XEXP(body, 0);
102463 + if (GET_CODE(body) != MEM)
102464 + continue;
102465 + body = XEXP(body, 0);
102466 + if (GET_CODE(body) != SYMBOL_REF)
102467 + continue;
102468 + if (strcmp(XSTR(body, 0), track_function))
102469 + continue;
102470 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
102471 + // 2. delete call
102472 + delete_insn_and_edges(insn);
102473 +#if BUILDING_GCC_VERSION >= 4007
102474 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
102475 + insn = next;
102476 + next = NEXT_INSN(insn);
102477 + delete_insn_and_edges(insn);
102478 + }
102479 +#endif
102480 + }
102481 +
102482 +// print_simple_rtl(stderr, get_insns());
102483 +// print_rtl(stderr, get_insns());
102484 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
102485 +
102486 + return 0;
102487 +}
102488 +
102489 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102490 +{
102491 + const char * const plugin_name = plugin_info->base_name;
102492 + const int argc = plugin_info->argc;
102493 + const struct plugin_argument * const argv = plugin_info->argv;
102494 + int i;
102495 + struct register_pass_info stackleak_tree_instrument_pass_info = {
102496 + .pass = &stackleak_tree_instrument_pass.pass,
102497 +// .reference_pass_name = "tree_profile",
102498 + .reference_pass_name = "optimized",
102499 + .ref_pass_instance_number = 1,
102500 + .pos_op = PASS_POS_INSERT_BEFORE
102501 + };
102502 + struct register_pass_info stackleak_final_pass_info = {
102503 + .pass = &stackleak_final_rtl_opt_pass.pass,
102504 + .reference_pass_name = "final",
102505 + .ref_pass_instance_number = 1,
102506 + .pos_op = PASS_POS_INSERT_BEFORE
102507 + };
102508 +
102509 + if (!plugin_default_version_check(version, &gcc_version)) {
102510 + error(G_("incompatible gcc/plugin versions"));
102511 + return 1;
102512 + }
102513 +
102514 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
102515 +
102516 + for (i = 0; i < argc; ++i) {
102517 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
102518 + if (!argv[i].value) {
102519 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102520 + continue;
102521 + }
102522 + track_frame_size = atoi(argv[i].value);
102523 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
102524 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102525 + continue;
102526 + }
102527 + if (!strcmp(argv[i].key, "initialize-locals")) {
102528 + if (argv[i].value) {
102529 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102530 + continue;
102531 + }
102532 + init_locals = true;
102533 + continue;
102534 + }
102535 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102536 + }
102537 +
102538 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
102539 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
102540 +
102541 + return 0;
102542 +}
102543 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
102544 new file mode 100644
102545 index 0000000..77a6b1d
102546 --- /dev/null
102547 +++ b/tools/gcc/structleak_plugin.c
102548 @@ -0,0 +1,270 @@
102549 +/*
102550 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
102551 + * Licensed under the GPL v2
102552 + *
102553 + * Note: the choice of the license means that the compilation process is
102554 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102555 + * but for the kernel it doesn't matter since it doesn't link against
102556 + * any of the gcc libraries
102557 + *
102558 + * gcc plugin to forcibly initialize certain local variables that could
102559 + * otherwise leak kernel stack to userland if they aren't properly initialized
102560 + * by later code
102561 + *
102562 + * Homepage: http://pax.grsecurity.net/
102563 + *
102564 + * Usage:
102565 + * $ # for 4.5/4.6/C based 4.7
102566 + * $ 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
102567 + * $ # for C++ based 4.7/4.8+
102568 + * $ 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
102569 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
102570 + *
102571 + * TODO: eliminate redundant initializers
102572 + * increase type coverage
102573 + */
102574 +
102575 +#include "gcc-plugin.h"
102576 +#include "config.h"
102577 +#include "system.h"
102578 +#include "coretypes.h"
102579 +#include "tree.h"
102580 +#include "tree-pass.h"
102581 +#include "intl.h"
102582 +#include "plugin-version.h"
102583 +#include "tm.h"
102584 +#include "toplev.h"
102585 +#include "function.h"
102586 +#include "tree-flow.h"
102587 +#include "plugin.h"
102588 +#include "gimple.h"
102589 +#include "diagnostic.h"
102590 +#include "cfgloop.h"
102591 +#include "langhooks.h"
102592 +
102593 +#if BUILDING_GCC_VERSION >= 4008
102594 +#define TODO_dump_func 0
102595 +#endif
102596 +
102597 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
102598 +
102599 +// unused type flag in all versions 4.5-4.8
102600 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
102601 +
102602 +int plugin_is_GPL_compatible;
102603 +void debug_gimple_stmt(gimple gs);
102604 +
102605 +static struct plugin_info structleak_plugin_info = {
102606 + .version = "201303270300",
102607 + .help = "disable\tdo not activate plugin\n",
102608 +};
102609 +
102610 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
102611 +{
102612 + *no_add_attrs = true;
102613 +
102614 + // check for types? for now accept everything linux has to offer
102615 + if (TREE_CODE(*node) != FIELD_DECL)
102616 + return NULL_TREE;
102617 +
102618 + *no_add_attrs = false;
102619 + return NULL_TREE;
102620 +}
102621 +
102622 +static struct attribute_spec user_attr = {
102623 + .name = "user",
102624 + .min_length = 0,
102625 + .max_length = 0,
102626 + .decl_required = false,
102627 + .type_required = false,
102628 + .function_type_required = false,
102629 + .handler = handle_user_attribute,
102630 +#if BUILDING_GCC_VERSION >= 4007
102631 + .affects_type_identity = true
102632 +#endif
102633 +};
102634 +
102635 +static void register_attributes(void *event_data, void *data)
102636 +{
102637 + register_attribute(&user_attr);
102638 +// register_attribute(&force_attr);
102639 +}
102640 +
102641 +static tree get_field_type(tree field)
102642 +{
102643 + return strip_array_types(TREE_TYPE(field));
102644 +}
102645 +
102646 +static bool is_userspace_type(tree type)
102647 +{
102648 + tree field;
102649 +
102650 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
102651 + tree fieldtype = get_field_type(field);
102652 + enum tree_code code = TREE_CODE(fieldtype);
102653 +
102654 + if (code == RECORD_TYPE || code == UNION_TYPE)
102655 + if (is_userspace_type(fieldtype))
102656 + return true;
102657 +
102658 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
102659 + return true;
102660 + }
102661 + return false;
102662 +}
102663 +
102664 +static void finish_type(void *event_data, void *data)
102665 +{
102666 + tree type = (tree)event_data;
102667 +
102668 + if (TYPE_USERSPACE(type))
102669 + return;
102670 +
102671 + if (is_userspace_type(type))
102672 + TYPE_USERSPACE(type) = 1;
102673 +}
102674 +
102675 +static void initialize(tree var)
102676 +{
102677 + basic_block bb;
102678 + gimple_stmt_iterator gsi;
102679 + tree initializer;
102680 + gimple init_stmt;
102681 +
102682 + // this is the original entry bb before the forced split
102683 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
102684 +
102685 + // first check if the variable is already initialized, warn otherwise
102686 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102687 + gimple stmt = gsi_stmt(gsi);
102688 +
102689 + // we're looking for an assignment...
102690 + if (!(is_gimple_assign(stmt)))
102691 + continue;
102692 + // ... of a single rhs (unary op)...
102693 + if (gimple_num_ops(stmt) != 2)
102694 + continue;
102695 + // ... to our variable...
102696 + if (gimple_get_lhs(stmt) != var)
102697 + continue;
102698 + // if it's an initializer then we're good
102699 + if (TREE_CODE(gimple_assign_rhs1(stmt)) == CONSTRUCTOR)
102700 + return;
102701 + }
102702 +
102703 + // build the initializer expression
102704 + initializer = make_node(CONSTRUCTOR);
102705 + TREE_TYPE(initializer) = TREE_TYPE(var);
102706 +
102707 + // build the initializer stmt
102708 + init_stmt = gimple_build_assign(var, initializer);
102709 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
102710 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
102711 + update_stmt(init_stmt);
102712 +}
102713 +
102714 +static unsigned int handle_function(void)
102715 +{
102716 + basic_block bb;
102717 + unsigned int ret = 0;
102718 + tree var;
102719 +
102720 +#if BUILDING_GCC_VERSION == 4005
102721 + tree vars;
102722 +#else
102723 + unsigned int i;
102724 +#endif
102725 +
102726 + // split the first bb where we can put the forced initializers
102727 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102728 + if (dom_info_available_p(CDI_DOMINATORS))
102729 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102730 +
102731 + // enumarate all local variables and forcibly initialize our targets
102732 +#if BUILDING_GCC_VERSION == 4005
102733 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
102734 + var = TREE_VALUE(vars);
102735 +#else
102736 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
102737 +#endif
102738 + tree type = TREE_TYPE(var);
102739 +
102740 + gcc_assert(DECL_P(var));
102741 + if (is_global_var(var))
102742 + continue;
102743 +
102744 + // only care about structure types
102745 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
102746 + continue;
102747 +
102748 + // if the type is of interest, examine the variable
102749 + if (TYPE_USERSPACE(type))
102750 + initialize(var);
102751 + }
102752 +
102753 + return ret;
102754 +}
102755 +
102756 +static struct gimple_opt_pass structleak_pass = {
102757 + .pass = {
102758 + .type = GIMPLE_PASS,
102759 + .name = "structleak",
102760 +#if BUILDING_GCC_VERSION >= 4008
102761 + .optinfo_flags = OPTGROUP_NONE,
102762 +#endif
102763 + .gate = NULL,
102764 + .execute = handle_function,
102765 + .sub = NULL,
102766 + .next = NULL,
102767 + .static_pass_number = 0,
102768 + .tv_id = TV_NONE,
102769 + .properties_required = PROP_cfg,
102770 + .properties_provided = 0,
102771 + .properties_destroyed = 0,
102772 + .todo_flags_start = 0,
102773 + .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
102774 + }
102775 +};
102776 +
102777 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102778 +{
102779 + int i;
102780 + const char * const plugin_name = plugin_info->base_name;
102781 + const int argc = plugin_info->argc;
102782 + const struct plugin_argument * const argv = plugin_info->argv;
102783 + bool enable = true;
102784 +
102785 + struct register_pass_info structleak_pass_info = {
102786 + .pass = &structleak_pass.pass,
102787 + .reference_pass_name = "ssa",
102788 + .ref_pass_instance_number = 1,
102789 + .pos_op = PASS_POS_INSERT_AFTER
102790 + };
102791 +
102792 + if (!plugin_default_version_check(version, &gcc_version)) {
102793 + error(G_("incompatible gcc/plugin versions"));
102794 + return 1;
102795 + }
102796 +
102797 + if (strcmp(lang_hooks.name, "GNU C")) {
102798 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
102799 + enable = false;
102800 + }
102801 +
102802 + for (i = 0; i < argc; ++i) {
102803 + if (!strcmp(argv[i].key, "disable")) {
102804 + enable = false;
102805 + continue;
102806 + }
102807 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102808 + }
102809 +
102810 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
102811 + if (enable) {
102812 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
102813 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
102814 + }
102815 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102816 +
102817 + return 0;
102818 +}
102819 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
102820 index 6789d78..4afd019e 100644
102821 --- a/tools/perf/util/include/asm/alternative-asm.h
102822 +++ b/tools/perf/util/include/asm/alternative-asm.h
102823 @@ -5,4 +5,7 @@
102824
102825 #define altinstruction_entry #
102826
102827 + .macro pax_force_retaddr rip=0, reload=0
102828 + .endm
102829 +
102830 #endif
102831 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
102832 index 96b919d..c49bb74 100644
102833 --- a/tools/perf/util/include/linux/compiler.h
102834 +++ b/tools/perf/util/include/linux/compiler.h
102835 @@ -18,4 +18,12 @@
102836 #define __force
102837 #endif
102838
102839 +#ifndef __size_overflow
102840 +# define __size_overflow(...)
102841 +#endif
102842 +
102843 +#ifndef __intentional_overflow
102844 +# define __intentional_overflow(...)
102845 +#endif
102846 +
102847 #endif
102848 diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
102849 index cfb7e4d..52058f0 100644
102850 --- a/virt/kvm/ioapic.c
102851 +++ b/virt/kvm/ioapic.c
102852 @@ -73,9 +73,12 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
102853 u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
102854 u64 redir_content;
102855
102856 - ASSERT(redir_index < IOAPIC_NUM_PINS);
102857 + if (redir_index < IOAPIC_NUM_PINS)
102858 + redir_content =
102859 + ioapic->redirtbl[redir_index].bits;
102860 + else
102861 + redir_content = ~0ULL;
102862
102863 - redir_content = ioapic->redirtbl[redir_index].bits;
102864 result = (ioapic->ioregsel & 0x1) ?
102865 (redir_content >> 32) & 0xffffffff :
102866 redir_content & 0xffffffff;
102867 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
102868 index 1cd693a..f4a7b20 100644
102869 --- a/virt/kvm/kvm_main.c
102870 +++ b/virt/kvm/kvm_main.c
102871 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
102872
102873 static cpumask_var_t cpus_hardware_enabled;
102874 static int kvm_usage_count = 0;
102875 -static atomic_t hardware_enable_failed;
102876 +static atomic_unchecked_t hardware_enable_failed;
102877
102878 struct kmem_cache *kvm_vcpu_cache;
102879 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
102880
102881 -static __read_mostly struct preempt_ops kvm_preempt_ops;
102882 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
102883 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
102884 +static struct preempt_ops kvm_preempt_ops = {
102885 + .sched_in = kvm_sched_in,
102886 + .sched_out = kvm_sched_out,
102887 +};
102888
102889 struct dentry *kvm_debugfs_dir;
102890
102891 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
102892 /* We can read the guest memory with __xxx_user() later on. */
102893 if (user_alloc &&
102894 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
102895 - !access_ok(VERIFY_WRITE,
102896 + !__access_ok(VERIFY_WRITE,
102897 (void __user *)(unsigned long)mem->userspace_addr,
102898 mem->memory_size)))
102899 goto out;
102900 @@ -1783,7 +1788,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
102901 return 0;
102902 }
102903
102904 -static struct file_operations kvm_vcpu_fops = {
102905 +static file_operations_no_const kvm_vcpu_fops __read_only = {
102906 .release = kvm_vcpu_release,
102907 .unlocked_ioctl = kvm_vcpu_ioctl,
102908 #ifdef CONFIG_COMPAT
102909 @@ -2304,7 +2309,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
102910 return 0;
102911 }
102912
102913 -static struct file_operations kvm_vm_fops = {
102914 +static file_operations_no_const kvm_vm_fops __read_only = {
102915 .release = kvm_vm_release,
102916 .unlocked_ioctl = kvm_vm_ioctl,
102917 #ifdef CONFIG_COMPAT
102918 @@ -2402,7 +2407,7 @@ out:
102919 return r;
102920 }
102921
102922 -static struct file_operations kvm_chardev_ops = {
102923 +static file_operations_no_const kvm_chardev_ops __read_only = {
102924 .unlocked_ioctl = kvm_dev_ioctl,
102925 .compat_ioctl = kvm_dev_ioctl,
102926 .llseek = noop_llseek,
102927 @@ -2428,7 +2433,7 @@ static void hardware_enable_nolock(void *junk)
102928
102929 if (r) {
102930 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
102931 - atomic_inc(&hardware_enable_failed);
102932 + atomic_inc_unchecked(&hardware_enable_failed);
102933 printk(KERN_INFO "kvm: enabling virtualization on "
102934 "CPU%d failed\n", cpu);
102935 }
102936 @@ -2482,10 +2487,10 @@ static int hardware_enable_all(void)
102937
102938 kvm_usage_count++;
102939 if (kvm_usage_count == 1) {
102940 - atomic_set(&hardware_enable_failed, 0);
102941 + atomic_set_unchecked(&hardware_enable_failed, 0);
102942 on_each_cpu(hardware_enable_nolock, NULL, 1);
102943
102944 - if (atomic_read(&hardware_enable_failed)) {
102945 + if (atomic_read_unchecked(&hardware_enable_failed)) {
102946 hardware_disable_all_nolock();
102947 r = -EBUSY;
102948 }
102949 @@ -2843,7 +2848,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
102950 kvm_arch_vcpu_put(vcpu);
102951 }
102952
102953 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102954 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102955 struct module *module)
102956 {
102957 int r;
102958 @@ -2879,7 +2884,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102959 if (!vcpu_align)
102960 vcpu_align = __alignof__(struct kvm_vcpu);
102961 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
102962 - 0, NULL);
102963 + SLAB_USERCOPY, NULL);
102964 if (!kvm_vcpu_cache) {
102965 r = -ENOMEM;
102966 goto out_free_3;
102967 @@ -2889,9 +2894,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102968 if (r)
102969 goto out_free;
102970
102971 + pax_open_kernel();
102972 kvm_chardev_ops.owner = module;
102973 kvm_vm_fops.owner = module;
102974 kvm_vcpu_fops.owner = module;
102975 + pax_close_kernel();
102976
102977 r = misc_register(&kvm_dev);
102978 if (r) {
102979 @@ -2901,9 +2908,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102980
102981 register_syscore_ops(&kvm_syscore_ops);
102982
102983 - kvm_preempt_ops.sched_in = kvm_sched_in;
102984 - kvm_preempt_ops.sched_out = kvm_sched_out;
102985 -
102986 r = kvm_init_debug();
102987 if (r) {
102988 printk(KERN_ERR "kvm: create debugfs files failed\n");